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
@@ -0,0 +1,232 @@
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.UploadArgs = exports.TweetMediaArgs = exports.TweetArgs = exports.PostArgs = 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 posted.
34
+ *
35
+ * @public
36
+ */
37
+ var PostArgs = exports.PostArgs = /** @class */ (function () {
38
+ /**
39
+ * @param resource - The resource to be posted.
40
+ * @param args - Additional user-defined arguments for posting the resource.
41
+ */
42
+ function PostArgs(resource, args) {
43
+ this.id = args.id;
44
+ this.tweet = args.tweet ? new TweetArgs(args.tweet) : undefined;
45
+ this.upload = args.upload ? new UploadArgs(resource, args.upload) : undefined;
46
+ // Validating this object
47
+ var validationResult = (0, class_validator_1.validateSync)(this, { groups: [resource] });
48
+ // If valiation error occured
49
+ if (validationResult.length) {
50
+ throw new DataValidationError_1.DataValidationError(validationResult);
51
+ }
52
+ }
53
+ __decorate([
54
+ (0, class_validator_1.IsOptional)(),
55
+ (0, class_validator_1.IsNotEmpty)({
56
+ groups: [
57
+ Resource_1.EResourceType.TWEET_LIKE,
58
+ Resource_1.EResourceType.TWEET_RETWEET,
59
+ Resource_1.EResourceType.TWEET_UNLIKE,
60
+ Resource_1.EResourceType.TWEET_UNPOST,
61
+ Resource_1.EResourceType.TWEET_UNRETWEET,
62
+ Resource_1.EResourceType.USER_FOLLOW,
63
+ Resource_1.EResourceType.USER_UNFOLLOW,
64
+ ],
65
+ }),
66
+ (0, class_validator_1.IsNumberString)(undefined, {
67
+ groups: [
68
+ Resource_1.EResourceType.TWEET_LIKE,
69
+ Resource_1.EResourceType.TWEET_RETWEET,
70
+ Resource_1.EResourceType.TWEET_UNLIKE,
71
+ Resource_1.EResourceType.TWEET_UNPOST,
72
+ Resource_1.EResourceType.TWEET_UNRETWEET,
73
+ Resource_1.EResourceType.USER_FOLLOW,
74
+ Resource_1.EResourceType.USER_UNFOLLOW,
75
+ ],
76
+ }),
77
+ __metadata("design:type", String)
78
+ ], PostArgs.prototype, "id", void 0);
79
+ __decorate([
80
+ (0, class_validator_1.IsOptional)(),
81
+ (0, class_validator_1.IsNotEmpty)({ groups: [Resource_1.EResourceType.TWEET_POST] }),
82
+ (0, class_validator_1.IsObject)({ groups: [Resource_1.EResourceType.TWEET_POST] }),
83
+ __metadata("design:type", TweetArgs)
84
+ ], PostArgs.prototype, "tweet", void 0);
85
+ __decorate([
86
+ (0, class_validator_1.IsOptional)(),
87
+ (0, class_validator_1.IsNotEmpty)({
88
+ groups: [
89
+ Resource_1.EResourceType.MEDIA_UPLOAD_INITIALIZE,
90
+ Resource_1.EResourceType.MEDIA_UPLOAD_APPEND,
91
+ Resource_1.EResourceType.MEDIA_UPLOAD_FINALIZE,
92
+ ],
93
+ }),
94
+ (0, class_validator_1.IsObject)({
95
+ groups: [
96
+ Resource_1.EResourceType.MEDIA_UPLOAD_INITIALIZE,
97
+ Resource_1.EResourceType.MEDIA_UPLOAD_APPEND,
98
+ Resource_1.EResourceType.MEDIA_UPLOAD_FINALIZE,
99
+ ],
100
+ }),
101
+ __metadata("design:type", UploadArgs)
102
+ ], PostArgs.prototype, "upload", void 0);
103
+ return PostArgs;
104
+ }());
105
+ /**
106
+ * Options specifying the tweet that is to be posted.
107
+ *
108
+ * @public
109
+ */
110
+ var TweetArgs = exports.TweetArgs = /** @class */ (function (_super) {
111
+ __extends(TweetArgs, _super);
112
+ /**
113
+ * @param args - Arguments specifying the tweet to be posted.
114
+ */
115
+ function TweetArgs(args) {
116
+ var _this = _super.call(this) || this;
117
+ _this.text = args.text;
118
+ _this.quote = args.quote;
119
+ _this.media = args.media ? args.media.map(function (item) { return new TweetMediaArgs(item); }) : undefined;
120
+ _this.replyTo = args.replyTo;
121
+ // Validating this object
122
+ var validationResult = (0, class_validator_1.validateSync)(_this);
123
+ // If valiation error occured
124
+ if (validationResult.length) {
125
+ throw new DataValidationError_1.DataValidationError(validationResult);
126
+ }
127
+ return _this;
128
+ }
129
+ __decorate([
130
+ (0, class_validator_1.IsOptional)(),
131
+ (0, class_validator_1.IsArray)(),
132
+ (0, class_validator_1.ArrayMaxSize)(4),
133
+ (0, class_validator_1.IsObject)({ each: true }),
134
+ __metadata("design:type", Array)
135
+ ], TweetArgs.prototype, "media", void 0);
136
+ __decorate([
137
+ (0, class_validator_1.IsOptional)(),
138
+ (0, class_validator_1.IsNumberString)(),
139
+ __metadata("design:type", String)
140
+ ], TweetArgs.prototype, "quote", void 0);
141
+ __decorate([
142
+ (0, class_validator_1.IsOptional)(),
143
+ (0, class_validator_1.IsNumberString)(),
144
+ __metadata("design:type", String)
145
+ ], TweetArgs.prototype, "replyTo", void 0);
146
+ __decorate([
147
+ (0, class_validator_1.IsNotEmpty)(),
148
+ (0, class_validator_1.IsString)(),
149
+ (0, class_validator_1.MaxLength)(280),
150
+ __metadata("design:type", String)
151
+ ], TweetArgs.prototype, "text", void 0);
152
+ return TweetArgs;
153
+ }(rettiwt_core_1.NewTweet));
154
+ /**
155
+ * Options specifying the media that is to be posted.
156
+ *
157
+ * @public
158
+ */
159
+ var TweetMediaArgs = exports.TweetMediaArgs = /** @class */ (function (_super) {
160
+ __extends(TweetMediaArgs, _super);
161
+ /**
162
+ * @param args - Arguments specifying the media to be posted.
163
+ */
164
+ function TweetMediaArgs(args) {
165
+ var _this = this;
166
+ var _a;
167
+ _this = _super.call(this) || this;
168
+ _this.id = args.id;
169
+ _this.tags = (_a = args.tags) !== null && _a !== void 0 ? _a : [];
170
+ // Validating this object
171
+ var validationResult = (0, class_validator_1.validateSync)(_this);
172
+ // If validation error occured
173
+ if (validationResult.length) {
174
+ throw new DataValidationError_1.DataValidationError(validationResult);
175
+ }
176
+ return _this;
177
+ }
178
+ __decorate([
179
+ (0, class_validator_1.IsNotEmpty)(),
180
+ (0, class_validator_1.IsNumberString)(),
181
+ __metadata("design:type", String)
182
+ ], TweetMediaArgs.prototype, "id", void 0);
183
+ __decorate([
184
+ (0, class_validator_1.IsOptional)(),
185
+ (0, class_validator_1.IsArray)(),
186
+ (0, class_validator_1.ArrayMaxSize)(10),
187
+ (0, class_validator_1.IsNumberString)(undefined, { each: true }),
188
+ __metadata("design:type", Array)
189
+ ], TweetMediaArgs.prototype, "tags", void 0);
190
+ return TweetMediaArgs;
191
+ }(rettiwt_core_1.NewTweetMedia));
192
+ /**
193
+ * Options specifying the media file to be uploaded.
194
+ *
195
+ * @internal
196
+ */
197
+ var UploadArgs = exports.UploadArgs = /** @class */ (function () {
198
+ /**
199
+ * @param step - The upload step.
200
+ * @param args - The upload arguments for uploading the media file.
201
+ */
202
+ function UploadArgs(step, args) {
203
+ this.size = args.size;
204
+ this.media = args.media;
205
+ this.id = args.id;
206
+ // Validating this object
207
+ var validationResult = (0, class_validator_1.validateSync)(this, { groups: [step] });
208
+ // If validation error occured
209
+ if (validationResult.length) {
210
+ throw new DataValidationError_1.DataValidationError(validationResult);
211
+ }
212
+ }
213
+ __decorate([
214
+ (0, class_validator_1.IsOptional)(),
215
+ (0, class_validator_1.IsNotEmpty)({ groups: [Resource_1.EResourceType.MEDIA_UPLOAD_APPEND, Resource_1.EResourceType.MEDIA_UPLOAD_FINALIZE] }),
216
+ (0, class_validator_1.IsNumberString)(undefined, { groups: [Resource_1.EResourceType.MEDIA_UPLOAD_APPEND, Resource_1.EResourceType.MEDIA_UPLOAD_FINALIZE] }),
217
+ __metadata("design:type", String)
218
+ ], UploadArgs.prototype, "id", void 0);
219
+ __decorate([
220
+ (0, class_validator_1.IsOptional)(),
221
+ (0, class_validator_1.IsNotEmpty)({ groups: [Resource_1.EResourceType.MEDIA_UPLOAD_APPEND] }),
222
+ __metadata("design:type", Object)
223
+ ], UploadArgs.prototype, "media", void 0);
224
+ __decorate([
225
+ (0, class_validator_1.IsOptional)(),
226
+ (0, class_validator_1.IsNotEmpty)({ groups: [Resource_1.EResourceType.MEDIA_UPLOAD_INITIALIZE] }),
227
+ (0, class_validator_1.Max)(5242880, { groups: [Resource_1.EResourceType.MEDIA_UPLOAD_INITIALIZE] }),
228
+ __metadata("design:type", Number)
229
+ ], UploadArgs.prototype, "size", void 0);
230
+ return UploadArgs;
231
+ }());
232
+ //# sourceMappingURL=PostArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostArgs.js","sourceRoot":"","sources":["../../../src/models/args/PostArgs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAWyB;AAEzB,6CAAuD;AAEvD,iDAAqD;AACrD,qEAAoE;AAEpE;;;;GAIG;AACH;IA4EC;;;OAGG;IACH,kBAAmB,QAAuB,EAAE,IAAc;QACzD,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE9E,yBAAyB;QACzB,IAAM,gBAAgB,GAAG,IAAA,8BAAY,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAEpE,6BAA6B;QAC7B,IAAI,gBAAgB,CAAC,MAAM,EAAE;YAC5B,MAAM,IAAI,yCAAmB,CAAC,gBAAgB,CAAC,CAAC;SAChD;IACF,CAAC;IAvDM;QAvBN,IAAA,4BAAU,GAAE;QACZ,IAAA,4BAAU,EAAC;YACX,MAAM,EAAE;gBACP,wB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,IAAA,4BAAU,GAAE;QACZ,IAAA,4BAAU,EAAC,EAAE,MAAM,EAAE,CAAC,wBAAa,CAAC,mBAAmB,CAAC,EAAE,CAAC;;6CACxB;IAU7B;QAHN,IAAA,4BAAU,GAAE;QACZ,IAAA,4BAAU,EAAC,EAAE,MAAM,EAAE,CAAC,wBAAa,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAC/D,IAAA,qBAAG,EAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,wBAAa,CAAC,uBAAuB,CAAC,EAAE,CAAC;;4CAC7C;IAmBtB,iBAAC;CAAA,AAvCD,IAuCC"}
@@ -1,25 +1,27 @@
1
+ import { IResponse } from 'rettiwt-core';
2
+ import { EBaseType } from '../../enums/Data';
1
3
  import { Tweet } from './Tweet';
2
4
  import { User } from './User';
3
5
  /**
4
- * The data that us fetched batch-wise along with a cursor.
6
+ * The data that is fetched batch-wise using a cursor.
5
7
  *
6
- * @typeParam T - Type of data to be stored in the list.
8
+ * @typeParam T - Type of data to be stored.
7
9
  *
8
10
  * @public
9
11
  */
10
12
  export declare class CursoredData<T extends Tweet | User> {
11
- /** The list of data of the given type. */
13
+ /** The batch of data of the given type. */
12
14
  list: T[];
13
15
  /** The cursor to the next batch of data. */
14
16
  next: Cursor;
15
17
  /**
16
- * @param list - The list of data item to store.
17
- * @param next - The cursor to the next batch of data.
18
+ * @param response - The raw response.
19
+ * @param type - The base type of the data included in the batch.
18
20
  */
19
- constructor(list?: T[], next?: string);
21
+ constructor(response: IResponse<unknown>, type: EBaseType);
20
22
  }
21
23
  /**
22
- * The cursor to the batch of data to be fetched.
24
+ * The cursor to the batch of data to fetch.
23
25
  *
24
26
  * @public
25
27
  */
@@ -27,9 +29,7 @@ export declare class Cursor {
27
29
  /** The cursor string. */
28
30
  value: string;
29
31
  /**
30
- * Initializes a new cursor from the given cursor string.
31
- *
32
- * @param cursorStr - The string representation of the cursor.
32
+ * @param cursor - The cursor string.
33
33
  */
34
- constructor(cursorStr: string);
34
+ constructor(cursor: string);
35
35
  }
@@ -1,42 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cursor = exports.CursoredData = void 0;
4
+ var Data_1 = require("../../enums/Data");
5
+ var JsonUtils_1 = require("../../helper/JsonUtils");
6
+ var Tweet_1 = require("./Tweet");
7
+ var User_1 = require("./User");
4
8
  /**
5
- * The data that us fetched batch-wise along with a cursor.
9
+ * The data that is fetched batch-wise using a cursor.
6
10
  *
7
- * @typeParam T - Type of data to be stored in the list.
11
+ * @typeParam T - Type of data to be stored.
8
12
  *
9
13
  * @public
10
14
  */
11
15
  var CursoredData = /** @class */ (function () {
12
16
  /**
13
- * @param list - The list of data item to store.
14
- * @param next - The cursor to the next batch of data.
17
+ * @param response - The raw response.
18
+ * @param type - The base type of the data included in the batch.
15
19
  */
16
- function CursoredData(list, next) {
17
- if (list === void 0) { list = []; }
18
- if (next === void 0) { next = ''; }
19
- /** The list of data of the given type. */
20
+ function CursoredData(response, type) {
21
+ /** The batch of data of the given type. */
20
22
  this.list = [];
21
- this.list = list;
22
- this.next = new Cursor(next);
23
+ if (type == Data_1.EBaseType.TWEET) {
24
+ this.list = Tweet_1.Tweet.list(response);
25
+ }
26
+ else {
27
+ this.list = User_1.User.list(response);
28
+ }
29
+ this.next = new Cursor((0, JsonUtils_1.findByFilter)(response, 'cursorType', 'Bottom')[0].value);
23
30
  }
24
31
  return CursoredData;
25
32
  }());
26
33
  exports.CursoredData = CursoredData;
27
34
  /**
28
- * The cursor to the batch of data to be fetched.
35
+ * The cursor to the batch of data to fetch.
29
36
  *
30
37
  * @public
31
38
  */
32
39
  var Cursor = /** @class */ (function () {
33
40
  /**
34
- * Initializes a new cursor from the given cursor string.
35
- *
36
- * @param cursorStr - The string representation of the cursor.
41
+ * @param cursor - The cursor string.
37
42
  */
38
- function Cursor(cursorStr) {
39
- this.value = cursorStr;
43
+ function Cursor(cursor) {
44
+ this.value = cursor;
40
45
  }
41
46
  return Cursor;
42
47
  }());
@@ -1 +1 @@
1
- {"version":3,"file":"CursoredData.js","sourceRoot":"","sources":["../../../src/models/data/CursoredData.ts"],"names":[],"mappings":";;;AAIA;;;;;;GAMG;AACH;IAOC;;;OAGG;IACH,sBAAmB,IAAc,EAAE,IAAiB;QAAjC,qBAAA,EAAA,SAAc;QAAE,qBAAA,EAAA,SAAiB;QAVpD,0CAA0C;QACnC,SAAI,GAAQ,EAAE,CAAC;QAUrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IACF,mBAAC;AAAD,CAAC,AAfD,IAeC;AAfY,oCAAY;AAiBzB;;;;GAIG;AACH;IAIC;;;;OAIG;IACH,gBAAmB,SAAiB;QACnC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACxB,CAAC;IACF,aAAC;AAAD,CAAC,AAZD,IAYC;AAZY,wBAAM"}
1
+ {"version":3,"file":"CursoredData.js","sourceRoot":"","sources":["../../../src/models/data/CursoredData.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,oDAAsD;AAEtD,iCAAgC;AAChC,+BAA8B;AAE9B;;;;;;GAMG;AACH;IAOC;;;OAGG;IACH,sBAAmB,QAA4B,EAAE,IAAe;QAVhE,2CAA2C;QACpC,SAAI,GAAQ,EAAE,CAAC;QAUrB,IAAI,IAAI,IAAI,gBAAS,CAAC,KAAK,EAAE;YAC5B,IAAI,CAAC,IAAI,GAAG,aAAK,CAAC,IAAI,CAAC,QAAQ,CAAQ,CAAC;SACxC;aAAM;YACN,IAAI,CAAC,IAAI,GAAG,WAAI,CAAC,IAAI,CAAC,QAAQ,CAAQ,CAAC;SACvC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAA,wBAAY,EAAU,QAAQ,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1F,CAAC;IACF,mBAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,oCAAY;AAsBzB;;;;GAIG;AACH;IAIC;;OAEG;IACH,gBAAmB,MAAc;QAChC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;IACrB,CAAC;IACF,aAAC;AAAD,CAAC,AAVD,IAUC;AAVY,wBAAM"}
@@ -5,24 +5,22 @@ import { IList as IRawList } from 'rettiwt-core';
5
5
  * @public
6
6
  */
7
7
  export declare class List {
8
- /** The rest id of the list. */
9
- id: string;
10
- /** The name of the list. */
11
- name: string;
12
8
  /** The date and time of creation of the list, int UTC string format. */
13
9
  createdAt: string;
10
+ /** The rest id of the user who created the list. */
11
+ createdBy: string;
14
12
  /** The list description. */
15
- description: string;
13
+ description?: string;
14
+ /** The rest id of the list. */
15
+ id: string;
16
16
  /** The number of memeber of the list. */
17
17
  memberCount: number;
18
+ /** The name of the list. */
19
+ name: string;
18
20
  /** The number of subscribers of the list. */
19
21
  subscriberCount: number;
20
- /** The rest id of the user who created the list. */
21
- createdBy: string;
22
22
  /**
23
- * Initializes a new Tweet List from the given raw list data.
24
- *
25
- * @param list - list The raw tweet list data.
23
+ * @param list - The raw list details.
26
24
  */
27
25
  constructor(list: IRawList);
28
26
  }
@@ -8,15 +8,13 @@ exports.List = void 0;
8
8
  */
9
9
  var List = /** @class */ (function () {
10
10
  /**
11
- * Initializes a new Tweet List from the given raw list data.
12
- *
13
- * @param list - list The raw tweet list data.
11
+ * @param list - The raw list details.
14
12
  */
15
13
  function List(list) {
16
14
  this.id = list.id_str;
17
15
  this.name = list.name;
18
16
  this.createdAt = new Date(list.created_at).toISOString();
19
- this.description = list.description;
17
+ this.description = list.description.length ? list.description : undefined;
20
18
  this.memberCount = list.member_count;
21
19
  this.subscriberCount = list.subscriber_count;
22
20
  this.createdBy = list.user_results.result.id;
@@ -1 +1 @@
1
- {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/models/data/List.ts"],"names":[],"mapp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C;IACF,WAAC;AAAD,CAAC,AAlCD,IAkCC;AAlCY,oBAAI"}
@@ -1,49 +1,65 @@
1
- import { ITweet as IRawTweet, IEntities as IRawTweetEntities, IExtendedMedia as IRawExtendedMedia, EMediaType } from 'rettiwt-core';
1
+ import { EMediaType, IExtendedMedia as IRawExtendedMedia, ITweet as IRawTweet, IEntities as IRawTweetEntities, IResponse } from 'rettiwt-core';
2
2
  import { User } from './User';
3
3
  /**
4
- * The details of a single Tweet.
4
+ * The details of a single tweet.
5
5
  *
6
6
  * @public
7
7
  */
8
8
  export declare class Tweet {
9
- /** The rest id of the tweet. */
10
- id: string;
11
- /** The details of the user who made the tweet. */
12
- tweetBy: User;
9
+ /** The number of bookmarks of a tweet. */
10
+ bookmarkCount: number;
13
11
  /** The date and time of creation of the tweet, in UTC string format. */
14
12
  createdAt: string;
15
13
  /** Additional tweet entities like urls, mentions, etc. */
16
14
  entities: TweetEntities;
17
- /** The urls of the media contents of the tweet (if any). */
18
- media: TweetMedia[];
19
- /** The rest id of the tweet which is quoted in the tweet. */
20
- quoted: string;
21
15
  /** The full text content of the tweet. */
22
16
  fullText: string;
23
- /** The rest id of the tweet to which the tweet is a reply. */
24
- replyTo: string;
17
+ /** The rest id of the tweet. */
18
+ id: string;
25
19
  /** The language in which the tweet is written. */
26
20
  lang: string;
21
+ /** The number of likes of the tweet. */
22
+ likeCount: number;
23
+ /** The urls of the media contents of the tweet (if any). */
24
+ media?: TweetMedia[];
27
25
  /** The number of quotes of the tweet. */
28
26
  quoteCount: number;
27
+ /** The rest id of the tweet which is quoted in the tweet. */
28
+ quoted?: string;
29
29
  /** The number of replies to the tweet. */
30
30
  replyCount: number;
31
+ /** The rest id of the tweet to which the tweet is a reply. */
32
+ replyTo?: string;
31
33
  /** The number of retweets of the tweet. */
32
34
  retweetCount: number;
33
- /** The number of likes of the tweet. */
34
- likeCount: number;
35
- /** The number of views of a tweet. */
36
- viewCount: number;
37
- /** The number of bookmarks of a tweet. */
38
- bookmarkCount: number;
39
35
  /** The tweet which was retweeted in this tweet (if any). */
40
36
  retweetedTweet?: Tweet;
37
+ /** The details of the user who made the tweet. */
38
+ tweetBy: User;
39
+ /** The number of views of a tweet. */
40
+ viewCount: number;
41
41
  /**
42
- * Initializes a new Tweet from the given raw tweet data.
43
- *
44
- * @param tweet - The raw tweet data.
42
+ * @param tweet - The raw tweet details.
45
43
  */
46
44
  constructor(tweet: IRawTweet);
45
+ /**
46
+ * Extracts and deserializes the list of tweets from the given raw response data.
47
+ *
48
+ * @param response - The raw response data.
49
+ * @returns The deserialized list of tweets.
50
+ *
51
+ * @internal
52
+ */
53
+ static list(response: IResponse<unknown>): Tweet[];
54
+ /**
55
+ * Extracts and deserializes a single target tweet from the given raw response data.
56
+ *
57
+ * @param response - The raw response data.
58
+ * @returns The target deserialized tweet.
59
+ *
60
+ * @internal
61
+ */
62
+ static single(response: IResponse<unknown>): Tweet | undefined;
47
63
  }
48
64
  /**
49
65
  * The different types parsed entities like urls, media, mentions, hashtags, etc.
@@ -53,19 +69,17 @@ export declare class Tweet {
53
69
  export declare class TweetEntities {
54
70
  /** The list of hashtags mentioned in the tweet. */
55
71
  hashtags: string[];
56
- /** The list of urls mentioned in the tweet. */
57
- urls: string[];
58
72
  /** The list of IDs of users mentioned in the tweet. */
59
73
  mentionedUsers: string[];
74
+ /** The list of urls mentioned in the tweet. */
75
+ urls: string[];
60
76
  /**
61
- * Initializes the TweetEntities from the raw tweet entities.
62
- *
63
77
  * @param entities - The raw tweet entities.
64
78
  */
65
79
  constructor(entities: IRawTweetEntities);
66
80
  }
67
81
  /**
68
- * A single media content.
82
+ * The details of a single media content included in a tweet.
69
83
  *
70
84
  * @public
71
85
  */
@@ -75,9 +89,7 @@ export declare class TweetMedia {
75
89
  /** The direct URL to the media. */
76
90
  url: string;
77
91
  /**
78
- * Initializes the TweetMedia from the raw tweet media.
79
- *
80
- * @param media - The raw tweet media.
92
+ * @param media - The raw media details.
81
93
  */
82
94
  constructor(media: IRawExtendedMedia);
83
95
  }