Fix cross app installation (#18151)
# Introduction - Fixing app dependencyFlatEntityMaps load ( to load current app + dependent app ) - Fix empty flat entity maps and undefined optimistic override - Refactor the optimistic rendering to be mutation oriented at orchestrator level
This commit is contained in:
+4
@@ -11,6 +11,10 @@ type MetadataRequiredForValidation = {
|
||||
};
|
||||
};
|
||||
|
||||
export type MetadataRelatedMetadataNameForValidation<
|
||||
T extends AllMetadataName,
|
||||
> = keyof (typeof ALL_METADATA_REQUIRED_METADATA_FOR_VALIDATION)[T];
|
||||
|
||||
// TODO deprecate in favor of ALL_METADATA_SERIALIZED_RELATION
|
||||
export const ALL_METADATA_REQUIRED_METADATA_FOR_VALIDATION = {
|
||||
fieldMetadata: {
|
||||
|
||||
+3
@@ -12,6 +12,9 @@ type MetadataSerializedRelationProperties = {
|
||||
: Partial<Record<AllMetadataName, true>>;
|
||||
};
|
||||
|
||||
export type MetadataSerializedRelatedMetadataName<T extends AllMetadataName> =
|
||||
keyof (typeof ALL_METADATA_SERIALIZED_RELATION)[T];
|
||||
|
||||
export const ALL_METADATA_SERIALIZED_RELATION = {
|
||||
agent: {},
|
||||
skill: {},
|
||||
|
||||
+1
@@ -4,5 +4,6 @@ import { type UniversalFlatEntityMaps } from 'src/engine/workspace-manager/works
|
||||
export type FlatEntityMaps<T extends SyncableFlatEntity> =
|
||||
UniversalFlatEntityMaps<T> & {
|
||||
universalIdentifierById: Partial<Record<string, string>>;
|
||||
// TODO refactor or replicate to be universal and UniversalFlatEntityMaps lvl located
|
||||
universalIdentifiersByApplicationId: Partial<Record<string, string[]>>;
|
||||
};
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { type AllMetadataName } from 'twenty-shared/metadata';
|
||||
|
||||
import {
|
||||
ALL_METADATA_REQUIRED_METADATA_FOR_VALIDATION,
|
||||
type MetadataRelatedMetadataNameForValidation,
|
||||
} from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-required-metadata-for-validation.constant';
|
||||
|
||||
export const getMetadataRelatedMetadataNamesForValidation = <
|
||||
T extends AllMetadataName,
|
||||
>(
|
||||
metadataName: T,
|
||||
) => {
|
||||
return Object.keys(
|
||||
ALL_METADATA_REQUIRED_METADATA_FOR_VALIDATION[metadataName],
|
||||
) as MetadataRelatedMetadataNameForValidation<T>[];
|
||||
};
|
||||
+8
-5
@@ -1,11 +1,14 @@
|
||||
import { type AllMetadataName } from 'twenty-shared/metadata';
|
||||
|
||||
import { ALL_METADATA_SERIALIZED_RELATION } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-serialized-relation.constant';
|
||||
import {
|
||||
ALL_METADATA_SERIALIZED_RELATION,
|
||||
type MetadataSerializedRelatedMetadataName,
|
||||
} from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-serialized-relation.constant';
|
||||
|
||||
export const getMetadataSerializedRelationNames = (
|
||||
metadataName: AllMetadataName,
|
||||
): AllMetadataName[] => {
|
||||
export const getMetadataSerializedRelationNames = <T extends AllMetadataName>(
|
||||
metadataName: T,
|
||||
) => {
|
||||
return Object.keys(
|
||||
ALL_METADATA_SERIALIZED_RELATION[metadataName],
|
||||
) as AllMetadataName[];
|
||||
) as MetadataSerializedRelatedMetadataName<T>[];
|
||||
};
|
||||
|
||||
+9
-5
@@ -1,8 +1,8 @@
|
||||
import { createEmptyFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/constant/create-empty-flat-entity-maps.constant';
|
||||
import { type SyncableFlatEntity } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-from.type';
|
||||
import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';
|
||||
import { addFlatEntityToFlatEntityMapsOrThrow } from 'src/engine/metadata-modules/flat-entity/utils/add-flat-entity-to-flat-entity-maps-or-throw.util';
|
||||
import { findFlatEntityByIdInFlatEntityMapsOrThrow } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-id-in-flat-entity-maps-or-throw.util';
|
||||
import { addFlatEntityToFlatEntityMapsThroughMutationOrThrow } from 'src/engine/workspace-manager/workspace-migration/utils/add-flat-entity-to-flat-entity-maps-through-mutation-or-throw.util';
|
||||
|
||||
export const getSubFlatEntityByIdsMapsOrThrow = <T extends SyncableFlatEntity>({
|
||||
flatEntityIds,
|
||||
@@ -11,15 +11,19 @@ export const getSubFlatEntityByIdsMapsOrThrow = <T extends SyncableFlatEntity>({
|
||||
flatEntityMaps: FlatEntityMaps<T>;
|
||||
flatEntityIds: string[];
|
||||
}): FlatEntityMaps<T> => {
|
||||
return flatEntityIds.reduce<FlatEntityMaps<T>>((acc, flatEntityId) => {
|
||||
const flatEntityMapsToMutate = createEmptyFlatEntityMaps();
|
||||
|
||||
flatEntityIds.forEach((flatEntityId) => {
|
||||
const flatEntity = findFlatEntityByIdInFlatEntityMapsOrThrow({
|
||||
flatEntityId,
|
||||
flatEntityMaps,
|
||||
});
|
||||
|
||||
return addFlatEntityToFlatEntityMapsOrThrow({
|
||||
addFlatEntityToFlatEntityMapsThroughMutationOrThrow({
|
||||
flatEntity,
|
||||
flatEntityMaps: acc,
|
||||
flatEntityMapsToMutate,
|
||||
});
|
||||
}, createEmptyFlatEntityMaps());
|
||||
});
|
||||
|
||||
return flatEntityMapsToMutate;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user