twitter-openapi-typescript 0.0.14 → 0.0.16
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 +31 -0
- package/{LICENSE.txt → LICENSE.AGPL} +3 -3
- package/README.md +7 -0
- package/dist/src/api.js +11 -10
- package/dist/src/api.js.map +1 -1
- package/dist/src/apis/defaultApi.d.ts +1 -1
- package/dist/src/apis/defaultApi.d.ts.map +1 -1
- package/dist/src/apis/defaultApi.js.map +1 -1
- package/dist/src/apis/postApi.d.ts +1 -0
- package/dist/src/apis/postApi.d.ts.map +1 -1
- package/dist/src/apis/postApi.js +15 -9
- package/dist/src/apis/postApi.js.map +1 -1
- package/dist/src/apis/tweetApi.js +11 -11
- package/dist/src/apis/tweetApi.js.map +1 -1
- package/dist/src/apis/userApi.js +1 -1
- package/dist/src/apis/userApi.js.map +1 -1
- package/dist/src/apis/userListApi.js +5 -5
- package/dist/src/apis/userListApi.js.map +1 -1
- package/dist/src/models/timeline.d.ts +1 -1
- package/dist/src/models/timeline.d.ts.map +1 -1
- package/dist/src/models/tweet.d.ts +18 -0
- package/dist/src/models/tweet.d.ts.map +1 -0
- package/dist/src/models/tweet.js +3 -0
- package/dist/src/models/tweet.js.map +1 -0
- package/dist/src/models/user.d.ts +16 -0
- package/dist/src/models/user.d.ts.map +1 -0
- package/dist/src/models/user.js +3 -0
- package/dist/src/models/user.js.map +1 -0
- package/dist/src/models/user_list.d.ts +13 -0
- package/dist/src/models/user_list.d.ts.map +1 -0
- package/dist/src/models/user_list.js +3 -0
- package/dist/src/models/user_list.js.map +1 -0
- package/dist/src/utils/api.d.ts +1 -1
- package/dist/src/utils/api.d.ts.map +1 -1
- package/dist/src/utils/api.js +27 -20
- package/dist/src/utils/api.js.map +1 -1
- package/jest.config.js +2 -5
- package/package.json +18 -18
- package/src/api.ts +2 -2
- package/src/apis/defaultApi.ts +3 -1
- package/src/apis/postApi.ts +8 -0
- package/src/apis/tweetApi.ts +22 -22
- package/src/apis/userApi.ts +1 -1
- package/src/apis/userListApi.ts +10 -10
- package/src/models/timeline.ts +1 -1
- package/src/utils/api.ts +31 -23
- package/test/api/defaultApi.test.ts +2 -2
- package/test/api/usersApi.test.ts +1 -1
- package/test/util.ts +3 -3
- package/tsconfig.build.json +2 -1
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as i from 'twitter-openapi-typescript-generated';
|
|
2
|
+
import { ApiUtilsHeader } from './';
|
|
3
|
+
export type UserApiUtilsResponse = {
|
|
4
|
+
raw: UserApiUtilsRaw;
|
|
5
|
+
header: ApiUtilsHeader;
|
|
6
|
+
data: i.User;
|
|
7
|
+
};
|
|
8
|
+
export type UsersApiUtilsResponse = {
|
|
9
|
+
raw: UserApiUtilsRaw;
|
|
10
|
+
header: ApiUtilsHeader;
|
|
11
|
+
data: i.User[];
|
|
12
|
+
};
|
|
13
|
+
export type UserApiUtilsRaw = {
|
|
14
|
+
response: Response;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/models/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,sCAAsC,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,eAAe,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;CACd,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,eAAe,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../src/models/user.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as i from 'twitter-openapi-typescript-generated';
|
|
2
|
+
import { ApiUtilsRaw, CursorApiUtilsResponse, ApiUtilsHeader } from './';
|
|
3
|
+
export type UserListApiUtilsResponse = {
|
|
4
|
+
raw: ApiUtilsRaw;
|
|
5
|
+
header: ApiUtilsHeader;
|
|
6
|
+
cursor: CursorApiUtilsResponse;
|
|
7
|
+
data: UserApiUtilsData[];
|
|
8
|
+
};
|
|
9
|
+
export type UserApiUtilsData = {
|
|
10
|
+
raw: i.TimelineUser;
|
|
11
|
+
user: i.User;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=user_list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user_list.d.ts","sourceRoot":"","sources":["../../../src/models/user_list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,sCAAsC,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/E,MAAM,MAAM,wBAAwB,GAAG;IACrC,GAAG,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,IAAI,EAAE,gBAAgB,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,CAAC,CAAC,YAAY,CAAC;IACpB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user_list.js","sourceRoot":"","sources":["../../../src/models/user_list.ts"],"names":[],"mappings":""}
|
package/dist/src/utils/api.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ type buildTweetApiUtilsArgs = {
|
|
|
15
15
|
};
|
|
16
16
|
export declare const buildTweetApiUtils: (args: buildTweetApiUtilsArgs) => TweetApiUtilsData | undefined;
|
|
17
17
|
export declare const tweetResultsConverter: (tweetResults: i.ItemResult) => i.Tweet | undefined;
|
|
18
|
-
export declare const userOrNullConverter: (userResults: i.UserUnion) => i.User |
|
|
18
|
+
export declare const userOrNullConverter: (userResults: i.UserUnion) => i.User | undefined;
|
|
19
19
|
export declare const userEntriesConverter: (item: i.TimelineAddEntry[]) => i.UserResults[];
|
|
20
20
|
export declare const userResultConverter: (user: i.UserResults[]) => UserApiUtilsData[];
|
|
21
21
|
export declare const entriesCursor: (item: i.TimelineAddEntry[]) => CursorApiUtilsResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,sCAAsC,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEvG,eAAO,MAAM,SAAS;;;;MAAuE,GAY5F,CAAC;AAEF,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,sCAAsC,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEvG,eAAO,MAAM,SAAS;;;;MAAuE,GAY5F,CAAC;AAEF,eAAO,MAAM,UAAU,8BAQtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,SAAU,EAAE,gBAAgB,EAAE,KAAG,EAAE,gBAAgB,EASjF,CAAC;AAEF,eAAO,MAAM,qBAAqB,SAAU,EAAE,gBAAgB,EAAE,KAAG,iBAAiB,EA0BnF,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC;IACrB,gBAAgB,CAAC,EAAE,GAAG,CAAC;IACvB,KAAK,CAAC,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;CAC3B,CAAC;AACF,eAAO,MAAM,kBAAkB,SAAU,sBAAsB,KAAG,iBAAiB,GAAG,SAsBrF,CAAC;AAEF,eAAO,MAAM,qBAAqB,iBAAkB,EAAE,UAAU,KAAG,EAAE,KAAK,GAAG,SAW5E,CAAC;AAEF,eAAO,MAAM,mBAAmB,gBAAiB,EAAE,SAAS,KAAG,EAAE,IAAI,GAAG,SAIvE,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,EAAE,gBAAgB,EAAE,KAAG,EAAE,WAAW,EAW9E,CAAC;AAMF,eAAO,MAAM,mBAAmB,SAAU,EAAE,WAAW,EAAE,KAAG,gBAAgB,EAW3E,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,EAAE,gBAAgB,EAAE,KAAG,sBAc1D,CAAC;AAEF,eAAO,MAAM,WAAW,eAAgB,EAAE,sBAAsB,EAAE,KAAG,sBAKpE,CAAC;AAEF,eAAO,MAAM,WAAW,YAAa,OAAO,KAAG,cAe9C,CAAC"}
|
package/dist/src/utils/api.js
CHANGED
|
@@ -15,13 +15,13 @@ exports.buildHeader = exports.buildCursor = exports.entriesCursor = exports.user
|
|
|
15
15
|
var i = require("twitter-openapi-typescript-generated");
|
|
16
16
|
var getKwargs = function (flag, additional) {
|
|
17
17
|
var kwargs = { pathQueryId: flag.queryId };
|
|
18
|
-
if (flag.variables !=
|
|
18
|
+
if (flag.variables != undefined) {
|
|
19
19
|
kwargs.variables = JSON.stringify(__assign(__assign({}, flag.variables), additional));
|
|
20
20
|
}
|
|
21
|
-
if (flag.features !=
|
|
21
|
+
if (flag.features != undefined) {
|
|
22
22
|
kwargs.features = JSON.stringify(flag.features);
|
|
23
23
|
}
|
|
24
|
-
if (flag.fieldToggles !=
|
|
24
|
+
if (flag.fieldToggles != undefined) {
|
|
25
25
|
kwargs.fieldToggles = JSON.stringify(flag.fieldToggles);
|
|
26
26
|
}
|
|
27
27
|
return kwargs;
|
|
@@ -35,6 +35,7 @@ var errorCheck = function (data) {
|
|
|
35
35
|
else if (res.error != undefined) {
|
|
36
36
|
throw Error(res.errors[0].message);
|
|
37
37
|
}
|
|
38
|
+
throw Error();
|
|
38
39
|
};
|
|
39
40
|
exports.errorCheck = errorCheck;
|
|
40
41
|
var instructionToEntry = function (item) {
|
|
@@ -55,9 +56,9 @@ var tweetEntriesConverter = function (item) {
|
|
|
55
56
|
var _a;
|
|
56
57
|
if (e.content.entryType == i.ContentEntryType.TimelineTimelineItem) {
|
|
57
58
|
var item_1 = e.content.itemContent;
|
|
58
|
-
var timeline = item_1.itemType == i.ContentItemType.TimelineTweet ? item_1 :
|
|
59
|
-
if (timeline ==
|
|
60
|
-
return
|
|
59
|
+
var timeline = item_1.itemType == i.ContentItemType.TimelineTweet ? item_1 : undefined;
|
|
60
|
+
if (timeline == undefined)
|
|
61
|
+
return undefined;
|
|
61
62
|
return (0, exports.buildTweetApiUtils)({
|
|
62
63
|
result: timeline.tweetResults,
|
|
63
64
|
promotedMetadata: timeline.promotedMetadata,
|
|
@@ -69,7 +70,7 @@ var tweetEntriesConverter = function (item) {
|
|
|
69
70
|
.filter(function (e) { return e.item.itemContent.itemType == i.ContentItemType.TimelineTweet; })
|
|
70
71
|
.map(function (e) { return e.item.itemContent; });
|
|
71
72
|
if (timelineList.length == 0)
|
|
72
|
-
return
|
|
73
|
+
return undefined;
|
|
73
74
|
var timeline = timelineList[0];
|
|
74
75
|
return (0, exports.buildTweetApiUtils)({
|
|
75
76
|
result: timeline.tweetResults,
|
|
@@ -78,20 +79,21 @@ var tweetEntriesConverter = function (item) {
|
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
})
|
|
81
|
-
.filter(function (e) { return e !=
|
|
82
|
+
.filter(function (e) { return e != undefined; });
|
|
82
83
|
};
|
|
83
84
|
exports.tweetEntriesConverter = tweetEntriesConverter;
|
|
84
85
|
var buildTweetApiUtils = function (args) {
|
|
85
|
-
var _a, _b;
|
|
86
|
+
var _a, _b, _c, _d;
|
|
86
87
|
var tweet = (0, exports.tweetResultsConverter)(args.result);
|
|
87
|
-
if (tweet ==
|
|
88
|
+
if (tweet == undefined)
|
|
88
89
|
return undefined;
|
|
89
|
-
var
|
|
90
|
-
|
|
90
|
+
var result = (_a = tweet.core) === null || _a === void 0 ? void 0 : _a.userResults.result;
|
|
91
|
+
var user = result && (0, exports.userOrNullConverter)(result);
|
|
92
|
+
if (user == undefined)
|
|
91
93
|
return undefined;
|
|
92
94
|
var quoted = tweet.quotedStatusResult;
|
|
93
|
-
var retweeted = tweet.legacy.retweetedStatusResult;
|
|
94
|
-
var reply = (
|
|
95
|
+
var retweeted = (_b = tweet.legacy) === null || _b === void 0 ? void 0 : _b.retweetedStatusResult;
|
|
96
|
+
var reply = (_d = (_c = args.reply) === null || _c === void 0 ? void 0 : _c.map(function (e) { return (0, exports.buildTweetApiUtils)({ result: e.tweetResults, promotedMetadata: e.promotedMetadata }); }).filter(function (e) { return e != undefined; })) !== null && _d !== void 0 ? _d : [];
|
|
95
97
|
return {
|
|
96
98
|
raw: args.result,
|
|
97
99
|
promotedMetadata: args.promotedMetadata,
|
|
@@ -104,6 +106,8 @@ var buildTweetApiUtils = function (args) {
|
|
|
104
106
|
};
|
|
105
107
|
exports.buildTweetApiUtils = buildTweetApiUtils;
|
|
106
108
|
var tweetResultsConverter = function (tweetResults) {
|
|
109
|
+
if (tweetResults.result == undefined)
|
|
110
|
+
return undefined;
|
|
107
111
|
switch (tweetResults.result.typename) {
|
|
108
112
|
case i.TypeName.Tweet:
|
|
109
113
|
return tweetResults.result;
|
|
@@ -131,21 +135,24 @@ var userEntriesConverter = function (item) {
|
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
})
|
|
134
|
-
.filter(function (e) { return e !=
|
|
138
|
+
.filter(function (e) { return e != undefined; });
|
|
135
139
|
};
|
|
136
140
|
exports.userEntriesConverter = userEntriesConverter;
|
|
141
|
+
var a = function (a) {
|
|
142
|
+
return a;
|
|
143
|
+
};
|
|
137
144
|
var userResultConverter = function (user) {
|
|
138
145
|
return user
|
|
139
146
|
.map(function (e) {
|
|
140
|
-
var user = (0, exports.userOrNullConverter)(e.result);
|
|
141
|
-
if (user ==
|
|
142
|
-
return
|
|
147
|
+
var user = e.result && (0, exports.userOrNullConverter)(e.result);
|
|
148
|
+
if (user == undefined)
|
|
149
|
+
return undefined;
|
|
143
150
|
return {
|
|
144
151
|
raw: e,
|
|
145
152
|
user: user,
|
|
146
153
|
};
|
|
147
154
|
})
|
|
148
|
-
.filter(function (e) { return e !=
|
|
155
|
+
.filter(function (e) { return e != undefined; });
|
|
149
156
|
};
|
|
150
157
|
exports.userResultConverter = userResultConverter;
|
|
151
158
|
var entriesCursor = function (item) {
|
|
@@ -161,7 +168,7 @@ var entriesCursor = function (item) {
|
|
|
161
168
|
}
|
|
162
169
|
}
|
|
163
170
|
})
|
|
164
|
-
.filter(function (e) { return e !=
|
|
171
|
+
.filter(function (e) { return e != undefined; });
|
|
165
172
|
return (0, exports.buildCursor)(cursorList);
|
|
166
173
|
};
|
|
167
174
|
exports.entriesCursor = entriesCursor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,wDAA0D;AAGnD,IAAM,SAAS,GAAG,UAAC,IAA4B,EAAE,UAAkC;IACxF,IAAM,MAAM,GAA2B,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACrE,IAAI,IAAI,CAAC,SAAS,IAAI,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,wDAA0D;AAGnD,IAAM,SA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,MAAA,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,mCAAI,CAAC,CAAC;QACtE,cAAc,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,mCAAI,CAAC,CAAC;QAC9D,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACpD,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,MAAM;QAC7D,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAE;QAC/C,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAE;QAC5D,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB"}
|
package/jest.config.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
|
2
1
|
module.exports = {
|
|
3
2
|
preset: 'ts-jest',
|
|
4
3
|
testEnvironment: 'node',
|
|
5
|
-
|
|
6
|
-
"ts-jest"
|
|
7
|
-
tsconfig: "<rootDir>/tsconfig.json",
|
|
8
|
-
},
|
|
4
|
+
transform: {
|
|
5
|
+
"^.+\\.ts$": "ts-jest",
|
|
9
6
|
},
|
|
10
7
|
moduleNameMapper: {
|
|
11
8
|
"^@/(.*)$": "<rootDir>/src/$1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twitter-openapi-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Implementation of Twitter internal API in TypeScript",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scraper"
|
|
15
15
|
],
|
|
16
16
|
"author": "fa0311",
|
|
17
|
-
"license": "AGPL-3.0-
|
|
17
|
+
"license": "custom license or AGPL-3.0-or-later",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "https://github.com/fa0311/twitter-openapi-typescript.git"
|
|
@@ -22,24 +22,24 @@
|
|
|
22
22
|
"main": "./dist/src/index.js",
|
|
23
23
|
"typings": "./dist/src/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"twitter-openapi-typescript-generated": "^0.0.
|
|
25
|
+
"twitter-openapi-typescript-generated": "^0.0.12"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/jest": "
|
|
29
|
-
"@types/node": "
|
|
30
|
-
"@types/node-fetch": "
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "
|
|
32
|
-
"@typescript-eslint/parser": "
|
|
33
|
-
"dotenv": "^16.
|
|
34
|
-
"eslint": "^8.
|
|
35
|
-
"eslint-config-standard-with-typescript": "
|
|
36
|
-
"eslint-plugin-import": "
|
|
37
|
-
"eslint-plugin-n": "
|
|
38
|
-
"eslint-plugin-promise": "
|
|
39
|
-
"jest": "^
|
|
40
|
-
"
|
|
28
|
+
"@types/jest": "any",
|
|
29
|
+
"@types/node": "any",
|
|
30
|
+
"@types/node-fetch": "any",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "any",
|
|
32
|
+
"@typescript-eslint/parser": "any",
|
|
33
|
+
"dotenv": "^16.3.0",
|
|
34
|
+
"eslint": "^8.50.0",
|
|
35
|
+
"eslint-config-standard-with-typescript": "any",
|
|
36
|
+
"eslint-plugin-import": "any",
|
|
37
|
+
"eslint-plugin-n": "any",
|
|
38
|
+
"eslint-plugin-promise": "any",
|
|
39
|
+
"jest": "^29.7.0",
|
|
40
|
+
"ts-jest": "any",
|
|
41
|
+
"log4js": "^6.9.0",
|
|
41
42
|
"node-fetch": "^2.0.0",
|
|
42
|
-
"
|
|
43
|
-
"typescript": "^5.1"
|
|
43
|
+
"typescript": "^5.2.0"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/api.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type TwitterOpenApiCookie = {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export class TwitterOpenApi {
|
|
31
|
-
static hash = '
|
|
31
|
+
static hash = '7560ee63488ec9d15f5389e64867f2413701d7dd';
|
|
32
32
|
static url = `https://raw.githubusercontent.com/fa0311/twitter-openapi/${this.hash}/src/config/placeholder.json`;
|
|
33
33
|
static twitter = 'https://twitter.com/home';
|
|
34
34
|
|
|
@@ -75,7 +75,7 @@ export class TwitterOpenApi {
|
|
|
75
75
|
|
|
76
76
|
const re = new RegExp('<script nonce="([a-zA-Z0-9]{48})">(document.cookie="(.*?)";)+<\\/script>');
|
|
77
77
|
|
|
78
|
-
const script = html.match(re)[0];
|
|
78
|
+
const script = html.match(re)![0];
|
|
79
79
|
script
|
|
80
80
|
.split('document.cookie="')
|
|
81
81
|
.slice(1)
|
package/src/apis/defaultApi.ts
CHANGED
|
@@ -51,7 +51,9 @@ export class DefaultApiUtils {
|
|
|
51
51
|
return response;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
async getTweetResultByRestId(
|
|
54
|
+
async getTweetResultByRestId(
|
|
55
|
+
param: TweetResultByRestIdParam,
|
|
56
|
+
): Promise<TwitterApiUtilsResponse<TweetApiUtilsData | undefined>> {
|
|
55
57
|
const args = {
|
|
56
58
|
tweetId: param.tweetId,
|
|
57
59
|
...param.extraParam,
|
package/src/apis/postApi.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { error } from 'console';
|
|
|
6
6
|
|
|
7
7
|
type PostCreateTweetParam = {
|
|
8
8
|
tweetText: string;
|
|
9
|
+
media_ids?: string[];
|
|
9
10
|
extraParam?: { [key: string]: any };
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -48,9 +49,16 @@ export class PostApiUtils {
|
|
|
48
49
|
tweetText: param.tweetText,
|
|
49
50
|
...param.extraParam,
|
|
50
51
|
};
|
|
52
|
+
|
|
51
53
|
const queryId = 'CreateTweet';
|
|
52
54
|
const features = i.PostCreateTweetRequestFeaturesFromJSON(this.flag[queryId]['features']);
|
|
53
55
|
const variables = i.PostCreateTweetRequestVariablesFromJSON(this.flag[queryId]['variables']);
|
|
56
|
+
variables.media.mediaEntities =
|
|
57
|
+
param.media_ids?.map((mediaId) => ({
|
|
58
|
+
mediaId: mediaId,
|
|
59
|
+
taggedUsers: [],
|
|
60
|
+
})) ?? [];
|
|
61
|
+
|
|
54
62
|
const response = await this.api.postCreateTweetRaw({
|
|
55
63
|
pathQueryId: this.flag[queryId]['queryId'],
|
|
56
64
|
postCreateTweetRequest: {
|
package/src/apis/tweetApi.ts
CHANGED
|
@@ -113,8 +113,8 @@ export class TweetApiUtils {
|
|
|
113
113
|
async getTweetDetail(param: GetTweetDetailParam): Promise<ResponseType> {
|
|
114
114
|
const args = {
|
|
115
115
|
focalTweetId: param.focalTweetId,
|
|
116
|
-
...(param.cursor ==
|
|
117
|
-
...(param.controllerData ==
|
|
116
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
117
|
+
...(param.controllerData == undefined ? {} : { controller_data: param.controllerData }),
|
|
118
118
|
...param.extraParam,
|
|
119
119
|
};
|
|
120
120
|
|
|
@@ -129,9 +129,9 @@ export class TweetApiUtils {
|
|
|
129
129
|
async getSearchTimeline(param: GetSearchTimelineParam): Promise<ResponseType> {
|
|
130
130
|
const args = {
|
|
131
131
|
rawQuery: param.rawQuery,
|
|
132
|
-
...(param.product ==
|
|
133
|
-
...(param.cursor ==
|
|
134
|
-
...(param.count ==
|
|
132
|
+
...(param.product == undefined ? {} : { product: param.product }),
|
|
133
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
134
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
135
135
|
...param.extraParam,
|
|
136
136
|
};
|
|
137
137
|
|
|
@@ -146,8 +146,8 @@ export class TweetApiUtils {
|
|
|
146
146
|
|
|
147
147
|
async getHomeTimeline(param: GetHomeTimelineParam = {}): Promise<ResponseType> {
|
|
148
148
|
const args = {
|
|
149
|
-
...(param.count ==
|
|
150
|
-
...(param.couser ==
|
|
149
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
150
|
+
...(param.couser == undefined ? {} : { couser: param.couser }),
|
|
151
151
|
...param.extraParam,
|
|
152
152
|
};
|
|
153
153
|
|
|
@@ -162,8 +162,8 @@ export class TweetApiUtils {
|
|
|
162
162
|
|
|
163
163
|
async getHomeLatestTimeline(param: GetHomeLatestTimelineParam = {}): Promise<ResponseType> {
|
|
164
164
|
const args = {
|
|
165
|
-
...(param.count ==
|
|
166
|
-
...(param.cursor ==
|
|
165
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
166
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
167
167
|
...param.extraParam,
|
|
168
168
|
};
|
|
169
169
|
|
|
@@ -179,14 +179,14 @@ export class TweetApiUtils {
|
|
|
179
179
|
async getListLatestTweetsTimeline(param: GetListLatestTweetsTimelineParam): Promise<ResponseType> {
|
|
180
180
|
const args = {
|
|
181
181
|
listId: param.listId,
|
|
182
|
-
...(param.count ==
|
|
183
|
-
...(param.cursor ==
|
|
182
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
183
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
184
184
|
...param.extraParam,
|
|
185
185
|
};
|
|
186
186
|
|
|
187
187
|
const response = await this.request({
|
|
188
188
|
apiFn: this.api.getListLatestTweetsTimelineRaw,
|
|
189
|
-
convertFn: (e) => e.data.list.tweetsTimeline.timeline
|
|
189
|
+
convertFn: (e) => e.data.list.tweetsTimeline.timeline?.instructions ?? [],
|
|
190
190
|
key: 'ListLatestTweetsTimeline',
|
|
191
191
|
param: args,
|
|
192
192
|
});
|
|
@@ -196,8 +196,8 @@ export class TweetApiUtils {
|
|
|
196
196
|
async getUserTweets(param: GetUserTweetsParam): Promise<ResponseType> {
|
|
197
197
|
const args = {
|
|
198
198
|
userId: param.userId,
|
|
199
|
-
...(param.count ==
|
|
200
|
-
...(param.cursor ==
|
|
199
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
200
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
201
201
|
...param.extraParam,
|
|
202
202
|
};
|
|
203
203
|
|
|
@@ -213,8 +213,8 @@ export class TweetApiUtils {
|
|
|
213
213
|
async getUserTweetsAndReplies(param: GetUserTweetsAndRepliesParam): Promise<ResponseType> {
|
|
214
214
|
const args = {
|
|
215
215
|
userId: param.userId,
|
|
216
|
-
...(param.count ==
|
|
217
|
-
...(param.cursor ==
|
|
216
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
217
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
218
218
|
...param.extraParam,
|
|
219
219
|
};
|
|
220
220
|
|
|
@@ -230,8 +230,8 @@ export class TweetApiUtils {
|
|
|
230
230
|
async getUserMedia(param: GetUserMediaParam): Promise<ResponseType> {
|
|
231
231
|
const args = {
|
|
232
232
|
userId: param.userId,
|
|
233
|
-
...(param.count ==
|
|
234
|
-
...(param.cursor ==
|
|
233
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
234
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
235
235
|
...param.extraParam,
|
|
236
236
|
};
|
|
237
237
|
|
|
@@ -246,8 +246,8 @@ export class TweetApiUtils {
|
|
|
246
246
|
async getLikes(param: GetLikesParam): Promise<ResponseType> {
|
|
247
247
|
const args = {
|
|
248
248
|
userId: param.userId,
|
|
249
|
-
...(param.count ==
|
|
250
|
-
...(param.cursor ==
|
|
249
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
250
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
251
251
|
...param.extraParam,
|
|
252
252
|
};
|
|
253
253
|
|
|
@@ -261,8 +261,8 @@ export class TweetApiUtils {
|
|
|
261
261
|
}
|
|
262
262
|
async getBookmarks(param: GetBookmarksParam = {}): Promise<ResponseType> {
|
|
263
263
|
const args = {
|
|
264
|
-
...(param.count ==
|
|
265
|
-
...(param.cursor ==
|
|
264
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
265
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
266
266
|
...param.extraParam,
|
|
267
267
|
};
|
|
268
268
|
|
package/src/apis/userApi.ts
CHANGED
|
@@ -29,7 +29,7 @@ export class UserApiUtils {
|
|
|
29
29
|
const response = await apiFn(args);
|
|
30
30
|
const checked = errorCheck(await response.value());
|
|
31
31
|
const result = param.convertFn(checked);
|
|
32
|
-
const user = userOrNullConverter(result.result);
|
|
32
|
+
const user = result.result && userOrNullConverter(result.result);
|
|
33
33
|
|
|
34
34
|
return {
|
|
35
35
|
raw: { response: response.raw },
|
package/src/apis/userListApi.ts
CHANGED
|
@@ -93,8 +93,8 @@ export class UserListApiUtils {
|
|
|
93
93
|
async getFollowers(param: GetFollowersParam): Promise<ResponseType> {
|
|
94
94
|
const args = {
|
|
95
95
|
userId: param.userId,
|
|
96
|
-
...(param.cursor ==
|
|
97
|
-
...(param.count ==
|
|
96
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
97
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
98
98
|
...param.extraParam,
|
|
99
99
|
};
|
|
100
100
|
const response = await this.request({
|
|
@@ -108,8 +108,8 @@ export class UserListApiUtils {
|
|
|
108
108
|
async getFollowing(param: GetFollowingParam): Promise<ResponseType> {
|
|
109
109
|
const args = {
|
|
110
110
|
userId: param.userId,
|
|
111
|
-
...(param.cursor ==
|
|
112
|
-
...(param.count ==
|
|
111
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
112
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
113
113
|
...param.extraParam,
|
|
114
114
|
};
|
|
115
115
|
const response = await this.request({
|
|
@@ -124,8 +124,8 @@ export class UserListApiUtils {
|
|
|
124
124
|
async getFollowersYouKnow(param: GetFollowersYouKnowParam): Promise<ResponseType> {
|
|
125
125
|
const args = {
|
|
126
126
|
userId: param.userId,
|
|
127
|
-
...(param.cursor ==
|
|
128
|
-
...(param.count ==
|
|
127
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
128
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
129
129
|
...param.extraParam,
|
|
130
130
|
};
|
|
131
131
|
const response = await this.request({
|
|
@@ -140,8 +140,8 @@ export class UserListApiUtils {
|
|
|
140
140
|
async getFavoriters(param: GetFavoritersParam): Promise<ResponseType> {
|
|
141
141
|
const args = {
|
|
142
142
|
tweetId: param.tweetId,
|
|
143
|
-
...(param.cursor ==
|
|
144
|
-
...(param.count ==
|
|
143
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
144
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
145
145
|
...param.extraParam,
|
|
146
146
|
};
|
|
147
147
|
const response = await this.request({
|
|
@@ -156,8 +156,8 @@ export class UserListApiUtils {
|
|
|
156
156
|
async getRetweeters(param: GetRetweetersParam): Promise<ResponseType> {
|
|
157
157
|
const args = {
|
|
158
158
|
tweetId: param.tweetId,
|
|
159
|
-
...(param.cursor ==
|
|
160
|
-
...(param.count ==
|
|
159
|
+
...(param.cursor == undefined ? {} : { cursor: param.cursor }),
|
|
160
|
+
...(param.count == undefined ? {} : { count: param.count }),
|
|
161
161
|
...param.extraParam,
|
|
162
162
|
};
|
|
163
163
|
const response = await this.request({
|