From 914e30aa804cfee15e3639c2274824541148f6a4 Mon Sep 17 00:00:00 2001 From: windmemory Date: Sun, 16 Aug 2020 15:39:25 +0800 Subject: [PATCH 01/11] add corp base info to contact --- src/schemas/contact.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/schemas/contact.ts b/src/schemas/contact.ts index 02b71551..bc534ba1 100644 --- a/src/schemas/contact.ts +++ b/src/schemas/contact.ts @@ -41,6 +41,12 @@ export interface ContactPayload { signature? : string, star? : boolean, weixin? : string, + + corp? : string, + title? : string, + description? : string, + isWeixin? : boolean, + isExternal? : boolean, } /** @hidden */ From f9fc8967aee11e04df7b8a3cf641a8e4d3afbad9 Mon Sep 17 00:00:00 2001 From: windmemory Date: Wed, 19 Aug 2020 14:01:26 +0800 Subject: [PATCH 02/11] new design with complex contactType --- src/schemas/contact.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/schemas/contact.ts b/src/schemas/contact.ts index bc534ba1..c34b9c9f 100644 --- a/src/schemas/contact.ts +++ b/src/schemas/contact.ts @@ -7,10 +7,11 @@ export enum ContactGender { /** * Huan(202004) TODO: Lock the ENUM number (like protobuf) ? */ -export enum ContactType { +export enum BaseType { Unknown = 0, Individual = 1, Official = 2, + Corp = 3, /** * Huan(202004): @@ -19,6 +20,11 @@ export enum ContactType { Personal = Individual, } +export interface ContactType { + baseType: BaseType, + corpInternal?: boolean, +} + export interface ContactQueryFilter { alias?: string | RegExp, id?: string, @@ -45,8 +51,6 @@ export interface ContactPayload { corp? : string, title? : string, description? : string, - isWeixin? : boolean, - isExternal? : boolean, } /** @hidden */ From 55706604e71c459bef6b192f18ee35b8eafce14a Mon Sep 17 00:00:00 2001 From: windmemory Date: Wed, 19 Aug 2020 14:11:06 +0800 Subject: [PATCH 03/11] fix test --- src/puppet.spec.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/puppet.spec.ts b/src/puppet.spec.ts index f2b506cf..6654b2ba 100755 --- a/src/puppet.spec.ts +++ b/src/puppet.spec.ts @@ -12,7 +12,7 @@ import { import { ContactGender, ContactPayload, - ContactType, + BaseType, } from './schemas/contact' import { MessagePayload, @@ -42,7 +42,9 @@ test('contactQueryFilterFunction()', async t => { gender : ContactGender.Unknown, id : 'id1', name : TEXT_REGEX, - type : ContactType.Personal, + type : { + baseType: BaseType.Personal, + }, }, { alias : TEXT_REGEX, @@ -50,7 +52,9 @@ test('contactQueryFilterFunction()', async t => { gender : ContactGender.Unknown, id : 'id2', name : TEXT_TEXT, - type : ContactType.Personal, + type : { + baseType: BaseType.Personal, + }, }, { alias : TEXT_TEXT, @@ -58,7 +62,9 @@ test('contactQueryFilterFunction()', async t => { gender : ContactGender.Unknown, id : 'id3', name : TEXT_REGEX, - type : ContactType.Personal, + type : { + baseType: BaseType.Personal, + }, }, { alias : TEXT_REGEX, @@ -66,7 +72,9 @@ test('contactQueryFilterFunction()', async t => { gender : ContactGender.Unknown, id : 'id4', name : TEXT_TEXT, - type : ContactType.Personal, + type : { + baseType: BaseType.Personal, + }, }, ] From 88527f5f554839a7b43a9861acc5ee7fa48314d8 Mon Sep 17 00:00:00 2001 From: windmemory Date: Wed, 19 Aug 2020 14:11:16 +0800 Subject: [PATCH 04/11] 0.31.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 36432ce7..8c4189fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-puppet", - "version": "0.31.3", + "version": "0.31.4", "description": "Abstract Puppet for Wechaty", "main": "dist/src/index.js", "typings": "dist/src/index.d.ts", From d47f23af92f7ca1aa9c8eb17bd4f011e13588aa2 Mon Sep 17 00:00:00 2001 From: windmemory Date: Thu, 20 Aug 2020 10:49:07 +0800 Subject: [PATCH 05/11] flat the type and move internal property into root object --- src/schemas/contact.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/schemas/contact.ts b/src/schemas/contact.ts index c34b9c9f..76de2a7a 100644 --- a/src/schemas/contact.ts +++ b/src/schemas/contact.ts @@ -7,7 +7,7 @@ export enum ContactGender { /** * Huan(202004) TODO: Lock the ENUM number (like protobuf) ? */ -export enum BaseType { +export enum ContactType { Unknown = 0, Individual = 1, Official = 2, @@ -20,11 +20,6 @@ export enum BaseType { Personal = Individual, } -export interface ContactType { - baseType: BaseType, - corpInternal?: boolean, -} - export interface ContactQueryFilter { alias?: string | RegExp, id?: string, @@ -51,6 +46,7 @@ export interface ContactPayload { corp? : string, title? : string, description? : string, + internal? : boolean, } /** @hidden */ From 01fabb50f3045f95499b2d35fe9f7d661dbe1790 Mon Sep 17 00:00:00 2001 From: windmemory Date: Fri, 21 Aug 2020 16:05:44 +0800 Subject: [PATCH 06/11] update design --- src/puppet.spec.ts | 18 +++++------------- src/puppet.ts | 4 ++++ src/schemas/contact.ts | 4 ++-- tests/fixtures/puppet-test/puppet-test.ts | 4 ++++ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/puppet.spec.ts b/src/puppet.spec.ts index 6654b2ba..f2b506cf 100755 --- a/src/puppet.spec.ts +++ b/src/puppet.spec.ts @@ -12,7 +12,7 @@ import { import { ContactGender, ContactPayload, - BaseType, + ContactType, } from './schemas/contact' import { MessagePayload, @@ -42,9 +42,7 @@ test('contactQueryFilterFunction()', async t => { gender : ContactGender.Unknown, id : 'id1', name : TEXT_REGEX, - type : { - baseType: BaseType.Personal, - }, + type : ContactType.Personal, }, { alias : TEXT_REGEX, @@ -52,9 +50,7 @@ test('contactQueryFilterFunction()', async t => { gender : ContactGender.Unknown, id : 'id2', name : TEXT_TEXT, - type : { - baseType: BaseType.Personal, - }, + type : ContactType.Personal, }, { alias : TEXT_TEXT, @@ -62,9 +58,7 @@ test('contactQueryFilterFunction()', async t => { gender : ContactGender.Unknown, id : 'id3', name : TEXT_REGEX, - type : { - baseType: BaseType.Personal, - }, + type : ContactType.Personal, }, { alias : TEXT_REGEX, @@ -72,9 +66,7 @@ test('contactQueryFilterFunction()', async t => { gender : ContactGender.Unknown, id : 'id4', name : TEXT_TEXT, - type : { - baseType: BaseType.Personal, - }, + type : ContactType.Personal, }, ] diff --git a/src/puppet.ts b/src/puppet.ts index e5d5b577..af2ba32a 100644 --- a/src/puppet.ts +++ b/src/puppet.ts @@ -475,6 +475,10 @@ export abstract class Puppet extends PuppetEventEmitter { public abstract async contactPhone (contactId: string) : Promise public abstract async contactPhone (contactId: string, phoneList: string[]) : Promise + public abstract async contactCorpRemark (contactId: string, corpRemark: string): Promise + + public abstract async contactDesc (contactId: string, desc: string): Promise + public abstract async contactList () : Promise protected abstract async contactRawPayload (contactId: string) : Promise diff --git a/src/schemas/contact.ts b/src/schemas/contact.ts index 76de2a7a..781d96f7 100644 --- a/src/schemas/contact.ts +++ b/src/schemas/contact.ts @@ -45,8 +45,8 @@ export interface ContactPayload { corp? : string, title? : string, - description? : string, - internal? : boolean, + desc? : string, + coworker? : boolean, } /** @hidden */ diff --git a/tests/fixtures/puppet-test/puppet-test.ts b/tests/fixtures/puppet-test/puppet-test.ts index 0043bba8..44641bdb 100644 --- a/tests/fixtures/puppet-test/puppet-test.ts +++ b/tests/fixtures/puppet-test/puppet-test.ts @@ -69,6 +69,10 @@ export class PuppetTest extends Puppet { public async contactList () : Promise { return {} as any } + public async contactCorpRemark () : Promise { return {} as any } + + public async contactDesc (): Promise { return {} as any } + public async contactRawPayload (id: string) : Promise { return { id } as any } public async contactRawPayloadParser (rawPayload: any) : Promise { return { rawPayload } as any } From 70cbf795d2503f5374bdede57dfc942d36fcef7a Mon Sep 17 00:00:00 2001 From: windmemory Date: Fri, 21 Aug 2020 16:18:53 +0800 Subject: [PATCH 07/11] fix pack test --- tests/fixtures/smoke-testing.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/fixtures/smoke-testing.ts b/tests/fixtures/smoke-testing.ts index 0071d904..dd04a322 100644 --- a/tests/fixtures/smoke-testing.ts +++ b/tests/fixtures/smoke-testing.ts @@ -79,6 +79,10 @@ class PuppetTest extends Puppet { public async contactList () : Promise { return {} as any } + public async contactCorpRemark () : Promise { return {} as any } + + public async contactDesc (): Promise { return {} as any } + public async contactRawPayload (id: string) : Promise { return { id } as any } public async contactRawPayloadParser (rawPayload: any) : Promise { return { rawPayload } as any } From 1d8dce6efae80853822e0cdbaa036ca02dbcb2f7 Mon Sep 17 00:00:00 2001 From: windmemory Date: Fri, 21 Aug 2020 19:06:23 +0800 Subject: [PATCH 08/11] use full name for properties in contact --- src/schemas/contact.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/schemas/contact.ts b/src/schemas/contact.ts index 781d96f7..c84376ef 100644 --- a/src/schemas/contact.ts +++ b/src/schemas/contact.ts @@ -43,9 +43,9 @@ export interface ContactPayload { star? : boolean, weixin? : string, - corp? : string, + corporation? : string, title? : string, - desc? : string, + description? : string, coworker? : boolean, } From 8203c7eea556e881520dc4ce6ace71fd7400ad9b Mon Sep 17 00:00:00 2001 From: windmemory Date: Fri, 21 Aug 2020 19:06:41 +0800 Subject: [PATCH 09/11] 0.31.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8653d453..d2eaf4c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-puppet", - "version": "0.31.5", + "version": "0.31.6", "description": "Abstract Puppet for Wechaty", "main": "dist/src/index.js", "typings": "dist/src/index.d.ts", From dc821af1be8694df0f96e74ec2471a87c01163a3 Mon Sep 17 00:00:00 2001 From: windmemory Date: Fri, 21 Aug 2020 19:13:32 +0800 Subject: [PATCH 10/11] use full name for all methods --- src/puppet.ts | 4 ++-- tests/fixtures/puppet-test/puppet-test.ts | 4 ++-- tests/fixtures/smoke-testing.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/puppet.ts b/src/puppet.ts index af2ba32a..a69a5ff2 100644 --- a/src/puppet.ts +++ b/src/puppet.ts @@ -475,9 +475,9 @@ export abstract class Puppet extends PuppetEventEmitter { public abstract async contactPhone (contactId: string) : Promise public abstract async contactPhone (contactId: string, phoneList: string[]) : Promise - public abstract async contactCorpRemark (contactId: string, corpRemark: string): Promise + public abstract async contactCorporationRemark (contactId: string, corpRemark: string): Promise - public abstract async contactDesc (contactId: string, desc: string): Promise + public abstract async contactDescription (contactId: string, desc: string): Promise public abstract async contactList () : Promise diff --git a/tests/fixtures/puppet-test/puppet-test.ts b/tests/fixtures/puppet-test/puppet-test.ts index 44641bdb..5d913b13 100644 --- a/tests/fixtures/puppet-test/puppet-test.ts +++ b/tests/fixtures/puppet-test/puppet-test.ts @@ -69,9 +69,9 @@ export class PuppetTest extends Puppet { public async contactList () : Promise { return {} as any } - public async contactCorpRemark () : Promise { return {} as any } + public async contactCorporationRemark () : Promise { return {} as any } - public async contactDesc (): Promise { return {} as any } + public async contactDescription (): Promise { return {} as any } public async contactRawPayload (id: string) : Promise { return { id } as any } public async contactRawPayloadParser (rawPayload: any) : Promise { return { rawPayload } as any } diff --git a/tests/fixtures/smoke-testing.ts b/tests/fixtures/smoke-testing.ts index dd04a322..a3a43c82 100644 --- a/tests/fixtures/smoke-testing.ts +++ b/tests/fixtures/smoke-testing.ts @@ -79,9 +79,9 @@ class PuppetTest extends Puppet { public async contactList () : Promise { return {} as any } - public async contactCorpRemark () : Promise { return {} as any } + public async contactCorporationRemark () : Promise { return {} as any } - public async contactDesc (): Promise { return {} as any } + public async contactDescription (): Promise { return {} as any } public async contactRawPayload (id: string) : Promise { return { id } as any } public async contactRawPayloadParser (rawPayload: any) : Promise { return { rawPayload } as any } From 5b7110ae71fcb14d3722983b0c9e693760e0c5d7 Mon Sep 17 00:00:00 2001 From: windmemory Date: Fri, 21 Aug 2020 19:16:31 +0800 Subject: [PATCH 11/11] change contactType to full name --- src/schemas/contact.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/schemas/contact.ts b/src/schemas/contact.ts index c84376ef..e792ee02 100644 --- a/src/schemas/contact.ts +++ b/src/schemas/contact.ts @@ -8,10 +8,10 @@ export enum ContactGender { * Huan(202004) TODO: Lock the ENUM number (like protobuf) ? */ export enum ContactType { - Unknown = 0, - Individual = 1, - Official = 2, - Corp = 3, + Unknown = 0, + Individual = 1, + Official = 2, + Corporation = 3, /** * Huan(202004):