get element names from directory server#1095
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughEnriched parameter variants were introduced across contingency, PCC‑Min, sensitivity, and security domains. Services now enrich fetched ID-only parameters with element names via a directory lookup; UI hooks/components consume enriched types and map enriched form data back to ID-only payloads when calling backend update endpoints. A directory name lookup and PCC‑Min / sensitivity type utilities were added and re-exported. ChangesContingency Table Types & Wiring
PCC‑Min Parameters
Sensitivity Analysis Parameters
Security Analysis Parameters
Directory Service & Utility Re-exports
Sequence Diagram(s)sequenceDiagram
participant UI as Client UI
participant Hook as Form Hook
participant Svc as Service
participant Dir as Directory Service
participant BE as Backend API
UI->>Hook: request load parameters (uuid)
Hook->>Svc: fetchParameters(uuid)
Svc->>BE: GET /parameters/:uuid
BE-->>Svc: returns ID-only parameters
Svc->>Dir: fetchElementNames(setOfIds) (if any)
Dir->>BE: GET /v1/explore/elements/name?ids=...
BE-->>Dir: element id->name map
Dir-->>Svc: element names
Svc-->>Hook: enriched parameters (IDs + names)
Hook-->>UI: reset form with enriched values
UI->>Hook: save form
Hook->>Hook: formatNewParams(formData) -> enriched shape
Hook->>Svc: updateParameter(uuid, mapToIdOnly(enriched))
Svc->>BE: PUT /parameters/:uuid with ID-only payload
BE-->>Svc: ack
Svc-->>Hook: result
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
# Conflicts: # src/components/parameters/common/contingency-table/columns-definitions.ts # src/components/parameters/common/contingency-table/contingency-table.tsx # src/components/parameters/security-analysis/use-security-analysis-parameters-form.ts # src/components/parameters/sensi/use-sensitivity-analysis-parameters.ts # src/utils/types/parameters.type.ts
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/components/parameters/common/contingency-table/contingency-table.tsx (1)
89-93:⚠️ Potential issue | 🟡 Minor
flatMapcallback may returnundefined.
lists[CONTINGENCY_LISTS]?.map(...)can evaluate toundefined, whichflatMaptreats as a single non-array element, yieldingundefinedentries in the resultingUUID[]passed tofetchContingencyCount. SinceCONTINGENCY_LISTSonContingencyListsInfosEnrichedis required (IdName[]), drop the optional chaining, or guard with?? [].🔧 Proposed fix
- .flatMap((lists) => lists[CONTINGENCY_LISTS]?.map((contingencyList) => contingencyList[ID])), + .flatMap((lists) => (lists[CONTINGENCY_LISTS] ?? []).map((contingencyList) => contingencyList[ID])),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/parameters/common/contingency-table/contingency-table.tsx` around lines 89 - 93, The callback passed to flatMap can return undefined because of the optional chain on lists[CONTINGENCY_LISTS]; update the expression that builds the UUID[] for fetchContingencyCount to guarantee an array by removing the optional chaining or coalescing to an empty array (e.g., use lists[CONTINGENCY_LISTS] or lists[CONTINGENCY_LISTS] ?? []) so flatMap always receives an array of map results; adjust the call site referencing contingencyListsInfos, ACTIVATED, CONTINGENCY_LISTS, and ID accordingly to ensure no undefined values are produced.src/services/sensitivity-analysis.ts (1)
98-109:⚠️ Potential issue | 🟡 MinorTighten type and fix misleading log message.
Two issues on this function:
newParams: anybypasses the enriched-type contract enforced elsewhere. SincebodycallsmapSensitivityAnalysisParameters(newParams), the parameter should be typed asSensitivityAnalysisParametersInfosEnriched | nullto matchbackendUpdateParametersinParametersInfos<SENSITIVITY_ANALYSIS>.- The log reads
'set security analysis parameters'— copy-paste from the security-analysis service. It should reference sensitivity analysis.🛠 Proposed fix
-export function updateSensitivityAnalysisParameters(parameterUuid: UUID, newParams: any) { - console.info('set security analysis parameters'); - const setSecurityAnalysisParametersUrl = `${getSensiUrl()}parameters/${parameterUuid}`; - console.debug(setSecurityAnalysisParametersUrl); - return backendFetch(setSecurityAnalysisParametersUrl, { +export function updateSensitivityAnalysisParameters( + parameterUuid: UUID, + newParams: SensitivityAnalysisParametersInfosEnriched | null +) { + console.info('set sensitivity analysis parameters'); + const url = `${getSensiUrl()}parameters/${parameterUuid}`; + console.debug(url); + return backendFetch(url, { method: 'PUT', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, body: newParams ? JSON.stringify(mapSensitivityAnalysisParameters(newParams)) : null, }); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/services/sensitivity-analysis.ts` around lines 98 - 109, The function updateSensitivityAnalysisParameters currently accepts newParams: any and logs a misleading message; change the parameter type to SensitivityAnalysisParametersInfosEnriched | null (matching backendUpdateParameters / ParametersInfos<SENSITIVITY_ANALYSIS>) and ensure the body still calls mapSensitivityAnalysisParameters(newParams) when non-null, and update the console.info message from 'set security analysis parameters' to something like 'set sensitivity analysis parameters' so the log matches the function purpose; adjust any imports/types if needed to reference SensitivityAnalysisParametersInfosEnriched and keep the existing backendFetch call intact.src/utils/types/sensitivity-analysis.type.ts (1)
23-26:⚠️ Potential issue | 🟡 Minor
containerNameshould allownullto match enrichment behavior.
enrichSensitivityAnalysisParameterswritescontainerName: elementNames?.[id] ?? null(line 224), but the interface declarescontainerName: string. Any consumer reading these values (e.g., UI renderers, form defaults) that has been strictly typed onEquipmentsContainerwill be working against a lie when the directory lookup fails to return a name. Either widen the field or default to''.🛡️ Suggested fix
interface EquipmentsContainer { containerId: string; - containerName: string; + containerName: string | null; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/types/sensitivity-analysis.type.ts` around lines 23 - 26, The EquipmentsContainer interface currently declares containerName as string but enrichSensitivityAnalysisParameters sets containerName to elementNames?.[id] ?? null, so update the type to reflect actual values by changing EquipmentsContainer.containerName to string | null (or alternatively change enrichSensitivityAnalysisParameters to default to ''), and ensure any consumers handle the nullable case; reference the EquipmentsContainer interface and enrichSensitivityAnalysisParameters function when making the change.
🧹 Nitpick comments (8)
src/components/parameters/security-analysis/types.ts (1)
51-56: Misleading helper name.
getEquipmentsContainerIdsdoes not deal with equipment containers — it extracts contingency list IDs. Rename (e.g.getContingencyListIds) to match the domain and avoid copy-paste confusion.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/parameters/security-analysis/types.ts` around lines 51 - 56, Rename the misleading helper function getEquipmentsContainerIds to getContingencyListIds across the module and update all references; the function currently takes SAParameters and reads params.contingencyListsInfos.flatMap((cli) => cli.contingencyLists ?? []) to build the Set of contingency list IDs, so keep the implementation but change the function identifier (and any exported/imported names) to getContingencyListIds and adjust any typings/usages to match the new name to avoid copy-paste confusion.src/utils/types/pcc-min.type.ts (1)
29-47: Duplication withenrichSecurityAnalysisParameters.The enrichment pattern (collect UUIDs →
fetchElementNames→ map IDs to{id, name}) is repeated almost verbatim here and insrc/components/parameters/security-analysis/types.ts. Consider extracting a generic helper (e.g.enrichIdsWithNames(ids: Set<UUID>): Promise<Record<UUID, string> | null>) to reduce drift as more parameter types adopt the pattern.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/types/pcc-min.type.ts` around lines 29 - 47, enrichPccMinParameters duplicates the pattern used in enrichSecurityAnalysisParameters (collect UUIDs -> fetchElementNames -> map ids to {filterId, filterName}); extract a shared helper (e.g. enrichIdsWithNames or fetchNamesForIds) that takes a Set<UUID> or UUID[] and returns Promise<Record<UUID,string>|null>, then replace the local call to fetchElementNames/getFilterIdentifierIds in enrichPccMinParameters and in enrichSecurityAnalysisParameters to use that helper; update the mapping logic in enrichPccMinParameters (the mapIdsToFilterIdentifiers closure that uses FILTERS and getFilterIdentifierIds) to consume the helper's result (elementNames) instead of calling fetchElementNames directly so both functions share the same enrichment path.src/services/directory.ts (1)
79-91: Missing return type and inconsistent log level.
fetchElementNamesreturnsPromise<any>, which propagates untyped data intoenrichPccMinParameters/enrichSecurityAnalysisParameters(whereelementNames?.[id]is indexed blindly). Declare the expected backend shape (a UUID → name mapping) so consumers get compile-time safety. Also,console.logis inconsistent with the rest of this file, which usesconsole.debugfor URLs.🔧 Proposed fix
-export function fetchElementNames(elementUuids: Set<string>) { +export function fetchElementNames(elementUuids: Set<string>): Promise<Record<UUID, string>> { console.info('fetch directory element names'); const params = new URLSearchParams(); elementUuids.forEach((id) => { params.append('ids', id); }); const url = `${PREFIX_EXPLORE_SERVER_QUERIES}/v1/explore/elements/name?${params.toString()}`; - console.log(url); + console.debug(url); return backendFetchJson(url); }Please confirm the actual response shape returned by
GET /v1/explore/elements/name?ids=...(e.g.{ [uuid]: name }vs array of{id, name}); the current consumers assume the former viaelementNames?.[id].🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/services/directory.ts` around lines 79 - 91, fetchElementNames currently returns untyped Promise<any> and uses console.log for the URL; declare and return the concrete backend shape (e.g. Promise<Record<string, string>> if the API returns a mapping UUID→name, or adjust to Promise<Array<{id:string,name:string}>> and convert to a Record if the API returns an array) so callers like enrichPccMinParameters/enrichSecurityAnalysisParameters can index safely, and replace the console.log(url) with console.debug(url) for consistency; update the fetchElementNames signature and the call to backendFetchJson (and add a small mapping step if needed) to ensure compile-time safety and correct runtime shape.src/components/parameters/pcc-min/pcc-min-form-utils.ts (1)
26-42: Consolidate the two identical form-value converters.
fromPccMinParamsDataToFormValuesandfromStudyPccMinParamsDataToFormValueshave identical signatures and bodies. Either drop the study-specific variant and reuse the generic one at call sites, or have one delegate to the other to avoid divergence. This matches SonarCloud's warning on line 36.♻️ Proposed refactor
export const fromPccMinParamsDataToFormValues = (parameters: PccMinParametersEnriched | null): Record<string, any> => ({ [FILTERS]: parameters?.[FILTERS]?.map((filter) => ({ [ID]: filter[FILTER_ID], [NAME]: filter[FILTER_NAME], })) ?? [], }); -export const fromStudyPccMinParamsDataToFormValues = ( - parameters: PccMinParametersEnriched | null -): Record<string, any> => ({ - [FILTERS]: - parameters?.[FILTERS]?.map((filter) => ({ - [ID]: filter[FILTER_ID], - [NAME]: filter[FILTER_NAME], - })) ?? [], -}); +export const fromStudyPccMinParamsDataToFormValues = fromPccMinParamsDataToFormValues;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/parameters/pcc-min/pcc-min-form-utils.ts` around lines 26 - 42, The two functions fromPccMinParamsDataToFormValues and fromStudyPccMinParamsDataToFormValues are identical; remove duplication by keeping one canonical implementation (e.g., fromPccMinParamsDataToFormValues) and update usages of fromStudyPccMinParamsDataToFormValues to call/delegate to the canonical function (or replace call sites to use fromPccMinParamsDataToFormValues directly); ensure the exported API stays compatible by either exporting the alias (export const fromStudyPccMinParamsDataToFormValues = fromPccMinParamsDataToFormValues) or removing the duplicate export and refactoring call sites accordingly, preserving the same parameter signature and return shape.src/utils/types/sensitivity-analysis.type.ts (2)
125-282: Significant code duplication acrossmap*andenrich*helpers.Each of the 5 sensitivity sub-structures repeats nearly identical
map/enrichlogic in bothmapSensitivityAnalysisParametersandenrichSensitivityAnalysisParameters. Consider driving them from a small field-list descriptor keyed by structure name to reduce surface area and future drift (e.g., a new field missed in one branch but not the other).♻️ Sketch
const SUBSTRUCT_FIELDS = { sensitivityInjectionsSet: ['monitoredBranches', 'injections', 'contingencies'], sensitivityInjection: ['monitoredBranches', 'injections', 'contingencies'], sensitivityHVDC: ['monitoredBranches', 'hvdcs', 'contingencies'], sensitivityPST: ['monitoredBranches', 'psts', 'contingencies'], sensitivityNodes: ['monitoredVoltageLevels', 'equipmentsInVoltageRegulation', 'contingencies'], } as const;Iterate over that descriptor in both
mapandenrichto apply the same field-level transform.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/types/sensitivity-analysis.type.ts` around lines 125 - 282, The code duplicates nearly identical mapping/enrichment logic across mapSensitivityAnalysisParameters and enrichSensitivityAnalysisParameters for the five sensitivity sub-structures; refactor by introducing a shared descriptor (e.g., const SUBSTRUCT_FIELDS = { sensitivityInjectionsSet: ['monitoredBranches','injections','contingencies'], sensitivityInjection: [...], sensitivityHVDC: [...], sensitivityPST: [...], sensitivityNodes: [...] } as const) and iterate over its entries in both functions to apply the appropriate transform (use the existing helper mapEquipmentsContainerToIds in mapSensitivityAnalysisParameters and mapIdsToEquipmentsContainer / fetchElementNames flow in enrichSensitivityAnalysisParameters), dispatching per-field transforms by name to eliminate the repeated per-structure blocks while preserving existing return shapes and null/empty-array fallbacks.
128-130: Unsafeas UUID[]cast.
containerIdis typed asstring, notUUID. Theas UUID[]cast silently accepts any string shape. Since downstream types (SensitivityAnalysisParameters<UUID>) rely on this invariant, prefer either typingcontainerIdasUUIDonEquipmentsContainer(since it always originates from a UUID in the backend) or validating the id before casting.interface EquipmentsContainer { - containerId: string; + containerId: UUID; containerName: string | null; }Then
mapEquipmentsContainerToIdsno longer needs the cast.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/types/sensitivity-analysis.type.ts` around lines 128 - 130, The mapEquipmentsContainerToIds function currently force-casts strings to UUID[]; change the source typing or validate instead: update the EquipmentsContainer type's containerId from string to UUID so mapEquipmentsContainerToIds can simply return containers?.map(c => c.containerId) without an unsafe as-cast, and ensure SensitivityAnalysisParameters<UUID> consumers remain consistent; alternatively, if you cannot change the model, add a validation step inside mapEquipmentsContainerToIds to parse/validate each c.containerId as a UUID and only return validated ids (or throw/skip invalid ones) rather than using the as UUID[] cast.src/components/parameters/pcc-min/use-pcc-min-parameters-form.ts (1)
86-117: Inconsistent error-handling helper between inline and dialog save paths.
onSaveInlinecallssnackErrordirectly whileonSaveDialogusessnackWithFallback. For consistency (and to benefit from the fallback message whenerror.messageis missing), consider usingsnackWithFallbackin both branches.♻️ Proposed tweak
- updatePccMinParameters(studyUuid, fromPccMinParametersFormToParamValuesEnriched(formData)).catch( - (error) => { - snackError({ - messageTxt: error.message, - headerId: 'updatePccMinParametersError', - }); - } - ); + updatePccMinParameters(studyUuid, fromPccMinParametersFormToParamValuesEnriched(formData)).catch( + (error) => { + snackWithFallback(snackError, error, { headerId: 'updatePccMinParametersError' }); + } + );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/parameters/pcc-min/use-pcc-min-parameters-form.ts` around lines 86 - 117, The inline save path in onSaveInline uses snackError directly while onSaveDialog uses snackWithFallback; change onSaveInline's catch to call snackWithFallback(snackError, error, { headerId: 'updatePccMinParametersError' }) so it mirrors the dialog behavior and provides fallback messaging, and update the useCallback dependency array for onSaveInline to include snackWithFallback (in addition to snackError and studyUuid) to avoid stale closures.src/components/parameters/sensi/use-sensitivity-analysis-parameters.ts (1)
447-462:mapSensitivityAnalysisParameterswrap beforeupdateParameteris the right asymmetry.The generic
updateParameterservice cannot know the enriched shape, so converting here is correct. Note the intentional asymmetry withonSaveInlineat line 435, wheresetSensitivityAnalysisParametersperforms the mapping internally — worth a brief JSDoc on the service (or the hook) to make that contract explicit for future callers.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/parameters/sensi/use-sensitivity-analysis-parameters.ts` around lines 447 - 462, The code is correct to call mapSensitivityAnalysisParameters before updateParameter (the generic updateParameter expects the enriched shape already), but the asymmetry with onSaveInline (which lets setSensitivityAnalysisParameters do the mapping) should be documented; add a brief JSDoc on the updateParameter service (or on the hook that wraps it) describing the contract: updateParameter expects already-mapped/enriched parameter payloads (caller responsibility), and note that setSensitivityAnalysisParameters performs mapping internally while onSaveDialog must call mapSensitivityAnalysisParameters first; reference mapSensitivityAnalysisParameters, updateParameter, onSaveInline, and setSensitivityAnalysisParameters in the comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/parameters/security-analysis/types.ts`:
- Around line 63-72: The mapIdsToIdNames closure returns IdName objects with
[NAME] possibly set to null which violates IdName.name:string; update
mapIdsToIdNames in the elementNamesPromise.then block to coerce
elementNames?.[id] to a string (e.g., elementNames?.[id] ?? '') so [NAME] is
always a string, preserving the IdName type (alternatively, if you prefer a type
change, update the IdName declaration to allow string | null across usages, but
the quick fix is to use the empty-string fallback).
In `@src/services/directory.ts`:
- Around line 79-91: fetchElementNames currently builds a long GET URL by
appending many ids query params which can hit 414 limits; change
fetchElementNames to send the UUIDs in the request body instead (POST) or
implement client-side batching: build an array from elementUuids and call the
same endpoint with a POST to
`${PREFIX_EXPLORE_SERVER_QUERIES}/v1/explore/elements/name` using JSON body {
ids: [...] } and Content-Type: application/json (or, if POST is not allowed,
split elementUuids into chunks and perform multiple GET requests and merge
results). Update the call site to use backendFetchJson with method:'POST',
appropriate headers and JSON.stringify(body) (or loop over chunks and aggregate
responses) and keep function name fetchElementNames unchanged.
In `@src/services/pcc-min.ts`:
- Around line 18-32: The enrichment step can throw (fetchElementNames failure)
and currently bubbles up, so wrap the call to enrichPccMinParameters in a
rejection handler and return a sensible fallback so the base parameters still
resolve; specifically, in both getPccMinStudyParameters and
fetchPccMinParameters replace the direct .then(enrichPccMinParameters) with
.then(params => { try { return enrichPccMinParameters(params); } catch (err) {
return enrichPccMinParameters({ ...params, elementNames: {} }); } }) or
equivalent Promise.catch-based logic that catches enrichment errors and returns
the original parameters enriched with an empty elementNames map (reference
enrichPccMinParameters and the fact it calls fetchElementNames) so the form can
render even if fetchElementNames fails.
In `@src/utils/types/pcc-min.type.ts`:
- Around line 34-47: The mapIdsToFilterIdentifiers closure returns filterName as
elementNames?.[id] ?? null which can be null but FilterIdentifier.filterName is
declared as string; change the code so filterName is always a string (e.g.
elementNames?.[id] ?? id or elementNames?.[id] ?? '') or update the
FilterIdentifier type to allow string | null; locate the mapper in the
elementNamesPromise.then block (mapIdsToFilterIdentifiers, FILTERS,
FilterIdentifier) and implement the chosen fix consistently so the returned
object matches the FilterIdentifier definition.
- Around line 11-23: mapPccMinParameters uses optional chaining on a field that
the input type PccMinParametersEnriched marks as required, which can yield
undefined for the required PccMinParameters[FILTERS]; fix by ensuring FILTERS is
always an array: in mapPccMinParameters convert parametersInfos.filters to an
array (e.g. parametersInfos.filters ? parametersInfos.filters.map(f =>
f.filterId) : []) or remove the optional chaining and rely on the required type
(parametersInfos.filters.map(...)); reference mapPccMinParameters,
PccMinParametersEnriched, PccMinParameters and FILTERS when changing the
implementation or types.
In `@src/utils/types/sensitivity-analysis.type.ts`:
- Around line 219-281: The enrichSensitivityAnalysisParameters function
currently coerces undefined sensitivity sub-fields into empty arrays (e.g.,
sensitivityInjectionsSet, sensitivityInjection, sensitivityHVDC, sensitivityPST,
sensitivityNodes) by using ternaries that return []; change these to preserve
undefined using optional chaining or nullish checks so the function returns
undefined when the input was undefined (mirroring
mapSensitivityAnalysisParameters). Specifically, update the mapping logic that
uses mapIdsToEquipmentsContainer and the ternary patterns on
parameters.sensitivityInjectionsSet, parameters.sensitivityInjection,
parameters.sensitivityHVDC, parameters.sensitivityPST, and
parameters.sensitivityNodes to use optional chaining (e.g.,
parameters.sensitivityInjectionsSet?.map(...)) or return undefined instead of []
so round-trip semantics are preserved.
---
Outside diff comments:
In `@src/components/parameters/common/contingency-table/contingency-table.tsx`:
- Around line 89-93: The callback passed to flatMap can return undefined because
of the optional chain on lists[CONTINGENCY_LISTS]; update the expression that
builds the UUID[] for fetchContingencyCount to guarantee an array by removing
the optional chaining or coalescing to an empty array (e.g., use
lists[CONTINGENCY_LISTS] or lists[CONTINGENCY_LISTS] ?? []) so flatMap always
receives an array of map results; adjust the call site referencing
contingencyListsInfos, ACTIVATED, CONTINGENCY_LISTS, and ID accordingly to
ensure no undefined values are produced.
In `@src/services/sensitivity-analysis.ts`:
- Around line 98-109: The function updateSensitivityAnalysisParameters currently
accepts newParams: any and logs a misleading message; change the parameter type
to SensitivityAnalysisParametersInfosEnriched | null (matching
backendUpdateParameters / ParametersInfos<SENSITIVITY_ANALYSIS>) and ensure the
body still calls mapSensitivityAnalysisParameters(newParams) when non-null, and
update the console.info message from 'set security analysis parameters' to
something like 'set sensitivity analysis parameters' so the log matches the
function purpose; adjust any imports/types if needed to reference
SensitivityAnalysisParametersInfosEnriched and keep the existing backendFetch
call intact.
In `@src/utils/types/sensitivity-analysis.type.ts`:
- Around line 23-26: The EquipmentsContainer interface currently declares
containerName as string but enrichSensitivityAnalysisParameters sets
containerName to elementNames?.[id] ?? null, so update the type to reflect
actual values by changing EquipmentsContainer.containerName to string | null (or
alternatively change enrichSensitivityAnalysisParameters to default to ''), and
ensure any consumers handle the nullable case; reference the EquipmentsContainer
interface and enrichSensitivityAnalysisParameters function when making the
change.
---
Nitpick comments:
In `@src/components/parameters/pcc-min/pcc-min-form-utils.ts`:
- Around line 26-42: The two functions fromPccMinParamsDataToFormValues and
fromStudyPccMinParamsDataToFormValues are identical; remove duplication by
keeping one canonical implementation (e.g., fromPccMinParamsDataToFormValues)
and update usages of fromStudyPccMinParamsDataToFormValues to call/delegate to
the canonical function (or replace call sites to use
fromPccMinParamsDataToFormValues directly); ensure the exported API stays
compatible by either exporting the alias (export const
fromStudyPccMinParamsDataToFormValues = fromPccMinParamsDataToFormValues) or
removing the duplicate export and refactoring call sites accordingly, preserving
the same parameter signature and return shape.
In `@src/components/parameters/pcc-min/use-pcc-min-parameters-form.ts`:
- Around line 86-117: The inline save path in onSaveInline uses snackError
directly while onSaveDialog uses snackWithFallback; change onSaveInline's catch
to call snackWithFallback(snackError, error, { headerId:
'updatePccMinParametersError' }) so it mirrors the dialog behavior and provides
fallback messaging, and update the useCallback dependency array for onSaveInline
to include snackWithFallback (in addition to snackError and studyUuid) to avoid
stale closures.
In `@src/components/parameters/security-analysis/types.ts`:
- Around line 51-56: Rename the misleading helper function
getEquipmentsContainerIds to getContingencyListIds across the module and update
all references; the function currently takes SAParameters and reads
params.contingencyListsInfos.flatMap((cli) => cli.contingencyLists ?? []) to
build the Set of contingency list IDs, so keep the implementation but change the
function identifier (and any exported/imported names) to getContingencyListIds
and adjust any typings/usages to match the new name to avoid copy-paste
confusion.
In `@src/components/parameters/sensi/use-sensitivity-analysis-parameters.ts`:
- Around line 447-462: The code is correct to call
mapSensitivityAnalysisParameters before updateParameter (the generic
updateParameter expects the enriched shape already), but the asymmetry with
onSaveInline (which lets setSensitivityAnalysisParameters do the mapping) should
be documented; add a brief JSDoc on the updateParameter service (or on the hook
that wraps it) describing the contract: updateParameter expects
already-mapped/enriched parameter payloads (caller responsibility), and note
that setSensitivityAnalysisParameters performs mapping internally while
onSaveDialog must call mapSensitivityAnalysisParameters first; reference
mapSensitivityAnalysisParameters, updateParameter, onSaveInline, and
setSensitivityAnalysisParameters in the comment.
In `@src/services/directory.ts`:
- Around line 79-91: fetchElementNames currently returns untyped Promise<any>
and uses console.log for the URL; declare and return the concrete backend shape
(e.g. Promise<Record<string, string>> if the API returns a mapping UUID→name, or
adjust to Promise<Array<{id:string,name:string}>> and convert to a Record if the
API returns an array) so callers like
enrichPccMinParameters/enrichSecurityAnalysisParameters can index safely, and
replace the console.log(url) with console.debug(url) for consistency; update the
fetchElementNames signature and the call to backendFetchJson (and add a small
mapping step if needed) to ensure compile-time safety and correct runtime shape.
In `@src/utils/types/pcc-min.type.ts`:
- Around line 29-47: enrichPccMinParameters duplicates the pattern used in
enrichSecurityAnalysisParameters (collect UUIDs -> fetchElementNames -> map ids
to {filterId, filterName}); extract a shared helper (e.g. enrichIdsWithNames or
fetchNamesForIds) that takes a Set<UUID> or UUID[] and returns
Promise<Record<UUID,string>|null>, then replace the local call to
fetchElementNames/getFilterIdentifierIds in enrichPccMinParameters and in
enrichSecurityAnalysisParameters to use that helper; update the mapping logic in
enrichPccMinParameters (the mapIdsToFilterIdentifiers closure that uses FILTERS
and getFilterIdentifierIds) to consume the helper's result (elementNames)
instead of calling fetchElementNames directly so both functions share the same
enrichment path.
In `@src/utils/types/sensitivity-analysis.type.ts`:
- Around line 125-282: The code duplicates nearly identical mapping/enrichment
logic across mapSensitivityAnalysisParameters and
enrichSensitivityAnalysisParameters for the five sensitivity sub-structures;
refactor by introducing a shared descriptor (e.g., const SUBSTRUCT_FIELDS = {
sensitivityInjectionsSet: ['monitoredBranches','injections','contingencies'],
sensitivityInjection: [...], sensitivityHVDC: [...], sensitivityPST: [...],
sensitivityNodes: [...] } as const) and iterate over its entries in both
functions to apply the appropriate transform (use the existing helper
mapEquipmentsContainerToIds in mapSensitivityAnalysisParameters and
mapIdsToEquipmentsContainer / fetchElementNames flow in
enrichSensitivityAnalysisParameters), dispatching per-field transforms by name
to eliminate the repeated per-structure blocks while preserving existing return
shapes and null/empty-array fallbacks.
- Around line 128-130: The mapEquipmentsContainerToIds function currently
force-casts strings to UUID[]; change the source typing or validate instead:
update the EquipmentsContainer type's containerId from string to UUID so
mapEquipmentsContainerToIds can simply return containers?.map(c =>
c.containerId) without an unsafe as-cast, and ensure
SensitivityAnalysisParameters<UUID> consumers remain consistent; alternatively,
if you cannot change the model, add a validation step inside
mapEquipmentsContainerToIds to parse/validate each c.containerId as a UUID and
only return validated ids (or throw/skip invalid ones) rather than using the as
UUID[] cast.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 93bdbe37-35ea-4750-b6e3-94aebf809967
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (22)
src/components/parameters/common/contingency-table/columns-definitions.tssrc/components/parameters/common/contingency-table/contingency-table.tsxsrc/components/parameters/common/contingency-table/types.tssrc/components/parameters/pcc-min/pcc-min-form-utils.tssrc/components/parameters/pcc-min/pcc-min-parameters-inline.tsxsrc/components/parameters/pcc-min/use-pcc-min-parameters-form.tssrc/components/parameters/security-analysis/columns-definitions.tssrc/components/parameters/security-analysis/security-analysis-parameters-inline.tsxsrc/components/parameters/security-analysis/security-analysis-parameters-selector.tsxsrc/components/parameters/security-analysis/types.tssrc/components/parameters/security-analysis/use-security-analysis-parameters-form.tssrc/components/parameters/sensi/sensitivity-analysis-parameters-inline.tsxsrc/components/parameters/sensi/use-sensitivity-analysis-parameters.tssrc/services/directory.tssrc/services/index.tssrc/services/pcc-min.tssrc/services/security-analysis.tssrc/services/sensitivity-analysis.tssrc/utils/types/index.tssrc/utils/types/parameters.type.tssrc/utils/types/pcc-min.type.tssrc/utils/types/sensitivity-analysis.type.ts
| return elementNamesPromise.then((elementNames) => { | ||
| const mapIdsToIdNames = (ids: UUID[] | undefined): IdName[] => { | ||
| return ids | ||
| ? ids.map((id) => ({ | ||
| [ID]: id, | ||
| [NAME]: elementNames?.[id] ?? null, | ||
| })) | ||
| : []; | ||
| }; | ||
| return { |
There was a problem hiding this comment.
Type violation: [NAME]: null breaks IdName.
IdName[NAME] is declared as string (see src/components/parameters/common/contingency-table/types.ts), but elementNames?.[id] ?? null returns string | null. Same defect as in pcc-min.type.ts. Either widen IdName.name to string | null or fall back to ''.
🔧 Proposed fix
- [ID]: id,
- [NAME]: elementNames?.[id] ?? null,
+ [ID]: id,
+ [NAME]: elementNames?.[id] ?? '',🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/components/parameters/security-analysis/types.ts` around lines 63 - 72,
The mapIdsToIdNames closure returns IdName objects with [NAME] possibly set to
null which violates IdName.name:string; update mapIdsToIdNames in the
elementNamesPromise.then block to coerce elementNames?.[id] to a string (e.g.,
elementNames?.[id] ?? '') so [NAME] is always a string, preserving the IdName
type (alternatively, if you prefer a type change, update the IdName declaration
to allow string | null across usages, but the quick fix is to use the
empty-string fallback).
| export function fetchElementNames(elementUuids: Set<string>) { | ||
| console.info('fetch directory element names'); | ||
|
|
||
| const params = new URLSearchParams(); | ||
| elementUuids.forEach((id) => { | ||
| params.append('ids', id); | ||
| }); | ||
|
|
||
| const url = `${PREFIX_EXPLORE_SERVER_QUERIES}/v1/explore/elements/name?${params.toString()}`; | ||
| console.log(url); | ||
|
|
||
| return backendFetchJson(url); | ||
| } |
There was a problem hiding this comment.
Potential 414 URI Too Long with large UUID sets.
All IDs are sent as repeated ids query params on a GET. With many contingency lists/filters, the URL can exceed server/proxy limits (commonly 4–8 KB). Consider switching to POST with a JSON body, or batching the UUIDs client-side.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/services/directory.ts` around lines 79 - 91, fetchElementNames currently
builds a long GET URL by appending many ids query params which can hit 414
limits; change fetchElementNames to send the UUIDs in the request body instead
(POST) or implement client-side batching: build an array from elementUuids and
call the same endpoint with a POST to
`${PREFIX_EXPLORE_SERVER_QUERIES}/v1/explore/elements/name` using JSON body {
ids: [...] } and Content-Type: application/json (or, if POST is not allowed,
split elementUuids into chunks and perform multiple GET requests and merge
results). Update the call site to use backendFetchJson with method:'POST',
appropriate headers and JSON.stringify(body) (or loop over chunks and aggregate
responses) and keep function name fetchElementNames unchanged.
There was a problem hiding this comment.
in reality, we have not much uuids, not reached a hundred elements.
There was a problem hiding this comment.
@thangqp, understood — thanks for the context! With fewer than a hundred UUIDs, the URL length will stay well within typical server and proxy limits (each UUID is ~36 chars, so even 100 IDs only adds ~4 KB at most). The current GET-with-query-params approach is fine for this scale, and no change is needed.
| export function getPccMinStudyParameters(studyUuid: UUID): Promise<PccMinParametersEnriched | null> { | ||
| console.info('get pcc min study parameters'); | ||
| const getPccMintParams = `${getStudyUrl(studyUuid)}/pcc-min/parameters`; | ||
| console.debug(getPccMintParams); | ||
| return backendFetchJson(getPccMintParams); | ||
| const url = `${getStudyUrl(studyUuid)}/pcc-min/parameters`; | ||
| console.debug(url); | ||
| const parametersPromise: Promise<PccMinParameters> = backendFetchJson(url); | ||
| return parametersPromise.then((parameters) => enrichPccMinParameters(parameters)); | ||
| } | ||
|
|
||
| export function fetchPccMinParameters(parameterUuid: UUID): Promise<PccMinParameters> { | ||
| export function fetchPccMinParameters(parameterUuid: UUID): Promise<PccMinParametersEnriched> { | ||
| console.info('fetch pcc min parameters'); | ||
| const url = `${getPccMinUrl()}parameters/${encodeURIComponent(parameterUuid)}`; | ||
| console.debug(url); | ||
| return backendFetchJson(url); | ||
| const parametersPromise: Promise<PccMinParameters> = backendFetchJson(url); | ||
| return parametersPromise.then((parameters) => enrichPccMinParameters(parameters)); | ||
| } |
There was a problem hiding this comment.
Unhandled backend failure during enrichment.
enrichPccMinParameters now issues a network call inside getPccMinStudyParameters / fetchPccMinParameters. If fetchElementNames fails (directory server down, 4xx/5xx, timeout), the whole parameters load rejects even though the base parameters were successfully fetched. Consider catching the enrichment error and falling back to an empty-names mapping so the form can still render.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/services/pcc-min.ts` around lines 18 - 32, The enrichment step can throw
(fetchElementNames failure) and currently bubbles up, so wrap the call to
enrichPccMinParameters in a rejection handler and return a sensible fallback so
the base parameters still resolve; specifically, in both
getPccMinStudyParameters and fetchPccMinParameters replace the direct
.then(enrichPccMinParameters) with .then(params => { try { return
enrichPccMinParameters(params); } catch (err) { return enrichPccMinParameters({
...params, elementNames: {} }); } }) or equivalent Promise.catch-based logic
that catches enrichment errors and returns the original parameters enriched with
an empty elementNames map (reference enrichPccMinParameters and the fact it
calls fetchElementNames) so the form can render even if fetchElementNames fails.
| export type PccMinParametersEnriched = { | ||
| [FILTERS]: FilterIdentifier[]; | ||
| }; | ||
| export type PccMinParameters = { | ||
| [FILTERS]: UUID[]; | ||
| }; | ||
|
|
||
| export function mapPccMinParameters(parametersInfos: PccMinParametersEnriched): PccMinParameters { | ||
| return { | ||
| ...parametersInfos, | ||
| [FILTERS]: parametersInfos.filters?.map((filter) => filter.filterId), | ||
| }; | ||
| } |
There was a problem hiding this comment.
mapPccMinParameters: optional chaining + required field mismatch.
PccMinParametersEnriched.filters is non-optional, yet parametersInfos.filters?.map(...) can produce undefined, which is assigned to PccMinParameters.filters: UUID[] (required). Either tighten the types to optional or coalesce to [].
🔧 Proposed fix
- [FILTERS]: parametersInfos.filters?.map((filter) => filter.filterId),
+ [FILTERS]: parametersInfos.filters?.map((filter) => filter.filterId) ?? [],📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export type PccMinParametersEnriched = { | |
| [FILTERS]: FilterIdentifier[]; | |
| }; | |
| export type PccMinParameters = { | |
| [FILTERS]: UUID[]; | |
| }; | |
| export function mapPccMinParameters(parametersInfos: PccMinParametersEnriched): PccMinParameters { | |
| return { | |
| ...parametersInfos, | |
| [FILTERS]: parametersInfos.filters?.map((filter) => filter.filterId), | |
| }; | |
| } | |
| export type PccMinParametersEnriched = { | |
| [FILTERS]: FilterIdentifier[]; | |
| }; | |
| export type PccMinParameters = { | |
| [FILTERS]: UUID[]; | |
| }; | |
| export function mapPccMinParameters(parametersInfos: PccMinParametersEnriched): PccMinParameters { | |
| return { | |
| ...parametersInfos, | |
| [FILTERS]: parametersInfos.filters?.map((filter) => filter.filterId) ?? [], | |
| }; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/utils/types/pcc-min.type.ts` around lines 11 - 23, mapPccMinParameters
uses optional chaining on a field that the input type PccMinParametersEnriched
marks as required, which can yield undefined for the required
PccMinParameters[FILTERS]; fix by ensuring FILTERS is always an array: in
mapPccMinParameters convert parametersInfos.filters to an array (e.g.
parametersInfos.filters ? parametersInfos.filters.map(f => f.filterId) : []) or
remove the optional chaining and rely on the required type
(parametersInfos.filters.map(...)); reference mapPccMinParameters,
PccMinParametersEnriched, PccMinParameters and FILTERS when changing the
implementation or types.
| return elementNamesPromise.then((elementNames) => { | ||
| const mapIdsToFilterIdentifiers = (ids: UUID[] | undefined): FilterIdentifier[] => { | ||
| return ids | ||
| ? ids.map((id) => ({ | ||
| filterId: id, | ||
| filterName: elementNames?.[id] ?? null, | ||
| })) | ||
| : []; | ||
| }; | ||
| return { | ||
| ...parameters, | ||
| [FILTERS]: mapIdsToFilterIdentifiers(parameters[FILTERS]), | ||
| }; | ||
| }); |
There was a problem hiding this comment.
Type violation: filterName can be null but FilterIdentifier.filterName is string.
elementNames?.[id] ?? null produces UUID | null, which does not match FilterIdentifier (see src/utils/constants/filterConstant.ts where filterName: string). This will either fail type-checking or silently leak null into UI code that assumes a string. Either widen the type (filterName: string | null) or fall back to an empty string / the UUID.
🔧 Proposed fix
- filterId: id,
- filterName: elementNames?.[id] ?? null,
+ filterId: id,
+ filterName: elementNames?.[id] ?? '',📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return elementNamesPromise.then((elementNames) => { | |
| const mapIdsToFilterIdentifiers = (ids: UUID[] | undefined): FilterIdentifier[] => { | |
| return ids | |
| ? ids.map((id) => ({ | |
| filterId: id, | |
| filterName: elementNames?.[id] ?? null, | |
| })) | |
| : []; | |
| }; | |
| return { | |
| ...parameters, | |
| [FILTERS]: mapIdsToFilterIdentifiers(parameters[FILTERS]), | |
| }; | |
| }); | |
| return elementNamesPromise.then((elementNames) => { | |
| const mapIdsToFilterIdentifiers = (ids: UUID[] | undefined): FilterIdentifier[] => { | |
| return ids | |
| ? ids.map((id) => ({ | |
| filterId: id, | |
| filterName: elementNames?.[id] ?? '', | |
| })) | |
| : []; | |
| }; | |
| return { | |
| ...parameters, | |
| [FILTERS]: mapIdsToFilterIdentifiers(parameters[FILTERS]), | |
| }; | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/utils/types/pcc-min.type.ts` around lines 34 - 47, The
mapIdsToFilterIdentifiers closure returns filterName as elementNames?.[id] ??
null which can be null but FilterIdentifier.filterName is declared as string;
change the code so filterName is always a string (e.g. elementNames?.[id] ?? id
or elementNames?.[id] ?? '') or update the FilterIdentifier type to allow string
| null; locate the mapper in the elementNamesPromise.then block
(mapIdsToFilterIdentifiers, FILTERS, FilterIdentifier) and implement the chosen
fix consistently so the returned object matches the FilterIdentifier definition.
| return elementNamesPromise.then((elementNames) => { | ||
| const mapIdsToEquipmentsContainer = (ids: UUID[] | undefined): EquipmentsContainer[] => { | ||
| return ids | ||
| ? ids.map((id) => ({ | ||
| containerId: id, | ||
| containerName: elementNames?.[id] ?? null, | ||
| })) | ||
| : []; | ||
| }; | ||
| return { | ||
| ...parameters, | ||
| sensitivityInjectionsSet: parameters.sensitivityInjectionsSet | ||
| ? parameters.sensitivityInjectionsSet.map((is) => { | ||
| return { | ||
| ...is, | ||
| monitoredBranches: mapIdsToEquipmentsContainer(is.monitoredBranches), | ||
| injections: mapIdsToEquipmentsContainer(is.injections), | ||
| contingencies: mapIdsToEquipmentsContainer(is.contingencies), | ||
| }; | ||
| }) | ||
| : [], | ||
| sensitivityInjection: parameters.sensitivityInjection | ||
| ? parameters.sensitivityInjection.map((i) => { | ||
| return { | ||
| ...i, | ||
| monitoredBranches: mapIdsToEquipmentsContainer(i.monitoredBranches), | ||
| injections: mapIdsToEquipmentsContainer(i.injections), | ||
| contingencies: mapIdsToEquipmentsContainer(i.contingencies), | ||
| }; | ||
| }) | ||
| : [], | ||
| sensitivityHVDC: parameters.sensitivityHVDC | ||
| ? parameters.sensitivityHVDC.map((hvdc) => { | ||
| return { | ||
| ...hvdc, | ||
| monitoredBranches: mapIdsToEquipmentsContainer(hvdc.monitoredBranches), | ||
| hvdcs: mapIdsToEquipmentsContainer(hvdc.hvdcs), | ||
| contingencies: mapIdsToEquipmentsContainer(hvdc.contingencies), | ||
| }; | ||
| }) | ||
| : [], | ||
| sensitivityPST: parameters.sensitivityPST | ||
| ? parameters.sensitivityPST.map((pst) => { | ||
| return { | ||
| ...pst, | ||
| monitoredBranches: mapIdsToEquipmentsContainer(pst.monitoredBranches), | ||
| psts: mapIdsToEquipmentsContainer(pst.psts), | ||
| contingencies: mapIdsToEquipmentsContainer(pst.contingencies), | ||
| }; | ||
| }) | ||
| : [], | ||
| sensitivityNodes: parameters.sensitivityNodes | ||
| ? parameters.sensitivityNodes.map((n) => { | ||
| return { | ||
| ...n, | ||
| monitoredVoltageLevels: mapIdsToEquipmentsContainer(n.monitoredVoltageLevels), | ||
| equipmentsInVoltageRegulation: mapIdsToEquipmentsContainer(n.equipmentsInVoltageRegulation), | ||
| contingencies: mapIdsToEquipmentsContainer(n.contingencies), | ||
| }; | ||
| }) | ||
| : [], | ||
| }; | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find backend contract for sensitivity-analysis parameters to see whether
# omitted fields and empty arrays are handled equivalently.
rg -nP --type=ts -C3 '\bsensitivityInjectionsSet\b|\bsensitivityInjection\b|\bsensitivityHVDC\b' -g '!**/*.test.*'Repository: gridsuite/commons-ui
Length of output: 13141
Asymmetry in undefined handling between enrich and map functions causes silent round-trip conversion.
The enrichSensitivityAnalysisParameters function converts undefined fields to empty arrays (undefined → []), while its complement mapSensitivityAnalysisParameters preserves undefined values using optional chaining. This creates a semantic loss during round-tripping: a field omitted by the backend becomes an empty array when the form is sent back, which backends may interpret differently from truly absent fields (important for partial updates).
Suggested fix (apply to all sensitivity sub-structures)
- sensitivityInjectionsSet: parameters.sensitivityInjectionsSet
- ? parameters.sensitivityInjectionsSet.map((is) => {
+ sensitivityInjectionsSet: parameters.sensitivityInjectionsSet?.map((is) => {
return {
...is,
monitoredBranches: mapIdsToEquipmentsContainer(is.monitoredBranches),
injections: mapIdsToEquipmentsContainer(is.injections),
contingencies: mapIdsToEquipmentsContainer(is.contingencies),
};
- })
- : [],
+ }),Use optional chaining throughout to preserve undefined and maintain consistency with mapSensitivityAnalysisParameters.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/utils/types/sensitivity-analysis.type.ts` around lines 219 - 281, The
enrichSensitivityAnalysisParameters function currently coerces undefined
sensitivity sub-fields into empty arrays (e.g., sensitivityInjectionsSet,
sensitivityInjection, sensitivityHVDC, sensitivityPST, sensitivityNodes) by
using ternaries that return []; change these to preserve undefined using
optional chaining or nullish checks so the function returns undefined when the
input was undefined (mirroring mapSensitivityAnalysisParameters). Specifically,
update the mapping logic that uses mapIdsToEquipmentsContainer and the ternary
patterns on parameters.sensitivityInjectionsSet,
parameters.sensitivityInjection, parameters.sensitivityHVDC,
parameters.sensitivityPST, and parameters.sensitivityNodes to use optional
chaining (e.g., parameters.sensitivityInjectionsSet?.map(...)) or return
undefined instead of [] so round-trip semantics are preserved.
| import { ContingencyListsInfos, ContingencyListsInfosEnriched, IdName } from '../common/contingency-table/types'; | ||
| import { ILimitReductionsByVoltageLevel } from '../common/limitreductions/columns-definitions'; | ||
| import { fetchElementNames } from '../../../services/directory'; | ||
| import { ID, NAME } from '../common/parameter-table/constants'; |
There was a problem hiding this comment.
| import { ID, NAME } from '../common/parameter-table/constants'; | |
| import { ID, NAME } from '../common/parameter-table-field/constants'; |
There was a problem hiding this comment.
to remove the diff of this file in the PR
| return new Set(allContainerIds); | ||
| } | ||
|
|
||
| export function enrichSecurityAnalysisParameters(parameters: SAParameters): Promise<SAParametersEnriched> { |
There was a problem hiding this comment.
@thangqp is it ok to add these functions in the file "types.ts"?!
There was a problem hiding this comment.
it is not Top but if a transformation between the API backend DTO and a derived of this DTO is co-located with the dervied type, IMO it is acceptable. The best is separating to a new file security-analysis-utils.ts in utils/types and create a new file security-analysis.type.ts in the same directory.
Note that the transformation is performed at service level, i.e. /services/security-analysis.ts so it should not depend on components/parameters/security-analysis
I will note it for the next rework PR
| return new Set(params[FILTERS]); | ||
| } | ||
|
|
||
| export function enrichPccMinParameters(parameters: PccMinParameters): Promise<PccMinParametersEnriched> { |
There was a problem hiding this comment.
IDEM as my coment; https://github.com/gridsuite/commons-ui/pull/1095/changes#r3225949600
| allVariableIds?: string[]; | ||
| }; | ||
|
|
||
| export function mapSensitivityAnalysisParameters( |
There was a problem hiding this comment.
IDEM as my coment: https://github.com/gridsuite/commons-ui/pull/1095/changes#r3225949600
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
|



PR Summary