rettiwt-api 4.1.0-alpha.0 → 4.1.0-alpha.2
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/dist/commands/User.js +15 -39
- package/dist/commands/User.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models/data/CursoredData.js +6 -2
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +7 -3
- package/dist/services/public/TweetService.js +7 -3
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +19 -13
- package/dist/services/public/UserService.js +76 -26
- package/dist/services/public/UserService.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/User.ts +0 -14
- package/src/index.ts +1 -0
- package/src/models/data/CursoredData.ts +4 -3
- package/src/services/public/TweetService.ts +7 -3
- package/src/services/public/UserService.ts +55 -26
package/dist/commands/User.js
CHANGED
|
@@ -241,36 +241,12 @@ function createUserCommand(rettiwt) {
|
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
243
|
}); });
|
|
244
|
-
// Notifications
|
|
245
|
-
user.command('notifications')
|
|
246
|
-
.description('Fetch you list of notifications')
|
|
247
|
-
.argument('[count]', 'The number of notifications to fetch')
|
|
248
|
-
.argument('[cursor]', 'The cursor to the batch of notifications to fetch')
|
|
249
|
-
.action(function (count, cursor) { return __awaiter(_this, void 0, void 0, function () {
|
|
250
|
-
var notifications, error_9;
|
|
251
|
-
return __generator(this, function (_a) {
|
|
252
|
-
switch (_a.label) {
|
|
253
|
-
case 0:
|
|
254
|
-
_a.trys.push([0, 2, , 3]);
|
|
255
|
-
return [4 /*yield*/, rettiwt.user.notifications(count ? parseInt(count) : undefined, cursor)];
|
|
256
|
-
case 1:
|
|
257
|
-
notifications = _a.sent();
|
|
258
|
-
(0, CliUtils_1.output)(notifications);
|
|
259
|
-
return [3 /*break*/, 3];
|
|
260
|
-
case 2:
|
|
261
|
-
error_9 = _a.sent();
|
|
262
|
-
(0, CliUtils_1.output)(error_9);
|
|
263
|
-
return [3 /*break*/, 3];
|
|
264
|
-
case 3: return [2 /*return*/];
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}); });
|
|
268
244
|
// Recommended
|
|
269
245
|
user.command('recommended')
|
|
270
246
|
.description('Fetch your recommended feed')
|
|
271
247
|
.argument('[cursor]', 'The cursor to the batch of feed items to fetch')
|
|
272
248
|
.action(function (cursor) { return __awaiter(_this, void 0, void 0, function () {
|
|
273
|
-
var tweets,
|
|
249
|
+
var tweets, error_9;
|
|
274
250
|
return __generator(this, function (_a) {
|
|
275
251
|
switch (_a.label) {
|
|
276
252
|
case 0:
|
|
@@ -281,8 +257,8 @@ function createUserCommand(rettiwt) {
|
|
|
281
257
|
(0, CliUtils_1.output)(tweets);
|
|
282
258
|
return [3 /*break*/, 3];
|
|
283
259
|
case 2:
|
|
284
|
-
|
|
285
|
-
(0, CliUtils_1.output)(
|
|
260
|
+
error_9 = _a.sent();
|
|
261
|
+
(0, CliUtils_1.output)(error_9);
|
|
286
262
|
return [3 /*break*/, 3];
|
|
287
263
|
case 3: return [2 /*return*/];
|
|
288
264
|
}
|
|
@@ -295,7 +271,7 @@ function createUserCommand(rettiwt) {
|
|
|
295
271
|
.argument('[count]', 'The number of replies to fetch')
|
|
296
272
|
.argument('[cursor]', 'The cursor to the batch of replies to fetch')
|
|
297
273
|
.action(function (id, count, cursor) { return __awaiter(_this, void 0, void 0, function () {
|
|
298
|
-
var replies,
|
|
274
|
+
var replies, error_10;
|
|
299
275
|
return __generator(this, function (_a) {
|
|
300
276
|
switch (_a.label) {
|
|
301
277
|
case 0:
|
|
@@ -306,8 +282,8 @@ function createUserCommand(rettiwt) {
|
|
|
306
282
|
(0, CliUtils_1.output)(replies);
|
|
307
283
|
return [3 /*break*/, 3];
|
|
308
284
|
case 2:
|
|
309
|
-
|
|
310
|
-
(0, CliUtils_1.output)(
|
|
285
|
+
error_10 = _a.sent();
|
|
286
|
+
(0, CliUtils_1.output)(error_10);
|
|
311
287
|
return [3 /*break*/, 3];
|
|
312
288
|
case 3: return [2 /*return*/];
|
|
313
289
|
}
|
|
@@ -320,7 +296,7 @@ function createUserCommand(rettiwt) {
|
|
|
320
296
|
.argument('[count]', 'The number of subscriptions to fetch')
|
|
321
297
|
.argument('[cursor]', 'The cursor to the batch of subscriptions to fetch')
|
|
322
298
|
.action(function (id, count, cursor) { return __awaiter(_this, void 0, void 0, function () {
|
|
323
|
-
var users,
|
|
299
|
+
var users, error_11;
|
|
324
300
|
return __generator(this, function (_a) {
|
|
325
301
|
switch (_a.label) {
|
|
326
302
|
case 0:
|
|
@@ -331,8 +307,8 @@ function createUserCommand(rettiwt) {
|
|
|
331
307
|
(0, CliUtils_1.output)(users);
|
|
332
308
|
return [3 /*break*/, 3];
|
|
333
309
|
case 2:
|
|
334
|
-
|
|
335
|
-
(0, CliUtils_1.output)(
|
|
310
|
+
error_11 = _a.sent();
|
|
311
|
+
(0, CliUtils_1.output)(error_11);
|
|
336
312
|
return [3 /*break*/, 3];
|
|
337
313
|
case 3: return [2 /*return*/];
|
|
338
314
|
}
|
|
@@ -345,7 +321,7 @@ function createUserCommand(rettiwt) {
|
|
|
345
321
|
.argument('[count]', 'The number of tweets to fetch')
|
|
346
322
|
.argument('[cursor]', 'The cursor to the batch of tweets to fetch')
|
|
347
323
|
.action(function (id, count, cursor) { return __awaiter(_this, void 0, void 0, function () {
|
|
348
|
-
var tweets,
|
|
324
|
+
var tweets, error_12;
|
|
349
325
|
return __generator(this, function (_a) {
|
|
350
326
|
switch (_a.label) {
|
|
351
327
|
case 0:
|
|
@@ -356,8 +332,8 @@ function createUserCommand(rettiwt) {
|
|
|
356
332
|
(0, CliUtils_1.output)(tweets);
|
|
357
333
|
return [3 /*break*/, 3];
|
|
358
334
|
case 2:
|
|
359
|
-
|
|
360
|
-
(0, CliUtils_1.output)(
|
|
335
|
+
error_12 = _a.sent();
|
|
336
|
+
(0, CliUtils_1.output)(error_12);
|
|
361
337
|
return [3 /*break*/, 3];
|
|
362
338
|
case 3: return [2 /*return*/];
|
|
363
339
|
}
|
|
@@ -368,7 +344,7 @@ function createUserCommand(rettiwt) {
|
|
|
368
344
|
.description('Unfollow a user')
|
|
369
345
|
.argument('<id>', 'The user to unfollow')
|
|
370
346
|
.action(function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
371
|
-
var result,
|
|
347
|
+
var result, error_13;
|
|
372
348
|
return __generator(this, function (_a) {
|
|
373
349
|
switch (_a.label) {
|
|
374
350
|
case 0:
|
|
@@ -379,8 +355,8 @@ function createUserCommand(rettiwt) {
|
|
|
379
355
|
(0, CliUtils_1.output)(result);
|
|
380
356
|
return [3 /*break*/, 3];
|
|
381
357
|
case 2:
|
|
382
|
-
|
|
383
|
-
(0, CliUtils_1.output)(
|
|
358
|
+
error_13 = _a.sent();
|
|
359
|
+
(0, CliUtils_1.output)(error_13);
|
|
384
360
|
return [3 /*break*/, 3];
|
|
385
361
|
case 3: return [2 /*return*/];
|
|
386
362
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../src/commands/User.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAmD;AAEnD,+CAA4C;AAG5C;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,OAAgB;IAA3C,
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../src/commands/User.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAmD;AAEnD,+CAA4C;AAG5C;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,OAAgB;IAA3C,iBA6LC;IA5LA,8BAA8B;IAC9B,IAAM,IAAI,GAAG,IAAA,yBAAa,EAAC,MAAM,CAAC,CAAC,WAAW,CAAC,oCAAoC,CAAC,CAAC;IAErF,UAAU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;;;;;SAEf,CAAC,CAAC;IAEJ,WAAW;IACX,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;SACtB,WAAW,CAAC,iBAAiB,CAAC;SAC9B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;SACxC,MAAM,CAAC,UAAO,EAAU;;;;;;oBAER,qBAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAA;;oBAAxC,MAAM,GAAG,SAA+B;oBAC9C,IAAA,iBAAM,EAAC,MAAM,CAAC,CAAC;;;;oBAEf,IAAA,iBAAM,EAAC,QAAK,CAAC,CAAC;;;;;SAEf,CAAC,CAAC;IAEJ,OAAO,IAAI,CAAC;AACb,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './models/args/FetchArgs';
|
|
|
6
6
|
export * from './models/args/PostArgs';
|
|
7
7
|
export * from './models/data/CursoredData';
|
|
8
8
|
export * from './models/data/List';
|
|
9
|
+
export * from './models/data/Notification';
|
|
9
10
|
export * from './models/data/Tweet';
|
|
10
11
|
export * from './models/data/User';
|
|
11
12
|
export * from './models/errors/ApiError';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./models/args/PostArgs"), exports);
|
|
|
26
26
|
// DATA MODELS
|
|
27
27
|
__exportStar(require("./models/data/CursoredData"), exports);
|
|
28
28
|
__exportStar(require("./models/data/List"), exports);
|
|
29
|
+
__exportStar(require("./models/data/Notification"), exports);
|
|
29
30
|
__exportStar(require("./models/data/Tweet"), exports);
|
|
30
31
|
__exportStar(require("./models/data/User"), exports);
|
|
31
32
|
// ERROR MODELS
|
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,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,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"}
|
|
@@ -19,19 +19,23 @@ var CursoredData = /** @class */ (function () {
|
|
|
19
19
|
* @param type - The base type of the data included in the batch.
|
|
20
20
|
*/
|
|
21
21
|
function CursoredData(response, type) {
|
|
22
|
-
var _a, _b;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23
23
|
/** The batch of data of the given type. */
|
|
24
24
|
this.list = [];
|
|
25
|
+
/** The cursor to the next batch of data. */
|
|
26
|
+
this.next = new Cursor('');
|
|
25
27
|
if (type == Data_1.EBaseType.TWEET) {
|
|
26
28
|
this.list = Tweet_1.Tweet.list(response);
|
|
29
|
+
this.next = new Cursor((_b = (_a = (0, JsonUtils_1.findByFilter)(response, 'cursorType', 'Bottom')[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '');
|
|
27
30
|
}
|
|
28
31
|
else if (type == Data_1.EBaseType.USER) {
|
|
29
32
|
this.list = User_1.User.list(response);
|
|
33
|
+
this.next = new Cursor((_d = (_c = (0, JsonUtils_1.findByFilter)(response, 'cursorType', 'Bottom')[0]) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : '');
|
|
30
34
|
}
|
|
31
35
|
else if (type == Data_1.EBaseType.NOTIFICATION) {
|
|
32
36
|
this.list = Notification_1.Notification.list(response);
|
|
37
|
+
this.next = new Cursor((_f = (_e = (0, JsonUtils_1.findByFilter)(response, 'cursorType', 'Top')[0]) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : '');
|
|
33
38
|
}
|
|
34
|
-
this.next = new Cursor((_b = (_a = (0, JsonUtils_1.findByFilter)(response, 'cursorType', 'Bottom')[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '');
|
|
35
39
|
}
|
|
36
40
|
return CursoredData;
|
|
37
41
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursoredData.js","sourceRoot":"","sources":["../../../src/models/data/CursoredData.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,oDAAsD;AAEtD,+CAA8C;AAC9C,iCAAgC;AAChC,+BAA8B;AAE9B;;;;;;GAMG;AACH;IAOC;;;OAGG;IACH,sBAAmB,QAA8B,EAAE,IAAe;;QAVlE,2CAA2C;QACpC,SAAI,GAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"CursoredData.js","sourceRoot":"","sources":["../../../src/models/data/CursoredData.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,oDAAsD;AAEtD,+CAA8C;AAC9C,iCAAgC;AAChC,+BAA8B;AAE9B;;;;;;GAMG;AACH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G,MAAM,CAAC;IACrB,CAAC;IACF,aAAC;AAAD,CAAC,AAVD,IAUC;AAVY,wBAAM"}
|
|
@@ -303,9 +303,10 @@ export declare class TweetService extends FetcherService {
|
|
|
303
303
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
304
304
|
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
305
305
|
*
|
|
306
|
-
* //
|
|
307
|
-
*
|
|
306
|
+
* // Creating a function that streams all new tweets from the user 'user1'
|
|
307
|
+
* async function streamTweets() {
|
|
308
308
|
* try {
|
|
309
|
+
* // Awaiting for the tweets returned by the AsyncGenerator returned by the method
|
|
309
310
|
* for await (const tweet of rettiwt.tweet.stream({ fromUsers: ['user1'] }, 1000)) {
|
|
310
311
|
* console.log(tweet.fullText);
|
|
311
312
|
* }
|
|
@@ -313,7 +314,10 @@ export declare class TweetService extends FetcherService {
|
|
|
313
314
|
* catch (err) {
|
|
314
315
|
* console.log(err);
|
|
315
316
|
* }
|
|
316
|
-
* }
|
|
317
|
+
* }
|
|
318
|
+
*
|
|
319
|
+
* // Calling the function
|
|
320
|
+
* streamTweets();
|
|
317
321
|
* ```
|
|
318
322
|
*/
|
|
319
323
|
stream(filter: TweetFilter, pollingInterval?: number): AsyncGenerator<Tweet>;
|
|
@@ -528,9 +528,10 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
528
528
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
529
529
|
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
530
530
|
*
|
|
531
|
-
* //
|
|
532
|
-
*
|
|
531
|
+
* // Creating a function that streams all new tweets from the user 'user1'
|
|
532
|
+
* async function streamTweets() {
|
|
533
533
|
* try {
|
|
534
|
+
* // Awaiting for the tweets returned by the AsyncGenerator returned by the method
|
|
534
535
|
* for await (const tweet of rettiwt.tweet.stream({ fromUsers: ['user1'] }, 1000)) {
|
|
535
536
|
* console.log(tweet.fullText);
|
|
536
537
|
* }
|
|
@@ -538,7 +539,10 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
538
539
|
* catch (err) {
|
|
539
540
|
* console.log(err);
|
|
540
541
|
* }
|
|
541
|
-
* }
|
|
542
|
+
* }
|
|
543
|
+
*
|
|
544
|
+
* // Calling the function
|
|
545
|
+
* streamTweets();
|
|
542
546
|
* ```
|
|
543
547
|
*/
|
|
544
548
|
TweetService.prototype.stream = function (filter, pollingInterval) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TweetService.js","sourceRoot":"","sources":["../../../src/services/public/TweetService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAA8B;AAoB9B,2DAA0D;AAC1D,iDAAqD;AAOrD,mDAAkD;AAElD;;;;GAIG;AACH;IAAkC,gCAAc;IAC/C;;;;OAIG;IACH,sBAAmB,MAAuB;eACzC,kBAAM,MAAM,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,8BAAO,GAApB,UAAqB,EAAU;;;;;;6BAI1B,CAAA,IAAI,CAAC,MAAM,IAAI,SAAS,CAAA,EAAxB,wBAAwB;wBAC3B,QAAQ,GAAG,wBAAa,CAAC,iBAAiB,CAAC;wBAG1B,qBAAM,IAAI,CAAC,OAAO,CAAwB,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA;;wBAA1E,QAAQ,GAAG,SAA+D;wBAG1E,IAAI,GAAG,uBAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;wBAEhD,sBAAO,IAAI,EAAC;;wBAIZ,QAAQ,GAAG,wBAAa,CAAC,aAAa,CAAC;wBAGtB,qBAAM,IAAI,CAAC,OAAO,CAAwB,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA;;wBAA1E,QAAQ,GAAG,SAA+D;wB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AO,CAAU,wBAAa,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAA;;wBADpG,SAAS;wBACT,SAAoG,CAAC;wBAErG,WAAW;wBACX,qBAAM,IAAI,CAAC,OAAO,CAAU,wBAAa,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA;;wBADxF,WAAW;wBACX,SAAwF,CAAC;wBAEzF,sBAAO,EAAE,EAAC;;;;KACV;IACF,mBAAC;AAAD,CAAC,AAxpBD,CAAkC,+BAAc,GAwpB/C;AAxpBY,oCAAY"}
|
|
@@ -251,12 +251,11 @@ export declare class UserService extends FetcherService {
|
|
|
251
251
|
*/
|
|
252
252
|
media(id: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
253
253
|
/**
|
|
254
|
-
*
|
|
254
|
+
* Stream notifications of the logged in user in pseudo real-time.
|
|
255
255
|
*
|
|
256
|
-
* @param
|
|
257
|
-
* @param cursor - The cursor to the batch of notifications to fetch
|
|
256
|
+
* @param pollingInterval - The interval in milliseconds to poll for new tweets. Default interval is 60000 ms.
|
|
258
257
|
*
|
|
259
|
-
* @returns
|
|
258
|
+
* @returns An async generator that yields new notifications as they are received.
|
|
260
259
|
*
|
|
261
260
|
* @example
|
|
262
261
|
* ```
|
|
@@ -265,17 +264,24 @@ export declare class UserService extends FetcherService {
|
|
|
265
264
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
266
265
|
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
267
266
|
*
|
|
268
|
-
* //
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
267
|
+
* // Creating a function that streams all new notifications
|
|
268
|
+
* async function streamNotifications() {
|
|
269
|
+
* try {
|
|
270
|
+
* // Awaiting for the notifications returned by the AsyncGenerator returned by the method
|
|
271
|
+
* for await (const notification of rettiwt.user.notifications(1000)) {
|
|
272
|
+
* console.log(notification.message);
|
|
273
|
+
* }
|
|
274
|
+
* }
|
|
275
|
+
* catch (err) {
|
|
276
|
+
* console.log(err);
|
|
277
|
+
* }
|
|
278
|
+
* }
|
|
279
|
+
*
|
|
280
|
+
* // Calling the function
|
|
281
|
+
* streamNotifications();
|
|
276
282
|
* ```
|
|
277
283
|
*/
|
|
278
|
-
notifications(
|
|
284
|
+
notifications(pollingInterval?: number): AsyncGenerator<Notification>;
|
|
279
285
|
/**
|
|
280
286
|
* Get the recommended feed of the logged in user.
|
|
281
287
|
*
|
|
@@ -50,6 +50,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
54
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
55
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
56
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
57
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
58
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
59
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
60
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
61
|
+
function fulfill(value) { resume("next", value); }
|
|
62
|
+
function reject(value) { resume("throw", value); }
|
|
63
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
64
|
+
};
|
|
53
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
66
|
exports.UserService = void 0;
|
|
55
67
|
var Extractors_1 = require("../../collections/Extractors");
|
|
@@ -455,12 +467,11 @@ var UserService = /** @class */ (function (_super) {
|
|
|
455
467
|
});
|
|
456
468
|
};
|
|
457
469
|
/**
|
|
458
|
-
*
|
|
470
|
+
* Stream notifications of the logged in user in pseudo real-time.
|
|
459
471
|
*
|
|
460
|
-
* @param
|
|
461
|
-
* @param cursor - The cursor to the batch of notifications to fetch
|
|
472
|
+
* @param pollingInterval - The interval in milliseconds to poll for new tweets. Default interval is 60000 ms.
|
|
462
473
|
*
|
|
463
|
-
* @returns
|
|
474
|
+
* @returns An async generator that yields new notifications as they are received.
|
|
464
475
|
*
|
|
465
476
|
* @example
|
|
466
477
|
* ```
|
|
@@ -469,33 +480,72 @@ var UserService = /** @class */ (function (_super) {
|
|
|
469
480
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
470
481
|
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
471
482
|
*
|
|
472
|
-
* //
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
483
|
+
* // Creating a function that streams all new notifications
|
|
484
|
+
* async function streamNotifications() {
|
|
485
|
+
* try {
|
|
486
|
+
* // Awaiting for the notifications returned by the AsyncGenerator returned by the method
|
|
487
|
+
* for await (const notification of rettiwt.user.notifications(1000)) {
|
|
488
|
+
* console.log(notification.message);
|
|
489
|
+
* }
|
|
490
|
+
* }
|
|
491
|
+
* catch (err) {
|
|
492
|
+
* console.log(err);
|
|
493
|
+
* }
|
|
494
|
+
* }
|
|
495
|
+
*
|
|
496
|
+
* // Calling the function
|
|
497
|
+
* streamNotifications();
|
|
480
498
|
* ```
|
|
481
499
|
*/
|
|
482
|
-
UserService.prototype.notifications = function (
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
500
|
+
UserService.prototype.notifications = function (pollingInterval) {
|
|
501
|
+
if (pollingInterval === void 0) { pollingInterval = 60000; }
|
|
502
|
+
return __asyncGenerator(this, arguments, function notifications_1() {
|
|
503
|
+
var resource, first, cursor, response, notifications, _i, _a, notification;
|
|
504
|
+
return __generator(this, function (_b) {
|
|
505
|
+
switch (_b.label) {
|
|
487
506
|
case 0:
|
|
488
507
|
resource = Resource_1.EResourceType.USER_NOTIFICATIONS;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
})];
|
|
508
|
+
first = true;
|
|
509
|
+
cursor = undefined;
|
|
510
|
+
_b.label = 1;
|
|
493
511
|
case 1:
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
512
|
+
if (!true) return [3 /*break*/, 11];
|
|
513
|
+
// Pause execution for the specified polling interval before proceeding to the next iteration
|
|
514
|
+
return [4 /*yield*/, __await(new Promise(function (resolve) { return setTimeout(resolve, pollingInterval); }))];
|
|
515
|
+
case 2:
|
|
516
|
+
// Pause execution for the specified polling interval before proceeding to the next iteration
|
|
517
|
+
_b.sent();
|
|
518
|
+
return [4 /*yield*/, __await(this.request(resource, {
|
|
519
|
+
count: 40,
|
|
520
|
+
cursor: cursor,
|
|
521
|
+
}))];
|
|
522
|
+
case 3:
|
|
523
|
+
response = _b.sent();
|
|
524
|
+
notifications = Extractors_1.extractors[resource](response);
|
|
525
|
+
// Sorting the notifications by time, from oldest to recent
|
|
526
|
+
notifications.list.sort(function (a, b) { return new Date(a.receivedAt).valueOf() - new Date(b.receivedAt).valueOf(); });
|
|
527
|
+
if (!!first) return [3 /*break*/, 9];
|
|
528
|
+
_i = 0, _a = notifications.list;
|
|
529
|
+
_b.label = 4;
|
|
530
|
+
case 4:
|
|
531
|
+
if (!(_i < _a.length)) return [3 /*break*/, 8];
|
|
532
|
+
notification = _a[_i];
|
|
533
|
+
return [4 /*yield*/, __await(notification)];
|
|
534
|
+
case 5: return [4 /*yield*/, _b.sent()];
|
|
535
|
+
case 6:
|
|
536
|
+
_b.sent();
|
|
537
|
+
_b.label = 7;
|
|
538
|
+
case 7:
|
|
539
|
+
_i++;
|
|
540
|
+
return [3 /*break*/, 4];
|
|
541
|
+
case 8: return [3 /*break*/, 10];
|
|
542
|
+
case 9:
|
|
543
|
+
first = false;
|
|
544
|
+
_b.label = 10;
|
|
545
|
+
case 10:
|
|
546
|
+
cursor = notifications.next.value;
|
|
547
|
+
return [3 /*break*/, 1];
|
|
548
|
+
case 11: return [2 /*return*/];
|
|
499
549
|
}
|
|
500
550
|
});
|
|
501
551
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/public/UserService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/public/UserService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,2DAA0D;AAC1D,iDAAqD;AAOrD,mDAAkD;AAElD;;;;GAIG;AACH;IAAiC,+BAAc;IAC9C;;;;OAIG;IACH,qBAAmB,MAAuB;eACzC,kBAAM,MAAM,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACU,6BAAO,GAApB,UAAqB,EAAU;;;;;;wBAG9B,uBAAuB;wBACvB,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE;4BACtB,QAAQ,GAAG,wBAAa,CAAC,wBAAwB,CAAC;yBAClD;wBACD,iBAAiB;6BACZ;4BACJ,QAAQ,GAAG,wBAAa,CAAC,kBAAkB,CAAC;yBAC5C;wBAGgB,qBAAM,IAAI,CAAC,OAAO,CAAuB,QAAQ,EAAE,E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,EAAE,EAAE,EAAE,CAAC,EAAA;;wBAA7F,QAAQ,GAAG,SAAkF;wBAG7F,IAAI,GAAG,MAAA,uBAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,mCAAI,KAAK,CAAC;wBAErD,sBAAO,IAAI,EAAC;;;;KACZ;IACF,kBAAC;AAAD,CAAC,AApoBD,CAAiC,+BAAc,GAooB9C;AApoBY,kCAAW"}
|
package/package.json
CHANGED
package/src/commands/User.ts
CHANGED
|
@@ -126,20 +126,6 @@ function createUserCommand(rettiwt: Rettiwt): Command {
|
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
// Notifications
|
|
130
|
-
user.command('notifications')
|
|
131
|
-
.description('Fetch you list of notifications')
|
|
132
|
-
.argument('[count]', 'The number of notifications to fetch')
|
|
133
|
-
.argument('[cursor]', 'The cursor to the batch of notifications to fetch')
|
|
134
|
-
.action(async (count?: string, cursor?: string) => {
|
|
135
|
-
try {
|
|
136
|
-
const notifications = await rettiwt.user.notifications(count ? parseInt(count) : undefined, cursor);
|
|
137
|
-
output(notifications);
|
|
138
|
-
} catch (error) {
|
|
139
|
-
output(error);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
129
|
// Recommended
|
|
144
130
|
user.command('recommended')
|
|
145
131
|
.description('Fetch your recommended feed')
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './models/args/PostArgs';
|
|
|
13
13
|
// DATA MODELS
|
|
14
14
|
export * from './models/data/CursoredData';
|
|
15
15
|
export * from './models/data/List';
|
|
16
|
+
export * from './models/data/Notification';
|
|
16
17
|
export * from './models/data/Tweet';
|
|
17
18
|
export * from './models/data/User';
|
|
18
19
|
|
|
@@ -20,7 +20,7 @@ export class CursoredData<T extends Notification | Tweet | User> {
|
|
|
20
20
|
public list: T[] = [];
|
|
21
21
|
|
|
22
22
|
/** The cursor to the next batch of data. */
|
|
23
|
-
public next: Cursor;
|
|
23
|
+
public next: Cursor = new Cursor('');
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @param response - The raw response.
|
|
@@ -29,13 +29,14 @@ export class CursoredData<T extends Notification | Tweet | User> {
|
|
|
29
29
|
public constructor(response: NonNullable<unknown>, type: EBaseType) {
|
|
30
30
|
if (type == EBaseType.TWEET) {
|
|
31
31
|
this.list = Tweet.list(response) as T[];
|
|
32
|
+
this.next = new Cursor(findByFilter<ICursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '');
|
|
32
33
|
} else if (type == EBaseType.USER) {
|
|
33
34
|
this.list = User.list(response) as T[];
|
|
35
|
+
this.next = new Cursor(findByFilter<ICursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '');
|
|
34
36
|
} else if (type == EBaseType.NOTIFICATION) {
|
|
35
37
|
this.list = Notification.list(response) as T[];
|
|
38
|
+
this.next = new Cursor(findByFilter<ICursor>(response, 'cursorType', 'Top')[0]?.value ?? '');
|
|
36
39
|
}
|
|
37
|
-
|
|
38
|
-
this.next = new Cursor(findByFilter<ICursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '');
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -454,9 +454,10 @@ export class TweetService extends FetcherService {
|
|
|
454
454
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
455
455
|
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
456
456
|
*
|
|
457
|
-
* //
|
|
458
|
-
*
|
|
457
|
+
* // Creating a function that streams all new tweets from the user 'user1'
|
|
458
|
+
* async function streamTweets() {
|
|
459
459
|
* try {
|
|
460
|
+
* // Awaiting for the tweets returned by the AsyncGenerator returned by the method
|
|
460
461
|
* for await (const tweet of rettiwt.tweet.stream({ fromUsers: ['user1'] }, 1000)) {
|
|
461
462
|
* console.log(tweet.fullText);
|
|
462
463
|
* }
|
|
@@ -464,7 +465,10 @@ export class TweetService extends FetcherService {
|
|
|
464
465
|
* catch (err) {
|
|
465
466
|
* console.log(err);
|
|
466
467
|
* }
|
|
467
|
-
* }
|
|
468
|
+
* }
|
|
469
|
+
*
|
|
470
|
+
* // Calling the function
|
|
471
|
+
* streamTweets();
|
|
468
472
|
* ```
|
|
469
473
|
*/
|
|
470
474
|
public async *stream(filter: TweetFilter, pollingInterval: number = 60000): AsyncGenerator<Tweet> {
|
|
@@ -394,12 +394,11 @@ export class UserService extends FetcherService {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
/**
|
|
397
|
-
*
|
|
397
|
+
* Stream notifications of the logged in user in pseudo real-time.
|
|
398
398
|
*
|
|
399
|
-
* @param
|
|
400
|
-
* @param cursor - The cursor to the batch of notifications to fetch
|
|
399
|
+
* @param pollingInterval - The interval in milliseconds to poll for new tweets. Default interval is 60000 ms.
|
|
401
400
|
*
|
|
402
|
-
* @returns
|
|
401
|
+
* @returns An async generator that yields new notifications as they are received.
|
|
403
402
|
*
|
|
404
403
|
* @example
|
|
405
404
|
* ```
|
|
@@ -408,32 +407,62 @@ export class UserService extends FetcherService {
|
|
|
408
407
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
409
408
|
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
410
409
|
*
|
|
411
|
-
* //
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
410
|
+
* // Creating a function that streams all new notifications
|
|
411
|
+
* async function streamNotifications() {
|
|
412
|
+
* try {
|
|
413
|
+
* // Awaiting for the notifications returned by the AsyncGenerator returned by the method
|
|
414
|
+
* for await (const notification of rettiwt.user.notifications(1000)) {
|
|
415
|
+
* console.log(notification.message);
|
|
416
|
+
* }
|
|
417
|
+
* }
|
|
418
|
+
* catch (err) {
|
|
419
|
+
* console.log(err);
|
|
420
|
+
* }
|
|
421
|
+
* }
|
|
422
|
+
*
|
|
423
|
+
* // Calling the function
|
|
424
|
+
* streamNotifications();
|
|
419
425
|
* ```
|
|
420
426
|
*/
|
|
421
|
-
public async notifications(
|
|
427
|
+
public async *notifications(pollingInterval: number = 60000): AsyncGenerator<Notification> {
|
|
422
428
|
const resource = EResourceType.USER_NOTIFICATIONS;
|
|
423
429
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
430
|
+
/** Whether it's the first batch of notifications or not. */
|
|
431
|
+
let first: boolean = true;
|
|
432
|
+
|
|
433
|
+
/** The cursor to the last notification received. */
|
|
434
|
+
let cursor: string | undefined = undefined;
|
|
435
|
+
|
|
436
|
+
while (true) {
|
|
437
|
+
// Pause execution for the specified polling interval before proceeding to the next iteration
|
|
438
|
+
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
439
|
+
|
|
440
|
+
// Get the batch of notifications after the given cursor
|
|
441
|
+
const response = await this.request<IUserNotificationsResponse>(resource, {
|
|
442
|
+
count: 40,
|
|
443
|
+
cursor: cursor,
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
// Deserializing response
|
|
447
|
+
const notifications = extractors[resource](response);
|
|
448
|
+
|
|
449
|
+
// Sorting the notifications by time, from oldest to recent
|
|
450
|
+
notifications.list.sort((a, b) => new Date(a.receivedAt).valueOf() - new Date(b.receivedAt).valueOf());
|
|
451
|
+
|
|
452
|
+
// If not first batch, return new notifications
|
|
453
|
+
if (!first) {
|
|
454
|
+
// Yield the notifications
|
|
455
|
+
for (const notification of notifications.list) {
|
|
456
|
+
yield notification;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// Else do nothing, do nothing since first batch is notifications that have already been received
|
|
460
|
+
else {
|
|
461
|
+
first = false;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
cursor = notifications.next.value;
|
|
465
|
+
}
|
|
437
466
|
}
|
|
438
467
|
|
|
439
468
|
/**
|