@mx-space/api-client 3.3.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,33 @@
1
+ ** Mix Space Open Source License**
2
+
3
+ This project is dual-licensed under different terms for different parts of the project. It is important for users and contributors to understand the licensing terms applicable to each part of the project.
4
+
5
+ ### For the `apps/` Directory
6
+
7
+ **License:** GNU Affero General Public License v3.0 (AGPLv3) with Additional Terms (ADDITIONAL_TERMS).
8
+
9
+ **Scope:** This license applies exclusively to all files within the `apps/` directory of this project.
10
+
11
+ **Summary:**
12
+ - The AGPLv3 is a free, copyleft license suitable for software that will be distributed over a network. It allows users to use, modify, and distribute the software and any modifications under the same terms.
13
+ - The "Additional Terms" (ADDITIONAL_TERMS) are specific conditions that are added to the AGPLv3 license. These terms must be reviewed in the accompanying LICENSE file or documentation to understand any additional restrictions or permissions that apply to the software.
14
+
15
+ ### For Other Parts of the Project
16
+
17
+ **License:** MIT License.
18
+
19
+ **Scope:** This license applies to all parts of the project that are not included within the `apps/` directory.
20
+
21
+ **Summary:**
22
+ - The MIT License is a permissive open-source license that allows users considerable freedom. It permits use, copying, modification, merging, publishing, distribution, sublicensing, and/or selling copies of the software.
23
+ - It also protects the authors by including a limitation of liability and a disclaimer of warranty.
24
+
25
+ **General Conditions:**
26
+ - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the above license notices and this permission notice appear in all copies of the software.
27
+ - The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement.
28
+
29
+ **Contribution:**
30
+ - Contributions to this project are accepted under the terms of the same license as the part of the project to which the contribution is made.
31
+
32
+ **Notice:**
33
+ - This summary is not the license itself and is not a substitute for reading the licenses in their entirety. All users and contributors are encouraged to read the full text of the licenses for a comprehensive understanding.
package/dist/index.cjs CHANGED
@@ -256,7 +256,7 @@ var AIController = class {
256
256
  });
257
257
  }
258
258
  /**
259
- * Core >= 8.3.0
259
+ * @deprecated Feature removed from core; see ai-insights equivalent.
260
260
  * @param articleId
261
261
  */
262
262
  async getDeepReading(articleId) {
@@ -339,6 +339,48 @@ var AIController = class {
339
339
  }
340
340
  });
341
341
  }
342
+ /**
343
+ * Get cached AI insights for an article
344
+ * @support core >= 11.3.0
345
+ */
346
+ async getInsights({ articleId, lang = "zh", onlyDb }) {
347
+ return this.proxy.insights.article(articleId).get({ params: {
348
+ lang,
349
+ onlyDb
350
+ } });
351
+ }
352
+ /**
353
+ * Get URL for streaming insights generation (SSE)
354
+ *
355
+ * @see AIInsightsStreamEvent for event types
356
+ * @support core >= 11.3.0
357
+ */
358
+ getInsightsGenerateUrl({ articleId, lang }) {
359
+ const baseUrl = this.client.endpoint;
360
+ const params = new URLSearchParams();
361
+ if (lang) params.set("lang", lang);
362
+ const query = params.toString();
363
+ return `${baseUrl}/${this.base}/insights/article/${articleId}/generate${query ? `?${query}` : ""}`;
364
+ }
365
+ /**
366
+ * Stream insights generation using fetch
367
+ *
368
+ * @see AIInsightsStreamEvent for event types
369
+ * @support core >= 11.3.0
370
+ */
371
+ async streamInsightsGenerate({ articleId, lang }, fetchOptions) {
372
+ const url = this.getInsightsGenerateUrl({
373
+ articleId,
374
+ lang
375
+ });
376
+ return fetch(url, {
377
+ ...fetchOptions,
378
+ headers: {
379
+ Accept: "text/event-stream",
380
+ ...fetchOptions?.headers
381
+ }
382
+ });
383
+ }
342
384
  };
343
385
  //#endregion
344
386
  //#region core/error.ts
package/dist/index.d.cts CHANGED
@@ -196,6 +196,13 @@ type ModelWithTranslation<T> = T & {
196
196
  isTranslated: boolean;
197
197
  translationMeta?: TranslationMeta;
198
198
  availableTranslations?: string[];
199
+ /**
200
+ * Whether AI insights are available in the caller's requested locale.
201
+ * Independent from `translationMeta` because insights maintain their own
202
+ * translation pipeline — the article may be translated without insights,
203
+ * and vice versa. Absent (undefined) on endpoints that don't surface it.
204
+ */
205
+ hasInsightsInLocale?: boolean;
199
206
  };
200
207
  //#endregion
201
208
  //#region models/post.d.ts
@@ -708,6 +715,32 @@ type AITranslationStreamEvent = {
708
715
  type: 'error';
709
716
  data: string;
710
717
  };
718
+ interface AIInsightsModel {
719
+ id: string;
720
+ created: string;
721
+ updated?: string;
722
+ hash: string;
723
+ refId: string;
724
+ lang: string;
725
+ content: string;
726
+ isTranslation: boolean;
727
+ sourceInsightsId?: string;
728
+ sourceLang?: string;
729
+ modelInfo?: {
730
+ provider: string;
731
+ model: string;
732
+ };
733
+ }
734
+ type AIInsightsStreamEvent = {
735
+ type: 'token';
736
+ data: string;
737
+ } | {
738
+ type: 'done';
739
+ data: undefined;
740
+ } | {
741
+ type: 'error';
742
+ data: string;
743
+ };
711
744
  //#endregion
712
745
  //#region models/auth.d.ts
713
746
  interface AuthUser {
@@ -1277,7 +1310,7 @@ declare class AIController<ResponseWrapper> implements IController {
1277
1310
  $serialized: AISummaryModel;
1278
1311
  }>;
1279
1312
  /**
1280
- * Core >= 8.3.0
1313
+ * @deprecated Feature removed from core; see ai-insights equivalent.
1281
1314
  * @param articleId
1282
1315
  */
1283
1316
  getDeepReading(articleId: string): Promise<AIDeepReadingModel & {
@@ -1524,6 +1557,87 @@ declare class AIController<ResponseWrapper> implements IController {
1524
1557
  articleId: string;
1525
1558
  lang: string;
1526
1559
  }, fetchOptions?: RequestInit): Promise<Response>;
1560
+ /**
1561
+ * Get cached AI insights for an article
1562
+ * @support core >= 11.3.0
1563
+ */
1564
+ getInsights({
1565
+ articleId,
1566
+ lang,
1567
+ onlyDb
1568
+ }: {
1569
+ articleId: string;
1570
+ lang?: string;
1571
+ onlyDb?: boolean;
1572
+ }): Promise<AIInsightsModel & {
1573
+ $raw: ResponseWrapper extends {
1574
+ data: infer T;
1575
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
1576
+ [i: string]: any;
1577
+ data: (ResponseWrapper extends unknown ? {
1578
+ [key: string]: any;
1579
+ data: AIInsightsModel | null;
1580
+ } : ResponseWrapper extends {
1581
+ data: AIInsightsModel | null;
1582
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
1583
+ data: AIInsightsModel | null;
1584
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
1585
+ [key: string]: any;
1586
+ data: AIInsightsModel | null;
1587
+ } : ResponseWrapper extends {
1588
+ data: AIInsightsModel | null;
1589
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
1590
+ data: AIInsightsModel | null;
1591
+ }) ? T_1 extends unknown ? {
1592
+ id: string;
1593
+ created: string;
1594
+ updated?: string | undefined;
1595
+ hash: string;
1596
+ ref_id: string;
1597
+ lang: string;
1598
+ content: string;
1599
+ is_translation: boolean;
1600
+ source_insights_id?: string | undefined;
1601
+ source_lang?: string | undefined;
1602
+ model_info?: {
1603
+ provider: string;
1604
+ model: string;
1605
+ } | undefined;
1606
+ } : T_1 : never : never;
1607
+ } : ResponseWrapper;
1608
+ $request: {
1609
+ path: string;
1610
+ method: string;
1611
+ [k: string]: string;
1612
+ };
1613
+ $serialized: AIInsightsModel;
1614
+ }>;
1615
+ /**
1616
+ * Get URL for streaming insights generation (SSE)
1617
+ *
1618
+ * @see AIInsightsStreamEvent for event types
1619
+ * @support core >= 11.3.0
1620
+ */
1621
+ getInsightsGenerateUrl({
1622
+ articleId,
1623
+ lang
1624
+ }: {
1625
+ articleId: string;
1626
+ lang?: string;
1627
+ }): string;
1628
+ /**
1629
+ * Stream insights generation using fetch
1630
+ *
1631
+ * @see AIInsightsStreamEvent for event types
1632
+ * @support core >= 11.3.0
1633
+ */
1634
+ streamInsightsGenerate({
1635
+ articleId,
1636
+ lang
1637
+ }: {
1638
+ articleId: string;
1639
+ lang?: string;
1640
+ }, fetchOptions?: RequestInit): Promise<Response>;
1527
1641
  }
1528
1642
  //#endregion
1529
1643
  //#region controllers/category.d.ts
@@ -1574,7 +1688,7 @@ declare class CategoryController<ResponseWrapper> implements IController {
1574
1688
  name: string;
1575
1689
  created: string;
1576
1690
  id: string;
1577
- children: Pick<PostModel, "id" | "title" | "slug" | "modified" | "created">[];
1691
+ children: Pick<PostModel, "id" | "created" | "title" | "slug" | "modified">[];
1578
1692
  } : T_1 : never : never;
1579
1693
  } : ResponseWrapper;
1580
1694
  $request: {
@@ -1626,7 +1740,7 @@ declare class CategoryController<ResponseWrapper> implements IController {
1626
1740
  };
1627
1741
  }) ? T_1 extends unknown ? {
1628
1742
  tag: string;
1629
- data: Pick<PostModel, "category" | "id" | "title" | "slug" | "created">[];
1743
+ data: Pick<PostModel, "category" | "id" | "created" | "title" | "slug">[];
1630
1744
  } : T_1 : never : never;
1631
1745
  } : ResponseWrapper;
1632
1746
  $request: {
@@ -2467,35 +2581,35 @@ declare class SearchController<ResponseWrapper> implements IController {
2467
2581
  search(type: 'note', keyword: string, options?: SearchOption): Promise<RequestProxyResult<PaginateResult<Pick<NoteModel, 'modified' | 'id' | 'title' | 'created' | 'nid'> & SearchResultHighlight>, ResponseWrapper>>;
2468
2582
  search(type: 'post', keyword: string, options?: SearchOption): Promise<RequestProxyResult<PaginateResult<Pick<PostModel, 'modified' | 'id' | 'title' | 'created' | 'slug' | 'category'> & SearchResultHighlight>, ResponseWrapper>>;
2469
2583
  search(type: 'page', keyword: string, options?: SearchOption): Promise<RequestProxyResult<PaginateResult<Pick<PageModel, 'modified' | 'id' | 'title' | 'created' | 'slug'> & SearchResultHighlight>, ResponseWrapper>>;
2470
- searchAll(keyword: string, options?: SearchOption): RequestProxyResult<RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2584
+ searchAll(keyword: string, options?: SearchOption): RequestProxyResult<RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2471
2585
  type: "post";
2472
- }) | (Pick<NoteModel, "id" | "title" | "modified" | "created" | "nid"> & SearchResultHighlight & {
2586
+ }) | (Pick<NoteModel, "id" | "created" | "title" | "modified" | "nid"> & SearchResultHighlight & {
2473
2587
  type: "note";
2474
- }) | (Pick<PageModel, "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2588
+ }) | (Pick<PageModel, "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2475
2589
  type: "page";
2476
2590
  })>, ResponseWrapper>, ResponseWrapper, ResponseWrapper extends unknown ? {
2477
2591
  [key: string]: any;
2478
- data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2592
+ data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2479
2593
  type: "post";
2480
- }) | (Pick<NoteModel, "id" | "title" | "modified" | "created" | "nid"> & SearchResultHighlight & {
2594
+ }) | (Pick<NoteModel, "id" | "created" | "title" | "modified" | "nid"> & SearchResultHighlight & {
2481
2595
  type: "note";
2482
- }) | (Pick<PageModel, "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2596
+ }) | (Pick<PageModel, "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2483
2597
  type: "page";
2484
2598
  })>, ResponseWrapper>;
2485
2599
  } : ResponseWrapper extends {
2486
- data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2600
+ data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2487
2601
  type: "post";
2488
- }) | (Pick<NoteModel, "id" | "title" | "modified" | "created" | "nid"> & SearchResultHighlight & {
2602
+ }) | (Pick<NoteModel, "id" | "created" | "title" | "modified" | "nid"> & SearchResultHighlight & {
2489
2603
  type: "note";
2490
- }) | (Pick<PageModel, "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2604
+ }) | (Pick<PageModel, "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2491
2605
  type: "page";
2492
2606
  })>, ResponseWrapper>;
2493
2607
  } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
2494
- data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2608
+ data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2495
2609
  type: "post";
2496
- }) | (Pick<NoteModel, "id" | "title" | "modified" | "created" | "nid"> & SearchResultHighlight & {
2610
+ }) | (Pick<NoteModel, "id" | "created" | "title" | "modified" | "nid"> & SearchResultHighlight & {
2497
2611
  type: "note";
2498
- }) | (Pick<PageModel, "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2612
+ }) | (Pick<PageModel, "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2499
2613
  type: "page";
2500
2614
  })>, ResponseWrapper>;
2501
2615
  }>;
@@ -2639,4 +2753,4 @@ declare const allControllerNames: readonly ["ai", "ack", "activity", "aggregate"
2639
2753
  */
2640
2754
  declare const camelcaseKeys: <T = any>(obj: any) => T;
2641
2755
  //#endregion
2642
- export { AIController, AIDeepReadingModel, AISummaryModel, AISummaryStreamEvent, AITranslationModel, AITranslationStreamEvent, AcademicMetadata, AckController, ActivityController, ActivityPresence, AdminExtraModel, AggregateAIConfig, AggregateController, AggregateRoot, AggregateRootWithTheme, AggregateSiteInfo, AggregateStat, AggregateTop, AggregateTopNote, AggregateTopPost, AnonymousCommentDto, AuthUser, BackupOptionsModel, BaiduSearchOptionsModel, BaseCommentIndexModel, BaseModel, BetterAuthSession, BetterAuthSessionResult, BetterAuthSignInResult, BetterAuthUser, BetterAuthUserRole, BingSearchOptionsModel, BookMetadata, CategoryController, CategoryEntries, CategoryModel$1 as CategoryModel, CategoryType, CategoryWithChildrenModel, CheckLoggedResult, CodeMetadata, CollectionRefTypes, CommentController, CommentDto, CommentModel, CommentOptionsModel, CommentRef, CommentReplyWindow, CommentState, CommentThreadItem, CommentThreadReplies, Coordinate, Count, EnumPageType, GithubMetadata, type HTTPClient, IConfig, IConfigKeys, type IRequestAdapter, Image, LastYearPublication, LatestCombinedItem, LatestData, LatestNoteItem, LatestPostItem, LinkController, LinkMetadata, LinkModel, LinkState, LinkType, MailOptionsModel, MediaMetadata, ModelWithLiked, ModelWithTranslation, MusicMetadata, NoteController, type NoteMiddleListOptions, NoteModel, type NoteTimelineItem, type NoteTopicListItem, type NoteTopicListOptions, NoteWrappedPayload, NoteWrappedWithLikedAndTranslationPayload, NoteWrappedWithLikedPayload, OwnerAllowLoginResult, OwnerSessionResult, PageController, PageModel, Pager, PaginateResult, PostController, type PostListItem, type PostListOptions, PostModel, ProjectController, ProjectModel, ReaderCommentDto, ReaderModel, RecentActivities, RecentComment, RecentLike, RecentNote, RecentPost, RecentRecent, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, RecentlyMetadata, RecentlyModel, RecentlyRefType, RecentlyRefTypes, RecentlyTypeEnum, RequestError, RoomOmittedNote, RoomOmittedPage, RoomOmittedPost, RoomsData, SayController, SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, SubscribeType, SubscribeTypeToBitMap, TLogin, TagModel, TextBaseModel, TextBaseModelLexical, TextBaseModelMarkdown, ThirdPartyServiceIntegrationModel, TimelineData, TimelineType, TopicController, TopicModel, TranslationMeta, Url, UrlOptionModel, UserController, UserModel, allControllerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
2756
+ export { AIController, AIDeepReadingModel, AIInsightsModel, AIInsightsStreamEvent, AISummaryModel, AISummaryStreamEvent, AITranslationModel, AITranslationStreamEvent, AcademicMetadata, AckController, ActivityController, ActivityPresence, AdminExtraModel, AggregateAIConfig, AggregateController, AggregateRoot, AggregateRootWithTheme, AggregateSiteInfo, AggregateStat, AggregateTop, AggregateTopNote, AggregateTopPost, AnonymousCommentDto, AuthUser, BackupOptionsModel, BaiduSearchOptionsModel, BaseCommentIndexModel, BaseModel, BetterAuthSession, BetterAuthSessionResult, BetterAuthSignInResult, BetterAuthUser, BetterAuthUserRole, BingSearchOptionsModel, BookMetadata, CategoryController, CategoryEntries, CategoryModel$1 as CategoryModel, CategoryType, CategoryWithChildrenModel, CheckLoggedResult, CodeMetadata, CollectionRefTypes, CommentController, CommentDto, CommentModel, CommentOptionsModel, CommentRef, CommentReplyWindow, CommentState, CommentThreadItem, CommentThreadReplies, Coordinate, Count, EnumPageType, GithubMetadata, type HTTPClient, IConfig, IConfigKeys, type IRequestAdapter, Image, LastYearPublication, LatestCombinedItem, LatestData, LatestNoteItem, LatestPostItem, LinkController, LinkMetadata, LinkModel, LinkState, LinkType, MailOptionsModel, MediaMetadata, ModelWithLiked, ModelWithTranslation, MusicMetadata, NoteController, type NoteMiddleListOptions, NoteModel, type NoteTimelineItem, type NoteTopicListItem, type NoteTopicListOptions, NoteWrappedPayload, NoteWrappedWithLikedAndTranslationPayload, NoteWrappedWithLikedPayload, OwnerAllowLoginResult, OwnerSessionResult, PageController, PageModel, Pager, PaginateResult, PostController, type PostListItem, type PostListOptions, PostModel, ProjectController, ProjectModel, ReaderCommentDto, ReaderModel, RecentActivities, RecentComment, RecentLike, RecentNote, RecentPost, RecentRecent, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, RecentlyMetadata, RecentlyModel, RecentlyRefType, RecentlyRefTypes, RecentlyTypeEnum, RequestError, RoomOmittedNote, RoomOmittedPage, RoomOmittedPost, RoomsData, SayController, SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, SubscribeType, SubscribeTypeToBitMap, TLogin, TagModel, TextBaseModel, TextBaseModelLexical, TextBaseModelMarkdown, ThirdPartyServiceIntegrationModel, TimelineData, TimelineType, TopicController, TopicModel, TranslationMeta, Url, UrlOptionModel, UserController, UserModel, allControllerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
package/dist/index.d.mts CHANGED
@@ -196,6 +196,13 @@ type ModelWithTranslation<T> = T & {
196
196
  isTranslated: boolean;
197
197
  translationMeta?: TranslationMeta;
198
198
  availableTranslations?: string[];
199
+ /**
200
+ * Whether AI insights are available in the caller's requested locale.
201
+ * Independent from `translationMeta` because insights maintain their own
202
+ * translation pipeline — the article may be translated without insights,
203
+ * and vice versa. Absent (undefined) on endpoints that don't surface it.
204
+ */
205
+ hasInsightsInLocale?: boolean;
199
206
  };
200
207
  //#endregion
201
208
  //#region models/post.d.ts
@@ -708,6 +715,32 @@ type AITranslationStreamEvent = {
708
715
  type: 'error';
709
716
  data: string;
710
717
  };
718
+ interface AIInsightsModel {
719
+ id: string;
720
+ created: string;
721
+ updated?: string;
722
+ hash: string;
723
+ refId: string;
724
+ lang: string;
725
+ content: string;
726
+ isTranslation: boolean;
727
+ sourceInsightsId?: string;
728
+ sourceLang?: string;
729
+ modelInfo?: {
730
+ provider: string;
731
+ model: string;
732
+ };
733
+ }
734
+ type AIInsightsStreamEvent = {
735
+ type: 'token';
736
+ data: string;
737
+ } | {
738
+ type: 'done';
739
+ data: undefined;
740
+ } | {
741
+ type: 'error';
742
+ data: string;
743
+ };
711
744
  //#endregion
712
745
  //#region models/auth.d.ts
713
746
  interface AuthUser {
@@ -1277,7 +1310,7 @@ declare class AIController<ResponseWrapper> implements IController {
1277
1310
  $serialized: AISummaryModel;
1278
1311
  }>;
1279
1312
  /**
1280
- * Core >= 8.3.0
1313
+ * @deprecated Feature removed from core; see ai-insights equivalent.
1281
1314
  * @param articleId
1282
1315
  */
1283
1316
  getDeepReading(articleId: string): Promise<AIDeepReadingModel & {
@@ -1524,6 +1557,87 @@ declare class AIController<ResponseWrapper> implements IController {
1524
1557
  articleId: string;
1525
1558
  lang: string;
1526
1559
  }, fetchOptions?: RequestInit): Promise<Response>;
1560
+ /**
1561
+ * Get cached AI insights for an article
1562
+ * @support core >= 11.3.0
1563
+ */
1564
+ getInsights({
1565
+ articleId,
1566
+ lang,
1567
+ onlyDb
1568
+ }: {
1569
+ articleId: string;
1570
+ lang?: string;
1571
+ onlyDb?: boolean;
1572
+ }): Promise<AIInsightsModel & {
1573
+ $raw: ResponseWrapper extends {
1574
+ data: infer T;
1575
+ } ? ResponseWrapper : ResponseWrapper extends unknown ? {
1576
+ [i: string]: any;
1577
+ data: (ResponseWrapper extends unknown ? {
1578
+ [key: string]: any;
1579
+ data: AIInsightsModel | null;
1580
+ } : ResponseWrapper extends {
1581
+ data: AIInsightsModel | null;
1582
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
1583
+ data: AIInsightsModel | null;
1584
+ }) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
1585
+ [key: string]: any;
1586
+ data: AIInsightsModel | null;
1587
+ } : ResponseWrapper extends {
1588
+ data: AIInsightsModel | null;
1589
+ } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
1590
+ data: AIInsightsModel | null;
1591
+ }) ? T_1 extends unknown ? {
1592
+ id: string;
1593
+ created: string;
1594
+ updated?: string | undefined;
1595
+ hash: string;
1596
+ ref_id: string;
1597
+ lang: string;
1598
+ content: string;
1599
+ is_translation: boolean;
1600
+ source_insights_id?: string | undefined;
1601
+ source_lang?: string | undefined;
1602
+ model_info?: {
1603
+ provider: string;
1604
+ model: string;
1605
+ } | undefined;
1606
+ } : T_1 : never : never;
1607
+ } : ResponseWrapper;
1608
+ $request: {
1609
+ path: string;
1610
+ method: string;
1611
+ [k: string]: string;
1612
+ };
1613
+ $serialized: AIInsightsModel;
1614
+ }>;
1615
+ /**
1616
+ * Get URL for streaming insights generation (SSE)
1617
+ *
1618
+ * @see AIInsightsStreamEvent for event types
1619
+ * @support core >= 11.3.0
1620
+ */
1621
+ getInsightsGenerateUrl({
1622
+ articleId,
1623
+ lang
1624
+ }: {
1625
+ articleId: string;
1626
+ lang?: string;
1627
+ }): string;
1628
+ /**
1629
+ * Stream insights generation using fetch
1630
+ *
1631
+ * @see AIInsightsStreamEvent for event types
1632
+ * @support core >= 11.3.0
1633
+ */
1634
+ streamInsightsGenerate({
1635
+ articleId,
1636
+ lang
1637
+ }: {
1638
+ articleId: string;
1639
+ lang?: string;
1640
+ }, fetchOptions?: RequestInit): Promise<Response>;
1527
1641
  }
1528
1642
  //#endregion
1529
1643
  //#region controllers/category.d.ts
@@ -1574,7 +1688,7 @@ declare class CategoryController<ResponseWrapper> implements IController {
1574
1688
  name: string;
1575
1689
  created: string;
1576
1690
  id: string;
1577
- children: Pick<PostModel, "id" | "title" | "slug" | "modified" | "created">[];
1691
+ children: Pick<PostModel, "id" | "created" | "title" | "slug" | "modified">[];
1578
1692
  } : T_1 : never : never;
1579
1693
  } : ResponseWrapper;
1580
1694
  $request: {
@@ -1626,7 +1740,7 @@ declare class CategoryController<ResponseWrapper> implements IController {
1626
1740
  };
1627
1741
  }) ? T_1 extends unknown ? {
1628
1742
  tag: string;
1629
- data: Pick<PostModel, "category" | "id" | "title" | "slug" | "created">[];
1743
+ data: Pick<PostModel, "category" | "id" | "created" | "title" | "slug">[];
1630
1744
  } : T_1 : never : never;
1631
1745
  } : ResponseWrapper;
1632
1746
  $request: {
@@ -2467,35 +2581,35 @@ declare class SearchController<ResponseWrapper> implements IController {
2467
2581
  search(type: 'note', keyword: string, options?: SearchOption): Promise<RequestProxyResult<PaginateResult<Pick<NoteModel, 'modified' | 'id' | 'title' | 'created' | 'nid'> & SearchResultHighlight>, ResponseWrapper>>;
2468
2582
  search(type: 'post', keyword: string, options?: SearchOption): Promise<RequestProxyResult<PaginateResult<Pick<PostModel, 'modified' | 'id' | 'title' | 'created' | 'slug' | 'category'> & SearchResultHighlight>, ResponseWrapper>>;
2469
2583
  search(type: 'page', keyword: string, options?: SearchOption): Promise<RequestProxyResult<PaginateResult<Pick<PageModel, 'modified' | 'id' | 'title' | 'created' | 'slug'> & SearchResultHighlight>, ResponseWrapper>>;
2470
- searchAll(keyword: string, options?: SearchOption): RequestProxyResult<RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2584
+ searchAll(keyword: string, options?: SearchOption): RequestProxyResult<RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2471
2585
  type: "post";
2472
- }) | (Pick<NoteModel, "id" | "title" | "modified" | "created" | "nid"> & SearchResultHighlight & {
2586
+ }) | (Pick<NoteModel, "id" | "created" | "title" | "modified" | "nid"> & SearchResultHighlight & {
2473
2587
  type: "note";
2474
- }) | (Pick<PageModel, "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2588
+ }) | (Pick<PageModel, "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2475
2589
  type: "page";
2476
2590
  })>, ResponseWrapper>, ResponseWrapper, ResponseWrapper extends unknown ? {
2477
2591
  [key: string]: any;
2478
- data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2592
+ data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2479
2593
  type: "post";
2480
- }) | (Pick<NoteModel, "id" | "title" | "modified" | "created" | "nid"> & SearchResultHighlight & {
2594
+ }) | (Pick<NoteModel, "id" | "created" | "title" | "modified" | "nid"> & SearchResultHighlight & {
2481
2595
  type: "note";
2482
- }) | (Pick<PageModel, "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2596
+ }) | (Pick<PageModel, "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2483
2597
  type: "page";
2484
2598
  })>, ResponseWrapper>;
2485
2599
  } : ResponseWrapper extends {
2486
- data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2600
+ data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2487
2601
  type: "post";
2488
- }) | (Pick<NoteModel, "id" | "title" | "modified" | "created" | "nid"> & SearchResultHighlight & {
2602
+ }) | (Pick<NoteModel, "id" | "created" | "title" | "modified" | "nid"> & SearchResultHighlight & {
2489
2603
  type: "note";
2490
- }) | (Pick<PageModel, "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2604
+ }) | (Pick<PageModel, "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2491
2605
  type: "page";
2492
2606
  })>, ResponseWrapper>;
2493
2607
  } ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
2494
- data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2608
+ data: RequestProxyResult<PaginateResult<(Pick<PostModel, "category" | "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2495
2609
  type: "post";
2496
- }) | (Pick<NoteModel, "id" | "title" | "modified" | "created" | "nid"> & SearchResultHighlight & {
2610
+ }) | (Pick<NoteModel, "id" | "created" | "title" | "modified" | "nid"> & SearchResultHighlight & {
2497
2611
  type: "note";
2498
- }) | (Pick<PageModel, "id" | "title" | "slug" | "modified" | "created"> & SearchResultHighlight & {
2612
+ }) | (Pick<PageModel, "id" | "created" | "title" | "slug" | "modified"> & SearchResultHighlight & {
2499
2613
  type: "page";
2500
2614
  })>, ResponseWrapper>;
2501
2615
  }>;
@@ -2639,4 +2753,4 @@ declare const allControllerNames: readonly ["ai", "ack", "activity", "aggregate"
2639
2753
  */
2640
2754
  declare const camelcaseKeys: <T = any>(obj: any) => T;
2641
2755
  //#endregion
2642
- export { AIController, AIDeepReadingModel, AISummaryModel, AISummaryStreamEvent, AITranslationModel, AITranslationStreamEvent, AcademicMetadata, AckController, ActivityController, ActivityPresence, AdminExtraModel, AggregateAIConfig, AggregateController, AggregateRoot, AggregateRootWithTheme, AggregateSiteInfo, AggregateStat, AggregateTop, AggregateTopNote, AggregateTopPost, AnonymousCommentDto, AuthUser, BackupOptionsModel, BaiduSearchOptionsModel, BaseCommentIndexModel, BaseModel, BetterAuthSession, BetterAuthSessionResult, BetterAuthSignInResult, BetterAuthUser, BetterAuthUserRole, BingSearchOptionsModel, BookMetadata, CategoryController, CategoryEntries, CategoryModel$1 as CategoryModel, CategoryType, CategoryWithChildrenModel, CheckLoggedResult, CodeMetadata, CollectionRefTypes, CommentController, CommentDto, CommentModel, CommentOptionsModel, CommentRef, CommentReplyWindow, CommentState, CommentThreadItem, CommentThreadReplies, Coordinate, Count, EnumPageType, GithubMetadata, type HTTPClient, IConfig, IConfigKeys, type IRequestAdapter, Image, LastYearPublication, LatestCombinedItem, LatestData, LatestNoteItem, LatestPostItem, LinkController, LinkMetadata, LinkModel, LinkState, LinkType, MailOptionsModel, MediaMetadata, ModelWithLiked, ModelWithTranslation, MusicMetadata, NoteController, type NoteMiddleListOptions, NoteModel, type NoteTimelineItem, type NoteTopicListItem, type NoteTopicListOptions, NoteWrappedPayload, NoteWrappedWithLikedAndTranslationPayload, NoteWrappedWithLikedPayload, OwnerAllowLoginResult, OwnerSessionResult, PageController, PageModel, Pager, PaginateResult, PostController, type PostListItem, type PostListOptions, PostModel, ProjectController, ProjectModel, ReaderCommentDto, ReaderModel, RecentActivities, RecentComment, RecentLike, RecentNote, RecentPost, RecentRecent, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, RecentlyMetadata, RecentlyModel, RecentlyRefType, RecentlyRefTypes, RecentlyTypeEnum, RequestError, RoomOmittedNote, RoomOmittedPage, RoomOmittedPost, RoomsData, SayController, SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, SubscribeType, SubscribeTypeToBitMap, TLogin, TagModel, TextBaseModel, TextBaseModelLexical, TextBaseModelMarkdown, ThirdPartyServiceIntegrationModel, TimelineData, TimelineType, TopicController, TopicModel, TranslationMeta, Url, UrlOptionModel, UserController, UserModel, allControllerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
2756
+ export { AIController, AIDeepReadingModel, AIInsightsModel, AIInsightsStreamEvent, AISummaryModel, AISummaryStreamEvent, AITranslationModel, AITranslationStreamEvent, AcademicMetadata, AckController, ActivityController, ActivityPresence, AdminExtraModel, AggregateAIConfig, AggregateController, AggregateRoot, AggregateRootWithTheme, AggregateSiteInfo, AggregateStat, AggregateTop, AggregateTopNote, AggregateTopPost, AnonymousCommentDto, AuthUser, BackupOptionsModel, BaiduSearchOptionsModel, BaseCommentIndexModel, BaseModel, BetterAuthSession, BetterAuthSessionResult, BetterAuthSignInResult, BetterAuthUser, BetterAuthUserRole, BingSearchOptionsModel, BookMetadata, CategoryController, CategoryEntries, CategoryModel$1 as CategoryModel, CategoryType, CategoryWithChildrenModel, CheckLoggedResult, CodeMetadata, CollectionRefTypes, CommentController, CommentDto, CommentModel, CommentOptionsModel, CommentRef, CommentReplyWindow, CommentState, CommentThreadItem, CommentThreadReplies, Coordinate, Count, EnumPageType, GithubMetadata, type HTTPClient, IConfig, IConfigKeys, type IRequestAdapter, Image, LastYearPublication, LatestCombinedItem, LatestData, LatestNoteItem, LatestPostItem, LinkController, LinkMetadata, LinkModel, LinkState, LinkType, MailOptionsModel, MediaMetadata, ModelWithLiked, ModelWithTranslation, MusicMetadata, NoteController, type NoteMiddleListOptions, NoteModel, type NoteTimelineItem, type NoteTopicListItem, type NoteTopicListOptions, NoteWrappedPayload, NoteWrappedWithLikedAndTranslationPayload, NoteWrappedWithLikedPayload, OwnerAllowLoginResult, OwnerSessionResult, PageController, PageModel, Pager, PaginateResult, PostController, type PostListItem, type PostListOptions, PostModel, ProjectController, ProjectModel, ReaderCommentDto, ReaderModel, RecentActivities, RecentComment, RecentLike, RecentNote, RecentPost, RecentRecent, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, RecentlyMetadata, RecentlyModel, RecentlyRefType, RecentlyRefTypes, RecentlyTypeEnum, RequestError, RoomOmittedNote, RoomOmittedPage, RoomOmittedPost, RoomsData, SayController, SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, SubscribeType, SubscribeTypeToBitMap, TLogin, TagModel, TextBaseModel, TextBaseModelLexical, TextBaseModelMarkdown, ThirdPartyServiceIntegrationModel, TimelineData, TimelineType, TopicController, TopicModel, TranslationMeta, Url, UrlOptionModel, UserController, UserModel, allControllerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
package/dist/index.mjs CHANGED
@@ -252,7 +252,7 @@ var AIController = class {
252
252
  });
253
253
  }
254
254
  /**
255
- * Core >= 8.3.0
255
+ * @deprecated Feature removed from core; see ai-insights equivalent.
256
256
  * @param articleId
257
257
  */
258
258
  async getDeepReading(articleId) {
@@ -335,6 +335,48 @@ var AIController = class {
335
335
  }
336
336
  });
337
337
  }
338
+ /**
339
+ * Get cached AI insights for an article
340
+ * @support core >= 11.3.0
341
+ */
342
+ async getInsights({ articleId, lang = "zh", onlyDb }) {
343
+ return this.proxy.insights.article(articleId).get({ params: {
344
+ lang,
345
+ onlyDb
346
+ } });
347
+ }
348
+ /**
349
+ * Get URL for streaming insights generation (SSE)
350
+ *
351
+ * @see AIInsightsStreamEvent for event types
352
+ * @support core >= 11.3.0
353
+ */
354
+ getInsightsGenerateUrl({ articleId, lang }) {
355
+ const baseUrl = this.client.endpoint;
356
+ const params = new URLSearchParams();
357
+ if (lang) params.set("lang", lang);
358
+ const query = params.toString();
359
+ return `${baseUrl}/${this.base}/insights/article/${articleId}/generate${query ? `?${query}` : ""}`;
360
+ }
361
+ /**
362
+ * Stream insights generation using fetch
363
+ *
364
+ * @see AIInsightsStreamEvent for event types
365
+ * @support core >= 11.3.0
366
+ */
367
+ async streamInsightsGenerate({ articleId, lang }, fetchOptions) {
368
+ const url = this.getInsightsGenerateUrl({
369
+ articleId,
370
+ lang
371
+ });
372
+ return fetch(url, {
373
+ ...fetchOptions,
374
+ headers: {
375
+ Accept: "text/event-stream",
376
+ ...fetchOptions?.headers
377
+ }
378
+ });
379
+ }
338
380
  };
339
381
  //#endregion
340
382
  //#region core/error.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-space/api-client",
3
- "version": "3.3.0",
3
+ "version": "3.5.1",
4
4
  "description": "A api client for mx-space server@next",
5
5
  "type": "module",
6
6
  "engines": {
@@ -42,13 +42,6 @@
42
42
  "tag": false,
43
43
  "commit_message": "chore(release): bump @mx-space/api-client to v${NEW_VERSION}"
44
44
  },
45
- "scripts": {
46
- "package": "rm -rf dist && tsdown",
47
- "build": "npm run package",
48
- "prepackage": "rm -rf dist",
49
- "test": "vitest",
50
- "dev": "vitest"
51
- },
52
45
  "devDependencies": {
53
46
  "@types/cors": "2.8.19",
54
47
  "@types/express": "5.0.6",
@@ -63,5 +56,12 @@
63
56
  "umi-request": "1.4.0",
64
57
  "vite": "^8.0.8",
65
58
  "vitest": "4.1.4"
59
+ },
60
+ "scripts": {
61
+ "package": "rm -rf dist && tsdown",
62
+ "build": "npm run package",
63
+ "prepackage": "rm -rf dist",
64
+ "test": "vitest",
65
+ "dev": "vitest"
66
66
  }
67
- }
67
+ }