universo-platform-3d
217 строк · 4.2 Кб
1import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
2import {
3IsBoolean,
4IsEmail,
5IsEnum,
6IsMongoId,
7IsNotEmpty,
8IsNumber,
9IsOptional,
10IsString,
11Max,
12Min,
13ValidateIf
14} from 'class-validator'
15import { USER_AVATAR_TYPE } from '../../option-sets/user-avatar-types'
16import {
17ENTITY_TYPE,
18USER_ENTITY_ACTION_TYPE
19} from '../models/user-entity-action.schema'
20import { ENTITY_TYPE_AVAILABLE_TO_PURCHASE } from '../models/user-cart.schema'
21
22/**
23* NOTE: we don't use full spread operators (...) for DTOs for user because it has senesitive fields that a user shouldn't be able to modify, such as premiumAccess, termsAgreements, etec.
24*/
25export class UpdateUserProfileDto {
26@IsOptional()
27@IsEmail()
28@ApiPropertyOptional()
29email: string
30
31@IsOptional()
32@IsString()
33@ApiPropertyOptional()
34displayName: string
35
36@IsOptional()
37@IsString()
38@ApiPropertyOptional()
39publicBio: string
40
41@IsOptional()
42@IsString()
43@ApiPropertyOptional()
44discordUserId: string
45
46@IsOptional()
47@IsString()
48@ApiPropertyOptional()
49polygonPublicKey: string
50
51@IsOptional()
52@IsString()
53@ApiPropertyOptional()
54ethereumPublicKey: string
55
56@IsOptional()
57@IsString()
58@ApiPropertyOptional()
59twitterUsername: string
60
61@IsOptional()
62@IsString()
63@ApiPropertyOptional()
64githubUsername: string
65
66@IsOptional()
67@IsString()
68@ApiPropertyOptional()
69instagramUsername: string
70
71@IsOptional()
72@IsString()
73@ApiPropertyOptional()
74youtubeChannel: string
75
76@IsOptional()
77@IsString()
78@ApiPropertyOptional()
79artStationUsername: string
80
81@IsOptional()
82@IsString()
83@ApiPropertyOptional()
84sketchfabUsername: string
85
86@IsOptional()
87@IsString()
88@ApiPropertyOptional()
89profileImage: string
90
91@IsOptional()
92@IsString()
93@ApiPropertyOptional()
94coverImage: string
95}
96export class UpdateUserDeepLinkDto {
97@IsString()
98@IsNotEmpty()
99@ApiProperty()
100deepLinkKey: string
101@IsString()
102@IsNotEmpty()
103@ApiProperty()
104deepLinkValue: string
105}
106
107export class UpdateUserTermsDto {
108@IsBoolean()
109@IsOptional() // optional so that additional terms can be added to this dto in the future
110@ApiProperty({
111required: false
112})
113termsAgreedtoClosedAlpha?: boolean
114@IsBoolean()
115@IsOptional()
116@ApiProperty({
117required: false
118})
119termsAgreedtoGeneralTOSandPP?: boolean
120}
121
122export class UpdateUserAvatarDto {
123@IsString()
124@IsNotEmpty()
125@ApiProperty()
126avatarUrl?: string
127}
128
129export class UpdateUserTutorialDto {
130@IsBoolean()
131@IsOptional()
132@ApiProperty()
133shownFirstInSpacePopupV1?: boolean
134@IsBoolean()
135@IsOptional()
136@ApiProperty()
137shownFirstHomeScreenPopupV1?: boolean
138@IsBoolean()
139@IsOptional()
140@ApiProperty()
141shownWebAppPopupV1?: boolean
142}
143
144export class UpdateUserAvatarTypeDto {
145@IsEnum(USER_AVATAR_TYPE)
146@IsNotEmpty()
147@ApiProperty()
148avatarType: string
149
150@ValidateIf((dto) => dto.avatarType === USER_AVATAR_TYPE.READY_PLAYER_ME)
151@IsNotEmpty()
152@ApiProperty()
153readyPlayerMeUrlGlb?: string
154}
155export class AddRpmAvatarUrlDto {
156@IsString()
157@IsNotEmpty()
158@ApiProperty()
159rpmAvatarUrl: string
160}
161
162export class RemoveRpmAvatarUrlDto {
163@IsString()
164@IsNotEmpty()
165@ApiProperty()
166rpmAvatarUrl: string
167}
168
169export class UpsertUserEntityActionDto {
170@IsString()
171@IsNotEmpty()
172@ApiProperty()
173forEntity: string
174
175@IsEnum(USER_ENTITY_ACTION_TYPE)
176@IsNotEmpty()
177@ApiProperty()
178actionType: string
179
180@IsEnum(ENTITY_TYPE)
181@IsNotEmpty()
182@ApiProperty()
183entityType: string
184
185/**
186* Optional properties
187*/
188@IsNumber()
189@IsOptional()
190@Min(1, { message: 'Minimum rating is 1' })
191@Max(5, { message: 'Maximum rating is 5' })
192@ApiProperty()
193rating?: number
194}
195
196export class AddUserCartItemToUserCartDto {
197@IsNotEmpty()
198@IsString()
199@ApiProperty({
200description:
201'The ID of the entity.purchaseOptions array. This is used to track it as the source of truth (e.g. in case the owner changes the purchaseOptions before the buyer pays'
202})
203purchaseOptionId: string
204
205@IsNotEmpty()
206@IsMongoId()
207@ApiProperty({
208description: "ObjectId of the entity that it's for"
209})
210forEntity: string
211
212@IsNotEmpty()
213@IsString()
214@IsEnum(ENTITY_TYPE_AVAILABLE_TO_PURCHASE)
215@ApiProperty()
216entityType: string
217}
218