Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

1.9 KB
Raw Blame
/*
 * Copyright 2025 Daytona Platforms Inc.
 * Modified by BoxLite AI, 2025-2026
 * SPDX-License-Identifier: AGPL-3.0
 */

import { ApiProperty, ApiPropertyOptional, ApiSchema } from '@nestjs/swagger'
import { OrganizationMemberRole } from '../enums/organization-member-role.enum'
import { OrganizationRoleDto } from './organization-role.dto'
import { OrganizationUser } from '../entities/organization-user.entity'
import { User } from '../../user/user.entity'

@ApiSchema({ name: 'OrganizationUser' })
export class OrganizationUserDto {
  @ApiProperty({
    description: 'User ID',
  })
  userId: string

  @ApiProperty({
    description: 'Organization ID',
  })
  organizationId: string

  @ApiProperty({
    description: 'User name',
  })
  name: string

  @ApiProperty({
    description: 'User email',
  })
  email: string

  @ApiProperty({
    description: 'Member role',
    enum: OrganizationMemberRole,
  })
  role: OrganizationMemberRole

  @ApiPropertyOptional({
    readOnly: true,
    description: 'Set on the authenticated member when they are a system administrator.',
  })
  isSystemAdmin?: boolean

  @ApiProperty({
    description: 'Whether this organization membership is the user default organization',
  })
  isDefaultForUser: boolean

  @ApiProperty({
    description: 'Roles assigned to the user',
    type: [OrganizationRoleDto],
  })
  assignedRoles: OrganizationRoleDto[]

  @ApiProperty({
    description: 'Creation timestamp',
  })
  createdAt: Date

  @ApiProperty({
    description: 'Last update timestamp',
  })
  updatedAt: Date

  static fromEntities(organizationUser: OrganizationUser, user: User | null | undefined): OrganizationUserDto {
    const dto: OrganizationUserDto = {
      ...organizationUser,
      assignedRoles: organizationUser.assignedRoles.map(OrganizationRoleDto.fromOrganizationRole),
      name: user ? user.name : '',
      email: user ? user.email : '',
    }

    return dto
  }
}