twitter-openapi-typescript 0.0.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/.prettierrc +8 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/settings.json +5 -0
- package/dist/src/api.d.ts +30 -0
- package/dist/src/api.js +145 -0
- package/dist/src/apis/defaultApi.d.ts +17 -0
- package/dist/src/apis/defaultApi.js +106 -0
- package/dist/src/apis/index.d.ts +9 -0
- package/dist/src/apis/index.js +21 -0
- package/dist/src/apis/initialStateApi.d.ts +2 -0
- package/dist/src/apis/initialStateApi.js +9 -0
- package/dist/src/apis/postApi.d.ts +51 -0
- package/dist/src/apis/postApi.js +236 -0
- package/dist/src/apis/tweetApi.d.ts +88 -0
- package/dist/src/apis/tweetApi.js +277 -0
- package/dist/src/apis/userApi.d.ts +17 -0
- package/dist/src/apis/userApi.js +101 -0
- package/dist/src/apis/userListApi.d.ts +28 -0
- package/dist/src/apis/userListApi.js +135 -0
- package/dist/src/apis/v11GetApi.d.ts +7 -0
- package/dist/src/apis/v11GetApi.js +11 -0
- package/dist/src/apis/v11PostApi.d.ts +22 -0
- package/dist/src/apis/v11PostApi.js +93 -0
- package/dist/src/apis/v20GetApi.d.ts +7 -0
- package/dist/src/apis/v20GetApi.js +11 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +20 -0
- package/dist/src/models/api.d.ts +17 -0
- package/dist/src/models/api.js +130 -0
- package/dist/src/models/index.d.ts +2 -0
- package/dist/src/models/index.js +18 -0
- package/dist/src/models/type.d.ts +15 -0
- package/dist/src/models/type.js +2 -0
- package/dist/src/types/flag.d.ts +5 -0
- package/dist/src/types/flag.js +2 -0
- package/dist/src/types/header.d.ts +14 -0
- package/dist/src/types/header.js +2 -0
- package/dist/src/types/index.d.ts +7 -0
- package/dist/src/types/index.js +23 -0
- package/dist/src/types/response.d.ts +9 -0
- package/dist/src/types/response.js +2 -0
- package/dist/src/types/timeline.d.ts +10 -0
- package/dist/src/types/timeline.js +2 -0
- package/dist/src/types/tweet.d.ts +17 -0
- package/dist/src/types/tweet.js +2 -0
- package/dist/src/types/user.d.ts +10 -0
- package/dist/src/types/user.js +2 -0
- package/dist/src/types/user_list.d.ts +12 -0
- package/dist/src/types/user_list.js +2 -0
- package/jest.config.js +14 -0
- package/package.json +44 -0
- package/src/api.ts +118 -0
- package/src/apis/defaultApi.ts +51 -0
- package/src/apis/index.ts +9 -0
- package/src/apis/initialStateApi.ts +3 -0
- package/src/apis/postApi.ts +169 -0
- package/src/apis/tweetApi.ts +244 -0
- package/src/apis/userApi.ts +47 -0
- package/src/apis/userListApi.ts +90 -0
- package/src/apis/v11GetApi.ts +12 -0
- package/src/apis/v11PostApi.ts +73 -0
- package/src/apis/v20GetApi.ts +12 -0
- package/src/index.ts +4 -0
- package/src/models/api.ts +129 -0
- package/src/models/index.ts +2 -0
- package/src/models/type.ts +16 -0
- package/src/types/flag.ts +5 -0
- package/src/types/header.ts +14 -0
- package/src/types/index.ts +7 -0
- package/src/types/response.ts +11 -0
- package/src/types/timeline.ts +12 -0
- package/src/types/tweet.ts +19 -0
- package/src/types/user.ts +12 -0
- package/src/types/user_list.ts +14 -0
- package/test/api/defaultApi.test.ts +13 -0
- package/test/api/postApi.test.ts +50 -0
- package/test/api/tweetApi.test.ts +74 -0
- package/test/api/userApi.test.ts +13 -0
- package/test/api/userListApi.test.ts +18 -0
- package/test/api/v11PostApi.test.ts +13 -0
- package/test/init.ts +39 -0
- package/test/raw/tweet_api.test.ts +12 -0
- package/test/util.ts +18 -0
- package/tsconfig.build.json +22 -0
- package/tsconfig.json +22 -0
package/.prettierrc
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as i from 'twitter-openapi-typescript-generated';
|
|
2
|
+
import { DefaultApiUtils, InitialStateApiUtils, PostApiUtils, TweetApiUtils, UserApiUtils, UserListApiUtils, V11GetApiUtils, V11PostApiUtils, V20GetApiUtils } from './apis';
|
|
3
|
+
import { DefaultFlag } from './types/flag';
|
|
4
|
+
type TwitterOpenApiParams = {
|
|
5
|
+
lang?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class TwitterOpenApi {
|
|
8
|
+
static hash: string;
|
|
9
|
+
static url: string;
|
|
10
|
+
static userAgent: string;
|
|
11
|
+
static bearer: string;
|
|
12
|
+
param: TwitterOpenApiParams;
|
|
13
|
+
constructor(param?: TwitterOpenApiParams);
|
|
14
|
+
getClientFromCookies(ct0: string, authToken: string): Promise<TwitterOpenApiClient>;
|
|
15
|
+
}
|
|
16
|
+
export declare class TwitterOpenApiClient {
|
|
17
|
+
private config;
|
|
18
|
+
flag: DefaultFlag;
|
|
19
|
+
constructor(config: i.Configuration, flag: DefaultFlag);
|
|
20
|
+
getDefaultApi(): DefaultApiUtils;
|
|
21
|
+
getTweetApi(): TweetApiUtils;
|
|
22
|
+
getUserApi(): UserApiUtils;
|
|
23
|
+
getUserListApi(): UserListApiUtils;
|
|
24
|
+
getPostApi(): PostApiUtils;
|
|
25
|
+
getV11GetApi(): V11GetApiUtils;
|
|
26
|
+
getV11PostApi(): V11PostApiUtils;
|
|
27
|
+
getV20GetApi(): V20GetApiUtils;
|
|
28
|
+
getInitialStateApi(): InitialStateApiUtils;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
package/dist/src/api.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.TwitterOpenApiClient = exports.TwitterOpenApi = void 0;
|
|
40
|
+
var i = require("twitter-openapi-typescript-generated");
|
|
41
|
+
var apis_1 = require("./apis");
|
|
42
|
+
var TwitterOpenApi = /** @class */ (function () {
|
|
43
|
+
function TwitterOpenApi(param) {
|
|
44
|
+
if (param === void 0) { param = {}; }
|
|
45
|
+
this.param = param;
|
|
46
|
+
}
|
|
47
|
+
TwitterOpenApi.prototype.getClientFromCookies = function (ct0, authToken) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
+
var config, flag, _b, _c;
|
|
50
|
+
var _this = this;
|
|
51
|
+
return __generator(this, function (_d) {
|
|
52
|
+
switch (_d.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
config = {
|
|
55
|
+
middleware: [
|
|
56
|
+
{
|
|
57
|
+
pre: function (context) { return __awaiter(_this, void 0, void 0, function () {
|
|
58
|
+
var cookie, headers;
|
|
59
|
+
return __generator(this, function (_b) {
|
|
60
|
+
cookie = [
|
|
61
|
+
{
|
|
62
|
+
name: 'auth_token',
|
|
63
|
+
value: authToken,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'ct0',
|
|
67
|
+
value: ct0,
|
|
68
|
+
},
|
|
69
|
+
]
|
|
70
|
+
.map(function (cookie) { return "".concat(cookie.name, "=").concat(cookie.value); })
|
|
71
|
+
.join('; ');
|
|
72
|
+
if (context.init.headers) {
|
|
73
|
+
headers = context.init.headers;
|
|
74
|
+
headers['cookie'] = cookie;
|
|
75
|
+
}
|
|
76
|
+
return [2 /*return*/, context];
|
|
77
|
+
});
|
|
78
|
+
}); },
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
apiKey: function (key) {
|
|
82
|
+
var _b;
|
|
83
|
+
return {
|
|
84
|
+
'user-agent': TwitterOpenApi.userAgent,
|
|
85
|
+
'x-twitter-client-language': (_b = _this.param.lang) !== null && _b !== void 0 ? _b : 'en',
|
|
86
|
+
'x-twitter-active-user': 'yes',
|
|
87
|
+
'x-twitter-auth-type': 'OAuth2Session',
|
|
88
|
+
'x-csrf-token': ct0,
|
|
89
|
+
}[key];
|
|
90
|
+
},
|
|
91
|
+
accessToken: TwitterOpenApi.bearer,
|
|
92
|
+
};
|
|
93
|
+
flag = fetch(TwitterOpenApi.url, { method: 'GET' }).then(function (res) { return res.json(); });
|
|
94
|
+
_b = TwitterOpenApiClient.bind;
|
|
95
|
+
_c = [void 0, new i.Configuration(config)];
|
|
96
|
+
return [4 /*yield*/, flag];
|
|
97
|
+
case 1: return [2 /*return*/, new (_b.apply(TwitterOpenApiClient, _c.concat([_d.sent()])))()];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
var _a;
|
|
103
|
+
_a = TwitterOpenApi;
|
|
104
|
+
TwitterOpenApi.hash = 'd5ccc25869b68cbb39c68fa81a1fa77967a667da';
|
|
105
|
+
TwitterOpenApi.url = "https://raw.githubusercontent.com/fa0311/twitter-openapi/".concat(_a.hash, "/src/config/placeholder.json");
|
|
106
|
+
TwitterOpenApi.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36';
|
|
107
|
+
TwitterOpenApi.bearer = 'AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA';
|
|
108
|
+
return TwitterOpenApi;
|
|
109
|
+
}());
|
|
110
|
+
exports.TwitterOpenApi = TwitterOpenApi;
|
|
111
|
+
var TwitterOpenApiClient = /** @class */ (function () {
|
|
112
|
+
function TwitterOpenApiClient(config, flag) {
|
|
113
|
+
this.config = config;
|
|
114
|
+
this.flag = flag;
|
|
115
|
+
}
|
|
116
|
+
TwitterOpenApiClient.prototype.getDefaultApi = function () {
|
|
117
|
+
return new apis_1.DefaultApiUtils(new i.DefaultApi(this.config), this.flag);
|
|
118
|
+
};
|
|
119
|
+
TwitterOpenApiClient.prototype.getTweetApi = function () {
|
|
120
|
+
return new apis_1.TweetApiUtils(new i.TweetApi(this.config), this.flag);
|
|
121
|
+
};
|
|
122
|
+
TwitterOpenApiClient.prototype.getUserApi = function () {
|
|
123
|
+
return new apis_1.UserApiUtils(new i.UserApi(this.config), this.flag);
|
|
124
|
+
};
|
|
125
|
+
TwitterOpenApiClient.prototype.getUserListApi = function () {
|
|
126
|
+
return new apis_1.UserListApiUtils(new i.UserListApi(this.config), this.flag);
|
|
127
|
+
};
|
|
128
|
+
TwitterOpenApiClient.prototype.getPostApi = function () {
|
|
129
|
+
return new apis_1.PostApiUtils(new i.PostApi(this.config), this.flag);
|
|
130
|
+
};
|
|
131
|
+
TwitterOpenApiClient.prototype.getV11GetApi = function () {
|
|
132
|
+
return new apis_1.V11GetApiUtils(new i.V11GetApi(this.config), this.flag);
|
|
133
|
+
};
|
|
134
|
+
TwitterOpenApiClient.prototype.getV11PostApi = function () {
|
|
135
|
+
return new apis_1.V11PostApiUtils(new i.V11PostApi(this.config), this.flag);
|
|
136
|
+
};
|
|
137
|
+
TwitterOpenApiClient.prototype.getV20GetApi = function () {
|
|
138
|
+
return new apis_1.V20GetApiUtils(new i.V20GetApi(this.config), this.flag);
|
|
139
|
+
};
|
|
140
|
+
TwitterOpenApiClient.prototype.getInitialStateApi = function () {
|
|
141
|
+
return new apis_1.InitialStateApiUtils();
|
|
142
|
+
};
|
|
143
|
+
return TwitterOpenApiClient;
|
|
144
|
+
}());
|
|
145
|
+
exports.TwitterOpenApiClient = TwitterOpenApiClient;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as i from 'twitter-openapi-typescript-generated';
|
|
2
|
+
import { DefaultFlag } from '../types';
|
|
3
|
+
import { RequestParam } from '../models';
|
|
4
|
+
import { TwitterApiUtilsResponse } from '../types/response';
|
|
5
|
+
export type ProfileSpotlightsQueryParam = {
|
|
6
|
+
screenName: string;
|
|
7
|
+
extraParam?: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare class DefaultApiUtils {
|
|
12
|
+
api: i.DefaultApi;
|
|
13
|
+
flag: DefaultFlag;
|
|
14
|
+
constructor(api: i.DefaultApi, flag: DefaultFlag);
|
|
15
|
+
request<T1, T2>(param: RequestParam<T1, T2>): Promise<TwitterApiUtilsResponse<T1>>;
|
|
16
|
+
getProfileSpotlightsQuery(param: ProfileSpotlightsQueryParam): Promise<TwitterApiUtilsResponse<i.UserResultByScreenName>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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.DefaultApiUtils = void 0;
|
|
51
|
+
var models_1 = require("../models");
|
|
52
|
+
var DefaultApiUtils = /** @class */ (function () {
|
|
53
|
+
function DefaultApiUtils(api, flag) {
|
|
54
|
+
this.api = api;
|
|
55
|
+
this.flag = flag;
|
|
56
|
+
}
|
|
57
|
+
DefaultApiUtils.prototype.request = function (param) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var apiFn, response, data, _a, _b;
|
|
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
|
+
data = _b.apply(_a, [_c.sent()]);
|
|
75
|
+
return [2 /*return*/, {
|
|
76
|
+
raw: { response: response.raw },
|
|
77
|
+
header: (0, models_1.buildHeader)(response.raw.headers),
|
|
78
|
+
data: data,
|
|
79
|
+
}];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
DefaultApiUtils.prototype.getProfileSpotlightsQuery = function (param) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
+
var args, response;
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
args = __assign({ screenName: param.screenName }, param.extraParam);
|
|
91
|
+
return [4 /*yield*/, this.request({
|
|
92
|
+
key: 'ProfileSpotlightsQuery',
|
|
93
|
+
apiFn: this.api.getProfileSpotlightsQueryRaw,
|
|
94
|
+
convertFn: function (value) { return value.data.userResultByScreenName; },
|
|
95
|
+
param: args,
|
|
96
|
+
})];
|
|
97
|
+
case 1:
|
|
98
|
+
response = _a.sent();
|
|
99
|
+
return [2 /*return*/, response];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
return DefaultApiUtils;
|
|
105
|
+
}());
|
|
106
|
+
exports.DefaultApiUtils = DefaultApiUtils;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { DefaultApiUtils } from './defaultApi';
|
|
2
|
+
export { TweetApiUtils } from './tweetApi';
|
|
3
|
+
export { PostApiUtils } from './postApi';
|
|
4
|
+
export { UserApiUtils } from './userApi';
|
|
5
|
+
export { UserListApiUtils } from './userListApi';
|
|
6
|
+
export { V11GetApiUtils } from './v11GetApi';
|
|
7
|
+
export { V11PostApiUtils } from './v11PostApi';
|
|
8
|
+
export { V20GetApiUtils } from './v20GetApi';
|
|
9
|
+
export { InitialStateApiUtils } from './initialStateApi';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InitialStateApiUtils = exports.V20GetApiUtils = exports.V11PostApiUtils = exports.V11GetApiUtils = exports.UserListApiUtils = exports.UserApiUtils = exports.PostApiUtils = exports.TweetApiUtils = exports.DefaultApiUtils = void 0;
|
|
4
|
+
var defaultApi_1 = require("./defaultApi");
|
|
5
|
+
Object.defineProperty(exports, "DefaultApiUtils", { enumerable: true, get: function () { return defaultApi_1.DefaultApiUtils; } });
|
|
6
|
+
var tweetApi_1 = require("./tweetApi");
|
|
7
|
+
Object.defineProperty(exports, "TweetApiUtils", { enumerable: true, get: function () { return tweetApi_1.TweetApiUtils; } });
|
|
8
|
+
var postApi_1 = require("./postApi");
|
|
9
|
+
Object.defineProperty(exports, "PostApiUtils", { enumerable: true, get: function () { return postApi_1.PostApiUtils; } });
|
|
10
|
+
var userApi_1 = require("./userApi");
|
|
11
|
+
Object.defineProperty(exports, "UserApiUtils", { enumerable: true, get: function () { return userApi_1.UserApiUtils; } });
|
|
12
|
+
var userListApi_1 = require("./userListApi");
|
|
13
|
+
Object.defineProperty(exports, "UserListApiUtils", { enumerable: true, get: function () { return userListApi_1.UserListApiUtils; } });
|
|
14
|
+
var v11GetApi_1 = require("./v11GetApi");
|
|
15
|
+
Object.defineProperty(exports, "V11GetApiUtils", { enumerable: true, get: function () { return v11GetApi_1.V11GetApiUtils; } });
|
|
16
|
+
var v11PostApi_1 = require("./v11PostApi");
|
|
17
|
+
Object.defineProperty(exports, "V11PostApiUtils", { enumerable: true, get: function () { return v11PostApi_1.V11PostApiUtils; } });
|
|
18
|
+
var v20GetApi_1 = require("./v20GetApi");
|
|
19
|
+
Object.defineProperty(exports, "V20GetApiUtils", { enumerable: true, get: function () { return v20GetApi_1.V20GetApiUtils; } });
|
|
20
|
+
var initialStateApi_1 = require("./initialStateApi");
|
|
21
|
+
Object.defineProperty(exports, "InitialStateApiUtils", { enumerable: true, get: function () { return initialStateApi_1.InitialStateApiUtils; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InitialStateApiUtils = void 0;
|
|
4
|
+
var InitialStateApiUtils = /** @class */ (function () {
|
|
5
|
+
function InitialStateApiUtils() {
|
|
6
|
+
}
|
|
7
|
+
return InitialStateApiUtils;
|
|
8
|
+
}());
|
|
9
|
+
exports.InitialStateApiUtils = InitialStateApiUtils;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as i from 'twitter-openapi-typescript-generated';
|
|
2
|
+
import { DefaultFlag } from '../types';
|
|
3
|
+
import { TwitterApiUtilsResponse } from '../types';
|
|
4
|
+
type PostCreateTweetParam = {
|
|
5
|
+
tweetText: string;
|
|
6
|
+
extraParam?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type PostDeleteTweetParam = {
|
|
11
|
+
tweetId: string;
|
|
12
|
+
extraParam?: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
type PostCreateRetweetParam = {
|
|
17
|
+
tweetId: string;
|
|
18
|
+
extraParam?: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type PostDeleteRetweetParam = {
|
|
23
|
+
sourceTweetId: string;
|
|
24
|
+
extraParam?: {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
type PostFavoriteTweetParam = {
|
|
29
|
+
tweetId: string;
|
|
30
|
+
extraParam?: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
type PostUnfavoriteTweetParam = {
|
|
35
|
+
tweetId: string;
|
|
36
|
+
extraParam?: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare class PostApiUtils {
|
|
41
|
+
api: i.PostApi;
|
|
42
|
+
flag: DefaultFlag;
|
|
43
|
+
constructor(api: i.PostApi, flag: DefaultFlag);
|
|
44
|
+
postCreateTweet(param: PostCreateTweetParam): Promise<TwitterApiUtilsResponse<i.CreateTweetResponse>>;
|
|
45
|
+
postDeleteTweet(param: PostDeleteTweetParam): Promise<TwitterApiUtilsResponse<i.DeleteTweetResponse>>;
|
|
46
|
+
postCreateRetweet(param: PostCreateRetweetParam): Promise<TwitterApiUtilsResponse<i.CreateRetweetResponse>>;
|
|
47
|
+
postDeleteRetweet(param: PostDeleteRetweetParam): Promise<TwitterApiUtilsResponse<i.DeleteRetweetResponse>>;
|
|
48
|
+
postFavoriteTweet(param: PostFavoriteTweetParam): Promise<TwitterApiUtilsResponse<i.FavoriteTweetResponseData>>;
|
|
49
|
+
postUnfavoriteTweet(param: PostUnfavoriteTweetParam): Promise<TwitterApiUtilsResponse<i.UnfavoriteTweetResponseData>>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,236 @@
|
|
|
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.PostApiUtils = void 0;
|
|
51
|
+
var i = require("twitter-openapi-typescript-generated");
|
|
52
|
+
var models_1 = require("../models");
|
|
53
|
+
var PostApiUtils = /** @class */ (function () {
|
|
54
|
+
function PostApiUtils(api, flag) {
|
|
55
|
+
this.api = api;
|
|
56
|
+
this.flag = flag;
|
|
57
|
+
}
|
|
58
|
+
PostApiUtils.prototype.postCreateTweet = function (param) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var args, queryId, features, variables, response;
|
|
61
|
+
var _a;
|
|
62
|
+
return __generator(this, function (_b) {
|
|
63
|
+
switch (_b.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
args = __assign({ tweetText: param.tweetText }, param.extraParam);
|
|
66
|
+
queryId = 'CreateTweet';
|
|
67
|
+
features = i.PostCreateTweetRequestFeaturesFromJSON(this.flag[queryId]['features']);
|
|
68
|
+
variables = i.PostCreateTweetRequestVariablesFromJSON(this.flag[queryId]['variables']);
|
|
69
|
+
return [4 /*yield*/, this.api.postCreateTweetRaw({
|
|
70
|
+
postCreateTweetRequest: {
|
|
71
|
+
queryId: queryId,
|
|
72
|
+
features: features,
|
|
73
|
+
variables: __assign(__assign({}, variables), args),
|
|
74
|
+
},
|
|
75
|
+
})];
|
|
76
|
+
case 1:
|
|
77
|
+
response = _b.sent();
|
|
78
|
+
_a = {
|
|
79
|
+
raw: { response: response.raw },
|
|
80
|
+
header: (0, models_1.buildHeader)(response.raw.headers)
|
|
81
|
+
};
|
|
82
|
+
return [4 /*yield*/, response.value()];
|
|
83
|
+
case 2: return [2 /*return*/, (_a.data = _b.sent(),
|
|
84
|
+
_a)];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
PostApiUtils.prototype.postDeleteTweet = function (param) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
var args, queryId, variables, response;
|
|
92
|
+
var _a;
|
|
93
|
+
return __generator(this, function (_b) {
|
|
94
|
+
switch (_b.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
args = __assign({ tweetId: param.tweetId }, param.extraParam);
|
|
97
|
+
queryId = 'DeleteTweet';
|
|
98
|
+
variables = i.PostDeleteTweetRequestVariablesFromJSON(this.flag[queryId]['variables']);
|
|
99
|
+
return [4 /*yield*/, this.api.postDeleteTweetRaw({
|
|
100
|
+
postDeleteTweetRequest: {
|
|
101
|
+
queryId: queryId,
|
|
102
|
+
variables: __assign(__assign({}, variables), args),
|
|
103
|
+
},
|
|
104
|
+
})];
|
|
105
|
+
case 1:
|
|
106
|
+
response = _b.sent();
|
|
107
|
+
_a = {
|
|
108
|
+
raw: { response: response.raw },
|
|
109
|
+
header: (0, models_1.buildHeader)(response.raw.headers)
|
|
110
|
+
};
|
|
111
|
+
return [4 /*yield*/, response.value()];
|
|
112
|
+
case 2: return [2 /*return*/, (_a.data = _b.sent(),
|
|
113
|
+
_a)];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
PostApiUtils.prototype.postCreateRetweet = function (param) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var args, queryId, variables, response;
|
|
121
|
+
var _a;
|
|
122
|
+
return __generator(this, function (_b) {
|
|
123
|
+
switch (_b.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
args = __assign({ tweetId: param.tweetId }, param.extraParam);
|
|
126
|
+
queryId = 'CreateRetweet';
|
|
127
|
+
variables = i.PostCreateTweetRequestVariablesFromJSON(this.flag[queryId]['variables']);
|
|
128
|
+
return [4 /*yield*/, this.api.postCreateRetweetRaw({
|
|
129
|
+
postCreateRetweetRequest: {
|
|
130
|
+
queryId: queryId,
|
|
131
|
+
variables: __assign(__assign({}, variables), args),
|
|
132
|
+
},
|
|
133
|
+
})];
|
|
134
|
+
case 1:
|
|
135
|
+
response = _b.sent();
|
|
136
|
+
_a = {
|
|
137
|
+
raw: { response: response.raw },
|
|
138
|
+
header: (0, models_1.buildHeader)(response.raw.headers)
|
|
139
|
+
};
|
|
140
|
+
return [4 /*yield*/, response.value()];
|
|
141
|
+
case 2: return [2 /*return*/, (_a.data = _b.sent(),
|
|
142
|
+
_a)];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
PostApiUtils.prototype.postDeleteRetweet = function (param) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
var args, queryId, variables, response;
|
|
150
|
+
var _a;
|
|
151
|
+
return __generator(this, function (_b) {
|
|
152
|
+
switch (_b.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
args = __assign({ sourceTweetId: param.sourceTweetId }, param.extraParam);
|
|
155
|
+
queryId = 'DeleteRetweet';
|
|
156
|
+
variables = i.PostDeleteRetweetRequestVariablesFromJSON(this.flag[queryId]['variables']);
|
|
157
|
+
return [4 /*yield*/, this.api.postDeleteRetweetRaw({
|
|
158
|
+
postDeleteRetweetRequest: {
|
|
159
|
+
queryId: queryId,
|
|
160
|
+
variables: __assign(__assign({}, variables), args),
|
|
161
|
+
},
|
|
162
|
+
})];
|
|
163
|
+
case 1:
|
|
164
|
+
response = _b.sent();
|
|
165
|
+
_a = {
|
|
166
|
+
raw: { response: response.raw },
|
|
167
|
+
header: (0, models_1.buildHeader)(response.raw.headers)
|
|
168
|
+
};
|
|
169
|
+
return [4 /*yield*/, response.value()];
|
|
170
|
+
case 2: return [2 /*return*/, (_a.data = _b.sent(),
|
|
171
|
+
_a)];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
PostApiUtils.prototype.postFavoriteTweet = function (param) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
178
|
+
var args, queryId, variables, response;
|
|
179
|
+
var _a;
|
|
180
|
+
return __generator(this, function (_b) {
|
|
181
|
+
switch (_b.label) {
|
|
182
|
+
case 0:
|
|
183
|
+
args = __assign({ tweetId: param.tweetId }, param.extraParam);
|
|
184
|
+
queryId = 'FavoriteTweet';
|
|
185
|
+
variables = i.PostDeleteTweetRequestVariablesFromJSON(this.flag[queryId]['variables']);
|
|
186
|
+
return [4 /*yield*/, this.api.postFavoriteTweetRaw({
|
|
187
|
+
postFavoriteTweetRequest: {
|
|
188
|
+
queryId: queryId,
|
|
189
|
+
variables: __assign(__assign({}, variables), args),
|
|
190
|
+
},
|
|
191
|
+
})];
|
|
192
|
+
case 1:
|
|
193
|
+
response = _b.sent();
|
|
194
|
+
_a = {
|
|
195
|
+
raw: { response: response.raw },
|
|
196
|
+
header: (0, models_1.buildHeader)(response.raw.headers)
|
|
197
|
+
};
|
|
198
|
+
return [4 /*yield*/, response.value()];
|
|
199
|
+
case 2: return [2 /*return*/, (_a.data = _b.sent(),
|
|
200
|
+
_a)];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
PostApiUtils.prototype.postUnfavoriteTweet = function (param) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
207
|
+
var args, queryId, variables, response;
|
|
208
|
+
var _a;
|
|
209
|
+
return __generator(this, function (_b) {
|
|
210
|
+
switch (_b.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
args = __assign({ tweetId: param.tweetId }, param.extraParam);
|
|
213
|
+
queryId = 'UnfavoriteTweet';
|
|
214
|
+
variables = i.PostDeleteTweetRequestVariablesFromJSON(this.flag[queryId]['variables']);
|
|
215
|
+
return [4 /*yield*/, this.api.postUnfavoriteTweetRaw({
|
|
216
|
+
postUnfavoriteTweetRequest: {
|
|
217
|
+
queryId: queryId,
|
|
218
|
+
variables: __assign(__assign({}, variables), args),
|
|
219
|
+
},
|
|
220
|
+
})];
|
|
221
|
+
case 1:
|
|
222
|
+
response = _b.sent();
|
|
223
|
+
_a = {
|
|
224
|
+
raw: { response: response.raw },
|
|
225
|
+
header: (0, models_1.buildHeader)(response.raw.headers)
|
|
226
|
+
};
|
|
227
|
+
return [4 /*yield*/, response.value()];
|
|
228
|
+
case 2: return [2 /*return*/, (_a.data = _b.sent(),
|
|
229
|
+
_a)];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
return PostApiUtils;
|
|
235
|
+
}());
|
|
236
|
+
exports.PostApiUtils = PostApiUtils;
|