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.
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 +6 -23
  68. package/dist/models/data/Tweet.js +93 -97
  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 +28 -70
  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,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EAuthenticationErrors = exports.EAuthenticationType = void 0;
4
+ /**
5
+ * The different types of authentication for authenticating against Twitter.
6
+ */
7
+ var EAuthenticationType;
8
+ (function (EAuthenticationType) {
9
+ EAuthenticationType["GUEST"] = "GUEST";
10
+ EAuthenticationType["USER"] = "USER";
11
+ EAuthenticationType["LOGIN"] = "LOGIN";
12
+ })(EAuthenticationType || (exports.EAuthenticationType = EAuthenticationType = {}));
13
+ /**
14
+ * Different types of error messages related to authentication returned by services.
15
+ */
16
+ var EAuthenticationErrors;
17
+ (function (EAuthenticationErrors) {
18
+ EAuthenticationErrors["NOT_AUTHENTICATED"] = "Cannot fetch this data without authentication";
19
+ EAuthenticationErrors["INVALID_EMAIL"] = "No Twitter account found for the given email address";
20
+ EAuthenticationErrors["INVALID_USERNAME"] = "Incorrect username given for the given Twitter account";
21
+ EAuthenticationErrors["INVALID_PASSWORD"] = "Incorrect password given for the given Twitter account";
22
+ EAuthenticationErrors["AUTHENTICATION_FAILED"] = "Failed to authenticate using the given account Credentials";
23
+ })(EAuthenticationErrors || (exports.EAuthenticationErrors = EAuthenticationErrors = {}));
24
+ //# sourceMappingURL=Authentication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Authentication.js","sourceRoot":"","sources":["../../src/enums/Authentication.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC9B,sCAAe,CAAA;IACf,oCAAa,CAAA;IACb,sCAAe,CAAA;AAChB,CAAC,EAJW,mBAAmB,mCAAnB,mBAAmB,QAI9B;AAED;;GAEG;AACH,IAAY,qBAMX;AAND,WAAY,qBAAqB;IAChC,4FAAmE,CAAA;IACnE,+FAAsE,CAAA;IACtE,oGAA2E,CAAA;IAC3E,oGAA2E,CAAA;IAC3E,6GAAoF,CAAA;AACrF,CAAC,EANW,qBAAqB,qCAArB,qBAAqB,QAMhC"}
@@ -8,3 +8,15 @@ export declare enum EBaseType {
8
8
  TWEET = "Tweet",
9
9
  USER = "User"
10
10
  }
11
+ /**
12
+ * The different types of notifications.
13
+ *
14
+ * @public
15
+ */
16
+ export declare enum ENotificationType {
17
+ RECOMMENDATION = "RECOMMENDATION",
18
+ INFORMATION = "INFORMATION",
19
+ LIVE = "LIVE",
20
+ ALERT = "ALERT",
21
+ UNDEFINED = "UNDEFINED"
22
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EBaseType = void 0;
3
+ exports.ENotificationType = exports.EBaseType = void 0;
4
4
  /**
5
5
  * The different base types of data contained in response.
6
6
  *
@@ -12,4 +12,17 @@ var EBaseType;
12
12
  EBaseType["TWEET"] = "Tweet";
13
13
  EBaseType["USER"] = "User";
14
14
  })(EBaseType || (exports.EBaseType = EBaseType = {}));
15
+ /**
16
+ * The different types of notifications.
17
+ *
18
+ * @public
19
+ */
20
+ var ENotificationType;
21
+ (function (ENotificationType) {
22
+ ENotificationType["RECOMMENDATION"] = "RECOMMENDATION";
23
+ ENotificationType["INFORMATION"] = "INFORMATION";
24
+ ENotificationType["LIVE"] = "LIVE";
25
+ ENotificationType["ALERT"] = "ALERT";
26
+ ENotificationType["UNDEFINED"] = "UNDEFINED";
27
+ })(ENotificationType || (exports.ENotificationType = ENotificationType = {}));
15
28
  //# sourceMappingURL=Data.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Data.js","sourceRoot":"","sources":["../../src/enums/Data.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,SAIX;AAJD,WAAY,SAAS;IACpB,0CAA6B,CAAA;IAC7B,4BAAe,CAAA;IACf,0BAAa,CAAA;AACd,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB"}
1
+ {"version":3,"file":"Data.js","sourceRoot":"","sources":["../../src/enums/Data.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,SAIX;AAJD,WAAY,SAAS;IACpB,0CAA6B,CAAA;IAC7B,4BAAe,CAAA;IACf,0BAAa,CAAA;AACd,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB;AAED;;;;GAIG;AACH,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC5B,sDAAiC,CAAA;IACjC,gDAA2B,CAAA;IAC3B,kCAAa,CAAA;IACb,oCAAe,CAAA;IACf,4CAAuB,CAAA;AACxB,CAAC,EANW,iBAAiB,iCAAjB,iBAAiB,QAM5B"}
@@ -13,6 +13,7 @@ export declare enum EResourceType {
13
13
  TWEET_DETAILS_ALT = "TWEET_DETAILS_ALT",
14
14
  TWEET_LIKE = "TWEET_LIKE",
15
15
  TWEET_POST = "TWEET_POST",
16
+ TWEET_REPLIES = "TWEET_REPLIES",
16
17
  TWEET_RETWEET = "TWEET_RETWEET",
17
18
  TWEET_RETWEETERS = "TWEET_RETWEETERS",
18
19
  TWEET_SCHEDULE = "TWEET_SCHEDULE",
@@ -20,6 +20,7 @@ var EResourceType;
20
20
  EResourceType["TWEET_DETAILS_ALT"] = "TWEET_DETAILS_ALT";
21
21
  EResourceType["TWEET_LIKE"] = "TWEET_LIKE";
22
22
  EResourceType["TWEET_POST"] = "TWEET_POST";
23
+ EResourceType["TWEET_REPLIES"] = "TWEET_REPLIES";
23
24
  EResourceType["TWEET_RETWEET"] = "TWEET_RETWEET";
24
25
  EResourceType["TWEET_RETWEETERS"] = "TWEET_RETWEETERS";
25
26
  EResourceType["TWEET_SCHEDULE"] = "TWEET_SCHEDULE";
@@ -1 +1 @@
1
- {"version":3,"file":"Resource.js","sourceRoot":"","sources":["../../src/enums/Resource.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,aAyCX;AAzCD,WAAY,aAAa;IACxB,OAAO;IACP,8CAA6B,CAAA;IAC7B,4CAA2B,CAAA;IAE3B,QAAQ;IACR,4DAA2C,CAAA;IAC3C,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IAEnD,QAAQ;IACR,gDAA+B,CAAA;IAC/B,wDAAuC,CAAA;IACvC,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;IACzB,gDAA+B,CAAA;IAC/B,sDAAqC,CAAA;IACrC,kDAAiC,CAAA;IACjC,8CAA6B,CAAA;IAC7B,8CAA6B,CAAA;IAC7B,8CAA6B,CAAA;IAC7B,oDAAmC,CAAA;IACnC,sDAAqC,CAAA;IAErC,OAAO;IACP,kDAAiC,CAAA;IACjC,sEAAqD,CAAA;IACrD,0DAAyC,CAAA;IACzC,0DAAyC,CAAA;IACzC,gEAA+C,CAAA;IAC/C,4CAA2B,CAAA;IAC3B,kDAAiC,CAAA;IACjC,kDAAiC,CAAA;IACjC,oDAAmC,CAAA;IACnC,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;IACzB,0DAAyC,CAAA;IACzC,0DAAyC,CAAA;IACzC,gDAA+B,CAAA;IAC/B,wEAAuD,CAAA;IACvD,gDAA+B,CAAA;AAChC,CAAC,EAzCW,aAAa,6BAAb,aAAa,QAyCxB"}
1
+ {"version":3,"file":"Resource.js","sourceRoot":"","sources":["../../src/enums/Resource.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,aA0CX;AA1CD,WAAY,aAAa;IACxB,OAAO;IACP,8CAA6B,CAAA;IAC7B,4CAA2B,CAAA;IAE3B,QAAQ;IACR,4DAA2C,CAAA;IAC3C,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IAEnD,QAAQ;IACR,gDAA+B,CAAA;IAC/B,wDAAuC,CAAA;IACvC,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;IACzB,gDAA+B,CAAA;IAC/B,gDAA+B,CAAA;IAC/B,sDAAqC,CAAA;IACrC,kDAAiC,CAAA;IACjC,8CAA6B,CAAA;IAC7B,8CAA6B,CAAA;IAC7B,8CAA6B,CAAA;IAC7B,oDAAmC,CAAA;IACnC,sDAAqC,CAAA;IAErC,OAAO;IACP,kDAAiC,CAAA;IACjC,sEAAqD,CAAA;IACrD,0DAAyC,CAAA;IACzC,0DAAyC,CAAA;IACzC,gEAA+C,CAAA;IAC/C,4CAA2B,CAAA;IAC3B,kDAAiC,CAAA;IACjC,kDAAiC,CAAA;IACjC,oDAAmC,CAAA;IACnC,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;IACzB,0DAAyC,CAAA;IACzC,0DAAyC,CAAA;IACzC,gDAA+B,CAAA;IAC/B,wEAAuD,CAAA;IACvD,gDAA+B,CAAA;AAChC,CAAC,EA1CW,aAAa,6BAAb,aAAa,QA0CxB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.output = void 0;
3
+ exports.output = output;
4
4
  /**
5
5
  * Outputs the given JSON data.
6
6
  *
@@ -18,5 +18,4 @@ function output(data) {
18
18
  console.log(JSON.stringify(data, null, 4));
19
19
  }
20
20
  }
21
- exports.output = output;
22
21
  //# sourceMappingURL=CliUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CliUtils.js","sourceRoot":"","sources":["../../src/helper/CliUtils.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,IAAa;IACnC,kCAAkC;IAClC,IAAI,OAAO,IAAI,IAAI,QAAQ,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KAClB;IACD,0BAA0B;SACrB;QACJ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KAC3C;AACF,CAAC;AATD,wBASC"}
1
+ {"version":3,"file":"CliUtils.js","sourceRoot":"","sources":["../../src/helper/CliUtils.ts"],"names":[],"mappings":";;AAOA,wBASC;AAhBD;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,IAAa;IACnC,kCAAkC;IAClC,IAAI,OAAO,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IACD,0BAA0B;SACrB,CAAC;QACL,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;AACF,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findKeyByValue = exports.findByFilter = void 0;
3
+ exports.findByFilter = findByFilter;
4
+ exports.findKeyByValue = findKeyByValue;
4
5
  /**
5
6
  * Search for all the sub-objects (even deep-nested ones) that have the given key-value pair(filter).
6
7
  *
@@ -15,7 +16,7 @@ function findByFilter(data, key, value) {
15
16
  /**
16
17
  * The list containing all the objects matching given filter.
17
18
  */
18
- var res = [];
19
+ let res = [];
19
20
  /**
20
21
  * If the data is an array, recursively run the function of each element of the array and merge the results.
21
22
  */
@@ -26,7 +27,7 @@ function findByFilter(data, key, value) {
26
27
  * Therefore, map(item =\> findByFilter(.......)) returns an array of arrays.
27
28
  * Therefore, using ... operator to spread the 2-D array in 1-D array.
28
29
  */
29
- res = res.concat.apply(res, data.map(function (item) { return findByFilter(item, key, value); }));
30
+ res = res.concat(...data.map((item) => findByFilter(item, key, value)));
30
31
  }
31
32
  // If the data is an object
32
33
  else if (data != null && typeof data == 'object') {
@@ -39,14 +40,12 @@ function findByFilter(data, key, value) {
39
40
  /**
40
41
  * Recursively run the function on each value specified by each key in the object, for subsequent matches.
41
42
  */
42
- for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
43
- var _b = _a[_i], v = _b[1];
43
+ for (const [, v] of Object.entries(data)) {
44
44
  res = res.concat(findByFilter(v, key, value));
45
45
  }
46
46
  }
47
47
  return res;
48
48
  }
49
- exports.findByFilter = findByFilter;
50
49
  /**
51
50
  * Searches for the key which has the given value in the given object.
52
51
  *
@@ -58,10 +57,7 @@ exports.findByFilter = findByFilter;
58
57
  */
59
58
  function findKeyByValue(data, value) {
60
59
  // Finding the key-value pairs that have the given value
61
- var kvPair = Object.entries(data).filter(function (_a) {
62
- var v = _a[1];
63
- return v == value;
64
- })[0];
60
+ const kvPair = Object.entries(data).filter(([, v]) => v == value)[0];
65
61
  // If a match is found
66
62
  if (kvPair) {
67
63
  return kvPair[0];
@@ -71,5 +67,4 @@ function findKeyByValue(data, value) {
71
67
  return undefined;
72
68
  }
73
69
  }
74
- exports.findKeyByValue = findKeyByValue;
75
70
  //# sourceMappingURL=JsonUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"JsonUtils.js","sourceRoot":"","sources":["../../src/helper/JsonUtils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAAI,IAA0B,EAAE,GAAW,EAAE,KAAa;IACrF;;OAEG;IACH,IAAI,GAAG,GAAQ,EAAE,CAAC;IAElB;;OAEG;IACH,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACxB;;;;;WAKG;QACH,GAAG,GAAG,GAAG,CAAC,MAAM,OAAV,GAAG,EAAW,IAAI,CAAC,GA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,IAAI,MAAM,EAAE,CAAC;QACZ,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,uBAAuB;SAClB,CAAC;QACL,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -10,11 +10,10 @@ export * from './models/data/Notification';
10
10
  export * from './models/data/Tweet';
11
11
  export * from './models/data/User';
12
12
  export * from './models/errors/ApiError';
13
- export * from './models/errors/DataValidationError';
14
13
  export * from './models/errors/HttpError';
15
14
  export * from './models/errors/RettiwtError';
16
15
  export * from './models/errors/TimeoutError';
17
- export * from './services/public/AuthService';
16
+ export * from './services/internal/AuthService';
18
17
  export * from './services/public/FetcherService';
19
18
  export * from './services/public/TweetService';
20
19
  export * from './services/public/UserService';
package/dist/index.js CHANGED
@@ -31,12 +31,11 @@ __exportStar(require("./models/data/Tweet"), exports);
31
31
  __exportStar(require("./models/data/User"), exports);
32
32
  // ERROR MODELS
33
33
  __exportStar(require("./models/errors/ApiError"), exports);
34
- __exportStar(require("./models/errors/DataValidationError"), exports);
35
34
  __exportStar(require("./models/errors/HttpError"), exports);
36
35
  __exportStar(require("./models/errors/RettiwtError"), exports);
37
36
  __exportStar(require("./models/errors/TimeoutError"), exports);
38
37
  // SERVICES
39
- __exportStar(require("./services/public/AuthService"), exports);
38
+ __exportStar(require("./services/internal/AuthService"), exports);
40
39
  __exportStar(require("./services/public/FetcherService"), exports);
41
40
  __exportStar(require("./services/public/TweetService"), exports);
42
41
  __exportStar(require("./services/public/UserService"), exports);
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,QAAQ;AACR,8CAA4B;AAC5B,+CAA6B;AAC7B,mDAAiC;AAEjC,aAAa;AACb,0DAAwC;AACxC,yDAAuC;AAEvC,cAAc;AACd,6DAA2C;AAC3C,qDAAmC;AACnC,6DAA2C;AAC3C,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"}
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,6DAA2C;AAC3C,sDAAoC;AACpC,qDAAmC;AAEnC,eAAe;AACf,2DAAyC;AACzC,4DAA0C;AAC1C,+DAA6C;AAC7C,+DAA6C;AAE7C,WAAW;AACX,kEAAgD;AAChD,mEAAiD;AACjD,iEAA+C;AAC/C,gEAA8C;AAE9C,QAAQ;AACR,wDAAsC;AACtC,uDAAqC"}
@@ -1,149 +1,20 @@
1
- import { ESearchResultType, TweetFilter as TweetFilterCore } from 'rettiwt-core';
1
+ import { ESearchResultType, TweetFilter } from 'rettiwt-core';
2
2
  import { EResourceType } from '../../enums/Resource';
3
+ import { IFetchArgs } from '../../types/args/FetchArgs';
3
4
  /**
4
5
  * Options specifying the data that is to be fetched.
5
6
  *
6
7
  * @public
7
8
  */
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
- * - Has not effect for:
21
- * - {@link EResourceType.USER_FEED_FOLLOWED}
22
- * - {@link EResourceType.USER_FEED_RECOMMENDED}
23
- */
9
+ export declare class FetchArgs implements IFetchArgs {
24
10
  count?: number;
25
- /**
26
- * The cursor to the batch of data to fetch.
27
- *
28
- * @remarks
29
- * - May be used for cursored resources.
30
- * - Has no effect for other resources.
31
- */
32
11
  cursor?: string;
33
- /**
34
- * The filter for searching tweets.
35
- *
36
- * @remarks
37
- * Required when searching for tweets using {@link EResourceType.TWEET_SEARCH}.
38
- */
39
12
  filter?: TweetFilter;
40
- /**
41
- * The id of the target resource.
42
- *
43
- * @remarks
44
- * - Required for all resources except {@link EResourceType.TWEET_SEARCH} and {@link EResourceType.USER_TIMELINE_RECOMMENDED}.
45
- * - For {@link EResourceType.USER_DETAILS_BY_USERNAME}, can be alphanumeric, while for others, is strictly numeric.
46
- */
47
13
  id?: string;
48
- /**
49
- * The type of search results to fetch. Can be one of:
50
- * - {@link EResourceType.LATEST}, for latest search results.
51
- * - {@link EResourceType.TOP}, for top search results.
52
- *
53
- * @defaultValue {@link ESearchResultType.LATEST}.
54
- *
55
- * @remarks
56
- * - Applicable only for {@link EResourceType.TWEET_SEARCH}.
57
- */
58
14
  results?: ESearchResultType;
59
15
  /**
60
16
  * @param resource - The resource to be fetched.
61
17
  * @param args - Additional user-defined arguments for fetching the resource.
62
18
  */
63
- constructor(resource: EResourceType, args: FetchArgs);
64
- }
65
- /**
66
- * The filter to be used for searching tweets.
67
- *
68
- * @public
69
- */
70
- export declare class TweetFilter extends TweetFilterCore {
71
- /** The date upto which tweets are to be searched. */
72
- endDate?: Date;
73
- /** The list of words to exclude from search. */
74
- excludeWords?: string[];
75
- /**
76
- * The list of usernames whose tweets are to be searched.
77
- *
78
- * @remarks
79
- * '\@' must be excluded from the username!
80
- */
81
- fromUsers?: string[];
82
- /**
83
- * The list of hashtags to search.
84
- *
85
- * @remarks
86
- * '#' must be excluded from the hashtag!
87
- */
88
- hashtags?: string[];
89
- /** The exact phrase to search. */
90
- includePhrase?: string;
91
- /** The list of words to search. */
92
- includeWords?: string[];
93
- /** The language of the tweets to search. */
94
- language?: string;
95
- /**
96
- * Whether to fetch tweets that are links or not.
97
- *
98
- * @defaultValue true
99
- */
100
- links?: boolean;
101
- /** The list from which tweets are to be searched. */
102
- list?: string;
103
- /** The id of the tweet, before which the tweets are to be searched. */
104
- maxId?: string;
105
- /**
106
- * The list of username mentioned in the tweets to search.
107
- *
108
- * @remarks
109
- * '\@' must be excluded from the username!
110
- */
111
- mentions?: string[];
112
- /** The minimun number of likes to search by. */
113
- minLikes?: number;
114
- /** The minimum number of replies to search by. */
115
- minReplies?: number;
116
- /** The minimum number of retweets to search by. */
117
- minRetweets?: number;
118
- /** The optional words to search. */
119
- optionalWords?: string[];
120
- /** The id of the tweet which is quoted in the tweets to search. */
121
- quoted?: string;
122
- /**
123
- * Whether to fetch tweets that are replies or not.
124
- *
125
- * @defaultValue true
126
- */
127
- replies?: boolean;
128
- /** The id of the tweet, after which the tweets are to be searched. */
129
- sinceId?: string;
130
- /** The date starting from which tweets are to be searched. */
131
- startDate?: Date;
132
- /**
133
- * The list of username to whom the tweets to be searched, are adressed.
134
- *
135
- * @remarks
136
- * '\@' must be excluded from the username!
137
- */
138
- toUsers?: string[];
139
- /**
140
- * Whether to fetch top or not.
141
- *
142
- * @defaultValue true
143
- */
144
- top?: boolean;
145
- /**
146
- * @param filter - The filter to use for searching tweets.
147
- */
148
- constructor(filter: TweetFilter);
19
+ constructor(resource: EResourceType, args: IFetchArgs);
149
20
  }