rettiwt-api 2.7.1 → 3.0.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.
Files changed (139) hide show
  1. package/.eslintrc.js +73 -5
  2. package/.tool-versions +1 -0
  3. package/README.md +87 -20
  4. package/dist/Rettiwt.js +0 -1
  5. package/dist/Rettiwt.js.map +1 -1
  6. package/dist/cli.js +2 -4
  7. package/dist/cli.js.map +1 -1
  8. package/dist/collections/Extractors.d.ts +10 -0
  9. package/dist/collections/Extractors.js +43 -0
  10. package/dist/collections/Extractors.js.map +1 -0
  11. package/dist/collections/Groups.d.ts +19 -0
  12. package/dist/collections/Groups.js +55 -0
  13. package/dist/collections/Groups.js.map +1 -0
  14. package/dist/collections/Requests.d.ts +12 -0
  15. package/dist/collections/Requests.js +46 -0
  16. package/dist/collections/Requests.js.map +1 -0
  17. package/dist/commands/Auth.d.ts +6 -0
  18. package/dist/commands/Auth.js +26 -8
  19. package/dist/commands/Auth.js.map +1 -1
  20. package/dist/commands/Tweet.js +237 -82
  21. package/dist/commands/Tweet.js.map +1 -1
  22. package/dist/commands/User.js +197 -36
  23. package/dist/commands/User.js.map +1 -1
  24. package/dist/enums/Api.d.ts +30 -0
  25. package/dist/enums/Api.js +32 -1
  26. package/dist/enums/Api.js.map +1 -1
  27. package/dist/enums/Data.d.ts +9 -0
  28. package/dist/enums/Data.js +14 -0
  29. package/dist/enums/Data.js.map +1 -0
  30. package/dist/enums/Http.d.ts +1 -1
  31. package/dist/enums/Http.js +1 -1
  32. package/dist/enums/Logging.d.ts +6 -5
  33. package/dist/enums/Logging.js +6 -5
  34. package/dist/enums/Logging.js.map +1 -1
  35. package/dist/enums/Resource.d.ts +33 -0
  36. package/dist/enums/Resource.js +42 -0
  37. package/dist/enums/Resource.js.map +1 -0
  38. package/dist/helper/CliUtils.d.ts +1 -1
  39. package/dist/helper/CliUtils.js.map +1 -1
  40. package/dist/index.d.ts +11 -9
  41. package/dist/index.js +11 -14
  42. package/dist/index.js.map +1 -1
  43. package/dist/models/args/FetchArgs.d.ts +129 -0
  44. package/dist/models/args/FetchArgs.js +263 -0
  45. package/dist/models/args/FetchArgs.js.map +1 -0
  46. package/dist/models/args/PostArgs.d.ts +116 -0
  47. package/dist/models/args/PostArgs.js +232 -0
  48. package/dist/models/args/PostArgs.js.map +1 -0
  49. package/dist/models/data/CursoredData.d.ts +11 -11
  50. package/dist/models/data/CursoredData.js +21 -16
  51. package/dist/models/data/CursoredData.js.map +1 -1
  52. package/dist/models/data/List.d.ts +8 -10
  53. package/dist/models/data/List.js +2 -4
  54. package/dist/models/data/List.js.map +1 -1
  55. package/dist/models/data/Tweet.d.ts +41 -29
  56. package/dist/models/data/Tweet.js +71 -15
  57. package/dist/models/data/Tweet.js.map +1 -1
  58. package/dist/models/data/User.d.ts +36 -20
  59. package/dist/models/data/User.js +69 -7
  60. package/dist/models/data/User.js.map +1 -1
  61. package/dist/models/errors/ApiError.d.ts +1 -3
  62. package/dist/models/errors/ApiError.js +1 -4
  63. package/dist/models/errors/ApiError.js.map +1 -1
  64. package/dist/models/errors/DataValidationError.d.ts +30 -0
  65. package/dist/models/errors/DataValidationError.js +34 -0
  66. package/dist/models/errors/DataValidationError.js.map +1 -0
  67. package/dist/models/errors/HttpError.d.ts +1 -3
  68. package/dist/models/errors/HttpError.js +1 -4
  69. package/dist/models/errors/HttpError.js.map +1 -1
  70. package/dist/models/errors/TimeoutError.d.ts +2 -4
  71. package/dist/models/errors/TimeoutError.js +2 -5
  72. package/dist/models/errors/TimeoutError.js.map +1 -1
  73. package/dist/services/internal/ErrorService.d.ts +45 -35
  74. package/dist/services/internal/ErrorService.js +70 -68
  75. package/dist/services/internal/ErrorService.js.map +1 -1
  76. package/dist/services/internal/LogService.d.ts +7 -5
  77. package/dist/services/internal/LogService.js +28 -9
  78. package/dist/services/internal/LogService.js.map +1 -1
  79. package/dist/services/public/AuthService.d.ts +24 -20
  80. package/dist/services/public/AuthService.js +38 -36
  81. package/dist/services/public/AuthService.js.map +1 -1
  82. package/dist/services/public/FetcherService.d.ts +99 -0
  83. package/dist/services/public/FetcherService.js +254 -0
  84. package/dist/services/public/FetcherService.js.map +1 -0
  85. package/dist/services/public/TweetService.d.ts +213 -94
  86. package/dist/services/public/TweetService.js +405 -208
  87. package/dist/services/public/TweetService.js.map +1 -1
  88. package/dist/services/public/UserService.d.ts +185 -52
  89. package/dist/services/public/UserService.js +333 -103
  90. package/dist/services/public/UserService.js.map +1 -1
  91. package/dist/types/ReturnTypes.d.ts +21 -0
  92. package/dist/types/ReturnTypes.js +3 -0
  93. package/dist/types/ReturnTypes.js.map +1 -0
  94. package/package.json +4 -2
  95. package/src/Rettiwt.ts +0 -3
  96. package/src/cli.ts +2 -4
  97. package/src/collections/Extractors.ts +63 -0
  98. package/src/collections/Groups.ts +54 -0
  99. package/src/collections/Requests.ts +52 -0
  100. package/src/commands/Auth.ts +19 -7
  101. package/src/commands/Tweet.ts +179 -91
  102. package/src/commands/User.ts +118 -25
  103. package/src/enums/Api.ts +31 -0
  104. package/src/enums/Data.ts +9 -0
  105. package/src/enums/Http.ts +1 -1
  106. package/src/enums/Logging.ts +6 -5
  107. package/src/enums/Resource.ts +40 -0
  108. package/src/helper/CliUtils.ts +1 -1
  109. package/src/index.ts +41 -14
  110. package/src/models/args/FetchArgs.ts +296 -0
  111. package/src/models/args/PostArgs.ts +263 -0
  112. package/src/models/data/CursoredData.ts +23 -15
  113. package/src/models/data/List.ts +12 -15
  114. package/src/models/data/Tweet.ts +105 -39
  115. package/src/models/data/User.ts +97 -30
  116. package/src/models/errors/ApiError.ts +1 -4
  117. package/src/models/errors/DataValidationError.ts +44 -0
  118. package/src/models/errors/HttpError.ts +1 -4
  119. package/src/models/errors/TimeoutError.ts +2 -5
  120. package/src/services/internal/ErrorService.ts +76 -75
  121. package/src/services/internal/LogService.ts +20 -10
  122. package/src/services/public/AuthService.ts +39 -38
  123. package/src/services/public/FetcherService.ts +230 -0
  124. package/src/services/public/TweetService.ts +381 -179
  125. package/src/services/public/UserService.ts +314 -86
  126. package/src/types/RettiwtConfig.ts +0 -1
  127. package/src/types/ReturnTypes.ts +24 -0
  128. package/dist/models/args/TweetArgs.d.ts +0 -44
  129. package/dist/models/args/TweetArgs.js +0 -82
  130. package/dist/models/args/TweetArgs.js.map +0 -1
  131. package/dist/models/data/Media.d.ts +0 -14
  132. package/dist/models/data/Media.js +0 -19
  133. package/dist/models/data/Media.js.map +0 -1
  134. package/dist/services/internal/FetcherService.d.ts +0 -106
  135. package/dist/services/internal/FetcherService.js +0 -365
  136. package/dist/services/internal/FetcherService.js.map +0 -1
  137. package/src/models/args/TweetArgs.ts +0 -98
  138. package/src/models/data/Media.ts +0 -19
  139. package/src/services/internal/FetcherService.ts +0 -365
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TweetMediaArgs = exports.TweetArgs = void 0;
13
- // PACKAGES
14
- var class_validator_1 = require("class-validator");
15
- var rettiwt_core_1 = require("rettiwt-core");
16
- /**
17
- * The arguments specifying the tweet to be posted.
18
- */
19
- var TweetArgs = exports.TweetArgs = /** @class */ (function () {
20
- /**
21
- * @param tweet - The tweet arguments specifying the tweet.
22
- */
23
- function TweetArgs(tweet) {
24
- this.text = tweet.text;
25
- this.media = tweet.media ? tweet.media.map(function (item) { return new TweetMediaArgs(item); }) : undefined;
26
- // Validating this object
27
- var validationResult = (0, class_validator_1.validateSync)(this);
28
- // If validation error occured
29
- if (validationResult.length) {
30
- throw new rettiwt_core_1.DataValidationError(validationResult);
31
- }
32
- }
33
- __decorate([
34
- (0, class_validator_1.IsNotEmpty)(),
35
- (0, class_validator_1.IsString)(),
36
- (0, class_validator_1.MaxLength)(280),
37
- __metadata("design:type", String)
38
- ], TweetArgs.prototype, "text", void 0);
39
- __decorate([
40
- (0, class_validator_1.IsOptional)(),
41
- (0, class_validator_1.IsArray)(),
42
- (0, class_validator_1.ArrayMaxSize)(4),
43
- (0, class_validator_1.IsObject)({ each: true }),
44
- __metadata("design:type", Array)
45
- ], TweetArgs.prototype, "media", void 0);
46
- return TweetArgs;
47
- }());
48
- /**
49
- * The arguments specifying the media to be posted in a single tweet.
50
- *
51
- * @public
52
- */
53
- var TweetMediaArgs = exports.TweetMediaArgs = /** @class */ (function () {
54
- /**
55
- * @param media - The media arguments specifying the media.
56
- */
57
- function TweetMediaArgs(media) {
58
- var _a;
59
- this.path = media.path;
60
- this.tags = (_a = media.tags) !== null && _a !== void 0 ? _a : [];
61
- // Validating this object
62
- var validationResult = (0, class_validator_1.validateSync)(this);
63
- // If validation error occured
64
- if (validationResult.length) {
65
- throw new rettiwt_core_1.DataValidationError(validationResult);
66
- }
67
- }
68
- __decorate([
69
- (0, class_validator_1.IsNotEmpty)(),
70
- (0, class_validator_1.IsString)(),
71
- __metadata("design:type", String)
72
- ], TweetMediaArgs.prototype, "path", void 0);
73
- __decorate([
74
- (0, class_validator_1.IsOptional)(),
75
- (0, class_validator_1.IsArray)(),
76
- (0, class_validator_1.ArrayMaxSize)(10),
77
- (0, class_validator_1.IsNumberString)(undefined, { each: true }),
78
- __metadata("design:type", Array)
79
- ], TweetMediaArgs.prototype, "tags", void 0);
80
- return TweetMediaArgs;
81
- }());
82
- //# sourceMappingURL=TweetArgs.js.map
@@ -1 +0,0 @@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AC9B,IAAI,gBAAgB,CAAC,MAAM,EAAE;YAC5B,MAAM,IAAI,kCAAmB,CAAC,gBAAgB,CAAC,CAAC;SAChD;IACF,CAAC;IA3BM;QAFN,IAAA,4BAAU,GAAE;QACZ,IAAA,0BAAQ,GAAE;;gDACS;IAWb;QAJN,IAAA,4BAAU,GAAE;QACZ,IAAA,yBAAO,GAAE;QACT,IAAA,8BAAY,EAAC,EAAE,CAAC;QAChB,IAAA,gCAAc,EAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;gDACnB;IAiBxB,qBAAC;CAAA,AApCD,IAoCC"}
@@ -1,14 +0,0 @@
1
- import { IMediaUploadInitializeResponse } from 'rettiwt-core';
2
- /**
3
- * The details of a single media file.
4
- *
5
- * @public
6
- */
7
- export declare class Media {
8
- /** The id of the media. */
9
- id: string;
10
- /**
11
- * @param media - The raw media data.
12
- */
13
- constructor(media: IMediaUploadInitializeResponse);
14
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Media = void 0;
4
- /**
5
- * The details of a single media file.
6
- *
7
- * @public
8
- */
9
- var Media = /** @class */ (function () {
10
- /**
11
- * @param media - The raw media data.
12
- */
13
- function Media(media) {
14
- this.id = media.media_id_string;
15
- }
16
- return Media;
17
- }());
18
- exports.Media = Media;
19
- //# sourceMappingURL=Media.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Media.js","sourceRoot":"","sources":["../../../src/models/data/Media.ts"],"names":[],"mappings":";;;AAGA;;;;GAIG;AACH;IAIC;;OAEG;IACH,eAAmB,KAAqC;QACvD,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC;IACjC,CAAC;IACF,YAAC;AAAD,CAAC,AAVD,IAUC;AAVY,sBAAK"}
@@ -1,106 +0,0 @@
1
- import { FetchArgs, PostArgs, EResourceType } from 'rettiwt-core';
2
- import { IRettiwtConfig } from '../../types/RettiwtConfig';
3
- import { CursoredData } from '../../models/data/CursoredData';
4
- import { Tweet } from '../../models/data/Tweet';
5
- import { User } from '../../models/data/User';
6
- /**
7
- * The base service that handles all HTTP requests.
8
- *
9
- * @internal
10
- */
11
- export declare class FetcherService {
12
- /** The credential to use for authenticating against Twitter API. */
13
- private cred?;
14
- /** Whether the instance is authenticated or not. */
15
- private readonly isAuthenticated;
16
- /** The URL to the proxy server to use for authentication. */
17
- protected readonly authProxyUrl?: URL;
18
- /** The HTTPS Agent to use for requests to Twitter API. */
19
- private readonly httpsAgent;
20
- /** The max wait time for a response. */
21
- private readonly timeout;
22
- /** The log service instance to use to logging. */
23
- private readonly logger;
24
- /** The service used to handle HTTP and API errors */
25
- private readonly errorHandler;
26
- /**
27
- * @param config - The config object for configuring the Rettiwt instance.
28
- */
29
- constructor(config?: IRettiwtConfig);
30
- /**
31
- * Returns an AuthCredential generated using the given API key.
32
- *
33
- * @param apiKey - The API key to use for authenticating.
34
- * @returns The generated AuthCredential.
35
- */
36
- private getAuthCredential;
37
- /**
38
- * Returns an AuthCredential generated using the given guest key.
39
- *
40
- * @param guestKey - The guest key to use for authenticating as guest.
41
- * @returns The generated AuthCredential.
42
- */
43
- private getGuestCredential;
44
- /**
45
- * Checks the authorization status based on the requested resource.
46
- *
47
- * @param resourceType - The type of resource to fetch.
48
- * @throws An error if not authorized to access the requested resource.
49
- */
50
- private checkAuthorization;
51
- /**
52
- * Gets the HttpsAgent based on whether a proxy is used or not.
53
- *
54
- * @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
55
- * @returns The HttpsAgent to use.
56
- */
57
- private getHttpsAgent;
58
- /**
59
- * Makes an HTTP request according to the given parameters.
60
- *
61
- * @typeParam ResType - The type of the returned response data.
62
- * @param config - The request configuration.
63
- * @returns The response received.
64
- */
65
- private request;
66
- /**
67
- * Extracts the required data based on the type of resource passed as argument.
68
- *
69
- * @param data - The data from which extraction is to be done.
70
- * @param type - The type of data to extract.
71
- * @returns The extracted data.
72
- */
73
- private extractData;
74
- /**
75
- * Deserializes the extracted data into a cursored list.
76
- *
77
- * @param extractedData - The list of extracted data.
78
- * @param next - The cursor to the next batch of data.
79
- * @returns The cursored data object.
80
- */
81
- private deserializeData;
82
- /**
83
- * Fetches the requested resource from Twitter and returns it after processing.
84
- *
85
- * @param resourceType - The type of resource to fetch.
86
- * @param args - Resource specific arguments.
87
- * @typeParam OutType - The type of deserialized data returned.
88
- * @returns The processed data requested from Twitter.
89
- */
90
- protected fetch<OutType extends Tweet | User>(resourceType: EResourceType, args: FetchArgs): Promise<CursoredData<OutType>>;
91
- /**
92
- * Posts the requested resource to Twitter and returns the response.
93
- *
94
- * @param resourceType - The type of resource to post.
95
- * @param args - Resource specific arguments.
96
- * @returns Whether posting was successful or not.
97
- */
98
- protected post(resourceType: EResourceType, args: PostArgs): Promise<boolean>;
99
- /**
100
- * Uploads the given media file to Twitter
101
- *
102
- * @param media - The path to the media file to upload.
103
- * @returns The id of the uploaded media.
104
- */
105
- protected upload(media: string): Promise<string>;
106
- }
@@ -1,365 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.FetcherService = void 0;
54
- // PACKAGES
55
- var rettiwt_core_1 = require("rettiwt-core");
56
- var axios_1 = __importDefault(require("axios"));
57
- var https_1 = __importDefault(require("https"));
58
- var rettiwt_auth_1 = require("rettiwt-auth");
59
- var https_proxy_agent_1 = require("https-proxy-agent");
60
- // SERVICES
61
- var ErrorService_1 = require("./ErrorService");
62
- var LogService_1 = require("./LogService");
63
- // ENUMS
64
- var Api_1 = require("../../enums/Api");
65
- var Logging_1 = require("../../enums/Logging");
66
- // MODELS
67
- var CursoredData_1 = require("../../models/data/CursoredData");
68
- var Tweet_1 = require("../../models/data/Tweet");
69
- var User_1 = require("../../models/data/User");
70
- // HELPERS
71
- var JsonUtils_1 = require("../../helper/JsonUtils");
72
- var fs_1 = require("fs");
73
- /**
74
- * The base service that handles all HTTP requests.
75
- *
76
- * @internal
77
- */
78
- var FetcherService = /** @class */ (function () {
79
- /**
80
- * @param config - The config object for configuring the Rettiwt instance.
81
- */
82
- function FetcherService(config) {
83
- var _a, _b, _c;
84
- // If API key is supplied
85
- if (config === null || config === void 0 ? void 0 : config.apiKey) {
86
- this.cred = this.getAuthCredential(config.apiKey);
87
- }
88
- // If guest key is supplied
89
- else if (config === null || config === void 0 ? void 0 : config.guestKey) {
90
- this.cred = this.getGuestCredential(config.guestKey);
91
- }
92
- // If no key is supplied
93
- else {
94
- this.cred = undefined;
95
- }
96
- this.isAuthenticated = (config === null || config === void 0 ? void 0 : config.apiKey) ? true : false;
97
- this.authProxyUrl = (_a = config === null || config === void 0 ? void 0 : config.authProxyUrl) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config.proxyUrl;
98
- this.httpsAgent = this.getHttpsAgent(config === null || config === void 0 ? void 0 : config.proxyUrl);
99
- this.timeout = (_b = config === null || config === void 0 ? void 0 : config.timeout) !== null && _b !== void 0 ? _b : 0;
100
- this.logger = new LogService_1.LogService(config === null || config === void 0 ? void 0 : config.logging);
101
- this.errorHandler = (_c = config === null || config === void 0 ? void 0 : config.errorHandler) !== null && _c !== void 0 ? _c : new ErrorService_1.ErrorService();
102
- }
103
- /**
104
- * Returns an AuthCredential generated using the given API key.
105
- *
106
- * @param apiKey - The API key to use for authenticating.
107
- * @returns The generated AuthCredential.
108
- */
109
- FetcherService.prototype.getAuthCredential = function (apiKey) {
110
- // Converting apiKey from base64 to string
111
- apiKey = Buffer.from(apiKey, 'base64').toString('ascii');
112
- return new rettiwt_auth_1.AuthCredential(apiKey.split(';'));
113
- };
114
- /**
115
- * Returns an AuthCredential generated using the given guest key.
116
- *
117
- * @param guestKey - The guest key to use for authenticating as guest.
118
- * @returns The generated AuthCredential.
119
- */
120
- FetcherService.prototype.getGuestCredential = function (guestKey) {
121
- return new rettiwt_auth_1.AuthCredential(undefined, guestKey);
122
- };
123
- /**
124
- * Checks the authorization status based on the requested resource.
125
- *
126
- * @param resourceType - The type of resource to fetch.
127
- * @throws An error if not authorized to access the requested resource.
128
- */
129
- FetcherService.prototype.checkAuthorization = function (resourceType) {
130
- // Logging
131
- this.logger.log(Logging_1.ELogActions.AUTHORIZATION, { authenticated: this.isAuthenticated });
132
- // Checking authorization status
133
- if (resourceType != rettiwt_core_1.EResourceType.TWEET_DETAILS &&
134
- resourceType != rettiwt_core_1.EResourceType.USER_DETAILS &&
135
- resourceType != rettiwt_core_1.EResourceType.USER_TWEETS &&
136
- this.isAuthenticated == false) {
137
- throw new Error(Api_1.EApiErrors.RESOURCE_NOT_ALLOWED);
138
- }
139
- };
140
- /**
141
- * Gets the HttpsAgent based on whether a proxy is used or not.
142
- *
143
- * @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
144
- * @returns The HttpsAgent to use.
145
- */
146
- FetcherService.prototype.getHttpsAgent = function (proxyUrl) {
147
- if (proxyUrl) {
148
- return new https_proxy_agent_1.HttpsProxyAgent(proxyUrl);
149
- }
150
- return new https_1.default.Agent();
151
- };
152
- /**
153
- * Makes an HTTP request according to the given parameters.
154
- *
155
- * @typeParam ResType - The type of the returned response data.
156
- * @param config - The request configuration.
157
- * @returns The response received.
158
- */
159
- FetcherService.prototype.request = function (config) {
160
- var _a;
161
- return __awaiter(this, void 0, void 0, function () {
162
- var _b, _c;
163
- var _this = this;
164
- return __generator(this, function (_d) {
165
- switch (_d.label) {
166
- case 0:
167
- // Checking authorization for the requested resource
168
- this.checkAuthorization(config.url);
169
- // If not authenticated, use guest authentication
170
- _b = this;
171
- if (!((_a = this.cred) !== null && _a !== void 0)) return [3 /*break*/, 1];
172
- _c = _a;
173
- return [3 /*break*/, 3];
174
- case 1: return [4 /*yield*/, new rettiwt_auth_1.Auth({ proxyUrl: this.authProxyUrl }).getGuestCredential()];
175
- case 2:
176
- _c = (_d.sent());
177
- _d.label = 3;
178
- case 3:
179
- // If not authenticated, use guest authentication
180
- _b.cred = _c;
181
- // Setting additional request parameters
182
- config.headers = __assign(__assign({}, config.headers), this.cred.toHeader());
183
- config.httpAgent = this.httpsAgent;
184
- config.httpsAgent = this.httpsAgent;
185
- config.timeout = this.timeout;
186
- return [4 /*yield*/, (0, axios_1.default)(config).catch(function (error) {
187
- _this.errorHandler.handle(error);
188
- throw error;
189
- })];
190
- case 4:
191
- /**
192
- * If Axios request results in an error, catch it and rethrow a more specific error.
193
- */
194
- return [2 /*return*/, _d.sent()];
195
- }
196
- });
197
- });
198
- };
199
- /**
200
- * Extracts the required data based on the type of resource passed as argument.
201
- *
202
- * @param data - The data from which extraction is to be done.
203
- * @param type - The type of data to extract.
204
- * @returns The extracted data.
205
- */
206
- FetcherService.prototype.extractData = function (data, type) {
207
- var _a;
208
- /**
209
- * The required extracted data.
210
- */
211
- var required = [];
212
- if (type == rettiwt_core_1.EResourceType.TWEET_DETAILS) {
213
- required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'Tweet');
214
- }
215
- else if (type == rettiwt_core_1.EResourceType.USER_DETAILS || type == rettiwt_core_1.EResourceType.USER_DETAILS_BY_ID) {
216
- required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'User');
217
- }
218
- else if (type == rettiwt_core_1.EResourceType.TWEET_SEARCH ||
219
- type == rettiwt_core_1.EResourceType.USER_LIKES ||
220
- type == rettiwt_core_1.EResourceType.LIST_TWEETS ||
221
- type == rettiwt_core_1.EResourceType.USER_TWEETS ||
222
- type == rettiwt_core_1.EResourceType.USER_TWEETS_AND_REPLIES) {
223
- required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineTweet').map(function (item) { return item.tweet_results.result; });
224
- }
225
- else if (type == rettiwt_core_1.EResourceType.TWEET_FAVORITERS ||
226
- type == rettiwt_core_1.EResourceType.TWEET_RETWEETERS ||
227
- type == rettiwt_core_1.EResourceType.USER_FOLLOWERS ||
228
- type == rettiwt_core_1.EResourceType.USER_FOLLOWING) {
229
- required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineUser').map(function (item) { return item.user_results.result; });
230
- }
231
- return {
232
- required: required,
233
- next: (_a = (0, JsonUtils_1.findByFilter)(data, 'cursorType', 'Bottom')[0]) === null || _a === void 0 ? void 0 : _a.value,
234
- };
235
- };
236
- /**
237
- * Deserializes the extracted data into a cursored list.
238
- *
239
- * @param extractedData - The list of extracted data.
240
- * @param next - The cursor to the next batch of data.
241
- * @returns The cursored data object.
242
- */
243
- FetcherService.prototype.deserializeData = function (extractedData, next) {
244
- if (extractedData === void 0) { extractedData = []; }
245
- if (next === void 0) { next = ''; }
246
- /** The list of deserialized data. */
247
- var deserializedList = [];
248
- // Deserializing the extracted raw data and storing it in the list
249
- for (var _i = 0, extractedData_1 = extractedData; _i < extractedData_1.length; _i++) {
250
- var item = extractedData_1[_i];
251
- // If the item is a valid raw tweet
252
- if (item && item.__typename == 'Tweet' && item.rest_id && item.legacy) {
253
- // Logging
254
- this.logger.log(Logging_1.ELogActions.DESERIALIZE, { type: item.__typename, id: item.rest_id });
255
- // Adding deserialized Tweet to list
256
- deserializedList.push(new Tweet_1.Tweet(item));
257
- }
258
- // If the item is a valid raw user
259
- else if (item && item.__typename == 'User' && item.rest_id && item.id && item.legacy) {
260
- // Logging
261
- this.logger.log(Logging_1.ELogActions.DESERIALIZE, { type: item.__typename, id: item.rest_id });
262
- // Adding deserialized User to list
263
- deserializedList.push(new User_1.User(item));
264
- }
265
- }
266
- return new CursoredData_1.CursoredData(deserializedList, next);
267
- };
268
- /**
269
- * Fetches the requested resource from Twitter and returns it after processing.
270
- *
271
- * @param resourceType - The type of resource to fetch.
272
- * @param args - Resource specific arguments.
273
- * @typeParam OutType - The type of deserialized data returned.
274
- * @returns The processed data requested from Twitter.
275
- */
276
- FetcherService.prototype.fetch = function (resourceType, args) {
277
- return __awaiter(this, void 0, void 0, function () {
278
- var request, res, extractedData, deserializedData;
279
- return __generator(this, function (_a) {
280
- switch (_a.label) {
281
- case 0:
282
- // Logging
283
- this.logger.log(Logging_1.ELogActions.FETCH, { resourceType: resourceType, args: args });
284
- request = new rettiwt_core_1.Request(resourceType, args).toAxiosRequestConfig();
285
- return [4 /*yield*/, this.request(request).then(function (res) { return res.data; })];
286
- case 1:
287
- res = _a.sent();
288
- extractedData = this.extractData(res, resourceType);
289
- deserializedData = this.deserializeData(extractedData.required, extractedData.next);
290
- return [2 /*return*/, deserializedData];
291
- }
292
- });
293
- });
294
- };
295
- /**
296
- * Posts the requested resource to Twitter and returns the response.
297
- *
298
- * @param resourceType - The type of resource to post.
299
- * @param args - Resource specific arguments.
300
- * @returns Whether posting was successful or not.
301
- */
302
- FetcherService.prototype.post = function (resourceType, args) {
303
- return __awaiter(this, void 0, void 0, function () {
304
- var request;
305
- return __generator(this, function (_a) {
306
- switch (_a.label) {
307
- case 0:
308
- // Logging
309
- this.logger.log(Logging_1.ELogActions.POST, { resourceType: resourceType, args: args });
310
- request = new rettiwt_core_1.Request(resourceType, args).toAxiosRequestConfig();
311
- // Posting the data
312
- return [4 /*yield*/, this.request(request)];
313
- case 1:
314
- // Posting the data
315
- _a.sent();
316
- return [2 /*return*/, true];
317
- }
318
- });
319
- });
320
- };
321
- /**
322
- * Uploads the given media file to Twitter
323
- *
324
- * @param media - The path to the media file to upload.
325
- * @returns The id of the uploaded media.
326
- */
327
- FetcherService.prototype.upload = function (media) {
328
- return __awaiter(this, void 0, void 0, function () {
329
- var id;
330
- return __generator(this, function (_a) {
331
- switch (_a.label) {
332
- case 0:
333
- // INITIALIZE
334
- // Logging
335
- this.logger.log(Logging_1.ELogActions.UPLOAD, { step: rettiwt_core_1.EUploadSteps.INITIALIZE });
336
- return [4 /*yield*/, this.request(new rettiwt_core_1.Request(rettiwt_core_1.EResourceType.MEDIA_UPLOAD, {
337
- upload: { step: rettiwt_core_1.EUploadSteps.INITIALIZE, size: (0, fs_1.statSync)(media).size },
338
- }).toAxiosRequestConfig())];
339
- case 1:
340
- id = (_a.sent()).data.media_id_string;
341
- // APPEND
342
- // Logging
343
- this.logger.log(Logging_1.ELogActions.UPLOAD, { step: rettiwt_core_1.EUploadSteps.APPEND });
344
- return [4 /*yield*/, this.request(new rettiwt_core_1.Request(rettiwt_core_1.EResourceType.MEDIA_UPLOAD, {
345
- upload: { step: rettiwt_core_1.EUploadSteps.APPEND, id: id, media: media },
346
- }).toAxiosRequestConfig())];
347
- case 2:
348
- _a.sent();
349
- // FINALIZE
350
- // Logging
351
- this.logger.log(Logging_1.ELogActions.UPLOAD, { step: rettiwt_core_1.EUploadSteps.APPEND });
352
- return [4 /*yield*/, this.request(new rettiwt_core_1.Request(rettiwt_core_1.EResourceType.MEDIA_UPLOAD, {
353
- upload: { step: rettiwt_core_1.EUploadSteps.FINALIZE, id: id },
354
- }).toAxiosRequestConfig())];
355
- case 3:
356
- _a.sent();
357
- return [2 /*return*/, id];
358
- }
359
- });
360
- });
361
- };
362
- return FetcherService;
363
- }());
364
- exports.FetcherService = FetcherService;
365
- //# sourceMappingURL=FetcherService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../../src/services/internal/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAasB;AACtB,gDAAiE;AACjE,gDAAqC;AACrC,6CAAoD;AACpD,uDAAoD;AAEpD,WAAW;AACX,+CAA8C;AAC9C,2CAA0C;A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