universo-platform-3d
114 строк · 3.8 Кб
1import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2import { ApiProperty } from '@nestjs/swagger'
3import * as mongoose from 'mongoose'
4import { LICENSE_TYPE } from './license.subdocument.schema'
5
6export enum CURRENCY_FOR_PURCHASE_OPTION {
7USD = 'usd'
8// EUR = 'eur' // commented out for now
9}
10/**
11* @description MIRROR_REV_SHARE is for the Mirror Premium Access subscription, similar to Spotify, where the PLAYER pays TM a monthly fee and then TM gives the creator a cut if the user uses that.
12* @date 2023-07-09 17:49
13*/
14export enum PURCHASE_OPTION_TYPE {
15ONE_TIME = 'ONE_TIME',
16ONE_TIME_OPTIONAL_DONATION = 'ONE_TIME_OPTIONAL_DONATION',
17/**
18* IMPORTANT:
19* Spotify model: Charge the players, empower the creators (i.e. we don't charge the creators). Asset creators get paid monthly based on how much their assets are used.
20* Player: When a PLAYER has a Mirror Premium subscription, they can access games that use RevShare assets. The creators (both of the game and the assets) are paid monthly out of the pool of Mirror Premium subscription revenue.
21* Creator: no change, they can use these assets for FREE. They are paid monthly out of the pool of Mirror Premium subscription revenue when paying players play games that have these assets.
22* (Note: If a Space has no RevShare assets, then players can play the game without a premium subscription. If a Space has RevShare assets, then players must have a Mirror Premium subscription to play the game (OR they're shown ads or something else. This is to be determined)
23*/
24MIRROR_REV_SHARE = 'MIRROR_REV_SHARE',
25
26SUBSCRIPTION_MONTHLY = 'SUBSCRIPTION_MONTHLY' // the creator is paid monthly. The Mirror takes a cut. We're not doing this right away.
27}
28
29/**
30* This replaces AssetListing
31*/
32export type PurchaseOptionDocument = PurchaseOption & Document
33
34/**
35* This replaces AssetListing and should only be used a SUBdocument ARRAY of something that can be sold, e.g. asset.purchaseOptions?: PurchaseOption[]
36*/
37@Schema({
38timestamps: true,
39toJSON: {
40virtuals: true
41}
42})
43export class PurchaseOption {
44/**
45* Required fields
46*/
47@Prop({ required: true, default: false, type: Boolean })
48@ApiProperty({
49required: true,
50default: false,
51description: 'Whether this purchase option is active',
52type: Boolean
53})
54enabled: boolean
55
56@Prop({ required: false, type: Number })
57@ApiProperty({
58required: true,
59description:
60'The price in the currency specified in the SMALLEST unit, e.g. cents for USD. See https://stripe.com/docs/currencies',
61type: Number
62})
63price: number
64
65@Prop({ required: false, type: String, enum: CURRENCY_FOR_PURCHASE_OPTION })
66@ApiProperty({
67enum: CURRENCY_FOR_PURCHASE_OPTION,
68description: 'The currency used for the Stripe flow',
69type: String
70})
71currency: string
72
73@Prop({ required: true, type: 'string', enum: PURCHASE_OPTION_TYPE })
74@ApiProperty({
75enum: PURCHASE_OPTION_TYPE,
76description:
77'One-time purchase, subscription, available with Mirror RevShare, etc.',
78type: String
79})
80type: string
81
82@Prop({ required: true, type: 'string', enum: LICENSE_TYPE })
83@ApiProperty({
84enum: LICENSE_TYPE,
85description:
86'The license for the purchase: Standard, Mirror RevShare subscription, CC0, etc. Note that on entities like Asset, this is the same enum as asset.license.licenseType',
87type: String
88})
89licenseType: string
90
91/**
92* Optional fields
93*/
94@Prop({
95required: false
96})
97@ApiProperty({ required: false, type: String })
98description: string
99
100@Prop({ required: false, type: Date })
101@ApiProperty({ required: false })
102startDate: Date
103
104@Prop({ required: false, type: Date })
105@ApiProperty({ required: false })
106endDate: Date
107
108_id: mongoose.Types.ObjectId
109}
110
111/**
112* This replaces AssetListing
113*/
114export const PurchaseOptionSchema = SchemaFactory.createForClass(PurchaseOption)
115