Files
twenty/server/src/coreV2/user/user.entity.ts
Charles Bochet 6129444c5c [WIP] Whole FE migrated (#2517)
* Wip

* WIP

* Removed concole log

* Add relations to workspace init (#2511)

* Add relations to workspace init

* remove logs

* update prefill

* add missing isSystem

* comment relation fields

* Migrate v2 core models to graphql schema (#2509)

* migrate v2 core models to graphql schema

* Migrate to new workspace member schema

* Continue work

* migrated-main

* Finished accountOwner nested field integration on companies

* Introduce bug

* Fix

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Weiko <corentin@twenty.com>
2023-11-15 15:46:06 +01:00

94 lines
1.9 KiB
TypeScript

import { ID, Field, ObjectType } from '@nestjs/graphql';
import {
Entity,
Column,
PrimaryGeneratedColumn,
CreateDateColumn,
UpdateDateColumn,
OneToMany,
} from 'typeorm';
import { IDField } from '@ptc-org/nestjs-query-graphql';
import { GraphQLJSONObject } from 'graphql-type-json';
import { RefreshToken } from 'src/coreV2/refresh-token/refresh-token.entity';
@Entity('userV2')
@ObjectType('userV2')
// @Authorize({
// authorize: (context: any) => ({
// // FIXME: We do not have this relation in the database
// workspaceMember: {
// workspaceId: { eq: context?.req?.user?.workspace?.id },
// },
// }),
// })
export class UserV2 {
@IDField(() => ID)
@PrimaryGeneratedColumn('uuid')
id: string;
@Field()
@Column({ nullable: true })
firstName: string;
@Field()
@Column({ nullable: true })
lastName: string;
@Field()
@Column()
email: string;
@Field()
@Column({ default: false })
emailVerified: boolean;
@Field()
@Column({ nullable: true })
avatarUrl: string;
@Field()
@Column()
locale: string;
@Field({ nullable: true })
@Column({ nullable: true })
phoneNumber: string;
@Field({ nullable: true })
@Column({ nullable: true })
lastSeen: Date;
@Field({ nullable: true })
@Column({ default: false })
disabled: boolean;
@Field({ nullable: true })
@Column({ nullable: true })
passwordHash: string;
@Field(() => GraphQLJSONObject, { nullable: true })
@Column({ type: 'json', nullable: true })
metadata: Record<string, any>;
@Field()
@Column({ default: false })
canImpersonate: boolean;
@Field()
@CreateDateColumn({ type: 'timestamp with time zone' })
createdAt: Date;
@Field()
@UpdateDateColumn({ type: 'timestamp with time zone' })
updatedAt: Date;
@Field({ nullable: true })
@Column({ nullable: true })
deletedAt: Date;
@OneToMany(() => RefreshToken, (refreshToken) => refreshToken.user)
refreshTokens: RefreshToken[];
}