Setup relations for remote objects (#5149)

New strategy:
- add settings field on FieldMetadata. Contains a boolean isIdField and
for numbers, a precision
- if idField, the graphql scalar returned will be a GraphQL id. This
will allow the app to work even for ids that are not uuid
- remove globals dateScalar and numberScalar modes. These were not used
- set limit as Integer
- check manually in query runner mutations that we send a valid id

Todo left:
- remove WorkspaceBuildSchemaOptions since this is not used anymore.
Will do in another PR

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
Thomas Trompette
2024-04-26 14:37:34 +02:00
committed by GitHub
parent dc576d0818
commit 224c8d361b
71 changed files with 616 additions and 223 deletions

View File

@ -59,7 +59,6 @@ export class AddStandardIdCommand extends CommandRunner {
IS_AIRTABLE_INTEGRATION_ENABLED: true,
IS_POSTGRESQL_INTEGRATION_ENABLED: true,
IS_MULTI_SELECT_ENABLED: false,
IS_RELATION_FOR_REMOTE_OBJECTS_ENABLED: false,
},
);
const standardFieldMetadataCollection = this.standardFieldFactory.create(
@ -75,7 +74,6 @@ export class AddStandardIdCommand extends CommandRunner {
IS_AIRTABLE_INTEGRATION_ENABLED: true,
IS_POSTGRESQL_INTEGRATION_ENABLED: true,
IS_MULTI_SELECT_ENABLED: false,
IS_RELATION_FOR_REMOTE_OBJECTS_ENABLED: false,
},
);

View File

@ -48,6 +48,7 @@ export function FieldMetadata<T extends FieldMetadataType>(
description: `${restParams.description} id foreign key`,
defaultValue: null,
options: undefined,
settings: undefined,
},
joinColumn,
isNullable,

View File

@ -1,6 +1,7 @@
import { FieldMetadataDefaultValue } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-default-value.interface';
import { GateDecoratorParams } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/gate-decorator.interface';
import { FieldMetadataOptions } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-options.interface';
import { FieldMetadataSettings } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-settings.interface';
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
@ -16,12 +17,13 @@ export interface FieldMetadataDecoratorParams<
defaultValue?: FieldMetadataDefaultValue<T>;
joinColumn?: string;
options?: FieldMetadataOptions<T>;
settings?: FieldMetadataSettings<T>;
}
export interface ReflectFieldMetadata {
[key: string]: Omit<
FieldMetadataDecoratorParams<'default'>,
'defaultValue' | 'type' | 'options'
'defaultValue' | 'type' | 'options' | 'settings'
> & {
name: string;
type: FieldMetadataType;
@ -31,5 +33,6 @@ export interface ReflectFieldMetadata {
defaultValue: FieldMetadataDefaultValue<'default'> | null;
gate?: GateDecoratorParams;
options?: FieldMetadataOptions<'default'> | null;
settings?: FieldMetadataSettings<'default'> | null;
};
}

View File

@ -241,7 +241,9 @@ export class WorkspaceMetadataUpdaterService {
manager: EntityManager,
entityClass: EntityTarget<Entity>,
updateCollection: Array<
DeepPartial<Omit<Entity, 'fields' | 'options'>> & { id: string }
DeepPartial<Omit<Entity, 'fields' | 'options' | 'settings'>> & {
id: string;
}
>,
keysToOmit: (keyof Entity)[] = [],
): Promise<{ current: Entity; altered: Entity }[]> {