rettiwt-api 4.2.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.
Files changed (179) hide show
  1. package/.eslintrc.js +2 -3
  2. package/.github/workflows/documentation.yml +1 -1
  3. package/.github/workflows/publish-alpha.yml +1 -1
  4. package/.github/workflows/publish.yml +1 -1
  5. package/.prettierignore +1 -1
  6. package/.tool-versions +1 -1
  7. package/README.md +100 -100
  8. package/dist/Rettiwt.d.ts +1 -1
  9. package/dist/Rettiwt.js +15 -8
  10. package/dist/Rettiwt.js.map +1 -1
  11. package/dist/cli.js +8 -11
  12. package/dist/cli.js.map +1 -1
  13. package/dist/collections/Extractors.d.ts +1 -0
  14. package/dist/collections/Extractors.js +38 -69
  15. package/dist/collections/Extractors.js.map +1 -1
  16. package/dist/collections/Groups.js +2 -1
  17. package/dist/collections/Groups.js.map +1 -1
  18. package/dist/collections/Requests.d.ts +3 -3
  19. package/dist/collections/Requests.js +36 -35
  20. package/dist/collections/Requests.js.map +1 -1
  21. package/dist/commands/List.js +21 -78
  22. package/dist/commands/List.js.map +1 -1
  23. package/dist/commands/Tweet.js +185 -370
  24. package/dist/commands/Tweet.js.map +1 -1
  25. package/dist/commands/User.js +129 -306
  26. package/dist/commands/User.js.map +1 -1
  27. package/dist/enums/Authentication.d.ts +18 -0
  28. package/dist/enums/Authentication.js +24 -0
  29. package/dist/enums/Authentication.js.map +1 -0
  30. package/dist/enums/Data.d.ts +12 -0
  31. package/dist/enums/Data.js +14 -1
  32. package/dist/enums/Data.js.map +1 -1
  33. package/dist/enums/Resource.d.ts +1 -0
  34. package/dist/enums/Resource.js +1 -0
  35. package/dist/enums/Resource.js.map +1 -1
  36. package/dist/helper/CliUtils.js +1 -2
  37. package/dist/helper/CliUtils.js.map +1 -1
  38. package/dist/helper/JsonUtils.js +6 -11
  39. package/dist/helper/JsonUtils.js.map +1 -1
  40. package/dist/index.d.ts +1 -2
  41. package/dist/index.js +1 -2
  42. package/dist/index.js.map +1 -1
  43. package/dist/models/args/FetchArgs.d.ts +4 -133
  44. package/dist/models/args/FetchArgs.js +12 -416
  45. package/dist/models/args/FetchArgs.js.map +1 -1
  46. package/dist/models/args/PostArgs.d.ts +16 -101
  47. package/dist/models/args/PostArgs.js +26 -258
  48. package/dist/models/args/PostArgs.js.map +1 -1
  49. package/dist/models/auth/AccountCredential.d.ts +13 -0
  50. package/dist/models/auth/AccountCredential.js +21 -0
  51. package/dist/models/auth/AccountCredential.js.map +1 -0
  52. package/dist/models/auth/AuthCookie.d.ts +19 -0
  53. package/dist/models/auth/AuthCookie.js +53 -0
  54. package/dist/models/auth/AuthCookie.js.map +1 -0
  55. package/dist/models/auth/AuthCredential.d.ts +28 -0
  56. package/dist/models/auth/AuthCredential.js +76 -0
  57. package/dist/models/auth/AuthCredential.js.map +1 -0
  58. package/dist/models/data/CursoredData.d.ts +3 -4
  59. package/dist/models/data/CursoredData.js +19 -19
  60. package/dist/models/data/CursoredData.js.map +1 -1
  61. package/dist/models/data/List.d.ts +2 -8
  62. package/dist/models/data/List.js +10 -4
  63. package/dist/models/data/List.js.map +1 -1
  64. package/dist/models/data/Notification.d.ts +5 -21
  65. package/dist/models/data/Notification.js +24 -33
  66. package/dist/models/data/Notification.js.map +1 -1
  67. package/dist/models/data/Tweet.d.ts +4 -17
  68. package/dist/models/data/Tweet.js +83 -73
  69. package/dist/models/data/Tweet.js.map +1 -1
  70. package/dist/models/data/User.d.ts +2 -15
  71. package/dist/models/data/User.js +33 -23
  72. package/dist/models/data/User.js.map +1 -1
  73. package/dist/models/errors/ApiError.js +8 -24
  74. package/dist/models/errors/ApiError.js.map +1 -1
  75. package/dist/models/errors/HttpError.js +8 -24
  76. package/dist/models/errors/HttpError.js.map +1 -1
  77. package/dist/models/errors/RettiwtError.js +5 -23
  78. package/dist/models/errors/RettiwtError.js.map +1 -1
  79. package/dist/models/errors/TimeoutError.js +5 -22
  80. package/dist/models/errors/TimeoutError.js.map +1 -1
  81. package/dist/services/{public → internal}/AuthService.d.ts +5 -34
  82. package/dist/services/internal/AuthService.js +109 -0
  83. package/dist/services/internal/AuthService.js.map +1 -0
  84. package/dist/services/internal/ErrorService.js +38 -40
  85. package/dist/services/internal/ErrorService.js.map +1 -1
  86. package/dist/services/internal/LogService.d.ts +0 -6
  87. package/dist/services/internal/LogService.js +12 -32
  88. package/dist/services/internal/LogService.js.map +1 -1
  89. package/dist/services/public/FetcherService.d.ts +5 -3
  90. package/dist/services/public/FetcherService.js +96 -141
  91. package/dist/services/public/FetcherService.js.map +1 -1
  92. package/dist/services/public/ListService.js +31 -100
  93. package/dist/services/public/ListService.js.map +1 -1
  94. package/dist/services/public/TweetService.d.ts +29 -4
  95. package/dist/services/public/TweetService.js +208 -386
  96. package/dist/services/public/TweetService.js.map +1 -1
  97. package/dist/services/public/UserService.js +186 -385
  98. package/dist/services/public/UserService.js.map +1 -1
  99. package/dist/types/RettiwtConfig.d.ts +8 -0
  100. package/dist/types/args/FetchArgs.d.ts +59 -0
  101. package/dist/types/args/FetchArgs.js +3 -0
  102. package/dist/types/args/FetchArgs.js.map +1 -0
  103. package/dist/types/args/PostArgs.d.ts +56 -0
  104. package/dist/types/args/PostArgs.js +3 -0
  105. package/dist/types/args/PostArgs.js.map +1 -0
  106. package/dist/types/auth/AccountCredential.d.ts +11 -0
  107. package/dist/types/auth/AccountCredential.js +3 -0
  108. package/dist/types/auth/AccountCredential.js.map +1 -0
  109. package/dist/types/auth/AuthCookie.d.ts +13 -0
  110. package/dist/types/auth/AuthCookie.js +3 -0
  111. package/dist/types/auth/AuthCookie.js.map +1 -0
  112. package/dist/types/auth/AuthCredential.d.ts +21 -0
  113. package/dist/types/auth/AuthCredential.js +3 -0
  114. package/dist/types/auth/AuthCredential.js.map +1 -0
  115. package/dist/types/data/CursoredData.d.ts +25 -0
  116. package/dist/types/data/CursoredData.js +3 -0
  117. package/dist/types/data/CursoredData.js.map +1 -0
  118. package/dist/types/data/List.d.ts +21 -0
  119. package/dist/types/data/List.js +3 -0
  120. package/dist/types/data/List.js.map +1 -0
  121. package/dist/types/data/Notification.d.ts +20 -0
  122. package/dist/types/data/Notification.js +3 -0
  123. package/dist/types/data/Notification.js.map +1 -0
  124. package/dist/types/data/Tweet.d.ts +71 -0
  125. package/dist/types/data/Tweet.js +3 -0
  126. package/dist/types/data/Tweet.js.map +1 -0
  127. package/dist/types/data/User.d.ts +35 -0
  128. package/dist/types/data/User.js +3 -0
  129. package/dist/types/data/User.js.map +1 -0
  130. package/eslint.config.mjs +17 -0
  131. package/package.json +22 -19
  132. package/src/Rettiwt.ts +1 -1
  133. package/src/cli.ts +0 -2
  134. package/src/collections/Extractors.ts +2 -0
  135. package/src/collections/Groups.ts +1 -0
  136. package/src/collections/Requests.ts +37 -36
  137. package/src/enums/Authentication.ts +19 -0
  138. package/src/enums/Data.ts +13 -0
  139. package/src/enums/Resource.ts +1 -0
  140. package/src/helper/JsonUtils.ts +1 -1
  141. package/src/index.ts +1 -2
  142. package/src/models/args/FetchArgs.ts +4 -470
  143. package/src/models/args/PostArgs.ts +20 -285
  144. package/src/models/auth/AccountCredential.ts +19 -0
  145. package/src/models/auth/AuthCookie.ts +56 -0
  146. package/src/models/auth/AuthCredential.ts +83 -0
  147. package/src/models/data/CursoredData.ts +12 -9
  148. package/src/models/data/List.ts +3 -14
  149. package/src/models/data/Notification.ts +6 -28
  150. package/src/models/data/Tweet.ts +17 -43
  151. package/src/models/data/User.ts +5 -31
  152. package/src/services/{public → internal}/AuthService.ts +28 -55
  153. package/src/services/internal/LogService.ts +4 -19
  154. package/src/services/public/FetcherService.ts +18 -8
  155. package/src/services/public/TweetService.ts +44 -4
  156. package/src/services/public/UserService.ts +2 -2
  157. package/src/types/RettiwtConfig.ts +7 -0
  158. package/src/types/args/FetchArgs.ts +64 -0
  159. package/src/types/args/PostArgs.ts +62 -0
  160. package/src/types/auth/AccountCredential.ts +13 -0
  161. package/src/types/auth/AuthCookie.ts +20 -0
  162. package/src/types/auth/AuthCredential.ts +26 -0
  163. package/src/types/data/CursoredData.ts +28 -0
  164. package/src/types/data/List.ts +27 -0
  165. package/src/types/data/Notification.ts +26 -0
  166. package/src/types/data/Tweet.ts +96 -0
  167. package/src/types/data/User.ts +48 -0
  168. package/tsconfig.json +7 -5
  169. package/.eslintignore +0 -3
  170. package/dist/commands/Auth.d.ts +0 -10
  171. package/dist/commands/Auth.js +0 -101
  172. package/dist/commands/Auth.js.map +0 -1
  173. package/dist/models/errors/DataValidationError.d.ts +0 -30
  174. package/dist/models/errors/DataValidationError.js +0 -34
  175. package/dist/models/errors/DataValidationError.js.map +0 -1
  176. package/dist/services/public/AuthService.js +0 -205
  177. package/dist/services/public/AuthService.js.map +0 -1
  178. package/src/commands/Auth.ts +0 -46
  179. package/src/models/errors/DataValidationError.ts +0 -44
@@ -0,0 +1,62 @@
1
+ import { INewTweet } from 'rettiwt-core';
2
+
3
+ /**
4
+ * Options specifying the media file to be uploaded.
5
+ *
6
+ * @public
7
+ */
8
+ export interface IUploadArgs {
9
+ /** The id allocated to the media file to be uploaded. */
10
+ id?: string;
11
+
12
+ /** The media file to be uploaded. */
13
+ media?: string | ArrayBuffer;
14
+
15
+ /**
16
+ * The size (in bytes) of the media file to be uploaded.
17
+ *
18
+ * @remarks The size must be \<= 5242880 bytes.
19
+ */
20
+ size?: number;
21
+ }
22
+
23
+ /**
24
+ * Options specifying the data that is to be posted.
25
+ *
26
+ * @public
27
+ */
28
+ export interface IPostArgs {
29
+ /**
30
+ * The id of the target resource.
31
+ *
32
+ * @remarks
33
+ * Required only when posting using the following resources:
34
+ * - {@link EResourceType.TWEET_LIKE}
35
+ * - {@link EResourceType.TWEET_RETWEET}
36
+ * - {@link EResourceType.TWEET_UNLIKE}
37
+ * - {@link EResourceType.TWEET_UNPOST}
38
+ * - {@link EResourceType.TWEET_UNRETWEET}
39
+ * - {@link EResourceType.USER_FOLLOW}
40
+ * - {@link EResourceType.USER_UNFOLLOW}
41
+ */
42
+ id?: string;
43
+
44
+ /**
45
+ * The tweet that is to be posted.
46
+ *
47
+ * @remarks
48
+ * Required only when posting a tweet using {@link EResourceType.TWEET_POST}
49
+ */
50
+ tweet?: INewTweet;
51
+
52
+ /**
53
+ * The media file to be uploaded.
54
+ *
55
+ * @remarks
56
+ * Required only when uploading a media using the following resources:
57
+ * - {@link EResourceType.MEDIA_UPLOAD_APPEND}
58
+ * - {@link EResourceType.MEDIA_UPLOAD_FINALIZE}
59
+ * - {@link EResourceType.MEDIA_UPLOAD_INITIALIZE}
60
+ */
61
+ upload?: IUploadArgs;
62
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The credentials of the Twitter account to be logged into.
3
+ */
4
+ export interface IAccountCredential {
5
+ /** The email id associated with the Twitter account. */
6
+ email: string;
7
+
8
+ /** The password to the Twitter account. */
9
+ password: string;
10
+
11
+ /** The username associated with the Twitter account. */
12
+ userName: string;
13
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The cookie containing the tokens that are used to authenticate against Twitter.
3
+ */
4
+ export interface IAuthCookie {
5
+ /* eslint-disable @typescript-eslint/naming-convention */
6
+
7
+ /** The bearer token from twitter.com. */
8
+ auth_token: string;
9
+
10
+ /** The CSRF token for the session. */
11
+ ct0: string;
12
+
13
+ /** Token used to authenticate a device. */
14
+ kdt: string;
15
+
16
+ /** Token used to authenticate a user using a Twitter ID. */
17
+ twid: string;
18
+
19
+ /* eslint-enable @typescript-eslint/naming-convention */
20
+ }
@@ -0,0 +1,26 @@
1
+ import { EAuthenticationType } from '../../enums/Authentication';
2
+
3
+ /**
4
+ * The credentials for authenticating against Twitter.
5
+ *
6
+ * Depending on which tokens are present, the authentication type is determined as follows:
7
+ * - authToken, guestToken =\> Guest authentication.
8
+ * - authToken, csrfToken, cookie =\> User authentication.
9
+ * - authToken, guestToken, cookie =\> Guest authentication while logging in.
10
+ */
11
+ export interface IAuthCredential {
12
+ /** The bearer token from twitter.com. */
13
+ authToken?: string;
14
+
15
+ /** The type of authentication. */
16
+ authenticationType?: EAuthenticationType;
17
+
18
+ /** The cookie of the twitter account, which is used to authenticate against twitter. */
19
+ cookies?: string;
20
+
21
+ /** The CSRF token for the session. */
22
+ csrfToken?: string;
23
+
24
+ /** The guest token provided by Twitter API. */
25
+ guestToken?: string;
26
+ }
@@ -0,0 +1,28 @@
1
+ import { INotification } from './Notification';
2
+ import { ITweet } from './Tweet';
3
+ import { IUser } from './User';
4
+
5
+ /**
6
+ * The data that is fetched batch-wise using a cursor.
7
+ *
8
+ * @typeParam T - Type of data to be stored.
9
+ *
10
+ * @public
11
+ */
12
+ export interface ICursoredData<T extends INotification | ITweet | IUser> {
13
+ /** The batch of data of the given type. */
14
+ list: T[];
15
+
16
+ /** The cursor to the next batch of data. */
17
+ next: ICursor;
18
+ }
19
+
20
+ /**
21
+ * The cursor to the batch of data to fetch.
22
+ *
23
+ * @public
24
+ */
25
+ export interface ICursor {
26
+ /** The cursor string. */
27
+ value: string;
28
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The details of a single Twitter List.
3
+ *
4
+ * @public
5
+ */
6
+ export interface IList {
7
+ /** The date and time of creation of the list, int UTC string format. */
8
+ createdAt: string;
9
+
10
+ /** The rest id of the user who created the list. */
11
+ createdBy: string;
12
+
13
+ /** The list description. */
14
+ description?: string;
15
+
16
+ /** The rest id of the list. */
17
+ id: string;
18
+
19
+ /** The number of memeber of the list. */
20
+ memberCount: number;
21
+
22
+ /** The name of the list. */
23
+ name: string;
24
+
25
+ /** The number of subscribers of the list. */
26
+ subscriberCount: number;
27
+ }
@@ -0,0 +1,26 @@
1
+ import { ENotificationType } from '../../enums/Data';
2
+
3
+ /**
4
+ * The details of a single notification.
5
+ *
6
+ * @public
7
+ */
8
+ export interface INotification {
9
+ /** The list of id of the users from whom the notification was received. */
10
+ from: string[];
11
+
12
+ /** The id of the notification. */
13
+ id: string;
14
+
15
+ /** The text contents of the notification. */
16
+ message: string;
17
+
18
+ /** The date/time at which the notification was received. */
19
+ receivedAt: Date;
20
+
21
+ /** The list of id of the target tweet(s) of the notification. */
22
+ target: string[];
23
+
24
+ /** The type of notification. */
25
+ type?: ENotificationType;
26
+ }
@@ -0,0 +1,96 @@
1
+ import { EMediaType } from 'rettiwt-core';
2
+
3
+ import { IUser } from './User';
4
+
5
+ /**
6
+ * The details of a single tweet.
7
+ *
8
+ * @public
9
+ */
10
+ export interface ITweet {
11
+ /** The number of bookmarks of a tweet. */
12
+ bookmarkCount: number;
13
+
14
+ /** The ID of tweet which started the current conversation. */
15
+ conversationId: string;
16
+
17
+ /** The date and time of creation of the tweet, in UTC string format. */
18
+ createdAt: string;
19
+
20
+ /** Additional tweet entities like urls, mentions, etc. */
21
+ entities: ITweetEntities;
22
+
23
+ /** The full text content of the tweet. */
24
+ fullText: string;
25
+
26
+ /** The rest id of the tweet. */
27
+ id: string;
28
+
29
+ /** The language in which the tweet is written. */
30
+ lang: string;
31
+
32
+ /** The number of likes of the tweet. */
33
+ likeCount: number;
34
+
35
+ /** The urls of the media contents of the tweet (if any). */
36
+ media?: ITweetMedia[];
37
+
38
+ /** The number of quotes of the tweet. */
39
+ quoteCount: number;
40
+
41
+ /** The tweet which is quoted in the tweet. */
42
+ quoted?: ITweet;
43
+
44
+ /** The number of replies to the tweet. */
45
+ replyCount: number;
46
+
47
+ /** The rest id of the tweet to which the tweet is a reply. */
48
+ replyTo?: string;
49
+
50
+ /** The number of retweets of the tweet. */
51
+ retweetCount: number;
52
+
53
+ /** The tweet which is retweeted in this tweet (if any). */
54
+ retweetedTweet?: ITweet;
55
+
56
+ /** The details of the user who made the tweet. */
57
+ tweetBy: IUser;
58
+
59
+ /** The URL to the tweet. */
60
+ url: string;
61
+
62
+ /** The number of views of a tweet. */
63
+ viewCount: number;
64
+ }
65
+
66
+ /**
67
+ * The different types parsed entities like urls, media, mentions, hashtags, etc.
68
+ *
69
+ * @public
70
+ */
71
+ export interface ITweetEntities {
72
+ /** The list of hashtags mentioned in the tweet. */
73
+ hashtags: string[];
74
+
75
+ /** The list of IDs of users mentioned in the tweet. */
76
+ mentionedUsers: string[];
77
+
78
+ /** The list of urls mentioned in the tweet. */
79
+ urls: string[];
80
+ }
81
+
82
+ /**
83
+ * The details of a single media content included in a tweet.
84
+ *
85
+ * @public
86
+ */
87
+ export interface ITweetMedia {
88
+ /** The thumbnail URL for the video content of the tweet. */
89
+ thumbnailUrl?: string;
90
+
91
+ /** The type of media. */
92
+ type: EMediaType;
93
+
94
+ /** The direct URL to the media. */
95
+ url: string;
96
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The details of a single user.
3
+ *
4
+ * @public
5
+ */
6
+ export interface IUser {
7
+ /** The creation date of user's account. */
8
+ createdAt: string;
9
+
10
+ /** The user's description. */
11
+ description?: string;
12
+
13
+ /** The number of followers of the user. */
14
+ followersCount: number;
15
+
16
+ /** The number of following of the user. */
17
+ followingsCount: number;
18
+
19
+ /** The full name of the user. */
20
+ fullName: string;
21
+
22
+ /** The rest id of the user. */
23
+ id: string;
24
+
25
+ /** Whether the account is verified or not. */
26
+ isVerified: boolean;
27
+
28
+ /** The number of tweets liked by the user. */
29
+ likeCount: number;
30
+
31
+ /** The location of user as provided by user. */
32
+ location?: string;
33
+
34
+ /** The rest id of the tweet pinned in the user's profile. */
35
+ pinnedTweet?: string;
36
+
37
+ /** The url of the profile banner image. */
38
+ profileBanner?: string;
39
+
40
+ /** The url of the profile image. */
41
+ profileImage: string;
42
+
43
+ /** The number of tweets made by the user. */
44
+ statusesCount: number;
45
+
46
+ /** The username/screenname of the user. */
47
+ userName: string;
48
+ }
package/tsconfig.json CHANGED
@@ -9,7 +9,7 @@
9
9
  // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10
10
  // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11
11
  /* Language and Environment */
12
- // "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
12
+ "target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
13
13
  // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
14
14
  // "jsx": "preserve", /* Specify what JSX code is generated. */
15
15
  "experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */,
@@ -22,9 +22,9 @@
22
22
  // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
23
23
  // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
24
24
  /* Modules */
25
- // "module": "commonjs", /* Specify what module code is generated. */
26
- "rootDir": "./src" /* Specify the root folder within your source files. */,
27
- // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
25
+ "module": "NodeNext" /* Specify what module code is generated. */,
26
+ "rootDir": "./src/" /* Specify the root folder within your source files. */,
27
+ "moduleResolution": "nodenext" /* Specify how TypeScript looks up a file from a given module specifier. */,
28
28
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
29
29
  // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
30
30
  // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
@@ -91,5 +91,7 @@
91
91
  /* Completeness */
92
92
  // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
93
93
  // "skipLibCheck": true /* Skip type checking all .d.ts files. */
94
- }
94
+ },
95
+ "include": ["src/**/*"],
96
+ "exclude": ["node_modules", "**/*.spec.ts"]
95
97
  }
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- node_modules/
2
- dist/
3
- docs/
@@ -1,10 +0,0 @@
1
- import { Command } from 'commander';
2
- import { Rettiwt } from '../Rettiwt';
3
- /**
4
- * Creates a new 'auth' command which uses the given Rettiwt instance.
5
- *
6
- * @param rettiwt - The Rettiwt instance to use.
7
- * @returns The created 'auth' command.
8
- */
9
- declare function createAuthCommand(rettiwt: Rettiwt): Command;
10
- export default createAuthCommand;
@@ -1,101 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var commander_1 = require("commander");
40
- var CliUtils_1 = require("../helper/CliUtils");
41
- /**
42
- * Creates a new 'auth' command which uses the given Rettiwt instance.
43
- *
44
- * @param rettiwt - The Rettiwt instance to use.
45
- * @returns The created 'auth' command.
46
- */
47
- function createAuthCommand(rettiwt) {
48
- var _this = this;
49
- // Creating the 'auth' command
50
- var auth = (0, commander_1.createCommand)('auth').description('Manage authentication');
51
- // Login
52
- auth.command('login')
53
- .description('Generate a new API key using Twitter account login credentials')
54
- .argument('<email>', 'The email id of the Twitter account')
55
- .argument('<username>', 'The username associated with the Twitter account')
56
- .argument('<password>', 'The password to the Twitter account')
57
- .action(function (email, username, password) { return __awaiter(_this, void 0, void 0, function () {
58
- var apiKey, error_1;
59
- return __generator(this, function (_a) {
60
- switch (_a.label) {
61
- case 0:
62
- _a.trys.push([0, 2, , 3]);
63
- return [4 /*yield*/, rettiwt.auth.login(email, username, password)];
64
- case 1:
65
- apiKey = _a.sent();
66
- (0, CliUtils_1.output)(apiKey);
67
- return [3 /*break*/, 3];
68
- case 2:
69
- error_1 = _a.sent();
70
- (0, CliUtils_1.output)(error_1);
71
- return [3 /*break*/, 3];
72
- case 3: return [2 /*return*/];
73
- }
74
- });
75
- }); });
76
- // Guest
77
- auth.command('guest')
78
- .description('Generate a new guest key')
79
- .action(function () { return __awaiter(_this, void 0, void 0, function () {
80
- var guestKey, error_2;
81
- return __generator(this, function (_a) {
82
- switch (_a.label) {
83
- case 0:
84
- _a.trys.push([0, 2, , 3]);
85
- return [4 /*yield*/, rettiwt.auth.guest()];
86
- case 1:
87
- guestKey = _a.sent();
88
- (0, CliUtils_1.output)(guestKey);
89
- return [3 /*break*/, 3];
90
- case 2:
91
- error_2 = _a.sent();
92
- (0, CliUtils_1.output)(error_2);
93
- return [3 /*break*/, 3];
94
- case 3: return [2 /*return*/];
95
- }
96
- });
97
- }); });
98
- return auth;
99
- }
100
- exports.default = createAuthCommand;
101
- //# sourceMappingURL=Auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Auth.js","sourceRoot":"","sources":["../../src/commands/Auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAmD;AAEnD,+CAA4C;AAG5C;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,OAAgB;IAA3C,iBAgCC;IA/BA,8BAA8B;IAC9B,IAAM,IAAI,GAAG,IAAA,yBAAa,EAAC,MAAM,CAAC,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAExE,QAAQ;IACR,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SACnB,WAAW,CAAC,gEAAgE,CAAC;SAC7E,QAAQ,CAAC,SAAS,EAAE,qCAAqC,CAAC;SAC1D,QAAQ,CAAC,YAAY,EAAE,kDAAkD,CAAC;SAC1E,QAAQ,CAAC,YAAY,EAAE,qCAAqC,CAAC;SAC7D,MAAM,CAAC,UAAO,KAAa,EAAE,QAAgB,EAAE,QAAgB;;;;;;oBAEvC,qBAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAA;;oBAApE,MAAM,GAAW,SAAmD;oBAC1E,IAAA,iBAAM,EAAC,MAAM,CAAC,CAAC;;;;oBAEf,IAAA,iBAAM,EAAC,OAAK,CAAC,CAAC;;;;;SAEf,CAAC,CAAC;IAEJ,QAAQ;IACR,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SACnB,WAAW,CAAC,0BAA0B,CAAC;SACvC,MAAM,CAAC;;;;;;oBAEmB,qBAAM,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,EAAA;;oBAA7C,QAAQ,GAAW,SAA0B;oBACnD,IAAA,iBAAM,EAAC,QAAQ,CAAC,CAAC;;;;oBAEjB,IAAA,iBAAM,EAAC,OAAK,CAAC,CAAC;;;;;SAEf,CAAC,CAAC;IAEJ,OAAO,IAAI,CAAC;AACb,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
@@ -1,30 +0,0 @@
1
- import { ValidationError } from 'class-validator';
2
- /**
3
- * Represents and error when any fields of a validation-enabled class fails to validate.
4
- *
5
- * @public
6
- */
7
- export declare class DataValidationError {
8
- /** The detaied error message(s). */
9
- details: ValidationErrorDetails[];
10
- /** The user-friendly error message. */
11
- message: string;
12
- /** The name of the error. */
13
- name: string;
14
- /**
15
- * @param data - The error details, as a list of type {@link ValidationError}
16
- */
17
- constructor(errorDetails: ValidationError[]);
18
- }
19
- /**
20
- * Represents the validation error details of a single field.
21
- *
22
- * @public
23
- */
24
- export declare class ValidationErrorDetails {
25
- /** The constraints which failed to be validated for the given field. */
26
- constraints: string[];
27
- /** The name of the field which failed validation. */
28
- field: string;
29
- constructor(details: ValidationError);
30
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationErrorDetails = exports.DataValidationError = void 0;
4
- /**
5
- * Represents and error when any fields of a validation-enabled class fails to validate.
6
- *
7
- * @public
8
- */
9
- var DataValidationError = /** @class */ (function () {
10
- /**
11
- * @param data - The error details, as a list of type {@link ValidationError}
12
- */
13
- function DataValidationError(errorDetails) {
14
- this.name = 'VALIDATION_ERROR';
15
- this.message = 'One or more validation error(s) occured, check details field.';
16
- this.details = errorDetails.map(function (error) { return new ValidationErrorDetails(error); });
17
- }
18
- return DataValidationError;
19
- }());
20
- exports.DataValidationError = DataValidationError;
21
- /**
22
- * Represents the validation error details of a single field.
23
- *
24
- * @public
25
- */
26
- var ValidationErrorDetails = /** @class */ (function () {
27
- function ValidationErrorDetails(details) {
28
- this.field = details.property;
29
- this.constraints = Object.values(details.constraints);
30
- }
31
- return ValidationErrorDetails;
32
- }());
33
- exports.ValidationErrorDetails = ValidationErrorDetails;
34
- //# sourceMappingURL=DataValidationError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataValidationError.js","sourceRoot":"","sources":["../../../src/models/errors/DataValidationError.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH;IAUC;;OAEG;IACH,6BAAmB,YAA+B;QACjD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,+DAA+D,CAAC;QAC/E,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAjC,CAAiC,CAAC,CAAC;IAC/E,CAAC;IACF,0BAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,kDAAmB;AAoBhC;;;;GAIG;AACH;IAOC,gCAAmB,OAAwB;QAC1C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC;IACxD,CAAC;IACF,6BAAC;AAAD,CAAC,AAXD,IAWC;AAXY,wDAAsB"}