rettiwt-api 2.7.0 → 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
package/dist/index.js CHANGED
@@ -14,32 +14,29 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.TweetFilter = void 0;
18
17
  // MAIN
19
18
  __exportStar(require("./Rettiwt"), exports);
20
- // EXTERNAL
21
- var rettiwt_core_1 = require("rettiwt-core");
22
- Object.defineProperty(exports, "TweetFilter", { enumerable: true, get: function () { return rettiwt_core_1.TweetFilter; } });
23
19
  // ENUMS
24
20
  __exportStar(require("./enums/Api"), exports);
25
21
  __exportStar(require("./enums/Http"), exports);
26
- __exportStar(require("./enums/Logging"), exports);
27
- // ARGS MODELS
28
- __exportStar(require("./models/args/TweetArgs"), exports);
29
- // ERROR MODELS
30
- __exportStar(require("./models/errors/ApiError"), exports);
31
- __exportStar(require("./models/errors/HttpError"), exports);
32
- __exportStar(require("./models/errors/RettiwtError"), exports);
22
+ __exportStar(require("./enums/Resource"), exports);
23
+ // ARG MODELS
24
+ __exportStar(require("./models/args/FetchArgs"), exports);
25
+ __exportStar(require("./models/args/PostArgs"), exports);
33
26
  // DATA MODELS
34
27
  __exportStar(require("./models/data/CursoredData"), exports);
35
28
  __exportStar(require("./models/data/List"), exports);
36
29
  __exportStar(require("./models/data/Tweet"), exports);
37
30
  __exportStar(require("./models/data/User"), exports);
31
+ // ERROR MODELS
32
+ __exportStar(require("./models/errors/ApiError"), exports);
33
+ __exportStar(require("./models/errors/DataValidationError"), exports);
34
+ __exportStar(require("./models/errors/HttpError"), exports);
35
+ __exportStar(require("./models/errors/RettiwtError"), exports);
36
+ __exportStar(require("./models/errors/TimeoutError"), exports);
38
37
  // SERVICES
39
- __exportStar(require("./services/internal/ErrorService"), exports);
40
- __exportStar(require("./services/internal/FetcherService"), exports);
41
- __exportStar(require("./services/internal/LogService"), exports);
42
38
  __exportStar(require("./services/public/AuthService"), exports);
39
+ __exportStar(require("./services/public/FetcherService"), exports);
43
40
  __exportStar(require("./services/public/TweetService"), exports);
44
41
  __exportStar(require("./services/public/UserService"), exports);
45
42
  // TYPES
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAO;AACP,4CAA0B;AAE1B,WAAW;AACX,6CAA2C;AAAlC,2GAAA,WAAW,OAAA;AAEpB,QAAQ;AACR,8CAA4B;AAC5B,+CAA6B;AAC7B,kDAAgC;AAEhC,cAAc;AACd,0DAAwC;AAExC,eAAe;AACf,2DAAyC;AACzC,4DAA0C;AAC1C,+DAA6C;AAE7C,cAAc;AACd,6DAA2C;AAC3C,qDAAmC;AACnC,sDAAoC;AACpC,qDAAmC;AAEnC,WAAW;AACX,mEAAiD;AACjD,qEAAmD;AACnD,iEAA+C;AAC/C,gEAA8C;AAC9C,iEAA+C;AAC/C,gEAA8C;AAE9C,QAAQ;AACR,wDAAsC;AACtC,uDAAqC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO;AACP,4CAA0B;AAE1B,QAAQ;AACR,8CAA4B;AAC5B,+CAA6B;AAC7B,mDAAiC;AAEjC,aAAa;AACb,0DAAwC;AACxC,yDAAuC;AAEvC,cAAc;AACd,6DAA2C;AAC3C,qDAAmC;AACnC,sDAAoC;AACpC,qDAAmC;AAEnC,eAAe;AACf,2DAAyC;AACzC,sEAAoD;AACpD,4DAA0C;AAC1C,+DAA6C;AAC7C,+DAA6C;AAE7C,WAAW;AACX,gEAA8C;AAC9C,mEAAiD;AACjD,iEAA+C;AAC/C,gEAA8C;AAE9C,QAAQ;AACR,wDAAsC;AACtC,uDAAqC"}
@@ -0,0 +1,129 @@
1
+ import { TweetFilter as TweetFilterCore } from 'rettiwt-core';
2
+ import { EResourceType } from '../../enums/Resource';
3
+ /**
4
+ * Options specifying the data that is to be fetched.
5
+ *
6
+ * @public
7
+ */
8
+ export declare class FetchArgs {
9
+ /**
10
+ * The number of data items to fetch.
11
+ *
12
+ * @remarks
13
+ * - Works only for cursored resources.
14
+ * - Must be \<= 20 for:
15
+ * - {@link EResourceType.USER_TIMELINE}
16
+ * - {@link EResourceType.USER_TIMELINE}
17
+ * - {@link EResourceType.USER_TIMELINE_AND_REPLIES}.
18
+ * - Must be \<= 100 for all other cursored resources.
19
+ * - Due a bug on Twitter's end, count does not work for {@link EResourceType.USER_FOLLOWERS} and {@link EResourceType.USER_FOLLOWING}.
20
+ *
21
+ * @defaultValue 20
22
+ */
23
+ count?: number;
24
+ /**
25
+ * The cursor to the batch of data to fetch.
26
+ *
27
+ * @remarks
28
+ * - May be used for cursored resources.
29
+ * - Has no effect for other resources.
30
+ */
31
+ cursor?: string;
32
+ /**
33
+ * The filter for searching tweets.
34
+ *
35
+ * @remarks
36
+ * Required when searching for tweets using {@link EResourceType.TWEET_SEARCH}.
37
+ */
38
+ filter?: TweetFilter;
39
+ /**
40
+ * The id of the target resource.
41
+ *
42
+ * @remarks
43
+ * - Required for all resources except {@link EResourceType.TWEET_SEARCH}.
44
+ * - For {@link EResourceType.USER_DETAILS_BY_USERNAME}, can be alphanumeric, while for others, is strictly numeric.
45
+ */
46
+ id?: string;
47
+ /**
48
+ * @param resource - The resource to be fetched.
49
+ * @param args - Additional user-defined arguments for fetching the resource.
50
+ */
51
+ constructor(resource: EResourceType, args: FetchArgs);
52
+ }
53
+ /**
54
+ * The filter to be used for searching tweets.
55
+ *
56
+ * @public
57
+ */
58
+ export declare class TweetFilter extends TweetFilterCore {
59
+ /** The date upto which tweets are to be searched. */
60
+ endDate?: Date;
61
+ /** The list of words to exclude from search. */
62
+ excludeWords?: string[];
63
+ /**
64
+ * The list of usernames whose tweets are to be searched.
65
+ *
66
+ * @remarks
67
+ * '\@' must be excluded from the username!
68
+ */
69
+ fromUsers?: string[];
70
+ /**
71
+ * The list of hashtags to search.
72
+ *
73
+ * @remarks
74
+ * '#' must be excluded from the hashtag!
75
+ */
76
+ hashtags?: string[];
77
+ /** The exact phrase to search. */
78
+ includePhrase?: string;
79
+ /** The list of words to search. */
80
+ includeWords?: string[];
81
+ /** The language of the tweets to search. */
82
+ language?: string;
83
+ /**
84
+ * Whether to fetch tweets that are links or not.
85
+ *
86
+ * @defaultValue true
87
+ */
88
+ links?: boolean;
89
+ /** The id of the tweet, before which the tweets are to be searched. */
90
+ maxId?: string;
91
+ /**
92
+ * The list of username mentioned in the tweets to search.
93
+ *
94
+ * @remarks
95
+ * '\@' must be excluded from the username!
96
+ */
97
+ mentions?: string[];
98
+ /** The minimun number of likes to search by. */
99
+ minLikes?: number;
100
+ /** The minimum number of replies to search by. */
101
+ minReplies?: number;
102
+ /** The minimum number of retweets to search by. */
103
+ minRetweets?: number;
104
+ /** The optional words to search. */
105
+ optionalWords?: string[];
106
+ /** The id of the tweet which is quoted in the tweets to search. */
107
+ quoted?: string;
108
+ /**
109
+ * Whether to fetch tweets that are replies or not.
110
+ *
111
+ * @defaultValue true
112
+ */
113
+ replies?: boolean;
114
+ /** The id of the tweet, after which the tweets are to be searched. */
115
+ sinceId?: string;
116
+ /** The date starting from which tweets are to be searched. */
117
+ startDate?: Date;
118
+ /**
119
+ * The list of username to whom the tweets to be searched, are adressed.
120
+ *
121
+ * @remarks
122
+ * '\@' must be excluded from the username!
123
+ */
124
+ toUsers?: string[];
125
+ /**
126
+ * @param filter - The filter to use for searching tweets.
127
+ */
128
+ constructor(filter: TweetFilter);
129
+ }
@@ -0,0 +1,263 @@
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ 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;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.TweetFilter = exports.FetchArgs = void 0;
28
+ var class_validator_1 = require("class-validator");
29
+ var rettiwt_core_1 = require("rettiwt-core");
30
+ var Resource_1 = require("../../enums/Resource");
31
+ var DataValidationError_1 = require("../errors/DataValidationError");
32
+ /**
33
+ * Options specifying the data that is to be fetched.
34
+ *
35
+ * @public
36
+ */
37
+ var FetchArgs = exports.FetchArgs = /** @class */ (function () {
38
+ /**
39
+ * @param resource - The resource to be fetched.
40
+ * @param args - Additional user-defined arguments for fetching the resource.
41
+ */
42
+ function FetchArgs(resource, args) {
43
+ var _a;
44
+ this.id = args.id;
45
+ this.count = (_a = args.count) !== null && _a !== void 0 ? _a : 20;
46
+ this.cursor = args.cursor;
47
+ this.filter = args.filter ? new TweetFilter(args.filter) : undefined;
48
+ // Validating this object
49
+ var validationResult = (0, class_validator_1.validateSync)(this, { groups: [resource] });
50
+ // If valiation error occured
51
+ if (validationResult.length) {
52
+ throw new DataValidationError_1.DataValidationError(validationResult);
53
+ }
54
+ }
55
+ __decorate([
56
+ (0, class_validator_1.IsOptional)(),
57
+ (0, class_validator_1.Max)(100, {
58
+ groups: [
59
+ Resource_1.EResourceType.LIST_TWEETS,
60
+ Resource_1.EResourceType.TWEET_LIKERS,
61
+ Resource_1.EResourceType.TWEET_RETWEETERS,
62
+ Resource_1.EResourceType.USER_FOLLOWERS,
63
+ Resource_1.EResourceType.USER_FOLLOWING,
64
+ Resource_1.EResourceType.USER_HIGHLIGHTS,
65
+ Resource_1.EResourceType.USER_LIKES,
66
+ Resource_1.EResourceType.USER_MEDIA,
67
+ Resource_1.EResourceType.USER_SUBSCRIPTIONS,
68
+ ],
69
+ }),
70
+ (0, class_validator_1.Max)(20, {
71
+ groups: [Resource_1.EResourceType.TWEET_SEARCH, Resource_1.EResourceType.USER_TIMELINE, Resource_1.EResourceType.USER_TIMELINE_AND_REPLIES],
72
+ }),
73
+ __metadata("design:type", Number)
74
+ ], FetchArgs.prototype, "count", void 0);
75
+ __decorate([
76
+ (0, class_validator_1.IsOptional)(),
77
+ (0, class_validator_1.IsString)(),
78
+ __metadata("design:type", String)
79
+ ], FetchArgs.prototype, "cursor", void 0);
80
+ __decorate([
81
+ (0, class_validator_1.IsOptional)(),
82
+ (0, class_validator_1.IsNotEmpty)({ groups: [Resource_1.EResourceType.TWEET_SEARCH] }),
83
+ (0, class_validator_1.IsObject)({ groups: [Resource_1.EResourceType.TWEET_SEARCH] }),
84
+ __metadata("design:type", TweetFilter)
85
+ ], FetchArgs.prototype, "filter", void 0);
86
+ __decorate([
87
+ (0, class_validator_1.IsOptional)(),
88
+ (0, class_validator_1.IsNotEmpty)({
89
+ groups: [
90
+ Resource_1.EResourceType.LIST_TWEETS,
91
+ Resource_1.EResourceType.TWEET_DETAILS,
92
+ Resource_1.EResourceType.TWEET_LIKERS,
93
+ Resource_1.EResourceType.TWEET_RETWEETERS,
94
+ Resource_1.EResourceType.USER_DETAILS_BY_USERNAME,
95
+ Resource_1.EResourceType.USER_DETAILS_BY_ID,
96
+ Resource_1.EResourceType.USER_FOLLOWERS,
97
+ Resource_1.EResourceType.USER_FOLLOWING,
98
+ Resource_1.EResourceType.USER_HIGHLIGHTS,
99
+ Resource_1.EResourceType.USER_LIKES,
100
+ Resource_1.EResourceType.USER_MEDIA,
101
+ Resource_1.EResourceType.USER_SUBSCRIPTIONS,
102
+ Resource_1.EResourceType.USER_TIMELINE,
103
+ Resource_1.EResourceType.USER_TIMELINE_AND_REPLIES,
104
+ ],
105
+ }),
106
+ (0, class_validator_1.IsNumberString)(undefined, {
107
+ groups: [
108
+ Resource_1.EResourceType.LIST_TWEETS,
109
+ Resource_1.EResourceType.TWEET_DETAILS,
110
+ Resource_1.EResourceType.TWEET_LIKERS,
111
+ Resource_1.EResourceType.TWEET_RETWEETERS,
112
+ Resource_1.EResourceType.USER_DETAILS_BY_ID,
113
+ Resource_1.EResourceType.USER_FOLLOWERS,
114
+ Resource_1.EResourceType.USER_FOLLOWING,
115
+ Resource_1.EResourceType.USER_HIGHLIGHTS,
116
+ Resource_1.EResourceType.USER_LIKES,
117
+ Resource_1.EResourceType.USER_MEDIA,
118
+ Resource_1.EResourceType.USER_SUBSCRIPTIONS,
119
+ Resource_1.EResourceType.USER_TIMELINE,
120
+ Resource_1.EResourceType.USER_TIMELINE_AND_REPLIES,
121
+ ],
122
+ }),
123
+ __metadata("design:type", String)
124
+ ], FetchArgs.prototype, "id", void 0);
125
+ return FetchArgs;
126
+ }());
127
+ /**
128
+ * The filter to be used for searching tweets.
129
+ *
130
+ * @public
131
+ */
132
+ var TweetFilter = exports.TweetFilter = /** @class */ (function (_super) {
133
+ __extends(TweetFilter, _super);
134
+ /**
135
+ * @param filter - The filter to use for searching tweets.
136
+ */
137
+ function TweetFilter(filter) {
138
+ var _this = _super.call(this, filter) || this;
139
+ /**
140
+ * Whether to fetch tweets that are links or not.
141
+ *
142
+ * @defaultValue true
143
+ */
144
+ _this.links = true;
145
+ /**
146
+ * Whether to fetch tweets that are replies or not.
147
+ *
148
+ * @defaultValue true
149
+ */
150
+ _this.replies = true;
151
+ // Validating this object
152
+ var validationResult = (0, class_validator_1.validateSync)(_this);
153
+ // If valiation error occured
154
+ if (validationResult.length) {
155
+ throw new DataValidationError_1.DataValidationError(validationResult);
156
+ }
157
+ return _this;
158
+ }
159
+ __decorate([
160
+ (0, class_validator_1.IsOptional)(),
161
+ (0, class_validator_1.IsDate)(),
162
+ __metadata("design:type", Date)
163
+ ], TweetFilter.prototype, "endDate", void 0);
164
+ __decorate([
165
+ (0, class_validator_1.IsOptional)(),
166
+ (0, class_validator_1.IsArray)(),
167
+ (0, class_validator_1.IsString)({ each: true }),
168
+ __metadata("design:type", Array)
169
+ ], TweetFilter.prototype, "excludeWords", void 0);
170
+ __decorate([
171
+ (0, class_validator_1.IsOptional)(),
172
+ (0, class_validator_1.IsArray)(),
173
+ (0, class_validator_1.IsString)({ each: true }),
174
+ __metadata("design:type", Array)
175
+ ], TweetFilter.prototype, "fromUsers", void 0);
176
+ __decorate([
177
+ (0, class_validator_1.IsOptional)(),
178
+ (0, class_validator_1.IsArray)(),
179
+ (0, class_validator_1.IsString)({ each: true }),
180
+ __metadata("design:type", Array)
181
+ ], TweetFilter.prototype, "hashtags", void 0);
182
+ __decorate([
183
+ (0, class_validator_1.IsOptional)(),
184
+ (0, class_validator_1.IsString)(),
185
+ __metadata("design:type", String)
186
+ ], TweetFilter.prototype, "includePhrase", void 0);
187
+ __decorate([
188
+ (0, class_validator_1.IsOptional)(),
189
+ (0, class_validator_1.IsArray)(),
190
+ (0, class_validator_1.IsString)({ each: true }),
191
+ __metadata("design:type", Array)
192
+ ], TweetFilter.prototype, "includeWords", void 0);
193
+ __decorate([
194
+ (0, class_validator_1.IsOptional)(),
195
+ (0, class_validator_1.IsString)(),
196
+ __metadata("design:type", String)
197
+ ], TweetFilter.prototype, "language", void 0);
198
+ __decorate([
199
+ (0, class_validator_1.IsOptional)(),
200
+ (0, class_validator_1.IsBoolean)(),
201
+ __metadata("design:type", Boolean)
202
+ ], TweetFilter.prototype, "links", void 0);
203
+ __decorate([
204
+ (0, class_validator_1.IsOptional)(),
205
+ (0, class_validator_1.IsNumberString)(),
206
+ __metadata("design:type", String)
207
+ ], TweetFilter.prototype, "maxId", void 0);
208
+ __decorate([
209
+ (0, class_validator_1.IsOptional)(),
210
+ (0, class_validator_1.IsArray)(),
211
+ (0, class_validator_1.IsString)({ each: true }),
212
+ __metadata("design:type", Array)
213
+ ], TweetFilter.prototype, "mentions", void 0);
214
+ __decorate([
215
+ (0, class_validator_1.IsOptional)(),
216
+ (0, class_validator_1.IsNumber)(),
217
+ __metadata("design:type", Number)
218
+ ], TweetFilter.prototype, "minLikes", void 0);
219
+ __decorate([
220
+ (0, class_validator_1.IsOptional)(),
221
+ (0, class_validator_1.IsNumber)(),
222
+ __metadata("design:type", Number)
223
+ ], TweetFilter.prototype, "minReplies", void 0);
224
+ __decorate([
225
+ (0, class_validator_1.IsOptional)(),
226
+ (0, class_validator_1.IsNumber)(),
227
+ __metadata("design:type", Number)
228
+ ], TweetFilter.prototype, "minRetweets", void 0);
229
+ __decorate([
230
+ (0, class_validator_1.IsOptional)(),
231
+ (0, class_validator_1.IsArray)(),
232
+ (0, class_validator_1.IsString)({ each: true }),
233
+ __metadata("design:type", Array)
234
+ ], TweetFilter.prototype, "optionalWords", void 0);
235
+ __decorate([
236
+ (0, class_validator_1.IsOptional)(),
237
+ (0, class_validator_1.IsNumberString)(),
238
+ __metadata("design:type", String)
239
+ ], TweetFilter.prototype, "quoted", void 0);
240
+ __decorate([
241
+ (0, class_validator_1.IsOptional)(),
242
+ (0, class_validator_1.IsBoolean)(),
243
+ __metadata("design:type", Boolean)
244
+ ], TweetFilter.prototype, "replies", void 0);
245
+ __decorate([
246
+ (0, class_validator_1.IsOptional)(),
247
+ (0, class_validator_1.IsNumberString)(),
248
+ __metadata("design:type", String)
249
+ ], TweetFilter.prototype, "sinceId", void 0);
250
+ __decorate([
251
+ (0, class_validator_1.IsOptional)(),
252
+ (0, class_validator_1.IsDate)(),
253
+ __metadata("design:type", Date)
254
+ ], TweetFilter.prototype, "startDate", void 0);
255
+ __decorate([
256
+ (0, class_validator_1.IsOptional)(),
257
+ (0, class_validator_1.IsArray)(),
258
+ (0, class_validator_1.IsString)({ each: true }),
259
+ __metadata("design:type", Array)
260
+ ], TweetFilter.prototype, "toUsers", void 0);
261
+ return TweetFilter;
262
+ }(rettiwt_core_1.TweetFilter));
263
+ //# sourceMappingURL=FetchArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchArgs.js","sourceRoot":"","sources":["../../../src/models/args/FetchArgs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAYyB;AAEzB,6CAA8D;AAE9D,iDAAqD;AACrD,qEAAoE;AAEpE;;;;GAIG;AACH;IAqGC;;;OAGG;IACH,mBAAmB,QAAuB,EAAE,IAAe;;QAC1D,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,mCAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG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IAKpB;QAFN,IAAA,4BAAU,GAAE;QACZ,IAAA,0BAAQ,GAAE;;oDACiB;IAMrB;QAHN,IAAA,4BAAU,GAAE;QACZ,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;sDACO;IAKzB;QAFN,IAAA,4BAAU,GAAE;QACZ,IAAA,gCAAc,GAAE;;+CACM;IAShB;QAFN,IAAA,4BAAU,GAAE;QACZ,IAAA,2BAAS,GAAE;;gDACoB;IAKzB;QAFN,IAAA,4BAAU,GAAE;QACZ,IAAA,gCAAc,GAAE;;gDACO;IAKjB;QAFN,IAAA,4BAAU,GAAE;QACZ,IAAA,wBAAM,GAAE;kCACU,IAAI;kDAAC;IAWjB;QAHN,IAAA,4BAAU,GAAE;QACZ,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;gDACC;IAgB3B,kBAAC;CAAA,AAjJD,CAAiC,0BAAe,GAiJ/C"}
@@ -0,0 +1,116 @@
1
+ import { NewTweet, NewTweetMedia } from 'rettiwt-core';
2
+ import { EResourceType } from '../../enums/Resource';
3
+ /**
4
+ * Options specifying the data that is to be posted.
5
+ *
6
+ * @public
7
+ */
8
+ export declare class PostArgs {
9
+ /**
10
+ * The id of the target resource.
11
+ *
12
+ * @remarks
13
+ * Required only when posting using the following resources:
14
+ * - {@link EResourceType.TWEET_LIKE}
15
+ * - {@link EResourceType.TWEET_RETWEET}
16
+ * - {@link EResourceType.TWEET_UNLIKE}
17
+ * - {@link EResourceType.TWEET_UNPOST}
18
+ * - {@link EResourceType.TWEET_UNRETWEET}
19
+ * - {@link EResourceType.USER_FOLLOW}
20
+ * - {@link EResourceType.USER_UNFOLLOW}
21
+ */
22
+ id?: string;
23
+ /**
24
+ * The tweet that is to be posted.
25
+ *
26
+ * @remarks
27
+ * Required only when posting a tweet using {@link EResourceType.TWEET_POST}
28
+ */
29
+ tweet?: TweetArgs;
30
+ /**
31
+ * The media file to be uploaded.
32
+ *
33
+ * @remarks
34
+ * Required only when uploading a media using the following resources:
35
+ * - {@link EResourceType.MEDIA_UPLOAD_APPEND}
36
+ * - {@link EResourceType.MEDIA_UPLOAD_FINALIZE}
37
+ * - {@link EResourceType.MEDIA_UPLOAD_INITIALIZE}
38
+ */
39
+ upload?: UploadArgs;
40
+ /**
41
+ * @param resource - The resource to be posted.
42
+ * @param args - Additional user-defined arguments for posting the resource.
43
+ */
44
+ constructor(resource: EResourceType, args: PostArgs);
45
+ }
46
+ /**
47
+ * Options specifying the tweet that is to be posted.
48
+ *
49
+ * @public
50
+ */
51
+ export declare class TweetArgs extends NewTweet {
52
+ /**
53
+ * The list of media to be uploaded.
54
+ *
55
+ * @remarks
56
+ * Maximum number of media items that can be posted is 4.
57
+ */
58
+ media?: TweetMediaArgs[];
59
+ /** The id of the tweet to quote. */
60
+ quote?: string;
61
+ /** The id of the tweet to which the given tweet must be a reply. */
62
+ replyTo?: string;
63
+ /**
64
+ * The text for the tweet to be created.
65
+ *
66
+ * @remarks
67
+ * Length of the tweet must be \<= 280 characters.
68
+ */
69
+ text: string;
70
+ /**
71
+ * @param args - Arguments specifying the tweet to be posted.
72
+ */
73
+ constructor(args: TweetArgs);
74
+ }
75
+ /**
76
+ * Options specifying the media that is to be posted.
77
+ *
78
+ * @public
79
+ */
80
+ export declare class TweetMediaArgs extends NewTweetMedia {
81
+ /** The id of the media to post. */
82
+ id: string;
83
+ /**
84
+ * The list of id of the users tagged in the media.
85
+ *
86
+ * @remarks
87
+ * Maximum number of users that can be tagged is 10.
88
+ */
89
+ tags?: string[];
90
+ /**
91
+ * @param args - Arguments specifying the media to be posted.
92
+ */
93
+ constructor(args: TweetMediaArgs);
94
+ }
95
+ /**
96
+ * Options specifying the media file to be uploaded.
97
+ *
98
+ * @internal
99
+ */
100
+ export declare class UploadArgs {
101
+ /** The id allocated to the media file to be uploaded. */
102
+ id?: string;
103
+ /** The media file to be uploaded. */
104
+ media?: string | ArrayBuffer;
105
+ /**
106
+ * The size (in bytes) of the media file to be uploaded.
107
+ *
108
+ * @remarks The size must be \<= 5242880 bytes.
109
+ */
110
+ size?: number;
111
+ /**
112
+ * @param step - The upload step.
113
+ * @param args - The upload arguments for uploading the media file.
114
+ */
115
+ constructor(step: EResourceType, args: UploadArgs);
116
+ }