Add applicationId to syncableEntity and fix syncApp deletion (#15170)
## Context - All flatEntity should extend SyncableEntity - SyncableEntity should now have applicationId and application relation - Fix syncApp deletion, should now properly use migration v2 to delete syncable entities
This commit is contained in:
+3
@@ -19,4 +19,7 @@ export class CreateCronTriggerInput {
|
||||
|
||||
@HideField()
|
||||
universalIdentifier?: string;
|
||||
|
||||
@HideField()
|
||||
applicationId?: string;
|
||||
}
|
||||
|
||||
+4
-1
@@ -25,7 +25,10 @@ export const CRON_TRIGGER_ENTITY_RELATION_PROPERTIES = [
|
||||
|
||||
@Entity({ name: 'cronTrigger', schema: 'core' })
|
||||
@Index('IDX_CRON_TRIGGER_WORKSPACE_ID', ['workspaceId'])
|
||||
export class CronTrigger extends SyncableEntity {
|
||||
export class CronTrigger
|
||||
extends SyncableEntity
|
||||
implements Required<CronTrigger>
|
||||
{
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
|
||||
+9
-17
@@ -14,6 +14,7 @@ import {
|
||||
import { FlatCronTrigger } from 'src/engine/metadata-modules/cron-trigger/types/flat-cron-trigger.type';
|
||||
import { EMPTY_FLAT_ENTITY_MAPS } from 'src/engine/metadata-modules/flat-entity/constant/empty-flat-entity-maps.constant';
|
||||
import { 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 { WorkspaceFlatMapCache } from 'src/engine/workspace-flat-map-cache/decorators/workspace-flat-map-cache.decorator';
|
||||
import { WorkspaceFlatMapCacheService } from 'src/engine/workspace-flat-map-cache/services/workspace-flat-map-cache.service';
|
||||
|
||||
@@ -42,28 +43,19 @@ export class WorkspaceFlatCronTriggerMapCacheService extends WorkspaceFlatMapCac
|
||||
},
|
||||
});
|
||||
|
||||
const flatCronTriggerMaps = cronTriggers.reduce<
|
||||
FlatEntityMaps<FlatCronTrigger>
|
||||
>((flatEntityMaps, cronTrigger) => {
|
||||
return cronTriggers.reduce((flatCronTriggerMaps, cronTriggerEntity) => {
|
||||
const flatCronTrigger = {
|
||||
...removePropertiesFromRecord(cronTrigger, [
|
||||
...removePropertiesFromRecord(cronTriggerEntity, [
|
||||
...CRON_TRIGGER_ENTITY_RELATION_PROPERTIES,
|
||||
]),
|
||||
universalIdentifier: cronTrigger.universalIdentifier ?? cronTrigger.id,
|
||||
universalIdentifier:
|
||||
cronTriggerEntity.universalIdentifier ?? cronTriggerEntity.id,
|
||||
} satisfies FlatCronTrigger;
|
||||
|
||||
return {
|
||||
byId: {
|
||||
...flatEntityMaps.byId,
|
||||
[flatCronTrigger.id]: flatCronTrigger,
|
||||
},
|
||||
idByUniversalIdentifier: {
|
||||
...flatEntityMaps.idByUniversalIdentifier,
|
||||
[flatCronTrigger.universalIdentifier]: flatCronTrigger.id,
|
||||
},
|
||||
};
|
||||
return addFlatEntityToFlatEntityMapsOrThrow({
|
||||
flatEntity: flatCronTrigger,
|
||||
flatEntityMaps: flatCronTriggerMaps,
|
||||
});
|
||||
}, EMPTY_FLAT_ENTITY_MAPS);
|
||||
|
||||
return flatCronTriggerMaps;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,5 +1,6 @@
|
||||
import { type Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type CronTrigger } from 'src/engine/metadata-modules/cron-trigger/entities/cron-trigger.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
@@ -9,9 +10,7 @@ export type CronTriggerEntityRelationProperties =
|
||||
ServerlessFunctionEntity | Workspace
|
||||
>;
|
||||
|
||||
export type FlatCronTrigger = Omit<
|
||||
export type FlatCronTrigger = FlatEntityFrom<
|
||||
CronTrigger,
|
||||
CronTriggerEntityRelationProperties
|
||||
> & {
|
||||
universalIdentifier: string;
|
||||
};
|
||||
>;
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ export const fromCreateCronTriggerInputToFlatCronTrigger = ({
|
||||
universalIdentifier: createCronTriggerInput.universalIdentifier ?? v4(),
|
||||
settings: createCronTriggerInput.settings,
|
||||
serverlessFunctionId: createCronTriggerInput.serverlessFunctionId,
|
||||
applicationId: createCronTriggerInput.applicationId ?? null,
|
||||
workspaceId,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
|
||||
Reference in New Issue
Block a user