@xpoz/xpoz 0.2.1 → 0.3.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/dist/index.cjs +207 -18
- package/dist/index.d.cts +129 -2
- package/dist/index.d.ts +129 -2
- package/dist/index.js +197 -18
- package/package.json +3 -2
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
|
|
@@ -284,10 +294,18 @@ function coerce(value) {
|
|
|
284
294
|
}
|
|
285
295
|
|
|
286
296
|
// src/version.ts
|
|
287
|
-
var VERSION = "0.
|
|
297
|
+
var VERSION = "0.3.1";
|
|
288
298
|
|
|
289
299
|
// src/mcp/transport.ts
|
|
290
300
|
var USER_AGENT = `xpoz-ts-sdk/${VERSION}`;
|
|
301
|
+
function getProxyUrl() {
|
|
302
|
+
return process.env.HTTPS_PROXY ?? process.env.https_proxy ?? process.env.HTTP_PROXY ?? process.env.http_proxy;
|
|
303
|
+
}
|
|
304
|
+
async function createProxyFetch(proxyUrl) {
|
|
305
|
+
const { ProxyAgent, fetch: undiciFetch } = await import("undici");
|
|
306
|
+
const dispatcher = new ProxyAgent(proxyUrl);
|
|
307
|
+
return ((input, init) => undiciFetch(input, { ...init, dispatcher }));
|
|
308
|
+
}
|
|
291
309
|
var McpTransport = class {
|
|
292
310
|
serverUrl;
|
|
293
311
|
apiKey;
|
|
@@ -302,8 +320,11 @@ var McpTransport = class {
|
|
|
302
320
|
"User-Agent": USER_AGENT,
|
|
303
321
|
Authorization: `Bearer ${this.apiKey}`
|
|
304
322
|
};
|
|
323
|
+
const proxyUrl = getProxyUrl();
|
|
324
|
+
const customFetch = proxyUrl ? await createProxyFetch(proxyUrl) : void 0;
|
|
305
325
|
this.transport = new import_streamableHttp.StreamableHTTPClientTransport(new URL(this.serverUrl), {
|
|
306
|
-
requestInit: { headers }
|
|
326
|
+
requestInit: { headers },
|
|
327
|
+
...customFetch ? { fetch: customFetch } : {}
|
|
307
328
|
});
|
|
308
329
|
this.client = new import_client.Client(
|
|
309
330
|
{ name: "xpoz-ts-sdk", version: VERSION },
|
|
@@ -313,6 +334,10 @@ var McpTransport = class {
|
|
|
313
334
|
}
|
|
314
335
|
async close() {
|
|
315
336
|
if (this.client) {
|
|
337
|
+
try {
|
|
338
|
+
await this.transport?.terminateSession();
|
|
339
|
+
} catch {
|
|
340
|
+
}
|
|
316
341
|
try {
|
|
317
342
|
await this.client.close();
|
|
318
343
|
} catch {
|
|
@@ -571,6 +596,7 @@ var GET_TWITTER_COMMENTS = "getTwitterPostComments";
|
|
|
571
596
|
var GET_TWITTER_POST_INTERACTING_USERS = "getTwitterPostInteractingUsers";
|
|
572
597
|
var COUNT_TWEETS = "countTweets";
|
|
573
598
|
var GET_TWITTER_USER = "getTwitterUser";
|
|
599
|
+
var GET_TWITTER_USERS = "getTwitterUsers";
|
|
574
600
|
var SEARCH_TWITTER_USERS = "searchTwitterUsers";
|
|
575
601
|
var GET_TWITTER_USER_CONNECTIONS = "getTwitterUserConnections";
|
|
576
602
|
var GET_TWITTER_USERS_BY_KEYWORDS = "getTwitterUsersByKeywords";
|
|
@@ -592,6 +618,13 @@ var GET_REDDIT_USERS_BY_KEYWORDS = "getRedditUsersByKeywords";
|
|
|
592
618
|
var SEARCH_REDDIT_SUBREDDITS = "searchRedditSubreddits";
|
|
593
619
|
var GET_REDDIT_SUBREDDIT_WITH_POSTS = "getRedditSubredditWithPostsByName";
|
|
594
620
|
var GET_REDDIT_SUBREDDITS_BY_KEYWORDS = "getRedditSubredditsByKeywords";
|
|
621
|
+
var GET_TIKTOK_POSTS_BY_IDS = "getTiktokPostsByIds";
|
|
622
|
+
var GET_TIKTOK_POSTS_BY_USER = "getTiktokPostsByUser";
|
|
623
|
+
var SEARCH_TIKTOK_POSTS = "getTiktokPostsByKeywords";
|
|
624
|
+
var GET_TIKTOK_COMMENTS = "getTiktokCommentsByPostId";
|
|
625
|
+
var GET_TIKTOK_USER = "getTiktokUser";
|
|
626
|
+
var SEARCH_TIKTOK_USERS = "searchTiktokUsers";
|
|
627
|
+
var GET_TIKTOK_USERS_BY_KEYWORDS = "getTiktokUsersByKeywords";
|
|
595
628
|
|
|
596
629
|
// src/namespaces/twitter.ts
|
|
597
630
|
function parseTwitterPost(item) {
|
|
@@ -603,7 +636,10 @@ function parseUser(item) {
|
|
|
603
636
|
var TwitterNamespace = class extends BaseNamespace {
|
|
604
637
|
async getPostsByIds(postIds, options = {}) {
|
|
605
638
|
const args = this.buildArgs({ postIds, ...options });
|
|
606
|
-
const result = await this.callAndMaybePoll(
|
|
639
|
+
const result = await this.callAndMaybePoll(
|
|
640
|
+
GET_TWITTER_POSTS_BY_IDS,
|
|
641
|
+
args
|
|
642
|
+
);
|
|
607
643
|
return (result["results"] ?? []).map(parseTwitterPost);
|
|
608
644
|
}
|
|
609
645
|
async getPostsByAuthor(identifier, options = {}) {
|
|
@@ -616,8 +652,16 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
616
652
|
responseType: options.responseType,
|
|
617
653
|
limit: options.limit
|
|
618
654
|
});
|
|
619
|
-
const result = await this.callAndMaybePoll(
|
|
620
|
-
|
|
655
|
+
const result = await this.callAndMaybePoll(
|
|
656
|
+
GET_TWITTER_POSTS_BY_AUTHOR,
|
|
657
|
+
args
|
|
658
|
+
);
|
|
659
|
+
return this.buildPaginatedResult(
|
|
660
|
+
result,
|
|
661
|
+
parseTwitterPost,
|
|
662
|
+
GET_TWITTER_POSTS_BY_AUTHOR,
|
|
663
|
+
args
|
|
664
|
+
);
|
|
621
665
|
}
|
|
622
666
|
async searchPosts(query, options = {}) {
|
|
623
667
|
const args = this.buildArgs({
|
|
@@ -628,6 +672,7 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
628
672
|
authorUsername: options.authorUsername,
|
|
629
673
|
authorId: options.authorId,
|
|
630
674
|
language: options.language,
|
|
675
|
+
filterOutRetweets: options.filterOutRetweets,
|
|
631
676
|
forceLatest: options.forceLatest,
|
|
632
677
|
responseType: options.responseType,
|
|
633
678
|
limit: options.limit
|
|
@@ -635,30 +680,70 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
635
680
|
if (options.responseType === "csv" /* Csv */) {
|
|
636
681
|
const raw = await this.callTool(SEARCH_TWITTER_POSTS, args);
|
|
637
682
|
const exportOpId = raw["operationId"] ?? raw["dataDumpExportOperationId"] ?? null;
|
|
638
|
-
const csvRaw = {
|
|
639
|
-
|
|
683
|
+
const csvRaw = {
|
|
684
|
+
results: [],
|
|
685
|
+
dataDumpExportOperationId: exportOpId
|
|
686
|
+
};
|
|
687
|
+
return this.buildPaginatedResult(
|
|
688
|
+
csvRaw,
|
|
689
|
+
parseTwitterPost,
|
|
690
|
+
SEARCH_TWITTER_POSTS,
|
|
691
|
+
args
|
|
692
|
+
);
|
|
640
693
|
}
|
|
641
|
-
const result = await this.callAndMaybePoll(
|
|
642
|
-
|
|
694
|
+
const result = await this.callAndMaybePoll(
|
|
695
|
+
SEARCH_TWITTER_POSTS,
|
|
696
|
+
args
|
|
697
|
+
);
|
|
698
|
+
return this.buildPaginatedResult(
|
|
699
|
+
result,
|
|
700
|
+
parseTwitterPost,
|
|
701
|
+
SEARCH_TWITTER_POSTS,
|
|
702
|
+
args
|
|
703
|
+
);
|
|
643
704
|
}
|
|
644
705
|
async getRetweets(postId, options = {}) {
|
|
645
706
|
const args = this.buildArgs({ postId, ...options });
|
|
646
|
-
const result = await this.callAndMaybePoll(
|
|
647
|
-
|
|
707
|
+
const result = await this.callAndMaybePoll(
|
|
708
|
+
GET_TWITTER_RETWEETS,
|
|
709
|
+
args
|
|
710
|
+
);
|
|
711
|
+
return this.buildPaginatedResult(
|
|
712
|
+
result,
|
|
713
|
+
parseTwitterPost,
|
|
714
|
+
GET_TWITTER_RETWEETS,
|
|
715
|
+
args
|
|
716
|
+
);
|
|
648
717
|
}
|
|
649
718
|
async getQuotes(postId, options = {}) {
|
|
650
719
|
const args = this.buildArgs({ postId, ...options });
|
|
651
720
|
const result = await this.callAndMaybePoll(GET_TWITTER_QUOTES, args);
|
|
652
|
-
return this.buildPaginatedResult(
|
|
721
|
+
return this.buildPaginatedResult(
|
|
722
|
+
result,
|
|
723
|
+
parseTwitterPost,
|
|
724
|
+
GET_TWITTER_QUOTES,
|
|
725
|
+
args
|
|
726
|
+
);
|
|
653
727
|
}
|
|
654
728
|
async getComments(postId, options = {}) {
|
|
655
729
|
const args = this.buildArgs({ postId, ...options });
|
|
656
|
-
const result = await this.callAndMaybePoll(
|
|
657
|
-
|
|
730
|
+
const result = await this.callAndMaybePoll(
|
|
731
|
+
GET_TWITTER_COMMENTS,
|
|
732
|
+
args
|
|
733
|
+
);
|
|
734
|
+
return this.buildPaginatedResult(
|
|
735
|
+
result,
|
|
736
|
+
parseTwitterPost,
|
|
737
|
+
GET_TWITTER_COMMENTS,
|
|
738
|
+
args
|
|
739
|
+
);
|
|
658
740
|
}
|
|
659
741
|
async getPostInteractingUsers(postId, interactionType, options = {}) {
|
|
660
742
|
const args = this.buildArgs({ postId, interactionType, ...options });
|
|
661
|
-
const result = await this.callAndMaybePoll(
|
|
743
|
+
const result = await this.callAndMaybePoll(
|
|
744
|
+
GET_TWITTER_POST_INTERACTING_USERS,
|
|
745
|
+
args
|
|
746
|
+
);
|
|
662
747
|
return this.buildPaginatedResult(
|
|
663
748
|
result,
|
|
664
749
|
parseUser,
|
|
@@ -680,6 +765,16 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
680
765
|
}
|
|
681
766
|
return Number(count);
|
|
682
767
|
}
|
|
768
|
+
async getUsers(identifiers, options = {}) {
|
|
769
|
+
const args = this.buildArgs({
|
|
770
|
+
identifiers,
|
|
771
|
+
identifierType: options.identifierType ?? "username",
|
|
772
|
+
fields: options.fields,
|
|
773
|
+
forceLatest: options.forceLatest
|
|
774
|
+
});
|
|
775
|
+
const result = await this.callAndMaybePoll(GET_TWITTER_USERS, args);
|
|
776
|
+
return (result["results"] ?? []).map(parseUser);
|
|
777
|
+
}
|
|
683
778
|
async getUser(identifier, options = {}) {
|
|
684
779
|
const args = this.buildArgs({
|
|
685
780
|
identifier,
|
|
@@ -695,12 +790,18 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
695
790
|
}
|
|
696
791
|
async searchUsers(name, options = {}) {
|
|
697
792
|
const args = this.buildArgs({ name, ...options });
|
|
698
|
-
const result = await this.callAndMaybePoll(
|
|
793
|
+
const result = await this.callAndMaybePoll(
|
|
794
|
+
SEARCH_TWITTER_USERS,
|
|
795
|
+
args
|
|
796
|
+
);
|
|
699
797
|
return (result["results"] ?? []).map(parseUser);
|
|
700
798
|
}
|
|
701
799
|
async getUserConnections(username, connectionType, options = {}) {
|
|
702
800
|
const args = this.buildArgs({ username, connectionType, ...options });
|
|
703
|
-
const result = await this.callAndMaybePoll(
|
|
801
|
+
const result = await this.callAndMaybePoll(
|
|
802
|
+
GET_TWITTER_USER_CONNECTIONS,
|
|
803
|
+
args
|
|
804
|
+
);
|
|
704
805
|
return this.buildPaginatedResult(
|
|
705
806
|
result,
|
|
706
807
|
parseUser,
|
|
@@ -710,7 +811,10 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
710
811
|
}
|
|
711
812
|
async getUsersByKeywords(query, options = {}) {
|
|
712
813
|
const args = this.buildArgs({ query, ...options });
|
|
713
|
-
const result = await this.callAndMaybePoll(
|
|
814
|
+
const result = await this.callAndMaybePoll(
|
|
815
|
+
GET_TWITTER_USERS_BY_KEYWORDS,
|
|
816
|
+
args
|
|
817
|
+
);
|
|
714
818
|
return this.buildPaginatedResult(
|
|
715
819
|
result,
|
|
716
820
|
parseUser,
|
|
@@ -931,6 +1035,89 @@ var RedditNamespace = class extends BaseNamespace {
|
|
|
931
1035
|
}
|
|
932
1036
|
};
|
|
933
1037
|
|
|
1038
|
+
// src/namespaces/tiktok.ts
|
|
1039
|
+
function parsePost3(item) {
|
|
1040
|
+
return item;
|
|
1041
|
+
}
|
|
1042
|
+
function parseUser4(item) {
|
|
1043
|
+
return item;
|
|
1044
|
+
}
|
|
1045
|
+
function parseComment3(item) {
|
|
1046
|
+
return item;
|
|
1047
|
+
}
|
|
1048
|
+
var TiktokNamespace = class extends BaseNamespace {
|
|
1049
|
+
async getPostsByIds(postIds, options = {}) {
|
|
1050
|
+
const args = this.buildArgs({ postIds, ...options });
|
|
1051
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_POSTS_BY_IDS, args);
|
|
1052
|
+
return (result["results"] ?? []).map(parsePost3);
|
|
1053
|
+
}
|
|
1054
|
+
async getPostsByUser(identifier, options = {}) {
|
|
1055
|
+
const args = this.buildArgs({
|
|
1056
|
+
identifier,
|
|
1057
|
+
identifierType: options.identifierType ?? "username",
|
|
1058
|
+
fields: options.fields,
|
|
1059
|
+
startDate: options.startDate,
|
|
1060
|
+
endDate: options.endDate,
|
|
1061
|
+
forceLatest: options.forceLatest,
|
|
1062
|
+
responseType: options.responseType,
|
|
1063
|
+
limit: options.limit
|
|
1064
|
+
});
|
|
1065
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_POSTS_BY_USER, args);
|
|
1066
|
+
return this.buildPaginatedResult(
|
|
1067
|
+
result,
|
|
1068
|
+
parsePost3,
|
|
1069
|
+
GET_TIKTOK_POSTS_BY_USER,
|
|
1070
|
+
args
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
async searchPosts(query, options = {}) {
|
|
1074
|
+
const args = this.buildArgs({
|
|
1075
|
+
query,
|
|
1076
|
+
fields: options.fields,
|
|
1077
|
+
startDate: options.startDate,
|
|
1078
|
+
endDate: options.endDate,
|
|
1079
|
+
forceLatest: options.forceLatest,
|
|
1080
|
+
responseType: options.responseType,
|
|
1081
|
+
limit: options.limit
|
|
1082
|
+
});
|
|
1083
|
+
const result = await this.callAndMaybePoll(SEARCH_TIKTOK_POSTS, args);
|
|
1084
|
+
return this.buildPaginatedResult(result, parsePost3, SEARCH_TIKTOK_POSTS, args);
|
|
1085
|
+
}
|
|
1086
|
+
async getComments(postId, options = {}) {
|
|
1087
|
+
const args = this.buildArgs({ postId, ...options });
|
|
1088
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_COMMENTS, args);
|
|
1089
|
+
return this.buildPaginatedResult(result, parseComment3, GET_TIKTOK_COMMENTS, args);
|
|
1090
|
+
}
|
|
1091
|
+
async getUser(identifier, options = {}) {
|
|
1092
|
+
const args = this.buildArgs({
|
|
1093
|
+
identifier,
|
|
1094
|
+
identifierType: options.identifierType ?? "username",
|
|
1095
|
+
fields: options.fields
|
|
1096
|
+
});
|
|
1097
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_USER, args);
|
|
1098
|
+
const results = result["results"];
|
|
1099
|
+
if (Array.isArray(results) && results.length > 0) {
|
|
1100
|
+
return results[0];
|
|
1101
|
+
}
|
|
1102
|
+
return result;
|
|
1103
|
+
}
|
|
1104
|
+
async searchUsers(name, options = {}) {
|
|
1105
|
+
const args = this.buildArgs({ name, ...options });
|
|
1106
|
+
const result = await this.callAndMaybePoll(SEARCH_TIKTOK_USERS, args);
|
|
1107
|
+
return (result["results"] ?? []).map(parseUser4);
|
|
1108
|
+
}
|
|
1109
|
+
async getUsersByKeywords(query, options = {}) {
|
|
1110
|
+
const args = this.buildArgs({ query, ...options });
|
|
1111
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_USERS_BY_KEYWORDS, args);
|
|
1112
|
+
return this.buildPaginatedResult(
|
|
1113
|
+
result,
|
|
1114
|
+
parseUser4,
|
|
1115
|
+
GET_TIKTOK_USERS_BY_KEYWORDS,
|
|
1116
|
+
args
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
|
|
934
1121
|
// src/versionCheck.ts
|
|
935
1122
|
var NPM_REGISTRY_URL = "https://registry.npmjs.org/@xpoz/xpoz/latest";
|
|
936
1123
|
var CHECK_TIMEOUT_MS = 3e3;
|
|
@@ -976,6 +1163,7 @@ var XpozClient = class {
|
|
|
976
1163
|
twitter;
|
|
977
1164
|
instagram;
|
|
978
1165
|
reddit;
|
|
1166
|
+
tiktok;
|
|
979
1167
|
transport;
|
|
980
1168
|
versionCheck;
|
|
981
1169
|
constructor(options = {}) {
|
|
@@ -993,6 +1181,7 @@ var XpozClient = class {
|
|
|
993
1181
|
this.twitter = new TwitterNamespace(callTool, timeoutMs);
|
|
994
1182
|
this.instagram = new InstagramNamespace(callTool, timeoutMs);
|
|
995
1183
|
this.reddit = new RedditNamespace(callTool, timeoutMs);
|
|
1184
|
+
this.tiktok = new TiktokNamespace(callTool, timeoutMs);
|
|
996
1185
|
}
|
|
997
1186
|
async connect() {
|
|
998
1187
|
await this.transport.connect();
|
package/dist/index.d.cts
CHANGED
|
@@ -170,6 +170,7 @@ declare class TwitterNamespace extends BaseNamespace {
|
|
|
170
170
|
authorUsername?: string;
|
|
171
171
|
authorId?: string;
|
|
172
172
|
language?: string;
|
|
173
|
+
filterOutRetweets?: boolean;
|
|
173
174
|
forceLatest?: boolean;
|
|
174
175
|
responseType?: ResponseType;
|
|
175
176
|
limit?: number;
|
|
@@ -196,6 +197,11 @@ declare class TwitterNamespace extends BaseNamespace {
|
|
|
196
197
|
startDate?: string;
|
|
197
198
|
endDate?: string;
|
|
198
199
|
}): Promise<number>;
|
|
200
|
+
getUsers(identifiers: string[], options?: {
|
|
201
|
+
identifierType?: string;
|
|
202
|
+
fields?: string[];
|
|
203
|
+
forceLatest?: boolean;
|
|
204
|
+
}): Promise<TwitterUser[]>;
|
|
199
205
|
getUser(identifier: string, options?: {
|
|
200
206
|
identifierType?: string;
|
|
201
207
|
fields?: string[];
|
|
@@ -553,10 +559,131 @@ declare class RedditNamespace extends BaseNamespace {
|
|
|
553
559
|
private _parseSubredditWithPosts;
|
|
554
560
|
}
|
|
555
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
|
+
|
|
556
682
|
declare class XpozClient {
|
|
557
683
|
twitter: TwitterNamespace;
|
|
558
684
|
instagram: InstagramNamespace;
|
|
559
685
|
reddit: RedditNamespace;
|
|
686
|
+
tiktok: TiktokNamespace;
|
|
560
687
|
private transport;
|
|
561
688
|
private versionCheck;
|
|
562
689
|
constructor(options?: {
|
|
@@ -594,8 +721,8 @@ declare class OperationCancelledError extends XpozError {
|
|
|
594
721
|
constructor(operationId: string);
|
|
595
722
|
}
|
|
596
723
|
|
|
597
|
-
declare const VERSION = "0.
|
|
724
|
+
declare const VERSION = "0.3.1";
|
|
598
725
|
|
|
599
726
|
declare function checkForUpdates(): Promise<void>;
|
|
600
727
|
|
|
601
|
-
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 };
|
|
728
|
+
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 TiktokComment, type TiktokPost, type TiktokUser, type TwitterPost, type TwitterUser, VERSION, XpozClient, XpozConnectionError, XpozError, checkForUpdates };
|
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,7 @@ declare class TwitterNamespace extends BaseNamespace {
|
|
|
170
170
|
authorUsername?: string;
|
|
171
171
|
authorId?: string;
|
|
172
172
|
language?: string;
|
|
173
|
+
filterOutRetweets?: boolean;
|
|
173
174
|
forceLatest?: boolean;
|
|
174
175
|
responseType?: ResponseType;
|
|
175
176
|
limit?: number;
|
|
@@ -196,6 +197,11 @@ declare class TwitterNamespace extends BaseNamespace {
|
|
|
196
197
|
startDate?: string;
|
|
197
198
|
endDate?: string;
|
|
198
199
|
}): Promise<number>;
|
|
200
|
+
getUsers(identifiers: string[], options?: {
|
|
201
|
+
identifierType?: string;
|
|
202
|
+
fields?: string[];
|
|
203
|
+
forceLatest?: boolean;
|
|
204
|
+
}): Promise<TwitterUser[]>;
|
|
199
205
|
getUser(identifier: string, options?: {
|
|
200
206
|
identifierType?: string;
|
|
201
207
|
fields?: string[];
|
|
@@ -553,10 +559,131 @@ declare class RedditNamespace extends BaseNamespace {
|
|
|
553
559
|
private _parseSubredditWithPosts;
|
|
554
560
|
}
|
|
555
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
|
+
|
|
556
682
|
declare class XpozClient {
|
|
557
683
|
twitter: TwitterNamespace;
|
|
558
684
|
instagram: InstagramNamespace;
|
|
559
685
|
reddit: RedditNamespace;
|
|
686
|
+
tiktok: TiktokNamespace;
|
|
560
687
|
private transport;
|
|
561
688
|
private versionCheck;
|
|
562
689
|
constructor(options?: {
|
|
@@ -594,8 +721,8 @@ declare class OperationCancelledError extends XpozError {
|
|
|
594
721
|
constructor(operationId: string);
|
|
595
722
|
}
|
|
596
723
|
|
|
597
|
-
declare const VERSION = "0.
|
|
724
|
+
declare const VERSION = "0.3.1";
|
|
598
725
|
|
|
599
726
|
declare function checkForUpdates(): Promise<void>;
|
|
600
727
|
|
|
601
|
-
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 };
|
|
728
|
+
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 TiktokComment, type TiktokPost, type TiktokUser, 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.
|
|
251
|
+
var VERSION = "0.3.1";
|
|
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 {
|
|
@@ -535,6 +550,7 @@ var GET_TWITTER_COMMENTS = "getTwitterPostComments";
|
|
|
535
550
|
var GET_TWITTER_POST_INTERACTING_USERS = "getTwitterPostInteractingUsers";
|
|
536
551
|
var COUNT_TWEETS = "countTweets";
|
|
537
552
|
var GET_TWITTER_USER = "getTwitterUser";
|
|
553
|
+
var GET_TWITTER_USERS = "getTwitterUsers";
|
|
538
554
|
var SEARCH_TWITTER_USERS = "searchTwitterUsers";
|
|
539
555
|
var GET_TWITTER_USER_CONNECTIONS = "getTwitterUserConnections";
|
|
540
556
|
var GET_TWITTER_USERS_BY_KEYWORDS = "getTwitterUsersByKeywords";
|
|
@@ -556,6 +572,13 @@ var GET_REDDIT_USERS_BY_KEYWORDS = "getRedditUsersByKeywords";
|
|
|
556
572
|
var SEARCH_REDDIT_SUBREDDITS = "searchRedditSubreddits";
|
|
557
573
|
var GET_REDDIT_SUBREDDIT_WITH_POSTS = "getRedditSubredditWithPostsByName";
|
|
558
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";
|
|
559
582
|
|
|
560
583
|
// src/namespaces/twitter.ts
|
|
561
584
|
function parseTwitterPost(item) {
|
|
@@ -567,7 +590,10 @@ function parseUser(item) {
|
|
|
567
590
|
var TwitterNamespace = class extends BaseNamespace {
|
|
568
591
|
async getPostsByIds(postIds, options = {}) {
|
|
569
592
|
const args = this.buildArgs({ postIds, ...options });
|
|
570
|
-
const result = await this.callAndMaybePoll(
|
|
593
|
+
const result = await this.callAndMaybePoll(
|
|
594
|
+
GET_TWITTER_POSTS_BY_IDS,
|
|
595
|
+
args
|
|
596
|
+
);
|
|
571
597
|
return (result["results"] ?? []).map(parseTwitterPost);
|
|
572
598
|
}
|
|
573
599
|
async getPostsByAuthor(identifier, options = {}) {
|
|
@@ -580,8 +606,16 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
580
606
|
responseType: options.responseType,
|
|
581
607
|
limit: options.limit
|
|
582
608
|
});
|
|
583
|
-
const result = await this.callAndMaybePoll(
|
|
584
|
-
|
|
609
|
+
const result = await this.callAndMaybePoll(
|
|
610
|
+
GET_TWITTER_POSTS_BY_AUTHOR,
|
|
611
|
+
args
|
|
612
|
+
);
|
|
613
|
+
return this.buildPaginatedResult(
|
|
614
|
+
result,
|
|
615
|
+
parseTwitterPost,
|
|
616
|
+
GET_TWITTER_POSTS_BY_AUTHOR,
|
|
617
|
+
args
|
|
618
|
+
);
|
|
585
619
|
}
|
|
586
620
|
async searchPosts(query, options = {}) {
|
|
587
621
|
const args = this.buildArgs({
|
|
@@ -592,6 +626,7 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
592
626
|
authorUsername: options.authorUsername,
|
|
593
627
|
authorId: options.authorId,
|
|
594
628
|
language: options.language,
|
|
629
|
+
filterOutRetweets: options.filterOutRetweets,
|
|
595
630
|
forceLatest: options.forceLatest,
|
|
596
631
|
responseType: options.responseType,
|
|
597
632
|
limit: options.limit
|
|
@@ -599,30 +634,70 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
599
634
|
if (options.responseType === "csv" /* Csv */) {
|
|
600
635
|
const raw = await this.callTool(SEARCH_TWITTER_POSTS, args);
|
|
601
636
|
const exportOpId = raw["operationId"] ?? raw["dataDumpExportOperationId"] ?? null;
|
|
602
|
-
const csvRaw = {
|
|
603
|
-
|
|
637
|
+
const csvRaw = {
|
|
638
|
+
results: [],
|
|
639
|
+
dataDumpExportOperationId: exportOpId
|
|
640
|
+
};
|
|
641
|
+
return this.buildPaginatedResult(
|
|
642
|
+
csvRaw,
|
|
643
|
+
parseTwitterPost,
|
|
644
|
+
SEARCH_TWITTER_POSTS,
|
|
645
|
+
args
|
|
646
|
+
);
|
|
604
647
|
}
|
|
605
|
-
const result = await this.callAndMaybePoll(
|
|
606
|
-
|
|
648
|
+
const result = await this.callAndMaybePoll(
|
|
649
|
+
SEARCH_TWITTER_POSTS,
|
|
650
|
+
args
|
|
651
|
+
);
|
|
652
|
+
return this.buildPaginatedResult(
|
|
653
|
+
result,
|
|
654
|
+
parseTwitterPost,
|
|
655
|
+
SEARCH_TWITTER_POSTS,
|
|
656
|
+
args
|
|
657
|
+
);
|
|
607
658
|
}
|
|
608
659
|
async getRetweets(postId, options = {}) {
|
|
609
660
|
const args = this.buildArgs({ postId, ...options });
|
|
610
|
-
const result = await this.callAndMaybePoll(
|
|
611
|
-
|
|
661
|
+
const result = await this.callAndMaybePoll(
|
|
662
|
+
GET_TWITTER_RETWEETS,
|
|
663
|
+
args
|
|
664
|
+
);
|
|
665
|
+
return this.buildPaginatedResult(
|
|
666
|
+
result,
|
|
667
|
+
parseTwitterPost,
|
|
668
|
+
GET_TWITTER_RETWEETS,
|
|
669
|
+
args
|
|
670
|
+
);
|
|
612
671
|
}
|
|
613
672
|
async getQuotes(postId, options = {}) {
|
|
614
673
|
const args = this.buildArgs({ postId, ...options });
|
|
615
674
|
const result = await this.callAndMaybePoll(GET_TWITTER_QUOTES, args);
|
|
616
|
-
return this.buildPaginatedResult(
|
|
675
|
+
return this.buildPaginatedResult(
|
|
676
|
+
result,
|
|
677
|
+
parseTwitterPost,
|
|
678
|
+
GET_TWITTER_QUOTES,
|
|
679
|
+
args
|
|
680
|
+
);
|
|
617
681
|
}
|
|
618
682
|
async getComments(postId, options = {}) {
|
|
619
683
|
const args = this.buildArgs({ postId, ...options });
|
|
620
|
-
const result = await this.callAndMaybePoll(
|
|
621
|
-
|
|
684
|
+
const result = await this.callAndMaybePoll(
|
|
685
|
+
GET_TWITTER_COMMENTS,
|
|
686
|
+
args
|
|
687
|
+
);
|
|
688
|
+
return this.buildPaginatedResult(
|
|
689
|
+
result,
|
|
690
|
+
parseTwitterPost,
|
|
691
|
+
GET_TWITTER_COMMENTS,
|
|
692
|
+
args
|
|
693
|
+
);
|
|
622
694
|
}
|
|
623
695
|
async getPostInteractingUsers(postId, interactionType, options = {}) {
|
|
624
696
|
const args = this.buildArgs({ postId, interactionType, ...options });
|
|
625
|
-
const result = await this.callAndMaybePoll(
|
|
697
|
+
const result = await this.callAndMaybePoll(
|
|
698
|
+
GET_TWITTER_POST_INTERACTING_USERS,
|
|
699
|
+
args
|
|
700
|
+
);
|
|
626
701
|
return this.buildPaginatedResult(
|
|
627
702
|
result,
|
|
628
703
|
parseUser,
|
|
@@ -644,6 +719,16 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
644
719
|
}
|
|
645
720
|
return Number(count);
|
|
646
721
|
}
|
|
722
|
+
async getUsers(identifiers, options = {}) {
|
|
723
|
+
const args = this.buildArgs({
|
|
724
|
+
identifiers,
|
|
725
|
+
identifierType: options.identifierType ?? "username",
|
|
726
|
+
fields: options.fields,
|
|
727
|
+
forceLatest: options.forceLatest
|
|
728
|
+
});
|
|
729
|
+
const result = await this.callAndMaybePoll(GET_TWITTER_USERS, args);
|
|
730
|
+
return (result["results"] ?? []).map(parseUser);
|
|
731
|
+
}
|
|
647
732
|
async getUser(identifier, options = {}) {
|
|
648
733
|
const args = this.buildArgs({
|
|
649
734
|
identifier,
|
|
@@ -659,12 +744,18 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
659
744
|
}
|
|
660
745
|
async searchUsers(name, options = {}) {
|
|
661
746
|
const args = this.buildArgs({ name, ...options });
|
|
662
|
-
const result = await this.callAndMaybePoll(
|
|
747
|
+
const result = await this.callAndMaybePoll(
|
|
748
|
+
SEARCH_TWITTER_USERS,
|
|
749
|
+
args
|
|
750
|
+
);
|
|
663
751
|
return (result["results"] ?? []).map(parseUser);
|
|
664
752
|
}
|
|
665
753
|
async getUserConnections(username, connectionType, options = {}) {
|
|
666
754
|
const args = this.buildArgs({ username, connectionType, ...options });
|
|
667
|
-
const result = await this.callAndMaybePoll(
|
|
755
|
+
const result = await this.callAndMaybePoll(
|
|
756
|
+
GET_TWITTER_USER_CONNECTIONS,
|
|
757
|
+
args
|
|
758
|
+
);
|
|
668
759
|
return this.buildPaginatedResult(
|
|
669
760
|
result,
|
|
670
761
|
parseUser,
|
|
@@ -674,7 +765,10 @@ var TwitterNamespace = class extends BaseNamespace {
|
|
|
674
765
|
}
|
|
675
766
|
async getUsersByKeywords(query, options = {}) {
|
|
676
767
|
const args = this.buildArgs({ query, ...options });
|
|
677
|
-
const result = await this.callAndMaybePoll(
|
|
768
|
+
const result = await this.callAndMaybePoll(
|
|
769
|
+
GET_TWITTER_USERS_BY_KEYWORDS,
|
|
770
|
+
args
|
|
771
|
+
);
|
|
678
772
|
return this.buildPaginatedResult(
|
|
679
773
|
result,
|
|
680
774
|
parseUser,
|
|
@@ -895,6 +989,89 @@ var RedditNamespace = class extends BaseNamespace {
|
|
|
895
989
|
}
|
|
896
990
|
};
|
|
897
991
|
|
|
992
|
+
// src/namespaces/tiktok.ts
|
|
993
|
+
function parsePost3(item) {
|
|
994
|
+
return item;
|
|
995
|
+
}
|
|
996
|
+
function parseUser4(item) {
|
|
997
|
+
return item;
|
|
998
|
+
}
|
|
999
|
+
function parseComment3(item) {
|
|
1000
|
+
return item;
|
|
1001
|
+
}
|
|
1002
|
+
var TiktokNamespace = class extends BaseNamespace {
|
|
1003
|
+
async getPostsByIds(postIds, options = {}) {
|
|
1004
|
+
const args = this.buildArgs({ postIds, ...options });
|
|
1005
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_POSTS_BY_IDS, args);
|
|
1006
|
+
return (result["results"] ?? []).map(parsePost3);
|
|
1007
|
+
}
|
|
1008
|
+
async getPostsByUser(identifier, options = {}) {
|
|
1009
|
+
const args = this.buildArgs({
|
|
1010
|
+
identifier,
|
|
1011
|
+
identifierType: options.identifierType ?? "username",
|
|
1012
|
+
fields: options.fields,
|
|
1013
|
+
startDate: options.startDate,
|
|
1014
|
+
endDate: options.endDate,
|
|
1015
|
+
forceLatest: options.forceLatest,
|
|
1016
|
+
responseType: options.responseType,
|
|
1017
|
+
limit: options.limit
|
|
1018
|
+
});
|
|
1019
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_POSTS_BY_USER, args);
|
|
1020
|
+
return this.buildPaginatedResult(
|
|
1021
|
+
result,
|
|
1022
|
+
parsePost3,
|
|
1023
|
+
GET_TIKTOK_POSTS_BY_USER,
|
|
1024
|
+
args
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
async searchPosts(query, options = {}) {
|
|
1028
|
+
const args = this.buildArgs({
|
|
1029
|
+
query,
|
|
1030
|
+
fields: options.fields,
|
|
1031
|
+
startDate: options.startDate,
|
|
1032
|
+
endDate: options.endDate,
|
|
1033
|
+
forceLatest: options.forceLatest,
|
|
1034
|
+
responseType: options.responseType,
|
|
1035
|
+
limit: options.limit
|
|
1036
|
+
});
|
|
1037
|
+
const result = await this.callAndMaybePoll(SEARCH_TIKTOK_POSTS, args);
|
|
1038
|
+
return this.buildPaginatedResult(result, parsePost3, SEARCH_TIKTOK_POSTS, args);
|
|
1039
|
+
}
|
|
1040
|
+
async getComments(postId, options = {}) {
|
|
1041
|
+
const args = this.buildArgs({ postId, ...options });
|
|
1042
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_COMMENTS, args);
|
|
1043
|
+
return this.buildPaginatedResult(result, parseComment3, GET_TIKTOK_COMMENTS, args);
|
|
1044
|
+
}
|
|
1045
|
+
async getUser(identifier, options = {}) {
|
|
1046
|
+
const args = this.buildArgs({
|
|
1047
|
+
identifier,
|
|
1048
|
+
identifierType: options.identifierType ?? "username",
|
|
1049
|
+
fields: options.fields
|
|
1050
|
+
});
|
|
1051
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_USER, args);
|
|
1052
|
+
const results = result["results"];
|
|
1053
|
+
if (Array.isArray(results) && results.length > 0) {
|
|
1054
|
+
return results[0];
|
|
1055
|
+
}
|
|
1056
|
+
return result;
|
|
1057
|
+
}
|
|
1058
|
+
async searchUsers(name, options = {}) {
|
|
1059
|
+
const args = this.buildArgs({ name, ...options });
|
|
1060
|
+
const result = await this.callAndMaybePoll(SEARCH_TIKTOK_USERS, args);
|
|
1061
|
+
return (result["results"] ?? []).map(parseUser4);
|
|
1062
|
+
}
|
|
1063
|
+
async getUsersByKeywords(query, options = {}) {
|
|
1064
|
+
const args = this.buildArgs({ query, ...options });
|
|
1065
|
+
const result = await this.callAndMaybePoll(GET_TIKTOK_USERS_BY_KEYWORDS, args);
|
|
1066
|
+
return this.buildPaginatedResult(
|
|
1067
|
+
result,
|
|
1068
|
+
parseUser4,
|
|
1069
|
+
GET_TIKTOK_USERS_BY_KEYWORDS,
|
|
1070
|
+
args
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
|
|
898
1075
|
// src/versionCheck.ts
|
|
899
1076
|
var NPM_REGISTRY_URL = "https://registry.npmjs.org/@xpoz/xpoz/latest";
|
|
900
1077
|
var CHECK_TIMEOUT_MS = 3e3;
|
|
@@ -940,6 +1117,7 @@ var XpozClient = class {
|
|
|
940
1117
|
twitter;
|
|
941
1118
|
instagram;
|
|
942
1119
|
reddit;
|
|
1120
|
+
tiktok;
|
|
943
1121
|
transport;
|
|
944
1122
|
versionCheck;
|
|
945
1123
|
constructor(options = {}) {
|
|
@@ -957,6 +1135,7 @@ var XpozClient = class {
|
|
|
957
1135
|
this.twitter = new TwitterNamespace(callTool, timeoutMs);
|
|
958
1136
|
this.instagram = new InstagramNamespace(callTool, timeoutMs);
|
|
959
1137
|
this.reddit = new RedditNamespace(callTool, timeoutMs);
|
|
1138
|
+
this.tiktok = new TiktokNamespace(callTool, timeoutMs);
|
|
960
1139
|
}
|
|
961
1140
|
async connect() {
|
|
962
1141
|
await this.transport.connect();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpoz/xpoz",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|