tmc.js 0.3.0
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/LICENSE +19 -0
- package/README.md +36 -0
- package/index.js +16 -0
- package/index.mjs +10 -0
- package/lib/consumer.js +206 -0
- package/lib/header-type.js +29 -0
- package/lib/logger.js +18 -0
- package/lib/message-fields.js +61 -0
- package/lib/message-kind.js +35 -0
- package/lib/message-type.js +26 -0
- package/lib/message.js +302 -0
- package/lib/value-format.js +37 -0
- package/package.json +48 -0
- package/types/alibaba.d.ts +1919 -0
- package/types/alicom.d.ts +40 -0
- package/types/aliexpress.d.ts +165 -0
- package/types/alihealth.d.ts +39 -0
- package/types/alitrip.d.ts +298 -0
- package/types/aliyun.d.ts +10 -0
- package/types/banma.d.ts +14 -0
- package/types/cainiao.d.ts +39 -0
- package/types/damai.d.ts +59 -0
- package/types/fliggy.d.ts +96 -0
- package/types/fuwu.d.ts +32 -0
- package/types/gov.d.ts +30 -0
- package/types/idle.d.ts +174 -0
- package/types/index.d.ts +1691 -0
- package/types/jae.d.ts +6 -0
- package/types/lst.d.ts +26 -0
- package/types/message.d.ts +20 -0
- package/types/message.in.d.ts +848 -0
- package/types/taobao.d.ts +2971 -0
- package/types/tmall.d.ts +480 -0
- package/types/trip.d.ts +116 -0
- package/types/wdk.d.ts +83 -0
- package/types/xianyu.d.ts +183 -0
- package/types/youku.d.ts +18 -0
- package/types/yunos.d.ts +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2022 James ZHANG(TheNorthMemory)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Taobao Message Channel (tmc.js)
|
|
2
|
+
|
|
3
|
+
Events driven and chained Taobao Message Channel(TMC) for NodeJS
|
|
4
|
+
|
|
5
|
+
## 使用
|
|
6
|
+
|
|
7
|
+
`npm i tmc.js`
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import TMC from 'tmc.js';
|
|
11
|
+
|
|
12
|
+
new TMC('your_app_key', 'your_app_secret')
|
|
13
|
+
.on('taobao_trade_TradeChanged', msg => console.info(msg))
|
|
14
|
+
.taobao_trade_TradeClose(msg => console.info(msg))
|
|
15
|
+
.connect();
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
**`new TMC(appKey: string, appSecret: BinaryLike, groupName?: string | object, options?: object)`**
|
|
21
|
+
|
|
22
|
+
| 参数 | 类型 | 说明 |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| appKey | `string` | 应用ID |
|
|
25
|
+
| appSecret | `BinaryLike` | 应用密钥 |
|
|
26
|
+
| groupName | `string` | 消息分组(可选,默认`default`) |
|
|
27
|
+
| options | `object` | 消费端配置参数(可选) |
|
|
28
|
+
| options.pullRequestInterval | `number` | 定时发送`pullRequest`请求时间间隔(默认`5000`毫秒) |
|
|
29
|
+
| options.onErrorReconnection | `number` | 当消费端出现错误,重试连接间隔(默认`15000`毫秒) |
|
|
30
|
+
| options.onCloseReconnection | `number` | 当消费端断开连接,重试连接间隔(默认`3000`毫秒) |
|
|
31
|
+
| options.autoParseContentJson | `boolean` | 自动解析推送消息`$.content.content`字段为对象(默认`true`) |
|
|
32
|
+
| options.autoReplyConfirmation | `boolean` | 以推送的`$.content.id`字段自动`Confirm`消息(默认`true`) |
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
[MIT](LICENSE)
|
package/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const TaoMessageConsumer = require('./lib/consumer');
|
|
2
|
+
const HeaderType = require('./lib/header-type');
|
|
3
|
+
const MessageFields = require('./lib/message-fields');
|
|
4
|
+
const MessageKind = require('./lib/message-kind');
|
|
5
|
+
const MessageType = require('./lib/message-type');
|
|
6
|
+
const Message = require('./lib/message');
|
|
7
|
+
const ValueFormat = require('./lib/value-format');
|
|
8
|
+
|
|
9
|
+
module.exports = TaoMessageConsumer;
|
|
10
|
+
module.exports.default = TaoMessageConsumer;
|
|
11
|
+
module.exports.HeaderType = HeaderType;
|
|
12
|
+
module.exports.MessageFields = MessageFields;
|
|
13
|
+
module.exports.MessageKind = MessageKind;
|
|
14
|
+
module.exports.MessageType = MessageType;
|
|
15
|
+
module.exports.Message = Message;
|
|
16
|
+
module.exports.ValueFormat = ValueFormat;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import TaoMessageConsumer from './lib/consumer.js';
|
|
2
|
+
import HeaderType from './lib/header-type.js';
|
|
3
|
+
import MessageFields from './lib/message-fields.js';
|
|
4
|
+
import MessageKind from './lib/message-kind.js';
|
|
5
|
+
import MessageType from './lib/message-type.js';
|
|
6
|
+
import Message from './lib/message.js';
|
|
7
|
+
import ValueFormat from './lib/value-format.js';
|
|
8
|
+
|
|
9
|
+
export { HeaderType, MessageFields, MessageKind, MessageType, Message, ValueFormat };
|
|
10
|
+
export default TaoMessageConsumer;
|
package/lib/consumer.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
const { createHash, createSecretKey } = require('crypto');
|
|
2
|
+
const { networkInterfaces } = require('os');
|
|
3
|
+
const { EventEmitter, captureRejectionSymbol } = require('events');
|
|
4
|
+
|
|
5
|
+
const WebSocket = require('ws');
|
|
6
|
+
const JSONB = require('json-bigint')({ useNativeBigInt: true });
|
|
7
|
+
|
|
8
|
+
const logger = require('./logger');
|
|
9
|
+
const Message = require('./message');
|
|
10
|
+
const { PullRequest, Confirm } = require('./message-kind');
|
|
11
|
+
const {
|
|
12
|
+
CONNECT, SEND, SENDACK, CONNECTACK,
|
|
13
|
+
} = require('./message-type');
|
|
14
|
+
const {
|
|
15
|
+
APP_KEY, GROUP_NAME, INTRANET_IP, TIMESTAMP, SIGN, SDK, TYPE, CODE, TOKEN, CONTENT, ID, TOPIC,
|
|
16
|
+
} = require('./message-fields');
|
|
17
|
+
|
|
18
|
+
const kAddress = Symbol('kAddress');
|
|
19
|
+
const kAppKey = Symbol('kAppKey');
|
|
20
|
+
const kAppSecret = Symbol('kAppSecret');
|
|
21
|
+
const kGroupName = Symbol('kGroupName');
|
|
22
|
+
const kToken = Symbol('kToken');
|
|
23
|
+
const kOptions = Symbol('kOptions');
|
|
24
|
+
const kWebSocket = Symbol('kWebSocket');
|
|
25
|
+
|
|
26
|
+
function ipAddr() {
|
|
27
|
+
return Object.values(networkInterfaces()).flat().find(
|
|
28
|
+
({ internal, family, address }) => !internal && (family === 'IPv4' || family === 4) && address !== '127.0.0.1',
|
|
29
|
+
)?.address;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
class TaoMessageComsumer extends EventEmitter {
|
|
33
|
+
[kAddress] = 'ws://mc.api.taobao.com/';
|
|
34
|
+
|
|
35
|
+
[kGroupName] = 'default';
|
|
36
|
+
|
|
37
|
+
[kAppKey];
|
|
38
|
+
|
|
39
|
+
[kAppSecret];
|
|
40
|
+
|
|
41
|
+
[kToken];
|
|
42
|
+
|
|
43
|
+
[kOptions] = {
|
|
44
|
+
pullRequestInterval: 5e3,
|
|
45
|
+
onErrorReconnection: 15e3,
|
|
46
|
+
onCloseReconnection: 3e3,
|
|
47
|
+
autoParseContentJson: true,
|
|
48
|
+
autoReplyConfirmation: true,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
[kWebSocket];
|
|
52
|
+
|
|
53
|
+
constructor(appKey, appSecret, groupName, options = {}) {
|
|
54
|
+
super({ captureRejections: true });
|
|
55
|
+
|
|
56
|
+
this[kAppKey] = appKey;
|
|
57
|
+
this[kAppSecret] = createSecretKey(appSecret);
|
|
58
|
+
if (groupName && typeof groupName === 'string') { this[kGroupName] = groupName; }
|
|
59
|
+
this[kOptions] = {
|
|
60
|
+
...this[kOptions],
|
|
61
|
+
...(typeof groupName === 'object' ? groupName : options),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return /* eslint-disable-line no-constructor-return */ new Proxy(this, {
|
|
65
|
+
get(target, topic) {
|
|
66
|
+
if (typeof topic === 'symbol') { return target[topic]; }
|
|
67
|
+
if (!Object.prototype.hasOwnProperty.call(target, topic) && !(topic in target)) {
|
|
68
|
+
Object.defineProperty(target, topic, {
|
|
69
|
+
value: function subscriber(callback) {
|
|
70
|
+
if (typeof callback !== 'function') {
|
|
71
|
+
throw new TypeError('The callback must be a function here.');
|
|
72
|
+
}
|
|
73
|
+
return this.on(topic, callback);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return target[topic];
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
sign(timestamp) {
|
|
84
|
+
const sk = this[kAppSecret].export();
|
|
85
|
+
return [
|
|
86
|
+
['app_key', this[kAppKey]],
|
|
87
|
+
['group_name', this[kGroupName]],
|
|
88
|
+
['timestamp', `${timestamp}`],
|
|
89
|
+
].reduce(
|
|
90
|
+
(h, [k, v]) => h.update(k).update(v),
|
|
91
|
+
createHash('md5').update(sk),
|
|
92
|
+
).update(sk).digest('hex').toUpperCase();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
onopen() {
|
|
96
|
+
const now = `${Date.now()}`;
|
|
97
|
+
const msg = new Message(CONNECT)
|
|
98
|
+
.with(APP_KEY, this[kAppKey])
|
|
99
|
+
.with(GROUP_NAME, this[kGroupName])
|
|
100
|
+
.with(TIMESTAMP, now)
|
|
101
|
+
.with(SIGN, this.sign(now))
|
|
102
|
+
.with(SDK, this.constructor.name)
|
|
103
|
+
.with(INTRANET_IP, ipAddr());
|
|
104
|
+
|
|
105
|
+
logger.onopen(JSONB.stringify(msg));
|
|
106
|
+
|
|
107
|
+
this[kWebSocket]?.send(msg.buffer, { mask: true, binary: true });
|
|
108
|
+
|
|
109
|
+
if (this[kOptions].intervalId) { clearInterval(this[kOptions].intervalId); }
|
|
110
|
+
|
|
111
|
+
this[kOptions].intervalId = setInterval(() => this.onpull(), this[kOptions].pullRequestInterval);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
onpull() {
|
|
115
|
+
const msg = new Message(SEND, PullRequest).with(TOKEN, this[kToken]);
|
|
116
|
+
logger.onpull(JSONB.stringify(msg));
|
|
117
|
+
this[kWebSocket]?.send(msg.buffer, { mask: true, binary: true });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
onping(data) {
|
|
121
|
+
logger.onping('The channel is onping with data [%s].', JSONB.stringify(data));
|
|
122
|
+
this[kWebSocket]?.pong(data, { mask: true }, true);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
onerror(err) {
|
|
126
|
+
logger.onerror('The channel is onerror(%s), let us reconnect.', JSONB.stringify(err));
|
|
127
|
+
this.reconnect(this[kOptions].onErrorReconnection);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
onclose(...arg) {
|
|
131
|
+
logger.onclose('The channel is onclose(%s), let us reconnect.', JSONB.stringify(arg));
|
|
132
|
+
this.reconnect(this[kOptions].onCloseReconnection);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
[`process${CONNECTACK}`](msg) {
|
|
136
|
+
if (!msg[CODE] && msg[TOKEN]) { this[kToken] = msg[TOKEN]; }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
[`process${SEND}`](msg) {
|
|
140
|
+
if (msg && msg[CONTENT] && msg[CONTENT][TOPIC]) { this.emit(msg[CONTENT][TOPIC], msg); }
|
|
141
|
+
|
|
142
|
+
if (this[kOptions].autoReplyConfirmation && msg && msg[CONTENT] && msg[CONTENT][ID]) {
|
|
143
|
+
const reply = new Message(SEND, Confirm).with(TOKEN, this[kToken]).with(ID, msg[CONTENT][ID]);
|
|
144
|
+
logger.onmessage[SEND][Confirm](JSONB.stringify(reply));
|
|
145
|
+
this[kWebSocket]?.send(reply.buffer, { mask: true, binary: true });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
[`process${CONNECT}`]() { /* eslint-disable-line class-methods-use-this */ }
|
|
150
|
+
|
|
151
|
+
[`process${SENDACK}`]() { /* eslint-disable-line class-methods-use-this */ }
|
|
152
|
+
|
|
153
|
+
processundefined() { /* eslint-disable-line class-methods-use-this */ }
|
|
154
|
+
|
|
155
|
+
[captureRejectionSymbol](err) { this.onerror(err); }
|
|
156
|
+
|
|
157
|
+
onmessage(data, isBinary = true) {
|
|
158
|
+
if (!isBinary) { return; }
|
|
159
|
+
|
|
160
|
+
const msg = Message.from(data);
|
|
161
|
+
|
|
162
|
+
if (
|
|
163
|
+
this[kOptions].autoParseContentJson
|
|
164
|
+
&& msg[CONTENT][CONTENT]
|
|
165
|
+
&& typeof msg[CONTENT][CONTENT] === 'string'
|
|
166
|
+
&& /^\{.*\}$/.test(msg[CONTENT][CONTENT])) {
|
|
167
|
+
Reflect.set(msg[CONTENT], CONTENT, JSONB.parse(msg[CONTENT][CONTENT]));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
logger.onmessage[msg[TYPE]](JSONB.stringify(msg));
|
|
171
|
+
|
|
172
|
+
this[`process${msg[TYPE]}`](msg);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
reconnect(ms) {
|
|
176
|
+
this[kWebSocket]?.terminate();
|
|
177
|
+
|
|
178
|
+
if (this[kOptions].intervalId) { this[kOptions].intervalId = clearInterval(this[kOptions].intervalId); }
|
|
179
|
+
if (this[kOptions].timeoutId) { this[kOptions].timeoutId = clearTimeout(this[kOptions].timeoutId); }
|
|
180
|
+
|
|
181
|
+
this[kWebSocket] = undefined;
|
|
182
|
+
this[kOptions].timeoutId = setTimeout(() => this.connect(), ms);
|
|
183
|
+
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
connect(address) {
|
|
188
|
+
if (address) { this[kAddress] = address; }
|
|
189
|
+
|
|
190
|
+
this[kWebSocket]?.close();
|
|
191
|
+
|
|
192
|
+
const ws = new WebSocket(this[kAddress]);
|
|
193
|
+
Reflect.set(this, kWebSocket, ws);
|
|
194
|
+
|
|
195
|
+
ws.on('open', () => this.onopen());
|
|
196
|
+
ws.on('ping', (...arg) => this.onping(...arg));
|
|
197
|
+
ws.on('error', (err) => this.onerror(err));
|
|
198
|
+
ws.on('close', (...arg) => this.onclose(...arg));
|
|
199
|
+
ws.on('message', (...arg) => this.onmessage(...arg));
|
|
200
|
+
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
module.exports = TaoMessageComsumer;
|
|
206
|
+
module.exports.default = TaoMessageComsumer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const EndOfHeaders = 0;
|
|
2
|
+
const Custom = 1;
|
|
3
|
+
const StatusCode = 2;
|
|
4
|
+
const StatusPhrase = 3;
|
|
5
|
+
const Flag = 4;
|
|
6
|
+
const Token = 5;
|
|
7
|
+
|
|
8
|
+
class HeaderType {
|
|
9
|
+
static EndOfHeaders = EndOfHeaders;
|
|
10
|
+
|
|
11
|
+
static Custom = Custom;
|
|
12
|
+
|
|
13
|
+
static StatusCode = StatusCode;
|
|
14
|
+
|
|
15
|
+
static StatusPhrase = StatusPhrase;
|
|
16
|
+
|
|
17
|
+
static Flag = Flag;
|
|
18
|
+
|
|
19
|
+
static Token = Token;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = HeaderType;
|
|
23
|
+
module.exports.default = HeaderType;
|
|
24
|
+
module.exports.EndOfHeaders = EndOfHeaders;
|
|
25
|
+
module.exports.Custom = Custom;
|
|
26
|
+
module.exports.StatusCode = StatusCode;
|
|
27
|
+
module.exports.StatusPhrase = StatusPhrase;
|
|
28
|
+
module.exports.Flag = Flag;
|
|
29
|
+
module.exports.Token = Token;
|
package/lib/logger.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { debuglog } = require('util');
|
|
2
|
+
|
|
3
|
+
const logger = debuglog('tmc');
|
|
4
|
+
|
|
5
|
+
logger.onping = debuglog('tmc:onping');
|
|
6
|
+
logger.onopen = debuglog('tmc:onopen');
|
|
7
|
+
logger.onpull = debuglog('tmc:onpull');
|
|
8
|
+
logger.onerror = debuglog('tmc:onerror');
|
|
9
|
+
logger.onclose = debuglog('tmc:onclose');
|
|
10
|
+
logger.onmessage = debuglog('tmc:onmessage');
|
|
11
|
+
logger.onmessage[0] = debuglog('tmc:onmessage:connect');
|
|
12
|
+
logger.onmessage[1] = debuglog('tmc:onmessage:connectack');
|
|
13
|
+
logger.onmessage[2] = debuglog('tmc:onmessage:send');
|
|
14
|
+
logger.onmessage[3] = debuglog('tmc:onmessage:sendack');
|
|
15
|
+
logger.onmessage[2][2] = debuglog('tmc:onmessage:send:confirm');
|
|
16
|
+
|
|
17
|
+
module.exports = logger;
|
|
18
|
+
module.exports.default = logger;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const TYPE = 'messageType';
|
|
2
|
+
const CODE = 'statusCode';
|
|
3
|
+
const PHRASE = 'statusPhrase';
|
|
4
|
+
const FLAG = 'flag';
|
|
5
|
+
const TOKEN = 'token';
|
|
6
|
+
const CONTENT = 'content';
|
|
7
|
+
const APP_KEY = 'app_key';
|
|
8
|
+
const GROUP_NAME = 'group_name';
|
|
9
|
+
const TIMESTAMP = 'timestamp';
|
|
10
|
+
const SIGN = 'sign';
|
|
11
|
+
const SDK = 'sdk';
|
|
12
|
+
const INTRANET_IP = 'intranet_ip';
|
|
13
|
+
const ID = 'id';
|
|
14
|
+
const TOPIC = 'topic';
|
|
15
|
+
|
|
16
|
+
class MessageFields {
|
|
17
|
+
static TYPE = TYPE;
|
|
18
|
+
|
|
19
|
+
static CODE = CODE;
|
|
20
|
+
|
|
21
|
+
static PHRASE = PHRASE;
|
|
22
|
+
|
|
23
|
+
static FLAG = FLAG;
|
|
24
|
+
|
|
25
|
+
static TOKEN = TOKEN;
|
|
26
|
+
|
|
27
|
+
static CONTENT = CONTENT;
|
|
28
|
+
|
|
29
|
+
static APP_KEY = APP_KEY;
|
|
30
|
+
|
|
31
|
+
static GROUP_NAME = GROUP_NAME;
|
|
32
|
+
|
|
33
|
+
static TIMESTAMP = TIMESTAMP;
|
|
34
|
+
|
|
35
|
+
static SIGN = SIGN;
|
|
36
|
+
|
|
37
|
+
static SDK = SDK;
|
|
38
|
+
|
|
39
|
+
static INTRANET_IP = INTRANET_IP;
|
|
40
|
+
|
|
41
|
+
static ID = ID;
|
|
42
|
+
|
|
43
|
+
static TOPIC = TOPIC;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = MessageFields;
|
|
47
|
+
module.exports.default = MessageFields;
|
|
48
|
+
module.exports.TYPE = TYPE;
|
|
49
|
+
module.exports.CODE = CODE;
|
|
50
|
+
module.exports.PHRASE = PHRASE;
|
|
51
|
+
module.exports.FLAG = FLAG;
|
|
52
|
+
module.exports.TOKEN = TOKEN;
|
|
53
|
+
module.exports.CONTENT = CONTENT;
|
|
54
|
+
module.exports.APP_KEY = APP_KEY;
|
|
55
|
+
module.exports.GROUP_NAME = GROUP_NAME;
|
|
56
|
+
module.exports.TIMESTAMP = TIMESTAMP;
|
|
57
|
+
module.exports.SIGN = SIGN;
|
|
58
|
+
module.exports.SDK = SDK;
|
|
59
|
+
module.exports.INTRANET_IP = INTRANET_IP;
|
|
60
|
+
module.exports.ID = ID;
|
|
61
|
+
module.exports.TOPIC = TOPIC;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const None = 0;
|
|
2
|
+
const PullRequest = 1;
|
|
3
|
+
const Confirm = 2;
|
|
4
|
+
const Data = 3;
|
|
5
|
+
const Failed = 20;
|
|
6
|
+
|
|
7
|
+
function includes(value) { return [None, PullRequest, Confirm, Data, Failed].includes(value); }
|
|
8
|
+
|
|
9
|
+
function toPrimitive() { return '__kind'; }
|
|
10
|
+
|
|
11
|
+
class MessageKind {
|
|
12
|
+
static None = None;
|
|
13
|
+
|
|
14
|
+
static PullRequest = PullRequest;
|
|
15
|
+
|
|
16
|
+
static Confirm = Confirm;
|
|
17
|
+
|
|
18
|
+
static Data = Data;
|
|
19
|
+
|
|
20
|
+
static Failed = Failed;
|
|
21
|
+
|
|
22
|
+
static includes = includes;
|
|
23
|
+
|
|
24
|
+
static [Symbol.toPrimitive] = toPrimitive;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = MessageKind;
|
|
28
|
+
module.exports.default = MessageKind;
|
|
29
|
+
module.exports.None = None;
|
|
30
|
+
module.exports.PullRequest = PullRequest;
|
|
31
|
+
module.exports.Confirm = Confirm;
|
|
32
|
+
module.exports.Data = Data;
|
|
33
|
+
module.exports.Failed = Failed;
|
|
34
|
+
module.exports.includes = includes;
|
|
35
|
+
module.exports[Symbol.toPrimitive] = toPrimitive;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const CONNECT = 0;
|
|
2
|
+
const CONNECTACK = 1;
|
|
3
|
+
const SEND = 2;
|
|
4
|
+
const SENDACK = 3;
|
|
5
|
+
|
|
6
|
+
function includes(value) { return [CONNECT, CONNECTACK, SEND, SENDACK].includes(value); }
|
|
7
|
+
|
|
8
|
+
class MessageType {
|
|
9
|
+
static CONNECT = CONNECT;
|
|
10
|
+
|
|
11
|
+
static CONNECTACK = CONNECTACK;
|
|
12
|
+
|
|
13
|
+
static SEND = SEND;
|
|
14
|
+
|
|
15
|
+
static SENDACK = SENDACK;
|
|
16
|
+
|
|
17
|
+
static includes = includes;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = MessageType;
|
|
21
|
+
module.exports.default = MessageType;
|
|
22
|
+
module.exports.CONNECT = CONNECT;
|
|
23
|
+
module.exports.CONNECTACK = CONNECTACK;
|
|
24
|
+
module.exports.SEND = SEND;
|
|
25
|
+
module.exports.SENDACK = SENDACK;
|
|
26
|
+
module.exports.includes = includes;
|