@xpoz/xpoz 0.3.0 → 0.3.2

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
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -26,6 +36,8 @@ __export(index_exports, {
26
36
  OperationTimeoutError: () => OperationTimeoutError,
27
37
  PaginatedResult: () => PaginatedResult,
28
38
  ResponseType: () => ResponseType,
39
+ TrackedItemPlatform: () => TrackedItemPlatform,
40
+ TrackedItemType: () => TrackedItemType,
29
41
  VERSION: () => VERSION,
30
42
  XpozClient: () => XpozClient,
31
43
  XpozConnectionError: () => XpozConnectionError,
@@ -284,10 +296,18 @@ function coerce(value) {
284
296
  }
285
297
 
286
298
  // src/version.ts
287
- var VERSION = "0.3.0";
299
+ var VERSION = "0.3.2";
288
300
 
289
301
  // src/mcp/transport.ts
290
302
  var USER_AGENT = `xpoz-ts-sdk/${VERSION}`;
303
+ function getProxyUrl() {
304
+ return process.env.HTTPS_PROXY ?? process.env.https_proxy ?? process.env.HTTP_PROXY ?? process.env.http_proxy;
305
+ }
306
+ async function createProxyFetch(proxyUrl) {
307
+ const { ProxyAgent, fetch: undiciFetch } = await import("undici");
308
+ const dispatcher = new ProxyAgent(proxyUrl);
309
+ return ((input, init) => undiciFetch(input, { ...init, dispatcher }));
310
+ }
291
311
  var McpTransport = class {
292
312
  serverUrl;
293
313
  apiKey;
@@ -302,8 +322,11 @@ var McpTransport = class {
302
322
  "User-Agent": USER_AGENT,
303
323
  Authorization: `Bearer ${this.apiKey}`
304
324
  };
325
+ const proxyUrl = getProxyUrl();
326
+ const customFetch = proxyUrl ? await createProxyFetch(proxyUrl) : void 0;
305
327
  this.transport = new import_streamableHttp.StreamableHTTPClientTransport(new URL(this.serverUrl), {
306
- requestInit: { headers }
328
+ requestInit: { headers },
329
+ ...customFetch ? { fetch: customFetch } : {}
307
330
  });
308
331
  this.client = new import_client.Client(
309
332
  { name: "xpoz-ts-sdk", version: VERSION },
@@ -313,6 +336,10 @@ var McpTransport = class {
313
336
  }
314
337
  async close() {
315
338
  if (this.client) {
339
+ try {
340
+ await this.transport?.terminateSession();
341
+ } catch {
342
+ }
316
343
  try {
317
344
  await this.client.close();
318
345
  } catch {
@@ -593,6 +620,16 @@ var GET_REDDIT_USERS_BY_KEYWORDS = "getRedditUsersByKeywords";
593
620
  var SEARCH_REDDIT_SUBREDDITS = "searchRedditSubreddits";
594
621
  var GET_REDDIT_SUBREDDIT_WITH_POSTS = "getRedditSubredditWithPostsByName";
595
622
  var GET_REDDIT_SUBREDDITS_BY_KEYWORDS = "getRedditSubredditsByKeywords";
623
+ var GET_TIKTOK_POSTS_BY_IDS = "getTiktokPostsByIds";
624
+ var GET_TIKTOK_POSTS_BY_USER = "getTiktokPostsByUser";
625
+ var SEARCH_TIKTOK_POSTS = "getTiktokPostsByKeywords";
626
+ var GET_TIKTOK_COMMENTS = "getTiktokCommentsByPostId";
627
+ var GET_TIKTOK_USER = "getTiktokUser";
628
+ var SEARCH_TIKTOK_USERS = "searchTiktokUsers";
629
+ var GET_TIKTOK_USERS_BY_KEYWORDS = "getTiktokUsersByKeywords";
630
+ var GET_TRACKED_ITEMS = "getTrackedItems";
631
+ var ADD_TRACKED_ITEMS = "addTrackedItems";
632
+ var REMOVE_TRACKED_ITEMS = "removeTrackedItems";
596
633
 
597
634
  // src/namespaces/twitter.ts
598
635
  function parseTwitterPost(item) {
@@ -1003,6 +1040,107 @@ var RedditNamespace = class extends BaseNamespace {
1003
1040
  }
1004
1041
  };
1005
1042
 
1043
+ // src/namespaces/tiktok.ts
1044
+ function parsePost3(item) {
1045
+ return item;
1046
+ }
1047
+ function parseUser4(item) {
1048
+ return item;
1049
+ }
1050
+ function parseComment3(item) {
1051
+ return item;
1052
+ }
1053
+ var TiktokNamespace = class extends BaseNamespace {
1054
+ async getPostsByIds(postIds, options = {}) {
1055
+ const args = this.buildArgs({ postIds, ...options });
1056
+ const result = await this.callAndMaybePoll(GET_TIKTOK_POSTS_BY_IDS, args);
1057
+ return (result["results"] ?? []).map(parsePost3);
1058
+ }
1059
+ async getPostsByUser(identifier, options = {}) {
1060
+ const args = this.buildArgs({
1061
+ identifier,
1062
+ identifierType: options.identifierType ?? "username",
1063
+ fields: options.fields,
1064
+ startDate: options.startDate,
1065
+ endDate: options.endDate,
1066
+ forceLatest: options.forceLatest,
1067
+ responseType: options.responseType,
1068
+ limit: options.limit
1069
+ });
1070
+ const result = await this.callAndMaybePoll(GET_TIKTOK_POSTS_BY_USER, args);
1071
+ return this.buildPaginatedResult(
1072
+ result,
1073
+ parsePost3,
1074
+ GET_TIKTOK_POSTS_BY_USER,
1075
+ args
1076
+ );
1077
+ }
1078
+ async searchPosts(query, options = {}) {
1079
+ const args = this.buildArgs({
1080
+ query,
1081
+ fields: options.fields,
1082
+ startDate: options.startDate,
1083
+ endDate: options.endDate,
1084
+ forceLatest: options.forceLatest,
1085
+ responseType: options.responseType,
1086
+ limit: options.limit
1087
+ });
1088
+ const result = await this.callAndMaybePoll(SEARCH_TIKTOK_POSTS, args);
1089
+ return this.buildPaginatedResult(result, parsePost3, SEARCH_TIKTOK_POSTS, args);
1090
+ }
1091
+ async getComments(postId, options = {}) {
1092
+ const args = this.buildArgs({ postId, ...options });
1093
+ const result = await this.callAndMaybePoll(GET_TIKTOK_COMMENTS, args);
1094
+ return this.buildPaginatedResult(result, parseComment3, GET_TIKTOK_COMMENTS, args);
1095
+ }
1096
+ async getUser(identifier, options = {}) {
1097
+ const args = this.buildArgs({
1098
+ identifier,
1099
+ identifierType: options.identifierType ?? "username",
1100
+ fields: options.fields
1101
+ });
1102
+ const result = await this.callAndMaybePoll(GET_TIKTOK_USER, args);
1103
+ const results = result["results"];
1104
+ if (Array.isArray(results) && results.length > 0) {
1105
+ return results[0];
1106
+ }
1107
+ return result;
1108
+ }
1109
+ async searchUsers(name, options = {}) {
1110
+ const args = this.buildArgs({ name, ...options });
1111
+ const result = await this.callAndMaybePoll(SEARCH_TIKTOK_USERS, args);
1112
+ return (result["results"] ?? []).map(parseUser4);
1113
+ }
1114
+ async getUsersByKeywords(query, options = {}) {
1115
+ const args = this.buildArgs({ query, ...options });
1116
+ const result = await this.callAndMaybePoll(GET_TIKTOK_USERS_BY_KEYWORDS, args);
1117
+ return this.buildPaginatedResult(
1118
+ result,
1119
+ parseUser4,
1120
+ GET_TIKTOK_USERS_BY_KEYWORDS,
1121
+ args
1122
+ );
1123
+ }
1124
+ };
1125
+
1126
+ // src/namespaces/tracking.ts
1127
+ var TrackingNamespace = class extends BaseNamespace {
1128
+ async getTrackedItems() {
1129
+ const result = await this.callTool(GET_TRACKED_ITEMS, {});
1130
+ return result["data"] ?? [];
1131
+ }
1132
+ async addTrackedItems(items) {
1133
+ const args = this.buildArgs({ items });
1134
+ const result = await this.callTool(ADD_TRACKED_ITEMS, args);
1135
+ return result;
1136
+ }
1137
+ async removeTrackedItems(items) {
1138
+ const args = this.buildArgs({ items });
1139
+ const result = await this.callTool(REMOVE_TRACKED_ITEMS, args);
1140
+ return result;
1141
+ }
1142
+ };
1143
+
1006
1144
  // src/versionCheck.ts
1007
1145
  var NPM_REGISTRY_URL = "https://registry.npmjs.org/@xpoz/xpoz/latest";
1008
1146
  var CHECK_TIMEOUT_MS = 3e3;
@@ -1048,6 +1186,8 @@ var XpozClient = class {
1048
1186
  twitter;
1049
1187
  instagram;
1050
1188
  reddit;
1189
+ tiktok;
1190
+ tracking;
1051
1191
  transport;
1052
1192
  versionCheck;
1053
1193
  constructor(options = {}) {
@@ -1065,6 +1205,8 @@ var XpozClient = class {
1065
1205
  this.twitter = new TwitterNamespace(callTool, timeoutMs);
1066
1206
  this.instagram = new InstagramNamespace(callTool, timeoutMs);
1067
1207
  this.reddit = new RedditNamespace(callTool, timeoutMs);
1208
+ this.tiktok = new TiktokNamespace(callTool, timeoutMs);
1209
+ this.tracking = new TrackingNamespace(callTool, timeoutMs);
1068
1210
  }
1069
1211
  async connect() {
1070
1212
  await this.transport.connect();
@@ -1079,6 +1221,21 @@ var XpozClient = class {
1079
1221
  await this.close();
1080
1222
  }
1081
1223
  };
1224
+
1225
+ // src/types/tracking.ts
1226
+ var TrackedItemType = /* @__PURE__ */ ((TrackedItemType2) => {
1227
+ TrackedItemType2["Keyword"] = "keyword";
1228
+ TrackedItemType2["User"] = "user";
1229
+ TrackedItemType2["Subreddit"] = "subreddit";
1230
+ return TrackedItemType2;
1231
+ })(TrackedItemType || {});
1232
+ var TrackedItemPlatform = /* @__PURE__ */ ((TrackedItemPlatform2) => {
1233
+ TrackedItemPlatform2["Twitter"] = "twitter";
1234
+ TrackedItemPlatform2["Instagram"] = "instagram";
1235
+ TrackedItemPlatform2["Reddit"] = "reddit";
1236
+ TrackedItemPlatform2["TikTok"] = "tiktok";
1237
+ return TrackedItemPlatform2;
1238
+ })(TrackedItemPlatform || {});
1082
1239
  // Annotate the CommonJS export names for ESM import in node:
1083
1240
  0 && (module.exports = {
1084
1241
  AuthenticationError,
@@ -1087,6 +1244,8 @@ var XpozClient = class {
1087
1244
  OperationTimeoutError,
1088
1245
  PaginatedResult,
1089
1246
  ResponseType,
1247
+ TrackedItemPlatform,
1248
+ TrackedItemType,
1090
1249
  VERSION,
1091
1250
  XpozClient,
1092
1251
  XpozConnectionError,
package/dist/index.d.cts CHANGED
@@ -559,10 +559,168 @@ declare class RedditNamespace extends BaseNamespace {
559
559
  private _parseSubredditWithPosts;
560
560
  }
561
561
 
562
+ interface TiktokPost {
563
+ id?: string | null;
564
+ postType?: number | null;
565
+ isPrivate?: boolean | null;
566
+ videoThumbnail?: string | null;
567
+ description?: string | null;
568
+ descriptionLanguage?: string | null;
569
+ userId?: string | null;
570
+ username?: string | null;
571
+ nickname?: string | null;
572
+ collectCount?: number | null;
573
+ commentCount?: number | null;
574
+ likeCount?: number | null;
575
+ downloadCount?: number | null;
576
+ forwardCount?: number | null;
577
+ playCount?: number | null;
578
+ createdAt?: string | null;
579
+ createdAtTimestamp?: number | null;
580
+ createdAtDate?: string | null;
581
+ lastFetch?: string | null;
582
+ lastFetchDatetime?: string | null;
583
+ xLastUpdated?: string | null;
584
+ aggRelevance?: number | null;
585
+ relevantPostsCount?: number | null;
586
+ relevantPostsLikesSum?: number | null;
587
+ relevantPostsCommentsSum?: number | null;
588
+ relevantPostsPlaysSum?: number | null;
589
+ relevantPostsForwardsSum?: number | null;
590
+ [key: string]: unknown;
591
+ }
592
+ interface TiktokUser {
593
+ id?: string | null;
594
+ username?: string | null;
595
+ nickname?: string | null;
596
+ signature?: string | null;
597
+ secUid?: string | null;
598
+ avatar?: string | null;
599
+ isPrivate?: boolean | null;
600
+ isVerified?: boolean | null;
601
+ followerCount?: number | null;
602
+ followingCount?: number | null;
603
+ likeCount?: number | null;
604
+ postCount?: number | null;
605
+ language?: string | null;
606
+ region?: string | null;
607
+ createdAt?: string | null;
608
+ usernameModifyTime?: string | null;
609
+ lastFetch?: string | null;
610
+ lastFetchDatetime?: string | null;
611
+ xLastUpdated?: string | null;
612
+ aggRelevance?: number | null;
613
+ relevantPostsCount?: number | null;
614
+ relevantPostsLikesSum?: number | null;
615
+ relevantPostsCommentsSum?: number | null;
616
+ relevantPostsPlaysSum?: number | null;
617
+ relevantPostsForwardsSum?: number | null;
618
+ [key: string]: unknown;
619
+ }
620
+ interface TiktokComment {
621
+ id?: string | null;
622
+ postId?: string | null;
623
+ userId?: string | null;
624
+ username?: string | null;
625
+ text?: string | null;
626
+ likeCount?: number | null;
627
+ createdAt?: string | null;
628
+ createdAtTimestamp?: number | null;
629
+ createdAtDate?: string | null;
630
+ lastFetch?: string | null;
631
+ lastFetchDatetime?: string | null;
632
+ xLastUpdated?: string | null;
633
+ [key: string]: unknown;
634
+ }
635
+
636
+ declare class TiktokNamespace extends BaseNamespace {
637
+ getPostsByIds(postIds: string[], options?: {
638
+ fields?: string[];
639
+ forceLatest?: boolean;
640
+ }): Promise<TiktokPost[]>;
641
+ getPostsByUser(identifier: string, options?: {
642
+ identifierType?: string;
643
+ fields?: string[];
644
+ startDate?: string;
645
+ endDate?: string;
646
+ forceLatest?: boolean;
647
+ responseType?: ResponseType;
648
+ limit?: number;
649
+ }): Promise<PaginatedResult<TiktokPost>>;
650
+ searchPosts(query: string, options?: {
651
+ fields?: string[];
652
+ startDate?: string;
653
+ endDate?: string;
654
+ forceLatest?: boolean;
655
+ responseType?: ResponseType;
656
+ limit?: number;
657
+ }): Promise<PaginatedResult<TiktokPost>>;
658
+ getComments(postId: string, options?: {
659
+ fields?: string[];
660
+ startDate?: string;
661
+ endDate?: string;
662
+ forceLatest?: boolean;
663
+ }): Promise<PaginatedResult<TiktokComment>>;
664
+ getUser(identifier: string, options?: {
665
+ identifierType?: string;
666
+ fields?: string[];
667
+ }): Promise<TiktokUser>;
668
+ searchUsers(name: string, options?: {
669
+ limit?: number;
670
+ fields?: string[];
671
+ }): Promise<TiktokUser[]>;
672
+ getUsersByKeywords(query: string, options?: {
673
+ fields?: string[];
674
+ startDate?: string;
675
+ endDate?: string;
676
+ forceLatest?: boolean;
677
+ responseType?: ResponseType;
678
+ limit?: number;
679
+ }): Promise<PaginatedResult<TiktokUser>>;
680
+ }
681
+
682
+ declare enum TrackedItemType {
683
+ Keyword = "keyword",
684
+ User = "user",
685
+ Subreddit = "subreddit"
686
+ }
687
+ declare enum TrackedItemPlatform {
688
+ Twitter = "twitter",
689
+ Instagram = "instagram",
690
+ Reddit = "reddit",
691
+ TikTok = "tiktok"
692
+ }
693
+ interface TrackedItem {
694
+ phrase?: string;
695
+ type?: TrackedItemType;
696
+ platform?: TrackedItemPlatform;
697
+ }
698
+ interface AddTrackedItemsResult {
699
+ success?: boolean;
700
+ addedCount?: number;
701
+ message?: string;
702
+ currentCount?: number;
703
+ maxTrackedItems?: number;
704
+ planName?: string;
705
+ }
706
+ interface RemoveTrackedItemsResult {
707
+ success?: boolean;
708
+ removedCount?: number;
709
+ message?: string;
710
+ }
711
+
712
+ declare class TrackingNamespace extends BaseNamespace {
713
+ getTrackedItems(): Promise<TrackedItem[]>;
714
+ addTrackedItems(items: TrackedItem[]): Promise<AddTrackedItemsResult>;
715
+ removeTrackedItems(items: TrackedItem[]): Promise<RemoveTrackedItemsResult>;
716
+ }
717
+
562
718
  declare class XpozClient {
563
719
  twitter: TwitterNamespace;
564
720
  instagram: InstagramNamespace;
565
721
  reddit: RedditNamespace;
722
+ tiktok: TiktokNamespace;
723
+ tracking: TrackingNamespace;
566
724
  private transport;
567
725
  private versionCheck;
568
726
  constructor(options?: {
@@ -600,8 +758,8 @@ declare class OperationCancelledError extends XpozError {
600
758
  constructor(operationId: string);
601
759
  }
602
760
 
603
- declare const VERSION = "0.3.0";
761
+ declare const VERSION = "0.3.2";
604
762
 
605
763
  declare function checkForUpdates(): Promise<void>;
606
764
 
607
- export { AuthenticationError, type InstagramComment, type InstagramPost, type InstagramUser, OperationCancelledError, OperationFailedError, OperationTimeoutError, PaginatedResult, type PaginationInfo, type RedditComment, type RedditPost, type RedditPostWithComments, type RedditSubreddit, type RedditUser, ResponseType, type SubredditWithPosts, type TwitterPost, type TwitterUser, VERSION, XpozClient, XpozConnectionError, XpozError, checkForUpdates };
765
+ export { type AddTrackedItemsResult, AuthenticationError, type InstagramComment, type InstagramPost, type InstagramUser, OperationCancelledError, OperationFailedError, OperationTimeoutError, PaginatedResult, type PaginationInfo, type RedditComment, type RedditPost, type RedditPostWithComments, type RedditSubreddit, type RedditUser, type RemoveTrackedItemsResult, ResponseType, type SubredditWithPosts, type TiktokComment, type TiktokPost, type TiktokUser, type TrackedItem, TrackedItemPlatform, TrackedItemType, type TwitterPost, type TwitterUser, VERSION, XpozClient, XpozConnectionError, XpozError, checkForUpdates };
package/dist/index.d.ts CHANGED
@@ -559,10 +559,168 @@ declare class RedditNamespace extends BaseNamespace {
559
559
  private _parseSubredditWithPosts;
560
560
  }
561
561
 
562
+ interface TiktokPost {
563
+ id?: string | null;
564
+ postType?: number | null;
565
+ isPrivate?: boolean | null;
566
+ videoThumbnail?: string | null;
567
+ description?: string | null;
568
+ descriptionLanguage?: string | null;
569
+ userId?: string | null;
570
+ username?: string | null;
571
+ nickname?: string | null;
572
+ collectCount?: number | null;
573
+ commentCount?: number | null;
574
+ likeCount?: number | null;
575
+ downloadCount?: number | null;
576
+ forwardCount?: number | null;
577
+ playCount?: number | null;
578
+ createdAt?: string | null;
579
+ createdAtTimestamp?: number | null;
580
+ createdAtDate?: string | null;
581
+ lastFetch?: string | null;
582
+ lastFetchDatetime?: string | null;
583
+ xLastUpdated?: string | null;
584
+ aggRelevance?: number | null;
585
+ relevantPostsCount?: number | null;
586
+ relevantPostsLikesSum?: number | null;
587
+ relevantPostsCommentsSum?: number | null;
588
+ relevantPostsPlaysSum?: number | null;
589
+ relevantPostsForwardsSum?: number | null;
590
+ [key: string]: unknown;
591
+ }
592
+ interface TiktokUser {
593
+ id?: string | null;
594
+ username?: string | null;
595
+ nickname?: string | null;
596
+ signature?: string | null;
597
+ secUid?: string | null;
598
+ avatar?: string | null;
599
+ isPrivate?: boolean | null;
600
+ isVerified?: boolean | null;
601
+ followerCount?: number | null;
602
+ followingCount?: number | null;
603
+ likeCount?: number | null;
604
+ postCount?: number | null;
605
+ language?: string | null;
606
+ region?: string | null;
607
+ createdAt?: string | null;
608
+ usernameModifyTime?: string | null;
609
+ lastFetch?: string | null;
610
+ lastFetchDatetime?: string | null;
611
+ xLastUpdated?: string | null;
612
+ aggRelevance?: number | null;
613
+ relevantPostsCount?: number | null;
614
+ relevantPostsLikesSum?: number | null;
615
+ relevantPostsCommentsSum?: number | null;
616
+ relevantPostsPlaysSum?: number | null;
617
+ relevantPostsForwardsSum?: number | null;
618
+ [key: string]: unknown;
619
+ }
620
+ interface TiktokComment {
621
+ id?: string | null;
622
+ postId?: string | null;
623
+ userId?: string | null;
624
+ username?: string | null;
625
+ text?: string | null;
626
+ likeCount?: number | null;
627
+ createdAt?: string | null;
628
+ createdAtTimestamp?: number | null;
629
+ createdAtDate?: string | null;
630
+ lastFetch?: string | null;
631
+ lastFetchDatetime?: string | null;
632
+ xLastUpdated?: string | null;
633
+ [key: string]: unknown;
634
+ }
635
+
636
+ declare class TiktokNamespace extends BaseNamespace {
637
+ getPostsByIds(postIds: string[], options?: {
638
+ fields?: string[];
639
+ forceLatest?: boolean;
640
+ }): Promise<TiktokPost[]>;
641
+ getPostsByUser(identifier: string, options?: {
642
+ identifierType?: string;
643
+ fields?: string[];
644
+ startDate?: string;
645
+ endDate?: string;
646
+ forceLatest?: boolean;
647
+ responseType?: ResponseType;
648
+ limit?: number;
649
+ }): Promise<PaginatedResult<TiktokPost>>;
650
+ searchPosts(query: string, options?: {
651
+ fields?: string[];
652
+ startDate?: string;
653
+ endDate?: string;
654
+ forceLatest?: boolean;
655
+ responseType?: ResponseType;
656
+ limit?: number;
657
+ }): Promise<PaginatedResult<TiktokPost>>;
658
+ getComments(postId: string, options?: {
659
+ fields?: string[];
660
+ startDate?: string;
661
+ endDate?: string;
662
+ forceLatest?: boolean;
663
+ }): Promise<PaginatedResult<TiktokComment>>;
664
+ getUser(identifier: string, options?: {
665
+ identifierType?: string;
666
+ fields?: string[];
667
+ }): Promise<TiktokUser>;
668
+ searchUsers(name: string, options?: {
669
+ limit?: number;
670
+ fields?: string[];
671
+ }): Promise<TiktokUser[]>;
672
+ getUsersByKeywords(query: string, options?: {
673
+ fields?: string[];
674
+ startDate?: string;
675
+ endDate?: string;
676
+ forceLatest?: boolean;
677
+ responseType?: ResponseType;
678
+ limit?: number;
679
+ }): Promise<PaginatedResult<TiktokUser>>;
680
+ }
681
+
682
+ declare enum TrackedItemType {
683
+ Keyword = "keyword",
684
+ User = "user",
685
+ Subreddit = "subreddit"
686
+ }
687
+ declare enum TrackedItemPlatform {
688
+ Twitter = "twitter",
689
+ Instagram = "instagram",
690
+ Reddit = "reddit",
691
+ TikTok = "tiktok"
692
+ }
693
+ interface TrackedItem {
694
+ phrase?: string;
695
+ type?: TrackedItemType;
696
+ platform?: TrackedItemPlatform;
697
+ }
698
+ interface AddTrackedItemsResult {
699
+ success?: boolean;
700
+ addedCount?: number;
701
+ message?: string;
702
+ currentCount?: number;
703
+ maxTrackedItems?: number;
704
+ planName?: string;
705
+ }
706
+ interface RemoveTrackedItemsResult {
707
+ success?: boolean;
708
+ removedCount?: number;
709
+ message?: string;
710
+ }
711
+
712
+ declare class TrackingNamespace extends BaseNamespace {
713
+ getTrackedItems(): Promise<TrackedItem[]>;
714
+ addTrackedItems(items: TrackedItem[]): Promise<AddTrackedItemsResult>;
715
+ removeTrackedItems(items: TrackedItem[]): Promise<RemoveTrackedItemsResult>;
716
+ }
717
+
562
718
  declare class XpozClient {
563
719
  twitter: TwitterNamespace;
564
720
  instagram: InstagramNamespace;
565
721
  reddit: RedditNamespace;
722
+ tiktok: TiktokNamespace;
723
+ tracking: TrackingNamespace;
566
724
  private transport;
567
725
  private versionCheck;
568
726
  constructor(options?: {
@@ -600,8 +758,8 @@ declare class OperationCancelledError extends XpozError {
600
758
  constructor(operationId: string);
601
759
  }
602
760
 
603
- declare const VERSION = "0.3.0";
761
+ declare const VERSION = "0.3.2";
604
762
 
605
763
  declare function checkForUpdates(): Promise<void>;
606
764
 
607
- export { AuthenticationError, type InstagramComment, type InstagramPost, type InstagramUser, OperationCancelledError, OperationFailedError, OperationTimeoutError, PaginatedResult, type PaginationInfo, type RedditComment, type RedditPost, type RedditPostWithComments, type RedditSubreddit, type RedditUser, ResponseType, type SubredditWithPosts, type TwitterPost, type TwitterUser, VERSION, XpozClient, XpozConnectionError, XpozError, checkForUpdates };
765
+ export { type AddTrackedItemsResult, AuthenticationError, type InstagramComment, type InstagramPost, type InstagramUser, OperationCancelledError, OperationFailedError, OperationTimeoutError, PaginatedResult, type PaginationInfo, type RedditComment, type RedditPost, type RedditPostWithComments, type RedditSubreddit, type RedditUser, type RemoveTrackedItemsResult, ResponseType, type SubredditWithPosts, type TiktokComment, type TiktokPost, type TiktokUser, type TrackedItem, TrackedItemPlatform, TrackedItemType, type TwitterPost, type TwitterUser, VERSION, XpozClient, XpozConnectionError, XpozError, checkForUpdates };
package/dist/index.js CHANGED
@@ -248,10 +248,18 @@ function coerce(value) {
248
248
  }
249
249
 
250
250
  // src/version.ts
251
- var VERSION = "0.3.0";
251
+ var VERSION = "0.3.2";
252
252
 
253
253
  // src/mcp/transport.ts
254
254
  var USER_AGENT = `xpoz-ts-sdk/${VERSION}`;
255
+ function getProxyUrl() {
256
+ return process.env.HTTPS_PROXY ?? process.env.https_proxy ?? process.env.HTTP_PROXY ?? process.env.http_proxy;
257
+ }
258
+ async function createProxyFetch(proxyUrl) {
259
+ const { ProxyAgent, fetch: undiciFetch } = await import("undici");
260
+ const dispatcher = new ProxyAgent(proxyUrl);
261
+ return ((input, init) => undiciFetch(input, { ...init, dispatcher }));
262
+ }
255
263
  var McpTransport = class {
256
264
  serverUrl;
257
265
  apiKey;
@@ -266,8 +274,11 @@ var McpTransport = class {
266
274
  "User-Agent": USER_AGENT,
267
275
  Authorization: `Bearer ${this.apiKey}`
268
276
  };
277
+ const proxyUrl = getProxyUrl();
278
+ const customFetch = proxyUrl ? await createProxyFetch(proxyUrl) : void 0;
269
279
  this.transport = new StreamableHTTPClientTransport(new URL(this.serverUrl), {
270
- requestInit: { headers }
280
+ requestInit: { headers },
281
+ ...customFetch ? { fetch: customFetch } : {}
271
282
  });
272
283
  this.client = new Client(
273
284
  { name: "xpoz-ts-sdk", version: VERSION },
@@ -277,6 +288,10 @@ var McpTransport = class {
277
288
  }
278
289
  async close() {
279
290
  if (this.client) {
291
+ try {
292
+ await this.transport?.terminateSession();
293
+ } catch {
294
+ }
280
295
  try {
281
296
  await this.client.close();
282
297
  } catch {
@@ -557,6 +572,16 @@ var GET_REDDIT_USERS_BY_KEYWORDS = "getRedditUsersByKeywords";
557
572
  var SEARCH_REDDIT_SUBREDDITS = "searchRedditSubreddits";
558
573
  var GET_REDDIT_SUBREDDIT_WITH_POSTS = "getRedditSubredditWithPostsByName";
559
574
  var GET_REDDIT_SUBREDDITS_BY_KEYWORDS = "getRedditSubredditsByKeywords";
575
+ var GET_TIKTOK_POSTS_BY_IDS = "getTiktokPostsByIds";
576
+ var GET_TIKTOK_POSTS_BY_USER = "getTiktokPostsByUser";
577
+ var SEARCH_TIKTOK_POSTS = "getTiktokPostsByKeywords";
578
+ var GET_TIKTOK_COMMENTS = "getTiktokCommentsByPostId";
579
+ var GET_TIKTOK_USER = "getTiktokUser";
580
+ var SEARCH_TIKTOK_USERS = "searchTiktokUsers";
581
+ var GET_TIKTOK_USERS_BY_KEYWORDS = "getTiktokUsersByKeywords";
582
+ var GET_TRACKED_ITEMS = "getTrackedItems";
583
+ var ADD_TRACKED_ITEMS = "addTrackedItems";
584
+ var REMOVE_TRACKED_ITEMS = "removeTrackedItems";
560
585
 
561
586
  // src/namespaces/twitter.ts
562
587
  function parseTwitterPost(item) {
@@ -967,6 +992,107 @@ var RedditNamespace = class extends BaseNamespace {
967
992
  }
968
993
  };
969
994
 
995
+ // src/namespaces/tiktok.ts
996
+ function parsePost3(item) {
997
+ return item;
998
+ }
999
+ function parseUser4(item) {
1000
+ return item;
1001
+ }
1002
+ function parseComment3(item) {
1003
+ return item;
1004
+ }
1005
+ var TiktokNamespace = class extends BaseNamespace {
1006
+ async getPostsByIds(postIds, options = {}) {
1007
+ const args = this.buildArgs({ postIds, ...options });
1008
+ const result = await this.callAndMaybePoll(GET_TIKTOK_POSTS_BY_IDS, args);
1009
+ return (result["results"] ?? []).map(parsePost3);
1010
+ }
1011
+ async getPostsByUser(identifier, options = {}) {
1012
+ const args = this.buildArgs({
1013
+ identifier,
1014
+ identifierType: options.identifierType ?? "username",
1015
+ fields: options.fields,
1016
+ startDate: options.startDate,
1017
+ endDate: options.endDate,
1018
+ forceLatest: options.forceLatest,
1019
+ responseType: options.responseType,
1020
+ limit: options.limit
1021
+ });
1022
+ const result = await this.callAndMaybePoll(GET_TIKTOK_POSTS_BY_USER, args);
1023
+ return this.buildPaginatedResult(
1024
+ result,
1025
+ parsePost3,
1026
+ GET_TIKTOK_POSTS_BY_USER,
1027
+ args
1028
+ );
1029
+ }
1030
+ async searchPosts(query, options = {}) {
1031
+ const args = this.buildArgs({
1032
+ query,
1033
+ fields: options.fields,
1034
+ startDate: options.startDate,
1035
+ endDate: options.endDate,
1036
+ forceLatest: options.forceLatest,
1037
+ responseType: options.responseType,
1038
+ limit: options.limit
1039
+ });
1040
+ const result = await this.callAndMaybePoll(SEARCH_TIKTOK_POSTS, args);
1041
+ return this.buildPaginatedResult(result, parsePost3, SEARCH_TIKTOK_POSTS, args);
1042
+ }
1043
+ async getComments(postId, options = {}) {
1044
+ const args = this.buildArgs({ postId, ...options });
1045
+ const result = await this.callAndMaybePoll(GET_TIKTOK_COMMENTS, args);
1046
+ return this.buildPaginatedResult(result, parseComment3, GET_TIKTOK_COMMENTS, args);
1047
+ }
1048
+ async getUser(identifier, options = {}) {
1049
+ const args = this.buildArgs({
1050
+ identifier,
1051
+ identifierType: options.identifierType ?? "username",
1052
+ fields: options.fields
1053
+ });
1054
+ const result = await this.callAndMaybePoll(GET_TIKTOK_USER, args);
1055
+ const results = result["results"];
1056
+ if (Array.isArray(results) && results.length > 0) {
1057
+ return results[0];
1058
+ }
1059
+ return result;
1060
+ }
1061
+ async searchUsers(name, options = {}) {
1062
+ const args = this.buildArgs({ name, ...options });
1063
+ const result = await this.callAndMaybePoll(SEARCH_TIKTOK_USERS, args);
1064
+ return (result["results"] ?? []).map(parseUser4);
1065
+ }
1066
+ async getUsersByKeywords(query, options = {}) {
1067
+ const args = this.buildArgs({ query, ...options });
1068
+ const result = await this.callAndMaybePoll(GET_TIKTOK_USERS_BY_KEYWORDS, args);
1069
+ return this.buildPaginatedResult(
1070
+ result,
1071
+ parseUser4,
1072
+ GET_TIKTOK_USERS_BY_KEYWORDS,
1073
+ args
1074
+ );
1075
+ }
1076
+ };
1077
+
1078
+ // src/namespaces/tracking.ts
1079
+ var TrackingNamespace = class extends BaseNamespace {
1080
+ async getTrackedItems() {
1081
+ const result = await this.callTool(GET_TRACKED_ITEMS, {});
1082
+ return result["data"] ?? [];
1083
+ }
1084
+ async addTrackedItems(items) {
1085
+ const args = this.buildArgs({ items });
1086
+ const result = await this.callTool(ADD_TRACKED_ITEMS, args);
1087
+ return result;
1088
+ }
1089
+ async removeTrackedItems(items) {
1090
+ const args = this.buildArgs({ items });
1091
+ const result = await this.callTool(REMOVE_TRACKED_ITEMS, args);
1092
+ return result;
1093
+ }
1094
+ };
1095
+
970
1096
  // src/versionCheck.ts
971
1097
  var NPM_REGISTRY_URL = "https://registry.npmjs.org/@xpoz/xpoz/latest";
972
1098
  var CHECK_TIMEOUT_MS = 3e3;
@@ -1012,6 +1138,8 @@ var XpozClient = class {
1012
1138
  twitter;
1013
1139
  instagram;
1014
1140
  reddit;
1141
+ tiktok;
1142
+ tracking;
1015
1143
  transport;
1016
1144
  versionCheck;
1017
1145
  constructor(options = {}) {
@@ -1029,6 +1157,8 @@ var XpozClient = class {
1029
1157
  this.twitter = new TwitterNamespace(callTool, timeoutMs);
1030
1158
  this.instagram = new InstagramNamespace(callTool, timeoutMs);
1031
1159
  this.reddit = new RedditNamespace(callTool, timeoutMs);
1160
+ this.tiktok = new TiktokNamespace(callTool, timeoutMs);
1161
+ this.tracking = new TrackingNamespace(callTool, timeoutMs);
1032
1162
  }
1033
1163
  async connect() {
1034
1164
  await this.transport.connect();
@@ -1043,6 +1173,21 @@ var XpozClient = class {
1043
1173
  await this.close();
1044
1174
  }
1045
1175
  };
1176
+
1177
+ // src/types/tracking.ts
1178
+ var TrackedItemType = /* @__PURE__ */ ((TrackedItemType2) => {
1179
+ TrackedItemType2["Keyword"] = "keyword";
1180
+ TrackedItemType2["User"] = "user";
1181
+ TrackedItemType2["Subreddit"] = "subreddit";
1182
+ return TrackedItemType2;
1183
+ })(TrackedItemType || {});
1184
+ var TrackedItemPlatform = /* @__PURE__ */ ((TrackedItemPlatform2) => {
1185
+ TrackedItemPlatform2["Twitter"] = "twitter";
1186
+ TrackedItemPlatform2["Instagram"] = "instagram";
1187
+ TrackedItemPlatform2["Reddit"] = "reddit";
1188
+ TrackedItemPlatform2["TikTok"] = "tiktok";
1189
+ return TrackedItemPlatform2;
1190
+ })(TrackedItemPlatform || {});
1046
1191
  export {
1047
1192
  AuthenticationError,
1048
1193
  OperationCancelledError,
@@ -1050,6 +1195,8 @@ export {
1050
1195
  OperationTimeoutError,
1051
1196
  PaginatedResult,
1052
1197
  ResponseType,
1198
+ TrackedItemPlatform,
1199
+ TrackedItemType,
1053
1200
  VERSION,
1054
1201
  XpozClient,
1055
1202
  XpozConnectionError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpoz/xpoz",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "TypeScript SDK for the Xpoz social media intelligence platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -23,7 +23,8 @@
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "dependencies": {
26
- "@modelcontextprotocol/sdk": "^1.0.0"
26
+ "@modelcontextprotocol/sdk": "^1.0.0",
27
+ "undici": "^7.24.6"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@types/node": "^25.3.0",