提交 384317b2 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

Moving all basic types to Abstract Puppet

上级 ddd6b9c7
......@@ -31,46 +31,12 @@ import {
// import Message from './message'
/**
* Enum for Gender values.
*
* @enum {number}
* @property {number} Unknown - 0 for Unknown
* @property {number} Male - 1 for Male
* @property {number} Female - 2 for Female
*/
export enum Gender {
Unknown = 0,
Male = 1,
Female = 2,
}
export enum ContactType {
Unknown = 0,
Personal,
Official,
}
export interface ContactQueryFilter {
name?: string | RegExp,
alias?: string | RegExp,
}
export interface ContactPayload {
gender: Gender,
type: ContactType,
address?: string,
alias?: string | null,
avatar?: string,
city?: string,
friend?: boolean,
name?: string,
province?: string,
signature?: string,
star?: boolean,
weixin?: string,
}
import {
ContantGender,
ContactPayload,
ContactQueryFilter,
ContactType,
} from './puppet/'
export const POOL = Symbol('pool')
......@@ -84,7 +50,8 @@ export class Contact extends Accessory implements Sayable {
// tslint:disable-next-line:variable-name
public static Type = ContactType
public static Gender = Gender
// tslint:disable-next-line:variable-name
public static Gender = ContantGender
protected static [POOL]: Map<string, Contact>
protected static get pool() {
......@@ -483,14 +450,14 @@ export class Contact extends Accessory implements Sayable {
/**
* Contact gender
*
* @returns {Gender.Male(2)|Gender.Female(1)|Gender.Unknown(0)}
* @returns {ContantGender.Male(2)|Gender.Female(1)|Gender.Unknown(0)}
* @example
* const gender = contact.gender()
*/
public gender(): Gender {
public gender(): ContantGender {
return this.payload
? this.payload.gender
: Gender.Unknown
: ContantGender.Unknown
}
/**
......
......@@ -37,27 +37,10 @@ import {
Misc,
} from './misc'
export enum FriendRequestType {
Unknown = 0,
Receive,
Confirm,
}
export interface FriendRequestPayloadConfirm {
contactId : string,
hello? : string,
type : FriendRequestType.Confirm,
}
export interface FriendRequestPayloadReceive {
contactId : string,
hello? : string,
ticket : string
type : FriendRequestType.Receive,
}
export type FriendRequestPayload = FriendRequestPayloadReceive
| FriendRequestPayloadConfirm
import {
FriendRequestPayload,
FriendRequestType,
} from './puppet/'
/**
* Send, receive friend request, and friend confirmation events.
......
......@@ -41,31 +41,10 @@ import {
Room,
} from './room'
export enum MessageType {
Unknown = 0,
Attachment,
Audio,
Emoticon,
Image,
Text,
Video,
}
/**
*
* MessagePayload
*
*/
export interface MessagePayload {
type : MessageType,
text? : string,
fromId? : string,
filename? : string,
timestamp : number, // milliseconds
toId? : null | string, // if to is not set, then room must be set
roomId? : null | string,
}
import {
MessagePayload,
MessageType,
} from './puppet/'
/**
* All wechat messages will be encapsulated as a Message.
*
......
export * from './schemas/contact'
export * from './schemas/friend-request'
export * from './schemas/message'
export * from './schemas/room'
export * from './schemas/puppet'
export {
Puppet,
PuppetEventName,
PuppetOptions,
Receiver,
ScanPayload,
} from './puppet'
Puppet,
} from './puppet'
export enum ContantGender {
Unknown = 0,
Male = 1,
Female = 2,
}
export enum ContactType {
Unknown = 0,
Personal,
Official,
}
export interface ContactQueryFilter {
name?: string | RegExp,
alias?: string | RegExp,
}
export interface ContactPayload {
id: string,
gender: ContantGender,
type: ContactType,
address?: string,
alias?: string | null,
avatar?: string,
city?: string,
friend?: boolean,
name?: string,
province?: string,
signature?: string,
star?: boolean,
weixin?: string,
}
export type ContactPayloadFilterFunction = (payload: ContactPayload) => boolean
export type ContactPayloadFilterFactory = (query: ContactQueryFilter) => ContactPayloadFilterFunction
export enum FriendRequestType {
Unknown = 0,
Receive,
Confirm,
}
export interface FriendRequestPayloadBase {
id : string,
contactId : string,
hello? : string,
}
export type FriendRequestPayloadConfirm = FriendRequestPayloadBase & {
type : FriendRequestType.Confirm,
}
export type FriendRequestPayloadReceive = FriendRequestPayloadBase & {
ticket : string
type : FriendRequestType.Receive,
}
export type FriendRequestPayload = FriendRequestPayloadReceive
| FriendRequestPayloadConfirm
export enum MessageType {
Unknown = 0,
Attachment,
Audio,
Emoticon,
Image,
Text,
Video,
}
export interface MessagePayload {
id : string,
type : MessageType,
filename? : string,
fromId? : string,
roomId? : null | string,
text? : string,
timestamp : number, // milliseconds
toId? : null | string, // if to is not set, then room must be set
}
import {
MemoryCard,
} from 'memory-card'
// export interface ScanPayload {
// code : number, // Code
// data? : string, // Image Data URL
// url : string, // QR Code URL
// }
export const CHAT_EVENT_DICT = {
friend : 'document can be writen at here',
login : 'document can be writen at here',
logout : 'document can be writen at here',
message : 'document can be writen at here',
'room-join' : 'document can be writen at here',
'room-leave': 'document can be writen at here',
'room-topic': 'document can be writen at here',
scan : 'document can be writen at here',
}
export const PUPPET_EVENT_DICT = {
...CHAT_EVENT_DICT,
error : 'document can be writen at here',
heartbeat : 'document can be writen at here',
start : 'document can be writen at here',
stop : 'document can be writen at here',
watchdog : 'document can be writen at here',
}
export type PuppetEventName = keyof typeof PUPPET_EVENT_DICT
export interface PuppetOptions {
memory: MemoryCard,
}
export interface Receiver {
contactId? : string,
roomId? : string,
}
export interface RoomMemberQueryFilter {
name? : string,
roomAlias? : string,
contactAlias? : string,
}
export interface RoomQueryFilter {
topic: string | RegExp,
}
export interface RoomPayload {
id : string,
topic : string,
memberIdList : string[],
ownerId? : string,
nameMap : Map<string, string>,
roomAliasMap : Map<string, string>,
contactAliasMap : Map<string, string>,
// [index: string]: Map<string, string> | string | number | PuppeteerContact[],
}
export type RoomPayloadFilterFunction = (payload: RoomPayload) => boolean
export type RoomPayloadFilterFactory = (query: RoomQueryFilter) => RoomPayloadFilterFunction
......@@ -48,26 +48,11 @@ export const ROOM_EVENT_DICT = {
}
export type RoomEventName = keyof typeof ROOM_EVENT_DICT
export interface RoomMemberQueryFilter {
name?: string,
roomAlias?: string,
contactAlias?: string,
}
export interface RoomQueryFilter {
topic: string | RegExp,
}
export interface RoomPayload {
topic : string,
memberIdList : string[],
ownerId? : string,
nameMap: Map<string, string>,
roomAliasMap: Map<string, string>,
contactAliasMap: Map<string, string>,
// [index: string]: Map<string, string> | string | number | PuppeteerContact[],
}
import {
RoomMemberQueryFilter,
RoomPayload,
RoomQueryFilter,
} from './puppet/'
/**
* All wechat rooms(groups) will be encapsulated as a Room.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册