Spaces:
Build error
Build error
twenty / packages /twenty-server /src /engine /metadata-modules /flat-entity /utils /split-entities-by-reset-strategy.util.ts
| type EntityWithApplicationIdentifierAndOverrides = { | |
| applicationUniversalIdentifier: string; | |
| isActive: boolean; | |
| overrides: unknown; | |
| isSystemSideEffect?: boolean; | |
| }; | |
| export const splitEntitiesByResetStrategy = < | |
| T extends EntityWithApplicationIdentifierAndOverrides, | |
| >({ | |
| entities, | |
| workspaceCustomApplicationUniversalIdentifier, | |
| now, | |
| }: { | |
| entities: T[]; | |
| workspaceCustomApplicationUniversalIdentifier: string; | |
| now: string; | |
| }): { | |
| toHardDelete: T[]; | |
| toReset: (T & { isActive: true; overrides: null; updatedAt: string })[]; | |
| } => { | |
| const toHardDelete: T[] = []; | |
| const toReset: (T & { | |
| isActive: true; | |
| overrides: null; | |
| updatedAt: string; | |
| })[] = []; | |
| for (const entity of entities) { | |
| if ( | |
| entity.applicationUniversalIdentifier === | |
| workspaceCustomApplicationUniversalIdentifier && | |
| !entity.isSystemSideEffect | |
| ) { | |
| toHardDelete.push(entity); | |
| } else { | |
| toReset.push({ | |
| ...entity, | |
| isActive: true as const, | |
| overrides: null, | |
| ...('universalOverrides' in entity ? { universalOverrides: null } : {}), | |
| updatedAt: now, | |
| }); | |
| } | |
| } | |
| return { toHardDelete, toReset }; | |
| }; | |