tmc.js 0.3.9 → 0.3.11

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/README.md CHANGED
@@ -134,11 +134,11 @@ new Tmc('your_app_key', 'your_app_secret', { autoReplyConfirmation: false })
134
134
 
135
135
  ## 支持的TOPICS
136
136
 
137
- <details><summary>共计 82+ 类别,441+ 消息数</summary>
137
+ <details><summary>共计 83+ 类别,445+ 消息数</summary>
138
138
 
139
139
  | 类别 | 消息数 |
140
140
  | --- | --- |
141
- | 淘宝交易 | 20 |
141
+ | 淘宝交易 | 21 |
142
142
  | 淘宝退款 | 13 |
143
143
  | 淘宝商品 | 13 |
144
144
  | 淘宝分销 | 23 |
@@ -154,8 +154,9 @@ new Tmc('your_app_key', 'your_app_secret', { autoReplyConfirmation: false })
154
154
  | 天猫美妆 | 2 |
155
155
  | 聚石塔 | 9 |
156
156
  | 淘宝物流 | 1 |
157
- | 阿里通信 | 17 |
157
+ | 阿里通信 | 18 |
158
158
  | 天猫魔盒 | 2 |
159
+ | 营销平台 | 1 |
159
160
  | OpenIM消息 | 1 |
160
161
  | 网上法庭 | 8 |
161
162
  | 电子发票 | 20 |
@@ -195,7 +196,7 @@ new Tmc('your_app_key', 'your_app_secret', { autoReplyConfirmation: false })
195
196
  | TVOS应用审核平台 | 1 |
196
197
  | Gifting送礼 | 1 |
197
198
  | 五道口商品 | 2 |
198
- | HOMEAI | 1 |
199
+ | HOMEAI | 2 |
199
200
  | HOMEAI消息对接 | 5 |
200
201
  | 零售通_公共 | 8 |
201
202
  | 酒店标准库基础信息变更消息 | 2 |
package/lib/message.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /* eslint max-classes-per-file: ["error", 3] */
2
2
  const { types } = require('util');
3
- const ValueFormat = require('./value-format');
4
3
  const MessageType = require('./message-type');
5
4
  const MessageKind = require('./message-kind');
6
5
  const {
@@ -9,6 +8,9 @@ const {
9
8
  const {
10
9
  TYPE, CODE, PHRASE, FLAG, TOKEN, CONTENT,
11
10
  } = require('./message-fields');
11
+ const {
12
+ Void, Byte, Int16, Int32, Int64, ByteArray, CountedString, Date: FmtDate,
13
+ } = require('./value-format');
12
14
 
13
15
  const kData = Symbol('kData');
14
16
  const kBuffer = Symbol('kBuffer');
@@ -58,10 +60,6 @@ const utf8 = 'utf8';
58
60
 
59
61
  const kOffset = Symbol('kOffset');
60
62
 
61
- const {
62
- Void, Byte, Int16, Int32, Int64, ByteArray, CountedString,
63
- } = ValueFormat;
64
-
65
63
  class Encoder {
66
64
  [kOffset] = 0;
67
65
 
@@ -89,25 +87,25 @@ class Encoder {
89
87
  }
90
88
 
91
89
  put(value) {
92
- this[kBuffer].push(['writeInt8', Number(value), (this[kOffset] += 1) - 1, 1]);
90
+ this[kBuffer].push(['writeInt8', Number(value), (this[kOffset] += 1) - 1]);
93
91
 
94
92
  return this;
95
93
  }
96
94
 
97
95
  putShort(value) {
98
- this[kBuffer].push(['writeInt16LE', Number(value), (this[kOffset] += 2) - 2, 2]);
96
+ this[kBuffer].push(['writeInt16LE', Number(value), (this[kOffset] += 2) - 2]);
99
97
 
100
98
  return this;
101
99
  }
102
100
 
103
101
  putInt(value) {
104
- this[kBuffer].push(['writeInt32LE', Number(value), (this[kOffset] += 4) - 4, 4]);
102
+ this[kBuffer].push(['writeInt32LE', Number(value), (this[kOffset] += 4) - 4]);
105
103
 
106
104
  return this;
107
105
  }
108
106
 
109
107
  putLong(value) {
110
- this[kBuffer].push(['writeBigInt64LE', BigInt(value), (this[kOffset] += 8) - 8, 8]);
108
+ this[kBuffer].push(['writeBigInt64LE', BigInt(value), (this[kOffset] += 8) - 8]);
111
109
 
112
110
  return this;
113
111
  }
@@ -120,6 +118,11 @@ class Encoder {
120
118
  return this;
121
119
  }
122
120
 
121
+ /**
122
+ * Only Support kind of `number`(integer), `bigint`, `string`(utf-8), `Date` and `Buffer` values
123
+ * @param {number|bigint|string|Date|Buffer} value - The value
124
+ * @returns {this} This instance
125
+ */
123
126
  writeCustomValue(value) {
124
127
  const type = typeof value;
125
128
  if (value === null || ['undefined', 'symbol', 'boolean', 'function'].includes(type)) {
@@ -151,16 +154,17 @@ class Encoder {
151
154
  }
152
155
 
153
156
  if (types.isDate(value)) {
154
- return this.put(ValueFormat.Date).putLong(value);
157
+ return this.put(FmtDate).putLong(value);
155
158
  }
156
159
 
157
160
  if (Buffer.isBuffer(value)) {
158
161
  const len = value.length;
159
162
  this.put(ByteArray).putInt(len);
160
- this[kBuffer].push(['fill', value, (this[kOffset] += len) - len, len]);
163
+ this[kBuffer].push(['fill', value, this[kOffset], this[kOffset] += len]);
164
+ return this;
161
165
  }
162
166
 
163
- return this;
167
+ return this.put(Void);
164
168
  }
165
169
 
166
170
  get buffer() {
@@ -220,36 +224,35 @@ class Decoder {
220
224
  }
221
225
 
222
226
  get() {
223
- const value = this[kBuffer].readInt8(this[kOffset]);
224
- this[kOffset] += 1;
227
+ const value = this[kBuffer].readInt8((this[kOffset] += 1) - 1);
228
+
225
229
  return Number(value);
226
230
  }
227
231
 
228
232
  getShort() {
229
- const value = this[kBuffer].readInt16LE(this[kOffset]);
230
- this[kOffset] += 2;
233
+ const value = this[kBuffer].readInt16LE((this[kOffset] += 2) - 2);
234
+
231
235
  return Number(value);
232
236
  }
233
237
 
234
238
  getInt() {
235
- const value = this[kBuffer].readInt32LE(this[kOffset]);
236
- this[kOffset] += 4;
239
+ const value = this[kBuffer].readInt32LE((this[kOffset] += 4) - 4);
240
+
237
241
  return Number(value);
238
242
  }
239
243
 
240
244
  getLong() {
241
- const value = this[kBuffer].readBigInt64LE(this[kOffset]);
242
- this[kOffset] += 8;
245
+ const value = this[kBuffer].readBigInt64LE((this[kOffset] += 8) - 8);
246
+
243
247
  return BigInt(value);
244
248
  }
245
249
 
246
250
  readBuffer() {
247
251
  const size = this.getInt();
248
- if (size === 0) {
249
- return null;
250
- }
251
- const buf = this[kBuffer].subarray(this[kOffset], this[kOffset] + size);
252
- this[kOffset] += size;
252
+ if (size === 0) { return null; }
253
+
254
+ const buf = this[kBuffer].subarray(this[kOffset], this[kOffset] += size);
255
+
253
256
  return buf;
254
257
  }
255
258
 
@@ -267,7 +270,7 @@ class Decoder {
267
270
 
268
271
  [`parse${Int64}`]() { return this.getLong(); }
269
272
 
270
- [`parse${ValueFormat.Date}`]() { return new Date(Number(this.getLong())); }
273
+ [`parse${FmtDate}`]() { return new Date(Number(this.getLong())); }
271
274
 
272
275
  [`parse${ByteArray}`]() { return this.readBuffer(); }
273
276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmc.js",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "Events driven and chained Taobao Message Channel(TMC) for NodeJS",
5
5
  "author": "James ZHANG",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@ declare namespace Alibaba.Alicom {
48
48
  }
49
49
  }
50
50
 
51
- /** 阿里健康-疫苗 */
51
+ /** 阿里健康追溯码 */
52
52
  declare namespace Alibaba.Alihealth {
53
53
  /** 单据处理状态通知 */
54
54
  interface BillProcessStatusNotify {
@@ -340,6 +340,26 @@ declare namespace Alibaba.Aliqin {
340
340
  oper_type: string;
341
341
  }
342
342
 
343
+ /** 语音呼叫结果推送 */
344
+ interface TaFcCallCdr {
345
+ /** 任务主键 */
346
+ biz_id: string;
347
+ /** DTMF */
348
+ dtmf: string;
349
+ /** 通话时长,未接通为0 */
350
+ duration: string;
351
+ /** 通话结束时间,未接通则为空 */
352
+ end_time: string;
353
+ /** 扩展字段回传,将调用api时传入的字段返回 */
354
+ extend: string;
355
+ /** 通话开始时间,未接通则为空 */
356
+ start_time: string;
357
+ /** 呼叫结果状态码 */
358
+ status_code: string;
359
+ /** 结果描述 */
360
+ status_msg: string;
361
+ }
362
+
343
363
  /** 聚石塔短消息发送结果报告 */
344
364
  interface TaFcSmsDR {
345
365
  /** 任务主键 */
@@ -484,7 +504,7 @@ declare namespace Alibaba.Happytrip {
484
504
  }
485
505
  }
486
506
 
487
- /** 阿里发票 */
507
+ /** 电子发票 */
488
508
  declare namespace Alibaba.Invoice {
489
509
  /** 开票申请 */
490
510
  interface Apply {
@@ -1233,7 +1253,7 @@ declare namespace Alibaba.Nlife {
1233
1253
  /** 商品的商家编码 */
1234
1254
  outer_id: string;
1235
1255
  /** 商品的skuId */
1236
- sku_id: number;
1256
+ sku_id: number | bigint;
1237
1257
  /** 门店id */
1238
1258
  store_id: string;
1239
1259
  /** 商品的变动类型:PRICE_CHANGE-价格变化; INVENTORY_CHANGE-库存变化; ONSALE_CHANGE-上架变化; OFFSALE_CHANGE-下架变化; NEWSKU_CHANGE-新增sku变化; DELSKU_CHANGE-删除sku变化 */
@@ -1405,7 +1425,7 @@ declare namespace Alibaba.Tianji {
1405
1425
  }
1406
1426
  }
1407
1427
 
1408
- /** 五道口商品 */
1428
+ /** 五道口订单 */
1409
1429
  declare namespace Alibaba.Wdk {
1410
1430
  /** 差评回评 */
1411
1431
  interface ChannelCommentAudit {
package/types/fliggy.d.ts CHANGED
@@ -83,7 +83,7 @@ declare namespace Fliggy.Ticket {
83
83
  /** 产品价格 */
84
84
  product_price: number;
85
85
  /** skuId */
86
- sku_id: number;
86
+ sku_id: number | bigint;
87
87
  }
88
88
 
89
89
  /** 域外分销订单码核销消息 */