Add label to remote server (#5637)

Added label on remote server entity. 

Also added the possibility to update schema. 

<img width="688" alt="Capture d’écran 2024-05-28 à 15 36 31"
src="https://github.com/twentyhq/twenty/assets/22936103/c9786122-8459-4876-833e-c9a1d7d27829">
This commit is contained in:
Thomas Trompette
2024-05-28 15:54:57 +02:00
committed by GitHub
parent ae6d5afdfc
commit ebb1aa0377
17 changed files with 91 additions and 50 deletions

View File

@ -17,6 +17,9 @@ export class CreateRemoteServerInput<T extends RemoteServerType> {
@Field(() => GraphQLJSON)
foreignDataWrapperOptions: ForeignDataWrapperOptions<T>;
@Field(() => String)
label: string;
@IsOptional()
@Field(() => UserMappingOptions, { nullable: true })
userMappingOptions?: UserMappingOptions;

View File

@ -20,6 +20,9 @@ export class RemoteServerDTO<T extends RemoteServerType> {
@Field(() => String)
foreignDataWrapperType: T;
@Field(() => String)
label: string;
@IsOptional()
@Field(() => GraphQLJSON, { nullable: true })
foreignDataWrapperOptions?: ForeignDataWrapperOptions<T>;

View File

@ -21,6 +21,10 @@ export class UpdateRemoteServerInput<T extends RemoteServerType> {
@Field(() => GraphQLJSON, { nullable: true })
foreignDataWrapperOptions?: Partial<ForeignDataWrapperOptions<T>>;
@IsOptional()
@Field(() => String, { nullable: true })
label?: string;
@IsOptional()
@Field(() => UserMappingOptionsUpdateInput, { nullable: true })
userMappingOptions?: Partial<UserMappingOptions>;

View File

@ -46,6 +46,9 @@ export class RemoteServerEntity<T extends RemoteServerType> {
@Column({ type: 'text', nullable: true })
foreignDataWrapperType: T;
@Column({ type: 'text', nullable: true })
label: string;
@Column({ nullable: true, type: 'jsonb' })
foreignDataWrapperOptions: ForeignDataWrapperOptions<T>;

View File

@ -40,6 +40,14 @@ export const buildUpdateRemoteServerRawQuery = (
options.push(foreignDataWrapperOptionsQuery);
}
if (remoteServerToUpdate.schema) {
options.push(`"schema" = $${parametersPositions['schema']}`);
}
if (remoteServerToUpdate.label) {
options.push(`"label" = $${parametersPositions['label']}`);
}
if (options.length < 1) {
throw new BadRequestException('No fields to update');
}
@ -76,6 +84,16 @@ const buildParametersAndPositions = (
);
}
if (remoteServerToUpdate.schema) {
parameters.push(remoteServerToUpdate.schema);
parametersPositions['schema'] = parameters.length;
}
if (remoteServerToUpdate.label) {
parameters.push(remoteServerToUpdate.label);
parametersPositions['label'] = parameters.length;
}
return [parameters, parametersPositions];
};