Fix flatFieldMetadata transpiler to fit real cache typing (#13529)

# Introduction
The cache is not accurately typed regarding the `fieldMetadataMaps` they
do not contain relations
In this way we:
- Created dedicated transpilation tools for cache manipulation
- Avoided recursivity in transpilation tools
- Fix and finalized the createMany fields metadata service v2
- Refactor the validator to handle validation :)

## What's next:
- Implem integration tests to make things run 🙃 
- migrate existing settings valdiation
- Finish the create object metadata service
- Handle update input transpilation and validation
This commit is contained in:
Paul Rastoin
2025-08-01 18:39:11 +02:00
committed by GitHub
parent dd47bfe6d5
commit b98d8c4d39
22 changed files with 384 additions and 124 deletions
@@ -0,0 +1,12 @@
import { FlatObjectMetadataWithoutFields } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
import { fromObjectMetadataEntityToFlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/utils/from-object-metadata-entity-to-flat-object-metadata.util';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
export const fromObjectMetadataEntityToFlatObjectMetadataWithoutFields = (
objectMetadataEntity: ObjectMetadataEntity,
): FlatObjectMetadataWithoutFields => {
return fromObjectMetadataEntityToFlatObjectMetadata({
...objectMetadataEntity,
fields: [],
});
};
@@ -36,6 +36,7 @@ export class WorkspaceMigrationBuilderV2Service {
createdObjectMetadata,
deletedObjectMetadata,
updatedObjectMetadata,
inferDeletionFromMissingObjectFieldIndex,
});
const createdObjectMetadataCreateIndexActions =
@@ -13,11 +13,14 @@ import {
} from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/utils/get-workspace-migration-v2-object-actions';
export type CreatedDeletedUpdatedObjectMetadataInputMatrix =
CustomDeletedCreatedUpdatedMatrix<'objectMetadata', FlatObjectMetadata>;
CustomDeletedCreatedUpdatedMatrix<'objectMetadata', FlatObjectMetadata> & {
inferDeletionFromMissingObjectFieldIndex: boolean;
};
export const buildWorkspaceMigrationV2ObjectActions = ({
createdObjectMetadata,
deletedObjectMetadata,
updatedObjectMetadata,
inferDeletionFromMissingObjectFieldIndex,
}: CreatedDeletedUpdatedObjectMetadataInputMatrix): WorkspaceMigrationObjectActionV2[] => {
const createdObjectActions = createdObjectMetadata.map(
(flatObjectMetadata) => {
@@ -36,9 +39,9 @@ export const buildWorkspaceMigrationV2ObjectActions = ({
},
);
const deletedObjectActions = deletedObjectMetadata.map(
getWorkspaceMigrationV2ObjectDeleteAction,
);
const deletedObjectActions = inferDeletionFromMissingObjectFieldIndex
? deletedObjectMetadata.map(getWorkspaceMigrationV2ObjectDeleteAction)
: [];
const updatedObjectActions =
updatedObjectMetadata.flatMap<UpdateObjectAction>(({ from, to }) => {