@mx-space/api-client 1.21.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -246,6 +246,83 @@ var AIController = class {
246
246
  async getDeepReading(articleId) {
247
247
  return this.proxy("deep-readings").article(articleId).get();
248
248
  }
249
+ /**
250
+ * Get translation for an article
251
+ * @support core >= 9.4.0
252
+ */
253
+ async getTranslation({ articleId, lang }) {
254
+ return this.proxy.translations.article(articleId).get({ params: { lang } });
255
+ }
256
+ /**
257
+ * Get available translation languages for an article
258
+ * @support core >= 9.4.0
259
+ */
260
+ async getAvailableLanguages(articleId) {
261
+ return this.proxy.translations.article(articleId).languages.get();
262
+ }
263
+ /**
264
+ * Get URL for streaming summary generation (SSE)
265
+ *
266
+ * @see AISummaryStreamEvent for event types
267
+ * @support core >= 9.4.0
268
+ */
269
+ getSummaryGenerateUrl({ articleId, lang }) {
270
+ const baseUrl = this.client.endpoint;
271
+ const params = new URLSearchParams();
272
+ if (lang) params.set("lang", lang);
273
+ const query = params.toString();
274
+ return `${baseUrl}/${this.base}/summaries/article/${articleId}/generate${query ? `?${query}` : ""}`;
275
+ }
276
+ /**
277
+ * Stream summary generation using fetch
278
+ *
279
+ * @see AISummaryStreamEvent for event types
280
+ * @support core >= 9.4.0
281
+ */
282
+ async streamSummaryGenerate({ articleId, lang }, fetchOptions) {
283
+ const url = this.getSummaryGenerateUrl({
284
+ articleId,
285
+ lang
286
+ });
287
+ return fetch(url, {
288
+ ...fetchOptions,
289
+ headers: {
290
+ Accept: "text/event-stream",
291
+ ...fetchOptions?.headers
292
+ }
293
+ });
294
+ }
295
+ /**
296
+ * Get URL for streaming translation generation (SSE)
297
+ *
298
+ * @see AITranslationStreamEvent for event types
299
+ * @support core >= 9.4.0
300
+ */
301
+ getTranslationGenerateUrl({ articleId, lang }) {
302
+ const baseUrl = this.client.endpoint;
303
+ const params = new URLSearchParams();
304
+ params.set("lang", lang);
305
+ return `${baseUrl}/${this.base}/translations/article/${articleId}/generate?${params.toString()}`;
306
+ }
307
+ /**
308
+ * Stream translation generation using fetch
309
+ *
310
+ * @see AITranslationStreamEvent for event types
311
+ * @support core >= 9.4.0
312
+ */
313
+ async streamTranslationGenerate({ articleId, lang }, fetchOptions) {
314
+ const url = this.getTranslationGenerateUrl({
315
+ articleId,
316
+ lang
317
+ });
318
+ return fetch(url, {
319
+ ...fetchOptions,
320
+ headers: {
321
+ Accept: "text/event-stream",
322
+ ...fetchOptions?.headers
323
+ }
324
+ });
325
+ }
249
326
  };
250
327
 
251
328
  //#endregion
@@ -484,6 +561,81 @@ var NoteController = class {
484
561
  }
485
562
  };
486
563
 
564
+ //#endregion
565
+ //#region controllers/owner.ts
566
+ var UserController = class {
567
+ constructor(client) {
568
+ this.client = client;
569
+ this.base = "owner";
570
+ this.name = ["owner"];
571
+ autoBind(this);
572
+ }
573
+ get proxy() {
574
+ return this.client.proxy(this.base);
575
+ }
576
+ get authProxy() {
577
+ return this.client.proxy("auth");
578
+ }
579
+ normalizeToken(token) {
580
+ const normalized = token?.trim();
581
+ if (!normalized) return;
582
+ return normalized.replace(/^bearer\s+/i, "");
583
+ }
584
+ /**
585
+ * @deprecated Use `getOwnerInfo()` instead.
586
+ */
587
+ getMasterInfo() {
588
+ return this.getOwnerInfo();
589
+ }
590
+ getOwnerInfo() {
591
+ return this.proxy.get();
592
+ }
593
+ login(username, password, options) {
594
+ return this.authProxy("sign-in").username.post({ data: {
595
+ username,
596
+ password,
597
+ ...options
598
+ } });
599
+ }
600
+ logout() {
601
+ return this.authProxy("sign-out").post();
602
+ }
603
+ /**
604
+ * Better Auth raw session (`/auth/get-session`).
605
+ */
606
+ getAuthSession(options) {
607
+ return this.authProxy("get-session").get({ params: options });
608
+ }
609
+ /**
610
+ * Core session summary (`/auth/session`).
611
+ */
612
+ getSession() {
613
+ return this.authProxy.session.get();
614
+ }
615
+ getProviders() {
616
+ return this.authProxy.providers.get();
617
+ }
618
+ getAllowLoginMethods() {
619
+ return this.proxy("allow-login").get();
620
+ }
621
+ listSessions() {
622
+ return this.authProxy("list-sessions").get();
623
+ }
624
+ revokeSession(token) {
625
+ return this.authProxy("revoke-session").post({ data: { token } });
626
+ }
627
+ revokeSessions() {
628
+ return this.authProxy("revoke-sessions").post();
629
+ }
630
+ revokeOtherSessions() {
631
+ return this.authProxy("revoke-other-sessions").post();
632
+ }
633
+ checkTokenValid(token) {
634
+ const normalized = this.normalizeToken(token);
635
+ return this.proxy.check_logged.get({ params: normalized ? { token: normalized } : void 0 });
636
+ }
637
+ };
638
+
487
639
  //#endregion
488
640
  //#region controllers/page.ts
489
641
  var PageController = class {
@@ -769,35 +921,6 @@ var TopicController = class extends BaseCrudController {
769
921
  }
770
922
  };
771
923
 
772
- //#endregion
773
- //#region controllers/user.ts
774
- var UserController = class {
775
- constructor(client) {
776
- this.client = client;
777
- this.base = "master";
778
- this.name = ["user", "master"];
779
- autoBind(this);
780
- }
781
- get proxy() {
782
- return this.client.proxy(this.base);
783
- }
784
- getMasterInfo() {
785
- return this.proxy.get();
786
- }
787
- login(username, password) {
788
- return this.proxy.login.post({ data: {
789
- username,
790
- password
791
- } });
792
- }
793
- loginWithToken(token) {
794
- return this.proxy.login.put({ params: token ? { token: `bearer ${token.replace(/^bearer\s/i, "")}` } : void 0 });
795
- }
796
- checkTokenValid(token) {
797
- return this.proxy.check_logged.get({ params: { token: `bearer ${token.replace(/^bearer\s/i, "")}` } });
798
- }
799
- };
800
-
801
924
  //#endregion
802
925
  //#region controllers/index.ts
803
926
  const allControllers = [
@@ -840,9 +963,8 @@ const allControllerNames = [
840
963
  "snippet",
841
964
  "serverless",
842
965
  "subscribe",
843
- "user",
966
+ "owner",
844
967
  "friend",
845
- "master",
846
968
  "shorthand"
847
969
  ];
848
970
 
@@ -1043,9 +1165,9 @@ let TimelineType = /* @__PURE__ */ function(TimelineType) {
1043
1165
 
1044
1166
  //#endregion
1045
1167
  //#region ../../apps/core/src/constants/db.constant.ts
1046
- const POST_COLLECTION_NAME = "posts";
1047
1168
  const NOTE_COLLECTION_NAME = "notes";
1048
1169
  const PAGE_COLLECTION_NAME = "pages";
1170
+ const POST_COLLECTION_NAME = "posts";
1049
1171
  const RECENTLY_COLLECTION_NAME = "recentlies";
1050
1172
  let CollectionRefTypes = /* @__PURE__ */ function(CollectionRefTypes) {
1051
1173
  CollectionRefTypes[CollectionRefTypes["Post"] = POST_COLLECTION_NAME] = "Post";
@@ -1110,7 +1232,7 @@ let SnippetType = /* @__PURE__ */ function(SnippetType) {
1110
1232
 
1111
1233
  //#endregion
1112
1234
  //#region ../../apps/core/src/modules/subscribe/subscribe.constant.ts
1113
- const SubscribePostCreateBit = Math.trunc(1);
1235
+ const SubscribePostCreateBit = 1;
1114
1236
  const SubscribeNoteCreateBit = 2;
1115
1237
  const SubscribeSayCreateBit = 4;
1116
1238
  const SubscribeRecentCreateBit = 8;