-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Showing
81 changed files
with
1,686 additions
and
2,025 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-object.decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage'; | ||
import { TypedReflect } from 'src/utils/typed-reflect'; | ||
|
||
export function WorkspaceCustomObject(): ClassDecorator { | ||
return (target) => { | ||
const gate = TypedReflect.getMetadata( | ||
'workspace:gate-metadata-args', | ||
target, | ||
); | ||
|
||
metadataArgsStorage.addExtendedEntities({ | ||
target, | ||
gate, | ||
}); | ||
}; | ||
} |
49 changes: 49 additions & 0 deletions
49
...es/twenty-server/src/engine/twenty-orm/decorators/workspace-dynamic-relation.decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ObjectType } from 'typeorm'; | ||
|
||
import { WorkspaceDynamicRelationMetadataArgsFactory } from 'src/engine/twenty-orm/interfaces/workspace-dynamic-relation-metadata-args.interface'; | ||
|
||
import { TypedReflect } from 'src/utils/typed-reflect'; | ||
import { | ||
RelationMetadataType, | ||
RelationOnDeleteAction, | ||
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity'; | ||
import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage'; | ||
|
||
interface WorkspaceBaseDynamicRelationOptions<TClass> { | ||
type: RelationMetadataType; | ||
argsFactory: WorkspaceDynamicRelationMetadataArgsFactory; | ||
inverseSideTarget: () => ObjectType<TClass>; | ||
inverseSideFieldKey?: keyof TClass; | ||
onDelete?: RelationOnDeleteAction; | ||
} | ||
|
||
export function WorkspaceDynamicRelation<TClass extends object>( | ||
args: WorkspaceBaseDynamicRelationOptions<TClass>, | ||
): PropertyDecorator { | ||
return (target, propertyKey) => { | ||
const isSystem = | ||
TypedReflect.getMetadata( | ||
'workspace:is-system-metadata-args', | ||
target, | ||
propertyKey.toString(), | ||
) ?? false; | ||
const gate = TypedReflect.getMetadata( | ||
'workspace:gate-metadata-args', | ||
target, | ||
propertyKey.toString(), | ||
); | ||
|
||
metadataArgsStorage.addDynamicRelations({ | ||
target: target.constructor, | ||
argsFactory: args.argsFactory, | ||
type: args.type, | ||
inverseSideTarget: args.inverseSideTarget, | ||
inverseSideFieldKey: args.inverseSideFieldKey as string | undefined, | ||
onDelete: args.onDelete, | ||
isSystem, | ||
isNullable: true, | ||
isPrimary: false, | ||
gate, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.