rettiwt-api 5.0.0-alpha.0 → 5.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -3
- package/.github/workflows/documentation.yml +1 -1
- package/.github/workflows/publish-alpha.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/.prettierignore +1 -1
- package/.tool-versions +1 -1
- package/README.md +100 -100
- package/dist/Rettiwt.d.ts +1 -1
- package/dist/Rettiwt.js +15 -8
- package/dist/Rettiwt.js.map +1 -1
- package/dist/cli.js +8 -11
- package/dist/cli.js.map +1 -1
- package/dist/collections/Extractors.d.ts +1 -0
- package/dist/collections/Extractors.js +38 -69
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +2 -1
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.d.ts +3 -3
- package/dist/collections/Requests.js +36 -35
- package/dist/collections/Requests.js.map +1 -1
- package/dist/commands/List.js +21 -78
- package/dist/commands/List.js.map +1 -1
- package/dist/commands/Tweet.js +185 -370
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/commands/User.js +129 -306
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Authentication.d.ts +18 -0
- package/dist/enums/Authentication.js +24 -0
- package/dist/enums/Authentication.js.map +1 -0
- package/dist/enums/Data.d.ts +12 -0
- package/dist/enums/Data.js +14 -1
- package/dist/enums/Data.js.map +1 -1
- package/dist/enums/Resource.d.ts +1 -0
- package/dist/enums/Resource.js +1 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/helper/CliUtils.js +1 -2
- package/dist/helper/CliUtils.js.map +1 -1
- package/dist/helper/JsonUtils.js +6 -11
- package/dist/helper/JsonUtils.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/models/args/FetchArgs.d.ts +4 -133
- package/dist/models/args/FetchArgs.js +12 -416
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/args/PostArgs.d.ts +16 -101
- package/dist/models/args/PostArgs.js +26 -258
- package/dist/models/args/PostArgs.js.map +1 -1
- package/dist/models/auth/AccountCredential.d.ts +13 -0
- package/dist/models/auth/AccountCredential.js +21 -0
- package/dist/models/auth/AccountCredential.js.map +1 -0
- package/dist/models/auth/AuthCookie.d.ts +19 -0
- package/dist/models/auth/AuthCookie.js +53 -0
- package/dist/models/auth/AuthCookie.js.map +1 -0
- package/dist/models/auth/AuthCredential.d.ts +28 -0
- package/dist/models/auth/AuthCredential.js +76 -0
- package/dist/models/auth/AuthCredential.js.map +1 -0
- package/dist/models/data/CursoredData.d.ts +3 -4
- package/dist/models/data/CursoredData.js +19 -19
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/models/data/List.d.ts +2 -8
- package/dist/models/data/List.js +10 -4
- package/dist/models/data/List.js.map +1 -1
- package/dist/models/data/Notification.d.ts +5 -21
- package/dist/models/data/Notification.js +24 -33
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +6 -23
- package/dist/models/data/Tweet.js +93 -97
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +2 -15
- package/dist/models/data/User.js +33 -23
- package/dist/models/data/User.js.map +1 -1
- package/dist/models/errors/ApiError.js +8 -24
- package/dist/models/errors/ApiError.js.map +1 -1
- package/dist/models/errors/HttpError.js +8 -24
- package/dist/models/errors/HttpError.js.map +1 -1
- package/dist/models/errors/RettiwtError.js +5 -23
- package/dist/models/errors/RettiwtError.js.map +1 -1
- package/dist/models/errors/TimeoutError.js +5 -22
- package/dist/models/errors/TimeoutError.js.map +1 -1
- package/dist/services/{public → internal}/AuthService.d.ts +5 -34
- package/dist/services/internal/AuthService.js +109 -0
- package/dist/services/internal/AuthService.js.map +1 -0
- package/dist/services/internal/ErrorService.js +38 -40
- package/dist/services/internal/ErrorService.js.map +1 -1
- package/dist/services/internal/LogService.d.ts +0 -6
- package/dist/services/internal/LogService.js +12 -32
- package/dist/services/internal/LogService.js.map +1 -1
- package/dist/services/public/FetcherService.d.ts +5 -3
- package/dist/services/public/FetcherService.js +96 -141
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.js +31 -100
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +29 -4
- package/dist/services/public/TweetService.js +208 -386
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.js +186 -385
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/RettiwtConfig.d.ts +8 -0
- package/dist/types/args/FetchArgs.d.ts +59 -0
- package/dist/types/args/FetchArgs.js +3 -0
- package/dist/types/args/FetchArgs.js.map +1 -0
- package/dist/types/args/PostArgs.d.ts +56 -0
- package/dist/types/args/PostArgs.js +3 -0
- package/dist/types/args/PostArgs.js.map +1 -0
- package/dist/types/auth/AccountCredential.d.ts +11 -0
- package/dist/types/auth/AccountCredential.js +3 -0
- package/dist/types/auth/AccountCredential.js.map +1 -0
- package/dist/types/auth/AuthCookie.d.ts +13 -0
- package/dist/types/auth/AuthCookie.js +3 -0
- package/dist/types/auth/AuthCookie.js.map +1 -0
- package/dist/types/auth/AuthCredential.d.ts +21 -0
- package/dist/types/auth/AuthCredential.js +3 -0
- package/dist/types/auth/AuthCredential.js.map +1 -0
- package/dist/types/data/CursoredData.d.ts +25 -0
- package/dist/types/data/CursoredData.js +3 -0
- package/dist/types/data/CursoredData.js.map +1 -0
- package/dist/types/data/List.d.ts +21 -0
- package/dist/types/data/List.js +3 -0
- package/dist/types/data/List.js.map +1 -0
- package/dist/types/data/Notification.d.ts +20 -0
- package/dist/types/data/Notification.js +3 -0
- package/dist/types/data/Notification.js.map +1 -0
- package/dist/types/data/Tweet.d.ts +71 -0
- package/dist/types/data/Tweet.js +3 -0
- package/dist/types/data/Tweet.js.map +1 -0
- package/dist/types/data/User.d.ts +35 -0
- package/dist/types/data/User.js +3 -0
- package/dist/types/data/User.js.map +1 -0
- package/eslint.config.mjs +17 -0
- package/package.json +22 -19
- package/src/Rettiwt.ts +1 -1
- package/src/cli.ts +0 -2
- package/src/collections/Extractors.ts +2 -0
- package/src/collections/Groups.ts +1 -0
- package/src/collections/Requests.ts +37 -36
- package/src/enums/Authentication.ts +19 -0
- package/src/enums/Data.ts +13 -0
- package/src/enums/Resource.ts +1 -0
- package/src/helper/JsonUtils.ts +1 -1
- package/src/index.ts +1 -2
- package/src/models/args/FetchArgs.ts +4 -470
- package/src/models/args/PostArgs.ts +20 -285
- package/src/models/auth/AccountCredential.ts +19 -0
- package/src/models/auth/AuthCookie.ts +56 -0
- package/src/models/auth/AuthCredential.ts +83 -0
- package/src/models/data/CursoredData.ts +12 -9
- package/src/models/data/List.ts +3 -14
- package/src/models/data/Notification.ts +6 -28
- package/src/models/data/Tweet.ts +28 -70
- package/src/models/data/User.ts +5 -31
- package/src/services/{public → internal}/AuthService.ts +28 -55
- package/src/services/internal/LogService.ts +4 -19
- package/src/services/public/FetcherService.ts +18 -8
- package/src/services/public/TweetService.ts +44 -4
- package/src/services/public/UserService.ts +2 -2
- package/src/types/RettiwtConfig.ts +7 -0
- package/src/types/args/FetchArgs.ts +64 -0
- package/src/types/args/PostArgs.ts +62 -0
- package/src/types/auth/AccountCredential.ts +13 -0
- package/src/types/auth/AuthCookie.ts +20 -0
- package/src/types/auth/AuthCredential.ts +26 -0
- package/src/types/data/CursoredData.ts +28 -0
- package/src/types/data/List.ts +27 -0
- package/src/types/data/Notification.ts +26 -0
- package/src/types/data/Tweet.ts +96 -0
- package/src/types/data/User.ts +48 -0
- package/tsconfig.json +7 -5
- package/.eslintignore +0 -3
- package/dist/commands/Auth.d.ts +0 -10
- package/dist/commands/Auth.js +0 -101
- package/dist/commands/Auth.js.map +0 -1
- package/dist/models/errors/DataValidationError.d.ts +0 -30
- package/dist/models/errors/DataValidationError.js +0 -34
- package/dist/models/errors/DataValidationError.js.map +0 -1
- package/dist/services/public/AuthService.js +0 -205
- package/dist/services/public/AuthService.js.map +0 -1
- package/src/commands/Auth.ts +0 -46
- package/src/models/errors/DataValidationError.ts +0 -44
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Cursor = exports.CursoredData = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const Data_1 = require("../../enums/Data");
|
|
5
|
+
const JsonUtils_1 = require("../../helper/JsonUtils");
|
|
6
|
+
const Notification_1 = require("./Notification");
|
|
7
|
+
const Tweet_1 = require("./Tweet");
|
|
8
|
+
const User_1 = require("./User");
|
|
9
9
|
/**
|
|
10
10
|
* The data that is fetched batch-wise using a cursor.
|
|
11
11
|
*
|
|
@@ -13,46 +13,46 @@ var User_1 = require("./User");
|
|
|
13
13
|
*
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
class CursoredData {
|
|
17
|
+
list = [];
|
|
18
|
+
next = new Cursor('');
|
|
17
19
|
/**
|
|
18
20
|
* @param response - The raw response.
|
|
19
21
|
* @param type - The base type of the data included in the batch.
|
|
20
22
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/** The batch of data of the given type. */
|
|
23
|
+
constructor(response, type) {
|
|
24
|
+
// Initializing defaults
|
|
24
25
|
this.list = [];
|
|
25
|
-
/** The cursor to the next batch of data. */
|
|
26
26
|
this.next = new Cursor('');
|
|
27
27
|
if (type == Data_1.EBaseType.TWEET) {
|
|
28
28
|
this.list = Tweet_1.Tweet.list(response);
|
|
29
|
-
this.next = new Cursor((
|
|
29
|
+
this.next = new Cursor((0, JsonUtils_1.findByFilter)(response, 'cursorType', 'Bottom')[0]?.value ?? '');
|
|
30
30
|
}
|
|
31
31
|
else if (type == Data_1.EBaseType.USER) {
|
|
32
32
|
this.list = User_1.User.list(response);
|
|
33
|
-
this.next = new Cursor((
|
|
33
|
+
this.next = new Cursor((0, JsonUtils_1.findByFilter)(response, 'cursorType', 'Bottom')[0]?.value ?? '');
|
|
34
34
|
}
|
|
35
35
|
else if (type == Data_1.EBaseType.NOTIFICATION) {
|
|
36
36
|
this.list = Notification_1.Notification.list(response);
|
|
37
|
-
this.next = new Cursor((
|
|
37
|
+
this.next = new Cursor((0, JsonUtils_1.findByFilter)(response, 'cursorType', 'Top')[0]?.value ?? '');
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
}());
|
|
40
|
+
}
|
|
42
41
|
exports.CursoredData = CursoredData;
|
|
43
42
|
/**
|
|
44
43
|
* The cursor to the batch of data to fetch.
|
|
45
44
|
*
|
|
46
45
|
* @public
|
|
47
46
|
*/
|
|
48
|
-
|
|
47
|
+
class Cursor {
|
|
48
|
+
/** The cursor string. */
|
|
49
|
+
value;
|
|
49
50
|
/**
|
|
50
51
|
* @param cursor - The cursor string.
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
+
constructor(cursor) {
|
|
53
54
|
this.value = cursor;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
}());
|
|
56
|
+
}
|
|
57
57
|
exports.Cursor = Cursor;
|
|
58
58
|
//# sourceMappingURL=CursoredData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursoredData.js","sourceRoot":"","sources":["../../../src/models/data/CursoredData.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"CursoredData.js","sourceRoot":"","sources":["../../../src/models/data/CursoredData.ts"],"names":[],"mappings":";;;AAEA,2CAA6C;AAE7C,sDAAsD;AAItD,iDAA8C;AAC9C,mCAAgC;AAChC,iCAA8B;AAE9B;;;;;;GAMG;AACH,MAAa,YAAY;IACjB,IAAI,GAAQ,EAAE,CAAC;IACf,IAAI,GAAW,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC;IAErC;;;OAGG;IACH,YAAmB,QAA8B,EAAE,IAAe;QACjE,wBAAwB;QAC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1,17 @@
|
|
|
1
1
|
import { IList as IRawList } from 'rettiwt-core';
|
|
2
|
+
import { IList } from '../../types/data/List';
|
|
2
3
|
/**
|
|
3
4
|
* The details of a single Twitter List.
|
|
4
5
|
*
|
|
5
6
|
* @public
|
|
6
7
|
*/
|
|
7
|
-
export declare class List {
|
|
8
|
-
/** The date and time of creation of the list, int UTC string format. */
|
|
8
|
+
export declare class List implements IList {
|
|
9
9
|
createdAt: string;
|
|
10
|
-
/** The rest id of the user who created the list. */
|
|
11
10
|
createdBy: string;
|
|
12
|
-
/** The list description. */
|
|
13
11
|
description?: string;
|
|
14
|
-
/** The rest id of the list. */
|
|
15
12
|
id: string;
|
|
16
|
-
/** The number of memeber of the list. */
|
|
17
13
|
memberCount: number;
|
|
18
|
-
/** The name of the list. */
|
|
19
14
|
name: string;
|
|
20
|
-
/** The number of subscribers of the list. */
|
|
21
15
|
subscriberCount: number;
|
|
22
16
|
/**
|
|
23
17
|
* @param list - The raw list details.
|
package/dist/models/data/List.js
CHANGED
|
@@ -6,11 +6,18 @@ exports.List = void 0;
|
|
|
6
6
|
*
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
class List {
|
|
10
|
+
createdAt;
|
|
11
|
+
createdBy;
|
|
12
|
+
description;
|
|
13
|
+
id;
|
|
14
|
+
memberCount;
|
|
15
|
+
name;
|
|
16
|
+
subscriberCount;
|
|
10
17
|
/**
|
|
11
18
|
* @param list - The raw list details.
|
|
12
19
|
*/
|
|
13
|
-
|
|
20
|
+
constructor(list) {
|
|
14
21
|
this.id = list.id_str;
|
|
15
22
|
this.name = list.name;
|
|
16
23
|
this.createdAt = new Date(list.created_at).toISOString();
|
|
@@ -19,7 +26,6 @@ var List = /** @class */ (function () {
|
|
|
19
26
|
this.subscriberCount = list.subscriber_count;
|
|
20
27
|
this.createdBy = list.user_results.result.id;
|
|
21
28
|
}
|
|
22
|
-
|
|
23
|
-
}());
|
|
29
|
+
}
|
|
24
30
|
exports.List = List;
|
|
25
31
|
//# sourceMappingURL=List.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/models/data/List.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/models/data/List.ts"],"names":[],"mappings":";;;AAIA;;;;GAIG;AACH,MAAa,IAAI;IACT,SAAS,CAAS;IAClB,SAAS,CAAS;IAClB,WAAW,CAAU;IACrB,EAAE,CAAS;IACX,WAAW,CAAS;IACpB,IAAI,CAAS;IACb,eAAe,CAAS;IAE/B;;OAEG;IACH,YAAmB,IAAc;QAChC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1E,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9C,CAAC;CACD;AArBD,oBAqBC"}
|
|
@@ -1,38 +1,22 @@
|
|
|
1
|
-
import { INotification } from 'rettiwt-core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare enum ENotificationType {
|
|
8
|
-
RECOMMENDATION = "RECOMMENDATION",
|
|
9
|
-
INFORMATION = "INFORMATION",
|
|
10
|
-
LIVE = "LIVE",
|
|
11
|
-
ALERT = "ALERT",
|
|
12
|
-
UNDEFINED = "UNDEFINED"
|
|
13
|
-
}
|
|
1
|
+
import { INotification as IRawNotification } from 'rettiwt-core';
|
|
2
|
+
import { ENotificationType } from '../../enums/Data';
|
|
3
|
+
import { INotification } from '../../types/data/Notification';
|
|
14
4
|
/**
|
|
15
5
|
* The details of a single notification.
|
|
16
6
|
*
|
|
17
7
|
* @public
|
|
18
8
|
*/
|
|
19
|
-
export declare class Notification {
|
|
20
|
-
/** The list of id of the users from whom the notification was received. */
|
|
9
|
+
export declare class Notification implements INotification {
|
|
21
10
|
from: string[];
|
|
22
|
-
/** The id of the notification. */
|
|
23
11
|
id: string;
|
|
24
|
-
/** The text contents of the notification. */
|
|
25
12
|
message: string;
|
|
26
|
-
/** The date/time at which the notification was received. */
|
|
27
13
|
receivedAt: Date;
|
|
28
|
-
/** The list of id of the target tweet(s) of the notification. */
|
|
29
14
|
target: string[];
|
|
30
|
-
/** The type of notification. */
|
|
31
15
|
type?: ENotificationType;
|
|
32
16
|
/**
|
|
33
17
|
* @param notification - The raw notification details.
|
|
34
18
|
*/
|
|
35
|
-
constructor(notification:
|
|
19
|
+
constructor(notification: IRawNotification);
|
|
36
20
|
/**
|
|
37
21
|
* Extracts and deserializes the list of notifications from the given raw response data.
|
|
38
22
|
*
|
|
@@ -1,46 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Notification =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* The different types of notifications.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
var ENotificationType;
|
|
12
|
-
(function (ENotificationType) {
|
|
13
|
-
ENotificationType["RECOMMENDATION"] = "RECOMMENDATION";
|
|
14
|
-
ENotificationType["INFORMATION"] = "INFORMATION";
|
|
15
|
-
ENotificationType["LIVE"] = "LIVE";
|
|
16
|
-
ENotificationType["ALERT"] = "ALERT";
|
|
17
|
-
ENotificationType["UNDEFINED"] = "UNDEFINED";
|
|
18
|
-
})(ENotificationType || (exports.ENotificationType = ENotificationType = {}));
|
|
3
|
+
exports.Notification = void 0;
|
|
4
|
+
const rettiwt_core_1 = require("rettiwt-core");
|
|
5
|
+
const Data_1 = require("../../enums/Data");
|
|
6
|
+
const JsonUtils_1 = require("../../helper/JsonUtils");
|
|
19
7
|
/**
|
|
20
8
|
* The details of a single notification.
|
|
21
9
|
*
|
|
22
10
|
* @public
|
|
23
11
|
*/
|
|
24
|
-
|
|
12
|
+
class Notification {
|
|
13
|
+
from;
|
|
14
|
+
id;
|
|
15
|
+
message;
|
|
16
|
+
receivedAt;
|
|
17
|
+
target;
|
|
18
|
+
type;
|
|
25
19
|
/**
|
|
26
20
|
* @param notification - The raw notification details.
|
|
27
21
|
*/
|
|
28
|
-
|
|
29
|
-
var _a, _b, _c, _d;
|
|
22
|
+
constructor(notification) {
|
|
30
23
|
// Getting the original notification type
|
|
31
|
-
|
|
32
|
-
this.from =
|
|
33
|
-
? notification.template.aggregateUserActionsV1.fromUsers.map(
|
|
24
|
+
const notificationType = (0, JsonUtils_1.findKeyByValue)(rettiwt_core_1.ENotificationType, notification.icon.id);
|
|
25
|
+
this.from = notification.template?.aggregateUserActionsV1?.fromUsers
|
|
26
|
+
? notification.template.aggregateUserActionsV1.fromUsers.map((item) => item.user.id)
|
|
34
27
|
: [];
|
|
35
28
|
this.id = notification.id;
|
|
36
29
|
this.message = notification.message.text;
|
|
37
30
|
this.receivedAt = new Date(Number(notification.timestampMs));
|
|
38
|
-
this.target =
|
|
39
|
-
? notification.template.aggregateUserActionsV1.targetObjects.map(
|
|
31
|
+
this.target = notification.template?.aggregateUserActionsV1?.targetObjects
|
|
32
|
+
? notification.template.aggregateUserActionsV1.targetObjects.map((item) => item.tweet.id)
|
|
40
33
|
: [];
|
|
41
34
|
this.type = notificationType
|
|
42
|
-
? ENotificationType[notificationType]
|
|
43
|
-
: ENotificationType.UNDEFINED;
|
|
35
|
+
? Data_1.ENotificationType[notificationType]
|
|
36
|
+
: Data_1.ENotificationType.UNDEFINED;
|
|
44
37
|
}
|
|
45
38
|
/**
|
|
46
39
|
* Extracts and deserializes the list of notifications from the given raw response data.
|
|
@@ -51,19 +44,17 @@ var Notification = /** @class */ (function () {
|
|
|
51
44
|
*
|
|
52
45
|
* @internal
|
|
53
46
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
static list(response) {
|
|
48
|
+
const notifications = [];
|
|
56
49
|
// Extracting notifications
|
|
57
50
|
if (response.globalObjects.notifications) {
|
|
58
51
|
// Iterating over the raw list of notifications
|
|
59
|
-
for (
|
|
60
|
-
var _b = _a[_i], value = _b[1];
|
|
52
|
+
for (const [, value] of Object.entries(response.globalObjects.notifications)) {
|
|
61
53
|
notifications.push(new Notification(value));
|
|
62
54
|
}
|
|
63
55
|
}
|
|
64
56
|
return notifications;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
68
59
|
exports.Notification = Notification;
|
|
69
60
|
//# sourceMappingURL=Notification.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notification.js","sourceRoot":"","sources":["../../../src/models/data/Notification.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"Notification.js","sourceRoot":"","sources":["../../../src/models/data/Notification.ts"],"names":[],"mappings":";;;AAAA,+CAIsB;AAEtB,2CAAqD;AACrD,sDAAwD;AAGxD;;;;GAIG;AACH,MAAa,YAAY;IACjB,IAAI,CAAW;IACf,EAAE,CAAS;IACX,OAAO,CAAS;IAChB,UAAU,CAAO;IACjB,MAAM,CAAW;IACjB,IAAI,CAAqB;IAEhC;;OAEG;IACH,YAAmB,YAA8B;QAChD,yCAAyC;QACzC,MAAM,gBAAgB,GAAuB,IAAA,0BAAc,EAAC,gCAAyB,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE7G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,CAAC;YACjE,CAAC;QACF,CAAC;QAED,OAAO,aAAa,CAAC;IACtB,CAAC;CACD;AArDD,oCAqDC"}
|
|
@@ -1,54 +1,38 @@
|
|
|
1
1
|
import { EMediaType, IExtendedMedia as IRawExtendedMedia, ITweet as IRawTweet, IEntities as IRawTweetEntities } from 'rettiwt-core';
|
|
2
|
+
import { ITweet } from '../../types/data/Tweet';
|
|
2
3
|
import { User } from './User';
|
|
3
4
|
/**
|
|
4
5
|
* The details of a single tweet.
|
|
5
6
|
*
|
|
6
7
|
* @public
|
|
7
8
|
*/
|
|
8
|
-
export declare class Tweet {
|
|
9
|
-
/** The number of bookmarks of a tweet. */
|
|
9
|
+
export declare class Tweet implements ITweet {
|
|
10
10
|
bookmarkCount: number;
|
|
11
|
-
|
|
11
|
+
conversationId: string;
|
|
12
12
|
createdAt: string;
|
|
13
|
-
/** Additional tweet entities like urls, mentions, etc. */
|
|
14
13
|
entities: TweetEntities;
|
|
15
|
-
/** The full text content of the tweet. */
|
|
16
14
|
fullText: string;
|
|
17
|
-
/** The rest id of the tweet. */
|
|
18
15
|
id: string;
|
|
19
|
-
/** The language in which the tweet is written. */
|
|
20
16
|
lang: string;
|
|
21
|
-
/** The number of likes of the tweet. */
|
|
22
17
|
likeCount: number;
|
|
23
|
-
/** The urls of the media contents of the tweet (if any). */
|
|
24
18
|
media?: TweetMedia[];
|
|
25
|
-
/** The number of quotes of the tweet. */
|
|
26
19
|
quoteCount: number;
|
|
27
|
-
/** The tweet which is quoted in the tweet. */
|
|
28
20
|
quoted?: Tweet;
|
|
29
|
-
/** The number of replies to the tweet. */
|
|
30
21
|
replyCount: number;
|
|
31
|
-
|
|
32
|
-
replyTo?: Tweet;
|
|
33
|
-
/** The number of retweets of the tweet. */
|
|
22
|
+
replyTo?: string;
|
|
34
23
|
retweetCount: number;
|
|
35
|
-
/** The tweet which is retweeted in this tweet (if any). */
|
|
36
24
|
retweetedTweet?: Tweet;
|
|
37
|
-
/** The details of the user who made the tweet. */
|
|
38
25
|
tweetBy: User;
|
|
39
|
-
|
|
26
|
+
url: string;
|
|
40
27
|
viewCount: number;
|
|
41
28
|
/**
|
|
42
29
|
* @param tweet - The raw tweet details.
|
|
43
|
-
* @param response - The raw response
|
|
44
30
|
*/
|
|
45
|
-
constructor(tweet: IRawTweet
|
|
46
|
-
private getParentTweet;
|
|
31
|
+
constructor(tweet: IRawTweet);
|
|
47
32
|
/**
|
|
48
33
|
* Extract and deserialize the original quoted tweet from the given raw tweet.
|
|
49
34
|
*
|
|
50
35
|
* @param tweet - The raw tweet.
|
|
51
|
-
* @param response - The raw response
|
|
52
36
|
*
|
|
53
37
|
* @returns - The deserialized original quoted tweet.
|
|
54
38
|
*/
|
|
@@ -57,7 +41,6 @@ export declare class Tweet {
|
|
|
57
41
|
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
58
42
|
*
|
|
59
43
|
* @param tweet - The raw tweet.
|
|
60
|
-
* @param response - The raw response
|
|
61
44
|
*
|
|
62
45
|
* @returns - The deserialized original retweeted tweet.
|
|
63
46
|
*/
|