FlatObjectMetadataMaps and non FP style refactor (#13590)

# Introduction
- Retrieveing flat-object-metadata-maps for input transpilation, we
decided not to introduce map merge for remaining validation operation
for the moment
- Refactored the field metadata service v2 to sequentially
optimistically render on each iteration
This commit is contained in:
Paul Rastoin
2025-08-05 08:46:28 +00:00
committed by GitHub
parent ca9464e19d
commit 6af99ab1ea
14 changed files with 316 additions and 94 deletions
@@ -0,0 +1,27 @@
import { StringPropertyKeys } from '@/utils/trim-and-remove-duplicated-whitespaces-from-object-string-properties';
import { isDefined } from '@/utils/validation';
export const fromArrayToValuesByKeyRecord = <T extends object>({
array,
key,
}: {
array: T[];
key: StringPropertyKeys<T>;
}) => {
return array.reduce<Record<string, T[]>>((acc, value) => {
const computedKey = value[key] as string;
const occurrence = acc[computedKey];
if (isDefined(occurrence)) {
return {
...acc,
[computedKey]: [...occurrence, value],
};
}
return {
...acc,
[computedKey]: [value],
};
}, {});
};