@mx-space/api-client 1.11.2 → 1.12.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.
@@ -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) => {
@@ -294,6 +297,42 @@ var AggregateController = class {
294
297
  }
295
298
  };
296
299
 
300
+ // controllers/ai.ts
301
+ var AIController = class {
302
+ constructor(client) {
303
+ this.client = client;
304
+ this.base = "ai";
305
+ this.name = "ai";
306
+ autoBind(this);
307
+ }
308
+ get proxy() {
309
+ return this.client.proxy(this.base);
310
+ }
311
+ async getSummary({
312
+ articleId,
313
+ lang = "zh-CN",
314
+ onlyDb
315
+ }) {
316
+ return this.proxy.summaries.article(articleId).get({
317
+ params: {
318
+ lang,
319
+ onlyDb
320
+ }
321
+ });
322
+ }
323
+ async generateSummary(articleId, lang = "zh-CN", token = "") {
324
+ return this.proxy("generate-summary").post({
325
+ params: {
326
+ token
327
+ },
328
+ data: {
329
+ lang,
330
+ refId: articleId
331
+ }
332
+ });
333
+ }
334
+ };
335
+
297
336
  // core/error.ts
298
337
  var RequestError = class extends Error {
299
338
  constructor(message, status, path, raw) {
@@ -868,6 +907,7 @@ var UserController = class {
868
907
 
869
908
  // controllers/index.ts
870
909
  var allControllers = [
910
+ AIController,
871
911
  AckController,
872
912
  ActivityController,
873
913
  AggregateController,
@@ -888,6 +928,7 @@ var allControllers = [
888
928
  UserController
889
929
  ];
890
930
  var allControllerNames = [
931
+ "ai",
891
932
  "ack",
892
933
  "activity",
893
934
  "aggregate",
@@ -1211,6 +1252,7 @@ var SubscribeTypeToBitMap = {
1211
1252
  var api_client_default = createClient;
1212
1253
  // Annotate the CommonJS export names for ESM import in node:
1213
1254
  0 && (module.exports = {
1255
+ AIController,
1214
1256
  AckController,
1215
1257
  ActivityController,
1216
1258
  AggregateController,
package/dist/index.d.cts CHANGED
@@ -691,6 +691,105 @@ declare class AggregateController<ResponseWrapper> implements IController {
691
691
  }>;
692
692
  }
693
693
 
694
+ interface AISummaryModel {
695
+ id: string;
696
+ created: string;
697
+ summary: string;
698
+ hash: string;
699
+ refId: string;
700
+ lang: string;
701
+ }
702
+
703
+ declare module '../core/client' {
704
+ interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
705
+ ai: AIController<ResponseWrapper>;
706
+ }
707
+ }
708
+ /**
709
+ * @support core >= 5.6.0
710
+ */
711
+ declare class AIController<ResponseWrapper> implements IController {
712
+ private client;
713
+ base: string;
714
+ name: string;
715
+ constructor(client: HTTPClient);
716
+ get proxy(): IRequestHandler<ResponseWrapper>;
717
+ getSummary({ articleId, lang, onlyDb, }: {
718
+ articleId: string;
719
+ lang?: string;
720
+ onlyDb?: boolean;
721
+ }): Promise<AISummaryModel & {
722
+ $raw: ResponseWrapper extends {
723
+ data: infer T;
724
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
725
+ [i: string]: any;
726
+ data: (ResponseWrapper extends unknown ? {
727
+ [key: string]: any;
728
+ data: AISummaryModel;
729
+ } : ResponseWrapper extends {
730
+ data: AISummaryModel;
731
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
732
+ data: AISummaryModel;
733
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
734
+ [key: string]: any;
735
+ data: AISummaryModel;
736
+ } : ResponseWrapper extends {
737
+ data: AISummaryModel;
738
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
739
+ data: AISummaryModel;
740
+ }) ? T_1 extends unknown ? {
741
+ id: string;
742
+ created: string;
743
+ summary: string;
744
+ hash: string;
745
+ ref_id: string;
746
+ lang: string;
747
+ } : T_1 : never : never;
748
+ } : ResponseWrapper;
749
+ $request: {
750
+ [k: string]: string;
751
+ path: string;
752
+ method: string;
753
+ };
754
+ $serialized: AISummaryModel;
755
+ }>;
756
+ generateSummary(articleId: string, lang?: string, token?: string): Promise<AISummaryModel & {
757
+ $raw: ResponseWrapper extends {
758
+ data: infer T;
759
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
760
+ [i: string]: any;
761
+ data: (ResponseWrapper extends unknown ? {
762
+ [key: string]: any;
763
+ data: AISummaryModel;
764
+ } : ResponseWrapper extends {
765
+ data: AISummaryModel;
766
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
767
+ data: AISummaryModel;
768
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
769
+ [key: string]: any;
770
+ data: AISummaryModel;
771
+ } : ResponseWrapper extends {
772
+ data: AISummaryModel;
773
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
774
+ data: AISummaryModel;
775
+ }) ? T_1 extends unknown ? {
776
+ id: string;
777
+ created: string;
778
+ summary: string;
779
+ hash: string;
780
+ ref_id: string;
781
+ lang: string;
782
+ } : T_1 : never : never;
783
+ } : ResponseWrapper;
784
+ $request: {
785
+ [k: string]: string;
786
+ path: string;
787
+ method: string;
788
+ };
789
+ $serialized: AISummaryModel;
790
+ }>;
791
+ }
792
+
694
793
  declare module '../core/client' {
695
794
  interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
696
795
  category: CategoryController<ResponseWrapper>;
@@ -1700,8 +1799,8 @@ declare class UserController<ResponseWrapper> implements IController {
1700
1799
  }>;
1701
1800
  }
1702
1801
 
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"];
1802
+ 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)[];
1803
+ 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
1804
 
1706
1805
  declare enum SnippetType {
1707
1806
  JSON = "json",
@@ -1727,4 +1826,4 @@ interface SnippetModel<T = unknown> extends BaseModel {
1727
1826
  */
1728
1827
  declare const camelcaseKeys: <T = any>(obj: any) => T;
1729
1828
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -691,6 +691,105 @@ declare class AggregateController<ResponseWrapper> implements IController {
691
691
  }>;
692
692
  }
693
693
 
694
+ interface AISummaryModel {
695
+ id: string;
696
+ created: string;
697
+ summary: string;
698
+ hash: string;
699
+ refId: string;
700
+ lang: string;
701
+ }
702
+
703
+ declare module '@mx-space/api-client' {
704
+ interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
705
+ ai: AIController<ResponseWrapper>;
706
+ }
707
+ }
708
+ /**
709
+ * @support core >= 5.6.0
710
+ */
711
+ declare class AIController<ResponseWrapper> implements IController {
712
+ private client;
713
+ base: string;
714
+ name: string;
715
+ constructor(client: HTTPClient);
716
+ get proxy(): IRequestHandler<ResponseWrapper>;
717
+ getSummary({ articleId, lang, onlyDb, }: {
718
+ articleId: string;
719
+ lang?: string;
720
+ onlyDb?: boolean;
721
+ }): Promise<AISummaryModel & {
722
+ $raw: ResponseWrapper extends {
723
+ data: infer T;
724
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
725
+ [i: string]: any;
726
+ data: (ResponseWrapper extends unknown ? {
727
+ [key: string]: any;
728
+ data: AISummaryModel;
729
+ } : ResponseWrapper extends {
730
+ data: AISummaryModel;
731
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
732
+ data: AISummaryModel;
733
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
734
+ [key: string]: any;
735
+ data: AISummaryModel;
736
+ } : ResponseWrapper extends {
737
+ data: AISummaryModel;
738
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
739
+ data: AISummaryModel;
740
+ }) ? T_1 extends unknown ? {
741
+ id: string;
742
+ created: string;
743
+ summary: string;
744
+ hash: string;
745
+ ref_id: string;
746
+ lang: string;
747
+ } : T_1 : never : never;
748
+ } : ResponseWrapper;
749
+ $request: {
750
+ [k: string]: string;
751
+ path: string;
752
+ method: string;
753
+ };
754
+ $serialized: AISummaryModel;
755
+ }>;
756
+ generateSummary(articleId: string, lang?: string, token?: string): Promise<AISummaryModel & {
757
+ $raw: ResponseWrapper extends {
758
+ data: infer T;
759
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
760
+ [i: string]: any;
761
+ data: (ResponseWrapper extends unknown ? {
762
+ [key: string]: any;
763
+ data: AISummaryModel;
764
+ } : ResponseWrapper extends {
765
+ data: AISummaryModel;
766
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
767
+ data: AISummaryModel;
768
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
769
+ [key: string]: any;
770
+ data: AISummaryModel;
771
+ } : ResponseWrapper extends {
772
+ data: AISummaryModel;
773
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
774
+ data: AISummaryModel;
775
+ }) ? T_1 extends unknown ? {
776
+ id: string;
777
+ created: string;
778
+ summary: string;
779
+ hash: string;
780
+ ref_id: string;
781
+ lang: string;
782
+ } : T_1 : never : never;
783
+ } : ResponseWrapper;
784
+ $request: {
785
+ [k: string]: string;
786
+ path: string;
787
+ method: string;
788
+ };
789
+ $serialized: AISummaryModel;
790
+ }>;
791
+ }
792
+
694
793
  declare module '@mx-space/api-client' {
695
794
  interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
696
795
  category: CategoryController<ResponseWrapper>;
@@ -1700,8 +1799,8 @@ declare class UserController<ResponseWrapper> implements IController {
1700
1799
  }>;
1701
1800
  }
1702
1801
 
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"];
1802
+ 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)[];
1803
+ 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
1804
 
1706
1805
  declare enum SnippetType {
1707
1806
  JSON = "json",
@@ -1727,4 +1826,4 @@ interface SnippetModel<T = unknown> extends BaseModel {
1727
1826
  */
1728
1827
  declare const camelcaseKeys: <T = any>(obj: any) => T;
1729
1828
 
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 };
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 };
@@ -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) => {
@@ -230,6 +232,42 @@
230
232
  }
231
233
  };
232
234
 
235
+ // controllers/ai.ts
236
+ var AIController = class {
237
+ constructor(client) {
238
+ this.client = client;
239
+ this.base = "ai";
240
+ this.name = "ai";
241
+ autoBind(this);
242
+ }
243
+ get proxy() {
244
+ return this.client.proxy(this.base);
245
+ }
246
+ async getSummary({
247
+ articleId,
248
+ lang = "zh-CN",
249
+ onlyDb
250
+ }) {
251
+ return this.proxy.summaries.article(articleId).get({
252
+ params: {
253
+ lang,
254
+ onlyDb
255
+ }
256
+ });
257
+ }
258
+ async generateSummary(articleId, lang = "zh-CN", token = "") {
259
+ return this.proxy("generate-summary").post({
260
+ params: {
261
+ token
262
+ },
263
+ data: {
264
+ lang,
265
+ refId: articleId
266
+ }
267
+ });
268
+ }
269
+ };
270
+
233
271
  // core/error.ts
234
272
  var RequestError = class extends Error {
235
273
  constructor(message, status, path, raw) {
@@ -804,6 +842,7 @@
804
842
 
805
843
  // controllers/index.ts
806
844
  var allControllers = [
845
+ AIController,
807
846
  AckController,
808
847
  ActivityController,
809
848
  AggregateController,
@@ -824,6 +863,7 @@
824
863
  UserController
825
864
  ];
826
865
  var allControllerNames = [
866
+ "ai",
827
867
  "ack",
828
868
  "activity",
829
869
  "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) => {
@@ -228,6 +230,42 @@ var AggregateController = class {
228
230
  }
229
231
  };
230
232
 
233
+ // controllers/ai.ts
234
+ var AIController = class {
235
+ constructor(client) {
236
+ this.client = client;
237
+ this.base = "ai";
238
+ this.name = "ai";
239
+ autoBind(this);
240
+ }
241
+ get proxy() {
242
+ return this.client.proxy(this.base);
243
+ }
244
+ async getSummary({
245
+ articleId,
246
+ lang = "zh-CN",
247
+ onlyDb
248
+ }) {
249
+ return this.proxy.summaries.article(articleId).get({
250
+ params: {
251
+ lang,
252
+ onlyDb
253
+ }
254
+ });
255
+ }
256
+ async generateSummary(articleId, lang = "zh-CN", token = "") {
257
+ return this.proxy("generate-summary").post({
258
+ params: {
259
+ token
260
+ },
261
+ data: {
262
+ lang,
263
+ refId: articleId
264
+ }
265
+ });
266
+ }
267
+ };
268
+
231
269
  // core/error.ts
232
270
  var RequestError = class extends Error {
233
271
  constructor(message, status, path, raw) {
@@ -802,6 +840,7 @@ var UserController = class {
802
840
 
803
841
  // controllers/index.ts
804
842
  var allControllers = [
843
+ AIController,
805
844
  AckController,
806
845
  ActivityController,
807
846
  AggregateController,
@@ -822,6 +861,7 @@ var allControllers = [
822
861
  UserController
823
862
  ];
824
863
  var allControllerNames = [
864
+ "ai",
825
865
  "ack",
826
866
  "activity",
827
867
  "aggregate",
@@ -1144,6 +1184,7 @@ var SubscribeTypeToBitMap = {
1144
1184
  // index.ts
1145
1185
  var api_client_default = createClient;
1146
1186
  export {
1187
+ AIController,
1147
1188
  AckController,
1148
1189
  ActivityController,
1149
1190
  AggregateController,
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.0",
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
  }