rettiwt-api 1.0.8 → 1.1.0
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/.dockerignore +1 -1
- package/dist/graphql/resolvers/TweetResolver.js +3 -3
- package/dist/graphql/resolvers/TweetResolver.js.map +1 -1
- package/dist/graphql/resolvers/UserResolver.js +3 -3
- package/dist/graphql/resolvers/UserResolver.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/services/data/TweetService.d.ts +4 -9
- package/dist/services/data/TweetService.js +6 -40
- package/dist/services/data/TweetService.js.map +1 -1
- package/dist/services/data/UserService.d.ts +2 -2
- package/dist/services/data/UserService.js +9 -9
- package/dist/services/data/UserService.js.map +1 -1
- package/dist/services/helper/extractors/Tweets.d.ts +2 -4
- package/dist/services/helper/extractors/Tweets.js +6 -8
- package/dist/services/helper/extractors/Tweets.js.map +1 -1
- package/dist/services/helper/extractors/Users.d.ts +3 -6
- package/dist/services/helper/extractors/Users.js +6 -9
- package/dist/services/helper/extractors/Users.js.map +1 -1
- package/dist/types/data/Errors.d.ts +10 -11
- package/dist/types/data/Errors.js +11 -10
- package/dist/types/data/Errors.js.map +1 -1
- package/dist/types/data/Service.d.ts +2 -2
- package/package.json +1 -1
- package/src/index.ts +7 -1
- package/src/types/data/Service.ts +2 -2
- package/dist/services/data/UserAccountService.d.ts +0 -42
- package/dist/services/data/UserAccountService.js +0 -253
- package/dist/services/data/UserAccountService.js.map +0 -1
- package/dist/services/helper/Deserializers.d.ts +0 -19
- package/dist/services/helper/Deserializers.js +0 -115
- package/dist/services/helper/Deserializers.js.map +0 -1
- package/dist/services/helper/Extractors.d.ts +0 -101
- package/dist/services/helper/Extractors.js +0 -409
- package/dist/services/helper/Extractors.js.map +0 -1
- package/dist/services/helper/Urls.d.ts +0 -74
- package/dist/services/helper/Urls.js +0 -130
- package/dist/services/helper/Urls.js.map +0 -1
- package/dist/services/helper/deserializers/User.d.ts +0 -0
- package/dist/services/helper/deserializers/User.js +0 -2
- package/dist/services/helper/deserializers/User.js.map +0 -1
- package/dist/services/helper/extractors/TweetExtractors.d.ts +0 -0
- package/dist/services/helper/extractors/TweetExtractors.js +0 -2
- package/dist/services/helper/extractors/TweetExtractors.js.map +0 -1
- package/dist/services/helper/extractors/UserExtractors.d.ts +0 -45
- package/dist/services/helper/extractors/UserExtractors.js +0 -176
- package/dist/services/helper/extractors/UserExtractors.js.map +0 -1
- package/dist/services/helper/urls/Urls.d.ts +0 -4
- package/dist/services/helper/urls/Urls.js +0 -11
- package/dist/services/helper/urls/Urls.js.map +0 -1
- package/dist/types/Errors.d.ts +0 -15
- package/dist/types/Errors.js +0 -23
- package/dist/types/Errors.js.map +0 -1
- package/dist/types/Service.d.ts +0 -30
- package/dist/types/Service.js +0 -19
- package/dist/types/Service.js.map +0 -1
- package/dist/types/Tweet.d.ts +0 -41
- package/dist/types/Tweet.js +0 -5
- package/dist/types/Tweet.js.map +0 -1
- package/dist/types/User.d.ts +0 -19
- package/dist/types/User.js +0 -4
- package/dist/types/User.js.map +0 -1
- package/dist/types/UserAccount.d.ts +0 -19
- package/dist/types/UserAccount.js +0 -4
- package/dist/types/UserAccount.js.map +0 -1
- package/dist/types/raw/http/Error.d.ts +0 -34
- package/dist/types/raw/http/Error.js +0 -3
- package/dist/types/raw/http/Error.js.map +0 -1
- package/dist/types/raw/http/Response.d.ts +0 -34
- package/dist/types/raw/http/Response.js +0 -3
- package/dist/types/raw/http/Response.js.map +0 -1
- package/dist/types/raw/user/Tweets.d.ts +0 -2428
- package/dist/types/raw/user/Tweets.js +0 -3
- package/dist/types/raw/user/Tweets.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Users.js","sourceRoot":"","sources":["../../../../src/services/helper/extractors/Users.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qDAAwD;AAMxD,UAAU;AACV,iDAAqC;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,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;wBAC9D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;wBACpF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;qBAC/D;oBACD,6BAA6B;yBACxB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE;wBACnD,MAAM,GAAG,MAAA,KAAK,CAAC,OAAO,CAAC,KAAK,mCAAI,EAAE,CAAC;qBACtC;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;KACN;IAED,qBAAqB;IACrB,OAAO;QACH,QAAQ,EAAE,QAAQ;QAClB,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,MAAM;KACjB,CAAC;AACN,CAAC;AAxCD,4CAwCC"}
|
|
@@ -10,18 +10,17 @@ export declare enum AuthenticationErrors {
|
|
|
10
10
|
export declare enum ValidationErrors {
|
|
11
11
|
InvalidTweetFilter = "Atleast one of fromUsers/toUsers/mentions/hashtags/words argument is required",
|
|
12
12
|
NoUserIdentification = "Either userName or id must be given",
|
|
13
|
-
InvalidCount = "Invalid count provided"
|
|
14
|
-
InvalidTweetIdCount = "Atleast one Tweet ID must be provided"
|
|
13
|
+
InvalidCount = "Invalid count provided"
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
16
|
* @summary Stores all the different type of error messages that are returned by services
|
|
18
17
|
*/
|
|
19
|
-
export declare
|
|
20
|
-
UserNotFound
|
|
21
|
-
TweetNotFound
|
|
22
|
-
NoTweetsFound
|
|
23
|
-
NoLikersFound
|
|
24
|
-
NoRetweetersFound
|
|
25
|
-
NoFollowsFound
|
|
26
|
-
NoLikedTweetsFound
|
|
27
|
-
}
|
|
18
|
+
export declare enum DataErrors {
|
|
19
|
+
UserNotFound = "An account with given username/id was not found",
|
|
20
|
+
TweetNotFound = "A tweet with the given id was not found",
|
|
21
|
+
NoTweetsFound = "No tweets matching the given criteria found",
|
|
22
|
+
NoLikersFound = "No likers found for the tweet with the given id",
|
|
23
|
+
NoRetweetersFound = "No retweeters found for the tweet with the given id",
|
|
24
|
+
NoFollowsFound = "No follow details were found for the user with the given id",
|
|
25
|
+
NoLikedTweetsFound = "No liked tweets were found for the user with the given id"
|
|
26
|
+
}
|
|
@@ -17,19 +17,20 @@ var ValidationErrors;
|
|
|
17
17
|
ValidationErrors["InvalidTweetFilter"] = "Atleast one of fromUsers/toUsers/mentions/hashtags/words argument is required";
|
|
18
18
|
ValidationErrors["NoUserIdentification"] = "Either userName or id must be given";
|
|
19
19
|
ValidationErrors["InvalidCount"] = "Invalid count provided";
|
|
20
|
-
ValidationErrors["InvalidTweetIdCount"] = "Atleast one Tweet ID must be provided";
|
|
21
20
|
})(ValidationErrors = exports.ValidationErrors || (exports.ValidationErrors = {}));
|
|
22
21
|
;
|
|
23
22
|
/**
|
|
24
23
|
* @summary Stores all the different type of error messages that are returned by services
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
var DataErrors;
|
|
26
|
+
(function (DataErrors) {
|
|
27
|
+
DataErrors["UserNotFound"] = "An account with given username/id was not found";
|
|
28
|
+
DataErrors["TweetNotFound"] = "A tweet with the given id was not found";
|
|
29
|
+
DataErrors["NoTweetsFound"] = "No tweets matching the given criteria found";
|
|
30
|
+
DataErrors["NoLikersFound"] = "No likers found for the tweet with the given id";
|
|
31
|
+
DataErrors["NoRetweetersFound"] = "No retweeters found for the tweet with the given id";
|
|
32
|
+
DataErrors["NoFollowsFound"] = "No follow details were found for the user with the given id";
|
|
33
|
+
DataErrors["NoLikedTweetsFound"] = "No liked tweets were found for the user with the given id";
|
|
34
|
+
})(DataErrors = exports.DataErrors || (exports.DataErrors = {}));
|
|
35
|
+
;
|
|
35
36
|
//# sourceMappingURL=Errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../../../src/types/data/Errors.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../../../src/types/data/Errors.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,oBAEX;AAFD,WAAY,oBAAoB;IAC5B,0FAAkE,CAAA;AACtE,CAAC,EAFW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAE/B;AAAA,CAAC;AAEF;;GAEG;AACH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IACxB,wHAAoG,CAAA;IACpG,gFAA4D,CAAA;IAC5D,2DAAuC,CAAA;AAC3C,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B;AAAA,CAAC;AAEF;;GAEG;AACH,IAAY,UAQX;AARD,WAAY,UAAU;IAClB,8EAAgE,CAAA;IAChE,uEAAyD,CAAA;IACzD,2EAA6D,CAAA;IAC7D,+EAAiE,CAAA;IACjE,uFAAyE,CAAA;IACzE,4FAA8E,CAAA;IAC9E,8FAAgF,CAAA;AACpF,CAAC,EARW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAQrB;AAAA,CAAC"}
|
|
@@ -16,8 +16,8 @@ export declare class Cursor {
|
|
|
16
16
|
* @summary Stores cursored data that is returned by services
|
|
17
17
|
*/
|
|
18
18
|
export interface CursoredData<Type> {
|
|
19
|
-
list
|
|
20
|
-
next
|
|
19
|
+
list: Type[];
|
|
20
|
+
next: Cursor;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* @summary Stores the data context from where data is to be fetched
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -18,4 +18,10 @@ export const Rettiwt = (cookie: string = '') => {
|
|
|
18
18
|
tweets: new TweetService(auth),
|
|
19
19
|
account: new AccountService()
|
|
20
20
|
};
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Exporting additional types
|
|
24
|
+
export { User } from './types/data/User';
|
|
25
|
+
export { Tweet, TweetEntities, TweetFilter } from './types/data/Tweet';
|
|
26
|
+
export { Cursor, CursoredData } from './types/data/Service';
|
|
27
|
+
export { AuthenticationErrors, ValidationErrors, DataErrors } from './types/data/Errors';
|
|
@@ -24,8 +24,8 @@ export class Cursor {
|
|
|
24
24
|
* @summary Stores cursored data that is returned by services
|
|
25
25
|
*/
|
|
26
26
|
export interface CursoredData<Type> {
|
|
27
|
-
list
|
|
28
|
-
next
|
|
27
|
+
list: Type[]; // To store the list data
|
|
28
|
+
next: Cursor; // To store the information about cursor to the next batch
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { FetcherService } from '../FetcherService';
|
|
2
|
-
import { AuthService } from '../AuthService';
|
|
3
|
-
import { User } from '../../types/UserAccount';
|
|
4
|
-
import { Tweet } from '../../types/Tweet';
|
|
5
|
-
import { CursoredData } from '../../types/Service';
|
|
6
|
-
/**
|
|
7
|
-
* A service that deals with fetching of data related to user account
|
|
8
|
-
*/
|
|
9
|
-
export declare class UserAccountService extends FetcherService {
|
|
10
|
-
constructor(auth: AuthService);
|
|
11
|
-
/**
|
|
12
|
-
* @returns The user account details of the given user
|
|
13
|
-
* @param screenName The screen name of the target user.
|
|
14
|
-
*/
|
|
15
|
-
getUserAccountDetails(screenName: string): Promise<User>;
|
|
16
|
-
/**
|
|
17
|
-
* @returns The user account details of the user with given rest id
|
|
18
|
-
* @param restId The screen name of the target user.
|
|
19
|
-
*/
|
|
20
|
-
getUserAccountDetailsById(restId: string): Promise<User>;
|
|
21
|
-
/**
|
|
22
|
-
* @returns The list of users followed by the target user
|
|
23
|
-
* @param userId The rest id of the target user
|
|
24
|
-
* @param count The number of following to fetch, should be >= 40 (when no cursor is provided) and <=100
|
|
25
|
-
* @param cursor The cursor to next batch. If blank, first batch is fetched
|
|
26
|
-
*/
|
|
27
|
-
getUserFollowing(userId: string, count: number, cursor: string): Promise<CursoredData<User>>;
|
|
28
|
-
/**
|
|
29
|
-
* @returns The list of users following the target user
|
|
30
|
-
* @param userId The rest id of the target user
|
|
31
|
-
* @param count The number of followers to fetch, should be >= 40 (when no cursor is provided) and <=100
|
|
32
|
-
* @param cursor The cursor to next batch. If blank, first batch is fetched
|
|
33
|
-
*/
|
|
34
|
-
getUserFollowers(userId: string, count: number, cursor: string): Promise<CursoredData<User>>;
|
|
35
|
-
/**
|
|
36
|
-
* @returns The list of tweets liked by the target user
|
|
37
|
-
* @param userId The rest id of the target user
|
|
38
|
-
* @param count The number of likes to fetch, must be >= 10 (when no cursor is provided) and <= 100
|
|
39
|
-
* @param cursor The cursor to next batch. If blank, first batch is fetched
|
|
40
|
-
*/
|
|
41
|
-
getUserLikes(userId: string, count: number, cursor: string): Promise<CursoredData<Tweet>>;
|
|
42
|
-
}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
50
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
51
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
52
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
|
-
function step(op) {
|
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
-
while (_) try {
|
|
56
|
-
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;
|
|
57
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
|
-
switch (op[0]) {
|
|
59
|
-
case 0: case 1: t = op; break;
|
|
60
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
61
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
62
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
63
|
-
default:
|
|
64
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
65
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
66
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
67
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
68
|
-
if (t[2]) _.ops.pop();
|
|
69
|
-
_.trys.pop(); continue;
|
|
70
|
-
}
|
|
71
|
-
op = body.call(thisArg, _);
|
|
72
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
73
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
exports.__esModule = true;
|
|
77
|
-
exports.UserAccountService = void 0;
|
|
78
|
-
// SERVICES
|
|
79
|
-
var FetcherService_1 = require("../FetcherService");
|
|
80
|
-
// URLS
|
|
81
|
-
var Urls = __importStar(require("../helper/Urls"));
|
|
82
|
-
// EXTRACTORS
|
|
83
|
-
var Extractors = __importStar(require("../helper/Extractors"));
|
|
84
|
-
// DESERIALIZERS
|
|
85
|
-
var Deserializers = __importStar(require("../helper/Deserializers"));
|
|
86
|
-
/**
|
|
87
|
-
* A service that deals with fetching of data related to user account
|
|
88
|
-
*/
|
|
89
|
-
var UserAccountService = /** @class */ (function (_super) {
|
|
90
|
-
__extends(UserAccountService, _super);
|
|
91
|
-
// MEMBER METHODS
|
|
92
|
-
function UserAccountService(auth) {
|
|
93
|
-
return _super.call(this, auth) || this;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* @returns The user account details of the given user
|
|
97
|
-
* @param screenName The screen name of the target user.
|
|
98
|
-
*/
|
|
99
|
-
UserAccountService.prototype.getUserAccountDetails = function (screenName) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
var res, data, user;
|
|
102
|
-
return __generator(this, function (_a) {
|
|
103
|
-
switch (_a.label) {
|
|
104
|
-
case 0: return [4 /*yield*/, this.request(Urls.userAccountUrl(screenName), false).then(function (res) { return res.data; })];
|
|
105
|
-
case 1:
|
|
106
|
-
res = _a.sent();
|
|
107
|
-
data = Extractors.extractUserAccountDetails(res);
|
|
108
|
-
// Caching data
|
|
109
|
-
this.cacheData(data);
|
|
110
|
-
user = Deserializers.toUser(data.required[0]);
|
|
111
|
-
return [2 /*return*/, user];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* @returns The user account details of the user with given rest id
|
|
118
|
-
* @param restId The screen name of the target user.
|
|
119
|
-
*/
|
|
120
|
-
UserAccountService.prototype.getUserAccountDetailsById = function (restId) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
var cachedData, res, data, user;
|
|
123
|
-
return __generator(this, function (_a) {
|
|
124
|
-
switch (_a.label) {
|
|
125
|
-
case 0: return [4 /*yield*/, this.readData(restId)];
|
|
126
|
-
case 1:
|
|
127
|
-
cachedData = _a.sent();
|
|
128
|
-
// If data exists in cache
|
|
129
|
-
if (cachedData) {
|
|
130
|
-
return [2 /*return*/, cachedData];
|
|
131
|
-
}
|
|
132
|
-
return [4 /*yield*/, this.request(Urls.userAccountByIdUrl(restId), false).then(function (res) { return res.data; })];
|
|
133
|
-
case 2:
|
|
134
|
-
res = _a.sent();
|
|
135
|
-
data = Extractors.extractUserAccountDetails(res);
|
|
136
|
-
// Caching data
|
|
137
|
-
this.cacheData(data);
|
|
138
|
-
user = Deserializers.toUser(data.required[0]);
|
|
139
|
-
return [2 /*return*/, user];
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* @returns The list of users followed by the target user
|
|
146
|
-
* @param userId The rest id of the target user
|
|
147
|
-
* @param count The number of following to fetch, should be >= 40 (when no cursor is provided) and <=100
|
|
148
|
-
* @param cursor The cursor to next batch. If blank, first batch is fetched
|
|
149
|
-
*/
|
|
150
|
-
UserAccountService.prototype.getUserFollowing = function (userId, count, cursor) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
var res, data, users;
|
|
153
|
-
return __generator(this, function (_a) {
|
|
154
|
-
switch (_a.label) {
|
|
155
|
-
case 0:
|
|
156
|
-
// If user is not authenticated, abort
|
|
157
|
-
if (!this.isAuthenticated) {
|
|
158
|
-
return [2 /*return*/, { error: new Error('Cannot fetch user following without authentication!') }];
|
|
159
|
-
}
|
|
160
|
-
// If invalid count provided
|
|
161
|
-
if (count < 40 && !cursor) {
|
|
162
|
-
return [2 /*return*/, { error: new Error('Count must be >= 40 (when no cursor if provided)!') }];
|
|
163
|
-
}
|
|
164
|
-
return [4 /*yield*/, this.request(Urls.userFollowingUrl(userId, count, cursor)).then(function (res) { return res.data; })];
|
|
165
|
-
case 1:
|
|
166
|
-
res = _a.sent();
|
|
167
|
-
data = Extractors.extractUserFollow(res);
|
|
168
|
-
// Caching data
|
|
169
|
-
this.cacheData(data);
|
|
170
|
-
users = data.required.map(function (item) { return Deserializers.toUser(item); });
|
|
171
|
-
return [2 /*return*/, {
|
|
172
|
-
list: users,
|
|
173
|
-
next: { value: data.cursor }
|
|
174
|
-
}];
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* @returns The list of users following the target user
|
|
181
|
-
* @param userId The rest id of the target user
|
|
182
|
-
* @param count The number of followers to fetch, should be >= 40 (when no cursor is provided) and <=100
|
|
183
|
-
* @param cursor The cursor to next batch. If blank, first batch is fetched
|
|
184
|
-
*/
|
|
185
|
-
UserAccountService.prototype.getUserFollowers = function (userId, count, cursor) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
-
var res, data, users;
|
|
188
|
-
return __generator(this, function (_a) {
|
|
189
|
-
switch (_a.label) {
|
|
190
|
-
case 0:
|
|
191
|
-
// If user is not authenticated, abort
|
|
192
|
-
if (!this.isAuthenticated) {
|
|
193
|
-
return [2 /*return*/, { error: new Error('Cannot fetch user followers without authentication!') }];
|
|
194
|
-
}
|
|
195
|
-
// If invalid count provided
|
|
196
|
-
if (count < 40 && !cursor) {
|
|
197
|
-
return [2 /*return*/, { error: new Error('Count must be >= 40 (when no cursor is provided)!') }];
|
|
198
|
-
}
|
|
199
|
-
return [4 /*yield*/, this.request(Urls.userFollowersUrl(userId, count, cursor)).then(function (res) { return res.data; })];
|
|
200
|
-
case 1:
|
|
201
|
-
res = _a.sent();
|
|
202
|
-
data = Extractors.extractUserFollow(res);
|
|
203
|
-
// Caching data
|
|
204
|
-
this.cacheData(data);
|
|
205
|
-
users = data.required.map(function (item) { return Deserializers.toUser(item); });
|
|
206
|
-
return [2 /*return*/, {
|
|
207
|
-
list: users,
|
|
208
|
-
next: { value: data.cursor }
|
|
209
|
-
}];
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
/**
|
|
215
|
-
* @returns The list of tweets liked by the target user
|
|
216
|
-
* @param userId The rest id of the target user
|
|
217
|
-
* @param count The number of likes to fetch, must be >= 10 (when no cursor is provided) and <= 100
|
|
218
|
-
* @param cursor The cursor to next batch. If blank, first batch is fetched
|
|
219
|
-
*/
|
|
220
|
-
UserAccountService.prototype.getUserLikes = function (userId, count, cursor) {
|
|
221
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
-
var res, data, tweets;
|
|
223
|
-
return __generator(this, function (_a) {
|
|
224
|
-
switch (_a.label) {
|
|
225
|
-
case 0:
|
|
226
|
-
// If user is not authenticated, abort
|
|
227
|
-
if (!this.isAuthenticated) {
|
|
228
|
-
return [2 /*return*/, { error: new Error('Cannot fetch user likes without authentication!') }];
|
|
229
|
-
}
|
|
230
|
-
// If invalid count provided
|
|
231
|
-
if (count < 40 && !cursor) {
|
|
232
|
-
return [2 /*return*/, { error: new Error('Count must be >= 10 (when no cursor is provided)!') }];
|
|
233
|
-
}
|
|
234
|
-
return [4 /*yield*/, this.request(Urls.userLikesUrl(userId, count, cursor)).then(function (res) { return res.data; })];
|
|
235
|
-
case 1:
|
|
236
|
-
res = _a.sent();
|
|
237
|
-
data = Extractors.extractUserLikes(res);
|
|
238
|
-
// Caching data
|
|
239
|
-
this.cacheData(data);
|
|
240
|
-
tweets = data.required.map(function (item) { return Deserializers.toTweet(item); });
|
|
241
|
-
return [2 /*return*/, {
|
|
242
|
-
list: tweets,
|
|
243
|
-
next: { value: data.cursor }
|
|
244
|
-
}];
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
|
-
return UserAccountService;
|
|
250
|
-
}(FetcherService_1.FetcherService));
|
|
251
|
-
exports.UserAccountService = UserAccountService;
|
|
252
|
-
;
|
|
253
|
-
//# sourceMappingURL=UserAccountService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserAccountService.js","sourceRoot":"","sources":["../../../src/services/data/UserAccountService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,oDAAmD;AAYnD,OAAO;AACP,mDAAuC;AAEvC,aAAa;AACb,+DAAmD;AAEnD,gBAAgB;AAChB,qEAAyD;AAEzD;;GAEG;AACH;IAAwC,sCAAc;IAClD,iBAAiB;IACjB,4BAAY,IAAiB;eACzB,kBAAM,IAAI,CAAC;IACf,CAAC;IAED;;;OAGG;IACG,kDAAqB,GAA3B,UAA4B,UAAkB;;;;;4BAEvB,qBAAM,IAAI,CAAC,OAAO,CAAU,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,IAAI,EAAR,CAAQ,CAAC,EAAA;;wBAAxG,GAAG,GAAY,SAAyF;wBAGxG,IAAI,GAAG,UAAU,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;wBAErD,eAAe;wBACf,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;wBAGjB,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;wBAElD,sBAAO,IAAI,EAAC;;;;KACf;IAED;;;OAGG;IACG,sDAAyB,GAA/B,UAAgC,MAAc;;;;;4BAEzB,qBAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAA;;wBAAxC,UAAU,GAAG,SAA2B;wBAE5C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tweet';
|
|
3
|
-
import { Result as RawUser } from '../../types/raw/user/User';
|
|
4
|
-
import { Result as RawTweet, Entities2 as RawTweetEntities } from '../../types/raw/tweet/Tweet';
|
|
5
|
-
/**
|
|
6
|
-
* @returns A User object containing the user details
|
|
7
|
-
* @param data The raw user data from Twitter API
|
|
8
|
-
*/
|
|
9
|
-
export declare function toUser(data: RawUser): User;
|
|
10
|
-
/**
|
|
11
|
-
* @returns A TweetEntities object containing the various tweet entities
|
|
12
|
-
* @param data The raw tweet entities data from the response received from TwitterAPI
|
|
13
|
-
*/
|
|
14
|
-
export declare function toTweetEntities(data: RawTweetEntities): TweetEntities;
|
|
15
|
-
/**
|
|
16
|
-
* @returns A Tweet object containing the tweet data
|
|
17
|
-
* @param data The raw tweet data from the response received from TwitterAPI
|
|
18
|
-
*/
|
|
19
|
-
export declare function toTweet(data: RawTweet): Tweet;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
exports.__esModule = true;
|
|
26
|
-
exports.toTweet = exports.toTweetEntities = exports.toUser = void 0;
|
|
27
|
-
// PARSERS
|
|
28
|
-
var Parsers = __importStar(require("./Parser"));
|
|
29
|
-
/**
|
|
30
|
-
* @returns A User object containing the user details
|
|
31
|
-
* @param data The raw user data from Twitter API
|
|
32
|
-
*/
|
|
33
|
-
function toUser(data) {
|
|
34
|
-
return {
|
|
35
|
-
id: data.rest_id,
|
|
36
|
-
userName: data.legacy.screen_name,
|
|
37
|
-
fullName: data.legacy.name,
|
|
38
|
-
createdAt: data.legacy.created_at,
|
|
39
|
-
description: data.legacy.description,
|
|
40
|
-
isVerified: data.legacy.verified,
|
|
41
|
-
favouritesCount: data.legacy.favourites_count,
|
|
42
|
-
followersCount: data.legacy.followers_count,
|
|
43
|
-
followingsCount: data.legacy.friends_count,
|
|
44
|
-
statusesCount: data.legacy.statuses_count,
|
|
45
|
-
location: data.legacy.location,
|
|
46
|
-
pinnedTweet: data.legacy.pinned_tweet_ids_str[0],
|
|
47
|
-
profileBanner: data.legacy.profile_banner_url,
|
|
48
|
-
profileImage: data.legacy.profile_image_url_https
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
exports.toUser = toUser;
|
|
52
|
-
/**
|
|
53
|
-
* @returns A TweetEntities object containing the various tweet entities
|
|
54
|
-
* @param data The raw tweet entities data from the response received from TwitterAPI
|
|
55
|
-
*/
|
|
56
|
-
function toTweetEntities(data) {
|
|
57
|
-
var entities = {
|
|
58
|
-
mentionedUsers: [],
|
|
59
|
-
urls: [],
|
|
60
|
-
media: [],
|
|
61
|
-
hashtags: []
|
|
62
|
-
};
|
|
63
|
-
// Extracting user mentions
|
|
64
|
-
if (data.user_mentions) {
|
|
65
|
-
for (var _i = 0, _a = data.user_mentions; _i < _a.length; _i++) {
|
|
66
|
-
var user = _a[_i];
|
|
67
|
-
entities.mentionedUsers.push(user.id_str);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Extracting urls
|
|
71
|
-
if (data.urls) {
|
|
72
|
-
for (var _b = 0, _c = data.urls; _b < _c.length; _b++) {
|
|
73
|
-
var url = _c[_b];
|
|
74
|
-
entities.urls.push(url.expanded_url);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Extracting hashtags
|
|
78
|
-
if (data.hashtags) {
|
|
79
|
-
for (var _d = 0, _e = data.hashtags; _d < _e.length; _d++) {
|
|
80
|
-
var hashtag = _e[_d];
|
|
81
|
-
entities.hashtags.push(hashtag.text);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Extracting media urls (if any)
|
|
85
|
-
if (data.media) {
|
|
86
|
-
for (var _f = 0, _g = data.media; _f < _g.length; _f++) {
|
|
87
|
-
var media = _g[_f];
|
|
88
|
-
entities.media.push(media.media_url_https);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return entities;
|
|
92
|
-
}
|
|
93
|
-
exports.toTweetEntities = toTweetEntities;
|
|
94
|
-
/**
|
|
95
|
-
* @returns A Tweet object containing the tweet data
|
|
96
|
-
* @param data The raw tweet data from the response received from TwitterAPI
|
|
97
|
-
*/
|
|
98
|
-
function toTweet(data) {
|
|
99
|
-
return {
|
|
100
|
-
id: data.rest_id,
|
|
101
|
-
createdAt: data.legacy.created_at,
|
|
102
|
-
tweetBy: data.legacy.user_id_str,
|
|
103
|
-
entities: toTweetEntities(data.legacy.entities),
|
|
104
|
-
quoted: data.legacy.quoted_status_id_str,
|
|
105
|
-
fullText: Parsers.normalizeText(data.legacy.full_text),
|
|
106
|
-
replyTo: data.legacy.in_reply_to_status_id_str,
|
|
107
|
-
lang: data.legacy.lang,
|
|
108
|
-
quoteCount: data.legacy.quote_count,
|
|
109
|
-
replyCount: data.legacy.reply_count,
|
|
110
|
-
retweetCount: data.legacy.retweet_count,
|
|
111
|
-
likeCount: data.legacy.favorite_count
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
exports.toTweet = toTweet;
|
|
115
|
-
//# sourceMappingURL=Deserializers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Deserializers.js","sourceRoot":"","sources":["../../../src/services/helper/Deserializers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,UAAU;AACV,gDAAoC;AAEpC;;;GAGG;AACH,SAAgB,MAAM,CAAC,IAAa;IAChC,OAAO;QACH,EAAE,EAAE,IAAI,CAAC,OAAO;QAChB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;QACjC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;QAC1B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;QACjC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;QACpC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;QAChC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;QAC7C,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe;QAC3C,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa;QAC1C,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;QACzC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;QAC9B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAChD,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,kBAAkB;QAC7C,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,uBAAuB;KACpD,CAAC;AACN,CAAC;AAjBD,wBAiBC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,IAAsB;IAClD,IAAI,QAAQ,GAAkB;QAC1B,cAA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