dinegg 3.8.0 → 3.8.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/index.d.ts CHANGED
@@ -11,7 +11,6 @@
11
11
  import * as Egg from "egg";
12
12
 
13
13
  // 将该上层框架用到的插件 import 进来
14
- import "@diyaner/egg-sequelize";
15
14
  import "egg-cors";
16
15
  import "egg-jwt";
17
16
  import "./lib/typings/shim.schedule";
@@ -31,7 +30,7 @@ import AppCache from "./lib/core/AppCache";
31
30
  // ts 这里可以理解成导入一个类。并将这个类的类型提取给ts作为自定义type。然后这个type就可以放在interface上,或者提供给其他interface等。
32
31
  // context扩展声明,需先自定义type
33
32
  // type ExtendContextType = typeof ExtendContext;
34
- interface ExtendContextType {}
33
+ interface ExtendContextType { }
35
34
 
36
35
  import { AbstractPermissionAccessControl } from "./decorator";
37
36
  import DineggAPIClient from "./lib/core/ClusterClient/DineggAPIClient";
@@ -144,7 +143,7 @@ declare module "egg" {
144
143
  * @return {*} {IResponseBodyData}
145
144
  * @memberof Controller
146
145
  */
147
- send(data: any, status?: number, msg?: string, errDetails?: string[]): IResponseBodyData;
146
+ protected send<T extends any>(data: T, status?: number, msg?: string, errDetails?: string[]): IResponseBodyData<T>;
148
147
  /**
149
148
  *ctx发送成功的响应
150
149
  * - 不能在router中直接调用
@@ -152,7 +151,7 @@ declare module "egg" {
152
151
  * @param {*} data
153
152
  * @memberof Controller
154
153
  */
155
- success(data: any): IResponseBodyData;
154
+ protected success<T extends any>(data: T): IResponseBodyData<T>;
156
155
 
157
156
  /**
158
157
  *发送警告的响应,主体响应仍然是成功的,但是将携带一个弃用或变更之类的警告,提醒caller,该api将发生变化
@@ -162,7 +161,7 @@ declare module "egg" {
162
161
  * @return {*} {IResponseBodyData}
163
162
  * @memberof Controller
164
163
  */
165
- warning(data: any, msg?: string): IResponseBodyData;
164
+ protected warning<T extends any>(data: T, msg?: string): IResponseBodyData<T>;
166
165
  /**
167
166
  *
168
167
  *ctx发送错误的响应
@@ -177,7 +176,7 @@ declare module "egg" {
177
176
  * @return {*} {IResponseBodyData}
178
177
  * @memberof Controller
179
178
  */
180
- error(msg: string, code?: number, errDetails?: stirng[]): IResponseBodyData;
179
+ protected error(msg: string, code?: number, errDetails?: stirng[]): IResponseBodyData<null>;
181
180
  /**
182
181
  *
183
182
  *ctx发送错误的响应 设置响应码400,对浏览器前端更友好
@@ -192,12 +191,12 @@ declare module "egg" {
192
191
  * @return {*} {IResponseBodyData}
193
192
  * @memberof Controller
194
193
  */
195
- errorBy400(msg: string, code?: number, errDetails?: stirng[]): IResponseBodyData;
194
+ protected errorBy400(msg: string, code?: number, errDetails?: stirng[]): IResponseBodyData;
196
195
  }
197
196
 
198
197
  /** json 响应body规范 */
199
- interface IResponseBodyData {
200
- data: any;
198
+ interface IResponseBodyData<T extends any = any> {
199
+ data: T;
201
200
  code: number;
202
201
  msg: string | null;
203
202
  details?: string[];
@@ -7,27 +7,27 @@ export default class DineggController extends Controller {
7
7
  * @param {number} [status=20000] 自定义的状态码
8
8
  * @param {string} [msg=""] 修改状态对应的msg信息。
9
9
  */
10
- send(data: any, status?: number, msg?: string, errDetails?: string[]): IResponseBodyData;
10
+ send(data: any, status?: number, msg?: string, errDetails?: string[]): IResponseBodyData<any>;
11
11
  /**
12
12
  *发送成功的响应,携带数据
13
13
  *
14
14
  * @param {*} data
15
15
  */
16
- success(data: any): IResponseBodyData;
16
+ success(data: any): IResponseBodyData<any>;
17
17
  /**
18
18
  *发送警告的响应,主体响应仍然是成功的,但是将携带一个弃用或变更之类的警告,提醒caller,该api将发生变化
19
19
  *
20
20
  * @param {*} data
21
21
  */
22
- warning(data: any, msg?: string): IResponseBodyData;
22
+ warning(data: any, msg?: string): IResponseBodyData<any>;
23
23
  /**
24
24
  *发送失败的响应,携带msg信息
25
25
  *
26
26
  * @param {*} msg
27
27
  */
28
- error(msg: any, code?: number, details?: string[]): IResponseBodyData;
28
+ error(msg: any, code?: number, details?: string[]): IResponseBodyData<any>;
29
29
  /**
30
30
  * 响应http status 为400的错误,对浏览器端更友好
31
31
  */
32
- errorBy400(msg: any, code?: number, details?: string[]): IResponseBodyData;
32
+ errorBy400(msg: any, code?: number, details?: string[]): IResponseBodyData<any>;
33
33
  }
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "dinegg",
3
- "version": "3.8.0",
3
+ "version": "3.8.2",
4
4
  "description": "egg framework dinegg.",
5
5
  "dependencies": {
6
+ "cluster-client": "^3.6.0",
6
7
  "egg": "3.21.0",
7
8
  "egg-cors": "^2.2.3",
8
9
  "egg-jwt": "^3.1.7",
9
10
  "egg-validate": "^2.0.2",
10
11
  "globby": "^11.0.2",
11
- "reflect-metadata": "^0.1.13"
12
+ "reflect-metadata": "^0.1.13",
13
+ "sdk-base": "^4.2.1"
12
14
  },
13
15
  "devDependencies": {
14
16
  "@diyaner/egg-sequelize": "^6.35.1",