UNPKG

@wearesage/schema

Version:

A flexible schema definition and validation system for TypeScript with multi-database support

50 lines (39 loc) 1.29 kB
import { Conversation } from './Conversation'; import { Entity, Property, Id, OneToMany, ManyToMany, Index, Email, Timestamp, Auth, Labels } from '../core/decorators'; import { Space } from './Space'; import { Team } from './Team'; @Entity() @Labels(['User']) @Auth({ permissions: ['user'] }) // Authenticated users only export class User { @Id() id!: string; @Property({ required: true }) @Email() @Index() email!: string; @Property({ required: true }) @Index() name!: string; @Property() status?: 'active' | 'inactive' | 'pending'; // Teams owned by this user @OneToMany({ target: () => Team, inverse: 'owners' }) ownedTeams!: Team[]; // Teams this user is a member of @ManyToMany({ target: () => Team, inverse: 'members' }) teams!: Team[]; // Spaces owned by this user @OneToMany({ target: () => Space, inverse: 'owner' }) ownedSpaces!: Space[]; // Spaces this user participates in @ManyToMany({ target: () => Space, inverse: 'participants' }) participatingSpaces!: Space[]; // Conversations this user participates in @ManyToMany({ target: () => Conversation, inverse: 'participants' }) conversations!: Conversation[]; @Timestamp({ onCreate: true }) createdAt!: Date; @Timestamp({ onUpdate: true }) updatedAt!: Date; }