Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.85 KB | None | 0 0
  1. enum STATUS {
  2. ACTIVE
  3. INACTIVE
  4. }
  5.  
  6. enum USER_ROLE {
  7. USER
  8. INFLUENCER
  9. PARTNER
  10. OWNER
  11. UPLOADER
  12. ADMIN
  13. }
  14.  
  15. enum SEX {
  16. MALE
  17. FEMALE
  18. }
  19.  
  20. enum SUBSCRIPTION_TYPE {
  21. MONTHLY
  22. CREDIT
  23. FIX
  24. }
  25.  
  26. enum SUBSCRIPTION_STATUS {
  27. ACTIVE
  28. INACTIVE
  29. CANCELED
  30. PAST_DUE
  31. }
  32.  
  33. enum SUBSCRIPTION_DURATION {
  34. ONE_MONTH
  35. SIX_MONTH
  36. TWELVE_MONTHS
  37. TWENTY_MONTHS
  38. INFINITIVE
  39. }
  40.  
  41. enum CANCELATION_TYPE {
  42. BY_USER
  43. BY_PAST_DUE
  44. BY_STORNO
  45. }
  46.  
  47. enum RIGHTOWNER_TYPE {
  48. AUDIO
  49. TRANSLATION
  50. }
  51.  
  52. enum MOBILE_OS {
  53. ANDROID
  54. IOS
  55. }
  56.  
  57. type User {
  58. id: ID! @unique
  59. email: String! @unique
  60. password: String
  61. socialId: String @unique
  62. deviceId: String @unique
  63. firstName: String
  64. lastName: String
  65. role: USER_ROLE! @default(value: "USER")
  66. billingName: String
  67. contactName: String
  68. publisher: String
  69. taxId: String
  70. country: String
  71. zip: String
  72. city: String
  73. address: String
  74. phone: String
  75. sex: SEX
  76. age: String
  77. clientValue: Int @default(value: "0")
  78. sapiId: Int
  79. mobileOS: MOBILE_OS
  80. purchasedBooks: [PurchasedBook!]! @relation(name: "UserPurchasedBook", onDelete: CASCADE)
  81. subscriptions: [Subscription!]! @relation(name: "UserSubscription", onDelete: SET_NULL)
  82. listenedChapters: [ListenedChapter!]! @relation(name: "UserListenedChapter", onDelete: SET_NULL)
  83. status: STATUS @default(value: "INACTIVE")
  84. isTester: Boolean @default(value: "false")
  85. code: String
  86. usedCoupons: [UserCoupon!]! @relation(name: "UserCoupons")
  87. royalty: UserRoyalty @realation(name: "UserUserRoyalty", onDelete: SET_NULL)
  88. completedChapters: [CompletedChapter!]!
  89. listenStatistic: AggregatedUserStatistic @relation(name: "AggregatedUserStatisticUser", onDelete: SET_NULL)
  90. createdAt: DateTime!
  91. updatedAt: DateTime!
  92. }
  93.  
  94. type Book {
  95. id: ID! @unique
  96. name: String!
  97. longName: String
  98. author: String
  99. authors: [Author!]! @realation(name: "BookAuthor")
  100. publisher: Publisher @realation(name: "BookPublisher")
  101. narrator: Narrator @realation(name: "BookNarrator")
  102. slug: String
  103. translator: String
  104. description: String
  105. image: String
  106. isbn: String
  107. releaseYear: String
  108. fullLength: String
  109. categories: [Category!]! @relation(name: "BookCategory")
  110. tags: [Tag!]! @relation(name: "BookTags")
  111. chapters: [Chapter!]! @relation(name: "BookChapters", onDelete: CASCADE)
  112. price: BookPrice! @relation(name: "BookPriceBook", onDelete: CASCADE)
  113. royalty: [BookRoyalty!]! @relation(name: "BookRoyalty", onDelete: CASCADE)
  114. isFree: Boolean @default(value: false)
  115. isSelfProduction: Boolean @default(value: true)
  116. status: STATUS @default(value: "INACTIVE")
  117. deletedAt: DateTime
  118. createdAt: DateTime!
  119. updatedAt: DateTime!
  120. }
  121.  
  122. type Chapter {
  123. id: ID! @unique
  124. name: String!
  125. description: String
  126. file: File @relation(name: "ChapterFile", onDelete: CASCADE)
  127. book: Book @relation(name: "BookChapters")
  128. isFirst: Boolean @default(value: false)
  129. order: Int @default(value: 0)
  130. status: STATUS @default(value: "INACTIVE")
  131. createdAt: DateTime!
  132. updatedAt: DateTime!
  133. deletedAt: DateTime
  134. }
  135.  
  136. type Category {
  137. id: ID! @unique
  138. name: String! @unique
  139. slug: String @unique
  140. description: String
  141. image: String
  142. books: [Book!]! @relation(name: "BookCategory", onDelete: SET_NULL)
  143. parent: Category @relation(name: "CategoriesRelation")
  144. categories: [Category!]!
  145. @relation(name: "CategoriesRelation", onDelete: SET_NULL)
  146. rank: Int
  147. status: STATUS @default(value: "INACTIVE")
  148. createdAt: DateTime!
  149. updatedAt: DateTime!
  150. }
  151.  
  152. type Tag {
  153. id: ID! @unique
  154. name: String! @unique
  155. createdAt: DateTime!
  156. updatedAt: DateTime!
  157. }
  158.  
  159. type Narrator {
  160. id: ID! @unique
  161. books: [Book] @realation(name: "BookNarrator")
  162. name: String! @unique
  163. slug: String @unique
  164. description: String
  165. image: String
  166. createdAt: DateTime!
  167. updatedAt: DateTime!
  168. }
  169.  
  170. type File {
  171. id: ID! @unique
  172. name: String
  173. url: String
  174. duration: String
  175. size: Int
  176. encrypted: Boolean @default(value: false)
  177. chapter: Chapter! @relation(name: "ChapterFile")
  178. createdAt: DateTime!
  179. updatedAt: DateTime!
  180. }
  181.  
  182. type PasswordReset {
  183. id: ID! @unique
  184. email: String! @unique
  185. token: String! @unique
  186. site: String
  187. notification: Boolean @default(value: true)
  188. createdAt: DateTime!
  189. updatedAt: DateTime!
  190. }
  191.  
  192. type Subscription {
  193. id: ID! @unique
  194. orderId: Int! @unique
  195. user: User! @relation(name: "UserSubscription")
  196. type: SUBSCRIPTION_TYPE!
  197. durationMonths: SUBSCRIPTION_DURATION! @default(value: ONE_MONTH)
  198. credit: Float @default(value: 0)
  199. monthlyCredit: Int @default(value: 0)
  200. amount: Int!
  201. startedAt: DateTime!
  202. endAt: DateTime
  203. isRecurring: Boolean! @default(value: false)
  204. referenceTransactionId: String
  205. transactions: [Transaction!]!
  206. @relation(name: "SubscriptionTransactions", onDelete: SET_NULL)
  207. status: SUBSCRIPTION_STATUS! @default(value: INACTIVE)
  208. usedCoupon: UserCoupon @relation(name: "UserCouponSubscription")
  209. purchasedBooks: [PurchasedBook!]! @relation(name: "SubscriptionPurchasedBook")
  210. listenStatistic: AggregatedSubscriptionListenStatic @relation(name: "SubscriptionAggregatedSubscription")
  211. canceledBy: CANCELATION_TYPE @default(value: null)
  212. createdAt: DateTime!
  213. updatedAt: DateTime!
  214. }
  215.  
  216. type Transaction {
  217. id: ID! @unique
  218. subscription: Subscription!
  219. @relation(name: "SubscriptionTransactions", onDelete: SET_NULL)
  220. transactionId: String @unique
  221. amount: Int!
  222. message: String
  223. isPaid: Boolean! @default(value: false)
  224. invoice: String
  225. gatewayResponse: String
  226. createdAt: DateTime!
  227. updatedAt: DateTime!
  228. }
  229.  
  230. type PurchasedBook {
  231. id: ID! @unique
  232. user: User! @relation(name: "UserPurchasedBook")
  233. book: Book!
  234. subscription: Subscription! @relation(name: "SubscriptionPurchasedBook")
  235. royalty: RoyaltyBook
  236. royaltyPrice: Float @default(value: "0")
  237. royaltyRate: Float @default(value: "0")
  238. status: STATUS @default(value: INACTIVE)
  239. createdAt: DateTime!
  240. updatedAt: DateTime!
  241. }
  242.  
  243. type BookPrice {
  244. id: ID! @unique
  245. book: Book! @relation(name: "BookPriceBook")
  246. fullPrice: Int
  247. credit: Float @default(value: 1)
  248. acquisitionPrice: Int
  249. createdAt: DateTime!
  250. updatedAt: DateTime!
  251. }
  252.  
  253. type BookRoyalty {
  254. id: ID! @unique
  255. user: User! @relation(name: "RoyaltyBookRightOwner")
  256. book: Book! @relation(name: "BookRoyalty")
  257. rate: Int
  258. fullPrice: Int
  259. creditPrice: Int
  260. minuteCharge: Int
  261. type: RIGHTOWNER_TYPE!
  262. createdAt: DateTime!
  263. updatedAt: DateTime!
  264. }
  265.  
  266. type UserRoyalty {
  267. id: ID! @unique
  268. user: User!
  269. rate: Int
  270. couponDiscount: Int
  271. fullPrice: Int
  272. creditPrice: Int
  273. minuteCharge: Int
  274. logo: String
  275. shortDescription: String
  276. createdAt: DateTime!
  277. updatedAt: DateTime!
  278. }
  279.  
  280. type ListenedChapter {
  281. id: ID! @unique
  282. user: User! @relation(name: "UserListenedChapter")
  283. chapter: Chapter!
  284. stoppedTime: String!
  285. playedLength: String!
  286. royalty: RoyaltyBook @relation(name: "RoyaltyBookListenedChapter")
  287. timestamp: String
  288. royaltyPrice: Float @default(value: "0")
  289. royaltyRate: Float @default(value: "0")
  290. withCoupon: Boolean @default(value: "false")
  291. withSubscription: Boolean @default(value: "false")
  292. createdAt: DateTime!
  293. updatedAt: DateTime!
  294. }
  295.  
  296. type Option {
  297. id: ID! @unique
  298. key: String! @unique
  299. name: String
  300. value: String!
  301. createdAt: DateTime!
  302. updatedAt: DateTime!
  303. }
  304.  
  305. type Royalty {
  306. id: ID! @unique
  307. date: String!
  308. owner: User! @relation(name: "UserRoyalty")
  309. total: Float!
  310. invoice: String
  311. isClosed: Boolean @default(value: "false")
  312. createdAt: DateTime!
  313. updatedAt: DateTime!
  314. }
  315.  
  316. type RoyaltyBook {
  317. id: ID! @unique
  318. royalty: Royalty! @relation(name: "RoyaltyRoyaltyBook")
  319. book: Book! @relation(name: "BookRoyaltyBook")
  320. type: SUBSCRIPTION_TYPE!
  321. playedLength: Int
  322. quantity: Int
  323. charge: Int
  324. price: Float
  325. total: Float
  326. isSelfProduction: Boolean
  327. listenedChapters: [ListenedChapter!]! @relation(name: "RoyaltyBookListenedChapter")
  328. purchasedBooks: [PurchasedBook!]!
  329. createdAt: DateTime!
  330. updatedAt: DateTime!
  331. }
  332.  
  333. type Coupon {
  334. id: ID! @unique
  335. code: String! @unique
  336. owner: User!
  337. discount: Float!
  338. isReusable: Boolean @default(value: false)
  339. used: [UserCoupon]!
  340. subscriptions: [CouponSubscription]! @relation(name: "CouponSubscriptionCoupon")
  341. createdAt: DateTime!
  342. updatedAt: DateTime!
  343. }
  344.  
  345. type CouponSubscription {
  346. id: ID! @unique
  347. coupon: Coupon @relation(name: "CouponSubscriptionCoupon")
  348. couponDiscount: Float @default(value: null)
  349. type: SUBSCRIPTION_TYPE
  350. durationMonths: SUBSCRIPTION_DURATION
  351. price: Float
  352. credit: Float
  353. createdAt: DateTime!
  354. updatedAt: DateTime!
  355. }
  356.  
  357. type UserCoupon {
  358. id: ID! @unique
  359. user: User! @relation(name: "UserCoupons")
  360. owner: User @relation(name: "CouponUser")
  361. coupon: Coupon
  362. discount: Int
  363. code: String!
  364. usedAt: DateTime
  365. subscription: Subscription @relation(name: "UserCouponSubscription")
  366. createdAt: DateTime!
  367. updatedAt: DateTime!
  368. }
  369.  
  370. type RoyaltyTransaction {
  371. id: ID! @unique
  372. royalty: Royalty! @relation(name: "RoyaltyRoylatyTransaction")
  373. transaction: Transaction! @relation(name: "TransactionRoylatyTransaction")
  374. type: SUBSCRIPTION_TYPE!
  375. total: Float
  376. percent: Int
  377. createdAt: DateTime!
  378. updatedAt: DateTime!
  379. }
  380.  
  381. type Author {
  382. id: ID! @unique
  383. books: [Book!]! @realation(name: "BookAuthor")
  384. name: String!
  385. slug: String @unique
  386. description: String
  387. image: String
  388. createdAt: DateTime!
  389. updatedAt: DateTime!
  390. }
  391.  
  392. type Publisher {
  393. id: ID! @unique
  394. name: String!
  395. books: [Book] @realation(name: "BookPublisher")
  396. slug: String @unique
  397. description: String
  398. image: String
  399. createdAt: DateTime!
  400. updatedAt: DateTime!
  401. }
  402.  
  403. type Favorite {
  404. id: ID! @unique
  405. user: User!
  406. book: Book!
  407. createdAt: DateTime!
  408. updatedAt: DateTime!
  409. }
  410.  
  411. type CompletedChapter {
  412. id: ID! @unique
  413. user: User!
  414. book: Book!
  415. chapter: Chapter!
  416. createdAt: DateTime!
  417. updatedAt: DateTime!
  418. }
  419.  
  420. type AggregatedStatistic {
  421. id: ID! @unique
  422. month: String! @unique
  423. MONTHLY: Int!
  424. MONTHLY_TRANSACTION: Int!
  425. CREDIT: Int!
  426. CREDIT_TRANSACTION: Int!
  427. FIX: Int!
  428. FIX_TRANSACTION: Int!
  429. CANCELLED: Int!
  430. FREE: Int!
  431. NEW_USERS: Int!
  432. NEW_SUBSCRIBER: Int!
  433. RESUBSCRIBER: Int!
  434. MONTHLY_AVG: Float!
  435. COUPON_AVG: Float!
  436. FREE_AVG: Float!
  437. createdAt: DateTime!
  438. updatedAt: DateTime!
  439. }
  440.  
  441. type AggregatedDailyListens {
  442. id: ID! @unique
  443. day: DateTime! @unique
  444. ALL_LISTENS: Int!
  445. MONTHLY_ALL: Int!
  446. COUPON_ALL: Int!
  447. FREE_ALL: Int!
  448. FIX_ALL: Float!
  449. CREDIT_ALL: Int!
  450. CREDIT: Int!
  451. CREDIT_COUPON: Int!
  452. MONTHLY: Int!
  453. MONTHLY_COUPON: Int!
  454. }
  455.  
  456. type AggregatedUserStatistic {
  457. id: ID! @unique
  458. user: User! @unique @relation(name: "AggregatedUserStatisticUser", onDelete: SET_NULL)
  459. ALL_IN_LISTENS: Float!
  460. COUPON_LISTENS: Float!
  461. ALL_IN_LISTENS_AVG: Float!
  462. USER_VALUE: Float!
  463. FREE_LISTENS: Float!
  464. }
  465.  
  466. type AggregatedSubscriptionListenStatic {
  467. id: ID! @unique
  468. subscription: Subscription! @relation(name: "SubscriptionAggregatedSubscription")
  469. ALL_IN_LISTENS: Float!
  470. COUPON_LISTENS: Float!
  471. listens: [ListenedBookLengthStatics] @relation(name: "LisenBookAggregation", onDelete: CASCADE)
  472. createdAt: DateTime!
  473. updatedAt: DateTime!
  474. }
  475.  
  476. type ListenedBookLengthStatics {
  477. id: ID! @unique
  478. book: Book!
  479. subscriptionAggregateions: AggregatedSubscriptionListenStatic! @relation(name: "LisenBookAggregation")
  480. ALL_IN_LISTENS: Int!
  481. COUPON_LISTENS: Float!
  482. }
  483.  
  484. type AggregatedBookStatic {
  485. id: ID! @unique
  486. book: Book!
  487. startDate: DateTime!
  488. endDate: DateTime!
  489. LISTEN_SUM: Int!
  490. MONTHLY_SUM: Int!
  491. COUPON_SUM: Int!
  492. FREE_SUM: Int!
  493. }
  494.  
  495. type LastListenedBooksPayload {
  496. id: ID! @unique
  497. user: User!
  498. book: Book!
  499. lastListenedChapter: ListenedChapter
  500. createdAt: DateTime!
  501. updatedAt: DateTime!
  502. }
  503.  
  504. type Migration {
  505. name: String! @unique
  506. createdAt: DateTime!
  507. updatedAt: DateTime!
  508. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement