@mx-space/api-client 1.12.0 → 1.13.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/ack.ts +2 -4
- package/controllers/activity.ts +6 -2
- package/controllers/aggregate.ts +3 -4
- package/controllers/ai.ts +2 -3
- package/controllers/base.ts +1 -2
- package/controllers/category.ts +4 -6
- package/controllers/comment.ts +1 -2
- package/controllers/link.ts +2 -4
- package/controllers/note.ts +1 -2
- package/controllers/page.ts +1 -2
- package/controllers/post.ts +1 -2
- package/controllers/project.ts +2 -4
- package/controllers/recently.ts +1 -2
- package/controllers/say.ts +2 -4
- package/controllers/search.ts +1 -2
- package/controllers/severless.ts +1 -2
- package/controllers/snippet.ts +1 -2
- package/controllers/subscribe.ts +1 -2
- package/controllers/topic.ts +2 -4
- package/controllers/user.ts +3 -4
- package/dist/adapter-4fDtRx9o.d.cts +23 -0
- package/dist/adapter-4fDtRx9o.d.ts +23 -0
- package/dist/adaptors/axios.d.cts +1 -1
- package/dist/adaptors/axios.d.ts +1 -1
- package/dist/adaptors/fetch.d.cts +1 -1
- package/dist/adaptors/fetch.d.ts +1 -1
- package/dist/adaptors/umi-request.d.cts +1 -1
- package/dist/adaptors/umi-request.d.ts +1 -1
- package/dist/index.cjs +14 -11
- package/dist/index.d.cts +60 -31
- package/dist/index.d.ts +60 -31
- package/dist/index.global.js +14 -11
- package/dist/index.js +14 -11
- package/esm/packages/api-client/adaptors/ky.d.ts +10 -10
- package/esm/packages/api-client/controllers/category.d.ts +1 -1
- package/esm/packages/api-client/controllers/link.d.ts +1 -1
- package/esm/packages/api-client/controllers/project.d.ts +1 -1
- package/esm/packages/api-client/controllers/say.d.ts +1 -1
- package/esm/packages/api-client/controllers/topic.d.ts +1 -1
- package/esm/packages/api-client/interfaces/adapter.d.ts +5 -5
- package/esm/packages/api-client/interfaces/request.d.ts +7 -7
- package/interfaces/adapter.ts +10 -10
- package/interfaces/request.ts +26 -26
- package/models/activity.ts +30 -0
- package/models/comment.ts +1 -2
- package/package.json +2 -2
- package/tsup.config.ts +2 -2
- package/dist/adapter-29diOMCR.d.cts +0 -23
- package/dist/adapter-29diOMCR.d.ts +0 -23
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestOptions, I as IRequestAdapter, a as IAdaptorRequestResponseType } from './adapter-
|
|
1
|
+
import { R as RequestOptions, I as IRequestAdapter, a as IAdaptorRequestResponseType } from './adapter-4fDtRx9o.js';
|
|
2
2
|
|
|
3
3
|
interface IController {
|
|
4
4
|
base: string;
|
|
@@ -29,13 +29,13 @@ type NoStringIndex<T> = {
|
|
|
29
29
|
};
|
|
30
30
|
interface IRequestHandler<ResponseWrapper> {
|
|
31
31
|
(path?: string | number): IRequestHandler<ResponseWrapper>;
|
|
32
|
-
get<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>)
|
|
33
|
-
post<P = unknown>(options?: RequestOptions)
|
|
34
|
-
patch<P = unknown>(options?: RequestOptions)
|
|
35
|
-
delete<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>)
|
|
36
|
-
put<P = unknown>(options?: RequestOptions)
|
|
37
|
-
toString(withBase?: boolean)
|
|
38
|
-
valueOf(withBase?: boolean)
|
|
32
|
+
get: <P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>) => RequestProxyResult<P, ResponseWrapper>;
|
|
33
|
+
post: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
34
|
+
patch: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
35
|
+
delete: <P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>) => RequestProxyResult<P, ResponseWrapper>;
|
|
36
|
+
put: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
37
|
+
toString: (withBase?: boolean) => string;
|
|
38
|
+
valueOf: (withBase?: boolean) => string;
|
|
39
39
|
[key: string]: IRequestHandler<ResponseWrapper>;
|
|
40
40
|
}
|
|
41
41
|
type RequestProxyResult<T, ResponseWrapper, R = ResponseWrapper extends unknown ? {
|
|
@@ -294,6 +294,34 @@ interface RecentRecent {
|
|
|
294
294
|
down: number;
|
|
295
295
|
created: string;
|
|
296
296
|
}
|
|
297
|
+
interface LastYearPublication {
|
|
298
|
+
posts: PostsItem[];
|
|
299
|
+
notes: NotesItem[];
|
|
300
|
+
}
|
|
301
|
+
interface PostsItem {
|
|
302
|
+
id: string;
|
|
303
|
+
created: string;
|
|
304
|
+
title: string;
|
|
305
|
+
slug: string;
|
|
306
|
+
categoryId: string;
|
|
307
|
+
category: Category;
|
|
308
|
+
}
|
|
309
|
+
interface Category {
|
|
310
|
+
id: string;
|
|
311
|
+
type: number;
|
|
312
|
+
name: string;
|
|
313
|
+
slug: string;
|
|
314
|
+
created: string;
|
|
315
|
+
}
|
|
316
|
+
interface NotesItem {
|
|
317
|
+
id: string;
|
|
318
|
+
created: string;
|
|
319
|
+
title: string;
|
|
320
|
+
mood: string;
|
|
321
|
+
weather: string;
|
|
322
|
+
nid: number;
|
|
323
|
+
bookmark: boolean;
|
|
324
|
+
}
|
|
297
325
|
|
|
298
326
|
declare module '@mx-space/api-client' {
|
|
299
327
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
@@ -420,6 +448,7 @@ declare class ActivityController<ResponseWrapper> implements IController {
|
|
|
420
448
|
};
|
|
421
449
|
$serialized: RecentActivities;
|
|
422
450
|
}>;
|
|
451
|
+
getLastYearPublication(): Promise<LastYearPublication>;
|
|
423
452
|
}
|
|
424
453
|
|
|
425
454
|
type SortOrder = 'asc' | 'desc';
|
|
@@ -1025,28 +1054,6 @@ declare class CommentController<ResponseWrapper> implements IController {
|
|
|
1025
1054
|
}>;
|
|
1026
1055
|
}
|
|
1027
1056
|
|
|
1028
|
-
declare enum LinkType {
|
|
1029
|
-
Friend = 0,
|
|
1030
|
-
Collection = 1
|
|
1031
|
-
}
|
|
1032
|
-
declare enum LinkState {
|
|
1033
|
-
Pass = 0,
|
|
1034
|
-
Audit = 1,
|
|
1035
|
-
Outdate = 2,
|
|
1036
|
-
Banned = 3,
|
|
1037
|
-
Reject = 4
|
|
1038
|
-
}
|
|
1039
|
-
interface LinkModel extends BaseModel {
|
|
1040
|
-
name: string;
|
|
1041
|
-
url: string;
|
|
1042
|
-
avatar: string;
|
|
1043
|
-
description?: string;
|
|
1044
|
-
type: LinkType;
|
|
1045
|
-
state: LinkState;
|
|
1046
|
-
hide: boolean;
|
|
1047
|
-
email: string;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
1057
|
type SortOptions = {
|
|
1051
1058
|
sortBy?: string;
|
|
1052
1059
|
sortOrder?: 1 | -1 | 'asc' | 'desc';
|
|
@@ -1088,6 +1095,28 @@ declare abstract class BaseCrudController<T, ResponseWrapper> {
|
|
|
1088
1095
|
}>;
|
|
1089
1096
|
}
|
|
1090
1097
|
|
|
1098
|
+
declare enum LinkType {
|
|
1099
|
+
Friend = 0,
|
|
1100
|
+
Collection = 1
|
|
1101
|
+
}
|
|
1102
|
+
declare enum LinkState {
|
|
1103
|
+
Pass = 0,
|
|
1104
|
+
Audit = 1,
|
|
1105
|
+
Outdate = 2,
|
|
1106
|
+
Banned = 3,
|
|
1107
|
+
Reject = 4
|
|
1108
|
+
}
|
|
1109
|
+
interface LinkModel extends BaseModel {
|
|
1110
|
+
name: string;
|
|
1111
|
+
url: string;
|
|
1112
|
+
avatar: string;
|
|
1113
|
+
description?: string;
|
|
1114
|
+
type: LinkType;
|
|
1115
|
+
state: LinkState;
|
|
1116
|
+
hide: boolean;
|
|
1117
|
+
email: string;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1091
1120
|
declare module '@mx-space/api-client' {
|
|
1092
1121
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1093
1122
|
link: LinkController<ResponseWrapper>;
|
|
@@ -1826,4 +1855,4 @@ interface SnippetModel<T = unknown> extends BaseModel {
|
|
|
1826
1855
|
*/
|
|
1827
1856
|
declare const camelcaseKeys: <T = any>(obj: any) => T;
|
|
1828
1857
|
|
|
1829
|
-
export { AIController, type AISummaryModel, AckController, ActivityController, type ActivityPresence, AdminExtraModel, AggregateController, type AggregateRoot, type AggregateRootWithTheme, type AggregateStat, type AggregateTop, type AggregateTopNote, type AggregateTopPost, AlgoliaSearchOptionsModel, BackupOptionsModel, BaiduSearchOptionsModel, type BaseCommentIndexModel, type BaseModel, CategoryController, type CategoryEntries, type CategoryModel, CategoryType, type CategoryWithChildrenModel, CollectionRefTypes, CommentController, type CommentDto, type CommentModel, CommentOptionsModel, type CommentRef, CommentState, type Coordinate, type Count, EnumPageType, HTTPClient, type IConfig, type IConfigKeys, IRequestAdapter, type Image, LinkController, type LinkModel, LinkState, LinkType, MailOptionsModel, type ModelWithLiked, NoteController, type NoteModel, type NoteWrappedPayload, type NoteWrappedWithLikedPayload, PageController, type PageModel, type Pager, type PaginateResult, PostController, type PostModel, ProjectController, type ProjectModel, type RecentActivities, type RecentComment, type RecentLike, type RecentNote, type RecentPost, type RecentRecent, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, type RecentlyModel, type RecentlyRefType, RecentlyRefTypes, RequestError, type RoomOmittedNote, type RoomOmittedPage, type RoomOmittedPost, type RoomsData, SayController, type SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, type SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, type SubscribeType, SubscribeTypeToBitMap, type TLogin, type TagModel, type TextBaseModel, type TimelineData, TimelineType, TopicController, type TopicModel, type Url, UrlOptionModel, UserController, type UserModel, allControllerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
|
|
1858
|
+
export { AIController, type AISummaryModel, AckController, ActivityController, type ActivityPresence, AdminExtraModel, AggregateController, type AggregateRoot, type AggregateRootWithTheme, type AggregateStat, type AggregateTop, type AggregateTopNote, type AggregateTopPost, AlgoliaSearchOptionsModel, BackupOptionsModel, BaiduSearchOptionsModel, type BaseCommentIndexModel, type BaseModel, CategoryController, type CategoryEntries, type CategoryModel, CategoryType, type CategoryWithChildrenModel, CollectionRefTypes, CommentController, type CommentDto, type CommentModel, CommentOptionsModel, type CommentRef, CommentState, type Coordinate, type Count, EnumPageType, HTTPClient, type IConfig, type IConfigKeys, IRequestAdapter, type Image, type LastYearPublication, LinkController, type LinkModel, LinkState, LinkType, MailOptionsModel, type ModelWithLiked, NoteController, type NoteModel, type NoteWrappedPayload, type NoteWrappedWithLikedPayload, PageController, type PageModel, type Pager, type PaginateResult, PostController, type PostModel, ProjectController, type ProjectModel, type RecentActivities, type RecentComment, type RecentLike, type RecentNote, type RecentPost, type RecentRecent, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, type RecentlyModel, type RecentlyRefType, RecentlyRefTypes, RequestError, type RoomOmittedNote, type RoomOmittedPage, type RoomOmittedPost, type RoomsData, SayController, type SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, type SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, type SubscribeType, SubscribeTypeToBitMap, type TLogin, type TagModel, type TextBaseModel, type TimelineData, TimelineType, TopicController, type TopicModel, type Url, UrlOptionModel, UserController, type UserModel, allControllerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
|
package/dist/index.global.js
CHANGED
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
return obj;
|
|
56
56
|
};
|
|
57
57
|
function camelcase(str) {
|
|
58
|
-
return str.replace(/^_+/, "").
|
|
58
|
+
return str.replace(/^_+/, "").replaceAll(/([_-][a-z])/gi, ($1) => {
|
|
59
59
|
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
var isMongoId = (id) => id.length === 24 && /^[
|
|
62
|
+
var isMongoId = (id) => id.length === 24 && /^[\dA-Fa-f]{24}$/.test(id);
|
|
63
63
|
|
|
64
64
|
// utils/path.ts
|
|
65
65
|
var resolveFullPath = (endpoint, path) => {
|
|
@@ -185,6 +185,9 @@
|
|
|
185
185
|
async getRecentActivities() {
|
|
186
186
|
return this.proxy.recent.get();
|
|
187
187
|
}
|
|
188
|
+
async getLastYearPublication() {
|
|
189
|
+
return this.proxy(`last-year`).publication.get();
|
|
190
|
+
}
|
|
188
191
|
};
|
|
189
192
|
|
|
190
193
|
// controllers/aggregate.ts
|
|
@@ -256,7 +259,7 @@
|
|
|
256
259
|
});
|
|
257
260
|
}
|
|
258
261
|
async generateSummary(articleId, lang = "zh-CN", token = "") {
|
|
259
|
-
return this.proxy
|
|
262
|
+
return this.proxy.summaries.generate.post({
|
|
260
263
|
params: {
|
|
261
264
|
token
|
|
262
265
|
},
|
|
@@ -827,14 +830,14 @@
|
|
|
827
830
|
loginWithToken(token) {
|
|
828
831
|
return this.proxy.login.put({
|
|
829
832
|
params: token ? {
|
|
830
|
-
token: `bearer ${token.replace(/^
|
|
833
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
831
834
|
} : void 0
|
|
832
835
|
});
|
|
833
836
|
}
|
|
834
837
|
checkTokenValid(token) {
|
|
835
838
|
return this.proxy.check_logged.get({
|
|
836
839
|
params: {
|
|
837
|
-
token: `bearer ${token.replace(/^
|
|
840
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
838
841
|
}
|
|
839
842
|
});
|
|
840
843
|
}
|
|
@@ -1029,15 +1032,15 @@
|
|
|
1029
1032
|
...options,
|
|
1030
1033
|
url
|
|
1031
1034
|
});
|
|
1032
|
-
} catch (
|
|
1033
|
-
let message =
|
|
1034
|
-
let code =
|
|
1035
|
+
} catch (error) {
|
|
1036
|
+
let message = error.message;
|
|
1037
|
+
let code = error.code || error.status || error.statusCode || error.response?.status || error.response?.statusCode || error.response?.code || 500;
|
|
1035
1038
|
if (that.options.getCodeMessageFromException) {
|
|
1036
|
-
const errorInfo = that.options.getCodeMessageFromException(
|
|
1039
|
+
const errorInfo = that.options.getCodeMessageFromException(error);
|
|
1037
1040
|
message = errorInfo.message || message;
|
|
1038
1041
|
code = errorInfo.code || code;
|
|
1039
1042
|
}
|
|
1040
|
-
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(
|
|
1043
|
+
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(error) : new RequestError(message, code, url, error);
|
|
1041
1044
|
}
|
|
1042
1045
|
const data = that.options.getDataFromResponse(res);
|
|
1043
1046
|
if (!data) {
|
|
@@ -1170,7 +1173,7 @@
|
|
|
1170
1173
|
})(SnippetType || {});
|
|
1171
1174
|
|
|
1172
1175
|
// ../../apps/core/src/modules/subscribe/subscribe.constant.ts
|
|
1173
|
-
var SubscribePostCreateBit = 1
|
|
1176
|
+
var SubscribePostCreateBit = Math.trunc(1);
|
|
1174
1177
|
var SubscribeNoteCreateBit = 1 << 1;
|
|
1175
1178
|
var SubscribeSayCreateBit = 1 << 2;
|
|
1176
1179
|
var SubscribeRecentCreateBit = 1 << 3;
|
package/dist/index.js
CHANGED
|
@@ -53,11 +53,11 @@ var camelcaseKeys = (obj) => {
|
|
|
53
53
|
return obj;
|
|
54
54
|
};
|
|
55
55
|
function camelcase(str) {
|
|
56
|
-
return str.replace(/^_+/, "").
|
|
56
|
+
return str.replace(/^_+/, "").replaceAll(/([_-][a-z])/gi, ($1) => {
|
|
57
57
|
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
var isMongoId = (id) => id.length === 24 && /^[
|
|
60
|
+
var isMongoId = (id) => id.length === 24 && /^[\dA-Fa-f]{24}$/.test(id);
|
|
61
61
|
|
|
62
62
|
// utils/path.ts
|
|
63
63
|
var resolveFullPath = (endpoint, path) => {
|
|
@@ -183,6 +183,9 @@ var ActivityController = class {
|
|
|
183
183
|
async getRecentActivities() {
|
|
184
184
|
return this.proxy.recent.get();
|
|
185
185
|
}
|
|
186
|
+
async getLastYearPublication() {
|
|
187
|
+
return this.proxy(`last-year`).publication.get();
|
|
188
|
+
}
|
|
186
189
|
};
|
|
187
190
|
|
|
188
191
|
// controllers/aggregate.ts
|
|
@@ -254,7 +257,7 @@ var AIController = class {
|
|
|
254
257
|
});
|
|
255
258
|
}
|
|
256
259
|
async generateSummary(articleId, lang = "zh-CN", token = "") {
|
|
257
|
-
return this.proxy
|
|
260
|
+
return this.proxy.summaries.generate.post({
|
|
258
261
|
params: {
|
|
259
262
|
token
|
|
260
263
|
},
|
|
@@ -825,14 +828,14 @@ var UserController = class {
|
|
|
825
828
|
loginWithToken(token) {
|
|
826
829
|
return this.proxy.login.put({
|
|
827
830
|
params: token ? {
|
|
828
|
-
token: `bearer ${token.replace(/^
|
|
831
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
829
832
|
} : void 0
|
|
830
833
|
});
|
|
831
834
|
}
|
|
832
835
|
checkTokenValid(token) {
|
|
833
836
|
return this.proxy.check_logged.get({
|
|
834
837
|
params: {
|
|
835
|
-
token: `bearer ${token.replace(/^
|
|
838
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
836
839
|
}
|
|
837
840
|
});
|
|
838
841
|
}
|
|
@@ -1027,15 +1030,15 @@ var HTTPClient = class {
|
|
|
1027
1030
|
...options,
|
|
1028
1031
|
url
|
|
1029
1032
|
});
|
|
1030
|
-
} catch (
|
|
1031
|
-
let message =
|
|
1032
|
-
let code =
|
|
1033
|
+
} catch (error) {
|
|
1034
|
+
let message = error.message;
|
|
1035
|
+
let code = error.code || error.status || error.statusCode || error.response?.status || error.response?.statusCode || error.response?.code || 500;
|
|
1033
1036
|
if (that.options.getCodeMessageFromException) {
|
|
1034
|
-
const errorInfo = that.options.getCodeMessageFromException(
|
|
1037
|
+
const errorInfo = that.options.getCodeMessageFromException(error);
|
|
1035
1038
|
message = errorInfo.message || message;
|
|
1036
1039
|
code = errorInfo.code || code;
|
|
1037
1040
|
}
|
|
1038
|
-
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(
|
|
1041
|
+
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(error) : new RequestError(message, code, url, error);
|
|
1039
1042
|
}
|
|
1040
1043
|
const data = that.options.getDataFromResponse(res);
|
|
1041
1044
|
if (!data) {
|
|
@@ -1168,7 +1171,7 @@ var SnippetType = /* @__PURE__ */ ((SnippetType2) => {
|
|
|
1168
1171
|
})(SnippetType || {});
|
|
1169
1172
|
|
|
1170
1173
|
// ../../apps/core/src/modules/subscribe/subscribe.constant.ts
|
|
1171
|
-
var SubscribePostCreateBit = 1
|
|
1174
|
+
var SubscribePostCreateBit = Math.trunc(1);
|
|
1172
1175
|
var SubscribeNoteCreateBit = 1 << 1;
|
|
1173
1176
|
var SubscribeSayCreateBit = 1 << 2;
|
|
1174
1177
|
var SubscribeRecentCreateBit = 1 << 3;
|
|
@@ -4,20 +4,20 @@ export declare const createKyAdaptor: (ky: KyInstance) => Readonly<{
|
|
|
4
4
|
responseWrapper: ResponsePromise;
|
|
5
5
|
} & {
|
|
6
6
|
default: KyInstance;
|
|
7
|
-
get<P = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined)
|
|
8
|
-
post<P_1 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
9
|
-
patch<P_2 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
10
|
-
delete<P_3 = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined)
|
|
11
|
-
put<P_4 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
7
|
+
get: <P = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P>;
|
|
8
|
+
post: <P_1 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_1>;
|
|
9
|
+
patch: <P_2 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_2>;
|
|
10
|
+
delete: <P_3 = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_3>;
|
|
11
|
+
put: <P_4 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_4>;
|
|
12
12
|
}>;
|
|
13
13
|
export declare const defaultKyAdaptor: Readonly<{
|
|
14
14
|
responseWrapper: ResponsePromise;
|
|
15
15
|
} & {
|
|
16
16
|
default: KyInstance;
|
|
17
|
-
get<P = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined)
|
|
18
|
-
post<P_1 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
19
|
-
patch<P_2 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
20
|
-
delete<P_3 = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined)
|
|
21
|
-
put<P_4 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
17
|
+
get: <P = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P>;
|
|
18
|
+
post: <P_1 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_1>;
|
|
19
|
+
patch: <P_2 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_2>;
|
|
20
|
+
delete: <P_3 = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_3>;
|
|
21
|
+
put: <P_4 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_4>;
|
|
22
22
|
}>;
|
|
23
23
|
export default defaultKyAdaptor;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { CategoryType } from '../models/category';
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
3
|
import type { IController } from '~/interfaces/controller';
|
|
3
4
|
import type { IRequestHandler, RequestProxyResult, ResponseProxyExtraRaw } from '~/interfaces/request';
|
|
4
5
|
import type { HTTPClient } from '../core/client';
|
|
5
6
|
import type { CategoryModel, CategoryWithChildrenModel, TagModel } from '../models/category';
|
|
6
7
|
import type { PostModel } from '../models/post';
|
|
7
|
-
import { CategoryType } from '../models/category';
|
|
8
8
|
declare module '../core/client' {
|
|
9
9
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
10
10
|
category: CategoryController<ResponseWrapper>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BaseCrudController } from './base';
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
3
|
import type { LinkModel } from '~/models/link';
|
|
3
4
|
import type { HTTPClient } from '../core';
|
|
4
|
-
import { BaseCrudController } from './base';
|
|
5
5
|
declare module '../core/client' {
|
|
6
6
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
7
7
|
link: LinkController<ResponseWrapper>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BaseCrudController } from './base';
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
3
|
import type { ProjectModel } from '~/models/project';
|
|
3
4
|
import type { HTTPClient } from '../core';
|
|
4
|
-
import { BaseCrudController } from './base';
|
|
5
5
|
declare module '../core/client' {
|
|
6
6
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
7
7
|
project: ProjectController<ResponseWrapper>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { BaseCrudController } from './base';
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
3
|
import type { IController } from '~/interfaces/controller';
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request';
|
|
4
5
|
import type { SayModel } from '~/models/say';
|
|
5
6
|
import type { HTTPClient } from '../core';
|
|
6
|
-
import { BaseCrudController } from './base';
|
|
7
7
|
declare module '../core/client' {
|
|
8
8
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
9
|
say: SayController<ResponseWrapper>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { BaseCrudController } from './base';
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
3
|
import type { IController } from '~/interfaces/controller';
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request';
|
|
4
5
|
import type { TopicModel } from '~/models/topic';
|
|
5
6
|
import type { HTTPClient } from '../core';
|
|
6
|
-
import { BaseCrudController } from './base';
|
|
7
7
|
declare module '../core/client' {
|
|
8
8
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
9
|
topic: TopicController<ResponseWrapper>;
|
|
@@ -6,9 +6,9 @@ export type IRequestAdapter<T = any, Response = undefined> = Readonly<(Response
|
|
|
6
6
|
responseWrapper: Response;
|
|
7
7
|
}) & {
|
|
8
8
|
default: T;
|
|
9
|
-
get<P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>)
|
|
10
|
-
post<P = unknown>(url: string, options: Partial<RequestOptions>)
|
|
11
|
-
patch<P = unknown>(url: string, options: Partial<RequestOptions>)
|
|
12
|
-
delete<P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>)
|
|
13
|
-
put<P = unknown>(url: string, options: Partial<RequestOptions>)
|
|
9
|
+
get: <P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>) => IAdaptorRequestResponseType<P>;
|
|
10
|
+
post: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
11
|
+
patch: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
12
|
+
delete: <P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>) => IAdaptorRequestResponseType<P>;
|
|
13
|
+
put: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
14
14
|
}>;
|
|
@@ -5,13 +5,13 @@ type NoStringIndex<T> = {
|
|
|
5
5
|
export type Method = 'get' | 'delete' | 'post' | 'put' | 'patch';
|
|
6
6
|
export interface IRequestHandler<ResponseWrapper> {
|
|
7
7
|
(path?: string | number): IRequestHandler<ResponseWrapper>;
|
|
8
|
-
get<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>)
|
|
9
|
-
post<P = unknown>(options?: RequestOptions)
|
|
10
|
-
patch<P = unknown>(options?: RequestOptions)
|
|
11
|
-
delete<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>)
|
|
12
|
-
put<P = unknown>(options?: RequestOptions)
|
|
13
|
-
toString(withBase?: boolean)
|
|
14
|
-
valueOf(withBase?: boolean)
|
|
8
|
+
get: <P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>) => RequestProxyResult<P, ResponseWrapper>;
|
|
9
|
+
post: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
10
|
+
patch: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
11
|
+
delete: <P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>) => RequestProxyResult<P, ResponseWrapper>;
|
|
12
|
+
put: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
13
|
+
toString: (withBase?: boolean) => string;
|
|
14
|
+
valueOf: (withBase?: boolean) => string;
|
|
15
15
|
[key: string]: IRequestHandler<ResponseWrapper>;
|
|
16
16
|
}
|
|
17
17
|
export type RequestProxyResult<T, ResponseWrapper, R = ResponseWrapper extends unknown ? {
|
package/interfaces/adapter.ts
CHANGED
|
@@ -8,29 +8,29 @@ export type IRequestAdapter<T = any, Response = undefined> = Readonly<
|
|
|
8
8
|
(Response extends undefined ? {} : { responseWrapper: Response }) & {
|
|
9
9
|
default: T
|
|
10
10
|
|
|
11
|
-
get<P = unknown>(
|
|
11
|
+
get: <P = unknown>(
|
|
12
12
|
url: string,
|
|
13
13
|
options?: Omit<RequestOptions, 'data'>,
|
|
14
|
-
)
|
|
14
|
+
) => IAdaptorRequestResponseType<P>
|
|
15
15
|
|
|
16
|
-
post<P = unknown>(
|
|
16
|
+
post: <P = unknown>(
|
|
17
17
|
url: string,
|
|
18
18
|
options: Partial<RequestOptions>,
|
|
19
|
-
)
|
|
19
|
+
) => IAdaptorRequestResponseType<P>
|
|
20
20
|
|
|
21
|
-
patch<P = unknown>(
|
|
21
|
+
patch: <P = unknown>(
|
|
22
22
|
url: string,
|
|
23
23
|
options: Partial<RequestOptions>,
|
|
24
|
-
)
|
|
24
|
+
) => IAdaptorRequestResponseType<P>
|
|
25
25
|
|
|
26
|
-
delete<P = unknown>(
|
|
26
|
+
delete: <P = unknown>(
|
|
27
27
|
url: string,
|
|
28
28
|
options?: Omit<RequestOptions, 'data'>,
|
|
29
|
-
)
|
|
29
|
+
) => IAdaptorRequestResponseType<P>
|
|
30
30
|
|
|
31
|
-
put<P = unknown>(
|
|
31
|
+
put: <P = unknown>(
|
|
32
32
|
url: string,
|
|
33
33
|
options: Partial<RequestOptions>,
|
|
34
|
-
)
|
|
34
|
+
) => IAdaptorRequestResponseType<P>
|
|
35
35
|
}
|
|
36
36
|
>
|
package/interfaces/request.ts
CHANGED
|
@@ -7,29 +7,29 @@ export type Method = 'get' | 'delete' | 'post' | 'put' | 'patch'
|
|
|
7
7
|
export interface IRequestHandler<ResponseWrapper> {
|
|
8
8
|
(path?: string | number): IRequestHandler<ResponseWrapper>
|
|
9
9
|
// @ts-ignore
|
|
10
|
-
get<P = unknown>(
|
|
10
|
+
get: <P = unknown>(
|
|
11
11
|
options?: Omit<NoStringIndex<RequestOptions>, 'data'>,
|
|
12
|
-
)
|
|
12
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
post<P = unknown>(
|
|
14
|
+
post: <P = unknown>(
|
|
15
15
|
options?: RequestOptions,
|
|
16
|
-
)
|
|
16
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
17
17
|
// @ts-ignore
|
|
18
|
-
patch<P = unknown>(
|
|
18
|
+
patch: <P = unknown>(
|
|
19
19
|
options?: RequestOptions,
|
|
20
|
-
)
|
|
20
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
21
21
|
// @ts-ignore
|
|
22
|
-
delete<P = unknown>(
|
|
22
|
+
delete: <P = unknown>(
|
|
23
23
|
options?: Omit<NoStringIndex<RequestOptions>, 'data'>,
|
|
24
|
-
)
|
|
24
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
25
25
|
// @ts-ignore
|
|
26
|
-
put<P = unknown>(
|
|
26
|
+
put: <P = unknown>(
|
|
27
27
|
options?: RequestOptions,
|
|
28
|
-
)
|
|
28
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
29
29
|
// @ts-ignore
|
|
30
|
-
toString(withBase?: boolean)
|
|
30
|
+
toString: (withBase?: boolean) => string
|
|
31
31
|
// @ts-ignore
|
|
32
|
-
valueOf(withBase?: boolean)
|
|
32
|
+
valueOf: (withBase?: boolean) => string
|
|
33
33
|
[key: string]: IRequestHandler<ResponseWrapper>
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -39,18 +39,18 @@ export type RequestProxyResult<
|
|
|
39
39
|
R = ResponseWrapper extends unknown
|
|
40
40
|
? { data: T; [key: string]: any }
|
|
41
41
|
: ResponseWrapper extends { data: T }
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
? ResponseWrapper
|
|
43
|
+
: Omit<ResponseWrapper, 'data'> & { data: T },
|
|
44
44
|
> = Promise<ResponseProxyExtraRaw<T, R, ResponseWrapper>>
|
|
45
45
|
|
|
46
46
|
type CamelToSnake<T extends string, P extends string = ''> = string extends T
|
|
47
47
|
? string
|
|
48
48
|
: T extends `${infer C0}${infer R}`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
? CamelToSnake<
|
|
50
|
+
R,
|
|
51
|
+
`${P}${C0 extends Lowercase<C0> ? '' : '_'}${Lowercase<C0>}`
|
|
52
|
+
>
|
|
53
|
+
: P
|
|
54
54
|
|
|
55
55
|
type CamelKeysToSnake<T> = {
|
|
56
56
|
[K in keyof T as CamelToSnake<Extract<K, string>>]: T[K]
|
|
@@ -60,11 +60,11 @@ type ResponseWrapperType<Response, RawData, T> = {
|
|
|
60
60
|
$raw: Response extends { data: infer T }
|
|
61
61
|
? Response
|
|
62
62
|
: Response extends unknown
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
? {
|
|
64
|
+
[i: string]: any
|
|
65
|
+
data: RawData extends unknown ? CamelKeysToSnake<T> : RawData
|
|
66
|
+
}
|
|
67
|
+
: Response
|
|
68
68
|
$request: {
|
|
69
69
|
path: string
|
|
70
70
|
method: string
|
|
@@ -81,5 +81,5 @@ export type ResponseProxyExtraRaw<
|
|
|
81
81
|
> = T extends object
|
|
82
82
|
? T & ResponseWrapperType<Response, RawData, T>
|
|
83
83
|
: T extends unknown
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
? T & ResponseWrapperType<Response, RawData, T>
|
|
85
|
+
: unknown
|
package/models/activity.ts
CHANGED
|
@@ -100,3 +100,33 @@ export interface RecentRecent {
|
|
|
100
100
|
down: number
|
|
101
101
|
created: string
|
|
102
102
|
}
|
|
103
|
+
|
|
104
|
+
export interface LastYearPublication {
|
|
105
|
+
posts: PostsItem[]
|
|
106
|
+
notes: NotesItem[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface PostsItem {
|
|
110
|
+
id: string
|
|
111
|
+
created: string
|
|
112
|
+
title: string
|
|
113
|
+
slug: string
|
|
114
|
+
categoryId: string
|
|
115
|
+
category: Category
|
|
116
|
+
}
|
|
117
|
+
interface Category {
|
|
118
|
+
id: string
|
|
119
|
+
type: number
|
|
120
|
+
name: string
|
|
121
|
+
slug: string
|
|
122
|
+
created: string
|
|
123
|
+
}
|
|
124
|
+
interface NotesItem {
|
|
125
|
+
id: string
|
|
126
|
+
created: string
|
|
127
|
+
title: string
|
|
128
|
+
mood: string
|
|
129
|
+
weather: string
|
|
130
|
+
nid: number
|
|
131
|
+
bookmark: boolean
|
|
132
|
+
}
|
package/models/comment.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { CollectionRefTypes } from '@core/constants/db.constant'
|
|
1
2
|
import type { BaseModel } from './base'
|
|
2
3
|
import type { CategoryModel } from './category'
|
|
3
4
|
|
|
4
|
-
import { CollectionRefTypes } from '@core/constants/db.constant'
|
|
5
|
-
|
|
6
5
|
export { CollectionRefTypes }
|
|
7
6
|
export interface CommentModel extends BaseModel {
|
|
8
7
|
refType: CollectionRefTypes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-space/api-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A api client for mx-space server@next",
|
|
6
6
|
"author": "Innei",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/cors": "2.8.17",
|
|
48
48
|
"@types/express": "4.17.21",
|
|
49
|
-
"@types/lodash": "4.17.
|
|
49
|
+
"@types/lodash": "4.17.1",
|
|
50
50
|
"abort-controller": "3.0.0",
|
|
51
51
|
"axios": "^1.6.7",
|
|
52
52
|
"camelcase-keys": "^9.1.3",
|
package/tsup.config.ts
CHANGED