Fix flat entity maps date serialization (#16420)

Changes:
- as we store date in redis as serialized, let's make all flatEntity
dates as string. This requires changing FlatEntity types and making sure
that entity are converted to flatEntity and flatEntity to dtos
This commit is contained in:
Charles Bochet
2025-12-09 16:41:50 +01:00
committed by GitHub
parent 608e5751a9
commit a18203934c
94 changed files with 357 additions and 204 deletions
@@ -22,6 +22,7 @@ import {
ViewGroupException,
ViewGroupExceptionCode,
} from 'src/engine/metadata-modules/view-group/exceptions/view-group.exception';
import { fromFlatViewGroupToViewGroupDto } from 'src/engine/metadata-modules/view-group/utils/from-flat-view-group-to-view-group-dto.util';
import { WorkspaceMigrationBuilderExceptionV2 } from 'src/engine/workspace-manager/workspace-migration-v2/exceptions/workspace-migration-builder-exception-v2';
import { WorkspaceMigrationValidateBuildAndRunService } from 'src/engine/workspace-manager/workspace-migration-v2/services/workspace-migration-validate-build-and-run-service';
@@ -138,7 +139,7 @@ export class ViewGroupService {
return findManyFlatEntityByIdInFlatEntityMapsOrThrow({
flatEntityIds: flatViewGroupsToCreate.map((el) => el.id),
flatEntityMaps: recomputedExistingFlatViewGroupMaps,
});
}).map(fromFlatViewGroupToViewGroupDto);
}
async updateOne({
@@ -192,10 +193,12 @@ export class ViewGroupService {
},
);
return findFlatEntityByIdInFlatEntityMapsOrThrow({
flatEntityId: optimisticallyUpdatedFlatViewGroup.id,
flatEntityMaps: recomputedExistingFlatViewGroupMaps,
});
return fromFlatViewGroupToViewGroupDto(
findFlatEntityByIdInFlatEntityMapsOrThrow({
flatEntityId: optimisticallyUpdatedFlatViewGroup.id,
flatEntityMaps: recomputedExistingFlatViewGroupMaps,
}),
);
}
async deleteOne({
@@ -251,10 +254,12 @@ export class ViewGroupService {
},
);
return findFlatEntityByIdInFlatEntityMapsOrThrow({
flatEntityId: optimisticallyUpdatedFlatViewGroupWithDeletedAt.id,
flatEntityMaps: recomputedExistingFlatViewGroupMaps,
});
return fromFlatViewGroupToViewGroupDto(
findFlatEntityByIdInFlatEntityMapsOrThrow({
flatEntityId: optimisticallyUpdatedFlatViewGroupWithDeletedAt.id,
flatEntityMaps: recomputedExistingFlatViewGroupMaps,
}),
);
}
async destroyOne({
@@ -300,7 +305,7 @@ export class ViewGroupService {
);
}
return existingViewGroupToDelete;
return fromFlatViewGroupToViewGroupDto(existingViewGroupToDelete);
}
async findByWorkspaceId(workspaceId: string): Promise<ViewGroupEntity[]> {
@@ -0,0 +1,15 @@
import { type FlatViewGroup } from 'src/engine/metadata-modules/flat-view-group/types/flat-view-group.type';
import { type ViewGroupDTO } from 'src/engine/metadata-modules/view-group/dtos/view-group.dto';
export const fromFlatViewGroupToViewGroupDto = (
flatViewGroup: FlatViewGroup,
): ViewGroupDTO => {
const { createdAt, updatedAt, deletedAt, ...rest } = flatViewGroup;
return {
...rest,
createdAt: new Date(createdAt),
updatedAt: new Date(updatedAt),
deletedAt: deletedAt ? new Date(deletedAt) : null,
};
};