node-easywechat 2.8.0 → 2.9.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.
Files changed (142) hide show
  1. package/README.md +51 -4
  2. package/dist/BaseService/Jssdk/JssdkClient.js +5 -5
  3. package/dist/BaseService/Media/MediaClient.js +1 -1
  4. package/dist/Core/AES.d.ts +1 -1
  5. package/dist/Core/AES.js +4 -4
  6. package/dist/Core/BaseAccessToken.js +2 -2
  7. package/dist/Core/BaseApplication.js +4 -4
  8. package/dist/Core/BaseClient.js +2 -2
  9. package/dist/Core/Cache/FileCache.js +3 -3
  10. package/dist/Core/Encryptor.js +3 -3
  11. package/dist/Core/Http/Request.js +13 -13
  12. package/dist/Core/Http/StreamResponse.js +1 -1
  13. package/dist/Core/Messages/Media.js +2 -2
  14. package/dist/Core/Messages/Message.js +7 -7
  15. package/dist/Core/Mixins/HttpMixin.js +4 -4
  16. package/dist/Core/ServerGuard.d.ts +2 -2
  17. package/dist/Core/ServerGuard.js +5 -5
  18. package/dist/Core/Types.d.ts +34 -4
  19. package/dist/Core/Utils.js +18 -18
  20. package/dist/MicroMerchant/Application.js +1 -1
  21. package/dist/MicroMerchant/Base/MicroMerchantBase.js +6 -6
  22. package/dist/MicroMerchant/Certficates/CertficatesClient.js +1 -1
  23. package/dist/MicroMerchant/Core/BaseClient.js +8 -8
  24. package/dist/MicroMerchant/Media/MediaClient.js +1 -1
  25. package/dist/MicroMerchant/MerchantConfig/MerchantConfigClient.js +1 -1
  26. package/dist/MicroMerchant/Meterial/MeterialClient.js +4 -4
  27. package/dist/MicroMerchant/Withdraw/WithdrawClient.js +2 -2
  28. package/dist/MiniProgram/ActivityMessage/ActivityMessageClient.js +3 -3
  29. package/dist/MiniProgram/AppCode/AppCodeClient.js +2 -2
  30. package/dist/MiniProgram/Application.d.ts +16 -0
  31. package/dist/MiniProgram/Application.js +40 -0
  32. package/dist/MiniProgram/Base/MiniProgramBase.js +1 -1
  33. package/dist/MiniProgram/NearbyPoi/NearbyPoiClient.js +3 -3
  34. package/dist/MiniProgram/OpenData/OpenDataClient.js +2 -2
  35. package/dist/MiniProgram/RealtimeLog/RealtimeLogClient.js +1 -1
  36. package/dist/MiniProgram/Shop/AccoutClient.d.ts +25 -0
  37. package/dist/MiniProgram/Shop/AccoutClient.js +42 -0
  38. package/dist/MiniProgram/Shop/AftersaleClient.d.ts +22 -0
  39. package/dist/MiniProgram/Shop/AftersaleClient.js +35 -0
  40. package/dist/MiniProgram/Shop/BasicClient.d.ts +39 -0
  41. package/dist/MiniProgram/Shop/BasicClient.js +69 -0
  42. package/dist/MiniProgram/Shop/DeliveryClient.d.ts +20 -0
  43. package/dist/MiniProgram/Shop/DeliveryClient.js +32 -0
  44. package/dist/MiniProgram/Shop/OrderClient.d.ts +32 -0
  45. package/dist/MiniProgram/Shop/OrderClient.js +51 -0
  46. package/dist/MiniProgram/Shop/RegisterClient.d.ts +25 -0
  47. package/dist/MiniProgram/Shop/RegisterClient.js +43 -0
  48. package/dist/MiniProgram/Shop/SpuClient.d.ts +67 -0
  49. package/dist/MiniProgram/Shop/SpuClient.js +92 -0
  50. package/dist/MiniProgram/ShortLink/ShortLinkClient.d.ts +11 -0
  51. package/dist/MiniProgram/ShortLink/ShortLinkClient.js +23 -0
  52. package/dist/MiniProgram/SubscribeMessage/SubscribeMessageClient.js +5 -5
  53. package/dist/MiniProgram/UniformMessage/UniformMessageClient.js +3 -3
  54. package/dist/MiniProgram/UrlLink/UrlLinkClient.d.ts +6 -1
  55. package/dist/MiniProgram/UrlLink/UrlLinkClient.js +7 -2
  56. package/dist/OfficialAccount/Base/OfficialAccountBase.js +2 -2
  57. package/dist/OfficialAccount/Broadcasting/BroadcastingClient.js +2 -2
  58. package/dist/OfficialAccount/Broadcasting/MessageBuilder.js +1 -1
  59. package/dist/OfficialAccount/Card/Client.js +1 -1
  60. package/dist/OfficialAccount/Card/JssdkClient.js +2 -2
  61. package/dist/OfficialAccount/Card/MemberCardClient.js +1 -1
  62. package/dist/OfficialAccount/CustomerService/CustomerServiceClient.js +2 -2
  63. package/dist/OfficialAccount/CustomerService/Messenger.js +1 -1
  64. package/dist/OfficialAccount/DataCube/DataCubeClient.js +1 -1
  65. package/dist/OfficialAccount/Material/MaterialClient.js +2 -2
  66. package/dist/OfficialAccount/OCR/OCRClient.js +1 -1
  67. package/dist/OfficialAccount/Semantic/SemanticClient.js +1 -1
  68. package/dist/OfficialAccount/SubscribeMessage/SubscribeMessageClient.js +4 -4
  69. package/dist/OfficialAccount/TemplateMessage/TemplateMessageClient.js +4 -4
  70. package/dist/OpenPlatform/Application.js +8 -8
  71. package/dist/OpenPlatform/Authorizer/Auth/AccessToken.js +1 -1
  72. package/dist/OpenPlatform/Authorizer/OfficialAccount/Account/Client.js +1 -1
  73. package/dist/OpenWork/Application.d.ts +37 -0
  74. package/dist/OpenWork/Application.js +128 -0
  75. package/dist/OpenWork/Auth/ProviderAccessToken.d.ts +8 -0
  76. package/dist/OpenWork/Auth/ProviderAccessToken.js +33 -0
  77. package/dist/OpenWork/Auth/SuiteAccessToken.d.ts +8 -0
  78. package/dist/OpenWork/Auth/SuiteAccessToken.js +34 -0
  79. package/dist/OpenWork/Auth/SuiteTicket.d.ts +8 -0
  80. package/dist/OpenWork/Auth/SuiteTicket.js +40 -0
  81. package/dist/OpenWork/Corp/CorpClient.d.ts +72 -0
  82. package/dist/OpenWork/Corp/CorpClient.js +150 -0
  83. package/dist/OpenWork/MiniProgram/MiniProgramClient.d.ts +5 -0
  84. package/dist/OpenWork/MiniProgram/MiniProgramClient.js +18 -0
  85. package/dist/OpenWork/Provider/ProviderClient.d.ts +81 -0
  86. package/dist/OpenWork/Provider/ProviderClient.js +172 -0
  87. package/dist/OpenWork/Server/OpenWorkGuard.d.ts +13 -0
  88. package/dist/OpenWork/Server/OpenWorkGuard.js +51 -0
  89. package/dist/OpenWork/Work/Application.d.ts +5 -0
  90. package/dist/OpenWork/Work/Application.js +22 -0
  91. package/dist/OpenWork/Work/Auth/AccessToken.d.ts +12 -0
  92. package/dist/OpenWork/Work/Auth/AccessToken.js +44 -0
  93. package/dist/Payment/Application.js +4 -4
  94. package/dist/Payment/Bill/BillClient.js +2 -2
  95. package/dist/Payment/Core/BaseClient.js +8 -8
  96. package/dist/Payment/Jssdk/JssdkClient.js +14 -14
  97. package/dist/Payment/Merchant/MerchantClient.js +1 -1
  98. package/dist/Payment/Notify/Handler.js +5 -5
  99. package/dist/Payment/Notify/Refunded.js +1 -1
  100. package/dist/Payment/Notify/Scanned.js +2 -2
  101. package/dist/Payment/Order/OrderClient.js +1 -1
  102. package/dist/Payment/Redpack/RedpackClient.js +5 -5
  103. package/dist/Payment/Refund/RefundClient.js +3 -3
  104. package/dist/Payment/Sandbox/SandboxClient.js +1 -1
  105. package/dist/Payment/Transfer/TransferClient.js +1 -1
  106. package/dist/Work/Agent/AgentClient.js +1 -1
  107. package/dist/Work/Agent/WorkbenchClient.d.ts +24 -0
  108. package/dist/Work/Agent/WorkbenchClient.js +39 -0
  109. package/dist/Work/Application.d.ts +8 -0
  110. package/dist/Work/Application.js +20 -0
  111. package/dist/Work/Calendar/CalendarClient.js +1 -1
  112. package/dist/Work/Chat/ChatClient.js +1 -1
  113. package/dist/Work/CorpGroup/CorpGroupClient.d.ts +34 -0
  114. package/dist/Work/CorpGroup/CorpGroupClient.js +42 -0
  115. package/dist/Work/Department/DepartmentClient.js +1 -1
  116. package/dist/Work/ExternalContact/Client.d.ts +56 -0
  117. package/dist/Work/ExternalContact/Client.js +88 -0
  118. package/dist/Work/ExternalContact/ContactWayClient.d.ts +37 -0
  119. package/dist/Work/ExternalContact/ContactWayClient.js +51 -2
  120. package/dist/Work/ExternalContact/MessageClient.js +4 -4
  121. package/dist/Work/ExternalContact/MessageTemplateClient.js +3 -3
  122. package/dist/Work/ExternalContact/MomentClient.d.ts +56 -3
  123. package/dist/Work/ExternalContact/MomentClient.js +62 -3
  124. package/dist/Work/ExternalContact/StatisticsClient.d.ts +24 -0
  125. package/dist/Work/ExternalContact/StatisticsClient.js +35 -0
  126. package/dist/Work/Jssdk/JssdkClient.js +3 -3
  127. package/dist/Work/Kf/KfAccountClient.d.ts +41 -0
  128. package/dist/Work/Kf/KfAccountClient.js +71 -0
  129. package/dist/Work/Kf/KfMessageClient.d.ts +44 -0
  130. package/dist/Work/Kf/KfMessageClient.js +73 -0
  131. package/dist/Work/Kf/KfServicerClient.d.ts +26 -0
  132. package/dist/Work/Kf/KfServicerClient.js +47 -0
  133. package/dist/Work/Media/MediaClient.js +1 -1
  134. package/dist/Work/Message/Messenger.js +2 -2
  135. package/dist/Work/Schedule/ScheduleClient.js +1 -1
  136. package/dist/Work/Server/Guard.d.ts +1 -1
  137. package/dist/Work/User/UserClient.js +3 -3
  138. package/dist/index.d.ts +8 -2
  139. package/dist/index.js +9 -7
  140. package/node-easywechat.file_cache.easywechat.kernel.access_token.8a9684b45da7de42a06a70ba01a7005a.cache +1 -1
  141. package/node-easywechat.file_cache.easywechat.kernel.access_token.c3d06edaf326aad75d32f31348df787a.cache +1 -1
  142. package/package.json +11 -11
@@ -24,12 +24,12 @@ class JssdkClient extends JssdkClient_1.default {
24
24
  bridgeConfig(prepayId, json = true) {
25
25
  let params = {
26
26
  appId: this.app.config.sub_appid ? this.app.config.sub_appid : this.app.config.app_id,
27
- timeStamp: Utils_1.getTimestamp() + '',
28
- nonceStr: Utils_1.randomString(16),
27
+ timeStamp: (0, Utils_1.getTimestamp)() + '',
28
+ nonceStr: (0, Utils_1.randomString)(16),
29
29
  package: `prepay_id=${prepayId}`,
30
30
  signType: 'MD5',
31
31
  };
32
- params['paySign'] = Utils_1.makeSignature(params, this.app.config.key, 'md5');
32
+ params['paySign'] = (0, Utils_1.makeSignature)(params, this.app.config.key, 'md5');
33
33
  return json ? JSON.stringify(params) : params;
34
34
  }
35
35
  /**
@@ -51,11 +51,11 @@ class JssdkClient extends JssdkClient_1.default {
51
51
  appid: this.app.config.app_id,
52
52
  partnerid: this.app.config.mch_id,
53
53
  prepayid: prepayId,
54
- noncestr: Utils_1.randomString(16),
55
- timestamp: Utils_1.getTimestamp() + '',
54
+ noncestr: (0, Utils_1.randomString)(16),
55
+ timestamp: (0, Utils_1.getTimestamp)() + '',
56
56
  package: 'Sign=WXPay',
57
57
  };
58
- params['sign'] = Utils_1.makeSignature(params, this.app.config.key, 'md5');
58
+ params['sign'] = (0, Utils_1.makeSignature)(params, this.app.config.key, 'md5');
59
59
  return params;
60
60
  }
61
61
  /**
@@ -71,8 +71,8 @@ class JssdkClient extends JssdkClient_1.default {
71
71
  let params = {
72
72
  appId: this.app.config.app_id,
73
73
  scope: 'jsapi_address',
74
- timeStamp: Utils_1.getTimestamp() + '',
75
- nonceStr: Utils_1.randomString(16),
74
+ timeStamp: (0, Utils_1.getTimestamp)() + '',
75
+ nonceStr: (0, Utils_1.randomString)(16),
76
76
  signType: 'SHA1',
77
77
  };
78
78
  let signParams = {
@@ -82,7 +82,7 @@ class JssdkClient extends JssdkClient_1.default {
82
82
  noncestr: params['nonceStr'],
83
83
  accesstoken: '' + accessToken,
84
84
  };
85
- params['addrSign'] = Utils_1.makeSignature(signParams, '', 'sha1');
85
+ params['addrSign'] = (0, Utils_1.makeSignature)(signParams, '', 'sha1');
86
86
  return json ? JSON.stringify(params) : params;
87
87
  });
88
88
  }
@@ -94,8 +94,8 @@ class JssdkClient extends JssdkClient_1.default {
94
94
  contractConfig(params, json = false) {
95
95
  return __awaiter(this, void 0, void 0, function* () {
96
96
  params['appid'] = this.app.config.app_id;
97
- params['timestamp'] = Utils_1.getTimestamp() + '';
98
- params['sign'] = Utils_1.makeSignature(params, this.app.config.key, 'md5');
97
+ params['timestamp'] = (0, Utils_1.getTimestamp)() + '';
98
+ params['sign'] = (0, Utils_1.makeSignature)(params, this.app.config.key, 'md5');
99
99
  return json ? JSON.stringify(params) : params;
100
100
  });
101
101
  }
@@ -108,11 +108,11 @@ class JssdkClient extends JssdkClient_1.default {
108
108
  return __awaiter(this, void 0, void 0, function* () {
109
109
  let params = {
110
110
  appId: this.app.config.app_id,
111
- timeStamp: Utils_1.getTimestamp() + '',
112
- nonceStr: Utils_1.randomString(16),
111
+ timeStamp: (0, Utils_1.getTimestamp)() + '',
112
+ nonceStr: (0, Utils_1.randomString)(16),
113
113
  package: pkg,
114
114
  };
115
- params['paySign'] = Utils_1.makeSignature(params, '', 'md5');
115
+ params['paySign'] = (0, Utils_1.makeSignature)(params, '', 'md5');
116
116
  params['signType'] = 'MD5';
117
117
  delete params.appId;
118
118
  return json ? JSON.stringify(params) : params;
@@ -28,7 +28,7 @@ class MerchantClient extends BaseClient_1.default {
28
28
  });
29
29
  }
30
30
  manage(data, query) {
31
- let params = Utils_1.merge(Utils_1.merge({}, data), {
31
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, data), {
32
32
  appid: this.app.config.app_id,
33
33
  nonce_str: '',
34
34
  sub_mech_id: '',
@@ -50,11 +50,11 @@ class Handler {
50
50
  return_code: this.fail === null ? this.SUCCESS : this.FAIL,
51
51
  return_msg: this.fail
52
52
  };
53
- let attributes = Utils_1.merge(base, this.attributes);
53
+ let attributes = (0, Utils_1.merge)(base, this.attributes);
54
54
  if (this.sign) {
55
- attributes['sign'] = Utils_1.makeSignature(attributes, yield this.app.getKey());
55
+ attributes['sign'] = (0, Utils_1.makeSignature)(attributes, yield this.app.getKey());
56
56
  }
57
- return new Response_1.default(Buffer.from(Utils_1.buildXml(attributes)));
57
+ return new Response_1.default(Buffer.from((0, Utils_1.buildXml)(attributes)));
58
58
  });
59
59
  }
60
60
  getMessage() {
@@ -76,13 +76,13 @@ class Handler {
76
76
  if (!message[key]) {
77
77
  return null;
78
78
  }
79
- return AES_1.AES.decrypt(Buffer.from(message[key], 'base64'), Utils_1.createHash(this.app.config.key, 'md5'), '', true, 'aes-256-ecb').toString();
79
+ return AES_1.AES.decrypt(Buffer.from(message[key], 'base64'), (0, Utils_1.createHash)(this.app.config.key, 'md5'), '', true, 'aes-256-ecb').toString();
80
80
  });
81
81
  }
82
82
  validate(message) {
83
83
  return __awaiter(this, void 0, void 0, function* () {
84
84
  let sign = message['sign'];
85
- if (Utils_1.makeSignature(message, yield this.app.getKey()) !== sign) {
85
+ if ((0, Utils_1.makeSignature)(message, yield this.app.getKey()) !== sign) {
86
86
  throw new Error('Invalid Sign');
87
87
  }
88
88
  });
@@ -32,7 +32,7 @@ class RefundedHandler extends Handler_1.default {
32
32
  }
33
33
  reqInfo() {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
- return yield Utils_1.parseXml(yield this.decryptMessage('req_info'));
35
+ return yield (0, Utils_1.parseXml)(yield this.decryptMessage('req_info'));
36
36
  });
37
37
  }
38
38
  }
@@ -41,10 +41,10 @@ class ScannedHandler extends Handler_1.default {
41
41
  result_code: (this.alert === null && this.fail === null) ? this.SUCCESS : this.FAIL,
42
42
  err_code_des: this.alert,
43
43
  };
44
- if (this.alert === null && Utils_1.isString(result)) {
44
+ if (this.alert === null && (0, Utils_1.isString)(result)) {
45
45
  attributes['appid'] = this.app.config.app_id;
46
46
  attributes['mch_id'] = this.app.config.mch_id;
47
- attributes['nonce_str'] = Utils_1.randomString(16);
47
+ attributes['nonce_str'] = (0, Utils_1.randomString)(16);
48
48
  attributes['prepay_id'] = result;
49
49
  }
50
50
  return yield this.respondWith(attributes, true).toResponse();
@@ -30,7 +30,7 @@ class OrderClient extends BaseClient_1.default {
30
30
  if (isContract) {
31
31
  params['contract_appid'] = this.app.config.app_id;
32
32
  params['contract_mchid'] = this.app.config.mch_id;
33
- params['request_serial'] = params['request_serial'] || Utils_1.getTimestamp();
33
+ params['request_serial'] = params['request_serial'] || (0, Utils_1.getTimestamp)();
34
34
  params['contract_notify_url'] = params['contract_notify_url'] || this.app.config.contract_notify_url;
35
35
  return this.request(this.wrap('pay/contractorder'), params);
36
36
  }
@@ -20,10 +20,10 @@ class RedpackClient extends BaseClient_1.default {
20
20
  * @param mchBillno 商户订单号
21
21
  */
22
22
  info(mchBillno) {
23
- let data = Utils_1.isObject(mchBillno) ? mchBillno : {
23
+ let data = (0, Utils_1.isObject)(mchBillno) ? mchBillno : {
24
24
  mch_billno: mchBillno
25
25
  };
26
- let params = Utils_1.merge(Utils_1.merge({}, data), {
26
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, data), {
27
27
  appid: this.app.config.app_id,
28
28
  bill_type: 'MCHT',
29
29
  });
@@ -35,7 +35,7 @@ class RedpackClient extends BaseClient_1.default {
35
35
  */
36
36
  sendMiniprogramNormal(data) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- let params = Utils_1.merge(Utils_1.merge({}, data), {
38
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, data), {
39
39
  notify_way: 'MINI_PROGRAM_JSAPI',
40
40
  wxappid: this.app.config.app_id,
41
41
  total_num: 1,
@@ -50,7 +50,7 @@ class RedpackClient extends BaseClient_1.default {
50
50
  */
51
51
  sendNormal(data) {
52
52
  return __awaiter(this, void 0, void 0, function* () {
53
- let params = Utils_1.merge(Utils_1.merge({}, data), {
53
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, data), {
54
54
  wxappid: this.app.config.app_id,
55
55
  total_num: 1,
56
56
  client_ip: data['client_ip'] || (yield this.getServerIp()),
@@ -63,7 +63,7 @@ class RedpackClient extends BaseClient_1.default {
63
63
  * @param params 红包参数
64
64
  */
65
65
  sendGroup(params) {
66
- params = Utils_1.merge(params, {
66
+ params = (0, Utils_1.merge)(params, {
67
67
  wxappid: this.app.config.app_id,
68
68
  amt_type: 'ALL_RAND',
69
69
  });
@@ -15,7 +15,7 @@ class RefundClient extends BaseClient_1.default {
15
15
  * @param optional 其它参数
16
16
  */
17
17
  byOutTradeNumber(number, refundNumber, totalFee, refundFee, optional = {}) {
18
- return this.refund(refundNumber, totalFee, refundFee, Utils_1.merge(Utils_1.merge({}, optional), {
18
+ return this.refund(refundNumber, totalFee, refundFee, (0, Utils_1.merge)((0, Utils_1.merge)({}, optional), {
19
19
  out_trade_no: number,
20
20
  }));
21
21
  }
@@ -28,12 +28,12 @@ class RefundClient extends BaseClient_1.default {
28
28
  * @param optional 其它参数
29
29
  */
30
30
  byTransactionId(transactionId, refundNumber, totalFee, refundFee, optional = {}) {
31
- return this.refund(refundNumber, totalFee, refundFee, Utils_1.merge(Utils_1.merge({}, optional), {
31
+ return this.refund(refundNumber, totalFee, refundFee, (0, Utils_1.merge)((0, Utils_1.merge)({}, optional), {
32
32
  transaction_id: transactionId,
33
33
  }));
34
34
  }
35
35
  refund(refundNumber, totalFee, refundFee, optional = {}) {
36
- let params = Utils_1.merge({
36
+ let params = (0, Utils_1.merge)({
37
37
  appid: this.app.config.app_id,
38
38
  out_refund_no: refundNumber,
39
39
  total_fee: totalFee,
@@ -34,7 +34,7 @@ class SandboxClient extends BaseClient_1.default {
34
34
  });
35
35
  }
36
36
  getCacheKey() {
37
- return 'easywechat.payment.sandbox.' + Utils_1.createHash(this.app.config.app_id + this.app.config.mch_id, 'md5');
37
+ return 'easywechat.payment.sandbox.' + (0, Utils_1.createHash)(this.app.config.app_id + this.app.config.mch_id, 'md5');
38
38
  }
39
39
  }
40
40
  exports.default = SandboxClient;
@@ -54,7 +54,7 @@ class TransferClient extends BaseClient_1.default {
54
54
  if (!params['spbill_create_ip']) {
55
55
  params['spbill_create_ip'] = yield this.getServerIp();
56
56
  }
57
- return this.safeRequest('mmpaymkttransfers/promotion/transfers', Utils_1.merge(base, params));
57
+ return this.safeRequest('mmpaymkttransfers/promotion/transfers', (0, Utils_1.merge)(base, params));
58
58
  });
59
59
  }
60
60
  /**
@@ -13,7 +13,7 @@ class AgentClient extends BaseClient_1.default {
13
13
  return this.httpGet('cgi-bin/agent/get', params);
14
14
  }
15
15
  set(agentId, attributes) {
16
- let params = Utils_1.merge({
16
+ let params = (0, Utils_1.merge)({
17
17
  agentid: agentId,
18
18
  }, attributes);
19
19
  return this.httpPostJson('cgi-bin/agent/set', params);
@@ -0,0 +1,24 @@
1
+ import BaseClient from '../../Core/BaseClient';
2
+ export default class WorkbenchClient extends BaseClient {
3
+ /**
4
+ * 设置应用在工作台展示的模版
5
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#设置应用在工作台展示的模版
6
+ * @param params
7
+ * @returns
8
+ */
9
+ setWorkbenchTemplate(params: object): Promise<any>;
10
+ /**
11
+ * 获取应用在工作台展示的模版
12
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#获取应用在工作台展示的模版
13
+ * @param agentId
14
+ * @returns
15
+ */
16
+ getWorkbenchTemplate(agentId: number): Promise<any>;
17
+ /**
18
+ * 设置应用在用户工作台展示的数据
19
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#设置应用在用户工作台展示的数据
20
+ * @param params
21
+ * @returns
22
+ */
23
+ setWorkbenchData(params: object): Promise<any>;
24
+ }
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
7
+ class WorkbenchClient extends BaseClient_1.default {
8
+ /**
9
+ * 设置应用在工作台展示的模版
10
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#设置应用在工作台展示的模版
11
+ * @param params
12
+ * @returns
13
+ */
14
+ setWorkbenchTemplate(params) {
15
+ return this.httpPostJson('cgi-bin/agent/set_workbench_template', params);
16
+ }
17
+ /**
18
+ * 获取应用在工作台展示的模版
19
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#获取应用在工作台展示的模版
20
+ * @param agentId
21
+ * @returns
22
+ */
23
+ getWorkbenchTemplate(agentId) {
24
+ let params = {
25
+ agentid: agentId,
26
+ };
27
+ return this.httpPostJson('cgi-bin/agent/get_workbench_template', params);
28
+ }
29
+ /**
30
+ * 设置应用在用户工作台展示的数据
31
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#设置应用在用户工作台展示的数据
32
+ * @param params
33
+ * @returns
34
+ */
35
+ setWorkbenchData(params) {
36
+ return this.httpPostJson('cgi-bin/agent/set_workbench_data', params);
37
+ }
38
+ }
39
+ exports.default = WorkbenchClient;
@@ -4,6 +4,7 @@ import WorkBase from './Base/WorkBase';
4
4
  import OAClient from './OA/OAClient';
5
5
  import AccessToken from './Auth/AccessToken';
6
6
  import AgentClient from './Agent/AgentClient';
7
+ import WorkbenchClient from './Agent/WorkbenchClient';
7
8
  import CalendarClient from './Calendar/CalendarClient';
8
9
  import ChatClient from './Chat/ChatClient';
9
10
  import DepartmentClient from './Department/DepartmentClient';
@@ -11,6 +12,9 @@ import GroupRobotClient from './GroupRobot/GroupRobotClient';
11
12
  import GroupRobotMessenger from './GroupRobot/Messenger';
12
13
  import InvoiceClient from './Invoice/InvoiceClient';
13
14
  import JssdkClient from './Jssdk/JssdkClient';
15
+ import KfAccountClient from './Kf/KfAccountClient';
16
+ import KfMessageClient from './Kf/KfMessageClient';
17
+ import KfServicerClient from './Kf/KfServicerClient';
14
18
  import LiveClient from './Live/LiveClient';
15
19
  import MediaClient from './Media/MediaClient';
16
20
  import MenuClient from './Menu/MenuClient';
@@ -36,6 +40,7 @@ export default class Work extends BaseApplication {
36
40
  oa: OAClient;
37
41
  access_token: AccessToken;
38
42
  agent: AgentClient;
43
+ agent_workbench: WorkbenchClient;
39
44
  base: WorkBase;
40
45
  calendar: CalendarClient;
41
46
  chat: ChatClient;
@@ -52,6 +57,9 @@ export default class Work extends BaseApplication {
52
57
  group_robot_messenger: GroupRobotMessenger;
53
58
  invoice: InvoiceClient;
54
59
  jssdk: JssdkClient;
60
+ kf_account: KfAccountClient;
61
+ kf_message: KfMessageClient;
62
+ kf_servicer: KfServicerClient;
55
63
  live: LiveClient;
56
64
  media: MediaClient;
57
65
  menu: MenuClient;
@@ -17,6 +17,7 @@ const WorkBase_1 = __importDefault(require("./Base/WorkBase"));
17
17
  const OAClient_1 = __importDefault(require("./OA/OAClient"));
18
18
  const AccessToken_1 = __importDefault(require("./Auth/AccessToken"));
19
19
  const AgentClient_1 = __importDefault(require("./Agent/AgentClient"));
20
+ const WorkbenchClient_1 = __importDefault(require("./Agent/WorkbenchClient"));
20
21
  const CalendarClient_1 = __importDefault(require("./Calendar/CalendarClient"));
21
22
  const ChatClient_1 = __importDefault(require("./Chat/ChatClient"));
22
23
  const DepartmentClient_1 = __importDefault(require("./Department/DepartmentClient"));
@@ -24,6 +25,9 @@ const GroupRobotClient_1 = __importDefault(require("./GroupRobot/GroupRobotClien
24
25
  const Messenger_1 = __importDefault(require("./GroupRobot/Messenger"));
25
26
  const InvoiceClient_1 = __importDefault(require("./Invoice/InvoiceClient"));
26
27
  const JssdkClient_1 = __importDefault(require("./Jssdk/JssdkClient"));
28
+ const KfAccountClient_1 = __importDefault(require("./Kf/KfAccountClient"));
29
+ const KfMessageClient_1 = __importDefault(require("./Kf/KfMessageClient"));
30
+ const KfServicerClient_1 = __importDefault(require("./Kf/KfServicerClient"));
27
31
  const LiveClient_1 = __importDefault(require("./Live/LiveClient"));
28
32
  const MediaClient_1 = __importDefault(require("./Media/MediaClient"));
29
33
  const MenuClient_1 = __importDefault(require("./Menu/MenuClient"));
@@ -56,6 +60,7 @@ class Work extends BaseApplication_1.default {
56
60
  this.oa = null;
57
61
  this.access_token = null;
58
62
  this.agent = null;
63
+ this.agent_workbench = null;
59
64
  this.base = null;
60
65
  this.calendar = null;
61
66
  this.chat = null;
@@ -72,6 +77,9 @@ class Work extends BaseApplication_1.default {
72
77
  this.group_robot_messenger = null;
73
78
  this.invoice = null;
74
79
  this.jssdk = null;
80
+ this.kf_account = null;
81
+ this.kf_message = null;
82
+ this.kf_servicer = null;
75
83
  this.live = null;
76
84
  this.media = null;
77
85
  this.menu = null;
@@ -101,6 +109,9 @@ class Work extends BaseApplication_1.default {
101
109
  this.offsetSet('agent', function (app) {
102
110
  return new AgentClient_1.default(app);
103
111
  });
112
+ this.offsetSet('agent_workbench', function (app) {
113
+ return new WorkbenchClient_1.default(app);
114
+ });
104
115
  this.offsetSet('calendar', function (app) {
105
116
  return new CalendarClient_1.default(app);
106
117
  });
@@ -146,6 +157,15 @@ class Work extends BaseApplication_1.default {
146
157
  this.offsetSet('jssdk', function (app) {
147
158
  return new JssdkClient_1.default(app);
148
159
  });
160
+ this.offsetSet('kf_account', function (app) {
161
+ return new KfAccountClient_1.default(app);
162
+ });
163
+ this.offsetSet('kf_message', function (app) {
164
+ return new KfMessageClient_1.default(app);
165
+ });
166
+ this.offsetSet('kf_servicer', function (app) {
167
+ return new KfServicerClient_1.default(app);
168
+ });
149
169
  this.offsetSet('live', function (app) {
150
170
  return new LiveClient_1.default(app);
151
171
  });
@@ -13,7 +13,7 @@ class CalendarClient extends BaseClient_1.default {
13
13
  return this.httpPostJson('cgi-bin/oa/calendar/add', params);
14
14
  }
15
15
  update(id, calendar) {
16
- let params = Utils_1.merge({
16
+ let params = (0, Utils_1.merge)({
17
17
  cal_id: id,
18
18
  }, calendar);
19
19
  return this.httpPostJson('cgi-bin/oa/calendar/update', params);
@@ -15,7 +15,7 @@ class ChatClient extends BaseClient_1.default {
15
15
  return this.httpPostJson('cgi-bin/appchat/create', data);
16
16
  }
17
17
  update(chatId, data) {
18
- let params = Utils_1.merge({
18
+ let params = (0, Utils_1.merge)({
19
19
  chatid: chatId,
20
20
  }, data);
21
21
  return this.httpPostJson('cgi-bin/appchat/update', params);
@@ -1,6 +1,40 @@
1
1
  import BaseClient from '../../Core/BaseClient';
2
2
  export default class CorpGroupClient extends BaseClient {
3
+ /**
4
+ * 获取应用共享信息
5
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93403
6
+ * @param agentId
7
+ * @returns
8
+ */
3
9
  getAppShareInfo(agentId: number): Promise<any>;
10
+ /**
11
+ * 获取下级企业的access_token
12
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93359
13
+ * @param corpId
14
+ * @param agentId
15
+ * @returns
16
+ */
4
17
  getToken(corpId: string, agentId: number): Promise<any>;
18
+ /**
19
+ * 获取下级企业的小程序session
20
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93355
21
+ * @param userId
22
+ * @param sessionKey
23
+ * @returns
24
+ */
5
25
  getMiniProgramTransferSession(userId: string, sessionKey: number): Promise<any>;
26
+ /**
27
+ * 将明文corpid转换为第三方应用获取的corpid(仅限第三方服务商,转换已获授权企业的corpid)
28
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#1.4%20corpid%E8%BD%AC%E6%8D%A2
29
+ * @param corpId
30
+ * @returns
31
+ */
32
+ getOpenCorpid(corpId: string): Promise<any>;
33
+ /**
34
+ * 将自建应用获取的userid转换为第三方应用获取的userid(仅代开发自建应用或第三方应用可调用)
35
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#2.4%20userid%E7%9A%84%E8%BD%AC%E6%8D%A2
36
+ * @param useridList
37
+ * @returns
38
+ */
39
+ batchUseridToOpenUserid(useridList: string[]): Promise<any>;
6
40
  }
@@ -5,22 +5,64 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
7
7
  class CorpGroupClient extends BaseClient_1.default {
8
+ /**
9
+ * 获取应用共享信息
10
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93403
11
+ * @param agentId
12
+ * @returns
13
+ */
8
14
  getAppShareInfo(agentId) {
9
15
  return this.httpPostJson('cgi-bin/corpgroup/corp/list_app_share_info', {
10
16
  agentid: agentId,
11
17
  });
12
18
  }
19
+ /**
20
+ * 获取下级企业的access_token
21
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93359
22
+ * @param corpId
23
+ * @param agentId
24
+ * @returns
25
+ */
13
26
  getToken(corpId, agentId) {
14
27
  return this.httpPostJson('cgi-bin/corpgroup/corp/gettoken', {
15
28
  corpid: corpId,
16
29
  agentid: agentId,
17
30
  });
18
31
  }
32
+ /**
33
+ * 获取下级企业的小程序session
34
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93355
35
+ * @param userId
36
+ * @param sessionKey
37
+ * @returns
38
+ */
19
39
  getMiniProgramTransferSession(userId, sessionKey) {
20
40
  return this.httpPostJson('cgi-bin/miniprogram/transfer_session', {
21
41
  userid: userId,
22
42
  session_key: sessionKey,
23
43
  });
24
44
  }
45
+ /**
46
+ * 将明文corpid转换为第三方应用获取的corpid(仅限第三方服务商,转换已获授权企业的corpid)
47
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#1.4%20corpid%E8%BD%AC%E6%8D%A2
48
+ * @param corpId
49
+ * @returns
50
+ */
51
+ getOpenCorpid(corpId) {
52
+ return this.httpPostJson('cgi-bin/corp/to_open_corpid', {
53
+ corpid: corpId,
54
+ });
55
+ }
56
+ /**
57
+ * 将自建应用获取的userid转换为第三方应用获取的userid(仅代开发自建应用或第三方应用可调用)
58
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#2.4%20userid%E7%9A%84%E8%BD%AC%E6%8D%A2
59
+ * @param useridList
60
+ * @returns
61
+ */
62
+ batchUseridToOpenUserid(useridList) {
63
+ return this.httpPostJson('cgi-bin/batch/userid_to_openuserid', {
64
+ userid_list: useridList,
65
+ });
66
+ }
25
67
  }
26
68
  exports.default = CorpGroupClient;
@@ -10,7 +10,7 @@ class DepartmentClient extends BaseClient_1.default {
10
10
  return this.httpPostJson('cgi-bin/department/create', data);
11
11
  }
12
12
  update(id, data) {
13
- let params = Utils_1.merge({
13
+ let params = (0, Utils_1.merge)({
14
14
  id: id,
15
15
  }, data);
16
16
  return this.httpPostJson('cgi-bin/department/update', params);
@@ -1,4 +1,6 @@
1
+ /// <reference types="node" />
1
2
  import BaseClient from '../../Core/BaseClient';
3
+ import Stream from 'stream';
2
4
  export default class ExternalContactClient extends BaseClient {
3
5
  /**
4
6
  * 获取配置了客户联系功能的成员列表
@@ -163,4 +165,58 @@ export default class ExternalContactClient extends BaseClient {
163
165
  * @returns
164
166
  */
165
167
  markTags(data: object): Promise<any>;
168
+ /**
169
+ * 外部联系人unionid转换
170
+ * @see https://work.weixin.qq.com/api/doc/90001/90143/93274
171
+ * @param unionid 微信客户的unionid
172
+ * @param openid 微信客户的openid
173
+ * @returns
174
+ */
175
+ unionidToExternalUserid(unionid?: string, openid?: string): Promise<any>;
176
+ /**
177
+ * 代开发应用external_userid转换
178
+ * @see https://work.weixin.qq.com/api/doc/90001/90143/95195
179
+ * @param unionid 微信客户的unionid
180
+ * @returns
181
+ */
182
+ toServiceExternalUserid(externalUserid: string): Promise<any>;
183
+ /**
184
+ * 转换external_userid
185
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#%E8%BD%AC%E6%8D%A2external_userid
186
+ * @param externalUserIds
187
+ * @returns
188
+ */
189
+ getNewExternalUserid(externalUserIds: string[]): Promise<any>;
190
+ /**
191
+ * 设置迁移完成
192
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#%E8%AE%BE%E7%BD%AE%E8%BF%81%E7%A7%BB%E5%AE%8C%E6%88%90
193
+ * @param corpid
194
+ * @returns
195
+ */
196
+ finishExternalUseridMigration(corpid: string): Promise<any>;
197
+ /**
198
+ * unionid查询external_userid
199
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#4.2%20unionid%E6%9F%A5%E8%AF%A2external_userid
200
+ * @param unionid
201
+ * @param openid
202
+ * @param corpid
203
+ * @returns
204
+ */
205
+ unionidToexternalUserid3rd(unionid: string, openid: string, corpid?: string): Promise<any>;
206
+ /**
207
+ * 客户群opengid转换
208
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/94822
209
+ * @param opengid
210
+ * @returns
211
+ */
212
+ opengidToChatid(opengid: string): Promise<any>;
213
+ /**
214
+ * 上传附件资源
215
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/95098
216
+ * @param path
217
+ * @param mediaType
218
+ * @param attachmentType
219
+ * @returns
220
+ */
221
+ uploadAttachment(path: string | Stream.Readable, mediaType: string, attachmentType: string): Promise<any>;
166
222
  }