File

src/auth/client/entities/client.entity.ts

Description

Represents a client in the system that belongs to a tenant.

Index

Properties

Properties

clientId
Type : string
Decorators :
@IsString()
@PrimaryColumn()

The unique identifier for the client.

Optional description
Type : string
Decorators :
@IsString()
@IsOptional()
@Column({nullable: true})

The description of the client.

roles
Type : Role[]
Decorators :
@IsEnum(Role, {each: true})
@Column({type: 'json'})

The roles assigned to the client.

Optional secret
Type : string
Decorators :
@IsString()
@Column({nullable: true})

The secret key for the client.

Optional tenant
Type : TenantEntity
Decorators :
@ManyToOne(undefined, tenant => tenant.clients, {onDelete: 'CASCADE'})

The tenant that the client belongs to.

Optional tenantId
Type : string
Decorators :
@Column({nullable: true})

The unique identifier for the tenant that the client belongs to. Only null for accounts that manage tenants, that do not belong to a client.

import { IsEnum, IsOptional, IsString } from "class-validator";
import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm";
import { Role } from "../../roles/role.enum";
import { TenantEntity } from "../../tenant/entitites/tenant.entity";

/**
 * Represents a client in the system that belongs to a tenant.
 */
@Entity()
export class ClientEntity {
    /**
     * The unique identifier for the client.
     */
    @IsString()
    @PrimaryColumn()
    clientId: string;

    /**
     * The secret key for the client.
     */
    @IsString()
    @Column({ nullable: true })
    secret?: string;

    /**
     * The unique identifier for the tenant that the client belongs to. Only null for accounts that manage tenants, that do not belong to a client.
     */
    @Column({ nullable: true })
    tenantId?: string;

    /**
     * The description of the client.
     */
    @IsString()
    @IsOptional()
    @Column({ nullable: true })
    description?: string;

    /**
     * The roles assigned to the client.
     */
    @IsEnum(Role, { each: true })
    @Column({ type: "json" })
    roles: Role[];

    /**
     * The tenant that the client belongs to.
     */
    @ManyToOne(
        () => TenantEntity,
        (tenant) => tenant.clients,
        { onDelete: "CASCADE" },
    )
    tenant?: TenantEntity;
}

results matching ""

    No results matching ""