[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.
 

376 lines
7.6 KiB

// collections.ts
// Copyright (C) 2020 Dwayne Harris
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// Containers
//
// Users
// - Partition Key: pk (userId)
// Groups
// - Partition Key: pk (groupId)
// Directory
// - Partition Key: pk
// Posts
// - Partition Key: pk (postId)
// Ancestry
// - Partition Key: pk (postId)
import {
USER_LISTING_PARTITION_KEY,
GROUP_LISTING_PARTITION_KEY,
APP_PARTITION_KEY,
INSTALLATION_PARTITION_KEY,
MEDIA_PARTITION_KEY,
} from '../constants'
export enum UserItemType {
User = 'user',
Token = 'token',
Post = 'post',
Follow = 'follow',
Timeline = 'timeline',
Subscription = 'subscription',
InverseSubscription = 'isubscription',
Block = 'block',
Transaction = 'transation',
}
export enum UserPrivacyType {
Public = 'public',
Group = 'group',
Subscribers = 'subscribers',
Private = 'private',
}
export enum GroupStatus {
Pending = 'pending',
Paid = 'paid',
}
export enum GroupRegistrationType {
Open = 'open',
Approval = 'approval',
Closed = 'closed',
}
export enum GroupItemType {
Group = 'group',
Membership = 'membership',
Report = 'report',
Block = 'block',
Invitation = 'invitation',
Log = 'log',
}
export enum GroupMembershipType {
Admin = 'admin',
Moderator = 'moderator',
Member = 'member',
}
export enum ReportStatus {
Pending = 'pending',
Complete = 'complete',
}
export enum BlockType {
User = 'user',
Group = 'group',
}
export interface UserListing {
id: string
pk: typeof USER_LISTING_PARTITION_KEY
groupId?: string
email?: string
phone?: string
created: number
}
export interface GroupListing {
id: string
pk: typeof GROUP_LISTING_PARTITION_KEY
registration: GroupRegistrationType
members: number
created: number
}
export interface Group {
id: string
pk: string // ID
t: GroupItemType.Group
userId: string
name: string // Prenormalized ID
about?: string
codeOfConduct?: string
imageUrl?: string
coverImageUrl?: string
iconImageUrl?: string
theme: string
registration: GroupRegistrationType
members: number
status: GroupStatus
active: boolean
created: number
}
export interface GroupMembership {
id?: string
pk: string // Group ID
t: GroupItemType.Membership
userId: string
pending: boolean
membership: GroupMembershipType
intro?: string
invitation?: string
created: number
}
export interface GroupInvitation {
id: string
pk: string // Group ID
t: GroupItemType.Invitation
userId: string
limit?: number
expiration?: number
uses: number
active: boolean
created: number
}
export interface GroupReport {
id: string
pk: string // Group ID
t: GroupItemType.Report
postId: string
reportedById: string
description?: string
status: string
created: number
}
export interface GroupBlock {
id?: string
pk: string // Group ID
t: GroupItemType.Block
blockedId: string // User or Group ID
userId: string // blocker ID
created: number
}
export interface GroupLog {
id?: string
pk: string // Group ID
t: GroupItemType.Log
userId: string
content: string
created: number
}
export interface UserSettings {
allowThemeChange: boolean
alwaysReveal: boolean
autoPlayGifs: boolean
}
export interface User {
id: string
pk: string // ID
t: UserItemType.User
groupId?: string
group?: Group
name: string
about?: string
imageUrl?: string
coverImageUrl?: string
theme: string
email: string
emailVerified: boolean
phone?: string
phoneVerified: boolean
passwordHash: string
settings: UserSettings
installations: string[]
posts: number
subscriberCount: number
subscribedCount: number
pending: boolean
requiresApproval: boolean
privacy: UserPrivacyType
active: boolean
created: number // Timestamp
}
export interface UserToken {
id: string
pk: string // userId
t: UserItemType.Token
userAgent: string
ip: string
expires: number
created: number
}
export interface UserPost {
id?: string
postId: string
pk: string // userId
t: UserItemType.Post
created: number
}
export interface UserSubscription {
id?: string
userId: string // from
pk: string // to
t: UserItemType.Subscription
pending: boolean
created: number
}
export interface UserInverseSubscription {
id?: string
userId: string // to
pk: string // from
t: UserItemType.InverseSubscription
pending: boolean
created: number
}
export interface UserBlock {
id?: string
blockedId: string
pk: string
t: UserItemType.Block
blockType: BlockType
description?: string
created: number
}
export interface UserTimelinePost {
id: string
pk: string // userId
t: UserItemType.Timeline
created: number
}
export interface PostAttachment {
url: string
text?: string
cover?: string
}
export interface Status {
imageUrl: string
text: string
created: number
}
export interface PostData {
[key: string]: any
}
export interface Post {
id: string
pk: string // postId
userId: string
appId: string
root: string
parents: string[] // Post IDs
text?: string
cover?: string
attachments: PostAttachment[]
status?: Status
data?: PostData
visible: boolean
replies: number
created: number
}
export interface PostRelationship {
id: string
parents: string[] // Post IDs
pk: string // root post ID
}
export interface InstallationSettings {
[key: string]: any
}
export interface Installation {
id: string
pk: typeof INSTALLATION_PARTITION_KEY
userId: string
appId: string
settings: InstallationSettings
created: number
}
export interface AppRevision {
version: string
name: string
imageUrl?: string
coverImageUrl?: string
iconImageUrl?: string
about?: string
websiteUrl?: string
companyName?: string
composerUrl?: string
composerSchema?: object
rendererUrl?: string
rendererSchema?: object
initCallbackUrl?: string
composeCallbackUrl?: string
created: number
}
export interface App {
id: string
pk: typeof APP_PARTITION_KEY
userId: string
version: string
name: string
imageUrl?: string
coverImageUrl?: string
iconImageUrl?: string
about?: string
websiteUrl?: string
companyName?: string
composerUrl?: string
composerSchema?: object
rendererUrl?: string
rendererSchema?: object
initCallbackUrl?: string
composeCallbackUrl?: string
rating: number
users: number
publicKey: string
privateKey: string
preinstall: boolean
revisions: AppRevision[]
active: boolean
updated: number
created: number
}
export interface Media {
id: string
pk: typeof MEDIA_PARTITION_KEY
size: number
type: string
originalName: string
attached: boolean
created: number
}