[ABANDONED] API server for Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

393 lines
7.5 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. // Containers
  2. //
  3. // Users
  4. // - Partition Key: pk (userId)
  5. // Groups
  6. // - Partition Key: pk (groupId)
  7. // GroupDirectory
  8. // - Partition Key: pk
  9. // Posts
  10. // - Partition Key: pk (postId)
  11. // Ancestry
  12. // - Partition Key: pk (postId)
  13. // Points: total reward value + likes
  14. import {
  15. GROUP_LISTING_PARTITION_KEY,
  16. APP_PARTITION_KEY,
  17. INSTALLATION_PARTITION_KEY,
  18. MEDIA_PARTITION_KEY,
  19. } from '../constants'
  20. export enum UserItemType {
  21. User = 'user',
  22. Token = 'token',
  23. Post = 'post',
  24. Follow = 'follow',
  25. Timeline = 'timeline',
  26. Subscription = 'subscription',
  27. InverseSubscription = 'isubscription',
  28. Block = 'block',
  29. Transaction = 'transation',
  30. }
  31. export enum UserPrivacyType {
  32. Public = 'public',
  33. Group = 'group',
  34. Subscribers = 'subscribers',
  35. Private = 'private',
  36. }
  37. export enum UserTransactionType {
  38. Purchase = 'purchase',
  39. Award = 'award',
  40. }
  41. export enum GroupStatus {
  42. Pending = 'pending',
  43. Paid = 'paid',
  44. }
  45. export enum GroupRegistrationType {
  46. Open = 'open',
  47. Approval = 'approval',
  48. Closed = 'closed',
  49. }
  50. export enum GroupItemType {
  51. Group = 'group',
  52. Membership = 'membership',
  53. Report = 'report',
  54. Block = 'block',
  55. Invitation = 'invitation',
  56. Log = 'log',
  57. }
  58. export enum GroupMembershipType {
  59. Admin = 'admin',
  60. Moderator = 'moderator',
  61. Member = 'member',
  62. }
  63. export enum ReportStatus {
  64. Pending = 'pending',
  65. Complete = 'complete',
  66. }
  67. export enum BlockType {
  68. User = 'user',
  69. Group = 'group',
  70. }
  71. export enum PostItemType {
  72. Post = 'post',
  73. Award = 'award',
  74. }
  75. export interface GroupListing {
  76. id: string
  77. pk: typeof GROUP_LISTING_PARTITION_KEY
  78. name: string
  79. about?: string
  80. registration: GroupRegistrationType
  81. members: number
  82. posts: number
  83. awards: number
  84. points: number
  85. latestAwards: PostAwardPartial[]
  86. created: number
  87. }
  88. export interface Group {
  89. id: string
  90. pk: string // ID
  91. t: GroupItemType.Group
  92. userId: string
  93. name: string // Prenormalized ID
  94. about?: string
  95. codeOfConduct?: string
  96. imageUrl?: string
  97. coverImageUrl?: string
  98. iconImageUrl?: string
  99. registration: GroupRegistrationType
  100. status: GroupStatus
  101. active: boolean
  102. created: number
  103. }
  104. export interface GroupMembership {
  105. id?: string
  106. pk: string // Group ID
  107. t: GroupItemType.Membership
  108. userId: string
  109. pending: boolean
  110. membership: GroupMembershipType
  111. invitation?: string
  112. created: number
  113. }
  114. export interface GroupInvitation {
  115. id: string
  116. pk: string // Group ID
  117. t: GroupItemType.Invitation
  118. userId: string
  119. limit?: number
  120. expiration?: number
  121. uses: number
  122. active: boolean
  123. created: number
  124. }
  125. export interface GroupReport {
  126. id: string
  127. pk: string // Group ID
  128. t: GroupItemType.Report
  129. postId: string
  130. reportedById: string
  131. description?: string
  132. status: string
  133. created: number
  134. }
  135. export interface GroupBlock {
  136. id?: string
  137. pk: string // Group ID
  138. t: GroupItemType.Block
  139. blockedId: string // User or Group ID
  140. userId: string // blocker ID
  141. created: number
  142. }
  143. export interface GroupLog {
  144. id?: string
  145. pk: string // Group ID
  146. t: GroupItemType.Log
  147. userId: string
  148. content: string
  149. created: number
  150. }
  151. export interface User {
  152. id: string
  153. pk: string // ID
  154. t: UserItemType.User
  155. groupId?: string
  156. group?: Group
  157. name: string
  158. about?: string
  159. imageUrl?: string
  160. coverImageUrl?: string
  161. email: string
  162. emailVerified: boolean
  163. passwordHash: string
  164. installations: string[]
  165. awards: number // Total Awards
  166. points: number
  167. balance: number // Currency (Flex)
  168. posts: number
  169. subscriberCount: number
  170. subscribedCount: number
  171. pending: boolean
  172. requiresApproval: boolean
  173. privacy: UserPrivacyType
  174. paid: boolean
  175. active: boolean
  176. created: number // Timestamp
  177. }
  178. export interface UserToken {
  179. id: string
  180. pk: string // userId
  181. t: UserItemType.Token
  182. userAgent: string
  183. ip: string
  184. expires: number
  185. created: number
  186. }
  187. export interface UserPost {
  188. id?: string
  189. postId: string
  190. pk: string // userId
  191. t: UserItemType.Post
  192. created: number
  193. }
  194. export interface UserSubscription {
  195. id?: string
  196. userId: string // from
  197. pk: string // to
  198. t: UserItemType.Subscription
  199. pending: boolean
  200. created: number
  201. }
  202. export interface UserInverseSubscription {
  203. id?: string
  204. userId: string // to
  205. pk: string // from
  206. t: UserItemType.InverseSubscription
  207. pending: boolean
  208. created: number
  209. }
  210. export interface UserBlock {
  211. id?: string
  212. blockedId: string
  213. pk: string
  214. t: UserItemType.Block
  215. blockType: BlockType
  216. description?: string
  217. created: number
  218. }
  219. export interface UserTransaction {
  220. id: string
  221. pk: string
  222. t: UserItemType.Transaction
  223. transactionType: UserTransactionType
  224. fromUserId: string
  225. toUserId: string
  226. amount: number
  227. created: number
  228. }
  229. export interface UserTimelinePost {
  230. id: string
  231. pk: string // userId
  232. t: UserItemType.Timeline
  233. created: number
  234. }
  235. export interface PostAttachment {
  236. url: string
  237. text?: string
  238. cover?: string
  239. }
  240. export interface Status {
  241. imageUrl: string
  242. text: string
  243. created: number
  244. }
  245. export interface PostData {
  246. [key: string]: any
  247. }
  248. export interface Post {
  249. id: string
  250. pk: string // postId
  251. t: PostItemType.Post
  252. userId: string
  253. appId: string
  254. root: string
  255. parents: string[] // Post IDs
  256. text?: string
  257. cover?: string
  258. attachments: PostAttachment[]
  259. status?: Status
  260. data?: PostData
  261. visible: boolean
  262. replies: number
  263. awards: number
  264. latestAwards: PostAwardPartial[]
  265. created: number
  266. }
  267. export interface PostAward {
  268. id: string
  269. pk: string // postId
  270. t: PostItemType.Award
  271. userId: string
  272. imageUrl: string
  273. text: string
  274. userText: string
  275. cost: number
  276. reward: number
  277. created: number
  278. }
  279. export interface PostAwardPartial {
  280. userId: string
  281. imageUrl: string
  282. text: string
  283. userText: string
  284. created: number
  285. }
  286. export interface PostRelationship {
  287. id: string
  288. parents: string[] // Post IDs
  289. pk: string // root post ID
  290. }
  291. export interface InstallationSettings {
  292. [key: string]: any
  293. }
  294. export interface Installation {
  295. id: string
  296. pk: typeof INSTALLATION_PARTITION_KEY
  297. userId: string
  298. appId: string
  299. settings: InstallationSettings
  300. created: number
  301. }
  302. export interface AppRevision {
  303. version: string
  304. name: string
  305. imageUrl?: string
  306. coverImageUrl?: string
  307. iconImageUrl?: string
  308. about?: string
  309. websiteUrl?: string
  310. companyName?: string
  311. composerUrl?: string
  312. composerSchema?: object
  313. rendererUrl?: string
  314. rendererSchema?: object
  315. initCallbackUrl?: string
  316. composeCallbackUrl?: string
  317. created: number
  318. }
  319. export interface App {
  320. id: string
  321. pk: typeof APP_PARTITION_KEY
  322. userId: string
  323. version: string
  324. name: string
  325. imageUrl?: string
  326. coverImageUrl?: string
  327. iconImageUrl?: string
  328. about?: string
  329. websiteUrl?: string
  330. companyName?: string
  331. composerUrl?: string
  332. composerSchema?: object
  333. rendererUrl?: string
  334. rendererSchema?: object
  335. initCallbackUrl?: string
  336. composeCallbackUrl?: string
  337. rating: number
  338. users: number
  339. publicKey: string
  340. privateKey: string
  341. preinstall: boolean
  342. revisions: AppRevision[]
  343. active: boolean
  344. updated: number
  345. created: number
  346. }
  347. export interface Media {
  348. id: string
  349. pk: typeof MEDIA_PARTITION_KEY
  350. size: number
  351. type: string
  352. originalName: string
  353. attached: boolean
  354. created: number
  355. }