@mx-space/api-client 1.4.3 → 1.5.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.
- package/controllers/activity.ts +41 -0
- package/controllers/aggregate.ts +2 -1
- package/controllers/index.ts +4 -0
- package/dist/adaptors/axios.global.js +4 -4
- package/dist/index.cjs +25 -0
- package/dist/index.d.cts +27 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.global.js +23 -0
- package/dist/index.js +24 -0
- package/esm/apps/core/src/modules/subscribe/subscribe.constant.d.ts +12 -0
- package/esm/apps/core/src/modules/subscribe/subscribe.constant.js +16 -0
- package/esm/apps/core/src/modules/subscribe/subscribe.constant.js.map +1 -0
- package/esm/packages/api-client/adaptors/axios.d.ts +4 -0
- package/esm/packages/api-client/adaptors/axios.js +37 -0
- package/esm/packages/api-client/adaptors/axios.js.map +1 -0
- package/esm/packages/api-client/adaptors/fetch.d.ts +2 -0
- package/esm/packages/api-client/adaptors/fetch.js +95 -0
- package/esm/packages/api-client/adaptors/fetch.js.map +1 -0
- package/esm/packages/api-client/adaptors/ky.d.ts +23 -0
- package/esm/packages/api-client/adaptors/ky.js +62 -0
- package/esm/packages/api-client/adaptors/ky.js.map +1 -0
- package/esm/packages/api-client/adaptors/umi-request.d.ts +4 -0
- package/esm/packages/api-client/adaptors/umi-request.js +31 -0
- package/esm/packages/api-client/adaptors/umi-request.js.map +1 -0
- package/esm/packages/api-client/controllers/aggregate.d.ts +64 -0
- package/esm/packages/api-client/controllers/aggregate.js +46 -0
- package/esm/packages/api-client/controllers/aggregate.js.map +1 -0
- package/esm/packages/api-client/controllers/base.d.ts +43 -0
- package/esm/packages/api-client/controllers/base.js +27 -0
- package/esm/packages/api-client/controllers/base.js.map +1 -0
- package/esm/packages/api-client/controllers/category.d.ts +120 -0
- package/esm/packages/api-client/controllers/category.js +68 -0
- package/esm/packages/api-client/controllers/category.js.map +1 -0
- package/esm/packages/api-client/controllers/comment.d.ts +81 -0
- package/esm/packages/api-client/controllers/comment.js +47 -0
- package/esm/packages/api-client/controllers/comment.js.map +1 -0
- package/esm/packages/api-client/controllers/index.d.ts +19 -0
- package/esm/packages/api-client/controllers/index.js +60 -0
- package/esm/packages/api-client/controllers/index.js.map +1 -0
- package/esm/packages/api-client/controllers/link.d.ts +20 -0
- package/esm/packages/api-client/controllers/link.js +21 -0
- package/esm/packages/api-client/controllers/link.js.map +1 -0
- package/esm/packages/api-client/controllers/note.d.ts +103 -0
- package/esm/packages/api-client/controllers/note.js +68 -0
- package/esm/packages/api-client/controllers/note.js.map +1 -0
- package/esm/packages/api-client/controllers/page.d.ts +59 -0
- package/esm/packages/api-client/controllers/page.js +42 -0
- package/esm/packages/api-client/controllers/page.js.map +1 -0
- package/esm/packages/api-client/controllers/post.d.ts +72 -0
- package/esm/packages/api-client/controllers/post.js +52 -0
- package/esm/packages/api-client/controllers/post.js.map +1 -0
- package/esm/packages/api-client/controllers/project.d.ts +15 -0
- package/esm/packages/api-client/controllers/project.js +12 -0
- package/esm/packages/api-client/controllers/project.js.map +1 -0
- package/esm/packages/api-client/controllers/recently.d.ts +110 -0
- package/esm/packages/api-client/controllers/recently.js +49 -0
- package/esm/packages/api-client/controllers/recently.js.map +1 -0
- package/esm/packages/api-client/controllers/say.d.ts +37 -0
- package/esm/packages/api-client/controllers/say.js +21 -0
- package/esm/packages/api-client/controllers/say.js.map +1 -0
- package/esm/packages/api-client/controllers/search.d.ts +87 -0
- package/esm/packages/api-client/controllers/search.js +28 -0
- package/esm/packages/api-client/controllers/search.js.map +1 -0
- package/esm/packages/api-client/controllers/severless.d.ts +24 -0
- package/esm/packages/api-client/controllers/severless.js +16 -0
- package/esm/packages/api-client/controllers/severless.js.map +1 -0
- package/esm/packages/api-client/controllers/snippet.d.ts +24 -0
- package/esm/packages/api-client/controllers/snippet.js +19 -0
- package/esm/packages/api-client/controllers/snippet.js.map +1 -0
- package/esm/packages/api-client/controllers/subscribe.d.ts +64 -0
- package/esm/packages/api-client/controllers/subscribe.js +35 -0
- package/esm/packages/api-client/controllers/subscribe.js.map +1 -0
- package/esm/packages/api-client/controllers/topic.d.ts +26 -0
- package/esm/packages/api-client/controllers/topic.js +18 -0
- package/esm/packages/api-client/controllers/topic.js.map +1 -0
- package/esm/packages/api-client/controllers/user.d.ts +70 -0
- package/esm/packages/api-client/controllers/user.js +40 -0
- package/esm/packages/api-client/controllers/user.js.map +1 -0
- package/esm/packages/api-client/core/attach-request.d.ts +2 -0
- package/esm/packages/api-client/core/attach-request.js +36 -0
- package/esm/packages/api-client/core/attach-request.js.map +1 -0
- package/esm/packages/api-client/core/client.d.ts +29 -0
- package/esm/packages/api-client/core/client.js +193 -0
- package/esm/packages/api-client/core/client.js.map +1 -0
- package/esm/packages/api-client/core/error.d.ts +6 -0
- package/esm/packages/api-client/core/error.js +9 -0
- package/esm/packages/api-client/core/error.js.map +1 -0
- package/esm/packages/api-client/core/index.d.ts +2 -0
- package/esm/packages/api-client/core/index.js +3 -0
- package/esm/packages/api-client/core/index.js.map +1 -0
- package/esm/packages/api-client/dtos/comment.d.ts +8 -0
- package/esm/packages/api-client/dtos/comment.js +2 -0
- package/esm/packages/api-client/dtos/comment.js.map +1 -0
- package/esm/packages/api-client/dtos/index.d.ts +1 -0
- package/esm/packages/api-client/dtos/index.js +2 -0
- package/esm/packages/api-client/dtos/index.js.map +1 -0
- package/esm/packages/api-client/index.d.ts +8 -0
- package/esm/packages/api-client/index.js +9 -0
- package/esm/packages/api-client/index.js.map +1 -0
- package/esm/packages/api-client/interfaces/adapter.d.ts +14 -0
- package/esm/packages/api-client/interfaces/adapter.js +2 -0
- package/esm/packages/api-client/interfaces/adapter.js.map +1 -0
- package/esm/packages/api-client/interfaces/client.d.ts +13 -0
- package/esm/packages/api-client/interfaces/client.js +2 -0
- package/esm/packages/api-client/interfaces/client.js.map +1 -0
- package/esm/packages/api-client/interfaces/controller.d.ts +4 -0
- package/esm/packages/api-client/interfaces/controller.js +2 -0
- package/esm/packages/api-client/interfaces/controller.js.map +1 -0
- package/esm/packages/api-client/interfaces/instance.d.ts +7 -0
- package/esm/packages/api-client/interfaces/instance.js +2 -0
- package/esm/packages/api-client/interfaces/instance.js.map +1 -0
- package/esm/packages/api-client/interfaces/options.d.ts +1 -0
- package/esm/packages/api-client/interfaces/options.js +2 -0
- package/esm/packages/api-client/interfaces/options.js.map +1 -0
- package/esm/packages/api-client/interfaces/params.d.ts +4 -0
- package/esm/packages/api-client/interfaces/params.js +2 -0
- package/esm/packages/api-client/interfaces/params.js.map +1 -0
- package/esm/packages/api-client/interfaces/request.d.ts +44 -0
- package/esm/packages/api-client/interfaces/request.js +2 -0
- package/esm/packages/api-client/interfaces/request.js.map +1 -0
- package/esm/packages/api-client/interfaces/types.d.ts +2 -0
- package/esm/packages/api-client/interfaces/types.js +2 -0
- package/esm/packages/api-client/interfaces/types.js.map +1 -0
- package/esm/packages/api-client/models/aggregate.d.ts +67 -0
- package/esm/packages/api-client/models/aggregate.js +6 -0
- package/esm/packages/api-client/models/aggregate.js.map +1 -0
- package/esm/packages/api-client/models/base.d.ts +40 -0
- package/esm/packages/api-client/models/base.js +2 -0
- package/esm/packages/api-client/models/base.js.map +1 -0
- package/esm/packages/api-client/models/category.d.ts +22 -0
- package/esm/packages/api-client/models/category.js +6 -0
- package/esm/packages/api-client/models/category.js.map +1 -0
- package/esm/packages/api-client/models/comment.d.ts +39 -0
- package/esm/packages/api-client/models/comment.js +13 -0
- package/esm/packages/api-client/models/comment.js.map +1 -0
- package/esm/packages/api-client/models/index.d.ts +16 -0
- package/esm/packages/api-client/models/index.js +17 -0
- package/esm/packages/api-client/models/index.js.map +1 -0
- package/esm/packages/api-client/models/link.d.ts +22 -0
- package/esm/packages/api-client/models/link.js +14 -0
- package/esm/packages/api-client/models/link.js.map +1 -0
- package/esm/packages/api-client/models/note.d.ts +38 -0
- package/esm/packages/api-client/models/note.js +2 -0
- package/esm/packages/api-client/models/note.js.map +1 -0
- package/esm/packages/api-client/models/page.d.ts +14 -0
- package/esm/packages/api-client/models/page.js +7 -0
- package/esm/packages/api-client/models/page.js.map +1 -0
- package/esm/packages/api-client/models/post.d.ts +17 -0
- package/esm/packages/api-client/models/post.js +2 -0
- package/esm/packages/api-client/models/post.js.map +1 -0
- package/esm/packages/api-client/models/project.d.ts +11 -0
- package/esm/packages/api-client/models/project.js +2 -0
- package/esm/packages/api-client/models/project.js.map +1 -0
- package/esm/packages/api-client/models/recently.d.ts +20 -0
- package/esm/packages/api-client/models/recently.js +7 -0
- package/esm/packages/api-client/models/recently.js.map +1 -0
- package/esm/packages/api-client/models/say.d.ts +6 -0
- package/esm/packages/api-client/models/say.js +2 -0
- package/esm/packages/api-client/models/say.js.map +1 -0
- package/esm/packages/api-client/models/setting.d.ts +66 -0
- package/esm/packages/api-client/models/setting.js +2 -0
- package/esm/packages/api-client/models/setting.js.map +1 -0
- package/esm/packages/api-client/models/snippet.d.ts +18 -0
- package/esm/packages/api-client/models/snippet.js +8 -0
- package/esm/packages/api-client/models/snippet.js.map +1 -0
- package/esm/packages/api-client/models/subscribe.d.ts +3 -0
- package/esm/packages/api-client/models/subscribe.js +2 -0
- package/esm/packages/api-client/models/subscribe.js.map +1 -0
- package/esm/packages/api-client/models/topic.d.ts +8 -0
- package/esm/packages/api-client/models/topic.js +2 -0
- package/esm/packages/api-client/models/topic.js.map +1 -0
- package/esm/packages/api-client/models/user.d.ts +21 -0
- package/esm/packages/api-client/models/user.js +2 -0
- package/esm/packages/api-client/models/user.js.map +1 -0
- package/esm/packages/api-client/tsup.config.d.ts +2 -0
- package/esm/packages/api-client/tsup.config.js +14 -0
- package/esm/packages/api-client/tsup.config.js.map +1 -0
- package/esm/packages/api-client/utils/auto-bind.d.ts +4 -0
- package/esm/packages/api-client/utils/auto-bind.js +36 -0
- package/esm/packages/api-client/utils/auto-bind.js.map +1 -0
- package/esm/packages/api-client/utils/camelcase-keys.d.ts +6 -0
- package/esm/packages/api-client/utils/camelcase-keys.js +23 -0
- package/esm/packages/api-client/utils/camelcase-keys.js.map +1 -0
- package/esm/packages/api-client/utils/index.d.ts +5 -0
- package/esm/packages/api-client/utils/index.js +43 -0
- package/esm/packages/api-client/utils/index.js.map +1 -0
- package/esm/packages/api-client/utils/path.d.ts +1 -0
- package/esm/packages/api-client/utils/path.js +7 -0
- package/esm/packages/api-client/utils/path.js.map +1 -0
- package/esm/packages/api-client/vitest.config.d.ts +2 -0
- package/esm/packages/api-client/vitest.config.js +15 -0
- package/esm/packages/api-client/vitest.config.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { extend } from 'umi-request';
|
|
2
|
+
// eslint-disable-next-line spaced-comment
|
|
3
|
+
const $http = /*#__PURE__*/ extend({
|
|
4
|
+
getResponse: true,
|
|
5
|
+
requestType: 'json',
|
|
6
|
+
responseType: 'json',
|
|
7
|
+
});
|
|
8
|
+
export const umiAdaptor = Object.preventExtensions({
|
|
9
|
+
get default() {
|
|
10
|
+
return $http;
|
|
11
|
+
},
|
|
12
|
+
responseWrapper: {},
|
|
13
|
+
get(url, options) {
|
|
14
|
+
return $http.get(url, options);
|
|
15
|
+
},
|
|
16
|
+
post(url, options) {
|
|
17
|
+
return $http.post(url, options);
|
|
18
|
+
},
|
|
19
|
+
put(url, options) {
|
|
20
|
+
return $http.put(url, options);
|
|
21
|
+
},
|
|
22
|
+
delete(url, options) {
|
|
23
|
+
return $http.delete(url, options);
|
|
24
|
+
},
|
|
25
|
+
patch(url, options) {
|
|
26
|
+
return $http.patch(url, options);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
// eslint-disable-next-line import/no-default-export
|
|
30
|
+
export default umiAdaptor;
|
|
31
|
+
//# sourceMappingURL=umi-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"umi-request.js","sourceRoot":"","sources":["../../../../adaptors/umi-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAIpC,0CAA0C;AAC1C,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC;IACjC,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;AAEF,oDAAoD;AACpD,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
|
+
import type { IController } from '~/interfaces/controller';
|
|
3
|
+
import type { SortOrder } from '~/interfaces/options';
|
|
4
|
+
import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request';
|
|
5
|
+
import type { AggregateRootWithTheme, AggregateStat, AggregateTop, TimelineData, TimelineType } from '~/models/aggregate';
|
|
6
|
+
import type { HTTPClient } from '../core';
|
|
7
|
+
declare module '../core/client' {
|
|
8
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
|
+
aggregate: AggregateController<ResponseWrapper>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare class AggregateController<ResponseWrapper> implements IController {
|
|
13
|
+
private client;
|
|
14
|
+
base: string;
|
|
15
|
+
name: string;
|
|
16
|
+
constructor(client: HTTPClient);
|
|
17
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
18
|
+
/**
|
|
19
|
+
* 获取聚合数据
|
|
20
|
+
*/
|
|
21
|
+
getAggregateData<Theme>(theme?: string): RequestProxyResult<AggregateRootWithTheme<Theme>, ResponseWrapper>;
|
|
22
|
+
/**
|
|
23
|
+
* 获取最新发布的内容
|
|
24
|
+
*/
|
|
25
|
+
getTop(size?: number): RequestProxyResult<AggregateTop, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
data: AggregateTop;
|
|
28
|
+
} : ResponseWrapper extends {
|
|
29
|
+
data: AggregateTop;
|
|
30
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
31
|
+
data: AggregateTop;
|
|
32
|
+
}>;
|
|
33
|
+
getTimeline(options?: {
|
|
34
|
+
sort?: SortOrder;
|
|
35
|
+
type?: TimelineType;
|
|
36
|
+
year?: number;
|
|
37
|
+
}): RequestProxyResult<{
|
|
38
|
+
data: TimelineData;
|
|
39
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
data: {
|
|
42
|
+
data: TimelineData;
|
|
43
|
+
};
|
|
44
|
+
} : ResponseWrapper extends {
|
|
45
|
+
data: {
|
|
46
|
+
data: TimelineData;
|
|
47
|
+
};
|
|
48
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
49
|
+
data: {
|
|
50
|
+
data: TimelineData;
|
|
51
|
+
};
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* 获取聚合数据统计
|
|
55
|
+
*/
|
|
56
|
+
getStat(): RequestProxyResult<AggregateStat, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
data: AggregateStat;
|
|
59
|
+
} : ResponseWrapper extends {
|
|
60
|
+
data: AggregateStat;
|
|
61
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
62
|
+
data: AggregateStat;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { sortOrderToNumber } from '~/utils';
|
|
2
|
+
import { autoBind } from '~/utils/auto-bind';
|
|
3
|
+
export class AggregateController {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
this.base = 'aggregate';
|
|
7
|
+
this.name = 'aggregate';
|
|
8
|
+
autoBind(this);
|
|
9
|
+
}
|
|
10
|
+
get proxy() {
|
|
11
|
+
return this.client.proxy(this.base);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 获取聚合数据
|
|
15
|
+
*/
|
|
16
|
+
getAggregateData(theme) {
|
|
17
|
+
return this.proxy.get({
|
|
18
|
+
params: {
|
|
19
|
+
theme,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 获取最新发布的内容
|
|
25
|
+
*/
|
|
26
|
+
getTop(size = 5) {
|
|
27
|
+
return this.proxy.top.get({ params: { size } });
|
|
28
|
+
}
|
|
29
|
+
getTimeline(options) {
|
|
30
|
+
const { sort, type, year } = options || {};
|
|
31
|
+
return this.proxy.timeline.get({
|
|
32
|
+
params: {
|
|
33
|
+
sort: sort && sortOrderToNumber(sort),
|
|
34
|
+
type,
|
|
35
|
+
year,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 获取聚合数据统计
|
|
41
|
+
*/
|
|
42
|
+
getStat() {
|
|
43
|
+
return this.proxy.stat.get();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=aggregate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregate.js","sourceRoot":"","sources":["../../../../controllers/aggregate.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAW5C,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,CACd,KAAc;QAEd,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgC;YACnD,MAAM,EAAE;gBACN,KAAK;aACN;SACF,CAAC,CAAA;IACJ,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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request';
|
|
2
|
+
import type { PaginateResult } from '~/models/base';
|
|
3
|
+
import type { HTTPClient } from '../core';
|
|
4
|
+
export type SortOptions = {
|
|
5
|
+
sortBy?: string;
|
|
6
|
+
sortOrder?: 1 | -1 | 'asc' | 'desc';
|
|
7
|
+
};
|
|
8
|
+
export declare abstract class BaseCrudController<T, ResponseWrapper> {
|
|
9
|
+
protected client: HTTPClient;
|
|
10
|
+
base: string;
|
|
11
|
+
constructor(client: HTTPClient);
|
|
12
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
13
|
+
getById(id: string): RequestProxyResult<T, ResponseWrapper>;
|
|
14
|
+
getAll(): RequestProxyResult<{
|
|
15
|
+
data: T[];
|
|
16
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
data: {
|
|
19
|
+
data: T[];
|
|
20
|
+
};
|
|
21
|
+
} : ResponseWrapper extends {
|
|
22
|
+
data: {
|
|
23
|
+
data: T[];
|
|
24
|
+
};
|
|
25
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
26
|
+
data: {
|
|
27
|
+
data: T[];
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* 带分页的查询
|
|
32
|
+
* @param page
|
|
33
|
+
* @param perPage
|
|
34
|
+
*/
|
|
35
|
+
getAllPaginated(page?: number, perPage?: number, sortOption?: SortOptions): RequestProxyResult<PaginateResult<T>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
data: PaginateResult<T>;
|
|
38
|
+
} : ResponseWrapper extends {
|
|
39
|
+
data: PaginateResult<T>;
|
|
40
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
41
|
+
data: PaginateResult<T>;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind';
|
|
2
|
+
export class BaseCrudController {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
autoBind(this);
|
|
6
|
+
}
|
|
7
|
+
get proxy() {
|
|
8
|
+
return this.client.proxy(this.base);
|
|
9
|
+
}
|
|
10
|
+
getById(id) {
|
|
11
|
+
return this.proxy(id).get();
|
|
12
|
+
}
|
|
13
|
+
getAll() {
|
|
14
|
+
return this.proxy.all.get();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 带分页的查询
|
|
18
|
+
* @param page
|
|
19
|
+
* @param perPage
|
|
20
|
+
*/
|
|
21
|
+
getAllPaginated(page, perPage, sortOption) {
|
|
22
|
+
return this.proxy.get({
|
|
23
|
+
params: { page, size: perPage, ...sortOption },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../controllers/base.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAM5C,MAAM,OAAgB,kBAAkB;IAEtC,YAAsB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QACtC,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,OAAO,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,EAAK,CAAA;IAChC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAiB,CAAA;IAC5C,CAAC;IACD;;;;OAIG;IACH,eAAe,CAAC,IAAa,EAAE,OAAgB,EAAE,UAAwB;QACvE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAoB;YACvC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE;SAC/C,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
|
+
import type { IController } from '~/interfaces/controller';
|
|
3
|
+
import type { IRequestHandler, RequestProxyResult, ResponseProxyExtraRaw } from '~/interfaces/request';
|
|
4
|
+
import type { HTTPClient } from '../core/client';
|
|
5
|
+
import type { CategoryModel, CategoryWithChildrenModel, TagModel } from '../models/category';
|
|
6
|
+
import type { PostModel } from '../models/post';
|
|
7
|
+
import { CategoryType } from '../models/category';
|
|
8
|
+
declare module '../core/client' {
|
|
9
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
10
|
+
category: CategoryController<ResponseWrapper>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare class CategoryController<ResponseWrapper> implements IController {
|
|
14
|
+
private client;
|
|
15
|
+
name: string;
|
|
16
|
+
base: string;
|
|
17
|
+
constructor(client: HTTPClient);
|
|
18
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
19
|
+
getAllCategories(): RequestProxyResult<{
|
|
20
|
+
data: CategoryModel[];
|
|
21
|
+
}, ResponseWrapper>;
|
|
22
|
+
getAllTags(): RequestProxyResult<{
|
|
23
|
+
data: TagModel[];
|
|
24
|
+
}, ResponseWrapper>;
|
|
25
|
+
getCategoryDetail(id: string): Promise<ResponseProxyExtraRaw<CategoryWithChildrenModel>>;
|
|
26
|
+
getCategoryDetail(ids: string[]): Promise<ResponseProxyExtraRaw<Map<string, CategoryWithChildrenModel>>>;
|
|
27
|
+
getCategoryByIdOrSlug(idOrSlug: string): Promise<CategoryModel & {
|
|
28
|
+
children: Pick<PostModel, "id" | "created" | "modified" | "title" | "slug">[];
|
|
29
|
+
} & {
|
|
30
|
+
$raw: ResponseWrapper extends {
|
|
31
|
+
data: infer T;
|
|
32
|
+
} ? ResponseWrapper : ResponseWrapper extends unknown ? {
|
|
33
|
+
[i: string]: any;
|
|
34
|
+
data: (ResponseWrapper extends unknown ? {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
data: CategoryWithChildrenModel;
|
|
37
|
+
} : ResponseWrapper extends {
|
|
38
|
+
data: CategoryWithChildrenModel;
|
|
39
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
40
|
+
data: CategoryWithChildrenModel;
|
|
41
|
+
}) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
data: CategoryWithChildrenModel;
|
|
44
|
+
} : ResponseWrapper extends {
|
|
45
|
+
data: CategoryWithChildrenModel;
|
|
46
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
47
|
+
data: CategoryWithChildrenModel;
|
|
48
|
+
}) ? T_1 extends unknown ? {
|
|
49
|
+
type: CategoryType;
|
|
50
|
+
count: number;
|
|
51
|
+
slug: string;
|
|
52
|
+
name: string;
|
|
53
|
+
created: string;
|
|
54
|
+
id: string;
|
|
55
|
+
children: Pick<PostModel, "id" | "created" | "modified" | "title" | "slug">[];
|
|
56
|
+
} : T_1 : never : never;
|
|
57
|
+
} : ResponseWrapper;
|
|
58
|
+
$request: {
|
|
59
|
+
[k: string]: string;
|
|
60
|
+
path: string;
|
|
61
|
+
method: string;
|
|
62
|
+
};
|
|
63
|
+
$serialized: CategoryWithChildrenModel;
|
|
64
|
+
}>;
|
|
65
|
+
getTagByName(name: string): Promise<{
|
|
66
|
+
tag: string;
|
|
67
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
68
|
+
} & {
|
|
69
|
+
$raw: ResponseWrapper extends {
|
|
70
|
+
data: infer T;
|
|
71
|
+
} ? ResponseWrapper : ResponseWrapper extends unknown ? {
|
|
72
|
+
[i: string]: any;
|
|
73
|
+
data: (ResponseWrapper extends unknown ? {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
data: {
|
|
76
|
+
tag: string;
|
|
77
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
78
|
+
};
|
|
79
|
+
} : ResponseWrapper extends {
|
|
80
|
+
data: {
|
|
81
|
+
tag: string;
|
|
82
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
83
|
+
};
|
|
84
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
85
|
+
data: {
|
|
86
|
+
tag: string;
|
|
87
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
88
|
+
};
|
|
89
|
+
}) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
|
|
90
|
+
[key: string]: any;
|
|
91
|
+
data: {
|
|
92
|
+
tag: string;
|
|
93
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
94
|
+
};
|
|
95
|
+
} : ResponseWrapper extends {
|
|
96
|
+
data: {
|
|
97
|
+
tag: string;
|
|
98
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
99
|
+
};
|
|
100
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
101
|
+
data: {
|
|
102
|
+
tag: string;
|
|
103
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
104
|
+
};
|
|
105
|
+
}) ? T_1 extends unknown ? {
|
|
106
|
+
tag: string;
|
|
107
|
+
data: Pick<PostModel, "id" | "category" | "created" | "title" | "slug">[];
|
|
108
|
+
} : T_1 : never : never;
|
|
109
|
+
} : ResponseWrapper;
|
|
110
|
+
$request: {
|
|
111
|
+
[k: string]: string;
|
|
112
|
+
path: string;
|
|
113
|
+
method: string;
|
|
114
|
+
};
|
|
115
|
+
$serialized: {
|
|
116
|
+
tag: string;
|
|
117
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
118
|
+
};
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { attachRawFromOneToAnthor, destructureData } from '~/utils';
|
|
2
|
+
import { autoBind } from '~/utils/auto-bind';
|
|
3
|
+
import { RequestError } from '../core/error';
|
|
4
|
+
import { CategoryType } from '../models/category';
|
|
5
|
+
export class CategoryController {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
this.name = 'category';
|
|
9
|
+
this.base = 'categories';
|
|
10
|
+
autoBind(this);
|
|
11
|
+
}
|
|
12
|
+
get proxy() {
|
|
13
|
+
return this.client.proxy(this.base);
|
|
14
|
+
}
|
|
15
|
+
getAllCategories() {
|
|
16
|
+
return this.proxy.get({
|
|
17
|
+
params: {
|
|
18
|
+
type: CategoryType.Category,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
getAllTags() {
|
|
23
|
+
return this.proxy.get({
|
|
24
|
+
params: {
|
|
25
|
+
type: CategoryType.Tag,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async getCategoryDetail(ids) {
|
|
30
|
+
if (typeof ids === 'string') {
|
|
31
|
+
const data = await this.proxy.get({
|
|
32
|
+
params: {
|
|
33
|
+
ids,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const result = Object.values(data.entries)[0];
|
|
37
|
+
attachRawFromOneToAnthor(data, result);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
else if (Array.isArray(ids)) {
|
|
41
|
+
const data = await this.proxy.get({
|
|
42
|
+
params: {
|
|
43
|
+
ids: ids.join(','),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const entries = data?.entries;
|
|
47
|
+
if (!entries) {
|
|
48
|
+
throw new RequestError('data structure error', 500, data.$request.path, data);
|
|
49
|
+
}
|
|
50
|
+
const map = new Map(Object.entries(entries).map(([id, value]) => [id.toLowerCase(), value]));
|
|
51
|
+
attachRawFromOneToAnthor(data, map);
|
|
52
|
+
return map;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async getCategoryByIdOrSlug(idOrSlug) {
|
|
56
|
+
const res = await this.proxy(idOrSlug).get();
|
|
57
|
+
return destructureData(res);
|
|
58
|
+
}
|
|
59
|
+
async getTagByName(name) {
|
|
60
|
+
const res = await this.proxy(name).get({
|
|
61
|
+
params: {
|
|
62
|
+
tag: 1,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
return res;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=category.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../../../controllers/category.ts"],"names":[],"mappings":"AAgBA,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,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAWjD,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;iBACJ;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"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
|
+
import type { IController } from '~/interfaces/controller';
|
|
3
|
+
import type { PaginationParams } from '~/interfaces/params';
|
|
4
|
+
import type { IRequestHandler } from '~/interfaces/request';
|
|
5
|
+
import type { PaginateResult } from '~/models/base';
|
|
6
|
+
import type { CommentModel } from '~/models/comment';
|
|
7
|
+
import type { HTTPClient } from '../core';
|
|
8
|
+
import type { CommentDto } from '../dtos/comment';
|
|
9
|
+
declare module '../core/client' {
|
|
10
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
11
|
+
comment: CommentController<ResponseWrapper>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare class CommentController<ResponseWrapper> implements IController {
|
|
15
|
+
private readonly client;
|
|
16
|
+
base: string;
|
|
17
|
+
name: string;
|
|
18
|
+
constructor(client: HTTPClient);
|
|
19
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
20
|
+
/**
|
|
21
|
+
* 根据 comment id 获取评论, 包括子评论
|
|
22
|
+
*/
|
|
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
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* 获取文章的评论列表
|
|
41
|
+
* @param refId 文章 Id
|
|
42
|
+
*/
|
|
43
|
+
getByRefId(refId: string, pagination?: PaginationParams): import("~/interfaces/request").RequestProxyResult<PaginateResult<CommentModel & {
|
|
44
|
+
ref: string;
|
|
45
|
+
}>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
data: PaginateResult<CommentModel & {
|
|
48
|
+
ref: string;
|
|
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
|
+
}>;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* 评论
|
|
61
|
+
*/
|
|
62
|
+
comment(refId: string, data: CommentDto): import("~/interfaces/request").RequestProxyResult<CommentModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
data: CommentModel;
|
|
65
|
+
} : ResponseWrapper extends {
|
|
66
|
+
data: CommentModel;
|
|
67
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
68
|
+
data: CommentModel;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* 回复评论
|
|
72
|
+
*/
|
|
73
|
+
reply(commentId: string, data: CommentDto): import("~/interfaces/request").RequestProxyResult<CommentModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
data: CommentModel;
|
|
76
|
+
} : ResponseWrapper extends {
|
|
77
|
+
data: CommentModel;
|
|
78
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
79
|
+
data: CommentModel;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind';
|
|
2
|
+
export class CommentController {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
this.base = 'comments';
|
|
6
|
+
this.name = 'comment';
|
|
7
|
+
autoBind(this);
|
|
8
|
+
}
|
|
9
|
+
get proxy() {
|
|
10
|
+
return this.client.proxy(this.base);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 根据 comment id 获取评论, 包括子评论
|
|
14
|
+
*/
|
|
15
|
+
getById(id) {
|
|
16
|
+
return this.proxy(id).get();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 获取文章的评论列表
|
|
20
|
+
* @param refId 文章 Id
|
|
21
|
+
*/
|
|
22
|
+
getByRefId(refId, pagination = {}) {
|
|
23
|
+
const { page, size } = pagination;
|
|
24
|
+
return this.proxy
|
|
25
|
+
.ref(refId)
|
|
26
|
+
.get({
|
|
27
|
+
params: { page: page || 1, size: size || 10 },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 评论
|
|
32
|
+
*/
|
|
33
|
+
comment(refId, data) {
|
|
34
|
+
return this.proxy(refId).post({
|
|
35
|
+
data,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 回复评论
|
|
40
|
+
*/
|
|
41
|
+
reply(commentId, data) {
|
|
42
|
+
return this.proxy.reply(commentId).post({
|
|
43
|
+
data,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../../controllers/comment.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAW5C,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AggregateController } from './aggregate';
|
|
2
|
+
import { CategoryController } from './category';
|
|
3
|
+
import { CommentController } from './comment';
|
|
4
|
+
import { LinkController } from './link';
|
|
5
|
+
import { NoteController } from './note';
|
|
6
|
+
import { PageController } from './page';
|
|
7
|
+
import { PostController } from './post';
|
|
8
|
+
import { ProjectController } from './project';
|
|
9
|
+
import { RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController } from './recently';
|
|
10
|
+
import { SayController } from './say';
|
|
11
|
+
import { SearchController } from './search';
|
|
12
|
+
import { ServerlessController } from './severless';
|
|
13
|
+
import { SnippetController } from './snippet';
|
|
14
|
+
import { SubscribeController } from './subscribe';
|
|
15
|
+
import { TopicController } from './topic';
|
|
16
|
+
import { UserController } from './user';
|
|
17
|
+
export declare const allControllers: (typeof AggregateController | typeof CategoryController | typeof CommentController | typeof LinkController | typeof NoteController | typeof PageController | typeof PostController | typeof ProjectController | typeof RecentlyController | typeof SayController | typeof SearchController | typeof ServerlessController | typeof SnippetController | typeof SubscribeController | typeof TopicController | typeof UserController)[];
|
|
18
|
+
export declare const allContollerNames: readonly ["aggregate", "category", "comment", "link", "note", "page", "post", "project", "topic", "recently", "say", "search", "snippet", "serverless", "subscribe", "user", "friend", "master", "shorthand"];
|
|
19
|
+
export { AggregateController, CategoryController, CommentController, LinkController, NoteController, PageController, PostController, ProjectController, RecentlyController, SayController, SearchController, SnippetController, ServerlessController, SubscribeController, UserController, TopicController, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AggregateController } from './aggregate';
|
|
2
|
+
import { CategoryController } from './category';
|
|
3
|
+
import { CommentController } from './comment';
|
|
4
|
+
import { LinkController } from './link';
|
|
5
|
+
import { NoteController } from './note';
|
|
6
|
+
import { PageController } from './page';
|
|
7
|
+
import { PostController } from './post';
|
|
8
|
+
import { ProjectController } from './project';
|
|
9
|
+
import { RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, } from './recently';
|
|
10
|
+
import { SayController } from './say';
|
|
11
|
+
import { SearchController } from './search';
|
|
12
|
+
import { ServerlessController } from './severless';
|
|
13
|
+
import { SnippetController } from './snippet';
|
|
14
|
+
import { SubscribeController } from './subscribe';
|
|
15
|
+
import { TopicController } from './topic';
|
|
16
|
+
import { UserController } from './user';
|
|
17
|
+
export const allControllers = [
|
|
18
|
+
AggregateController,
|
|
19
|
+
CategoryController,
|
|
20
|
+
CommentController,
|
|
21
|
+
LinkController,
|
|
22
|
+
NoteController,
|
|
23
|
+
PageController,
|
|
24
|
+
PostController,
|
|
25
|
+
ProjectController,
|
|
26
|
+
RecentlyController,
|
|
27
|
+
TopicController,
|
|
28
|
+
SayController,
|
|
29
|
+
SearchController,
|
|
30
|
+
SnippetController,
|
|
31
|
+
ServerlessController,
|
|
32
|
+
SubscribeController,
|
|
33
|
+
UserController,
|
|
34
|
+
];
|
|
35
|
+
export const allContollerNames = [
|
|
36
|
+
'aggregate',
|
|
37
|
+
'category',
|
|
38
|
+
'comment',
|
|
39
|
+
'link',
|
|
40
|
+
'note',
|
|
41
|
+
'page',
|
|
42
|
+
'post',
|
|
43
|
+
'project',
|
|
44
|
+
'topic',
|
|
45
|
+
'recently',
|
|
46
|
+
'say',
|
|
47
|
+
'search',
|
|
48
|
+
'snippet',
|
|
49
|
+
'serverless',
|
|
50
|
+
'subscribe',
|
|
51
|
+
'user',
|
|
52
|
+
// alias,
|
|
53
|
+
'friend',
|
|
54
|
+
'master',
|
|
55
|
+
'shorthand',
|
|
56
|
+
];
|
|
57
|
+
export { AggregateController, CategoryController, CommentController, LinkController, NoteController, PageController, PostController, ProjectController, RecentlyController, SayController, SearchController, SnippetController, ServerlessController, SubscribeController, UserController, TopicController,
|
|
58
|
+
// Enum
|
|
59
|
+
RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, };
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../controllers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAEvC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,mBAAmB;IACnB,kBAAkB;IAClB,iBAAiB;IACjB,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,kBAAkB;IAClB,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,iBAAiB;IACjB,oBAAoB;IACpB,mBAAmB;IACnB,cAAc;CACf,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,WAAW;IACX,UAAU;IACV,SAAS;IACT,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,SAAS;IACT,OAAO;IACP,UAAU;IACV,KAAK;IACL,QAAQ;IACR,SAAS;IACT,YAAY;IACZ,WAAW;IACX,MAAM;IAEN,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,WAAW;CACH,CAAA;AAEV,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,eAAe;AAEf,OAAO;AACP,oBAAoB,EACpB,0BAA0B,GAC3B,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
|
+
import type { LinkModel } from '~/models/link';
|
|
3
|
+
import type { HTTPClient } from '../core';
|
|
4
|
+
import { BaseCrudController } from './base';
|
|
5
|
+
declare module '../core/client' {
|
|
6
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
7
|
+
link: LinkController<ResponseWrapper>;
|
|
8
|
+
friend: LinkController<ResponseWrapper>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare class LinkController<ResponseWrapper> extends BaseCrudController<LinkModel, ResponseWrapper> {
|
|
12
|
+
protected readonly client: HTTPClient;
|
|
13
|
+
constructor(client: HTTPClient);
|
|
14
|
+
canApplyLink(): Promise<boolean>;
|
|
15
|
+
applyLink(data: Pick<LinkModel, 'avatar' | 'name' | 'description' | 'url' | 'email'> & {
|
|
16
|
+
author: string;
|
|
17
|
+
}): Promise<never>;
|
|
18
|
+
name: string[];
|
|
19
|
+
base: string;
|
|
20
|
+
}
|