node-easywechat 2.8.1 → 2.9.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.
Files changed (67) hide show
  1. package/README.md +51 -4
  2. package/dist/Core/Http/Request.js +2 -2
  3. package/dist/Core/ServerGuard.d.ts +2 -2
  4. package/dist/Core/Types.d.ts +34 -4
  5. package/dist/MiniProgram/Application.d.ts +14 -0
  6. package/dist/MiniProgram/Application.js +35 -0
  7. package/dist/MiniProgram/Shop/AccoutClient.d.ts +25 -0
  8. package/dist/MiniProgram/Shop/AccoutClient.js +42 -0
  9. package/dist/MiniProgram/Shop/AftersaleClient.d.ts +22 -0
  10. package/dist/MiniProgram/Shop/AftersaleClient.js +35 -0
  11. package/dist/MiniProgram/Shop/BasicClient.d.ts +39 -0
  12. package/dist/MiniProgram/Shop/BasicClient.js +69 -0
  13. package/dist/MiniProgram/Shop/DeliveryClient.d.ts +20 -0
  14. package/dist/MiniProgram/Shop/DeliveryClient.js +32 -0
  15. package/dist/MiniProgram/Shop/OrderClient.d.ts +32 -0
  16. package/dist/MiniProgram/Shop/OrderClient.js +51 -0
  17. package/dist/MiniProgram/Shop/RegisterClient.d.ts +25 -0
  18. package/dist/MiniProgram/Shop/RegisterClient.js +43 -0
  19. package/dist/MiniProgram/Shop/SpuClient.d.ts +67 -0
  20. package/dist/MiniProgram/Shop/SpuClient.js +92 -0
  21. package/dist/OpenPlatform/Application.js +2 -2
  22. package/dist/OpenWork/Application.d.ts +37 -0
  23. package/dist/OpenWork/Application.js +128 -0
  24. package/dist/OpenWork/Auth/ProviderAccessToken.d.ts +8 -0
  25. package/dist/OpenWork/Auth/ProviderAccessToken.js +33 -0
  26. package/dist/OpenWork/Auth/SuiteAccessToken.d.ts +8 -0
  27. package/dist/OpenWork/Auth/SuiteAccessToken.js +34 -0
  28. package/dist/OpenWork/Auth/SuiteTicket.d.ts +8 -0
  29. package/dist/OpenWork/Auth/SuiteTicket.js +40 -0
  30. package/dist/OpenWork/Corp/CorpClient.d.ts +72 -0
  31. package/dist/OpenWork/Corp/CorpClient.js +150 -0
  32. package/dist/OpenWork/MiniProgram/MiniProgramClient.d.ts +5 -0
  33. package/dist/OpenWork/MiniProgram/MiniProgramClient.js +18 -0
  34. package/dist/OpenWork/Provider/ProviderClient.d.ts +81 -0
  35. package/dist/OpenWork/Provider/ProviderClient.js +172 -0
  36. package/dist/OpenWork/Server/OpenWorkGuard.d.ts +13 -0
  37. package/dist/OpenWork/Server/OpenWorkGuard.js +51 -0
  38. package/dist/OpenWork/Work/Application.d.ts +5 -0
  39. package/dist/OpenWork/Work/Application.js +22 -0
  40. package/dist/OpenWork/Work/Auth/AccessToken.d.ts +12 -0
  41. package/dist/OpenWork/Work/Auth/AccessToken.js +44 -0
  42. package/dist/Work/Agent/WorkbenchClient.d.ts +24 -0
  43. package/dist/Work/Agent/WorkbenchClient.js +39 -0
  44. package/dist/Work/Application.d.ts +8 -0
  45. package/dist/Work/Application.js +20 -0
  46. package/dist/Work/CorpGroup/CorpGroupClient.d.ts +34 -0
  47. package/dist/Work/CorpGroup/CorpGroupClient.js +42 -0
  48. package/dist/Work/ExternalContact/Client.d.ts +11 -0
  49. package/dist/Work/ExternalContact/Client.js +16 -0
  50. package/dist/Work/ExternalContact/ContactWayClient.d.ts +37 -0
  51. package/dist/Work/ExternalContact/ContactWayClient.js +49 -0
  52. package/dist/Work/ExternalContact/MomentClient.d.ts +56 -3
  53. package/dist/Work/ExternalContact/MomentClient.js +62 -3
  54. package/dist/Work/ExternalContact/StatisticsClient.d.ts +24 -0
  55. package/dist/Work/ExternalContact/StatisticsClient.js +35 -0
  56. package/dist/Work/Kf/KfAccountClient.d.ts +41 -0
  57. package/dist/Work/Kf/KfAccountClient.js +71 -0
  58. package/dist/Work/Kf/KfMessageClient.d.ts +44 -0
  59. package/dist/Work/Kf/KfMessageClient.js +73 -0
  60. package/dist/Work/Kf/KfServicerClient.d.ts +26 -0
  61. package/dist/Work/Kf/KfServicerClient.js +47 -0
  62. package/dist/Work/Server/Guard.d.ts +1 -1
  63. package/dist/index.d.ts +8 -2
  64. package/dist/index.js +8 -6
  65. package/package.json +5 -5
  66. package/node-easywechat.file_cache.easywechat.kernel.access_token.8a9684b45da7de42a06a70ba01a7005a.cache +0 -1
  67. package/node-easywechat.file_cache.easywechat.kernel.access_token.c3d06edaf326aad75d32f31348df787a.cache +0 -1
@@ -0,0 +1,71 @@
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 KfAccountClient extends BaseClient_1.default {
8
+ /**
9
+ * 添加客服帐号
10
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94662
11
+ * @param name
12
+ * @param mediaId
13
+ * @returns
14
+ */
15
+ add(name, mediaId) {
16
+ let params = {
17
+ name,
18
+ media_id: mediaId,
19
+ };
20
+ return this.httpPostJson('cgi-bin/kf/account/add', params);
21
+ }
22
+ /**
23
+ * 修改客服帐号
24
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94664
25
+ * @param openKfId
26
+ * @param name
27
+ * @param mediaId
28
+ * @returns
29
+ */
30
+ update(openKfId, name, mediaId) {
31
+ let params = {
32
+ open_kfid: openKfId,
33
+ name,
34
+ media_id: mediaId,
35
+ };
36
+ return this.httpPostJson('cgi-bin/kf/account/update', params);
37
+ }
38
+ /**
39
+ * 删除客服帐号
40
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94663
41
+ * @param openKfId
42
+ * @returns
43
+ */
44
+ del(openKfId) {
45
+ return this.httpPostJson('cgi-bin/kf/account/del', {
46
+ open_kfid: openKfId,
47
+ });
48
+ }
49
+ /**
50
+ * 获取客服帐号列表
51
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94661
52
+ * @returns
53
+ */
54
+ list() {
55
+ return this.httpGet('cgi-bin/kf/account/list');
56
+ }
57
+ /**
58
+ * 获取客服帐号链接
59
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94665
60
+ * @param openKfId
61
+ * @param scene
62
+ * @returns
63
+ */
64
+ getAccountLink(openKfId, scene) {
65
+ return this.httpPostJson('cgi-bin/kf/add_contact_way', {
66
+ open_kfid: openKfId,
67
+ scene,
68
+ });
69
+ }
70
+ }
71
+ exports.default = KfAccountClient;
@@ -0,0 +1,44 @@
1
+ import BaseClient from '../../Core/BaseClient';
2
+ export default class KfMessageClient extends BaseClient {
3
+ /**
4
+ * 获取会话状态
5
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94669
6
+ * @param openKfId
7
+ * @param externalUserId
8
+ * @returns
9
+ */
10
+ state(openKfId: string, externalUserId: string): Promise<any>;
11
+ /**
12
+ * 变更会话状态
13
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94669
14
+ * @param openKfId
15
+ * @param externalUserId
16
+ * @param serviceState
17
+ * @param serviceUserId
18
+ * @returns
19
+ */
20
+ del(openKfId: string, externalUserId: string, serviceState: number, serviceUserId: string): Promise<any>;
21
+ /**
22
+ * 读取消息
23
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94670
24
+ * @param cursor
25
+ * @param token
26
+ * @param limit
27
+ * @returns
28
+ */
29
+ sync(cursor: string, token: string, limit: number): Promise<any>;
30
+ /**
31
+ * 发送消息
32
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94677
33
+ * @param params
34
+ * @returns
35
+ */
36
+ send(params: object): Promise<any>;
37
+ /**
38
+ * 发送事件响应消息
39
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94677
40
+ * @param params
41
+ * @returns
42
+ */
43
+ event(params: object): Promise<any>;
44
+ }
@@ -0,0 +1,73 @@
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 KfMessageClient extends BaseClient_1.default {
8
+ /**
9
+ * 获取会话状态
10
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94669
11
+ * @param openKfId
12
+ * @param externalUserId
13
+ * @returns
14
+ */
15
+ state(openKfId, externalUserId) {
16
+ let params = {
17
+ open_kfid: openKfId,
18
+ external_userid: externalUserId,
19
+ };
20
+ return this.httpPostJson('cgi-bin/kf/service_state/get', params);
21
+ }
22
+ /**
23
+ * 变更会话状态
24
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94669
25
+ * @param openKfId
26
+ * @param externalUserId
27
+ * @param serviceState
28
+ * @param serviceUserId
29
+ * @returns
30
+ */
31
+ del(openKfId, externalUserId, serviceState, serviceUserId) {
32
+ return this.httpPostJson('cgi-bin/kf/service_state/trans', {
33
+ open_kfid: openKfId,
34
+ external_userid: externalUserId,
35
+ service_state: serviceState,
36
+ servicer_userid: serviceUserId,
37
+ });
38
+ }
39
+ /**
40
+ * 读取消息
41
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94670
42
+ * @param cursor
43
+ * @param token
44
+ * @param limit
45
+ * @returns
46
+ */
47
+ sync(cursor, token, limit) {
48
+ return this.httpPostJson('cgi-bin/kf/sync_msg', {
49
+ cursor,
50
+ token,
51
+ limit,
52
+ });
53
+ }
54
+ /**
55
+ * 发送消息
56
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94677
57
+ * @param params
58
+ * @returns
59
+ */
60
+ send(params) {
61
+ return this.httpPostJson('cgi-bin/kf/send_msg', params);
62
+ }
63
+ /**
64
+ * 发送事件响应消息
65
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94677
66
+ * @param params
67
+ * @returns
68
+ */
69
+ event(params) {
70
+ return this.httpPostJson('cgi-bin/kf/send_msg_on_event', params);
71
+ }
72
+ }
73
+ exports.default = KfMessageClient;
@@ -0,0 +1,26 @@
1
+ import BaseClient from '../../Core/BaseClient';
2
+ export default class KfServicerClient extends BaseClient {
3
+ /**
4
+ * 添加接待人员
5
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94646
6
+ * @param openKfId
7
+ * @param userIds
8
+ * @returns
9
+ */
10
+ add(openKfId: string, userIds: string[]): Promise<any>;
11
+ /**
12
+ * 删除接待人员
13
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94647
14
+ * @param openKfId
15
+ * @param userIds
16
+ * @returns
17
+ */
18
+ del(openKfId: string, userIds: string[]): Promise<any>;
19
+ /**
20
+ * 获取接待人员列表
21
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94645
22
+ * @param openKfId
23
+ * @returns
24
+ */
25
+ list(openKfId: string): Promise<any>;
26
+ }
@@ -0,0 +1,47 @@
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 KfServicerClient extends BaseClient_1.default {
8
+ /**
9
+ * 添加接待人员
10
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94646
11
+ * @param openKfId
12
+ * @param userIds
13
+ * @returns
14
+ */
15
+ add(openKfId, userIds) {
16
+ let params = {
17
+ open_kfid: openKfId,
18
+ media_id: userIds,
19
+ };
20
+ return this.httpPostJson('cgi-bin/kf/servicer/add', params);
21
+ }
22
+ /**
23
+ * 删除接待人员
24
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94647
25
+ * @param openKfId
26
+ * @param userIds
27
+ * @returns
28
+ */
29
+ del(openKfId, userIds) {
30
+ return this.httpPostJson('cgi-bin/kf/servicer/del', {
31
+ open_kfid: openKfId,
32
+ userid_list: userIds,
33
+ });
34
+ }
35
+ /**
36
+ * 获取接待人员列表
37
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94645
38
+ * @param openKfId
39
+ * @returns
40
+ */
41
+ list(openKfId) {
42
+ return this.httpGet('cgi-bin/kf/servicer/list', {
43
+ open_kfid: openKfId,
44
+ });
45
+ }
46
+ }
47
+ exports.default = KfServicerClient;
@@ -1,6 +1,6 @@
1
1
  import ServerGuard from '../../Core/ServerGuard';
2
2
  export default class Guard extends ServerGuard {
3
- protected validate(): Promise<this>;
3
+ validate(): Promise<this>;
4
4
  protected isSafeMode(): Promise<boolean>;
5
5
  protected shouldReturnRawResponse(): Promise<boolean>;
6
6
  }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import OfficialAccount from './OfficialAccount/Application';
2
2
  import BaseService from './BaseService/Application';
3
3
  import MiniProgram from './MiniProgram/Application';
4
4
  import OpenPlatform from './OpenPlatform/Application';
5
+ import OpenWork from './OpenWork/Application';
5
6
  import Payment from './Payment/Application';
6
7
  import Work from './Work/Application';
7
8
  import MicroMerchant from './MicroMerchant/Application';
@@ -15,13 +16,14 @@ import * as Messages from './Core/Messages';
15
16
  import { EasyWechatConfig } from './Core/Types';
16
17
  /**
17
18
  * 通用获取实例方法
18
- * @param service 服务名称,可选值:'BaseService' | 'OfficialAccount' | 'MiniProgram' | 'OpenPlatform' | 'Payment'
19
+ * @param service 服务名称,可选值:'BaseService' | 'OfficialAccount' | 'MiniProgram' | 'OpenPlatform' | 'OpenWork' | 'Payment' | 'Work'
19
20
  * @param config 对应的配置参数
20
21
  */
21
22
  declare function getInstance(service: 'OfficialAccount', config?: EasyWechatConfig): OfficialAccount;
22
23
  declare function getInstance(service: 'BaseService', config?: EasyWechatConfig): BaseService;
23
24
  declare function getInstance(service: 'MiniProgram', config?: EasyWechatConfig): MiniProgram;
24
25
  declare function getInstance(service: 'OpenPlatform', config?: EasyWechatConfig): OpenPlatform;
26
+ declare function getInstance(service: 'OpenWork', config?: EasyWechatConfig): OpenWork;
25
27
  declare function getInstance(service: 'Payment', config?: EasyWechatConfig): Payment;
26
28
  declare function getInstance(service: 'Work', config?: EasyWechatConfig): Work;
27
29
  declare function getInstance(service: 'MicroMerchant', config?: EasyWechatConfig): MicroMerchant;
@@ -46,6 +48,10 @@ declare class EasyWechat {
46
48
  * 开放平台类
47
49
  */
48
50
  OpenPlatform: typeof OpenPlatform;
51
+ /**
52
+ * 企业微信开放平台类
53
+ */
54
+ OpenWork: typeof OpenWork;
49
55
  /**
50
56
  * 支付类
51
57
  */
@@ -60,7 +66,7 @@ declare class EasyWechat {
60
66
  MicroMerchant: typeof MicroMerchant;
61
67
  /**
62
68
  * 通用获取实例方法
63
- * @param service 服务名称,可选值:'BaseService' | 'OfficialAccount' | 'MiniProgram' | 'OpenPlatform' | 'Payment'
69
+ * @param service 服务名称,可选值:'BaseService' | 'OfficialAccount' | 'MiniProgram' | 'OpenPlatform' | 'OpenWork' | 'Payment' | 'Work'
64
70
  * @param config 对应的配置参数
65
71
  */
66
72
  getInstance: typeof getInstance;
package/dist/index.js CHANGED
@@ -26,9 +26,10 @@ const Application_1 = __importDefault(require("./OfficialAccount/Application"));
26
26
  const Application_2 = __importDefault(require("./BaseService/Application"));
27
27
  const Application_3 = __importDefault(require("./MiniProgram/Application"));
28
28
  const Application_4 = __importDefault(require("./OpenPlatform/Application"));
29
- const Application_5 = __importDefault(require("./Payment/Application"));
30
- const Application_6 = __importDefault(require("./Work/Application"));
31
- const Application_7 = __importDefault(require("./MicroMerchant/Application"));
29
+ const Application_5 = __importDefault(require("./OpenWork/Application"));
30
+ const Application_6 = __importDefault(require("./Payment/Application"));
31
+ const Application_7 = __importDefault(require("./Work/Application"));
32
+ const Application_8 = __importDefault(require("./MicroMerchant/Application"));
32
33
  const CacheInterface_1 = __importDefault(require("./Core/Contracts/CacheInterface"));
33
34
  const FinallResult_1 = __importDefault(require("./Core/Decorators/FinallResult"));
34
35
  const TerminateResult_1 = __importDefault(require("./Core/Decorators/TerminateResult"));
@@ -62,9 +63,10 @@ class EasyWechat {
62
63
  BaseService: Application_2.default,
63
64
  MiniProgram: Application_3.default,
64
65
  OpenPlatform: Application_4.default,
65
- Payment: Application_5.default,
66
- Work: Application_6.default,
67
- MicroMerchant: Application_7.default,
66
+ OpenWork: Application_5.default,
67
+ Payment: Application_6.default,
68
+ Work: Application_7.default,
69
+ MicroMerchant: Application_8.default,
68
70
  getInstance: getInstance,
69
71
  };
70
72
  this.CacheInterface = CacheInterface_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-easywechat",
3
- "version": "2.8.1",
3
+ "version": "2.9.1",
4
4
  "description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -20,16 +20,16 @@
20
20
  "license": "MIT",
21
21
  "devDependencies": {
22
22
  "@types/node": "^17.0.8",
23
- "mocha": "^9.1.3",
23
+ "mocha": "^9.2.0",
24
24
  "sinon": "^12.0.1",
25
- "typedoc": "^0.22.10",
25
+ "typedoc": "^0.22.11",
26
26
  "typedoc-plugin-markdown": "^3.11.9",
27
27
  "typescript": "^4.5.4"
28
28
  },
29
29
  "dependencies": {
30
- "axios": "^0.21.4",
30
+ "axios": "^0.24.0",
31
31
  "form-data": "^4.0.0",
32
- "node-socialite": "^1.2.4",
32
+ "node-socialite": "^1.2.5",
33
33
  "qs": "^6.10.2",
34
34
  "raw-body": "^2.4.2",
35
35
  "xml2js": "^0.4.23"
@@ -1 +0,0 @@
1
- {"data":{"errcode":0,"errmsg":"ok","access_token":"moke-token","expires_in":7200},"lifeTime":1641494146}
@@ -1 +0,0 @@
1
- {"data":{"errcode":0,"errmsg":"ok"},"lifeTime":1641494146}