node-easywechat 3.0.0-beta.1 → 3.0.0-beta.2

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/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
- ## v3.0.0-beta.1 (2022-06-21)
4
+ ## v3.0.0-beta.2 (2022-06-21)
5
+
6
+ - Fix: 修复获取的服务端实例没有代码提示的问题
7
+
8
+ ## v3.0.0-beta.1, origin/3.x (2022-06-21)
5
9
 
6
10
  - Feat: 新增设置预置参数相关方法
7
11
  - Feat: 增加设置日志处理器的方法
@@ -1,3 +1,6 @@
1
+ /**
2
+ * 缓存接口
3
+ */
1
4
  declare abstract class CacheInterface {
2
5
  /**
3
6
  * 获取缓存
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ /**
12
+ * 缓存接口
13
+ */
11
14
  class CacheInterface {
12
15
  /**
13
16
  * 获取缓存
@@ -1,8 +1,14 @@
1
1
  import ResponseInterface from "../Http/Contracts/ResponseInterface";
2
+ import DecryptXmlMessageMixin from "../Mixins/DecryptXmlMessageMixin";
3
+ import HandlersMixin from "../Mixins/HandlersMixin";
4
+ import ResponseXmlMessageMixin from "../Mixins/ResponseXmlMessageMixin";
2
5
  declare abstract class ServerInterface {
6
+ constructor();
3
7
  /**
4
8
  * 处理消息
5
9
  */
6
10
  serve(): Promise<ResponseInterface>;
7
11
  }
12
+ interface ServerInterface extends HandlersMixin, DecryptXmlMessageMixin, ResponseXmlMessageMixin {
13
+ }
8
14
  export = ServerInterface;
@@ -8,7 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ const DecryptXmlMessageMixin_1 = __importDefault(require("../Mixins/DecryptXmlMessageMixin"));
15
+ const HandlersMixin_1 = __importDefault(require("../Mixins/HandlersMixin"));
16
+ const ResponseXmlMessageMixin_1 = __importDefault(require("../Mixins/ResponseXmlMessageMixin"));
17
+ const Utils_1 = require("../Support/Utils");
11
18
  class ServerInterface {
19
+ constructor() {
20
+ this.handlers = [];
21
+ }
12
22
  /**
13
23
  * 处理消息
14
24
  */
@@ -17,4 +27,6 @@ class ServerInterface {
17
27
  }
18
28
  }
19
29
  ;
30
+ ;
31
+ (0, Utils_1.applyMixins)(ServerInterface, [HandlersMixin_1.default, DecryptXmlMessageMixin_1.default, ResponseXmlMessageMixin_1.default]);
20
32
  module.exports = ServerInterface;
@@ -3,6 +3,9 @@ import { IncomingMessage } from "http";
3
3
  import ServerRequestInterface from "./Contracts/ServerRequestInterface";
4
4
  import MessageMixin from "./Minxins/MessageMixin";
5
5
  import RequestMixin from "./Minxins/RequestMixin";
6
+ /**
7
+ * 服务器收到的请求对象
8
+ */
6
9
  declare class ServerRequest implements ServerRequestInterface {
7
10
  protected attributes: Record<string, any>;
8
11
  protected cookieParams: Record<string, any>;
@@ -8,6 +8,9 @@ const url_1 = require("url");
8
8
  const Utils_1 = require("../Support/Utils");
9
9
  const MessageMixin_1 = __importDefault(require("./Minxins/MessageMixin"));
10
10
  const RequestMixin_1 = __importDefault(require("./Minxins/RequestMixin"));
11
+ /**
12
+ * 服务器收到的请求对象
13
+ */
11
14
  class ServerRequest {
12
15
  constructor(method, url, headers = {}, body = null, version = 'v1.1', serverParams = {}) {
13
16
  this.attributes = {};
@@ -117,7 +117,7 @@ class HttpClientResponse {
117
117
  * @returns
118
118
  */
119
119
  toDataUrl() {
120
- return 'data:' + this.getHeader('content-type') + ';base64,' + this.response.data;
120
+ return 'data:' + this.getHeader('content-type') + ';base64,' + this.response.data.toString('base64');
121
121
  }
122
122
  /**
123
123
  * 判断 content-type 是否指定类型
@@ -1,5 +1,8 @@
1
1
  import ServerRequestInterface from "./Http/Contracts/ServerRequestInterface";
2
2
  import HasAttributesMixin from "./Mixins/HasAttributesMixin";
3
+ /**
4
+ * 消息对象
5
+ */
3
6
  declare class Message {
4
7
  /**
5
8
  * 原始消息内容
@@ -13,6 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  const HasAttributesMixin_1 = __importDefault(require("./Mixins/HasAttributesMixin"));
15
15
  const Utils_1 = require("./Support/Utils");
16
+ /**
17
+ * 消息对象
18
+ */
16
19
  class Message {
17
20
  constructor(attributes, originContent = '') {
18
21
  /**
@@ -12,6 +12,9 @@ import { MiniAppConfig } from '../Types/global';
12
12
  import AccountInterface from './Contracts/AccountInterface';
13
13
  import ApplicationInterface from './Contracts/ApplicationInterface';
14
14
  import Utils from './Utils';
15
+ /**
16
+ * 小程序应用
17
+ */
15
18
  declare class Application implements ApplicationInterface {
16
19
  constructor(config: ConfigInterface | MiniAppConfig);
17
20
  protected account: AccountInterface;
@@ -17,6 +17,9 @@ const Account_1 = __importDefault(require("./Account"));
17
17
  const Server_1 = __importDefault(require("./Server"));
18
18
  const Utils_2 = __importDefault(require("./Utils"));
19
19
  const Config_1 = __importDefault(require("../OfficialAccount/Config"));
20
+ /**
21
+ * 小程序应用
22
+ */
20
23
  class Application {
21
24
  constructor(config) {
22
25
  this.account = null;
@@ -14,6 +14,9 @@ import AccountInterface from './Contracts/AccountInterface';
14
14
  import ApplicationInterface from './Contracts/ApplicationInterface';
15
15
  import JsApiTicket from './JsApiTicket';
16
16
  import Utils from './Utils';
17
+ /**
18
+ * 公众号应用
19
+ */
17
20
  declare class Application implements ApplicationInterface {
18
21
  constructor(config: ConfigInterface | OfficialAccountConfig);
19
22
  protected account: AccountInterface;
@@ -20,6 +20,9 @@ const Account_1 = __importDefault(require("./Account"));
20
20
  const JsApiTicket_1 = __importDefault(require("./JsApiTicket"));
21
21
  const Server_1 = __importDefault(require("./Server"));
22
22
  const Utils_2 = __importDefault(require("./Utils"));
23
+ /**
24
+ * 公众号应用
25
+ */
23
26
  class Application {
24
27
  constructor(config) {
25
28
  this.account = null;
@@ -3,11 +3,8 @@ import Encryptor from '../Core/Encryptor';
3
3
  import ServerInterface from '../Core/Contracts/ServerInterface';
4
4
  import Response from '../Core/Http/Response';
5
5
  import Message from './Message';
6
- import HandlersMixin from '../Core/Mixins/HandlersMixin';
7
- import DecryptXmlMessageMixin from '../Core/Mixins/DecryptXmlMessageMixin';
8
6
  import { ServerEventType, ServerHandlerClosure, ServerMessageType } from '../Types/global';
9
- import ResponseXmlMessageMixin from '../Core/Mixins/ResponseXmlMessageMixin';
10
- declare class Server implements ServerInterface {
7
+ declare class Server extends ServerInterface {
11
8
  protected request: ServerRequestInterface;
12
9
  protected encryptor: Encryptor;
13
10
  constructor(request?: ServerRequestInterface, encryptor?: Encryptor);
@@ -38,6 +35,4 @@ declare class Server implements ServerInterface {
38
35
  getRequestMessage(request?: ServerRequestInterface): Promise<Message>;
39
36
  protected decryptRequestMessage(query: Record<string, any>): ServerHandlerClosure;
40
37
  }
41
- interface Server extends HandlersMixin, DecryptXmlMessageMixin, ResponseXmlMessageMixin {
42
- }
43
38
  export = Server;
@@ -11,17 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
+ const ServerInterface_1 = __importDefault(require("../Core/Contracts/ServerInterface"));
14
15
  const Response_1 = __importDefault(require("../Core/Http/Response"));
15
16
  const Message_1 = __importDefault(require("./Message"));
16
- const HandlersMixin_1 = __importDefault(require("../Core/Mixins/HandlersMixin"));
17
- const Utils_1 = require("../Core/Support/Utils");
18
- const DecryptXmlMessageMixin_1 = __importDefault(require("../Core/Mixins/DecryptXmlMessageMixin"));
19
- const ResponseXmlMessageMixin_1 = __importDefault(require("../Core/Mixins/ResponseXmlMessageMixin"));
20
- class Server {
17
+ class Server extends ServerInterface_1.default {
21
18
  constructor(request = null, encryptor = null) {
19
+ super();
22
20
  this.request = request;
23
21
  this.encryptor = encryptor;
24
- this.handlers = [];
25
22
  }
26
23
  /**
27
24
  * 服务端消息处理
@@ -89,6 +86,4 @@ class Server {
89
86
  }
90
87
  }
91
88
  ;
92
- ;
93
- (0, Utils_1.applyMixins)(Server, [HandlersMixin_1.default, DecryptXmlMessageMixin_1.default, ResponseXmlMessageMixin_1.default]);
94
89
  module.exports = Server;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,14 @@
1
- import { OfficialAccountConfig, MiniAppConfig, LogHandler } from './Types/global';
1
+ import { OfficialAccountConfig, MiniAppConfig, LogHandler, ServerEventType, ServerHandlerClosure } from './Types/global';
2
2
  import OfficialAccount from './OfficialAccount/Application';
3
3
  import MiniApp from './MiniApp/Application';
4
4
  import CacheInterface from './Core/Contracts/CacheInterface';
5
5
  import ServerRequest from './Core/Http/ServerRequest';
6
- export { OfficialAccount, OfficialAccountConfig, MiniApp, MiniAppConfig, CacheInterface, ServerRequest, LogHandler, };
6
+ import Message from './Core/Message';
7
+ import FormData from 'form-data';
8
+ export { OfficialAccount, OfficialAccountConfig, MiniApp, MiniAppConfig, CacheInterface, ServerRequest, LogHandler, ServerEventType, ServerHandlerClosure, Message,
9
+ /**
10
+ * 表单对象
11
+ * @see https://github.com/axios/axios#formdata
12
+ * @see https://github.com/form-data/form-data#readme
13
+ */
14
+ FormData, };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ServerRequest = exports.CacheInterface = exports.MiniApp = exports.OfficialAccount = void 0;
6
+ exports.FormData = exports.Message = exports.ServerRequest = exports.CacheInterface = exports.MiniApp = exports.OfficialAccount = void 0;
7
7
  const Application_1 = __importDefault(require("./OfficialAccount/Application"));
8
8
  exports.OfficialAccount = Application_1.default;
9
9
  const Application_2 = __importDefault(require("./MiniApp/Application"));
@@ -12,3 +12,7 @@ const CacheInterface_1 = __importDefault(require("./Core/Contracts/CacheInterfac
12
12
  exports.CacheInterface = CacheInterface_1.default;
13
13
  const ServerRequest_1 = __importDefault(require("./Core/Http/ServerRequest"));
14
14
  exports.ServerRequest = ServerRequest_1.default;
15
+ const Message_1 = __importDefault(require("./Core/Message"));
16
+ exports.Message = Message_1.default;
17
+ const form_data_1 = __importDefault(require("form-data"));
18
+ exports.FormData = form_data_1.default;
@@ -1 +1 @@
1
- {"data":"mock-access_token","lifeTime":1655744193}
1
+ {"data":"mock-access_token","lifeTime":1655828727}
@@ -1 +1 @@
1
- {"data":"mock-access_token","lifeTime":1655744193}
1
+ {"data":"mock-access_token","lifeTime":1655828727}
@@ -1 +1 @@
1
- {"data":"mock-ticket","lifeTime":1655749893}
1
+ {"data":"mock-ticket","lifeTime":1655834427}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-easywechat",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {