@mx-space/api-client 1.4.2 → 1.5.0
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 +39 -0
- package/controllers/aggregate.ts +2 -1
- package/controllers/index.ts +4 -0
- package/dist/adaptors/axios.d.cts +6 -0
- package/dist/adaptors/axios.global.js +29 -7
- package/dist/adaptors/fetch.d.cts +5 -0
- package/dist/adaptors/ky.d.cts +26 -0
- package/dist/adaptors/ky.global.js +2 -2
- package/dist/adaptors/umi-request.d.cts +6 -0
- package/dist/adaptors/umi-request.global.js +9 -1
- package/dist/index.cjs +23 -6
- package/dist/index.d.cts +1497 -0
- package/dist/index.d.ts +31 -4
- package/dist/index.global.js +21 -4
- package/dist/index.js +22 -5
- package/dtos/comment.ts +7 -4
- 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/models/comment.ts +3 -0
- package/package.json +5 -5
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind';
|
|
2
|
+
import { BaseCrudController } from './base';
|
|
3
|
+
export class LinkController extends BaseCrudController {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
super(client);
|
|
6
|
+
this.client = client;
|
|
7
|
+
this.name = ['link', 'friend'];
|
|
8
|
+
this.base = 'links';
|
|
9
|
+
autoBind(this);
|
|
10
|
+
}
|
|
11
|
+
// 是否可以申请友链
|
|
12
|
+
async canApplyLink() {
|
|
13
|
+
const { can } = await this.proxy.audit.get();
|
|
14
|
+
return can;
|
|
15
|
+
}
|
|
16
|
+
// 申请友链
|
|
17
|
+
async applyLink(data) {
|
|
18
|
+
return await this.proxy.audit.post({ data });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../../controllers/link.ts"],"names":[],"mappings":"AAIA,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;QAuBjD,SAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QACzB,SAAI,GAAG,OAAO,CAAA;QAtBZ,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED,WAAW;IACX,KAAK,CAAC,YAAY;QAChB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAoB,CAAA;QAC9D,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,OAAO;IACP,KAAK,CAAC,SAAS,CACb,IAKC;QAED,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACrD,CAAC;CAIF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
|
+
import type { IController } from '~/interfaces/controller';
|
|
3
|
+
import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request';
|
|
4
|
+
import type { SelectFields } from '~/interfaces/types';
|
|
5
|
+
import type { PaginateResult } from '~/models/base';
|
|
6
|
+
import type { NoteModel, NoteWrappedPayload, NoteWrappedWithLikedPayload } from '~/models/note';
|
|
7
|
+
import type { HTTPClient } from '../core/client';
|
|
8
|
+
import type { SortOptions } from './base';
|
|
9
|
+
declare module '../core/client' {
|
|
10
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
11
|
+
note: NoteController<ResponseWrapper>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export type NoteListOptions = {
|
|
15
|
+
select?: SelectFields<keyof NoteModel>;
|
|
16
|
+
year?: number;
|
|
17
|
+
sortBy?: 'weather' | 'mood' | 'title' | 'created' | 'modified';
|
|
18
|
+
sortOrder?: 1 | -1;
|
|
19
|
+
};
|
|
20
|
+
export declare class NoteController<ResponseWrapper> implements IController {
|
|
21
|
+
private client;
|
|
22
|
+
base: string;
|
|
23
|
+
name: string;
|
|
24
|
+
constructor(client: HTTPClient);
|
|
25
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
26
|
+
/**
|
|
27
|
+
* 最新日记
|
|
28
|
+
*/
|
|
29
|
+
getLatest(): RequestProxyResult<NoteWrappedWithLikedPayload, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
data: NoteWrappedWithLikedPayload;
|
|
32
|
+
} : ResponseWrapper extends {
|
|
33
|
+
data: NoteWrappedWithLikedPayload;
|
|
34
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
35
|
+
data: NoteWrappedWithLikedPayload;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* 获取一篇日记,根据 Id 查询需要鉴权
|
|
39
|
+
* @param id id | nid
|
|
40
|
+
* @param password 访问密码
|
|
41
|
+
*/
|
|
42
|
+
getNoteById(id: string): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
43
|
+
getNoteById(id: number): Promise<NoteWrappedPayload>;
|
|
44
|
+
getNoteById(id: number, password: string): Promise<NoteWrappedPayload>;
|
|
45
|
+
getNoteById(id: number, password: undefined, singleResult: true): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
46
|
+
getNoteById(id: number, password: string, singleResult: true): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
47
|
+
/**
|
|
48
|
+
* 日记列表分页
|
|
49
|
+
*/
|
|
50
|
+
getList(page?: number, perPage?: number, options?: NoteListOptions): RequestProxyResult<PaginateResult<NoteModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
data: PaginateResult<NoteModel>;
|
|
53
|
+
} : ResponseWrapper extends {
|
|
54
|
+
data: PaginateResult<NoteModel>;
|
|
55
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
56
|
+
data: PaginateResult<NoteModel>;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* 获取当前日记的上下各 n / 2 篇日记
|
|
60
|
+
*/
|
|
61
|
+
getMiddleList(id: string, size?: number): RequestProxyResult<{
|
|
62
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
63
|
+
size: number;
|
|
64
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
data: {
|
|
67
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
68
|
+
size: number;
|
|
69
|
+
};
|
|
70
|
+
} : ResponseWrapper extends {
|
|
71
|
+
data: {
|
|
72
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
73
|
+
size: number;
|
|
74
|
+
};
|
|
75
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
76
|
+
data: {
|
|
77
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
78
|
+
size: number;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* 喜欢这篇日记
|
|
83
|
+
*/
|
|
84
|
+
likeIt(id: string | number): RequestProxyResult<never, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
data: never;
|
|
87
|
+
} : ResponseWrapper extends {
|
|
88
|
+
data: never;
|
|
89
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
90
|
+
data: never;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* 获取专栏内的所有日记
|
|
94
|
+
*/
|
|
95
|
+
getNoteByTopicId(topicId: string, page?: number, size?: number, sortOptions?: SortOptions): RequestProxyResult<PaginateResult<NoteModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
data: PaginateResult<NoteModel>;
|
|
98
|
+
} : ResponseWrapper extends {
|
|
99
|
+
data: PaginateResult<NoteModel>;
|
|
100
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
101
|
+
data: PaginateResult<NoteModel>;
|
|
102
|
+
}>;
|
|
103
|
+
}
|