@mx-space/api-client 0.9.3 → 0.10.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/adaptors/axios.ts +3 -2
- package/adaptors/umi-request.ts +3 -2
- package/build/index.cjs.js +42 -12
- 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 +42 -13
- 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 +42 -12
- 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 +6 -6
- package/controllers/base.ts +3 -3
- package/controllers/category.ts +7 -7
- package/controllers/comment.ts +8 -8
- package/controllers/index.ts +3 -0
- package/controllers/link.ts +3 -3
- package/controllers/note.ts +37 -11
- package/controllers/page.ts +7 -7
- package/controllers/post.ts +7 -7
- package/controllers/project.ts +3 -3
- package/controllers/recently.ts +5 -5
- package/controllers/say.ts +5 -5
- package/controllers/search.ts +8 -8
- package/controllers/severless.ts +4 -4
- package/controllers/snippet.ts +4 -4
- package/controllers/topic.ts +39 -0
- package/controllers/user.ts +5 -5
- package/core/client.ts +32 -19
- package/esm/adaptors/axios.d.ts +2 -2
- package/esm/adaptors/axios.js.map +1 -1
- package/esm/adaptors/umi-request.d.ts +2 -2
- package/esm/adaptors/umi-request.js.map +1 -1
- package/esm/controllers/aggregate.d.ts +6 -6
- package/esm/controllers/base.d.ts +3 -3
- package/esm/controllers/category.d.ts +7 -6
- package/esm/controllers/category.js +1 -1
- package/esm/controllers/category.js.map +1 -1
- package/esm/controllers/comment.d.ts +8 -8
- package/esm/controllers/index.d.ts +3 -2
- package/esm/controllers/index.js +3 -1
- package/esm/controllers/index.js.map +1 -1
- package/esm/controllers/link.d.ts +3 -3
- package/esm/controllers/note.d.ts +28 -20
- package/esm/controllers/note.js +12 -8
- package/esm/controllers/note.js.map +1 -1
- package/esm/controllers/page.d.ts +7 -7
- package/esm/controllers/post.d.ts +7 -7
- package/esm/controllers/project.d.ts +3 -3
- package/esm/controllers/recently.d.ts +5 -5
- package/esm/controllers/say.d.ts +5 -5
- package/esm/controllers/search.d.ts +8 -8
- package/esm/controllers/severless.d.ts +4 -4
- package/esm/controllers/snippet.d.ts +4 -4
- package/esm/controllers/topic.d.ts +27 -0
- package/esm/controllers/topic.js +18 -0
- package/esm/controllers/topic.js.map +1 -0
- package/esm/controllers/user.d.ts +5 -5
- package/esm/core/client.d.ts +7 -6
- package/esm/core/client.js +12 -4
- package/esm/core/client.js.map +1 -1
- package/esm/interfaces/adapter.d.ts +1 -1
- package/esm/interfaces/client.d.ts +6 -2
- package/esm/models/aggregate.d.ts +7 -7
- package/esm/models/category.d.ts +2 -2
- package/esm/models/comment.d.ts +2 -2
- package/esm/models/link.d.ts +1 -1
- package/esm/models/note.d.ts +1 -1
- package/esm/models/page.d.ts +1 -1
- package/esm/models/post.d.ts +2 -2
- package/esm/models/project.d.ts +1 -1
- package/esm/models/recently.d.ts +1 -1
- package/esm/models/say.d.ts +1 -1
- package/esm/models/snippet.d.ts +1 -1
- package/esm/models/topic.d.ts +8 -0
- package/esm/models/topic.js +2 -0
- package/esm/models/topic.js.map +1 -0
- package/esm/models/user.d.ts +1 -1
- package/esm/utils/index.d.ts +1 -1
- package/interfaces/adapter.ts +1 -1
- package/interfaces/client.ts +8 -2
- package/lib/adaptors/axios.d.ts +2 -2
- package/lib/adaptors/axios.js.map +1 -1
- package/lib/adaptors/umi-request.d.ts +2 -2
- package/lib/adaptors/umi-request.js.map +1 -1
- package/lib/controllers/aggregate.d.ts +6 -6
- package/lib/controllers/base.d.ts +3 -3
- package/lib/controllers/category.d.ts +7 -6
- package/lib/controllers/category.js.map +1 -1
- package/lib/controllers/comment.d.ts +8 -8
- package/lib/controllers/index.d.ts +3 -2
- package/lib/controllers/index.js +4 -1
- package/lib/controllers/index.js.map +1 -1
- package/lib/controllers/link.d.ts +3 -3
- package/lib/controllers/note.d.ts +28 -20
- package/lib/controllers/note.js +12 -8
- package/lib/controllers/note.js.map +1 -1
- package/lib/controllers/page.d.ts +7 -7
- package/lib/controllers/post.d.ts +7 -7
- package/lib/controllers/project.d.ts +3 -3
- package/lib/controllers/recently.d.ts +5 -5
- package/lib/controllers/say.d.ts +5 -5
- package/lib/controllers/search.d.ts +8 -8
- package/lib/controllers/severless.d.ts +4 -4
- package/lib/controllers/snippet.d.ts +4 -4
- package/lib/controllers/topic.d.ts +27 -0
- package/lib/controllers/topic.js +22 -0
- package/lib/controllers/topic.js.map +1 -0
- package/lib/controllers/user.d.ts +5 -5
- package/lib/core/client.d.ts +7 -6
- package/lib/core/client.js +12 -4
- package/lib/core/client.js.map +1 -1
- package/lib/interfaces/adapter.d.ts +1 -1
- package/lib/interfaces/client.d.ts +6 -2
- package/lib/models/aggregate.d.ts +7 -7
- package/lib/models/category.d.ts +2 -2
- package/lib/models/comment.d.ts +2 -2
- package/lib/models/link.d.ts +1 -1
- package/lib/models/note.d.ts +1 -1
- package/lib/models/page.d.ts +1 -1
- package/lib/models/post.d.ts +2 -2
- package/lib/models/project.d.ts +1 -1
- package/lib/models/recently.d.ts +1 -1
- package/lib/models/say.d.ts +1 -1
- package/lib/models/snippet.d.ts +1 -1
- package/lib/models/topic.d.ts +8 -0
- package/lib/models/topic.js +3 -0
- package/lib/models/topic.js.map +1 -0
- package/lib/models/user.d.ts +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/models/aggregate.ts +7 -7
- package/models/category.ts +2 -2
- package/models/comment.ts +2 -2
- package/models/link.ts +1 -1
- package/models/note.ts +1 -1
- package/models/page.ts +1 -1
- package/models/post.ts +2 -2
- package/models/project.ts +1 -1
- package/models/recently.ts +1 -1
- package/models/say.ts +1 -1
- package/models/snippet.ts +1 -1
- package/models/topic.ts +9 -0
- package/models/user.ts +1 -1
- package/package.json +6 -6
- package/types/adaptors/axios.d.ts +2 -2
- package/types/adaptors/umi-request.d.ts +2 -2
- package/types/controllers/aggregate.d.ts +6 -6
- package/types/controllers/base.d.ts +3 -3
- package/types/controllers/category.d.ts +7 -6
- package/types/controllers/comment.d.ts +8 -8
- package/types/controllers/index.d.ts +3 -2
- package/types/controllers/link.d.ts +3 -3
- package/types/controllers/note.d.ts +28 -20
- package/types/controllers/page.d.ts +7 -7
- package/types/controllers/post.d.ts +7 -7
- package/types/controllers/project.d.ts +3 -3
- package/types/controllers/recently.d.ts +5 -5
- package/types/controllers/say.d.ts +5 -5
- package/types/controllers/search.d.ts +8 -8
- package/types/controllers/severless.d.ts +4 -4
- package/types/controllers/snippet.d.ts +4 -4
- package/types/controllers/topic.d.ts +27 -0
- package/types/controllers/user.d.ts +5 -5
- package/types/core/client.d.ts +7 -6
- package/types/interfaces/adapter.d.ts +1 -1
- package/types/interfaces/client.d.ts +6 -2
- package/types/models/aggregate.d.ts +7 -7
- package/types/models/category.d.ts +2 -2
- package/types/models/comment.d.ts +2 -2
- package/types/models/link.d.ts +1 -1
- package/types/models/note.d.ts +1 -1
- package/types/models/page.d.ts +1 -1
- package/types/models/post.d.ts +2 -2
- package/types/models/project.d.ts +1 -1
- package/types/models/recently.d.ts +1 -1
- package/types/models/say.d.ts +1 -1
- package/types/models/snippet.d.ts +1 -1
- package/types/models/topic.d.ts +8 -0
- package/types/models/user.d.ts +1 -1
- package/types/utils/index.d.ts +1 -1
- package/utils/index.ts +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
-
import { IController } from '../interfaces/controller';
|
|
3
|
-
import { IRequestHandler } from '../interfaces/request';
|
|
4
|
-
import { TLogin, UserModel } from '../models/user';
|
|
5
|
-
import { HTTPClient } from '../core';
|
|
1
|
+
import type { IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
+
import type { IController } from '../interfaces/controller';
|
|
3
|
+
import type { IRequestHandler } from '../interfaces/request';
|
|
4
|
+
import type { TLogin, UserModel } from '../models/user';
|
|
5
|
+
import type { HTTPClient } from '../core';
|
|
6
6
|
declare module '../core/client' {
|
|
7
7
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
8
8
|
user: UserController<ResponseWrapper>;
|
package/lib/core/client.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { IAdaptorRequestResponseType, IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
-
import { ClientOptions } from '../interfaces/client';
|
|
3
|
-
import { IController } from '../interfaces/controller';
|
|
4
|
-
import { IRequestHandler } from '../interfaces/request';
|
|
5
|
-
import { Class } from '../interfaces/types';
|
|
1
|
+
import type { IAdaptorRequestResponseType, IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
+
import type { ClientOptions } from '../interfaces/client';
|
|
3
|
+
import type { IController } from '../interfaces/controller';
|
|
4
|
+
import type { IRequestHandler } from '../interfaces/request';
|
|
5
|
+
import type { Class } from '../interfaces/types';
|
|
6
6
|
export type { HTTPClient };
|
|
7
7
|
declare class HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
8
8
|
private readonly _endpoint;
|
|
9
9
|
private _adaptor;
|
|
10
|
+
private options;
|
|
10
11
|
private readonly _proxy;
|
|
11
|
-
constructor(_endpoint: string, _adaptor: T);
|
|
12
|
+
constructor(_endpoint: string, _adaptor: T, options?: Omit<ClientOptions, 'controllers'>);
|
|
12
13
|
private initGetClient;
|
|
13
14
|
injectControllers(...Controller: Class<IController>[]): void;
|
|
14
15
|
injectControllers(Controller: Class<IController>[]): void;
|
package/lib/core/client.js
CHANGED
|
@@ -12,9 +12,10 @@ const attach_request_1 = require("./attach-request");
|
|
|
12
12
|
const error_1 = require("./error");
|
|
13
13
|
const methodPrefix = '_$';
|
|
14
14
|
class HTTPClient {
|
|
15
|
-
constructor(_endpoint, _adaptor) {
|
|
15
|
+
constructor(_endpoint, _adaptor, options = {}) {
|
|
16
16
|
this._endpoint = _endpoint;
|
|
17
17
|
this._adaptor = _adaptor;
|
|
18
|
+
this.options = options;
|
|
18
19
|
this._endpoint = _endpoint
|
|
19
20
|
.replace(/\/*$/, '')
|
|
20
21
|
.replace('localhost', '127.0.0.1');
|
|
@@ -115,13 +116,20 @@ class HTTPClient {
|
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
118
|
catch (e) {
|
|
118
|
-
|
|
119
|
+
let message = e.message;
|
|
120
|
+
let code = e.code ||
|
|
119
121
|
e.status ||
|
|
120
122
|
e.statusCode ||
|
|
121
123
|
e.response?.status ||
|
|
122
124
|
e.response?.statusCode ||
|
|
123
125
|
e.response?.code ||
|
|
124
|
-
500
|
|
126
|
+
500;
|
|
127
|
+
if (that.options.getCodeMessageFromException) {
|
|
128
|
+
const errorInfo = that.options.getCodeMessageFromException(e);
|
|
129
|
+
message = errorInfo.message || message;
|
|
130
|
+
code = errorInfo.code || code;
|
|
131
|
+
}
|
|
132
|
+
throw new error_1.RequestError(message, code, url, e);
|
|
125
133
|
}
|
|
126
134
|
const data = res.data;
|
|
127
135
|
if (!data) {
|
|
@@ -168,7 +176,7 @@ class HTTPClient {
|
|
|
168
176
|
}
|
|
169
177
|
function createClient(adapter) {
|
|
170
178
|
return (endpoint, options) => {
|
|
171
|
-
const client = new HTTPClient(endpoint, adapter);
|
|
179
|
+
const client = new HTTPClient(endpoint, adapter, options);
|
|
172
180
|
const { controllers } = options || {};
|
|
173
181
|
if (controllers) {
|
|
174
182
|
client.injectControllers(controllers);
|
package/lib/core/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../core/client.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA0C;AAW1C,mCAAuC;AACvC,uCAA8C;AAE9C,gDAAkD;AAClD,qDAAsD;AACtD,mCAAsC;AAEtC,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB,MAAM,UAAU;IAMd,
|
|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EAAE;YACf,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAA;SACtC;QACD,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AAtBD,oCAsBC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { IController } from './controller';
|
|
2
|
-
import { Class } from './types';
|
|
1
|
+
import type { IController } from './controller';
|
|
2
|
+
import type { Class } from './types';
|
|
3
3
|
export declare type ClientOptions = {
|
|
4
4
|
controllers?: Class<IController>[];
|
|
5
|
+
getCodeMessageFromException?: <T = Error>(error: T) => {
|
|
6
|
+
message?: string | undefined | null;
|
|
7
|
+
code?: number | undefined | null;
|
|
8
|
+
};
|
|
5
9
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CategoryModel } from './category';
|
|
2
|
-
import { NoteModel } from './note';
|
|
3
|
-
import { PageModel } from './page';
|
|
4
|
-
import { PostModel } from './post';
|
|
5
|
-
import { SayModel } from './say';
|
|
6
|
-
import { SeoOptionModel } from './setting';
|
|
7
|
-
import { UserModel } from './user';
|
|
1
|
+
import type { CategoryModel } from './category';
|
|
2
|
+
import type { NoteModel } from './note';
|
|
3
|
+
import type { PageModel } from './page';
|
|
4
|
+
import type { PostModel } from './post';
|
|
5
|
+
import type { SayModel } from './say';
|
|
6
|
+
import type { SeoOptionModel } from './setting';
|
|
7
|
+
import type { UserModel } from './user';
|
|
8
8
|
export interface AggregateRoot {
|
|
9
9
|
user: UserModel;
|
|
10
10
|
seo: SeoOptionModel;
|
package/lib/models/category.d.ts
CHANGED
package/lib/models/comment.d.ts
CHANGED
package/lib/models/link.d.ts
CHANGED
package/lib/models/note.d.ts
CHANGED
package/lib/models/page.d.ts
CHANGED
package/lib/models/post.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Count, Image, TextBaseModel } from './base';
|
|
2
|
-
import { CategoryModel } from './category';
|
|
1
|
+
import type { Count, Image, TextBaseModel } from './base';
|
|
2
|
+
import type { CategoryModel } from './category';
|
|
3
3
|
export interface PostModel extends TextBaseModel {
|
|
4
4
|
summary?: string;
|
|
5
5
|
copyright: boolean;
|
package/lib/models/project.d.ts
CHANGED
package/lib/models/recently.d.ts
CHANGED
package/lib/models/say.d.ts
CHANGED
package/lib/models/snippet.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic.js","sourceRoot":"","sources":["../../models/topic.ts"],"names":[],"mappings":""}
|
package/lib/models/user.d.ts
CHANGED
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SortOrder } from '../interfaces/options';
|
|
1
|
+
import type { SortOrder } from '../interfaces/options';
|
|
2
2
|
export declare const isPlainObject: (obj: any) => any;
|
|
3
3
|
export declare const sortOrderToNumber: (order: SortOrder) => number;
|
|
4
4
|
export declare const destructureData: (payload: any) => any;
|
package/models/aggregate.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CategoryModel } from './category'
|
|
2
|
-
import { NoteModel } from './note'
|
|
3
|
-
import { PageModel } from './page'
|
|
4
|
-
import { PostModel } from './post'
|
|
5
|
-
import { SayModel } from './say'
|
|
6
|
-
import { SeoOptionModel } from './setting'
|
|
7
|
-
import { UserModel } from './user'
|
|
1
|
+
import type { CategoryModel } from './category'
|
|
2
|
+
import type { NoteModel } from './note'
|
|
3
|
+
import type { PageModel } from './page'
|
|
4
|
+
import type { PostModel } from './post'
|
|
5
|
+
import type { SayModel } from './say'
|
|
6
|
+
import type { SeoOptionModel } from './setting'
|
|
7
|
+
import type { UserModel } from './user'
|
|
8
8
|
|
|
9
9
|
export interface AggregateRoot {
|
|
10
10
|
user: UserModel
|
package/models/category.ts
CHANGED
package/models/comment.ts
CHANGED
package/models/link.ts
CHANGED
package/models/note.ts
CHANGED
package/models/page.ts
CHANGED
package/models/post.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Count, Image, TextBaseModel } from './base'
|
|
2
|
-
import { CategoryModel } from './category'
|
|
1
|
+
import type { Count, Image, TextBaseModel } from './base'
|
|
2
|
+
import type { CategoryModel } from './category'
|
|
3
3
|
|
|
4
4
|
export interface PostModel extends TextBaseModel {
|
|
5
5
|
summary?: string
|
package/models/project.ts
CHANGED
package/models/recently.ts
CHANGED
package/models/say.ts
CHANGED
package/models/snippet.ts
CHANGED
package/models/topic.ts
ADDED
package/models/user.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-space/api-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "A api client for mx-space server@next",
|
|
5
5
|
"author": "Innei",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"version": "vv"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@rollup/plugin-commonjs": "
|
|
48
|
-
"@rollup/plugin-node-resolve": "13.2.
|
|
47
|
+
"@rollup/plugin-commonjs": "22.0.0",
|
|
48
|
+
"@rollup/plugin-node-resolve": "13.2.2",
|
|
49
49
|
"@rollup/plugin-typescript": "8.3.2",
|
|
50
50
|
"@types/cors": "2.8.12",
|
|
51
51
|
"@types/lodash": "4.14.182",
|
|
52
|
-
"@types/node": "16.11.
|
|
53
|
-
"axios": "0.
|
|
52
|
+
"@types/node": "16.11.36",
|
|
53
|
+
"axios": "0.27.2",
|
|
54
54
|
"gh-pages": "3.2.3",
|
|
55
55
|
"lodash": "4.17.21",
|
|
56
|
-
"rollup": "2.
|
|
56
|
+
"rollup": "2.72.1",
|
|
57
57
|
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
58
58
|
"rollup-plugin-terser": "7.0.2",
|
|
59
59
|
"tsconfig-replace-paths": "0.0.11",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
-
import { IRequestAdapter } from '../interfaces/adapter';
|
|
1
|
+
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
+
import type { IRequestAdapter } from '../interfaces/adapter';
|
|
3
3
|
export declare const axiosAdaptor: IRequestAdapter<AxiosInstance, AxiosResponse<unknown>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RequestMethod, RequestResponse } from 'umi-request';
|
|
2
|
-
import { IRequestAdapter } from '../interfaces/adapter';
|
|
1
|
+
import type { RequestMethod, RequestResponse } from 'umi-request';
|
|
2
|
+
import type { IRequestAdapter } from '../interfaces/adapter';
|
|
3
3
|
export declare const umiAdaptor: IRequestAdapter<RequestMethod<true>, RequestResponse>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
-
import { IController } from '../interfaces/controller';
|
|
3
|
-
import { SortOrder } from '../interfaces/options';
|
|
4
|
-
import { IRequestHandler, RequestProxyResult } from '../interfaces/request';
|
|
5
|
-
import { AggregateRoot, AggregateStat, AggregateTop, TimelineData, TimelineType } from '../models/aggregate';
|
|
6
|
-
import { HTTPClient } from '../core';
|
|
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 { AggregateRoot, AggregateStat, AggregateTop, TimelineData, TimelineType } from '../models/aggregate';
|
|
6
|
+
import type { HTTPClient } from '../core';
|
|
7
7
|
declare module '../core/client' {
|
|
8
8
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
9
|
aggregate: AggregateController<ResponseWrapper>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IRequestHandler, RequestProxyResult } from '../interfaces/request';
|
|
2
|
-
import { PaginateResult } from '../models/base';
|
|
3
|
-
import { HTTPClient } from '../core';
|
|
1
|
+
import type { IRequestHandler, RequestProxyResult } from '../interfaces/request';
|
|
2
|
+
import type { PaginateResult } from '../models/base';
|
|
3
|
+
import type { HTTPClient } from '../core';
|
|
4
4
|
export declare abstract class BaseCrudController<T, ResponseWrapper> {
|
|
5
5
|
protected client: HTTPClient;
|
|
6
6
|
base: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
-
import { IController } from '../interfaces/controller';
|
|
3
|
-
import { IRequestHandler, RequestProxyResult, ResponseProxyExtraRaw } from '../interfaces/request';
|
|
4
|
-
import { HTTPClient } from '../core/client';
|
|
5
|
-
import { CategoryModel,
|
|
6
|
-
import {
|
|
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 { CategoryType } from '../models/category';
|
|
7
|
+
import type { PostModel } from '../models/post';
|
|
7
8
|
declare module '../core/client' {
|
|
8
9
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
10
|
category: CategoryController<ResponseWrapper>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
-
import { IController } from '../interfaces/controller';
|
|
3
|
-
import { PaginationParams } from '../interfaces/params';
|
|
4
|
-
import { IRequestHandler } from '../interfaces/request';
|
|
5
|
-
import { PaginateResult } from '../models/base';
|
|
6
|
-
import { CommentModel } from '../models/comment';
|
|
7
|
-
import { HTTPClient } from '../core';
|
|
8
|
-
import { CommentDto } from '../dtos/comment';
|
|
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
9
|
declare module '../core/client' {
|
|
10
10
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
11
11
|
comment: CommentController<ResponseWrapper>;
|
|
@@ -11,7 +11,8 @@ import { SayController } from './say';
|
|
|
11
11
|
import { SearchController } from './search';
|
|
12
12
|
import { ServerlessController } from './severless';
|
|
13
13
|
import { SnippetController } from './snippet';
|
|
14
|
+
import { TopicController } from './topic';
|
|
14
15
|
import { UserController } from './user';
|
|
15
16
|
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 UserController)[];
|
|
16
|
-
export declare const allContollerNames: readonly ["aggregate", "category", "comment", "link", "note", "page", "post", "project", "recently", "say", "search", "snippet", "serverless", "user", "friend", "master", "shorthand"];
|
|
17
|
-
export { AggregateController, CategoryController, CommentController, LinkController, NoteController, PageController, PostController, ProjectController, RecentlyController, SayController, SearchController, SnippetController, ServerlessController, UserController, };
|
|
17
|
+
export declare const allContollerNames: readonly ["aggregate", "category", "comment", "link", "note", "page", "post", "project", "topic", "recently", "say", "search", "snippet", "serverless", "user", "friend", "master", "shorthand"];
|
|
18
|
+
export { AggregateController, CategoryController, CommentController, LinkController, NoteController, PageController, PostController, ProjectController, RecentlyController, SayController, SearchController, SnippetController, ServerlessController, UserController, TopicController, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
-
import { LinkModel } from '../models/link';
|
|
3
|
-
import { HTTPClient } from '../core';
|
|
1
|
+
import type { IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
+
import type { LinkModel } from '../models/link';
|
|
3
|
+
import type { HTTPClient } from '../core';
|
|
4
4
|
import { BaseCrudController } from './base';
|
|
5
5
|
declare module '../core/client' {
|
|
6
6
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IRequestAdapter } from '../interfaces/adapter';
|
|
2
|
-
import { IController } from '../interfaces/controller';
|
|
3
|
-
import { IRequestHandler } from '../interfaces/request';
|
|
4
|
-
import { SelectFields } from '../interfaces/types';
|
|
5
|
-
import { PaginateResult } from '../models/base';
|
|
6
|
-
import { NoteModel, NoteWrappedPayload } from '../models/note';
|
|
7
|
-
import { HTTPClient } from '../core/client';
|
|
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 } from '../models/note';
|
|
7
|
+
import type { HTTPClient } from '../core/client';
|
|
8
8
|
declare module '../core/client' {
|
|
9
9
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
10
10
|
note: NoteController<ResponseWrapper>;
|
|
@@ -25,7 +25,7 @@ export declare class NoteController<ResponseWrapper> implements IController {
|
|
|
25
25
|
/**
|
|
26
26
|
* 最新日记
|
|
27
27
|
*/
|
|
28
|
-
getLatest():
|
|
28
|
+
getLatest(): RequestProxyResult<NoteWrappedPayload, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
29
29
|
[key: string]: any;
|
|
30
30
|
data: NoteWrappedPayload;
|
|
31
31
|
} : ResponseWrapper extends {
|
|
@@ -34,22 +34,19 @@ export declare class NoteController<ResponseWrapper> implements IController {
|
|
|
34
34
|
data: NoteWrappedPayload;
|
|
35
35
|
}>;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* 获取一篇日记, 根据 Id 查询需要鉴权
|
|
38
38
|
* @param id id | nid
|
|
39
39
|
* @param password 访问密码
|
|
40
40
|
*/
|
|
41
|
-
getNoteById(id: string
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
47
|
-
data: NoteWrappedPayload;
|
|
48
|
-
}>;
|
|
41
|
+
getNoteById(id: string): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
42
|
+
getNoteById(id: number): Promise<NoteWrappedPayload>;
|
|
43
|
+
getNoteById(id: number, password: string): Promise<NoteWrappedPayload>;
|
|
44
|
+
getNoteById(id: number, password: undefined, singleResult: true): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
45
|
+
getNoteById(id: number, password: string, singleResult: true): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
49
46
|
/**
|
|
50
47
|
* 日记列表分页
|
|
51
48
|
*/
|
|
52
|
-
getList(page?: number, perPage?: number, options?: NoteListOptions):
|
|
49
|
+
getList(page?: number, perPage?: number, options?: NoteListOptions): RequestProxyResult<PaginateResult<NoteModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
53
50
|
[key: string]: any;
|
|
54
51
|
data: PaginateResult<NoteModel>;
|
|
55
52
|
} : ResponseWrapper extends {
|
|
@@ -60,7 +57,7 @@ export declare class NoteController<ResponseWrapper> implements IController {
|
|
|
60
57
|
/**
|
|
61
58
|
* 获取当前日记的上下各 n / 2 篇日记
|
|
62
59
|
*/
|
|
63
|
-
getMiddleList(id: string, size?: number):
|
|
60
|
+
getMiddleList(id: string, size?: number): RequestProxyResult<{
|
|
64
61
|
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
65
62
|
size: number;
|
|
66
63
|
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
@@ -83,7 +80,7 @@ export declare class NoteController<ResponseWrapper> implements IController {
|
|
|
83
80
|
/**
|
|
84
81
|
* 喜欢这篇日记
|
|
85
82
|
*/
|
|
86
|
-
likeIt(id: string | number):
|
|
83
|
+
likeIt(id: string | number): RequestProxyResult<never, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
87
84
|
[key: string]: any;
|
|
88
85
|
data: never;
|
|
89
86
|
} : ResponseWrapper extends {
|
|
@@ -91,4 +88,15 @@ export declare class NoteController<ResponseWrapper> implements IController {
|
|
|
91
88
|
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
92
89
|
data: never;
|
|
93
90
|
}>;
|
|
91
|
+
/**
|
|
92
|
+
* 获取专栏内的所有日记
|
|
93
|
+
*/
|
|
94
|
+
getNoteByTopicId(topicId: string, page?: number, size?: number): RequestProxyResult<PaginateResult<NoteModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
data: PaginateResult<NoteModel>;
|
|
97
|
+
} : ResponseWrapper extends {
|
|
98
|
+
data: PaginateResult<NoteModel>;
|
|
99
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
100
|
+
data: PaginateResult<NoteModel>;
|
|
101
|
+
}>;
|
|
94
102
|
}
|