feat: twenty orm sync (#5266)
This PR is updating all object metadata entities with the new decorators, and deleting the old ones. This way we can use the new TwentyORM with all the standard objects. --------- Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -1,9 +0,0 @@
|
||||
import { CompositeMetadataTypes } from 'src/engine/metadata-modules/field-metadata/composite-types';
|
||||
|
||||
// TODO: At the time the composite types are generating union of types instead of a single type for their keys
|
||||
// We need to find a way to fix that
|
||||
export type FlattenCompositeTypes<T> = {
|
||||
[P in keyof T as T[P] extends CompositeMetadataTypes
|
||||
? `${string & P}${Capitalize<string & keyof T[P]>}`
|
||||
: P]: T[P] extends CompositeMetadataTypes ? T[P][keyof T[P]] : T[P];
|
||||
};
|
||||
@ -1,9 +1,9 @@
|
||||
import { FactoryProvider, ModuleMetadata, Type } from '@nestjs/common';
|
||||
|
||||
import { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
|
||||
|
||||
export interface TwentyORMOptions {
|
||||
objects: Type<BaseObjectMetadata>[];
|
||||
workspaceEntities: Type<BaseWorkspaceEntity>[];
|
||||
}
|
||||
|
||||
export type TwentyORMModuleAsyncOptions = {
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
import { ObjectType } from 'typeorm';
|
||||
|
||||
import { Gate } from 'src/engine/twenty-orm/interfaces/gate.interface';
|
||||
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
RelationMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
|
||||
export type WorkspaceDynamicRelationMetadataArgsFactory = (
|
||||
oppositeObjectMetadata: ObjectMetadataEntity,
|
||||
) => {
|
||||
/**
|
||||
* Standard id.
|
||||
*/
|
||||
readonly standardId: string;
|
||||
|
||||
/**
|
||||
* Relation name.
|
||||
*/
|
||||
readonly name: string;
|
||||
|
||||
/**
|
||||
* Relation label.
|
||||
*/
|
||||
readonly label: string;
|
||||
|
||||
/**
|
||||
* Relation description.
|
||||
*/
|
||||
readonly description?: string;
|
||||
|
||||
/**
|
||||
* Relation icon.
|
||||
*/
|
||||
readonly icon?: string;
|
||||
|
||||
/**
|
||||
* Relation join column.
|
||||
*/
|
||||
readonly joinColumn?: string;
|
||||
};
|
||||
|
||||
export interface WorkspaceDynamicRelationMetadataArgs {
|
||||
/**
|
||||
* Class to which relation is applied.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
readonly target: Function;
|
||||
|
||||
/**
|
||||
* Factory function
|
||||
*/
|
||||
readonly argsFactory: WorkspaceDynamicRelationMetadataArgsFactory;
|
||||
|
||||
/**
|
||||
* Relation type.
|
||||
*/
|
||||
readonly type: RelationMetadataType;
|
||||
|
||||
/**
|
||||
* Relation inverse side target.
|
||||
*/
|
||||
readonly inverseSideTarget: () => ObjectType<object>;
|
||||
|
||||
/**
|
||||
* Relation inverse side field key.
|
||||
*/
|
||||
readonly inverseSideFieldKey?: string;
|
||||
|
||||
/**
|
||||
* Relation on delete action.
|
||||
*/
|
||||
readonly onDelete?: RelationOnDeleteAction;
|
||||
|
||||
/**
|
||||
* Is primary field.
|
||||
*/
|
||||
readonly isPrimary: boolean;
|
||||
|
||||
/**
|
||||
* Is system field.
|
||||
*/
|
||||
readonly isSystem: boolean;
|
||||
|
||||
/**
|
||||
* Is nullable field.
|
||||
*/
|
||||
readonly isNullable: boolean;
|
||||
|
||||
/**
|
||||
* Field gate.
|
||||
*/
|
||||
readonly gate?: Gate;
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import { Gate } from 'src/engine/twenty-orm/interfaces/gate.interface';
|
||||
|
||||
export interface WorkspaceObjectMetadataArgs {
|
||||
export interface WorkspaceEntityMetadataArgs {
|
||||
/**
|
||||
* Standard id.
|
||||
*/
|
||||
@ -12,27 +12,27 @@ export interface WorkspaceObjectMetadataArgs {
|
||||
* String target is a table defined in a json schema.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
readonly target: Function | string;
|
||||
readonly target: Function;
|
||||
|
||||
/**
|
||||
* Object name.
|
||||
* Entity name.
|
||||
*/
|
||||
readonly nameSingular: string;
|
||||
readonly namePlural: string;
|
||||
|
||||
/**
|
||||
* Object label.
|
||||
* Entity label.
|
||||
*/
|
||||
readonly labelSingular: string;
|
||||
readonly labelPlural: string;
|
||||
|
||||
/**
|
||||
* Object description.
|
||||
* Entity description.
|
||||
*/
|
||||
readonly description?: string;
|
||||
|
||||
/**
|
||||
* Object icon.
|
||||
* Entity icon.
|
||||
*/
|
||||
readonly icon?: string;
|
||||
|
||||
@ -44,10 +44,10 @@ export interface WorkspaceObjectMetadataArgs {
|
||||
/**
|
||||
* Is system object.
|
||||
*/
|
||||
readonly isSystem?: boolean;
|
||||
readonly isSystem: boolean;
|
||||
|
||||
/**
|
||||
* Object gate.
|
||||
* Entity gate.
|
||||
*/
|
||||
readonly gate?: Gate;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
import { Gate } from 'src/engine/twenty-orm/interfaces/gate.interface';
|
||||
|
||||
export interface WorkspaceExtendedEntityMetadataArgs {
|
||||
/**
|
||||
* Class to which table is applied.
|
||||
* Function target is a table defined in the class.
|
||||
* String target is a table defined in a json schema.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
readonly target: Function;
|
||||
|
||||
/**
|
||||
* Entity gate.
|
||||
*/
|
||||
readonly gate?: Gate;
|
||||
}
|
||||
@ -15,7 +15,7 @@ export interface WorkspaceFieldMetadataArgs {
|
||||
* Class to which field is applied.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
readonly target: Function | string;
|
||||
readonly target: Function;
|
||||
|
||||
/**
|
||||
* Field name.
|
||||
@ -57,17 +57,17 @@ export interface WorkspaceFieldMetadataArgs {
|
||||
/**
|
||||
* Is primary field.
|
||||
*/
|
||||
readonly isPrimary?: boolean;
|
||||
readonly isPrimary: boolean;
|
||||
|
||||
/**
|
||||
* Is system field.
|
||||
*/
|
||||
readonly isSystem?: boolean;
|
||||
readonly isSystem: boolean;
|
||||
|
||||
/**
|
||||
* Is nullable field.
|
||||
*/
|
||||
readonly isNullable?: boolean;
|
||||
readonly isNullable: boolean;
|
||||
|
||||
/**
|
||||
* Field gate.
|
||||
|
||||
@ -18,7 +18,7 @@ export interface WorkspaceRelationMetadataArgs {
|
||||
* Class to which relation is applied.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
readonly target: Function | string;
|
||||
readonly target: Function;
|
||||
|
||||
/**
|
||||
* Relation name.
|
||||
@ -70,17 +70,17 @@ export interface WorkspaceRelationMetadataArgs {
|
||||
/**
|
||||
* Is primary field.
|
||||
*/
|
||||
readonly isPrimary?: boolean;
|
||||
readonly isPrimary: boolean;
|
||||
|
||||
/**
|
||||
* Is system field.
|
||||
*/
|
||||
readonly isSystem?: boolean;
|
||||
readonly isSystem: boolean;
|
||||
|
||||
/**
|
||||
* Is nullable field.
|
||||
*/
|
||||
readonly isNullable?: boolean;
|
||||
readonly isNullable: boolean;
|
||||
|
||||
/**
|
||||
* Field gate.
|
||||
|
||||
Reference in New Issue
Block a user