@juzi/wechaty-puppet-service 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/client/grpc-manager.d.ts.map +1 -1
- package/dist/cjs/src/client/grpc-manager.js +1 -0
- package/dist/cjs/src/client/grpc-manager.js.map +1 -1
- package/dist/cjs/src/client/puppet-service.d.ts +6 -0
- package/dist/cjs/src/client/puppet-service.d.ts.map +1 -1
- package/dist/cjs/src/client/puppet-service.js +63 -0
- package/dist/cjs/src/client/puppet-service.js.map +1 -1
- package/dist/cjs/src/file-box-helper/normalize-filebox.js +2 -2
- package/dist/cjs/src/file-box-helper/normalize-filebox.js.map +1 -1
- package/dist/cjs/src/file-box-helper/normalize-filebox.spec.js +3 -3
- package/dist/cjs/src/file-box-helper/normalize-filebox.spec.js.map +1 -1
- package/dist/cjs/src/package-json.js +3 -3
- package/dist/cjs/src/server/puppet-implementation.d.ts.map +1 -1
- package/dist/cjs/src/server/puppet-implementation.js +60 -0
- package/dist/cjs/src/server/puppet-implementation.js.map +1 -1
- package/dist/cjs/tests/uuid-file-box.spec.js +39 -0
- package/dist/cjs/tests/uuid-file-box.spec.js.map +1 -1
- package/dist/esm/src/client/grpc-manager.d.ts.map +1 -1
- package/dist/esm/src/client/grpc-manager.js +1 -0
- package/dist/esm/src/client/grpc-manager.js.map +1 -1
- package/dist/esm/src/client/puppet-service.d.ts +6 -0
- package/dist/esm/src/client/puppet-service.d.ts.map +1 -1
- package/dist/esm/src/client/puppet-service.js +63 -0
- package/dist/esm/src/client/puppet-service.js.map +1 -1
- package/dist/esm/src/file-box-helper/normalize-filebox.js +2 -2
- package/dist/esm/src/file-box-helper/normalize-filebox.js.map +1 -1
- package/dist/esm/src/file-box-helper/normalize-filebox.spec.js +3 -3
- package/dist/esm/src/file-box-helper/normalize-filebox.spec.js.map +1 -1
- package/dist/esm/src/package-json.js +3 -3
- package/dist/esm/src/server/puppet-implementation.d.ts.map +1 -1
- package/dist/esm/src/server/puppet-implementation.js +60 -0
- package/dist/esm/src/server/puppet-implementation.js.map +1 -1
- package/dist/esm/tests/uuid-file-box.spec.js +40 -1
- package/dist/esm/tests/uuid-file-box.spec.js.map +1 -1
- package/package.json +3 -3
- package/src/client/grpc-manager.ts +1 -0
- package/src/client/puppet-service.ts +72 -1
- package/src/file-box-helper/normalize-filebox.spec.ts +4 -4
- package/src/file-box-helper/normalize-filebox.ts +3 -3
- package/src/package-json.ts +3 -3
- package/src/server/puppet-implementation.ts +57 -0
|
@@ -5,7 +5,7 @@ import * as fs from 'fs';
|
|
|
5
5
|
import PuppetMock from 'wechaty-puppet-mock';
|
|
6
6
|
import getPort from 'get-port';
|
|
7
7
|
import temp from 'temp';
|
|
8
|
-
import { FileBox } from 'file-box';
|
|
8
|
+
import { FileBox, FileBoxType } from 'file-box';
|
|
9
9
|
import PuppetService, { PuppetServer } from '../src/mod.js';
|
|
10
10
|
const NIL_UUID_V4 = '00000000-0000-0000-0000-000000000000';
|
|
11
11
|
const __dirname = path.resolve();
|
|
@@ -37,6 +37,7 @@ test('message file test', async (t) => {
|
|
|
37
37
|
const puppetService = new PuppetService(puppetOptions);
|
|
38
38
|
await puppetService.start();
|
|
39
39
|
const file = await puppetService.messageFile('sb');
|
|
40
|
+
t.not(file.type, FileBoxType.Stream, 'should not fallback to messageFileStream');
|
|
40
41
|
const tmpFolder = temp.mkdirSync('test');
|
|
41
42
|
const tmpFile = path.join(tmpFolder, 'uuid-file.dat');
|
|
42
43
|
await file.toFile(tmpFile);
|
|
@@ -46,4 +47,42 @@ test('message file test', async (t) => {
|
|
|
46
47
|
await puppetService.stop();
|
|
47
48
|
await puppetServer.stop();
|
|
48
49
|
});
|
|
50
|
+
test('buffer file test', async (t) => {
|
|
51
|
+
const PORT = await getPort();
|
|
52
|
+
const TOKEN = `insecure_${NIL_UUID_V4}`;
|
|
53
|
+
const ENDPOINT = `0.0.0.0:${PORT}`;
|
|
54
|
+
const FILE = path.join(__dirname, 'tests', 'fixtures', 'smoke-testing.ts');
|
|
55
|
+
const EXPECTED_SIZE = fs.statSync(FILE).size;
|
|
56
|
+
/**
|
|
57
|
+
* Puppet Server
|
|
58
|
+
*/
|
|
59
|
+
const puppet = new PuppetMock();
|
|
60
|
+
puppet.messageFile = async () => FileBox.fromBuffer(await FileBox.fromFile(FILE).toBuffer());
|
|
61
|
+
const serverOptions = {
|
|
62
|
+
endpoint: ENDPOINT,
|
|
63
|
+
puppet: puppet,
|
|
64
|
+
token: TOKEN,
|
|
65
|
+
};
|
|
66
|
+
const puppetServer = new PuppetServer(serverOptions);
|
|
67
|
+
await puppetServer.start();
|
|
68
|
+
/**
|
|
69
|
+
* Puppet Service Client
|
|
70
|
+
*/
|
|
71
|
+
const puppetOptions = {
|
|
72
|
+
endpoint: ENDPOINT,
|
|
73
|
+
token: TOKEN,
|
|
74
|
+
};
|
|
75
|
+
const puppetService = new PuppetService(puppetOptions);
|
|
76
|
+
await puppetService.start();
|
|
77
|
+
const file = await puppetService.messageFile('sb');
|
|
78
|
+
t.not(file.type, FileBoxType.Stream, 'should not fallback to messageFileStream');
|
|
79
|
+
const tmpFolder = temp.mkdirSync('test');
|
|
80
|
+
const tmpFile = path.join(tmpFolder, 'buffer-file.dat');
|
|
81
|
+
await file.toFile(tmpFile);
|
|
82
|
+
const fileSize = fs.statSync(tmpFile).size;
|
|
83
|
+
t.equal(fileSize, EXPECTED_SIZE, 'should save file with the correct size');
|
|
84
|
+
fs.rmSync(tmpFile);
|
|
85
|
+
await puppetService.stop();
|
|
86
|
+
await puppetServer.stop();
|
|
87
|
+
});
|
|
49
88
|
//# sourceMappingURL=uuid-file-box.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid-file-box.spec.js","sourceRoot":"","sources":["../../../tests/uuid-file-box.spec.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"uuid-file-box.spec.js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,EAAE,aAAa,EAAE,wCAAwC,CAAC,CAAA;IAE1E,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAClB,MAAM,aAAa,CAAC,IAAI,EAAE,CAAA;IAC1B,MAAM,YAAY,CAAC,IAAI,EAAE,CAAA;AAC3B,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juzi/wechaty-puppet-service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Puppet Service for Wechaty",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"why-is-node-running": "^2.2.1"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@juzi/wechaty-puppet": "1.0.
|
|
68
|
+
"@juzi/wechaty-puppet": "1.0.1"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"clone-class": "^1.1.1",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"semver": "^7.3.5",
|
|
79
79
|
"stronger-typed-streams": "^0.2.0",
|
|
80
80
|
"uuid": "^8.3.2",
|
|
81
|
-
"@juzi/wechaty-grpc": "1.0.
|
|
81
|
+
"@juzi/wechaty-grpc": "1.0.1",
|
|
82
82
|
"wechaty-redux": "^1.20.2",
|
|
83
83
|
"wechaty-token": "^1.0.6"
|
|
84
84
|
},
|
|
@@ -97,6 +97,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
97
97
|
protected _grpcManager?: GrpcManager
|
|
98
98
|
get grpcManager (): GrpcManager {
|
|
99
99
|
if (!this._grpcManager) {
|
|
100
|
+
this.emit('error', 'no grpc manager')
|
|
100
101
|
throw new Error('no grpc manager')
|
|
101
102
|
}
|
|
102
103
|
return this._grpcManager
|
|
@@ -173,10 +174,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
173
174
|
await grpcManager.start()
|
|
174
175
|
log.verbose('PuppetService', 'start() starting grpc manager... done')
|
|
175
176
|
|
|
177
|
+
log.verbose('PuppetService', 'start healthCheck')
|
|
178
|
+
this.startHealthCheck()
|
|
179
|
+
|
|
176
180
|
/**
|
|
177
181
|
* Ducks management
|
|
178
182
|
*/
|
|
179
|
-
const subscription = puppet$(this)
|
|
183
|
+
const subscription = puppet$(this as any)
|
|
180
184
|
.subscribe(this._store.dispatch)
|
|
181
185
|
|
|
182
186
|
this._cleanupCallbackList.push(
|
|
@@ -201,6 +205,8 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
log.verbose('PuppetService', 'onStop() ... done')
|
|
208
|
+
log.verbose('PuppetService', 'stop healthCheck')
|
|
209
|
+
this.stopHealthCheck()
|
|
204
210
|
}
|
|
205
211
|
|
|
206
212
|
protected hookPayloadStore (): void {
|
|
@@ -868,6 +874,28 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
868
874
|
return contactId
|
|
869
875
|
}
|
|
870
876
|
|
|
877
|
+
override async messageChannel (
|
|
878
|
+
messageId: string,
|
|
879
|
+
): Promise<PUPPET.payloads.Channel> {
|
|
880
|
+
log.verbose('PuppetService', 'messageChannel(%s)', messageId)
|
|
881
|
+
|
|
882
|
+
const request = new grpcPuppet.MessageChannelRequest()
|
|
883
|
+
request.setId(messageId)
|
|
884
|
+
|
|
885
|
+
const response = await util.promisify(
|
|
886
|
+
this.grpcManager.client.messageChannel
|
|
887
|
+
.bind(this.grpcManager.client),
|
|
888
|
+
)(request)
|
|
889
|
+
|
|
890
|
+
const channelPayload = response.getChannel()!.toObject()
|
|
891
|
+
|
|
892
|
+
const payload: PUPPET.payloads.Channel = {
|
|
893
|
+
...channelPayload,
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
return payload
|
|
897
|
+
}
|
|
898
|
+
|
|
871
899
|
override async messageSendMiniProgram (
|
|
872
900
|
conversationId : string,
|
|
873
901
|
miniProgramPayload : PUPPET.payloads.MiniProgram,
|
|
@@ -946,6 +974,38 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
946
974
|
}
|
|
947
975
|
}
|
|
948
976
|
|
|
977
|
+
override async messageSendChannel (
|
|
978
|
+
conversationId: string,
|
|
979
|
+
channelPayload: PUPPET.payloads.Channel,
|
|
980
|
+
): Promise<void | string> {
|
|
981
|
+
log.verbose('PuppetService', 'messageSendChannel(%s, "%s")', conversationId, JSON.stringify(channelPayload))
|
|
982
|
+
|
|
983
|
+
const request = new grpcPuppet.MessageSendChannelRequest()
|
|
984
|
+
request.setConversationId(conversationId)
|
|
985
|
+
|
|
986
|
+
const pbChannelPayload = new grpcPuppet.ChannelPayload()
|
|
987
|
+
if (channelPayload.avatar) { pbChannelPayload.setAvatar(channelPayload.avatar) }
|
|
988
|
+
if (channelPayload.coverUrl) { pbChannelPayload.setCoverUrl(channelPayload.coverUrl) }
|
|
989
|
+
if (channelPayload.desc) { pbChannelPayload.setDesc(channelPayload.desc) }
|
|
990
|
+
if (channelPayload.extras) { pbChannelPayload.setExtras(channelPayload.extras) }
|
|
991
|
+
if (channelPayload.feedType) { pbChannelPayload.setFeedType(channelPayload.feedType) }
|
|
992
|
+
if (channelPayload.nickname) { pbChannelPayload.setNickname(channelPayload.nickname) }
|
|
993
|
+
if (channelPayload.thumbUrl) { pbChannelPayload.setThumbUrl(channelPayload.thumbUrl) }
|
|
994
|
+
if (channelPayload.url) { pbChannelPayload.setUrl(channelPayload.url) }
|
|
995
|
+
request.setChannel(pbChannelPayload)
|
|
996
|
+
|
|
997
|
+
const response = await util.promisify(
|
|
998
|
+
this.grpcManager.client.messageSendChannel
|
|
999
|
+
.bind(this.grpcManager.client),
|
|
1000
|
+
)(request)
|
|
1001
|
+
|
|
1002
|
+
const messageId = response.getId()
|
|
1003
|
+
|
|
1004
|
+
if (messageId) {
|
|
1005
|
+
return messageId
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
949
1009
|
override async messageRecall (
|
|
950
1010
|
messageId: string,
|
|
951
1011
|
): Promise<boolean> {
|
|
@@ -1930,6 +1990,17 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1930
1990
|
}
|
|
1931
1991
|
}
|
|
1932
1992
|
|
|
1993
|
+
healthCheckInterval?: NodeJS.Timer
|
|
1994
|
+
startHealthCheck () {
|
|
1995
|
+
this.healthCheckInterval = setInterval(() => {
|
|
1996
|
+
this.ding('healthCheck')
|
|
1997
|
+
}, 60 * 1000)
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
stopHealthCheck () {
|
|
2001
|
+
clearInterval(this.healthCheckInterval!)
|
|
2002
|
+
}
|
|
2003
|
+
|
|
1933
2004
|
}
|
|
1934
2005
|
|
|
1935
2006
|
export {
|
|
@@ -10,8 +10,8 @@ const kbFileBox = (size: number) => FileBox.fromBuffer(Buffer.from(
|
|
|
10
10
|
), size + 'KB.txt')
|
|
11
11
|
|
|
12
12
|
test('canPassthrough() size threshold', async t => {
|
|
13
|
-
t.
|
|
14
|
-
t.notOk(canPassthrough(kbFileBox(32)),
|
|
13
|
+
t.notOk(canPassthrough(kbFileBox(16)), 'should not passthrough 16KB')
|
|
14
|
+
t.notOk(canPassthrough(kbFileBox(32)), 'should not passthrough 32KB')
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
test('canPassthrough(): always true for green types', async t => {
|
|
@@ -38,8 +38,8 @@ test('canPassthrough(): will depend on the size for yellow types', async t => {
|
|
|
38
38
|
const bufferFileBox = FileBox.fromBuffer(Buffer.from('buf'))
|
|
39
39
|
const base64FileBox = FileBox.fromBase64(Buffer.from('buf').toString('base64'))
|
|
40
40
|
|
|
41
|
-
t.
|
|
42
|
-
t.
|
|
41
|
+
t.notOk(canPassthrough(bufferFileBox), 'should not passthrough any Buffer')
|
|
42
|
+
t.notOk(canPassthrough(base64FileBox), 'should not passthrough any Base64')
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* TODO: add the large size test which will over the threshold
|
|
@@ -27,9 +27,9 @@ const greenFileBoxTypes = [
|
|
|
27
27
|
* if it's bigger than the threshold,
|
|
28
28
|
* then it should be convert to a UUID file box before send out
|
|
29
29
|
*/
|
|
30
|
-
const yellowFileBoxTypes = [
|
|
31
|
-
FileBoxType.Buffer,
|
|
32
|
-
FileBoxType.Base64,
|
|
30
|
+
const yellowFileBoxTypes: FileBoxType [] = [
|
|
31
|
+
// FileBoxType.Buffer,
|
|
32
|
+
// FileBoxType.Base64,
|
|
33
33
|
]
|
|
34
34
|
|
|
35
35
|
const canPassthrough = (fileBox: FileBoxInterface) => {
|
package/src/package-json.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { PackageJson } from 'type-fest'
|
|
5
5
|
export const packageJson: PackageJson = {
|
|
6
6
|
"name": "@juzi/wechaty-puppet-service",
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.1",
|
|
8
8
|
"description": "Puppet Service for Wechaty",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
@@ -69,7 +69,7 @@ export const packageJson: PackageJson = {
|
|
|
69
69
|
"why-is-node-running": "^2.2.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@juzi/wechaty-puppet": "1.0.
|
|
72
|
+
"@juzi/wechaty-puppet": "1.0.1"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"clone-class": "^1.1.1",
|
|
@@ -82,7 +82,7 @@ export const packageJson: PackageJson = {
|
|
|
82
82
|
"semver": "^7.3.5",
|
|
83
83
|
"stronger-typed-streams": "^0.2.0",
|
|
84
84
|
"uuid": "^8.3.2",
|
|
85
|
-
"@juzi/wechaty-grpc": "1.0.
|
|
85
|
+
"@juzi/wechaty-grpc": "1.0.1",
|
|
86
86
|
"wechaty-redux": "^1.20.2",
|
|
87
87
|
"wechaty-token": "^1.0.6"
|
|
88
88
|
},
|
|
@@ -695,6 +695,34 @@ function puppetImplementation (
|
|
|
695
695
|
}
|
|
696
696
|
},
|
|
697
697
|
|
|
698
|
+
messageChannel: async (call, callback) => {
|
|
699
|
+
log.verbose('PuppetServiceImpl', 'messageChannel()')
|
|
700
|
+
|
|
701
|
+
try {
|
|
702
|
+
const id = call.request.getId()
|
|
703
|
+
|
|
704
|
+
const payload = await puppet.messageChannel(id)
|
|
705
|
+
|
|
706
|
+
const response = new grpcPuppet.MessageChannelResponse()
|
|
707
|
+
|
|
708
|
+
const pbChannelPayload = new grpcPuppet.ChannelPayload()
|
|
709
|
+
if (payload.avatar) { pbChannelPayload.setAvatar(payload.avatar) }
|
|
710
|
+
if (payload.coverUrl) { pbChannelPayload.setCoverUrl(payload.coverUrl) }
|
|
711
|
+
if (payload.desc) { pbChannelPayload.setDesc(payload.desc) }
|
|
712
|
+
if (payload.extras) { pbChannelPayload.setExtras(payload.extras) }
|
|
713
|
+
if (payload.feedType) { pbChannelPayload.setFeedType(payload.feedType) }
|
|
714
|
+
if (payload.nickname) { pbChannelPayload.setNickname(payload.nickname) }
|
|
715
|
+
if (payload.thumbUrl) { pbChannelPayload.setThumbUrl(payload.thumbUrl) }
|
|
716
|
+
if (payload.url) { pbChannelPayload.setUrl(payload.url) }
|
|
717
|
+
response.setChannel(pbChannelPayload)
|
|
718
|
+
|
|
719
|
+
return callback(null, response)
|
|
720
|
+
|
|
721
|
+
} catch (e) {
|
|
722
|
+
return grpcError('messageMiniProgram', e, callback)
|
|
723
|
+
}
|
|
724
|
+
},
|
|
725
|
+
|
|
698
726
|
messagePayload: async (call, callback) => {
|
|
699
727
|
log.verbose('PuppetServiceImpl', 'messagePayload()')
|
|
700
728
|
|
|
@@ -992,6 +1020,35 @@ function puppetImplementation (
|
|
|
992
1020
|
}
|
|
993
1021
|
},
|
|
994
1022
|
|
|
1023
|
+
messageSendChannel: async (call, callback) => {
|
|
1024
|
+
log.verbose('PuppetServiceImpl', 'messageSendChannel()')
|
|
1025
|
+
|
|
1026
|
+
try {
|
|
1027
|
+
const conversationId = call.request.getConversationId()
|
|
1028
|
+
const pbChannelPayload = call.request.getChannel()?.toObject()
|
|
1029
|
+
|
|
1030
|
+
if (!pbChannelPayload) {
|
|
1031
|
+
return grpcError('messageSendUrl', new Error().stack, callback)
|
|
1032
|
+
}
|
|
1033
|
+
const payload: PUPPET.payloads.Channel = {
|
|
1034
|
+
...pbChannelPayload,
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
const messageId = await puppet.messageSendChannel(conversationId, payload)
|
|
1038
|
+
|
|
1039
|
+
const response = new grpcPuppet.MessageSendChannelResponse()
|
|
1040
|
+
|
|
1041
|
+
if (messageId) {
|
|
1042
|
+
response.setId(messageId)
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
return callback(null, response)
|
|
1046
|
+
|
|
1047
|
+
} catch (e) {
|
|
1048
|
+
return grpcError('messageSendChannel', e, callback)
|
|
1049
|
+
}
|
|
1050
|
+
},
|
|
1051
|
+
|
|
995
1052
|
messageUrl: async (call, callback) => {
|
|
996
1053
|
log.verbose('PuppetServiceImpl', 'messageUrl()')
|
|
997
1054
|
|