@mx-space/api-client 0.7.0-alpha.1 → 0.7.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/adaptors/axios.ts +34 -32
- package/adaptors/umi-request.ts +25 -22
- package/build/index.cjs.js +12 -32
- package/build/index.cjs.js.map +1 -1
- package/build/index.cjs.min.js +1 -1
- package/build/index.cjs.min.js.map +1 -1
- package/build/index.esm.js +13 -32
- package/build/index.esm.js.map +1 -1
- package/build/index.esm.min.js +1 -1
- package/build/index.esm.min.js.map +1 -1
- package/build/index.umd.js +12 -32
- package/build/index.umd.js.map +1 -1
- package/build/index.umd.min.js +1 -1
- package/build/index.umd.min.js.map +1 -1
- package/controllers/aggregate.ts +9 -5
- package/controllers/base.ts +3 -3
- package/controllers/category.ts +18 -7
- package/controllers/comment.ts +10 -6
- package/controllers/link.ts +11 -4
- package/controllers/note.ts +11 -7
- package/controllers/page.ts +10 -5
- package/controllers/post.ts +15 -8
- package/controllers/project.ts +10 -3
- package/controllers/recently.ts +10 -5
- package/controllers/say.ts +10 -5
- package/controllers/search.ts +14 -7
- package/controllers/snippet.ts +9 -4
- package/controllers/user.ts +10 -5
- package/core/attach-request.ts +1 -1
- package/core/client.ts +37 -47
- package/coverage/clover.xml +570 -0
- package/coverage/coverage-final.json +30 -0
- package/coverage/lcov-report/adaptors/axios.ts.html +199 -0
- package/coverage/lcov-report/adaptors/index.html +131 -0
- package/coverage/lcov-report/adaptors/umi-request.ts.html +184 -0
- package/coverage/lcov-report/auto-bind.ts.html +229 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/controllers/aggregate.ts.html +292 -0
- package/coverage/lcov-report/controllers/base.ts.html +181 -0
- package/coverage/lcov-report/controllers/category.ts.html +439 -0
- package/coverage/lcov-report/controllers/comment.ts.html +289 -0
- package/coverage/lcov-report/controllers/index.html +326 -0
- package/coverage/lcov-report/controllers/index.ts.html +283 -0
- package/coverage/lcov-report/controllers/link.ts.html +169 -0
- package/coverage/lcov-report/controllers/note.ts.html +373 -0
- package/coverage/lcov-report/controllers/page.ts.html +277 -0
- package/coverage/lcov-report/controllers/post.ts.html +367 -0
- package/coverage/lcov-report/controllers/project.ts.html +166 -0
- package/coverage/lcov-report/controllers/recently.ts.html +244 -0
- package/coverage/lcov-report/controllers/say.ts.html +205 -0
- package/coverage/lcov-report/controllers/search.ts.html +409 -0
- package/coverage/lcov-report/controllers/snippet.ts.html +193 -0
- package/coverage/lcov-report/controllers/user.ts.html +238 -0
- package/coverage/lcov-report/core/attach-request.ts.html +214 -0
- package/coverage/lcov-report/core/client.ts.html +802 -0
- package/coverage/lcov-report/core/error.ts.html +115 -0
- package/coverage/lcov-report/core/index.html +161 -0
- package/coverage/lcov-report/core/index.ts.html +91 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +191 -0
- package/coverage/lcov-report/index.ts.html +244 -0
- package/coverage/lcov-report/models/aggregate.ts.html +298 -0
- package/coverage/lcov-report/models/category.ts.html +160 -0
- package/coverage/lcov-report/models/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/utils/auto-bind.ts.html +229 -0
- package/coverage/lcov-report/utils/index.html +131 -0
- package/coverage/lcov-report/utils/index.ts.html +244 -0
- package/coverage/lcov.info +1164 -0
- package/esm/adaptors/axios.d.ts +2 -2
- package/esm/adaptors/axios.js +1 -0
- package/esm/adaptors/axios.js.map +1 -1
- package/esm/adaptors/umi-request.d.ts +2 -2
- package/esm/adaptors/umi-request.js +1 -0
- package/esm/adaptors/umi-request.js.map +1 -1
- package/esm/controllers/aggregate.d.ts +25 -8
- package/esm/controllers/aggregate.js.map +1 -1
- package/esm/controllers/base.d.ts +17 -5
- package/esm/controllers/category.d.ts +64 -13
- package/esm/controllers/category.js.map +1 -1
- package/esm/controllers/comment.d.ts +42 -10
- package/esm/controllers/comment.js.map +1 -1
- package/esm/controllers/link.d.ts +5 -4
- package/esm/controllers/link.js.map +1 -1
- package/esm/controllers/note.d.ts +42 -12
- package/esm/controllers/note.js.map +1 -1
- package/esm/controllers/page.d.ts +22 -8
- package/esm/controllers/page.js.map +1 -1
- package/esm/controllers/post.d.ts +24 -11
- package/esm/controllers/post.js.map +1 -1
- package/esm/controllers/project.d.ts +4 -3
- package/esm/controllers/project.js.map +1 -1
- package/esm/controllers/recently.d.ts +30 -8
- package/esm/controllers/recently.js.map +1 -1
- package/esm/controllers/say.d.ts +15 -5
- package/esm/controllers/say.js.map +1 -1
- package/esm/controllers/search.d.ts +168 -9
- package/esm/controllers/search.js.map +1 -1
- package/esm/controllers/snippet.d.ts +16 -6
- package/esm/controllers/snippet.js.map +1 -1
- package/esm/controllers/user.d.ts +28 -8
- package/esm/controllers/user.js.map +1 -1
- package/esm/core/attach-request.d.ts +1 -1
- package/esm/core/attach-request.js.map +1 -1
- package/esm/core/client.d.ts +9 -6
- package/esm/core/client.js +13 -32
- package/esm/core/client.js.map +1 -1
- package/esm/index.d.ts +2 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/interfaces/adapter.d.ts +9 -8
- package/esm/interfaces/client.d.ts +1 -1
- package/esm/interfaces/request.d.ts +22 -13
- package/esm/interfaces/types.d.ts +2 -0
- package/esm/interfaces/types.js +2 -0
- package/esm/interfaces/types.js.map +1 -0
- package/esm/models/post.d.ts +0 -1
- package/index.ts +2 -1
- package/interfaces/adapter.ts +29 -24
- package/interfaces/client.ts +1 -1
- package/interfaces/request.ts +45 -20
- package/{types/helper.d.ts → interfaces/types.ts} +0 -0
- package/jest.config.js +12 -0
- package/lib/adaptors/axios.d.ts +2 -2
- package/lib/adaptors/axios.js +1 -0
- package/lib/adaptors/axios.js.map +1 -1
- package/lib/adaptors/umi-request.d.ts +2 -2
- package/lib/adaptors/umi-request.js +1 -0
- package/lib/adaptors/umi-request.js.map +1 -1
- package/lib/controllers/aggregate.d.ts +25 -8
- package/lib/controllers/aggregate.js.map +1 -1
- package/lib/controllers/base.d.ts +17 -5
- package/lib/controllers/category.d.ts +64 -13
- package/lib/controllers/category.js.map +1 -1
- package/lib/controllers/comment.d.ts +42 -10
- package/lib/controllers/comment.js.map +1 -1
- package/lib/controllers/link.d.ts +5 -4
- package/lib/controllers/link.js.map +1 -1
- package/lib/controllers/note.d.ts +42 -12
- package/lib/controllers/note.js.map +1 -1
- package/lib/controllers/page.d.ts +22 -8
- package/lib/controllers/page.js.map +1 -1
- package/lib/controllers/post.d.ts +24 -11
- package/lib/controllers/post.js.map +1 -1
- package/lib/controllers/project.d.ts +4 -3
- package/lib/controllers/project.js.map +1 -1
- package/lib/controllers/recently.d.ts +30 -8
- package/lib/controllers/recently.js.map +1 -1
- package/lib/controllers/say.d.ts +15 -5
- package/lib/controllers/say.js.map +1 -1
- package/lib/controllers/search.d.ts +168 -9
- package/lib/controllers/search.js.map +1 -1
- package/lib/controllers/snippet.d.ts +16 -6
- package/lib/controllers/snippet.js.map +1 -1
- package/lib/controllers/user.d.ts +28 -8
- package/lib/controllers/user.js.map +1 -1
- package/lib/core/attach-request.d.ts +1 -1
- package/lib/core/attach-request.js.map +1 -1
- package/lib/core/client.d.ts +9 -6
- package/lib/core/client.js +13 -33
- package/lib/core/client.js.map +1 -1
- package/lib/core/index.js +5 -1
- package/lib/core/index.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/lib/interfaces/adapter.d.ts +9 -8
- package/lib/interfaces/client.d.ts +1 -1
- package/lib/interfaces/request.d.ts +22 -13
- package/lib/interfaces/types.d.ts +2 -0
- package/lib/interfaces/types.js +3 -0
- package/lib/interfaces/types.js.map +1 -0
- package/lib/models/index.js +5 -1
- package/lib/models/index.js.map +1 -1
- package/lib/models/post.d.ts +0 -1
- package/models/post.ts +0 -1
- package/package.json +12 -12
- package/tsconfig.json +25 -4
- package/tsconfig.types.json +18 -0
- package/types/adaptors/axios.d.ts +3 -0
- package/types/adaptors/umi-request.d.ts +3 -0
- package/types/controllers/aggregate.d.ts +64 -0
- package/types/controllers/base.d.ts +39 -0
- package/types/controllers/category.d.ts +114 -0
- package/types/controllers/comment.d.ts +81 -0
- package/types/controllers/index.d.ts +16 -0
- package/types/controllers/link.d.ts +16 -0
- package/types/controllers/note.d.ts +94 -0
- package/types/controllers/page.d.ts +59 -0
- package/types/controllers/post.d.ts +72 -0
- package/types/controllers/project.d.ts +15 -0
- package/types/controllers/recently.d.ts +61 -0
- package/types/controllers/say.d.ts +37 -0
- package/types/controllers/search.d.ts +247 -0
- package/types/controllers/snippet.d.ts +33 -0
- package/types/controllers/user.d.ts +54 -0
- package/types/core/attach-request.d.ts +2 -0
- package/types/core/client.d.ts +29 -0
- package/types/core/error.d.ts +6 -0
- package/types/core/index.d.ts +2 -0
- package/types/dtos/comment.d.ts +6 -0
- package/types/index.d.ts +7 -0
- package/types/interfaces/adapter.d.ts +14 -0
- package/types/interfaces/client.d.ts +5 -0
- package/types/interfaces/controller.d.ts +4 -0
- package/types/interfaces/instance.d.ts +7 -0
- package/types/interfaces/options.d.ts +1 -0
- package/types/interfaces/params.d.ts +4 -0
- package/types/interfaces/request.d.ts +43 -0
- package/types/interfaces/types.d.ts +2 -0
- package/types/models/aggregate.d.ts +53 -0
- package/types/models/base.d.ts +37 -0
- package/types/models/category.d.ts +22 -0
- package/types/models/comment.d.ts +34 -0
- package/types/models/index.d.ts +14 -0
- package/types/models/link.d.ts +20 -0
- package/types/models/note.d.ts +30 -0
- package/types/models/page.d.ts +14 -0
- package/types/models/post.d.ts +14 -0
- package/types/models/project.d.ts +11 -0
- package/types/models/recently.d.ts +6 -0
- package/types/models/say.d.ts +6 -0
- package/types/models/setting.d.ts +66 -0
- package/types/models/snippet.d.ts +16 -0
- package/types/models/user.d.ts +21 -0
- package/types/utils/auto-bind.d.ts +4 -0
- package/types/utils/index.d.ts +5 -0
package/esm/adaptors/axios.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
2
|
import { IRequestAdapter } from '../interfaces/adapter';
|
|
3
|
-
export declare const axiosAdaptor: IRequestAdapter<AxiosInstance
|
|
3
|
+
export declare const axiosAdaptor: IRequestAdapter<AxiosInstance, AxiosResponse<unknown>>;
|
package/esm/adaptors/axios.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../adaptors/axios.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../adaptors/axios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAA;AAE3D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAE9B,2DAA2D;AAC3D,MAAM,CAAC,MAAM,YAAY,GAGrB,MAAM,CAAC,iBAAiB,CAAC;IAC3B,IAAI,OAAO;QACT,OAAO,KAAK,CAAA;IACd,CAAC;IACD,eAAe,EAAE,EAAmC;IACpD,GAAG,CAAC,GAAG,EAAE,OAAO;QACd,aAAa;QACb,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChC,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,OAAO;QACf,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QACzC,aAAa;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IACtC,CAAC;IACD,GAAG,CAAC,GAAG,EAAE,OAAO;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QACzC,aAAa;QACb,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IACrC,CAAC;IACD,MAAM,CAAC,GAAG,EAAE,OAAO;QACjB,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QACnC,aAAa;QACb,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,GAAG,EAAE,OAAO;QAChB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QACzC,aAAa;QACb,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RequestMethod } from 'umi-request';
|
|
1
|
+
import { RequestMethod, RequestResponse } from 'umi-request';
|
|
2
2
|
import { IRequestAdapter } from '../interfaces/adapter';
|
|
3
|
-
export declare const umiAdaptor: IRequestAdapter<RequestMethod<true
|
|
3
|
+
export declare const umiAdaptor: IRequestAdapter<RequestMethod<true>, RequestResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"umi-request.js","sourceRoot":"","sources":["../../adaptors/umi-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"umi-request.js","sourceRoot":"","sources":["../../adaptors/umi-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkC,MAAM,aAAa,CAAA;AAGpE,MAAM,KAAK,GAAG,MAAM,CAAC;IACnB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,MAAM;IACnB,YAAY,EAAE,MAAM;CACrB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,UAAU,GAGnB,MAAM,CAAC,iBAAiB,CAAC;IAC3B,IAAI,OAAO;QACT,OAAO,KAAK,CAAA;IACd,CAAC;IACD,eAAe,EAAE,EAA4B;IAC7C,GAAG,CAAC,GAAG,EAAE,OAAO;QACd,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChC,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,OAAO;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACjC,CAAC;IACD,GAAG,CAAC,GAAG,EAAE,OAAO;QACd,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChC,CAAC;IACD,MAAM,CAAC,GAAG,EAAE,OAAO;QACjB,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACnC,CAAC;IACD,KAAK,CAAC,GAAG,EAAE,OAAO;QAChB,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAClC,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1,29 +1,34 @@
|
|
|
1
|
+
import { IRequestAdapter } from '../interfaces/adapter';
|
|
1
2
|
import { IController } from '../interfaces/controller';
|
|
2
3
|
import { SortOrder } from '../interfaces/options';
|
|
3
4
|
import { IRequestHandler, RequestProxyResult } from '../interfaces/request';
|
|
4
5
|
import { AggregateRoot, AggregateStat, AggregateTop, TimelineData, TimelineType } from '../models/aggregate';
|
|
5
6
|
import { HTTPClient } from '../core';
|
|
6
7
|
declare module '../core/client' {
|
|
7
|
-
interface HTTPClient {
|
|
8
|
-
aggregate: AggregateController
|
|
8
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
|
+
aggregate: AggregateController<ResponseWrapper>;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
export declare class AggregateController implements IController {
|
|
12
|
+
export declare class AggregateController<ResponseWrapper> implements IController {
|
|
12
13
|
private client;
|
|
13
14
|
base: string;
|
|
14
15
|
name: string;
|
|
15
16
|
constructor(client: HTTPClient);
|
|
16
|
-
get proxy(): IRequestHandler
|
|
17
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
17
18
|
/**
|
|
18
19
|
* 获取聚合数据
|
|
19
20
|
*/
|
|
20
|
-
getAggregateData(): RequestProxyResult<AggregateRoot>;
|
|
21
|
+
getAggregateData(): RequestProxyResult<AggregateRoot, ResponseWrapper>;
|
|
21
22
|
/**
|
|
22
23
|
* 获取最新发布的内容
|
|
23
24
|
*/
|
|
24
|
-
getTop(size?: number): RequestProxyResult<AggregateTop, {
|
|
25
|
+
getTop(size?: number): RequestProxyResult<AggregateTop, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
25
26
|
[key: string]: any;
|
|
26
27
|
data: AggregateTop;
|
|
28
|
+
} : ResponseWrapper extends {
|
|
29
|
+
data: AggregateTop;
|
|
30
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
31
|
+
data: AggregateTop;
|
|
27
32
|
}>;
|
|
28
33
|
getTimeline(options?: {
|
|
29
34
|
sort?: SortOrder;
|
|
@@ -31,17 +36,29 @@ export declare class AggregateController implements IController {
|
|
|
31
36
|
year?: number;
|
|
32
37
|
}): RequestProxyResult<{
|
|
33
38
|
data: TimelineData;
|
|
34
|
-
}, {
|
|
39
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
35
40
|
[key: string]: any;
|
|
36
41
|
data: {
|
|
37
42
|
data: TimelineData;
|
|
38
43
|
};
|
|
44
|
+
} : ResponseWrapper extends {
|
|
45
|
+
data: {
|
|
46
|
+
data: TimelineData;
|
|
47
|
+
};
|
|
48
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
49
|
+
data: {
|
|
50
|
+
data: TimelineData;
|
|
51
|
+
};
|
|
39
52
|
}>;
|
|
40
53
|
/**
|
|
41
54
|
* 获取聚合数据统计
|
|
42
55
|
*/
|
|
43
|
-
getStat(): RequestProxyResult<AggregateStat, {
|
|
56
|
+
getStat(): RequestProxyResult<AggregateStat, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
44
57
|
[key: string]: any;
|
|
45
58
|
data: AggregateStat;
|
|
59
|
+
} : ResponseWrapper extends {
|
|
60
|
+
data: AggregateStat;
|
|
61
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
62
|
+
data: AggregateStat;
|
|
46
63
|
}>;
|
|
47
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate.js","sourceRoot":"","sources":["../../controllers/aggregate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aggregate.js","sourceRoot":"","sources":["../../controllers/aggregate.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAY5C,MAAM,OAAO,mBAAmB;IAG9B,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAFtC,SAAI,GAAG,WAAW,CAAA;QAClB,SAAI,GAAG,WAAW,CAAA;QAEhB,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IACD,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAiB,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,GAAG,CAAC;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAe,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IAC/D,CAAC;IAED,WAAW,CAAC,OAIX;QACC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAyB;YACrD,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI,IAAI,iBAAiB,CAAC,IAAI,CAAC;gBACrC,IAAI;gBACJ,IAAI;aACL;SACF,CAAC,CAAA;IACJ,CAAC;IACD;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAiB,CAAA;IAC7C,CAAC;CACF"}
|
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
import { IRequestHandler, RequestProxyResult } from '../interfaces/request';
|
|
2
2
|
import { PaginateResult } from '../models/base';
|
|
3
3
|
import { HTTPClient } from '../core';
|
|
4
|
-
export declare abstract class BaseCrudController<T> {
|
|
4
|
+
export declare abstract class BaseCrudController<T, ResponseWrapper> {
|
|
5
5
|
protected client: HTTPClient;
|
|
6
6
|
base: string;
|
|
7
7
|
constructor(client: HTTPClient);
|
|
8
|
-
get proxy(): IRequestHandler
|
|
9
|
-
getById(id: string): RequestProxyResult<T>;
|
|
8
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
9
|
+
getById(id: string): RequestProxyResult<T, ResponseWrapper>;
|
|
10
10
|
getAll(): RequestProxyResult<{
|
|
11
11
|
data: T[];
|
|
12
|
-
}, {
|
|
12
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
data: {
|
|
15
15
|
data: T[];
|
|
16
16
|
};
|
|
17
|
+
} : ResponseWrapper extends {
|
|
18
|
+
data: {
|
|
19
|
+
data: T[];
|
|
20
|
+
};
|
|
21
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
22
|
+
data: {
|
|
23
|
+
data: T[];
|
|
24
|
+
};
|
|
17
25
|
}>;
|
|
18
26
|
/**
|
|
19
27
|
* 带分页的查询
|
|
20
28
|
* @param page
|
|
21
29
|
* @param perPage
|
|
22
30
|
*/
|
|
23
|
-
getAllPaginated(page?: number, perPage?: number): RequestProxyResult<PaginateResult<T>, {
|
|
31
|
+
getAllPaginated(page?: number, perPage?: number): RequestProxyResult<PaginateResult<T>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
24
32
|
[key: string]: any;
|
|
25
33
|
data: PaginateResult<T>;
|
|
34
|
+
} : ResponseWrapper extends {
|
|
35
|
+
data: PaginateResult<T>;
|
|
36
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
37
|
+
data: PaginateResult<T>;
|
|
26
38
|
}>;
|
|
27
39
|
}
|
|
@@ -1,33 +1,43 @@
|
|
|
1
|
+
import { IRequestAdapter } from '../interfaces/adapter';
|
|
1
2
|
import { IController } from '../interfaces/controller';
|
|
2
|
-
import { RequestProxyResult, ResponseProxyExtraRaw } from '../interfaces/request';
|
|
3
|
+
import { IRequestHandler, RequestProxyResult, ResponseProxyExtraRaw } from '../interfaces/request';
|
|
3
4
|
import { HTTPClient } from '../core/client';
|
|
4
5
|
import { CategoryModel, CategoryType, CategoryWithChildrenModel, TagModel } from '../models/category';
|
|
5
6
|
import { PostModel } from '../models/post';
|
|
6
7
|
declare module '../core/client' {
|
|
7
|
-
interface HTTPClient {
|
|
8
|
-
category: CategoryController
|
|
8
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
|
+
category: CategoryController<ResponseWrapper>;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
export declare class CategoryController implements IController {
|
|
12
|
+
export declare class CategoryController<ResponseWrapper> implements IController {
|
|
12
13
|
private client;
|
|
13
14
|
name: string;
|
|
14
15
|
base: string;
|
|
15
16
|
constructor(client: HTTPClient);
|
|
16
|
-
get proxy():
|
|
17
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
17
18
|
getAllCategories(): RequestProxyResult<{
|
|
18
19
|
data: CategoryModel[];
|
|
19
|
-
}>;
|
|
20
|
+
}, ResponseWrapper>;
|
|
20
21
|
getAllTags(): RequestProxyResult<{
|
|
21
22
|
data: TagModel[];
|
|
22
|
-
}>;
|
|
23
|
+
}, ResponseWrapper>;
|
|
23
24
|
getCategoryDetail(id: string): Promise<ResponseProxyExtraRaw<CategoryWithChildrenModel>>;
|
|
24
25
|
getCategoryDetail(ids: string[]): Promise<ResponseProxyExtraRaw<Map<string, CategoryWithChildrenModel>>>;
|
|
25
26
|
getCategoryByIdOrSlug(idOrSlug: string): Promise<CategoryModel & {
|
|
26
27
|
children: Pick<PostModel, "id" | "title" | "slug" | "modified" | "created">[];
|
|
27
28
|
} & {
|
|
28
|
-
$raw: {
|
|
29
|
+
$raw: ResponseWrapper extends {
|
|
30
|
+
data: infer T;
|
|
31
|
+
} ? ResponseWrapper : ResponseWrapper extends unknown ? {
|
|
29
32
|
[i: string]: any;
|
|
30
|
-
data: {
|
|
33
|
+
data: (ResponseWrapper extends unknown ? {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
data: CategoryWithChildrenModel;
|
|
36
|
+
} : ResponseWrapper extends {
|
|
37
|
+
data: CategoryWithChildrenModel;
|
|
38
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
39
|
+
data: CategoryWithChildrenModel;
|
|
40
|
+
}) extends unknown ? {
|
|
31
41
|
type: CategoryType;
|
|
32
42
|
count: number;
|
|
33
43
|
slug: string;
|
|
@@ -35,8 +45,15 @@ export declare class CategoryController implements IController {
|
|
|
35
45
|
created: string;
|
|
36
46
|
id: string;
|
|
37
47
|
children: Pick<PostModel, "id" | "title" | "slug" | "modified" | "created">[];
|
|
48
|
+
} : ResponseWrapper extends unknown ? {
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
data: CategoryWithChildrenModel;
|
|
51
|
+
} : ResponseWrapper extends {
|
|
52
|
+
data: CategoryWithChildrenModel;
|
|
53
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
54
|
+
data: CategoryWithChildrenModel;
|
|
38
55
|
};
|
|
39
|
-
};
|
|
56
|
+
} : ResponseWrapper;
|
|
40
57
|
$request: {
|
|
41
58
|
[k: string]: string;
|
|
42
59
|
path: string;
|
|
@@ -47,13 +64,47 @@ export declare class CategoryController implements IController {
|
|
|
47
64
|
tag: string;
|
|
48
65
|
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
49
66
|
} & {
|
|
50
|
-
$raw: {
|
|
67
|
+
$raw: ResponseWrapper extends {
|
|
68
|
+
data: infer T;
|
|
69
|
+
} ? ResponseWrapper : ResponseWrapper extends unknown ? {
|
|
51
70
|
[i: string]: any;
|
|
52
|
-
data: {
|
|
71
|
+
data: (ResponseWrapper extends unknown ? {
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
data: {
|
|
74
|
+
tag: string;
|
|
75
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
76
|
+
};
|
|
77
|
+
} : ResponseWrapper extends {
|
|
78
|
+
data: {
|
|
79
|
+
tag: string;
|
|
80
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
81
|
+
};
|
|
82
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
83
|
+
data: {
|
|
84
|
+
tag: string;
|
|
85
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
86
|
+
};
|
|
87
|
+
}) extends unknown ? {
|
|
53
88
|
tag: string;
|
|
54
89
|
data: Pick<PostModel, "id" | "title" | "slug" | "created" | "category">[];
|
|
90
|
+
} : ResponseWrapper extends unknown ? {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
data: {
|
|
93
|
+
tag: string;
|
|
94
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
95
|
+
};
|
|
96
|
+
} : ResponseWrapper extends {
|
|
97
|
+
data: {
|
|
98
|
+
tag: string;
|
|
99
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
100
|
+
};
|
|
101
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
102
|
+
data: {
|
|
103
|
+
tag: string;
|
|
104
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
105
|
+
};
|
|
55
106
|
};
|
|
56
|
-
};
|
|
107
|
+
} : ResponseWrapper;
|
|
57
108
|
$request: {
|
|
58
109
|
[k: string]: string;
|
|
59
110
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../controllers/category.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../controllers/category.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAGL,YAAY,GAGb,MAAM,oBAAoB,CAAA;AAY3B,MAAM,OAAO,kBAAkB;IAG7B,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAFtC,SAAI,GAAG,UAAU,CAAA;QACjB,SAAI,GAAG,YAAY,CAAA;QAEjB,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED,gBAAgB;QAId,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YACpB,MAAM,EAAE;gBACN,IAAI,EAAE,YAAY,CAAC,QAAQ;aAC5B;SACF,CAAC,CAAA;IACJ,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAuB;YAC1C,MAAM,EAAE;gBACN,IAAI,EAAE,YAAY,CAAC,GAAG;aACvB;SACF,CAAC,CAAA;IACJ,CAAC;IAQD,KAAK,CAAC,iBAAiB,CAAC,GAAsB;QAC5C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB;gBACjD,MAAM,EAAE;oBACN,GAAG,EAAE,GAAG;iBACT;aACF,CAAC,CAAA;YACF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;YAC7C,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YACtC,OAAO,MAAM,CAAA;SACd;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB;gBACjD,MAAM,EAAE;oBACN,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;iBACnB;aACF,CAAC,CAAA;YACF,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,CAAA;YAC7B,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,IAAI,YAAY,CACpB,sBAAsB,EACtB,GAAG,EACH,IAAI,CAAC,QAAQ,CAAC,IAAI,EAClB,IAAI,CACL,CAAA;aACF;YAED,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC,CACxE,CAAA;YAED,wBAAwB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;YACnC,OAAO,GAAG,CAAA;SACX;IACH,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,QAAgB;QAC1C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,EAA6B,CAAA;QACvE,OAAO,eAAe,CAAC,GAAG,CAAe,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAY;QAC7B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAGnC;YACD,MAAM,EAAE;gBACN,GAAG,EAAE,CAAC;aACP;SACF,CAAC,CAAA;QAEF,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"}
|
|
@@ -1,49 +1,81 @@
|
|
|
1
|
+
import { IRequestAdapter } from '../interfaces/adapter';
|
|
1
2
|
import { IController } from '../interfaces/controller';
|
|
2
3
|
import { PaginationParams } from '../interfaces/params';
|
|
3
|
-
import { IRequestHandler
|
|
4
|
+
import { IRequestHandler } from '../interfaces/request';
|
|
4
5
|
import { PaginateResult } from '../models/base';
|
|
5
6
|
import { CommentModel } from '../models/comment';
|
|
6
7
|
import { HTTPClient } from '../core';
|
|
7
8
|
import { CommentDto } from '../dtos/comment';
|
|
8
9
|
declare module '../core/client' {
|
|
9
|
-
interface HTTPClient {
|
|
10
|
-
comment: CommentController
|
|
10
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
11
|
+
comment: CommentController<ResponseWrapper>;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
export declare class CommentController implements IController {
|
|
14
|
+
export declare class CommentController<ResponseWrapper> implements IController {
|
|
14
15
|
private readonly client;
|
|
15
16
|
base: string;
|
|
16
17
|
name: string;
|
|
17
18
|
constructor(client: HTTPClient);
|
|
18
|
-
get proxy(): IRequestHandler
|
|
19
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
19
20
|
/**
|
|
20
21
|
* 根据 comment id 获取评论, 包括子评论
|
|
21
22
|
*/
|
|
22
|
-
getById(id: string): RequestProxyResult<CommentModel
|
|
23
|
+
getById(id: string): import("../interfaces/request").RequestProxyResult<CommentModel & {
|
|
24
|
+
ref: string;
|
|
25
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
data: CommentModel & {
|
|
28
|
+
ref: string;
|
|
29
|
+
};
|
|
30
|
+
} : ResponseWrapper extends {
|
|
31
|
+
data: CommentModel & {
|
|
32
|
+
ref: string;
|
|
33
|
+
};
|
|
34
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
35
|
+
data: CommentModel & {
|
|
36
|
+
ref: string;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
23
39
|
/**
|
|
24
40
|
* 获取文章的评论列表
|
|
25
41
|
* @param refId 文章 Id
|
|
26
42
|
*/
|
|
27
|
-
getByRefId(refId: string, pagination?: PaginationParams): RequestProxyResult<PaginateResult<CommentModel & {
|
|
43
|
+
getByRefId(refId: string, pagination?: PaginationParams): import("../interfaces/request").RequestProxyResult<PaginateResult<CommentModel & {
|
|
28
44
|
ref: string;
|
|
29
|
-
}>, {
|
|
45
|
+
}>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
30
46
|
[key: string]: any;
|
|
31
47
|
data: PaginateResult<CommentModel & {
|
|
32
48
|
ref: string;
|
|
33
49
|
}>;
|
|
50
|
+
} : ResponseWrapper extends {
|
|
51
|
+
data: PaginateResult<CommentModel & {
|
|
52
|
+
ref: string;
|
|
53
|
+
}>;
|
|
54
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
55
|
+
data: PaginateResult<CommentModel & {
|
|
56
|
+
ref: string;
|
|
57
|
+
}>;
|
|
34
58
|
}>;
|
|
35
59
|
/**
|
|
36
60
|
* 评论
|
|
37
61
|
*/
|
|
38
|
-
comment(refId: string, data: CommentDto): RequestProxyResult<CommentModel, {
|
|
62
|
+
comment(refId: string, data: CommentDto): import("../interfaces/request").RequestProxyResult<CommentModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
39
63
|
[key: string]: any;
|
|
40
64
|
data: CommentModel;
|
|
65
|
+
} : ResponseWrapper extends {
|
|
66
|
+
data: CommentModel;
|
|
67
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
68
|
+
data: CommentModel;
|
|
41
69
|
}>;
|
|
42
70
|
/**
|
|
43
71
|
* 回复评论
|
|
44
72
|
*/
|
|
45
|
-
reply(commentId: string, data: CommentDto): RequestProxyResult<CommentModel, {
|
|
73
|
+
reply(commentId: string, data: CommentDto): import("../interfaces/request").RequestProxyResult<CommentModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
46
74
|
[key: string]: any;
|
|
47
75
|
data: CommentModel;
|
|
76
|
+
} : ResponseWrapper extends {
|
|
77
|
+
data: CommentModel;
|
|
78
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
79
|
+
data: CommentModel;
|
|
48
80
|
}>;
|
|
49
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../controllers/comment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../controllers/comment.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAa5C,MAAM,OAAO,iBAAiB;IAI5B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAH/C,SAAI,GAAG,UAAU,CAAA;QACjB,SAAI,GAAG,SAAS,CAAA;QAGd,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,EAAkC,CAAA;IAC7D,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,KAAa,EAAE,aAA+B,EAAE;QACzD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,UAAU,CAAA;QACjC,OAAO,IAAI,CAAC,KAAK;aACd,GAAG,CAAC,KAAK,CAAC;aACV,GAAG,CAAiD;YACnD,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE;SAC9C,CAAC,CAAA;IACN,CAAC;IACD;;OAEG;IACH,OAAO,CAAC,KAAa,EAAE,IAAgB;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAe;YAC1C,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAiB,EAAE,IAAgB;QACvC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAe;YACpD,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { IRequestAdapter } from '../interfaces/adapter';
|
|
1
2
|
import { LinkModel } from '../models/link';
|
|
2
3
|
import { HTTPClient } from '../core';
|
|
3
4
|
import { BaseCrudController } from './base';
|
|
4
5
|
declare module '../core/client' {
|
|
5
|
-
interface HTTPClient {
|
|
6
|
-
link: LinkController
|
|
7
|
-
friend: LinkController
|
|
6
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
7
|
+
link: LinkController<ResponseWrapper>;
|
|
8
|
+
friend: LinkController<ResponseWrapper>;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
export declare class LinkController extends BaseCrudController<LinkModel> {
|
|
11
|
+
export declare class LinkController<ResponseWrapper> extends BaseCrudController<LinkModel, ResponseWrapper> {
|
|
11
12
|
protected readonly client: HTTPClient;
|
|
12
13
|
constructor(client: HTTPClient);
|
|
13
14
|
name: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../controllers/link.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../controllers/link.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAY3C,MAAM,OAAO,cAAgC,SAAQ,kBAGpD;IACC,YAA+B,MAAkB;QAC/C,KAAK,CAAC,MAAM,CAAC,CAAA;QADgB,WAAM,GAAN,MAAM,CAAY;QAKjD,SAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QACzB,SAAI,GAAG,OAAO,CAAA;QAJZ,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;CAIF"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { IRequestAdapter } from '../interfaces/adapter';
|
|
1
2
|
import { IController } from '../interfaces/controller';
|
|
2
|
-
import { IRequestHandler
|
|
3
|
+
import { IRequestHandler } from '../interfaces/request';
|
|
4
|
+
import { SelectFields } from '../interfaces/types';
|
|
3
5
|
import { PaginateResult } from '../models/base';
|
|
4
6
|
import { NoteModel, NoteWrappedPayload } from '../models/note';
|
|
5
|
-
import { SelectFields } from '../types/helper';
|
|
6
7
|
import { HTTPClient } from '../core/client';
|
|
7
8
|
declare module '../core/client' {
|
|
8
|
-
interface HTTPClient {
|
|
9
|
-
note: NoteController
|
|
9
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
10
|
+
note: NoteController<ResponseWrapper>;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
export declare type NoteListOptions = {
|
|
@@ -15,50 +16,79 @@ export declare type NoteListOptions = {
|
|
|
15
16
|
sortBy?: 'weather' | 'mood' | 'title' | 'created' | 'modified';
|
|
16
17
|
sortOrder?: 1 | -1;
|
|
17
18
|
};
|
|
18
|
-
export declare class NoteController implements IController {
|
|
19
|
+
export declare class NoteController<ResponseWrapper> implements IController {
|
|
19
20
|
private client;
|
|
20
21
|
base: string;
|
|
21
22
|
name: string;
|
|
22
23
|
constructor(client: HTTPClient);
|
|
23
|
-
get proxy(): IRequestHandler
|
|
24
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
24
25
|
/**
|
|
25
26
|
* 最新日记
|
|
26
27
|
*/
|
|
27
|
-
getLatest(): RequestProxyResult<NoteWrappedPayload
|
|
28
|
+
getLatest(): import("../interfaces/request").RequestProxyResult<NoteWrappedPayload, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
data: NoteWrappedPayload;
|
|
31
|
+
} : ResponseWrapper extends {
|
|
32
|
+
data: NoteWrappedPayload;
|
|
33
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
34
|
+
data: NoteWrappedPayload;
|
|
35
|
+
}>;
|
|
28
36
|
/**
|
|
29
37
|
* 获取一篇日记
|
|
30
38
|
* @param id id | nid
|
|
31
39
|
* @param password 访问密码
|
|
32
40
|
*/
|
|
33
|
-
getNoteById(id: string | number, password?: string): RequestProxyResult<NoteWrappedPayload, {
|
|
41
|
+
getNoteById(id: string | number, password?: string): import("../interfaces/request").RequestProxyResult<NoteWrappedPayload, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
34
42
|
[key: string]: any;
|
|
35
43
|
data: NoteWrappedPayload;
|
|
44
|
+
} : ResponseWrapper extends {
|
|
45
|
+
data: NoteWrappedPayload;
|
|
46
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
47
|
+
data: NoteWrappedPayload;
|
|
36
48
|
}>;
|
|
37
49
|
/**
|
|
38
50
|
* 日记列表分页
|
|
39
51
|
*/
|
|
40
|
-
getList(page?: number, perPage?: number, options?: NoteListOptions): RequestProxyResult<PaginateResult<NoteModel>, {
|
|
52
|
+
getList(page?: number, perPage?: number, options?: NoteListOptions): import("../interfaces/request").RequestProxyResult<PaginateResult<NoteModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
41
53
|
[key: string]: any;
|
|
42
54
|
data: PaginateResult<NoteModel>;
|
|
55
|
+
} : ResponseWrapper extends {
|
|
56
|
+
data: PaginateResult<NoteModel>;
|
|
57
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
58
|
+
data: PaginateResult<NoteModel>;
|
|
43
59
|
}>;
|
|
44
60
|
/**
|
|
45
61
|
* 获取当前日记的上下各 n / 2 篇日记
|
|
46
62
|
*/
|
|
47
|
-
getMiddleList(id: string, size?: number): RequestProxyResult<{
|
|
63
|
+
getMiddleList(id: string, size?: number): import("../interfaces/request").RequestProxyResult<{
|
|
48
64
|
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
49
65
|
size: number;
|
|
50
|
-
}, {
|
|
66
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
51
67
|
[key: string]: any;
|
|
52
68
|
data: {
|
|
53
69
|
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
54
70
|
size: number;
|
|
55
71
|
};
|
|
72
|
+
} : ResponseWrapper extends {
|
|
73
|
+
data: {
|
|
74
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
75
|
+
size: number;
|
|
76
|
+
};
|
|
77
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
78
|
+
data: {
|
|
79
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
80
|
+
size: number;
|
|
81
|
+
};
|
|
56
82
|
}>;
|
|
57
83
|
/**
|
|
58
84
|
* 喜欢这篇日记
|
|
59
85
|
*/
|
|
60
|
-
likeIt(id: string | number): RequestProxyResult<never, {
|
|
86
|
+
likeIt(id: string | number): import("../interfaces/request").RequestProxyResult<never, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
61
87
|
[key: string]: any;
|
|
62
88
|
data: never;
|
|
89
|
+
} : ResponseWrapper extends {
|
|
90
|
+
data: never;
|
|
91
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
92
|
+
data: never;
|
|
63
93
|
}>;
|
|
64
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note.js","sourceRoot":"","sources":["../../controllers/note.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"note.js","sourceRoot":"","sources":["../../controllers/note.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAmB5C,MAAM,OAAO,cAAc;IAIzB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAHtC,SAAI,GAAG,OAAO,CAAA;QACd,SAAI,GAAG,MAAM,CAAA;QAGX,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IACD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAsB,CAAA;IACpD,CAAC;IAED;;;;OAIG;IAEH,WAAW,CAAC,EAAmB,EAAE,QAAiB;QAChD,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;YAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAqB;gBAC3D,MAAM,EAAE,EAAE,QAAQ,EAAE;aACrB,CAAC,CAAA;SACH;aAAM;YACL,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAqB,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;SACxE;IACH,CAAC;IAED;;OAEG;IAEH,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,UAA2B,EAAE;QAC3D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B;YAC/C,MAAM,EAAE;gBACN,IAAI;gBACJ,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC;gBACzB,MAAM;gBACN,SAAS;gBACT,IAAI;aACL;SACF,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,EAAU,EAAE,IAAI,GAAG,CAAC;QAChC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAG3B;YACD,MAAM,EAAE,EAAE,IAAI,EAAE;SACjB,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,EAAmB;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,EAAS,CAAA;IACzC,CAAC;CACF"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { IRequestAdapter } from '../interfaces/adapter';
|
|
1
2
|
import { IController } from '../interfaces/controller';
|
|
3
|
+
import { IRequestHandler } from '../interfaces/request';
|
|
4
|
+
import { SelectFields } from '../interfaces/types';
|
|
2
5
|
import { PaginateResult } from '../models/base';
|
|
3
6
|
import { PageModel } from '../models/page';
|
|
4
|
-
import { SelectFields } from '../types/helper';
|
|
5
7
|
import { HTTPClient } from '../core';
|
|
6
8
|
declare module '../core/client' {
|
|
7
|
-
interface HTTPClient {
|
|
8
|
-
page: PageController
|
|
9
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
10
|
+
page: PageController<ResponseWrapper>;
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
export declare type PageListOptions = {
|
|
@@ -13,33 +15,45 @@ export declare type PageListOptions = {
|
|
|
13
15
|
sortBy?: 'order' | 'subtitle' | 'title' | 'created' | 'modified';
|
|
14
16
|
sortOrder?: 1 | -1;
|
|
15
17
|
};
|
|
16
|
-
export declare class PageController implements IController {
|
|
18
|
+
export declare class PageController<ResponseWrapper> implements IController {
|
|
17
19
|
private readonly client;
|
|
18
20
|
constructor(client: HTTPClient);
|
|
19
21
|
base: string;
|
|
20
22
|
name: string;
|
|
21
|
-
get proxy():
|
|
23
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
22
24
|
/**
|
|
23
25
|
* 页面列表
|
|
24
26
|
*/
|
|
25
|
-
getList(page?: number, perPage?: number, options?: PageListOptions): import("../interfaces/request").RequestProxyResult<PaginateResult<PageModel>, {
|
|
27
|
+
getList(page?: number, perPage?: number, options?: PageListOptions): import("../interfaces/request").RequestProxyResult<PaginateResult<PageModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
26
28
|
[key: string]: any;
|
|
27
29
|
data: PaginateResult<PageModel>;
|
|
30
|
+
} : ResponseWrapper extends {
|
|
31
|
+
data: PaginateResult<PageModel>;
|
|
32
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
33
|
+
data: PaginateResult<PageModel>;
|
|
28
34
|
}>;
|
|
29
35
|
/**
|
|
30
36
|
* 页面详情
|
|
31
37
|
*/
|
|
32
|
-
getById(id: string): import("../interfaces/request").RequestProxyResult<PageModel, {
|
|
38
|
+
getById(id: string): import("../interfaces/request").RequestProxyResult<PageModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
33
39
|
[key: string]: any;
|
|
34
40
|
data: PageModel;
|
|
41
|
+
} : ResponseWrapper extends {
|
|
42
|
+
data: PageModel;
|
|
43
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
44
|
+
data: PageModel;
|
|
35
45
|
}>;
|
|
36
46
|
/**
|
|
37
47
|
* 根据路径获取页面
|
|
38
48
|
* @param slug 路径
|
|
39
49
|
* @returns
|
|
40
50
|
*/
|
|
41
|
-
getBySlug(slug: string): import("../interfaces/request").RequestProxyResult<PageModel, {
|
|
51
|
+
getBySlug(slug: string): import("../interfaces/request").RequestProxyResult<PageModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
42
52
|
[key: string]: any;
|
|
43
53
|
data: PageModel;
|
|
54
|
+
} : ResponseWrapper extends {
|
|
55
|
+
data: PageModel;
|
|
56
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
57
|
+
data: PageModel;
|
|
44
58
|
}>;
|
|
45
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../controllers/page.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../controllers/page.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAkB5C,MAAM,OAAO,cAAc;IACzB,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAG/C,SAAI,GAAG,OAAO,CAAA;QACd,SAAI,GAAG,MAAM,CAAA;QAHX,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAGD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IACD;;OAEG;IACH,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,UAA2B,EAAE;QAC3D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B;YAC/C,MAAM,EAAE;gBACN,IAAI;gBACJ,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC;gBACzB,MAAM;gBACN,SAAS;aACV;SACF,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,EAAa,CAAA;IACxC,CAAC;IACD;;;;OAIG;IACH,SAAS,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAY,EAAE,CAAC,CAAA;IACjD,CAAC;CACF"}
|