feat: drop calendar repository (#5824)

This PR is replacing and removing all the raw queries and repositories
with the new `TwentyORM` and injection system using
`@InjectWorkspaceRepository`.
Some logic that was contained inside repositories has been moved to the
services.
In this PR we're only replacing repositories for calendar feature.

---------

Co-authored-by: Weiko <corentin@twenty.com>
Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Jérémy M
2024-06-22 09:26:58 +02:00
committed by GitHub
parent 91b0c2bb8e
commit 0b4bfce324
90 changed files with 979 additions and 1541 deletions

View File

@ -1,19 +1,20 @@
import { ObjectLiteral } from 'typeorm';
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
export type ObjectRecord<T extends ObjectLiteral> = {
[K in keyof T as T[K] extends BaseWorkspaceEntity
? `${Extract<K, string>}Id`
: K]: T[K] extends BaseWorkspaceEntity
? string
: T[K] extends BaseWorkspaceEntity[]
? string[]
: T[K];
} & {
[K in keyof T]: T[K] extends BaseWorkspaceEntity
? ObjectRecord<T[K]>
: T[K] extends BaseWorkspaceEntity[]
? ObjectRecord<T[K][number]>[]
: T[K];
type RelationKeys<T> = {
[K in keyof T]: NonNullable<T[K]> extends BaseWorkspaceEntity ? K : never;
}[keyof T];
type ForeignKeyMap<T> = {
[K in RelationKeys<T> as `${K & string}Id`]: string;
};
type RecursiveObjectRecord<T> = {
[P in keyof T]: NonNullable<T[P]> extends BaseWorkspaceEntity
? ObjectRecord<NonNullable<T[P]>> & ForeignKeyMap<NonNullable<T[P]>>
: T[P];
};
// TODO: We should get rid of that it's causing too much issues
// Some relations can be null or undefined because they're not mendatory and other cannot
// This utility type put as defined all the joinColumn, so it's not well typed
export type ObjectRecord<T> = RecursiveObjectRecord<T> & ForeignKeyMap<T>;