@mx-space/api-client 1.11.2 → 1.12.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.
@@ -3,6 +3,7 @@ import type { IController } from '~/interfaces/controller'
3
3
  import type { IRequestHandler } from '~/interfaces/request'
4
4
  import type {
5
5
  ActivityPresence,
6
+ LastYearPublication,
6
7
  RecentActivities,
7
8
  RoomsData,
8
9
  } from '~/models/activity'
@@ -95,4 +96,8 @@ export class ActivityController<ResponseWrapper> implements IController {
95
96
  async getRecentActivities() {
96
97
  return this.proxy.recent.get<RecentActivities>()
97
98
  }
99
+
100
+ async getLastYearPublication(): Promise<LastYearPublication> {
101
+ return this.proxy(`last-year`).publication.get<LastYearPublication>()
102
+ }
98
103
  }
@@ -0,0 +1,61 @@
1
+ import type { IRequestAdapter } from '~/interfaces/adapter'
2
+ import type { IController } from '~/interfaces/controller'
3
+ import type { IRequestHandler } from '~/interfaces/request'
4
+ import type { HTTPClient } from '../core'
5
+ import type { AISummaryModel } from '../models/ai'
6
+
7
+ import { autoBind } from '~/utils/auto-bind'
8
+
9
+ declare module '../core/client' {
10
+ interface HTTPClient<
11
+ T extends IRequestAdapter = IRequestAdapter,
12
+ ResponseWrapper = unknown,
13
+ > {
14
+ ai: AIController<ResponseWrapper>
15
+ }
16
+ }
17
+
18
+ /**
19
+ * @support core >= 5.6.0
20
+ */
21
+ export class AIController<ResponseWrapper> implements IController {
22
+ base = 'ai'
23
+ name = 'ai'
24
+
25
+ constructor(private client: HTTPClient) {
26
+ autoBind(this)
27
+ }
28
+
29
+ public get proxy(): IRequestHandler<ResponseWrapper> {
30
+ return this.client.proxy(this.base)
31
+ }
32
+
33
+ async getSummary({
34
+ articleId,
35
+ lang = 'zh-CN',
36
+ onlyDb,
37
+ }: {
38
+ articleId: string
39
+ lang?: string
40
+ onlyDb?: boolean
41
+ }) {
42
+ return this.proxy.summaries.article(articleId).get<AISummaryModel>({
43
+ params: {
44
+ lang,
45
+ onlyDb,
46
+ },
47
+ })
48
+ }
49
+
50
+ async generateSummary(articleId: string, lang = 'zh-CN', token = '') {
51
+ return this.proxy('generate-summary').post<AISummaryModel>({
52
+ params: {
53
+ token,
54
+ },
55
+ data: {
56
+ lang,
57
+ refId: articleId,
58
+ },
59
+ })
60
+ }
61
+ }
@@ -1,6 +1,7 @@
1
1
  import { AckController } from './ack'
2
2
  import { ActivityController } from './activity'
3
3
  import { AggregateController } from './aggregate'
4
+ import { AIController } from './ai'
4
5
  import { CategoryController } from './category'
5
6
  import { CommentController } from './comment'
6
7
  import { LinkController } from './link'
@@ -22,6 +23,7 @@ import { TopicController } from './topic'
22
23
  import { UserController } from './user'
23
24
 
24
25
  export const allControllers = [
26
+ AIController,
25
27
  AckController,
26
28
  ActivityController,
27
29
  AggregateController,
@@ -43,6 +45,7 @@ export const allControllers = [
43
45
  ]
44
46
 
45
47
  export const allControllerNames = [
48
+ 'ai',
46
49
  'ack',
47
50
  'activity',
48
51
  'aggregate',
@@ -69,6 +72,7 @@ export const allControllerNames = [
69
72
  ] as const
70
73
 
71
74
  export {
75
+ AIController,
72
76
  AckController,
73
77
  ActivityController,
74
78
  AggregateController,
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // index.ts
21
21
  var api_client_exports = {};
22
22
  __export(api_client_exports, {
23
+ AIController: () => AIController,
23
24
  AckController: () => AckController,
24
25
  ActivityController: () => ActivityController,
25
26
  AggregateController: () => AggregateController,
@@ -111,17 +112,19 @@ var camelcaseKeys = (obj) => {
111
112
  }
112
113
  if (isPlainObject(obj)) {
113
114
  return Object.keys(obj).reduce((result, key) => {
114
- result[camelcase(key)] = camelcaseKeys(obj[key]);
115
+ const nextKey = isMongoId(key) ? key : camelcase(key);
116
+ result[nextKey] = camelcaseKeys(obj[key]);
115
117
  return result;
116
118
  }, {});
117
119
  }
118
120
  return obj;
119
121
  };
120
122
  function camelcase(str) {
121
- return str.replace(/([-_][a-z])/gi, ($1) => {
123
+ return str.replace(/^_+/, "").replace(/([-_][a-z])/gi, ($1) => {
122
124
  return $1.toUpperCase().replace("-", "").replace("_", "");
123
125
  });
124
126
  }
127
+ var isMongoId = (id) => id.length === 24 && /^[0-9a-fA-F]{24}$/.test(id);
125
128
 
126
129
  // utils/path.ts
127
130
  var resolveFullPath = (endpoint, path) => {
@@ -247,6 +250,9 @@ var ActivityController = class {
247
250
  async getRecentActivities() {
248
251
  return this.proxy.recent.get();
249
252
  }
253
+ async getLastYearPublication() {
254
+ return this.proxy(`last-year`).publication.get();
255
+ }
250
256
  };
251
257
 
252
258
  // controllers/aggregate.ts
@@ -294,6 +300,42 @@ var AggregateController = class {
294
300
  }
295
301
  };
296
302
 
303
+ // controllers/ai.ts
304
+ var AIController = class {
305
+ constructor(client) {
306
+ this.client = client;
307
+ this.base = "ai";
308
+ this.name = "ai";
309
+ autoBind(this);
310
+ }
311
+ get proxy() {
312
+ return this.client.proxy(this.base);
313
+ }
314
+ async getSummary({
315
+ articleId,
316
+ lang = "zh-CN",
317
+ onlyDb
318
+ }) {
319
+ return this.proxy.summaries.article(articleId).get({
320
+ params: {
321
+ lang,
322
+ onlyDb
323
+ }
324
+ });
325
+ }
326
+ async generateSummary(articleId, lang = "zh-CN", token = "") {
327
+ return this.proxy("generate-summary").post({
328
+ params: {
329
+ token
330
+ },
331
+ data: {
332
+ lang,
333
+ refId: articleId
334
+ }
335
+ });
336
+ }
337
+ };
338
+
297
339
  // core/error.ts
298
340
  var RequestError = class extends Error {
299
341
  constructor(message, status, path, raw) {
@@ -868,6 +910,7 @@ var UserController = class {
868
910
 
869
911
  // controllers/index.ts
870
912
  var allControllers = [
913
+ AIController,
871
914
  AckController,
872
915
  ActivityController,
873
916
  AggregateController,
@@ -888,6 +931,7 @@ var allControllers = [
888
931
  UserController
889
932
  ];
890
933
  var allControllerNames = [
934
+ "ai",
891
935
  "ack",
892
936
  "activity",
893
937
  "aggregate",
@@ -1211,6 +1255,7 @@ var SubscribeTypeToBitMap = {
1211
1255
  var api_client_default = createClient;
1212
1256
  // Annotate the CommonJS export names for ESM import in node:
1213
1257
  0 && (module.exports = {
1258
+ AIController,
1214
1259
  AckController,
1215
1260
  ActivityController,
1216
1261
  AggregateController,
package/dist/index.d.cts CHANGED
@@ -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 '../core/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';
@@ -691,6 +720,105 @@ declare class AggregateController<ResponseWrapper> implements IController {
691
720
  }>;
692
721
  }
693
722
 
723
+ interface AISummaryModel {
724
+ id: string;
725
+ created: string;
726
+ summary: string;
727
+ hash: string;
728
+ refId: string;
729
+ lang: string;
730
+ }
731
+
732
+ declare module '../core/client' {
733
+ interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
734
+ ai: AIController<ResponseWrapper>;
735
+ }
736
+ }
737
+ /**
738
+ * @support core >= 5.6.0
739
+ */
740
+ declare class AIController<ResponseWrapper> implements IController {
741
+ private client;
742
+ base: string;
743
+ name: string;
744
+ constructor(client: HTTPClient);
745
+ get proxy(): IRequestHandler<ResponseWrapper>;
746
+ getSummary({ articleId, lang, onlyDb, }: {
747
+ articleId: string;
748
+ lang?: string;
749
+ onlyDb?: boolean;
750
+ }): Promise<AISummaryModel & {
751
+ $raw: ResponseWrapper extends {
752
+ data: infer T;
753
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
754
+ [i: string]: any;
755
+ data: (ResponseWrapper extends unknown ? {
756
+ [key: string]: any;
757
+ data: AISummaryModel;
758
+ } : ResponseWrapper extends {
759
+ data: AISummaryModel;
760
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
761
+ data: AISummaryModel;
762
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
763
+ [key: string]: any;
764
+ data: AISummaryModel;
765
+ } : ResponseWrapper extends {
766
+ data: AISummaryModel;
767
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
768
+ data: AISummaryModel;
769
+ }) ? T_1 extends unknown ? {
770
+ id: string;
771
+ created: string;
772
+ summary: string;
773
+ hash: string;
774
+ ref_id: string;
775
+ lang: string;
776
+ } : T_1 : never : never;
777
+ } : ResponseWrapper;
778
+ $request: {
779
+ [k: string]: string;
780
+ path: string;
781
+ method: string;
782
+ };
783
+ $serialized: AISummaryModel;
784
+ }>;
785
+ generateSummary(articleId: string, lang?: string, token?: string): Promise<AISummaryModel & {
786
+ $raw: ResponseWrapper extends {
787
+ data: infer T;
788
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
789
+ [i: string]: any;
790
+ data: (ResponseWrapper extends unknown ? {
791
+ [key: string]: any;
792
+ data: AISummaryModel;
793
+ } : ResponseWrapper extends {
794
+ data: AISummaryModel;
795
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
796
+ data: AISummaryModel;
797
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
798
+ [key: string]: any;
799
+ data: AISummaryModel;
800
+ } : ResponseWrapper extends {
801
+ data: AISummaryModel;
802
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
803
+ data: AISummaryModel;
804
+ }) ? T_1 extends unknown ? {
805
+ id: string;
806
+ created: string;
807
+ summary: string;
808
+ hash: string;
809
+ ref_id: string;
810
+ lang: string;
811
+ } : T_1 : never : never;
812
+ } : ResponseWrapper;
813
+ $request: {
814
+ [k: string]: string;
815
+ path: string;
816
+ method: string;
817
+ };
818
+ $serialized: AISummaryModel;
819
+ }>;
820
+ }
821
+
694
822
  declare module '../core/client' {
695
823
  interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
696
824
  category: CategoryController<ResponseWrapper>;
@@ -1700,8 +1828,8 @@ declare class UserController<ResponseWrapper> implements IController {
1700
1828
  }>;
1701
1829
  }
1702
1830
 
1703
- declare const allControllers: (typeof AckController | typeof ActivityController | 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)[];
1704
- declare const allControllerNames: readonly ["ack", "activity", "aggregate", "category", "comment", "link", "note", "page", "post", "project", "topic", "recently", "say", "search", "snippet", "serverless", "subscribe", "user", "friend", "master", "shorthand"];
1831
+ declare const allControllers: (typeof AckController | typeof ActivityController | typeof AggregateController | typeof AIController | 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)[];
1832
+ declare const allControllerNames: readonly ["ai", "ack", "activity", "aggregate", "category", "comment", "link", "note", "page", "post", "project", "topic", "recently", "say", "search", "snippet", "serverless", "subscribe", "user", "friend", "master", "shorthand"];
1705
1833
 
1706
1834
  declare enum SnippetType {
1707
1835
  JSON = "json",
@@ -1727,4 +1855,4 @@ interface SnippetModel<T = unknown> extends BaseModel {
1727
1855
  */
1728
1856
  declare const camelcaseKeys: <T = any>(obj: any) => T;
1729
1857
 
1730
- export { 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.d.ts CHANGED
@@ -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';
@@ -691,6 +720,105 @@ declare class AggregateController<ResponseWrapper> implements IController {
691
720
  }>;
692
721
  }
693
722
 
723
+ interface AISummaryModel {
724
+ id: string;
725
+ created: string;
726
+ summary: string;
727
+ hash: string;
728
+ refId: string;
729
+ lang: string;
730
+ }
731
+
732
+ declare module '@mx-space/api-client' {
733
+ interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
734
+ ai: AIController<ResponseWrapper>;
735
+ }
736
+ }
737
+ /**
738
+ * @support core >= 5.6.0
739
+ */
740
+ declare class AIController<ResponseWrapper> implements IController {
741
+ private client;
742
+ base: string;
743
+ name: string;
744
+ constructor(client: HTTPClient);
745
+ get proxy(): IRequestHandler<ResponseWrapper>;
746
+ getSummary({ articleId, lang, onlyDb, }: {
747
+ articleId: string;
748
+ lang?: string;
749
+ onlyDb?: boolean;
750
+ }): Promise<AISummaryModel & {
751
+ $raw: ResponseWrapper extends {
752
+ data: infer T;
753
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
754
+ [i: string]: any;
755
+ data: (ResponseWrapper extends unknown ? {
756
+ [key: string]: any;
757
+ data: AISummaryModel;
758
+ } : ResponseWrapper extends {
759
+ data: AISummaryModel;
760
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
761
+ data: AISummaryModel;
762
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
763
+ [key: string]: any;
764
+ data: AISummaryModel;
765
+ } : ResponseWrapper extends {
766
+ data: AISummaryModel;
767
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
768
+ data: AISummaryModel;
769
+ }) ? T_1 extends unknown ? {
770
+ id: string;
771
+ created: string;
772
+ summary: string;
773
+ hash: string;
774
+ ref_id: string;
775
+ lang: string;
776
+ } : T_1 : never : never;
777
+ } : ResponseWrapper;
778
+ $request: {
779
+ [k: string]: string;
780
+ path: string;
781
+ method: string;
782
+ };
783
+ $serialized: AISummaryModel;
784
+ }>;
785
+ generateSummary(articleId: string, lang?: string, token?: string): Promise<AISummaryModel & {
786
+ $raw: ResponseWrapper extends {
787
+ data: infer T;
788
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
789
+ [i: string]: any;
790
+ data: (ResponseWrapper extends unknown ? {
791
+ [key: string]: any;
792
+ data: AISummaryModel;
793
+ } : ResponseWrapper extends {
794
+ data: AISummaryModel;
795
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
796
+ data: AISummaryModel;
797
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
798
+ [key: string]: any;
799
+ data: AISummaryModel;
800
+ } : ResponseWrapper extends {
801
+ data: AISummaryModel;
802
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
803
+ data: AISummaryModel;
804
+ }) ? T_1 extends unknown ? {
805
+ id: string;
806
+ created: string;
807
+ summary: string;
808
+ hash: string;
809
+ ref_id: string;
810
+ lang: string;
811
+ } : T_1 : never : never;
812
+ } : ResponseWrapper;
813
+ $request: {
814
+ [k: string]: string;
815
+ path: string;
816
+ method: string;
817
+ };
818
+ $serialized: AISummaryModel;
819
+ }>;
820
+ }
821
+
694
822
  declare module '@mx-space/api-client' {
695
823
  interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
696
824
  category: CategoryController<ResponseWrapper>;
@@ -1700,8 +1828,8 @@ declare class UserController<ResponseWrapper> implements IController {
1700
1828
  }>;
1701
1829
  }
1702
1830
 
1703
- declare const allControllers: (typeof AckController | typeof ActivityController | 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)[];
1704
- declare const allControllerNames: readonly ["ack", "activity", "aggregate", "category", "comment", "link", "note", "page", "post", "project", "topic", "recently", "say", "search", "snippet", "serverless", "subscribe", "user", "friend", "master", "shorthand"];
1831
+ declare const allControllers: (typeof AckController | typeof ActivityController | typeof AggregateController | typeof AIController | 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)[];
1832
+ declare const allControllerNames: readonly ["ai", "ack", "activity", "aggregate", "category", "comment", "link", "note", "page", "post", "project", "topic", "recently", "say", "search", "snippet", "serverless", "subscribe", "user", "friend", "master", "shorthand"];
1705
1833
 
1706
1834
  declare enum SnippetType {
1707
1835
  JSON = "json",
@@ -1727,4 +1855,4 @@ interface SnippetModel<T = unknown> extends BaseModel {
1727
1855
  */
1728
1856
  declare const camelcaseKeys: <T = any>(obj: any) => T;
1729
1857
 
1730
- export { 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 };
@@ -47,17 +47,19 @@
47
47
  }
48
48
  if (isPlainObject(obj)) {
49
49
  return Object.keys(obj).reduce((result, key) => {
50
- result[camelcase(key)] = camelcaseKeys(obj[key]);
50
+ const nextKey = isMongoId(key) ? key : camelcase(key);
51
+ result[nextKey] = camelcaseKeys(obj[key]);
51
52
  return result;
52
53
  }, {});
53
54
  }
54
55
  return obj;
55
56
  };
56
57
  function camelcase(str) {
57
- return str.replace(/([-_][a-z])/gi, ($1) => {
58
+ return str.replace(/^_+/, "").replace(/([-_][a-z])/gi, ($1) => {
58
59
  return $1.toUpperCase().replace("-", "").replace("_", "");
59
60
  });
60
61
  }
62
+ var isMongoId = (id) => id.length === 24 && /^[0-9a-fA-F]{24}$/.test(id);
61
63
 
62
64
  // utils/path.ts
63
65
  var resolveFullPath = (endpoint, path) => {
@@ -183,6 +185,9 @@
183
185
  async getRecentActivities() {
184
186
  return this.proxy.recent.get();
185
187
  }
188
+ async getLastYearPublication() {
189
+ return this.proxy(`last-year`).publication.get();
190
+ }
186
191
  };
187
192
 
188
193
  // controllers/aggregate.ts
@@ -230,6 +235,42 @@
230
235
  }
231
236
  };
232
237
 
238
+ // controllers/ai.ts
239
+ var AIController = class {
240
+ constructor(client) {
241
+ this.client = client;
242
+ this.base = "ai";
243
+ this.name = "ai";
244
+ autoBind(this);
245
+ }
246
+ get proxy() {
247
+ return this.client.proxy(this.base);
248
+ }
249
+ async getSummary({
250
+ articleId,
251
+ lang = "zh-CN",
252
+ onlyDb
253
+ }) {
254
+ return this.proxy.summaries.article(articleId).get({
255
+ params: {
256
+ lang,
257
+ onlyDb
258
+ }
259
+ });
260
+ }
261
+ async generateSummary(articleId, lang = "zh-CN", token = "") {
262
+ return this.proxy("generate-summary").post({
263
+ params: {
264
+ token
265
+ },
266
+ data: {
267
+ lang,
268
+ refId: articleId
269
+ }
270
+ });
271
+ }
272
+ };
273
+
233
274
  // core/error.ts
234
275
  var RequestError = class extends Error {
235
276
  constructor(message, status, path, raw) {
@@ -804,6 +845,7 @@
804
845
 
805
846
  // controllers/index.ts
806
847
  var allControllers = [
848
+ AIController,
807
849
  AckController,
808
850
  ActivityController,
809
851
  AggregateController,
@@ -824,6 +866,7 @@
824
866
  UserController
825
867
  ];
826
868
  var allControllerNames = [
869
+ "ai",
827
870
  "ack",
828
871
  "activity",
829
872
  "aggregate",
package/dist/index.js CHANGED
@@ -45,17 +45,19 @@ var camelcaseKeys = (obj) => {
45
45
  }
46
46
  if (isPlainObject(obj)) {
47
47
  return Object.keys(obj).reduce((result, key) => {
48
- result[camelcase(key)] = camelcaseKeys(obj[key]);
48
+ const nextKey = isMongoId(key) ? key : camelcase(key);
49
+ result[nextKey] = camelcaseKeys(obj[key]);
49
50
  return result;
50
51
  }, {});
51
52
  }
52
53
  return obj;
53
54
  };
54
55
  function camelcase(str) {
55
- return str.replace(/([-_][a-z])/gi, ($1) => {
56
+ return str.replace(/^_+/, "").replace(/([-_][a-z])/gi, ($1) => {
56
57
  return $1.toUpperCase().replace("-", "").replace("_", "");
57
58
  });
58
59
  }
60
+ var isMongoId = (id) => id.length === 24 && /^[0-9a-fA-F]{24}$/.test(id);
59
61
 
60
62
  // utils/path.ts
61
63
  var resolveFullPath = (endpoint, path) => {
@@ -181,6 +183,9 @@ var ActivityController = class {
181
183
  async getRecentActivities() {
182
184
  return this.proxy.recent.get();
183
185
  }
186
+ async getLastYearPublication() {
187
+ return this.proxy(`last-year`).publication.get();
188
+ }
184
189
  };
185
190
 
186
191
  // controllers/aggregate.ts
@@ -228,6 +233,42 @@ var AggregateController = class {
228
233
  }
229
234
  };
230
235
 
236
+ // controllers/ai.ts
237
+ var AIController = class {
238
+ constructor(client) {
239
+ this.client = client;
240
+ this.base = "ai";
241
+ this.name = "ai";
242
+ autoBind(this);
243
+ }
244
+ get proxy() {
245
+ return this.client.proxy(this.base);
246
+ }
247
+ async getSummary({
248
+ articleId,
249
+ lang = "zh-CN",
250
+ onlyDb
251
+ }) {
252
+ return this.proxy.summaries.article(articleId).get({
253
+ params: {
254
+ lang,
255
+ onlyDb
256
+ }
257
+ });
258
+ }
259
+ async generateSummary(articleId, lang = "zh-CN", token = "") {
260
+ return this.proxy("generate-summary").post({
261
+ params: {
262
+ token
263
+ },
264
+ data: {
265
+ lang,
266
+ refId: articleId
267
+ }
268
+ });
269
+ }
270
+ };
271
+
231
272
  // core/error.ts
232
273
  var RequestError = class extends Error {
233
274
  constructor(message, status, path, raw) {
@@ -802,6 +843,7 @@ var UserController = class {
802
843
 
803
844
  // controllers/index.ts
804
845
  var allControllers = [
846
+ AIController,
805
847
  AckController,
806
848
  ActivityController,
807
849
  AggregateController,
@@ -822,6 +864,7 @@ var allControllers = [
822
864
  UserController
823
865
  ];
824
866
  var allControllerNames = [
867
+ "ai",
825
868
  "ack",
826
869
  "activity",
827
870
  "aggregate",
@@ -1144,6 +1187,7 @@ var SubscribeTypeToBitMap = {
1144
1187
  // index.ts
1145
1188
  var api_client_default = createClient;
1146
1189
  export {
1190
+ AIController,
1147
1191
  AckController,
1148
1192
  ActivityController,
1149
1193
  AggregateController,
@@ -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/ai.ts ADDED
@@ -0,0 +1,8 @@
1
+ export interface AISummaryModel {
2
+ id: string
3
+ created: string
4
+ summary: string
5
+ hash: string
6
+ refId: string
7
+ lang: string
8
+ }
package/models/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './activity'
2
2
  export * from './aggregate'
3
+ export * from './ai'
3
4
  export * from './base'
4
5
  export * from './category'
5
6
  export * from './comment'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-space/api-client",
3
- "version": "1.11.2",
3
+ "version": "1.12.1",
4
4
  "type": "module",
5
5
  "description": "A api client for mx-space server@next",
6
6
  "author": "Innei",
@@ -57,6 +57,6 @@
57
57
  "tsup": "8.0.2",
58
58
  "umi-request": "1.4.0",
59
59
  "vite": "^5.1.7",
60
- "vitest": "^1.0.4"
60
+ "vitest": "1.5.2"
61
61
  }
62
62
  }