universo-platform-3d

Форк
0
217 строк · 4.2 Кб
1
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
2
import {
3
  IsBoolean,
4
  IsEmail,
5
  IsEnum,
6
  IsMongoId,
7
  IsNotEmpty,
8
  IsNumber,
9
  IsOptional,
10
  IsString,
11
  Max,
12
  Min,
13
  ValidateIf
14
} from 'class-validator'
15
import { USER_AVATAR_TYPE } from '../../option-sets/user-avatar-types'
16
import {
17
  ENTITY_TYPE,
18
  USER_ENTITY_ACTION_TYPE
19
} from '../models/user-entity-action.schema'
20
import { 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
 */
25
export class UpdateUserProfileDto {
26
  @IsOptional()
27
  @IsEmail()
28
  @ApiPropertyOptional()
29
  email: string
30

31
  @IsOptional()
32
  @IsString()
33
  @ApiPropertyOptional()
34
  displayName: string
35

36
  @IsOptional()
37
  @IsString()
38
  @ApiPropertyOptional()
39
  publicBio: string
40

41
  @IsOptional()
42
  @IsString()
43
  @ApiPropertyOptional()
44
  discordUserId: string
45

46
  @IsOptional()
47
  @IsString()
48
  @ApiPropertyOptional()
49
  polygonPublicKey: string
50

51
  @IsOptional()
52
  @IsString()
53
  @ApiPropertyOptional()
54
  ethereumPublicKey: string
55

56
  @IsOptional()
57
  @IsString()
58
  @ApiPropertyOptional()
59
  twitterUsername: string
60

61
  @IsOptional()
62
  @IsString()
63
  @ApiPropertyOptional()
64
  githubUsername: string
65

66
  @IsOptional()
67
  @IsString()
68
  @ApiPropertyOptional()
69
  instagramUsername: string
70

71
  @IsOptional()
72
  @IsString()
73
  @ApiPropertyOptional()
74
  youtubeChannel: string
75

76
  @IsOptional()
77
  @IsString()
78
  @ApiPropertyOptional()
79
  artStationUsername: string
80

81
  @IsOptional()
82
  @IsString()
83
  @ApiPropertyOptional()
84
  sketchfabUsername: string
85

86
  @IsOptional()
87
  @IsString()
88
  @ApiPropertyOptional()
89
  profileImage: string
90

91
  @IsOptional()
92
  @IsString()
93
  @ApiPropertyOptional()
94
  coverImage: string
95
}
96
export class UpdateUserDeepLinkDto {
97
  @IsString()
98
  @IsNotEmpty()
99
  @ApiProperty()
100
  deepLinkKey: string
101
  @IsString()
102
  @IsNotEmpty()
103
  @ApiProperty()
104
  deepLinkValue: string
105
}
106

107
export class UpdateUserTermsDto {
108
  @IsBoolean()
109
  @IsOptional() // optional so that additional terms can be added to this dto in the future
110
  @ApiProperty({
111
    required: false
112
  })
113
  termsAgreedtoClosedAlpha?: boolean
114
  @IsBoolean()
115
  @IsOptional()
116
  @ApiProperty({
117
    required: false
118
  })
119
  termsAgreedtoGeneralTOSandPP?: boolean
120
}
121

122
export class UpdateUserAvatarDto {
123
  @IsString()
124
  @IsNotEmpty()
125
  @ApiProperty()
126
  avatarUrl?: string
127
}
128

129
export class UpdateUserTutorialDto {
130
  @IsBoolean()
131
  @IsOptional()
132
  @ApiProperty()
133
  shownFirstInSpacePopupV1?: boolean
134
  @IsBoolean()
135
  @IsOptional()
136
  @ApiProperty()
137
  shownFirstHomeScreenPopupV1?: boolean
138
  @IsBoolean()
139
  @IsOptional()
140
  @ApiProperty()
141
  shownWebAppPopupV1?: boolean
142
}
143

144
export class UpdateUserAvatarTypeDto {
145
  @IsEnum(USER_AVATAR_TYPE)
146
  @IsNotEmpty()
147
  @ApiProperty()
148
  avatarType: string
149

150
  @ValidateIf((dto) => dto.avatarType === USER_AVATAR_TYPE.READY_PLAYER_ME)
151
  @IsNotEmpty()
152
  @ApiProperty()
153
  readyPlayerMeUrlGlb?: string
154
}
155
export class AddRpmAvatarUrlDto {
156
  @IsString()
157
  @IsNotEmpty()
158
  @ApiProperty()
159
  rpmAvatarUrl: string
160
}
161

162
export class RemoveRpmAvatarUrlDto {
163
  @IsString()
164
  @IsNotEmpty()
165
  @ApiProperty()
166
  rpmAvatarUrl: string
167
}
168

169
export class UpsertUserEntityActionDto {
170
  @IsString()
171
  @IsNotEmpty()
172
  @ApiProperty()
173
  forEntity: string
174

175
  @IsEnum(USER_ENTITY_ACTION_TYPE)
176
  @IsNotEmpty()
177
  @ApiProperty()
178
  actionType: string
179

180
  @IsEnum(ENTITY_TYPE)
181
  @IsNotEmpty()
182
  @ApiProperty()
183
  entityType: 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()
193
  rating?: number
194
}
195

196
export class AddUserCartItemToUserCartDto {
197
  @IsNotEmpty()
198
  @IsString()
199
  @ApiProperty({
200
    description:
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
  })
203
  purchaseOptionId: string
204

205
  @IsNotEmpty()
206
  @IsMongoId()
207
  @ApiProperty({
208
    description: "ObjectId of the entity that it's for"
209
  })
210
  forEntity: string
211

212
  @IsNotEmpty()
213
  @IsString()
214
  @IsEnum(ENTITY_TYPE_AVAILABLE_TO_PURCHASE)
215
  @ApiProperty()
216
  entityType: string
217
}
218

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.