Migrate components to typescript

This commit is contained in:
Qolzam
2017-10-30 20:48:18 +07:00
parent 97c2e0f157
commit 7bbb1679ad
346 changed files with 6045 additions and 3946 deletions

View File

@@ -0,0 +1,7 @@
import { LoginUser } from './loginResult'
import { RegisterUserResult } from './registerUserResult'
export {
LoginUser,
RegisterUserResult
}

View File

@@ -0,0 +1,25 @@
import { BaseDomain } from 'core/domain/common'
export class LoginUser extends BaseDomain{
constructor(uid: string){
super()
this._uid = uid
}
/**
* User identifier
*
* @type {string}
* @memberof LoginUser
*/
private _uid : string
public get uid() : string {
return this._uid
}
}

View File

@@ -0,0 +1,23 @@
import { BaseDomain } from 'core/domain/common'
export class RegisterUserResult extends BaseDomain{
constructor(uid: string){
super()
this._uid = uid
}
/**
* User identifier
*
* @type {string}
* @memberof LoginUser
*/
private _uid : string
public get uid (): string {
return this._uid
}
}

View File

@@ -0,0 +1,46 @@
import { UserFollower } from './userFollower'
import { BaseDomain } from 'core/domain/common'
export class Circle extends BaseDomain {
/**
* Circle identifier
*
* @type {string}
* @memberof User
*/
public id?: string | null
/**
* Circle creation date time
*
* @type {Date}
* @memberof Circle
*/
public creationDate?: number
/**
* Circle owner identifier
*
* @type {string}
* @memberof Circle
*/
public ownerId?: string | null
/**
* Circle name
*
* @type {string}
* @memberof User
*/
public name: string
/**
* The users in a circle
*
* @type {string}
* @memberof User
*/
public users: {[userId: string]: UserFollower}
}

View File

@@ -0,0 +1,7 @@
import {Circle} from './circle'
import {UserFollower} from './userFollower'
export {
Circle,
UserFollower
}

View File

@@ -0,0 +1,45 @@
import { BaseDomain } from 'core/domain/common'
export class UserFollower extends BaseDomain {
/**
* User identifier
*
* @type {string}
* @memberof UserFollower
*/
userId?: string
/**
* Circle creation date time
*
* @type {Date}
* @memberof Circle
*/
public creationDate?: number
/**
* User full name
*
* @type {string}
* @memberof UserFollower
*/
public fullName: string
/**
* Avatar URL address
*
* @type {string}
* @memberof UserFollower
*/
public avatar: string
/**
* If following user approved {true} or not {false}
*
* @type {Boolean}
* @memberof UserFollower
*/
public approved?: Boolean
}

View File

@@ -0,0 +1,78 @@
import { BaseDomain } from 'core/domain/common'
export class Comment extends BaseDomain {
/**
* Comment identifier
*
* @type {string}
* @memberof Comment
*/
public id?: string | null
/**
* Post identifier that comment belong to
*
* @type {string}
* @memberof Comment
*/
public postId: string
/**
* Comment text
*
* @type {string}
* @memberof Comment
*/
public text?: string | null
/**
* Comment score
*
* @type {number}
* @memberof Comment
*/
public score?: number | null
/**
* Comment creation date
*
* @type {number}
* @memberof Comment
*/
public creationDate?: number
/**
* Comment owner full name
*
* @type {string}
* @memberof Comment
*/
public userDisplayName?: string
/**
* Comment owner avater address
*
* @type {string}
* @memberof Comment
*/
public userAvatar?: string
/**
* Comment owner identifier
*
* @type {string}
* @memberof Comment
*/
public userId?: string
/**
* Comment is in edit state {true} or not {false}
*
* @type {boolean}
* @memberof Comment
*/
// TODO: Should be changed to reuseable component and remove this property
editorStatus?: boolean
}

View File

@@ -0,0 +1,5 @@
import {Comment} from './comment'
export {
Comment
}

View File

@@ -0,0 +1,4 @@
export class BaseDomain{
}

View File

@@ -0,0 +1,7 @@
import { SocialError } from './socialError'
import { BaseDomain } from './baseDomain'
export {
SocialError,
BaseDomain
}

View File

@@ -0,0 +1,38 @@
export class SocialError {
/**
* Error code
*
* @type {string}
* @memberof SocialError
*/
public get code (): string {
return this._code
}
/**
* Error message
*
* @type {string}
* @memberof SocialError
*/
public get message (): string {
return this._message
}
/**
* If is error {true} if not {false}
*
* @type {Boolean}
* @memberof SocialError
*/
private _isError: Boolean
public get isError (): Boolean {
return this._isError
}
constructor (private _code: string, private _message: string) {
this._isError = true
}
}

View File

@@ -0,0 +1,69 @@
import { BaseDomain } from 'core/domain/common'
export class Image extends BaseDomain {
/**
* Image identifier
*
* @type {string}
* @memberof Image
*/
public id?: string | null
/**
* Image creation date
*
* @type {number}
* @memberof Image
*/
public creationDate: number
/**
* Image delete date
*
* @type {string}
* @memberof Image
*/
public deleteDate: string
/**
* Image URL address
*
* @type {string}
* @memberof Image
*/
public URL: string
/**
* Image folder name with image name {folderName/imageName}
*
* @type {string}
* @memberof Image
*/
public fullPath: string
/**
* Image owner identifier
*
* @type {string}
* @memberof Image
*/
public ownerUserId: string
/**
* Last edit date
*
* @type {number}
* @memberof Image
*/
public lastEditDate: number
/**
* If the image was deleted {true} or not {false}
*
* @type {Boolean}
* @memberof Image
*/
public deleted: Boolean
}

View File

@@ -0,0 +1,5 @@
import { Image } from './image'
export {
Image
}

View File

@@ -0,0 +1,5 @@
import {Notification} from './notification'
export {
Notification
}

View File

@@ -0,0 +1,45 @@
import { BaseDomain } from 'core/domain/common'
export class Notification extends BaseDomain {
/**
* Description of notification
*
* @type {string}
* @memberof Notification
*/
public description: string
/**
* The URL which notification refer to
*
* @type {string}
* @memberof Notification
*/
public url: string
/**
* The identifier of the user who makes the notification
*
* @type {string}
* @memberof Notification
*/
public notifierUserId: string
/**
* The identifier of the user who receive the notification
*
* @type {string}
* @memberof Notification
*/
public notifyRecieverUserId: string
/**
* If the notification is seen {true} or not {false}
*
* @type {Boolean}
* @memberof Notification
*/
public isSeen: boolean
}

View File

@@ -0,0 +1,5 @@
import {Post} from './post'
export {
Post
}

View File

@@ -0,0 +1,157 @@
import { BaseDomain } from 'core/domain/common'
export class Post extends BaseDomain {
/**
* Post identifier
*
* @type {string}
* @memberof Post
*/
public id?: string | null
/**
* The identifier of post type
*
* @type {number}
* @memberof Post
*/
public postTypeId?: number
/**
* The post creation date
*
* @type {number}
* @memberof Post
*/
public creationDate?: number
/**
* The post delete date
*
* @type {number}
* @memberof Post
*/
public deleteDate?: number
/**
* The score of post
*
* @type {number}
* @memberof Post
*/
public score?: number
/**
* Post view count
*
* @type {number}
* @memberof Post
*/
public viewCount?: number
/**
* The text of post
*
* @type {string}
* @memberof Post
*/
public body?: string
/**
* The identifier of post owner
*
* @type {string}
* @memberof Post
*/
public ownerUserId?: string
/**
* Full name of post owner
*
* @type {string}
* @memberof Post
*/
public ownerDisplayName?: string
/**
* Avatar address of post owner
*
* @type {string}
* @memberof Post
*/
public ownerAvatar?: string
/**
* Last post edit date
*
* @type {number}
* @memberof Post
*/
public lastEditDate?: number
/**
* Post tags
*
* @type {string[]}
* @memberof Post
*/
public tags?: string[]
/**
* Numeber of comment on the post
*
* @type {number}
* @memberof Post
*/
public commentCounter?: number
/**
* The address of image on the post
*
* @type {string}
* @memberof Post
*/
public image?: string
/**
* Post image full path
*
* @type {string}
* @memberof Post
*/
public imageFullPath?: string
/**
* The adress of video on the post
*
* @type {string}
* @memberof Post
*/
public video?: string
/**
* If writing comment is disabled {true} or not {false}
*
* @type {Boolean}
* @memberof Post
*/
public disableComments?: Boolean
/**
* If sharing post is disabled {true} or not {false}
*
* @type {Boolean}
* @memberof Post
*/
public disableSharing?: Boolean
/**
* If the post is deleted {true} or not false
*
* @type {Boolean}
* @memberof Post
*/
public deleted?: Boolean
}

View File

@@ -0,0 +1,7 @@
import {User} from './user'
import {Profile} from './profile'
export {
User,
Profile
}

View File

@@ -0,0 +1,45 @@
import { BaseDomain } from 'core/domain/common'
export class Profile extends BaseDomain {
/**
* User avatar address
*
* @type {string}
* @memberof Profile
*/
public avatar: string
/**
* User email
*
* @type {string}
* @memberof Profile
*/
public email?: string | null
/**
* User full name
*
* @type {string}
* @memberof Profile
*/
public fullName: string
/**
* The banner address of user profile
*
* @type {string}
* @memberof Profile
*/
public banner: string
/**
* User tag line
*
* @type {string}
* @memberof Profile
*/
public tagLine: string
}

View File

@@ -0,0 +1,53 @@
import { BaseDomain } from 'core/domain/common'
export class User extends BaseDomain {
/**
* Full name of user
*
* @type {string}
* @memberof User
*/
public fullName: string
/**
* User avatar address
*
* @type {string}
* @memberof User
*/
public avatar: string
/**
* Email of the user
*
* @type {string}
* @memberof User
*/
public email?: string | null
/**
* Password of the user
*
* @type {string}
* @memberof User
*/
public password?: string | null
/**
* User identifier
*
* @type {string}
* @memberof User
*/
public userId?: string | null
/**
* User creation date
*
* @type {number}
* @memberof User
*/
public creationDate: number
}

View File

@@ -0,0 +1,5 @@
import {Vote} from './vote'
export {
Vote
}

View File

@@ -0,0 +1,53 @@
import { BaseDomain } from 'core/domain/common'
export class Vote extends BaseDomain {
/**
* Vote identifier
*
* @type {string}
* @memberof Vote
*/
public id?: string | null
/**
* Post identifire which vote on
*
* @type {string}
* @memberof Vote
*/
public postId: string
/**
* Vote date
*
* @type {number}
* @memberof Vote
*/
public creationDate: number
/**
* Voter full name
*
* @type {string}
* @memberof Vote
*/
public userDisplayName: string
/**
* Avatar of voter
*
* @type {string}
* @memberof Vote
*/
public userAvatar: string
/**
* Voter identifier
*
* @type {string}
* @memberof Vote
*/
public userId: string
}

3
src/core/environment.ts Normal file
View File

@@ -0,0 +1,3 @@
export const environment = {
appName : 'Green Social'
}

View File

@@ -0,0 +1,76 @@
import { IAuthorizeService } from 'services/authorize/IAuthorizeService'
import { ICircleService } from 'services/circles'
import { ICommentService } from 'core/services/comments'
import { ICommonService } from 'services/common'
import { IImageGalleryService } from 'services/imageGallery'
import { INotificationService } from 'services/notifications'
import { IPostService } from 'services/posts'
import { IUserService } from 'services/users'
import { IVoteService } from 'services/votes'
export interface IServiceProvider {
/**
* Create authorize service
*
* @memberof IServiceProvider
*/
createAuthorizeService: () => IAuthorizeService
/**
* Create instant for Circle Service
*
* @memberof ServiceProvide
*/
createCircleService: () => ICircleService
/**
* Create instant for Comment Service
*
* @memberof ServiceProvide
*/
createCommentService: () => ICommentService
/**
* Create instant for Common Service
*
* @memberof ServiceProvide
*/
createCommonService: () => ICommonService
/**
* Create instant for ImageGallery Service
*
* @memberof ServiceProvide
*/
createImageGalleryService: () => IImageGalleryService
/**
* Create instant for Notification Service
*
* @memberof ServiceProvide
*/
createNotificationService: () => INotificationService
/**
* Create instant for Post Service
*
* @memberof ServiceProvide
*/
createPostService: () => IPostService
/**
* Create instant for User Service
*
* @memberof ServiceProvide
*/
createUserService: () => IUserService
/**
* Create instant for Vote Service
*
* @memberof ServiceProvide
*/
createVoteService: () => IVoteService
}

View File

@@ -0,0 +1,7 @@
import { IServiceProvider } from './IServiceProvider'
import { ServiceProvide } from './serviceProvide'
export {
IServiceProvider,
ServiceProvide
}

View File

@@ -0,0 +1,118 @@
//#region Interfaces
import { IServiceProvider } from 'core/factories'
import {
IAuthorizeService,
ICircleService,
ICommentService,
ICommonService,
IImageGalleryService,
INotificationService,
IPostService,
IUserService,
IVoteService
} from 'core/services'
//#endregion
//#region Service implemented classes
// - Firebase services
import {
AuthorizeService,
CircleService,
CommentService,
CommonService,
ImageGalleryService,
NotificationService,
PostService,
UserService,
VoteService
} from 'data/firebaseClient/services'
//#endregion
export class ServiceProvide implements IServiceProvider {
/**
* Create instant for Authorize Service
*
* @memberof ServiceProvide
*/
createAuthorizeService: () => IAuthorizeService = () => {
return new AuthorizeService()
}
/**
* Create instant for Circle Service
*
* @memberof ServiceProvide
*/
createCircleService: () => ICircleService = () => {
return new CircleService()
}
/**
* Create instant for Comment Service
*
* @memberof ServiceProvide
*/
createCommentService: () => ICommentService = () => {
return new CommentService()
}
/**
* Create instant for Common Service
*
* @memberof ServiceProvide
*/
createCommonService: () => ICommonService = () => {
return new CommonService()
}
/**
* Create instant for ImageGallery Service
*
* @memberof ServiceProvide
*/
createImageGalleryService: () => IImageGalleryService = () => {
return new ImageGalleryService()
}
/**
* Create instant for Notification Service
*
* @memberof ServiceProvide
*/
createNotificationService: () => INotificationService = () => {
return new NotificationService()
}
/**
* Create instant for Post Service
*
* @memberof ServiceProvide
*/
createPostService: () => IPostService = () => {
return new PostService()
}
/**
* Create instant for User Service
*
* @memberof ServiceProvide
*/
createUserService: () => IUserService = () => {
return new UserService()
}
/**
* Create instant for Vote Service
*
* @memberof ServiceProvide
*/
createVoteService: () => IVoteService = () => {
return new VoteService()
}
}

View File

@@ -0,0 +1,38 @@
import { User } from 'core/domain/users'
import { LoginUser, RegisterUserResult } from 'core/domain/authorize'
/**
* Authentication service interface
*
* @export
* @interface IAuthorizeService
*/
export interface IAuthorizeService {
/**
* Login the user
*
* @returns {Promise<void>}
* @memberof IAuthorizeService
*/
login: (email: string, password: string) => Promise<LoginUser>
/**
* Logs out the user
*
* @returns {Promise<void>}
* @memberof IAuthorizeService
*/
logout: () => Promise<void>
/**
* @returns {Promise<void>}
*/
updatePassword: (newPassword: string) => Promise<void>
/**
* @returns {Promise<void>}
*/
registerUser: (user: User) => Promise<RegisterUserResult>
}

View File

@@ -0,0 +1,5 @@
import { IAuthorizeService } from './IAuthorizeService'
export {
IAuthorizeService
}

View File

@@ -0,0 +1,18 @@
import { User } from 'core/domain/users'
import { Circle, UserFollower } from 'core/domain/circles'
/**
* Circle service interface
*
* @export
* @interface ICircleService
*/
export interface ICircleService {
addCircle: (userId: string, circle: Circle) => Promise<string>
addFollowingUser: (userId: string, circleId: string, userCircle: User, userFollower: UserFollower, userFollowingId: string) => Promise<void>
deleteFollowingUser: (userId: string, circleId: string,userFollowingId: string) => Promise<void>
updateCircle: (userId: string, circleId: string, circle: Circle) => Promise<void>
deleteCircle: (userId: string, circleId: string) => Promise<void>
getCircles: (userId: string) => Promise<{ [circleId: string]: Circle }>
}

View File

@@ -0,0 +1,5 @@
import { ICircleService } from './ICircleService'
export {
ICircleService
}

View File

@@ -0,0 +1,18 @@
import { User } from 'core/domain/users'
import { Comment } from 'core/domain/comments'
/**
* Comment service interface
*
* @export
* @interface ICommentService
*/
export interface ICommentService {
addComment: (postId: string, comment: Comment) => Promise<string>
getComments: (callback: (resultComments: { [postId: string]: { [commentId: string]: Comment } }) => void) => void
updateComment: (userId: string, postId: string, comment: Comment) => Promise<void>
deleteComment: (commentId: string, postId: string) => Promise<void>
}

View File

@@ -0,0 +1,5 @@
import { ICommentService } from './ICommentService'
export {
ICommentService
}

View File

@@ -0,0 +1,11 @@
import { User } from 'core/domain/users'
/**
* Common service interface
*
* @export
* @interface ICommonService
*/
export interface ICommonService {
}

View File

@@ -0,0 +1,5 @@
import { ICommonService } from './ICommonService'
export {
ICommonService
}

View File

@@ -0,0 +1,16 @@
import { User } from 'core/domain/users'
import { Image } from 'core/domain/imageGallery'
/**
* Image gallery service interface
*
* @export
* @interface IImageGalleryService
*/
export interface IImageGalleryService {
getImageGallery: (userId: string) => Promise<Image[]>
saveImage: (userId: string, image: Image) => Promise<string>
deleteImage: (userId: string, imageId: string) => Promise<void>
uploadImage: (file: any, fileName: string, progressCallback: Function) => Promise<void>
downloadImage: (fileName: string) => Promise<string>
}

View File

@@ -0,0 +1,5 @@
import { IImageGalleryService } from './IImageGalleryService'
export {
IImageGalleryService
}

View File

@@ -0,0 +1,21 @@
import { IAuthorizeService } from './authorize'
import { ICircleService } from './circles'
import { ICommentService } from './comments'
import { ICommonService } from './common'
import { IImageGalleryService } from './imageGallery'
import { INotificationService } from './notifications'
import { IPostService } from './posts'
import { IUserService } from './users'
import { IVoteService } from './votes'
export {
IAuthorizeService,
ICircleService,
ICommentService,
ICommonService,
IImageGalleryService,
INotificationService,
IPostService,
IUserService,
IVoteService
}

View File

@@ -0,0 +1,16 @@
import { User } from 'core/domain/users'
import { Notification } from 'core/domain/notifications'
/**
* Notification service interface
*
* @export
* @interface INotificationService
*/
export interface INotificationService {
addNotification: (notification: Notification) => Promise<void>
getNotifications: (userId: string, callback: (resultNotifications: {[notifyId: string]: Notification}) => void) => void
deleteNotification: (notificationId: string, userId: string) => Promise<void>
setSeenNotification: (notificationId: string, userId: string, notification: Notification) => Promise<void>
}

View File

@@ -0,0 +1,5 @@
import { INotificationService } from './INotificationService'
export {
INotificationService
}

View File

@@ -0,0 +1,16 @@
import { User } from 'core/domain/users'
import { Post } from 'core/domain/posts'
/**
* Post service interface
*
* @export
* @interface IPostService
*/
export interface IPostService {
addPost: (userId: string, post: Post) => Promise<string>
updatePost: (userId: string, postId: string, post: Post) => Promise<void>
deletePost: (userId: string,postId: string) => Promise<void>
getPosts: (userId: string) => Promise<{ [postId: string]: Post }>
getPostById: (userId: string, postId: string) => Promise<Post>
}

View File

@@ -0,0 +1,5 @@
import { IPostService } from './IPostService'
export {
IPostService
}

View File

@@ -0,0 +1,13 @@
import { User, Profile } from 'core/domain/users'
/**
* User service interface
*
* @export
* @interface IUserService
*/
export interface IUserService {
getUserProfile: (userId: string) => Promise<Profile>
updateUserProfile: (userId: string, profile: Profile) => Promise<void>
getUsersProfile: (userId: string) => Promise<{[userId: string]: Profile}>
}

View File

@@ -0,0 +1,5 @@
import { IUserService } from './IUserService'
export {
IUserService
}

View File

@@ -0,0 +1,14 @@
import { User } from 'core/domain/users'
import { Vote } from 'core/domain/votes'
/**
* Vote service interface
*
* @export
* @interface IVoteService
*/
export interface IVoteService {
addVote: (vote: Vote) => Promise<string>
getVotes: () => Promise<{[postId: string]: {[voteId: string]: Vote}}>
deleteVote: (voteId: string, postId: string) => Promise<void>
}

View File

@@ -0,0 +1,5 @@
import { IVoteService } from './IVoteService'
export {
IVoteService
}