Upgrade application model (#17673)
This commit is contained in:
@@ -6,17 +6,20 @@ import {
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
OneToMany,
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
type Relation,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
|
||||
import { ApplicationVariableEntity } from 'src/engine/core-modules/applicationVariable/application-variable.entity';
|
||||
import { AgentEntity } from 'src/engine/metadata-modules/ai/ai-agent/entities/agent.entity';
|
||||
import { LogicFunctionEntity } from 'src/engine/metadata-modules/logic-function/logic-function.entity';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { RoleDTO } from 'src/engine/metadata-modules/role/dtos/role.dto';
|
||||
import { LogicFunctionEntity } from 'src/engine/metadata-modules/logic-function/logic-function.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'application', schema: 'core' })
|
||||
@@ -53,6 +56,29 @@ export class ApplicationEntity extends WorkspaceRelatedEntity {
|
||||
@Column({ nullable: false, type: 'text' })
|
||||
sourcePath: string;
|
||||
|
||||
@Column({ nullable: true, type: 'text' })
|
||||
packageJsonChecksum: string | null;
|
||||
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
packageJsonFileId: string | null;
|
||||
|
||||
@OneToOne(() => FileEntity, { onDelete: 'RESTRICT' })
|
||||
@JoinColumn({ name: 'packageJsonFileId' })
|
||||
packageJsonFile: Relation<FileEntity> | null;
|
||||
|
||||
@Column({ nullable: true, type: 'text' })
|
||||
yarnLockChecksum: string | null;
|
||||
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
yarnLockFileId: string | null;
|
||||
|
||||
@OneToOne(() => FileEntity, { onDelete: 'RESTRICT' })
|
||||
@JoinColumn({ name: 'yarnLockFileId' })
|
||||
yarnLockFile: Relation<FileEntity> | null;
|
||||
|
||||
@Column({ type: 'jsonb', nullable: false, default: {} })
|
||||
availablePackages: Record<string, string>;
|
||||
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
logicFunctionLayerId: string | null;
|
||||
|
||||
|
||||
+2
@@ -6,4 +6,6 @@ export const APPLICATION_ENTITY_RELATION_PROPERTIES = [
|
||||
'logicFunctions',
|
||||
'objects',
|
||||
'applicationVariables',
|
||||
'packageJsonFile',
|
||||
'yarnLockFile',
|
||||
] as const satisfies (keyof ApplicationEntity)[];
|
||||
|
||||
@@ -7,12 +7,13 @@ import {
|
||||
IsString,
|
||||
IsUUID,
|
||||
} from 'class-validator';
|
||||
import GraphQLJSON from 'graphql-type-json';
|
||||
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { ApplicationVariableEntityDTO } from 'src/engine/core-modules/applicationVariable/dtos/application-variable.dto';
|
||||
import { AgentDTO } from 'src/engine/metadata-modules/ai/ai-agent/dtos/agent.dto';
|
||||
import { ObjectMetadataDTO } from 'src/engine/metadata-modules/object-metadata/dtos/object-metadata.dto';
|
||||
import { LogicFunctionDTO } from 'src/engine/metadata-modules/logic-function/dtos/logic-function.dto';
|
||||
import { ObjectMetadataDTO } from 'src/engine/metadata-modules/object-metadata/dtos/object-metadata.dto';
|
||||
import { RoleDTO } from 'src/engine/metadata-modules/role/dtos/role.dto';
|
||||
|
||||
@ObjectType('Application')
|
||||
@@ -40,6 +41,29 @@ export class ApplicationDTO {
|
||||
@Field()
|
||||
universalIdentifier: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Field({ nullable: true })
|
||||
packageJsonChecksum?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
@Field(() => UUIDScalarType, { nullable: true })
|
||||
packageJsonFileId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Field({ nullable: true })
|
||||
yarnLockChecksum?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
@Field(() => UUIDScalarType, { nullable: true })
|
||||
yarnLockFileId?: string;
|
||||
|
||||
@Field(() => GraphQLJSON)
|
||||
availablePackages: Record<string, string>;
|
||||
|
||||
@Field(() => Boolean)
|
||||
@IsBoolean()
|
||||
canBeUninstalled: boolean;
|
||||
|
||||
+4
@@ -119,6 +119,8 @@ export class ApplicationService {
|
||||
'agents',
|
||||
'objects',
|
||||
'applicationVariables',
|
||||
'packageJsonFile',
|
||||
'yarnLockFile',
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -165,6 +167,8 @@ export class ApplicationService {
|
||||
'agents',
|
||||
'objects',
|
||||
'applicationVariables',
|
||||
'packageJsonFile',
|
||||
'yarnLockFile',
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
+10
-2
@@ -3,11 +3,14 @@ import { type FlatApplication } from 'src/engine/core-modules/application/types/
|
||||
|
||||
export const fromFlatApplicationToApplicationDto = ({
|
||||
canBeUninstalled,
|
||||
|
||||
description,
|
||||
id,
|
||||
name,
|
||||
|
||||
packageJsonChecksum,
|
||||
packageJsonFileId,
|
||||
yarnLockChecksum,
|
||||
yarnLockFileId,
|
||||
availablePackages,
|
||||
universalIdentifier,
|
||||
version,
|
||||
}: FlatApplication): ApplicationDTO => {
|
||||
@@ -17,6 +20,11 @@ export const fromFlatApplicationToApplicationDto = ({
|
||||
id,
|
||||
name,
|
||||
objects: [],
|
||||
packageJsonChecksum: packageJsonChecksum ?? undefined,
|
||||
packageJsonFileId: packageJsonFileId ?? undefined,
|
||||
yarnLockChecksum: yarnLockChecksum ?? undefined,
|
||||
yarnLockFileId: yarnLockFileId ?? undefined,
|
||||
availablePackages: availablePackages ?? {},
|
||||
universalIdentifier,
|
||||
version: version ?? undefined,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user