universo-platform-3d

Форк
0
/
license.subdocument.schema.ts 
163 строки · 5.3 Кб
1
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
3
import { IsOptional, IsString } from 'class-validator'
4
import mongoose from 'mongoose'
5
import { ENTITY_TYPE_AVAILABLE_TO_PURCHASE } from '../user/models/user-cart.schema'
6

7
export type LicenseDocument = License & Document
8

9
/**
10
 * @description See https://creativecommons.org/about/cclicenses/ and license dropdown list on https://sketchfab.com/3d-models/popular
11
 */
12
export enum LICENSE_TYPE {
13
  // 2023-08-09 17:13:47 To start, we'll just do MIRROR_REV_SHARE, CC0, CC_BY, and ALL_RIGHTS (ALL_RIGHTS is the default for someone who uploads an asset themselves)
14
  // Creators have full access to an asset with MIRROR_REV_SHARE. This is JUST to note that PLAYERS are restricted from PLAYING games that have assets with MIRROR_REV_SHARE unless they are a Mirror Premium subscriber. When a premium player plays a game with revshare assets, creators of the space get paid out of the pool (both the game creator and the creator of the assets)
15
  MIRROR_REV_SHARE = 'MIRROR_REV_SHARE',
16

17
  /**
18
   * Very limited, time-duration license so someone building a Space can TRY it before they buy it.
19
   * Restrictions:
20
   * - Only Build mode
21
   * - tryTimeDuration: default 15 minutes
22
   */
23
  TRY = 'TRY',
24

25
  // Creative Commons
26
  CC0 = 'CC0', // Full use: public domain
27
  CC_BY = 'CC_BY', // Full use but author must be credited
28
  CC_BY_SA = 'CC_BY_SA', // Full use but author must be credited AND modified versions must be shared under the same license
29

30
  ALL_RIGHTS = 'ALL_RIGHTS', // default when someone creates a new asset.
31

32
  // Important: These are NOT resellable and NOT transferable in the current implementation since we would have to check the license of the original seller. In the future, we could expand this to EXTERNAL_ONE_TIME_PURCHASE_TRANFERABLE though.
33
  EXTERNAL_ONE_TIME_PURCHASE = 'EXTERNAL_ONE_TIME_PURCHASE', // e.g. a Sketchfab model that is for sale on Sketchfab
34
  EXTERNAL_SUBSCRIPTION = 'EXTERNAL_SUBSCRIPTION', // e.g. a Sketchfab model that is for sale on Sketchfab
35

36
  // One-time purchase from The Mirror. This  Mirrors the Unity standard, Sketchfab standard, etc. Includes usage in Godot and others.
37
  STANDARD_ONE_TIME_PURCHASE = 'STANDARD_ONE_TIME_PURCHASE',
38

39
  // Subscription for a specific item that gets paid to the seller (different than MIRROR_REV_SHARE: this only gives access to the single item). TM takes a commission.
40
  // Note that we probably WON'T use this for awhile. We may want to approve developers who offer this (e.g. a business that has a plugin that they maintain)
41
  SUBSCRIPTION_MONTHLY = 'SUBSCRIPTION_MONTHLY'
42
}
43

44
@Schema({
45
  timestamps: true,
46
  toJSON: {
47
    virtuals: true
48
  }
49
})
50
export class License {
51
  @Prop({
52
    required: true,
53
    enum: LICENSE_TYPE
54
  })
55
  @ApiProperty({
56
    enum: LICENSE_TYPE,
57
    required: true
58
  })
59
  licenseType: string
60

61
  @Prop({
62
    required: false,
63
    enum: ENTITY_TYPE_AVAILABLE_TO_PURCHASE
64
  })
65
  @ApiProperty({ type: 'string' })
66
  entityType?: string
67

68
  /**
69
   * Optional: mainly used if the asset is publicly available and we link to the license (common for CC_BY, CC_BY_SA, etc.)
70
   * Example: We include these in our public open-source licenses page: https://the-mirror.notion.site/Open-Source-License-Credits-External-Page-8a3e0d75682b48d7bfaa3518f4b5caaf
71
   *
72
   * Godot: https://docs.godotengine.org/en/stable/about/complying_with_licenses.html
73
   * React: https://github.com/facebook/react/raw/master/LICENSE
74
   */
75
  @Prop({
76
    required: false,
77
    type: String
78
  })
79
  @ApiProperty({
80
    type: String
81
  })
82
  urlToLicense?: string
83

84
  /**
85
   * Optional: mainly used if the license was purchased
86
   */
87
  @Prop({
88
    required: false,
89
    type: Date
90
  })
91
  @ApiProperty({
92
    description:
93
      'Used to record when the license was purchased (if it was purchased)'
94
  })
95
  purchaseDate?: Date
96

97
  @Prop({
98
    required: false,
99
    type: mongoose.Types.ObjectId,
100
    refPath: 'entityType'
101
  })
102
  @ApiProperty({
103
    type: 'string',
104
    description:
105
      'This references the original entity ID (e.g. the Asset) that the license was originally for. This would be optional if the asset was initially made by the creator himself/herself'
106
  })
107
  originalEntityIdIfTransferred?: mongoose.Types.ObjectId
108

109
  // Only for LICENSE_TYPE.TRY
110
  @Prop({
111
    required: false,
112
    type: Date
113
  })
114
  @ApiProperty({
115
    type: Date
116
  })
117
  tryTimeDuration?: Date
118

119
  /**
120
   * EXTERNAL license fields
121
   */
122
  @Prop({
123
    required: false
124
  })
125
  @ApiProperty({
126
    required: false,
127
    description:
128
      'The issuer of the license, such as Sketchfab, Endemic Sound, Unity Asset Store, etc.'
129
  })
130
  externalLicenseIssuer?: string
131

132
  @Prop({
133
    required: false
134
  })
135
  @ApiProperty({
136
    required: false,
137
    description: "The name of the external license, e.g. 'Standard'"
138
  })
139
  externalLicenseName?: string
140

141
  @Prop({
142
    required: false
143
  })
144
  @ApiProperty({
145
    required: false,
146
    description:
147
      "A URL to the external license, e.g. 'https://sketchfab.com/licenses/standard'"
148
  })
149
  externalLicenseUrl?: string
150

151
  // TODO: add this when we add Stripe
152
  // stripeTransactionId? []
153

154
  /**
155
   * Used for subscription licenses
156
   */
157
  // TODO add these: TBD.
158
  /**
159
   * Timestamp when the subscription validity was last checked - cron job?
160
   */
161
}
162

163
export const LicenseSchema = SchemaFactory.createForClass(License)
164

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

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

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

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