universo-platform-3d

Форк
0
80 строк · 2.0 Кб
1
import * as mongoose from 'mongoose'
2
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
3
import { ApiProperty } from '@nestjs/swagger'
4
import { BLOCK_TYPE } from '../option-sets/block-type'
5
import { User } from '../user/user.schema'
6

7
export class BlockPublicData {
8
  @ApiProperty() // @ApiProperty must be included to be exposed by the API and flow to FE codegen
9
  _id = '' // Must not be undefined
10
  @ApiProperty()
11
  createdAt = new Date()
12
  @ApiProperty()
13
  updatedAt = new Date()
14
  @ApiProperty()
15
  name = ''
16
  @ApiProperty()
17
  description = ''
18
  @ApiProperty({ enum: BLOCK_TYPE })
19
  blockType = ''
20
}
21

22
export type BlockDocument = Block & Document
23

24
@Schema({
25
  timestamps: true,
26
  toJSON: {
27
    virtuals: true
28
  },
29
  strict: false // TEMP allowed until we lock down the structure for game logic
30
})
31
export class Block {
32
  /**
33
   * @description Human-readable name that the user will see for this block. The maxlength is arbitrary.
34
   * @date 2022-12-13 16:46
35
   */
36
  @Prop({ required: true, maxlength: 255 })
37
  @ApiProperty()
38
  name: string
39

40
  @Prop({
41
    required: false,
42
    default: BLOCK_TYPE.GENERIC,
43
    type: String,
44
    enum: BLOCK_TYPE
45
  })
46
  @ApiProperty({ enum: BLOCK_TYPE })
47
  blockType: string
48

49
  /**
50
   * @description Human-readable name that the user will see for this block. The maxlength is arbitrary.
51
   * @date 2022-12-13 16:46
52
   */
53
  @Prop()
54
  @ApiProperty({ required: false, maxLength: 1000 })
55
  description: string
56

57
  /**
58
   * @description Who the block was created by. This will be a TM account if is true
59
   * @date 2022-12-13 16:46
60
   */
61
  @Prop({
62
    type: mongoose.Schema.Types.ObjectId,
63
    ref: 'User'
64
  })
65
  @ApiProperty()
66
  creator: User
67

68
  /**
69
   * @description Whether the block is available to the public for all to use. This should be for general Mirror-provided blocks
70
   * @date 2022-12-13 16:45
71
   */
72
  @Prop({
73
    required: true,
74
    default: false
75
  })
76
  @ApiProperty()
77
  mirrorPublicLibrary: boolean
78
}
79

80
export const BlockSchema = SchemaFactory.createForClass(Block)
81

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

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

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

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