|
| 1 | +export interface Image { |
| 2 | + src: string; |
| 3 | + alt: string; |
| 4 | + name?: string; |
| 5 | + default?: boolean; |
| 6 | +} |
| 7 | + |
| 8 | +export enum ProviderType { |
| 9 | + PASSWORD = "password", |
| 10 | + GOOGLE = "google.com", |
| 11 | + TWITTER = "twitter.com", |
| 12 | + FACEBOOK = "facebook.com", |
| 13 | +} |
| 14 | + |
| 15 | +export interface ProviderData { |
| 16 | + providerType: ProviderType, |
| 17 | + displayName?: string, |
| 18 | + email?: string, |
| 19 | + phoneNumber?: string, |
| 20 | + photoURL?: string, |
| 21 | + uid?: string |
| 22 | +} |
| 23 | + |
| 24 | +export interface AuthUser { |
| 25 | + name: string; |
| 26 | + email?: string; |
| 27 | + profilePhoto?: Image; |
| 28 | + userId: string; |
| 29 | + username: string; |
| 30 | + verified: boolean; |
| 31 | + providers: ProviderData[]; |
| 32 | +} |
| 33 | + |
| 34 | +export enum FirebaseClaimKey { |
| 35 | + USER_ID = "user_id", |
| 36 | + USERNAME = "username", |
| 37 | + NAME = "name", |
| 38 | + EMAIL = "email", |
| 39 | + EMAIL_VERIFIED = "email_verified", |
| 40 | + PICTURE = "picture", |
| 41 | + FIREBASE = "firebase", |
| 42 | +} |
| 43 | + |
| 44 | +export interface FirebaseClaims { |
| 45 | + [FirebaseClaimKey.USERNAME]: string; |
| 46 | +} |
| 47 | + |
| 48 | +export const ApiConfig = { |
| 49 | + healthy: "/healthy", |
| 50 | + auth: { |
| 51 | + verify: "/auth/verify", |
| 52 | + claims: "/auth/claims", |
| 53 | + }, |
| 54 | + notification: { |
| 55 | + notify: { |
| 56 | + context: "/notification/notify/:notificationId", |
| 57 | + params: { |
| 58 | + notificationId: ":notificationId", |
| 59 | + }, |
| 60 | + }, |
| 61 | + }, |
| 62 | +}; |
| 63 | + |
| 64 | +export enum ApiErrorCode { |
| 65 | + INTERNAL_ERROR = "Internal Error", |
| 66 | + FORBIDDEN = "Forbidden", |
| 67 | + BAD_REQUEST = "Bad Request", |
| 68 | +} |
| 69 | + |
| 70 | +export enum AppCookie { |
| 71 | + TOKEN = '__session', |
| 72 | + REMEMBER_ME = 'rememberMe' |
| 73 | +} |
| 74 | + |
| 75 | +export enum AppHeader { |
| 76 | + SESSION_ID = 'ns-session-id', |
| 77 | + REQUEST_ID = 'ns-request-id' |
| 78 | +} |
| 79 | + |
| 80 | +export const AppTokenType = 'Bearer' |
| 81 | +export const AuthHeaderValuePrefix = `${AppTokenType} ` |
| 82 | + |
| 83 | +export enum PrivacyType { |
| 84 | + PRIVATE = 'private', |
| 85 | + PUBLIC = 'public' |
| 86 | +} |
| 87 | + |
| 88 | +/** |
| 89 | + * FIRESTORE types |
| 90 | + */ |
| 91 | +export enum FirebaseQueryOperator { |
| 92 | + LT = "<", |
| 93 | + LE = "<=", |
| 94 | + EQ = "==", |
| 95 | + GE = ">=", |
| 96 | + GT = ">", |
| 97 | + IN = "in", |
| 98 | + ARRAY_CONTAINS = "array-contains", |
| 99 | + ARRAY_CONTAINS_ANY = "array-contains-any", |
| 100 | +} |
| 101 | + |
| 102 | +export interface WhereClause { |
| 103 | + field: string; |
| 104 | + operator: FirebaseQueryOperator; |
| 105 | + value: any; |
| 106 | +} |
| 107 | + |
| 108 | +export interface OrderBy { |
| 109 | + field: string, |
| 110 | + direction: 'asc'|'desc' |
| 111 | +} |
| 112 | + |
| 113 | +export const orderByName: OrderBy = { |
| 114 | + field: 'name', |
| 115 | + direction: 'asc' |
| 116 | +} |
| 117 | + |
| 118 | +export enum collection { |
| 119 | + USER = "user", |
| 120 | + FOLLOWING = "following", |
| 121 | + NOTIFICATION = "notification", |
| 122 | + USER_DEVICE = "userDevice", |
| 123 | +} |
| 124 | + |
| 125 | +export const CollectionField = { |
| 126 | + BASE: { |
| 127 | + id: "id", |
| 128 | + createdAt: "createdAt", |
| 129 | + }, |
| 130 | + USER: { |
| 131 | + username: "username", |
| 132 | + privacy: "privacy", |
| 133 | + name: "name", |
| 134 | + }, |
| 135 | + USER_DEVICE: { |
| 136 | + userId: "userId", |
| 137 | + deviceToken: "deviceToken", |
| 138 | + }, |
| 139 | + FOLLOWING: { |
| 140 | + follower: "follower", |
| 141 | + following: "following", |
| 142 | + }, |
| 143 | + NOTIFICATION: { |
| 144 | + from: "from", |
| 145 | + to: "to", |
| 146 | + status: "status", |
| 147 | + }, |
| 148 | +}; |
| 149 | + |
| 150 | +export enum PushNotificationType { |
| 151 | + FOLLOW = "follow", |
| 152 | +} |
| 153 | + |
| 154 | +export enum PushNotificationStatus { |
| 155 | + NEW = "new", |
| 156 | + READ = "read", |
| 157 | + DELETED = "deleted", |
| 158 | + IGNORED = "ignored", |
| 159 | +} |
| 160 | + |
| 161 | +export interface BaseModel { |
| 162 | + id?: string |
| 163 | + createdAt?: Date |
| 164 | + createdBy?: string |
| 165 | + updatedAt?: Date |
| 166 | + updatedBy?: string |
| 167 | +} |
| 168 | + |
| 169 | +export interface User extends BaseModel { |
| 170 | + username?: string |
| 171 | + name?: string |
| 172 | + surname?: string |
| 173 | + email?: string |
| 174 | + profilePhoto?: Image |
| 175 | + coverPhoto?: Image |
| 176 | + privacy?: PrivacyType |
| 177 | + followersPrivacy?: PrivacyType |
| 178 | + followingPrivacy?: PrivacyType |
| 179 | +} |
| 180 | + |
| 181 | +export interface PushNotification extends BaseModel { |
| 182 | + from: string |
| 183 | + to: string |
| 184 | + notificationType: PushNotificationType |
| 185 | + status: PushNotificationStatus |
| 186 | +} |
| 187 | + |
| 188 | +export interface UserDevice extends BaseModel { |
| 189 | + userId: string |
| 190 | + deviceToken: string |
| 191 | +} |
| 192 | + |
| 193 | +export interface Following extends BaseModel { |
| 194 | + follower: string, |
| 195 | + following: string, |
| 196 | +} |
0 commit comments