twitter-openapi-typescript 0.0.4 → 0.0.6
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/README.md +37 -11
- package/dist/src/api.d.ts +41 -33
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +239 -151
- package/dist/src/api.js.map +1 -1
- package/dist/src/apis/defaultApi.d.ts +17 -17
- package/dist/src/apis/defaultApi.js +106 -106
- package/dist/src/apis/index.d.ts +9 -9
- package/dist/src/apis/index.js +21 -21
- package/dist/src/apis/initialStateApi.d.ts +2 -2
- package/dist/src/apis/initialStateApi.js +9 -9
- package/dist/src/apis/postApi.d.ts +51 -51
- package/dist/src/apis/postApi.js +236 -236
- package/dist/src/apis/tweetApi.d.ts +88 -88
- package/dist/src/apis/tweetApi.js +277 -277
- package/dist/src/apis/userApi.d.ts +17 -17
- package/dist/src/apis/userApi.js +101 -101
- package/dist/src/apis/userListApi.d.ts +28 -28
- package/dist/src/apis/userListApi.js +135 -135
- package/dist/src/apis/v11GetApi.d.ts +7 -7
- package/dist/src/apis/v11GetApi.js +11 -11
- package/dist/src/apis/v11PostApi.d.ts +22 -22
- package/dist/src/apis/v11PostApi.js +93 -93
- package/dist/src/apis/v20GetApi.d.ts +7 -7
- package/dist/src/apis/v20GetApi.js +11 -11
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +20 -20
- package/dist/src/models/api.d.ts +17 -17
- package/dist/src/models/api.js +130 -130
- package/dist/src/models/index.d.ts +2 -2
- package/dist/src/models/index.js +18 -18
- package/dist/src/models/type.d.ts +15 -15
- package/dist/src/models/type.js +2 -2
- package/dist/src/types/flag.d.ts +5 -5
- package/dist/src/types/flag.js +2 -2
- package/dist/src/types/header.d.ts +14 -14
- package/dist/src/types/header.js +2 -2
- package/dist/src/types/index.d.ts +7 -7
- package/dist/src/types/index.js +23 -23
- package/dist/src/types/response.d.ts +9 -9
- package/dist/src/types/response.js +2 -2
- package/dist/src/types/timeline.d.ts +10 -10
- package/dist/src/types/timeline.js +2 -2
- package/dist/src/types/tweet.d.ts +17 -17
- package/dist/src/types/tweet.js +2 -2
- package/dist/src/types/user.d.ts +10 -10
- package/dist/src/types/user.js +2 -2
- package/dist/src/types/user_list.d.ts +12 -12
- package/dist/src/types/user_list.js +2 -2
- package/package.json +4 -4
- package/src/api.ts +91 -35
- package/test/api/defaultApi.test.ts +0 -1
- package/test/init.ts +2 -2
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.TweetApiUtils = void 0;
|
|
51
|
-
var models_1 = require("../models");
|
|
52
|
-
var TweetApiUtils = /** @class */ (function () {
|
|
53
|
-
function TweetApiUtils(api, flag) {
|
|
54
|
-
this.api = api;
|
|
55
|
-
this.flag = flag;
|
|
56
|
-
}
|
|
57
|
-
TweetApiUtils.prototype.request = function (param) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var apiFn, response, instruction, _a, _b, entry, data, raw;
|
|
60
|
-
return __generator(this, function (_c) {
|
|
61
|
-
switch (_c.label) {
|
|
62
|
-
case 0:
|
|
63
|
-
apiFn = param.apiFn.bind(this.api);
|
|
64
|
-
return [4 /*yield*/, apiFn({
|
|
65
|
-
queryId: this.flag[param.key]['queryId'],
|
|
66
|
-
variables: JSON.stringify(__assign(__assign({}, this.flag[param.key]['variables']), param)),
|
|
67
|
-
features: JSON.stringify(this.flag[param.key]['features']),
|
|
68
|
-
})];
|
|
69
|
-
case 1:
|
|
70
|
-
response = _c.sent();
|
|
71
|
-
_b = (_a = param).convertFn;
|
|
72
|
-
return [4 /*yield*/, response.value()];
|
|
73
|
-
case 2:
|
|
74
|
-
instruction = _b.apply(_a, [_c.sent()]);
|
|
75
|
-
entry = (0, models_1.instructionToEntry)(instruction);
|
|
76
|
-
data = (0, models_1.tweetEntriesConverter)(entry);
|
|
77
|
-
raw = {
|
|
78
|
-
response: response.raw,
|
|
79
|
-
instruction: instruction,
|
|
80
|
-
entry: entry,
|
|
81
|
-
};
|
|
82
|
-
return [2 /*return*/, {
|
|
83
|
-
raw: raw,
|
|
84
|
-
header: (0, models_1.buildHeader)(response.raw.headers),
|
|
85
|
-
cursor: (0, models_1.entriesCursor)(entry),
|
|
86
|
-
data: data,
|
|
87
|
-
}];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
TweetApiUtils.prototype.getTweetDetail = function (param) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
-
var args, response;
|
|
95
|
-
return __generator(this, function (_a) {
|
|
96
|
-
switch (_a.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
args = __assign(__assign(__assign({ focalTweetId: param.focalTweetId }, (param.cursor == null ? {} : { cursor: param.cursor })), (param.controllerData == null ? {} : { controller_data: param.controllerData })), param.extraParam);
|
|
99
|
-
return [4 /*yield*/, this.request({
|
|
100
|
-
apiFn: this.api.getTweetDetailRaw,
|
|
101
|
-
convertFn: function (e) { return e.data.threadedConversationWithInjectionsV2.instructions; },
|
|
102
|
-
key: 'TweetDetail',
|
|
103
|
-
param: args,
|
|
104
|
-
})];
|
|
105
|
-
case 1:
|
|
106
|
-
response = _a.sent();
|
|
107
|
-
return [2 /*return*/, response];
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
TweetApiUtils.prototype.getHomeTimeline = function (param) {
|
|
113
|
-
if (param === void 0) { param = {}; }
|
|
114
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
-
var args, response;
|
|
116
|
-
return __generator(this, function (_a) {
|
|
117
|
-
switch (_a.label) {
|
|
118
|
-
case 0:
|
|
119
|
-
args = __assign(__assign(__assign({}, (param.count == null ? {} : { count: param.count })), (param.couser == null ? {} : { couser: param.couser })), param.extraParam);
|
|
120
|
-
return [4 /*yield*/, this.request({
|
|
121
|
-
apiFn: this.api.getHomeTimelineRaw,
|
|
122
|
-
convertFn: function (e) { return e.data.home.homeTimelineUrt.instructions; },
|
|
123
|
-
key: 'HomeTimeline',
|
|
124
|
-
param: args,
|
|
125
|
-
})];
|
|
126
|
-
case 1:
|
|
127
|
-
response = _a.sent();
|
|
128
|
-
return [2 /*return*/, response];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
TweetApiUtils.prototype.getHomeLatestTimeline = function (param) {
|
|
134
|
-
if (param === void 0) { param = {}; }
|
|
135
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
-
var args, response;
|
|
137
|
-
return __generator(this, function (_a) {
|
|
138
|
-
switch (_a.label) {
|
|
139
|
-
case 0:
|
|
140
|
-
args = __assign(__assign(__assign({}, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
141
|
-
return [4 /*yield*/, this.request({
|
|
142
|
-
apiFn: this.api.getHomeLatestTimelineRaw,
|
|
143
|
-
convertFn: function (e) { return e.data.home.homeTimelineUrt.instructions; },
|
|
144
|
-
key: 'HomeLatestTimeline',
|
|
145
|
-
param: args,
|
|
146
|
-
})];
|
|
147
|
-
case 1:
|
|
148
|
-
response = _a.sent();
|
|
149
|
-
return [2 /*return*/, response];
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
TweetApiUtils.prototype.getListLatestTweetsTimeline = function (param) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
-
var args, response;
|
|
157
|
-
return __generator(this, function (_a) {
|
|
158
|
-
switch (_a.label) {
|
|
159
|
-
case 0:
|
|
160
|
-
args = __assign(__assign(__assign({ listId: param.listId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
161
|
-
return [4 /*yield*/, this.request({
|
|
162
|
-
apiFn: this.api.getListLatestTweetsTimelineRaw,
|
|
163
|
-
convertFn: function (e) { return e.data.list.tweetsTimeline.timeline.instructions; },
|
|
164
|
-
key: 'ListLatestTweetsTimeline',
|
|
165
|
-
param: args,
|
|
166
|
-
})];
|
|
167
|
-
case 1:
|
|
168
|
-
response = _a.sent();
|
|
169
|
-
return [2 /*return*/, response];
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
TweetApiUtils.prototype.getUserTweets = function (param) {
|
|
175
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
-
var args, response;
|
|
177
|
-
return __generator(this, function (_a) {
|
|
178
|
-
switch (_a.label) {
|
|
179
|
-
case 0:
|
|
180
|
-
args = __assign(__assign(__assign({ userId: param.userId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
181
|
-
return [4 /*yield*/, this.request({
|
|
182
|
-
apiFn: this.api.getUserTweetsRaw,
|
|
183
|
-
convertFn: function (e) { return e.data.user.result.timelineV2.timeline.instructions; },
|
|
184
|
-
key: 'UserTweets',
|
|
185
|
-
param: args,
|
|
186
|
-
})];
|
|
187
|
-
case 1:
|
|
188
|
-
response = _a.sent();
|
|
189
|
-
return [2 /*return*/, response];
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
TweetApiUtils.prototype.getUserTweetsAndReplies = function (param) {
|
|
195
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
196
|
-
var args, response;
|
|
197
|
-
return __generator(this, function (_a) {
|
|
198
|
-
switch (_a.label) {
|
|
199
|
-
case 0:
|
|
200
|
-
args = __assign(__assign(__assign({ userId: param.userId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
201
|
-
return [4 /*yield*/, this.request({
|
|
202
|
-
apiFn: this.api.getUserTweetsAndRepliesRaw,
|
|
203
|
-
convertFn: function (e) { return e.data.user.result.timelineV2.timeline.instructions; },
|
|
204
|
-
key: 'UserTweetsAndReplies',
|
|
205
|
-
param: args,
|
|
206
|
-
})];
|
|
207
|
-
case 1:
|
|
208
|
-
response = _a.sent();
|
|
209
|
-
return [2 /*return*/, response];
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
TweetApiUtils.prototype.getUserMedia = function (param) {
|
|
215
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
216
|
-
var args, response;
|
|
217
|
-
return __generator(this, function (_a) {
|
|
218
|
-
switch (_a.label) {
|
|
219
|
-
case 0:
|
|
220
|
-
args = __assign(__assign(__assign({ userId: param.userId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
221
|
-
return [4 /*yield*/, this.request({
|
|
222
|
-
apiFn: this.api.getUserMediaRaw,
|
|
223
|
-
convertFn: function (e) { return e.data.user.result.timelineV2.timeline.instructions; },
|
|
224
|
-
key: 'UserMedia',
|
|
225
|
-
param: args,
|
|
226
|
-
})];
|
|
227
|
-
case 1:
|
|
228
|
-
response = _a.sent();
|
|
229
|
-
return [2 /*return*/, response];
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
TweetApiUtils.prototype.getLikes = function (param) {
|
|
235
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
236
|
-
var args, response;
|
|
237
|
-
return __generator(this, function (_a) {
|
|
238
|
-
switch (_a.label) {
|
|
239
|
-
case 0:
|
|
240
|
-
args = __assign(__assign(__assign({ userId: param.userId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
241
|
-
return [4 /*yield*/, this.request({
|
|
242
|
-
apiFn: this.api.getLikesRaw,
|
|
243
|
-
convertFn: function (e) { return e.data.user.result.timelineV2.timeline.instructions; },
|
|
244
|
-
key: 'Likes',
|
|
245
|
-
param: args,
|
|
246
|
-
})];
|
|
247
|
-
case 1:
|
|
248
|
-
response = _a.sent();
|
|
249
|
-
return [2 /*return*/, response];
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
TweetApiUtils.prototype.getBookmarks = function (param) {
|
|
255
|
-
if (param === void 0) { param = {}; }
|
|
256
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
-
var args, response;
|
|
258
|
-
return __generator(this, function (_a) {
|
|
259
|
-
switch (_a.label) {
|
|
260
|
-
case 0:
|
|
261
|
-
args = __assign(__assign(__assign({}, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
262
|
-
return [4 /*yield*/, this.request({
|
|
263
|
-
apiFn: this.api.getBookmarksRaw,
|
|
264
|
-
convertFn: function (e) { return e.data.bookmarkTimelineV2.timeline.instructions; },
|
|
265
|
-
key: 'Bookmarks',
|
|
266
|
-
param: args,
|
|
267
|
-
})];
|
|
268
|
-
case 1:
|
|
269
|
-
response = _a.sent();
|
|
270
|
-
return [2 /*return*/, response];
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
return TweetApiUtils;
|
|
276
|
-
}());
|
|
277
|
-
exports.TweetApiUtils = TweetApiUtils;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.TweetApiUtils = void 0;
|
|
51
|
+
var models_1 = require("../models");
|
|
52
|
+
var TweetApiUtils = /** @class */ (function () {
|
|
53
|
+
function TweetApiUtils(api, flag) {
|
|
54
|
+
this.api = api;
|
|
55
|
+
this.flag = flag;
|
|
56
|
+
}
|
|
57
|
+
TweetApiUtils.prototype.request = function (param) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var apiFn, response, instruction, _a, _b, entry, data, raw;
|
|
60
|
+
return __generator(this, function (_c) {
|
|
61
|
+
switch (_c.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
apiFn = param.apiFn.bind(this.api);
|
|
64
|
+
return [4 /*yield*/, apiFn({
|
|
65
|
+
queryId: this.flag[param.key]['queryId'],
|
|
66
|
+
variables: JSON.stringify(__assign(__assign({}, this.flag[param.key]['variables']), param)),
|
|
67
|
+
features: JSON.stringify(this.flag[param.key]['features']),
|
|
68
|
+
})];
|
|
69
|
+
case 1:
|
|
70
|
+
response = _c.sent();
|
|
71
|
+
_b = (_a = param).convertFn;
|
|
72
|
+
return [4 /*yield*/, response.value()];
|
|
73
|
+
case 2:
|
|
74
|
+
instruction = _b.apply(_a, [_c.sent()]);
|
|
75
|
+
entry = (0, models_1.instructionToEntry)(instruction);
|
|
76
|
+
data = (0, models_1.tweetEntriesConverter)(entry);
|
|
77
|
+
raw = {
|
|
78
|
+
response: response.raw,
|
|
79
|
+
instruction: instruction,
|
|
80
|
+
entry: entry,
|
|
81
|
+
};
|
|
82
|
+
return [2 /*return*/, {
|
|
83
|
+
raw: raw,
|
|
84
|
+
header: (0, models_1.buildHeader)(response.raw.headers),
|
|
85
|
+
cursor: (0, models_1.entriesCursor)(entry),
|
|
86
|
+
data: data,
|
|
87
|
+
}];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
TweetApiUtils.prototype.getTweetDetail = function (param) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
var args, response;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
args = __assign(__assign(__assign({ focalTweetId: param.focalTweetId }, (param.cursor == null ? {} : { cursor: param.cursor })), (param.controllerData == null ? {} : { controller_data: param.controllerData })), param.extraParam);
|
|
99
|
+
return [4 /*yield*/, this.request({
|
|
100
|
+
apiFn: this.api.getTweetDetailRaw,
|
|
101
|
+
convertFn: function (e) { return e.data.threadedConversationWithInjectionsV2.instructions; },
|
|
102
|
+
key: 'TweetDetail',
|
|
103
|
+
param: args,
|
|
104
|
+
})];
|
|
105
|
+
case 1:
|
|
106
|
+
response = _a.sent();
|
|
107
|
+
return [2 /*return*/, response];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
TweetApiUtils.prototype.getHomeTimeline = function (param) {
|
|
113
|
+
if (param === void 0) { param = {}; }
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
var args, response;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
args = __assign(__assign(__assign({}, (param.count == null ? {} : { count: param.count })), (param.couser == null ? {} : { couser: param.couser })), param.extraParam);
|
|
120
|
+
return [4 /*yield*/, this.request({
|
|
121
|
+
apiFn: this.api.getHomeTimelineRaw,
|
|
122
|
+
convertFn: function (e) { return e.data.home.homeTimelineUrt.instructions; },
|
|
123
|
+
key: 'HomeTimeline',
|
|
124
|
+
param: args,
|
|
125
|
+
})];
|
|
126
|
+
case 1:
|
|
127
|
+
response = _a.sent();
|
|
128
|
+
return [2 /*return*/, response];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
TweetApiUtils.prototype.getHomeLatestTimeline = function (param) {
|
|
134
|
+
if (param === void 0) { param = {}; }
|
|
135
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
var args, response;
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
args = __assign(__assign(__assign({}, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
141
|
+
return [4 /*yield*/, this.request({
|
|
142
|
+
apiFn: this.api.getHomeLatestTimelineRaw,
|
|
143
|
+
convertFn: function (e) { return e.data.home.homeTimelineUrt.instructions; },
|
|
144
|
+
key: 'HomeLatestTimeline',
|
|
145
|
+
param: args,
|
|
146
|
+
})];
|
|
147
|
+
case 1:
|
|
148
|
+
response = _a.sent();
|
|
149
|
+
return [2 /*return*/, response];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
TweetApiUtils.prototype.getListLatestTweetsTimeline = function (param) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
var args, response;
|
|
157
|
+
return __generator(this, function (_a) {
|
|
158
|
+
switch (_a.label) {
|
|
159
|
+
case 0:
|
|
160
|
+
args = __assign(__assign(__assign({ listId: param.listId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
161
|
+
return [4 /*yield*/, this.request({
|
|
162
|
+
apiFn: this.api.getListLatestTweetsTimelineRaw,
|
|
163
|
+
convertFn: function (e) { return e.data.list.tweetsTimeline.timeline.instructions; },
|
|
164
|
+
key: 'ListLatestTweetsTimeline',
|
|
165
|
+
param: args,
|
|
166
|
+
})];
|
|
167
|
+
case 1:
|
|
168
|
+
response = _a.sent();
|
|
169
|
+
return [2 /*return*/, response];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
TweetApiUtils.prototype.getUserTweets = function (param) {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
var args, response;
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
switch (_a.label) {
|
|
179
|
+
case 0:
|
|
180
|
+
args = __assign(__assign(__assign({ userId: param.userId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
181
|
+
return [4 /*yield*/, this.request({
|
|
182
|
+
apiFn: this.api.getUserTweetsRaw,
|
|
183
|
+
convertFn: function (e) { return e.data.user.result.timelineV2.timeline.instructions; },
|
|
184
|
+
key: 'UserTweets',
|
|
185
|
+
param: args,
|
|
186
|
+
})];
|
|
187
|
+
case 1:
|
|
188
|
+
response = _a.sent();
|
|
189
|
+
return [2 /*return*/, response];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
TweetApiUtils.prototype.getUserTweetsAndReplies = function (param) {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
196
|
+
var args, response;
|
|
197
|
+
return __generator(this, function (_a) {
|
|
198
|
+
switch (_a.label) {
|
|
199
|
+
case 0:
|
|
200
|
+
args = __assign(__assign(__assign({ userId: param.userId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
201
|
+
return [4 /*yield*/, this.request({
|
|
202
|
+
apiFn: this.api.getUserTweetsAndRepliesRaw,
|
|
203
|
+
convertFn: function (e) { return e.data.user.result.timelineV2.timeline.instructions; },
|
|
204
|
+
key: 'UserTweetsAndReplies',
|
|
205
|
+
param: args,
|
|
206
|
+
})];
|
|
207
|
+
case 1:
|
|
208
|
+
response = _a.sent();
|
|
209
|
+
return [2 /*return*/, response];
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
TweetApiUtils.prototype.getUserMedia = function (param) {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
216
|
+
var args, response;
|
|
217
|
+
return __generator(this, function (_a) {
|
|
218
|
+
switch (_a.label) {
|
|
219
|
+
case 0:
|
|
220
|
+
args = __assign(__assign(__assign({ userId: param.userId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
221
|
+
return [4 /*yield*/, this.request({
|
|
222
|
+
apiFn: this.api.getUserMediaRaw,
|
|
223
|
+
convertFn: function (e) { return e.data.user.result.timelineV2.timeline.instructions; },
|
|
224
|
+
key: 'UserMedia',
|
|
225
|
+
param: args,
|
|
226
|
+
})];
|
|
227
|
+
case 1:
|
|
228
|
+
response = _a.sent();
|
|
229
|
+
return [2 /*return*/, response];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
TweetApiUtils.prototype.getLikes = function (param) {
|
|
235
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
236
|
+
var args, response;
|
|
237
|
+
return __generator(this, function (_a) {
|
|
238
|
+
switch (_a.label) {
|
|
239
|
+
case 0:
|
|
240
|
+
args = __assign(__assign(__assign({ userId: param.userId }, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
241
|
+
return [4 /*yield*/, this.request({
|
|
242
|
+
apiFn: this.api.getLikesRaw,
|
|
243
|
+
convertFn: function (e) { return e.data.user.result.timelineV2.timeline.instructions; },
|
|
244
|
+
key: 'Likes',
|
|
245
|
+
param: args,
|
|
246
|
+
})];
|
|
247
|
+
case 1:
|
|
248
|
+
response = _a.sent();
|
|
249
|
+
return [2 /*return*/, response];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
TweetApiUtils.prototype.getBookmarks = function (param) {
|
|
255
|
+
if (param === void 0) { param = {}; }
|
|
256
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
+
var args, response;
|
|
258
|
+
return __generator(this, function (_a) {
|
|
259
|
+
switch (_a.label) {
|
|
260
|
+
case 0:
|
|
261
|
+
args = __assign(__assign(__assign({}, (param.count == null ? {} : { count: param.count })), (param.cursor == null ? {} : { cursor: param.cursor })), param.extraParam);
|
|
262
|
+
return [4 /*yield*/, this.request({
|
|
263
|
+
apiFn: this.api.getBookmarksRaw,
|
|
264
|
+
convertFn: function (e) { return e.data.bookmarkTimelineV2.timeline.instructions; },
|
|
265
|
+
key: 'Bookmarks',
|
|
266
|
+
param: args,
|
|
267
|
+
})];
|
|
268
|
+
case 1:
|
|
269
|
+
response = _a.sent();
|
|
270
|
+
return [2 /*return*/, response];
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
return TweetApiUtils;
|
|
276
|
+
}());
|
|
277
|
+
exports.TweetApiUtils = TweetApiUtils;
|
|
278
278
|
//# sourceMappingURL=tweetApi.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as i from 'twitter-openapi-typescript-generated';
|
|
2
|
-
import { DefaultFlag, UserApiUtilsResponse } from '../types';
|
|
3
|
-
import { RequestParam } from '../models';
|
|
4
|
-
type getUserByScreenNameParam = {
|
|
5
|
-
screenName: string;
|
|
6
|
-
extraParam?: {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare class UserApiUtils {
|
|
11
|
-
api: i.UserApi;
|
|
12
|
-
flag: DefaultFlag;
|
|
13
|
-
constructor(api: i.UserApi, flag: DefaultFlag);
|
|
14
|
-
request<T>(param: RequestParam<i.UserResults, T>): Promise<UserApiUtilsResponse>;
|
|
15
|
-
getUserByScreenName(param: getUserByScreenNameParam): Promise<UserApiUtilsResponse>;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
1
|
+
import * as i from 'twitter-openapi-typescript-generated';
|
|
2
|
+
import { DefaultFlag, UserApiUtilsResponse } from '../types';
|
|
3
|
+
import { RequestParam } from '../models';
|
|
4
|
+
type getUserByScreenNameParam = {
|
|
5
|
+
screenName: string;
|
|
6
|
+
extraParam?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare class UserApiUtils {
|
|
11
|
+
api: i.UserApi;
|
|
12
|
+
flag: DefaultFlag;
|
|
13
|
+
constructor(api: i.UserApi, flag: DefaultFlag);
|
|
14
|
+
request<T>(param: RequestParam<i.UserResults, T>): Promise<UserApiUtilsResponse>;
|
|
15
|
+
getUserByScreenName(param: getUserByScreenNameParam): Promise<UserApiUtilsResponse>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
18
|
//# sourceMappingURL=userApi.d.ts.map
|