youtubei 0.0.1-rc.7 → 1.0.0-rc.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 (264) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +50 -53
  3. package/dist/cjs/classes/Base/Base.js +10 -0
  4. package/dist/{index.js → cjs/classes/Base/index.js} +13 -13
  5. package/dist/cjs/classes/BaseChannel/BaseChannel.js +31 -0
  6. package/dist/cjs/classes/BaseChannel/BaseChannelParser.js +24 -0
  7. package/dist/cjs/classes/BaseChannel/ChannelPlaylists.js +57 -0
  8. package/dist/cjs/classes/BaseChannel/ChannelVideos.js +57 -0
  9. package/dist/{classes/client → cjs/classes/BaseChannel}/index.js +16 -19
  10. package/dist/cjs/classes/BaseVideo/BaseVideo.js +34 -0
  11. package/dist/cjs/classes/BaseVideo/BaseVideoParser.js +82 -0
  12. package/dist/cjs/classes/BaseVideo/VideoRelated.js +39 -0
  13. package/dist/{common → cjs/classes/BaseVideo}/index.js +15 -21
  14. package/dist/cjs/classes/Channel/Channel.js +24 -0
  15. package/dist/cjs/classes/Channel/ChannelParser.js +55 -0
  16. package/dist/cjs/classes/Channel/index.js +13 -0
  17. package/dist/cjs/classes/Chat/Chat.js +23 -0
  18. package/dist/cjs/classes/Chat/ChatParser.js +21 -0
  19. package/dist/cjs/classes/Chat/index.js +13 -0
  20. package/dist/cjs/classes/Client/Client.js +101 -0
  21. package/dist/cjs/classes/Client/HTTP.js +59 -0
  22. package/dist/cjs/classes/Client/index.js +13 -0
  23. package/dist/cjs/classes/Comment/Comment.js +29 -0
  24. package/dist/cjs/classes/Comment/CommentParser.js +43 -0
  25. package/dist/cjs/classes/Comment/CommentReplies.js +36 -0
  26. package/dist/cjs/classes/Comment/index.js +13 -0
  27. package/dist/cjs/classes/Continuable/Continuable.js +43 -0
  28. package/dist/cjs/classes/Continuable/index.js +13 -0
  29. package/dist/cjs/classes/LiveVideo/LiveVideo.js +84 -0
  30. package/dist/cjs/classes/LiveVideo/LiveVideoParser.js +29 -0
  31. package/dist/cjs/classes/LiveVideo/index.js +14 -0
  32. package/dist/cjs/classes/MixPlaylist/MixPlaylist.js +25 -0
  33. package/dist/cjs/classes/MixPlaylist/MixPlaylistParser.js +27 -0
  34. package/dist/cjs/classes/MixPlaylist/index.js +14 -0
  35. package/dist/cjs/classes/Playlist/Playlist.js +25 -0
  36. package/dist/cjs/classes/Playlist/PlaylistParser.js +83 -0
  37. package/dist/cjs/classes/Playlist/PlaylistVideos.js +50 -0
  38. package/dist/cjs/classes/Playlist/index.js +15 -0
  39. package/dist/cjs/classes/PlaylistCompact/PlaylistCompact.js +45 -0
  40. package/dist/cjs/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
  41. package/dist/cjs/classes/PlaylistCompact/index.js +14 -0
  42. package/dist/cjs/classes/Reply/Reply.js +23 -0
  43. package/dist/cjs/classes/Reply/ReplyParser.js +26 -0
  44. package/dist/cjs/classes/Reply/index.js +14 -0
  45. package/dist/cjs/classes/SearchManager/SearchManager.js +83 -0
  46. package/dist/cjs/classes/SearchManager/SearchManagerParser.js +40 -0
  47. package/dist/cjs/classes/SearchManager/index.js +14 -0
  48. package/dist/{common/types.js → cjs/classes/SearchManager/proto/SearchProto.js} +2 -2
  49. package/dist/cjs/classes/SearchManager/proto/index.js +57 -0
  50. package/dist/cjs/classes/Thumbnails/Thumbnails.js +67 -0
  51. package/dist/cjs/classes/Thumbnails/index.js +13 -0
  52. package/dist/cjs/classes/Video/Video.js +26 -0
  53. package/dist/cjs/classes/Video/VideoComments.js +53 -0
  54. package/dist/cjs/classes/Video/VideoParser.js +29 -0
  55. package/dist/cjs/classes/Video/index.js +14 -0
  56. package/dist/cjs/classes/VideoCompact/VideoCompact.js +49 -0
  57. package/dist/cjs/classes/VideoCompact/VideoCompactParser.js +36 -0
  58. package/dist/cjs/classes/VideoCompact/index.js +14 -0
  59. package/dist/cjs/classes/index.js +29 -0
  60. package/dist/{src → cjs}/common/decorators.js +14 -15
  61. package/dist/cjs/common/helper.js +45 -0
  62. package/dist/{src → cjs}/common/index.js +16 -21
  63. package/dist/cjs/common/mixins.js +14 -0
  64. package/dist/{classes/client → cjs/common}/types.js +2 -2
  65. package/dist/{src → cjs}/constants.js +10 -9
  66. package/dist/{src → cjs}/index.js +13 -13
  67. package/dist/esm/classes/Base/Base.js +8 -0
  68. package/dist/esm/classes/Base/index.js +1 -0
  69. package/dist/esm/classes/BaseChannel/BaseChannel.js +48 -0
  70. package/dist/esm/classes/BaseChannel/BaseChannelParser.js +24 -0
  71. package/dist/esm/classes/BaseChannel/ChannelPlaylists.js +109 -0
  72. package/dist/esm/classes/BaseChannel/ChannelVideos.js +109 -0
  73. package/dist/esm/classes/BaseChannel/index.js +4 -0
  74. package/dist/esm/classes/BaseVideo/BaseVideo.js +51 -0
  75. package/dist/esm/classes/BaseVideo/BaseVideoParser.js +93 -0
  76. package/dist/esm/classes/BaseVideo/VideoRelated.js +87 -0
  77. package/dist/esm/classes/BaseVideo/index.js +3 -0
  78. package/dist/esm/classes/Channel/Channel.js +37 -0
  79. package/dist/esm/classes/Channel/ChannelParser.js +77 -0
  80. package/dist/esm/classes/Channel/index.js +1 -0
  81. package/dist/esm/classes/Chat/Chat.js +36 -0
  82. package/dist/esm/classes/Chat/ChatParser.js +21 -0
  83. package/dist/esm/classes/Chat/index.js +1 -0
  84. package/dist/esm/classes/Client/Client.js +176 -0
  85. package/dist/esm/classes/Client/HTTP.js +112 -0
  86. package/dist/esm/classes/Client/index.js +1 -0
  87. package/dist/esm/classes/Comment/Comment.js +46 -0
  88. package/dist/esm/classes/Comment/CommentParser.js +45 -0
  89. package/dist/esm/classes/Comment/CommentReplies.js +84 -0
  90. package/dist/esm/classes/Comment/index.js +1 -0
  91. package/dist/esm/classes/Continuable/Continuable.js +125 -0
  92. package/dist/esm/classes/Continuable/index.js +1 -0
  93. package/dist/esm/classes/LiveVideo/LiveVideo.js +160 -0
  94. package/dist/esm/classes/LiveVideo/LiveVideoParser.js +29 -0
  95. package/dist/esm/classes/LiveVideo/index.js +2 -0
  96. package/dist/esm/classes/MixPlaylist/MixPlaylist.js +38 -0
  97. package/dist/esm/classes/MixPlaylist/MixPlaylistParser.js +49 -0
  98. package/dist/esm/classes/MixPlaylist/index.js +2 -0
  99. package/dist/esm/classes/Playlist/Playlist.js +38 -0
  100. package/dist/esm/classes/Playlist/PlaylistParser.js +105 -0
  101. package/dist/esm/classes/Playlist/PlaylistVideos.js +98 -0
  102. package/dist/esm/classes/Playlist/index.js +3 -0
  103. package/dist/esm/classes/PlaylistCompact/PlaylistCompact.js +90 -0
  104. package/dist/esm/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
  105. package/dist/esm/classes/PlaylistCompact/index.js +2 -0
  106. package/dist/esm/classes/Reply/Reply.js +36 -0
  107. package/dist/esm/classes/Reply/ReplyParser.js +26 -0
  108. package/dist/esm/classes/Reply/index.js +2 -0
  109. package/dist/esm/classes/SearchManager/SearchManager.js +159 -0
  110. package/dist/esm/classes/SearchManager/SearchManagerParser.js +62 -0
  111. package/dist/esm/classes/SearchManager/index.js +2 -0
  112. package/dist/esm/classes/SearchManager/proto/SearchProto.js +1 -0
  113. package/dist/esm/classes/SearchManager/proto/index.js +39 -0
  114. package/dist/esm/classes/Thumbnails/Thumbnails.js +109 -0
  115. package/dist/esm/classes/Thumbnails/index.js +1 -0
  116. package/dist/esm/classes/Video/Video.js +39 -0
  117. package/dist/esm/classes/Video/VideoComments.js +101 -0
  118. package/dist/esm/classes/Video/VideoParser.js +31 -0
  119. package/dist/esm/classes/Video/index.js +2 -0
  120. package/dist/esm/classes/VideoCompact/VideoCompact.js +98 -0
  121. package/dist/esm/classes/VideoCompact/VideoCompactParser.js +36 -0
  122. package/dist/esm/classes/VideoCompact/index.js +2 -0
  123. package/dist/esm/classes/index.js +17 -0
  124. package/dist/esm/common/decorators.js +30 -0
  125. package/dist/esm/common/helper.js +61 -0
  126. package/dist/{common/index.d.ts → esm/common/index.js} +4 -4
  127. package/dist/esm/common/mixins.js +10 -0
  128. package/dist/esm/common/types.js +1 -0
  129. package/dist/esm/constants.js +7 -0
  130. package/dist/{index.d.ts → esm/index.js} +1 -1
  131. package/dist/typings/classes/Base/Base.d.ts +11 -0
  132. package/dist/typings/classes/Base/index.d.ts +1 -0
  133. package/dist/typings/classes/BaseChannel/BaseChannel.d.ts +43 -0
  134. package/dist/typings/classes/BaseChannel/BaseChannelParser.d.ts +7 -0
  135. package/dist/typings/classes/BaseChannel/ChannelPlaylists.d.ts +30 -0
  136. package/dist/typings/classes/BaseChannel/ChannelVideos.d.ts +30 -0
  137. package/dist/typings/classes/BaseChannel/index.d.ts +4 -0
  138. package/dist/typings/classes/BaseVideo/BaseVideo.d.ts +59 -0
  139. package/dist/typings/classes/BaseVideo/BaseVideoParser.d.ts +14 -0
  140. package/dist/typings/classes/BaseVideo/VideoRelated.d.ts +21 -0
  141. package/dist/typings/classes/BaseVideo/index.d.ts +3 -0
  142. package/dist/typings/classes/Channel/Channel.d.ts +33 -0
  143. package/dist/typings/classes/Channel/ChannelParser.d.ts +6 -0
  144. package/dist/typings/classes/Channel/index.d.ts +1 -0
  145. package/dist/typings/classes/Chat/Chat.d.ts +33 -0
  146. package/dist/typings/classes/Chat/ChatParser.d.ts +5 -0
  147. package/dist/typings/classes/Chat/index.d.ts +1 -0
  148. package/dist/typings/classes/Client/Client.d.ts +41 -0
  149. package/dist/typings/classes/Client/HTTP.d.ts +21 -0
  150. package/dist/typings/classes/Client/index.d.ts +1 -0
  151. package/dist/typings/classes/Comment/Comment.d.ts +51 -0
  152. package/dist/typings/classes/Comment/CommentParser.d.ts +8 -0
  153. package/dist/typings/classes/Comment/CommentReplies.d.ts +17 -0
  154. package/dist/typings/classes/Comment/index.d.ts +1 -0
  155. package/dist/typings/classes/Continuable/Continuable.d.ts +24 -0
  156. package/dist/typings/classes/Continuable/index.d.ts +1 -0
  157. package/dist/typings/classes/LiveVideo/LiveVideo.d.ts +46 -0
  158. package/dist/typings/classes/LiveVideo/LiveVideoParser.d.ts +10 -0
  159. package/dist/typings/classes/LiveVideo/index.d.ts +2 -0
  160. package/dist/typings/classes/MixPlaylist/MixPlaylist.d.ts +29 -0
  161. package/dist/typings/classes/MixPlaylist/MixPlaylistParser.d.ts +6 -0
  162. package/dist/typings/classes/MixPlaylist/index.d.ts +2 -0
  163. package/dist/typings/classes/Playlist/Playlist.d.ts +39 -0
  164. package/dist/typings/classes/Playlist/PlaylistParser.d.ts +16 -0
  165. package/dist/typings/classes/Playlist/PlaylistVideos.d.ts +31 -0
  166. package/dist/typings/classes/Playlist/index.d.ts +3 -0
  167. package/dist/typings/classes/PlaylistCompact/PlaylistCompact.d.ts +43 -0
  168. package/dist/typings/classes/PlaylistCompact/PlaylistCompactParser.d.ts +5 -0
  169. package/dist/typings/classes/PlaylistCompact/index.d.ts +2 -0
  170. package/dist/typings/classes/Reply/Reply.d.ts +43 -0
  171. package/dist/typings/classes/Reply/ReplyParser.d.ts +5 -0
  172. package/dist/typings/classes/Reply/index.d.ts +2 -0
  173. package/dist/typings/classes/SearchManager/SearchManager.d.ts +51 -0
  174. package/dist/typings/classes/SearchManager/SearchManagerParser.d.ts +13 -0
  175. package/dist/typings/classes/SearchManager/index.d.ts +2 -0
  176. package/dist/typings/classes/SearchManager/proto/SearchProto.d.ts +13 -0
  177. package/dist/typings/classes/SearchManager/proto/index.d.ts +24 -0
  178. package/dist/typings/classes/Thumbnails/Thumbnails.d.ts +41 -0
  179. package/dist/typings/classes/Thumbnails/index.d.ts +1 -0
  180. package/dist/typings/classes/Video/Video.d.ts +24 -0
  181. package/dist/typings/classes/Video/VideoComments.d.ts +34 -0
  182. package/dist/typings/classes/Video/VideoParser.d.ts +8 -0
  183. package/dist/typings/classes/Video/index.d.ts +2 -0
  184. package/dist/typings/classes/VideoCompact/VideoCompact.d.ts +57 -0
  185. package/dist/typings/classes/VideoCompact/VideoCompactParser.d.ts +5 -0
  186. package/dist/typings/classes/VideoCompact/index.d.ts +2 -0
  187. package/dist/typings/classes/index.d.ts +17 -0
  188. package/dist/{src → typings}/common/decorators.d.ts +5 -7
  189. package/dist/typings/common/helper.d.ts +5 -0
  190. package/dist/{src → typings}/common/index.d.ts +4 -4
  191. package/dist/typings/common/mixins.d.ts +1 -0
  192. package/dist/{common → typings/common}/types.d.ts +1 -2
  193. package/dist/{constants.d.ts → typings/constants.d.ts} +7 -6
  194. package/dist/{src → typings}/index.d.ts +1 -1
  195. package/package.json +68 -53
  196. package/CHANGELOG.md +0 -6
  197. package/dist/classes/Base.d.ts +0 -8
  198. package/dist/classes/Base.js +0 -10
  199. package/dist/classes/Channel.d.ts +0 -63
  200. package/dist/classes/Channel.js +0 -115
  201. package/dist/classes/Comment.d.ts +0 -51
  202. package/dist/classes/Comment.js +0 -47
  203. package/dist/classes/LiveVideo.d.ts +0 -3
  204. package/dist/classes/LiveVideo.js +0 -12
  205. package/dist/classes/Playlist.d.ts +0 -66
  206. package/dist/classes/Playlist.js +0 -133
  207. package/dist/classes/PlaylistCompact.d.ts +0 -35
  208. package/dist/classes/PlaylistCompact.js +0 -47
  209. package/dist/classes/SearchResult.d.ts +0 -52
  210. package/dist/classes/SearchResult.js +0 -121
  211. package/dist/classes/Test.d.ts +0 -7
  212. package/dist/classes/Test.js +0 -9
  213. package/dist/classes/Thumbnails.d.ts +0 -23
  214. package/dist/classes/Thumbnails.js +0 -42
  215. package/dist/classes/Video.d.ts +0 -90
  216. package/dist/classes/Video.js +0 -153
  217. package/dist/classes/VideoCompact.d.ts +0 -46
  218. package/dist/classes/VideoCompact.js +0 -53
  219. package/dist/classes/client/Client.d.ts +0 -26
  220. package/dist/classes/client/Client.js +0 -63
  221. package/dist/classes/client/index.d.ts +0 -2
  222. package/dist/classes/client/types.d.ts +0 -12
  223. package/dist/classes/client.d.ts +0 -17
  224. package/dist/classes/client.js +0 -57
  225. package/dist/classes/index.d.ts +0 -10
  226. package/dist/classes/index.js +0 -26
  227. package/dist/common/decorators.d.ts +0 -7
  228. package/dist/common/decorators.js +0 -15
  229. package/dist/common/helper.d.ts +0 -4
  230. package/dist/common/helper.js +0 -39
  231. package/dist/common/http.d.ts +0 -33
  232. package/dist/common/http.js +0 -105
  233. package/dist/constants.js +0 -9
  234. package/dist/src/classes/Base.d.ts +0 -8
  235. package/dist/src/classes/Base.js +0 -10
  236. package/dist/src/classes/Channel.d.ts +0 -37
  237. package/dist/src/classes/Channel.js +0 -82
  238. package/dist/src/classes/Client.d.ts +0 -14
  239. package/dist/src/classes/Client.js +0 -51
  240. package/dist/src/classes/Comment.d.ts +0 -51
  241. package/dist/src/classes/Comment.js +0 -47
  242. package/dist/src/classes/Playlist.d.ts +0 -66
  243. package/dist/src/classes/Playlist.js +0 -133
  244. package/dist/src/classes/PlaylistCompact.d.ts +0 -35
  245. package/dist/src/classes/PlaylistCompact.js +0 -47
  246. package/dist/src/classes/SearchResult.d.ts +0 -53
  247. package/dist/src/classes/SearchResult.js +0 -122
  248. package/dist/src/classes/Thumbnails.d.ts +0 -24
  249. package/dist/src/classes/Thumbnails.js +0 -42
  250. package/dist/src/classes/Video.d.ts +0 -90
  251. package/dist/src/classes/Video.js +0 -153
  252. package/dist/src/classes/VideoCompact.d.ts +0 -46
  253. package/dist/src/classes/VideoCompact.js +0 -53
  254. package/dist/src/classes/index.d.ts +0 -10
  255. package/dist/src/classes/index.js +0 -26
  256. package/dist/src/common/helper.d.ts +0 -4
  257. package/dist/src/common/helper.js +0 -39
  258. package/dist/src/common/http.d.ts +0 -33
  259. package/dist/src/common/http.js +0 -105
  260. package/dist/src/common/types.d.ts +0 -2
  261. package/dist/src/common/types.js +0 -2
  262. package/dist/src/constants.d.ts +0 -6
  263. package/dist/tempCodeRunnerFile.d.ts +0 -8
  264. package/dist/tempCodeRunnerFile.js +0 -15
@@ -0,0 +1,176 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { I_END_POINT, WATCH_END_POINT } from "../../constants";
49
+ import { Channel } from "../Channel";
50
+ import { LiveVideo } from "../LiveVideo";
51
+ import { MixPlaylist } from "../MixPlaylist";
52
+ import { Playlist } from "../Playlist";
53
+ import { SearchManager } from "../SearchManager";
54
+ import { Video } from "../Video";
55
+ import { HTTP } from "./HTTP";
56
+ /** Youtube Client */
57
+ var Client = /** @class */ (function () {
58
+ function Client(options) {
59
+ if (options === void 0) { options = {}; }
60
+ var fullOptions = __assign(__assign({ initialCookie: "", fetchOptions: {} }, options), { youtubeClientOptions: __assign({ hl: "en", gl: "US" }, options.youtubeClientOptions) });
61
+ this.http = new HTTP(fullOptions);
62
+ }
63
+ /**
64
+ * Searches for videos / playlists / channels
65
+ *
66
+ * @param query The search query
67
+ * @param options Search options
68
+ *
69
+ */
70
+ Client.prototype.search = function (query, options) {
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ var manager;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ manager = new SearchManager({ client: this });
77
+ return [4 /*yield*/, manager.search(query, options || {})];
78
+ case 1:
79
+ _a.sent();
80
+ return [2 /*return*/, manager];
81
+ }
82
+ });
83
+ });
84
+ };
85
+ /**
86
+ * Search for videos / playlists / channels and returns the first result
87
+ *
88
+ * @return Can be {@link VideoCompact} | {@link PlaylistCompact} | {@link BaseChannel} | `undefined`
89
+ */
90
+ Client.prototype.findOne = function (query, options) {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var result;
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0: return [4 /*yield*/, this.search(query, options)];
96
+ case 1:
97
+ result = _a.sent();
98
+ return [2 /*return*/, result.items[0] || undefined];
99
+ }
100
+ });
101
+ });
102
+ };
103
+ /** Get playlist information and its videos by playlist id or URL */
104
+ Client.prototype.getPlaylist = function (playlistId) {
105
+ var _a, _b, _c;
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ var response_1, response;
108
+ return __generator(this, function (_d) {
109
+ switch (_d.label) {
110
+ case 0:
111
+ if (!playlistId.startsWith("RD")) return [3 /*break*/, 2];
112
+ return [4 /*yield*/, this.http.post(I_END_POINT + "/next", {
113
+ data: { playlistId: playlistId },
114
+ })];
115
+ case 1:
116
+ response_1 = _d.sent();
117
+ if (response_1.data.error) {
118
+ return [2 /*return*/, undefined];
119
+ }
120
+ return [2 /*return*/, new MixPlaylist({ client: this }).load(response_1.data)];
121
+ case 2: return [4 /*yield*/, this.http.post(I_END_POINT + "/browse", {
122
+ data: { browseId: "VL" + playlistId },
123
+ })];
124
+ case 3:
125
+ response = _d.sent();
126
+ if (response.data.error || ((_c = (_b = (_a = response.data.alerts) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.alertRenderer) === null || _c === void 0 ? void 0 : _c.type) === "ERROR") {
127
+ return [2 /*return*/, undefined];
128
+ }
129
+ return [2 /*return*/, new Playlist({ client: this }).load(response.data)];
130
+ }
131
+ });
132
+ });
133
+ };
134
+ /** Get video information by video id or URL */
135
+ Client.prototype.getVideo = function (videoId) {
136
+ return __awaiter(this, void 0, void 0, function () {
137
+ var response;
138
+ return __generator(this, function (_a) {
139
+ switch (_a.label) {
140
+ case 0: return [4 /*yield*/, this.http.get("" + WATCH_END_POINT, {
141
+ params: { v: videoId, pbj: "1" },
142
+ })];
143
+ case 1:
144
+ response = _a.sent();
145
+ if (!response.data[3].response.contents)
146
+ return [2 /*return*/, undefined];
147
+ return [2 /*return*/, (!response.data[2].playerResponse.playabilityStatus.liveStreamability
148
+ ? new Video({ client: this }).load(response.data)
149
+ : new LiveVideo({ client: this }).load(response.data))];
150
+ }
151
+ });
152
+ });
153
+ };
154
+ /** Get channel information by channel id+ */
155
+ Client.prototype.getChannel = function (channelId) {
156
+ var _a, _b, _c;
157
+ return __awaiter(this, void 0, void 0, function () {
158
+ var response;
159
+ return __generator(this, function (_d) {
160
+ switch (_d.label) {
161
+ case 0: return [4 /*yield*/, this.http.post(I_END_POINT + "/browse", {
162
+ data: { browseId: channelId },
163
+ })];
164
+ case 1:
165
+ response = _d.sent();
166
+ if (response.data.error || ((_c = (_b = (_a = response.data.alerts) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.alertRenderer) === null || _c === void 0 ? void 0 : _c.type) === "ERROR") {
167
+ return [2 /*return*/, undefined];
168
+ }
169
+ return [2 /*return*/, new Channel({ client: this }).load(response.data)];
170
+ }
171
+ });
172
+ });
173
+ };
174
+ return Client;
175
+ }());
176
+ export { Client };
@@ -0,0 +1,112 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import fetch from "node-fetch";
49
+ import { URLSearchParams } from "url";
50
+ import { BASE_URL, INNERTUBE_API_KEY, INNERTUBE_CLIENT_VERSION } from "../../constants";
51
+ var HTTP = /** @class */ (function () {
52
+ function HTTP(options) {
53
+ this.cookie = options.initialCookie || "";
54
+ this.defaultHeaders = {
55
+ "x-youtube-client-version": INNERTUBE_CLIENT_VERSION,
56
+ "x-youtube-client-name": "1",
57
+ "content-type": "application/json",
58
+ "accept-encoding": "gzip, deflate, br",
59
+ };
60
+ this.defaultFetchOptions = options.fetchOptions || {};
61
+ this.defaultClientOptions = options.youtubeClientOptions || {};
62
+ }
63
+ HTTP.prototype.get = function (url, options) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0: return [4 /*yield*/, this.request(url, __assign(__assign({}, options), { params: __assign({ prettyPrint: "false" }, options === null || options === void 0 ? void 0 : options.params), method: "GET" }))];
68
+ case 1: return [2 /*return*/, _a.sent()];
69
+ }
70
+ });
71
+ });
72
+ };
73
+ HTTP.prototype.post = function (url, options) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
77
+ case 0: return [4 /*yield*/, this.request(url, __assign(__assign({}, options), { method: "POST", params: __assign({ key: INNERTUBE_API_KEY, prettyPrint: "false" }, options === null || options === void 0 ? void 0 : options.params), data: __assign({ context: {
78
+ client: __assign({ clientName: "WEB", clientVersion: INNERTUBE_CLIENT_VERSION }, this.defaultClientOptions),
79
+ } }, options === null || options === void 0 ? void 0 : options.data) }))];
80
+ case 1: return [2 /*return*/, _a.sent()];
81
+ }
82
+ });
83
+ });
84
+ };
85
+ HTTP.prototype.request = function (url, partialOptions) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ var options, finalUrl, response, data;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0:
91
+ options = __assign(__assign(__assign({}, partialOptions), this.defaultFetchOptions), { headers: __assign(__assign(__assign(__assign({}, this.defaultHeaders), { cookie: this.cookie }), partialOptions.headers), this.defaultFetchOptions.headers), body: partialOptions.data ? JSON.stringify(partialOptions.data) : undefined });
92
+ finalUrl = "https://" + BASE_URL + "/" + url + "?" + new URLSearchParams(partialOptions.params);
93
+ return [4 /*yield*/, fetch(finalUrl, options)];
94
+ case 1:
95
+ response = _a.sent();
96
+ return [4 /*yield*/, response.json()];
97
+ case 2:
98
+ data = _a.sent();
99
+ this.parseCookie(response);
100
+ return [2 /*return*/, { data: data }];
101
+ }
102
+ });
103
+ });
104
+ };
105
+ HTTP.prototype.parseCookie = function (response) {
106
+ var cookie = response.headers.get("set-cookie");
107
+ if (cookie)
108
+ this.cookie = cookie;
109
+ };
110
+ return HTTP;
111
+ }());
112
+ export { HTTP };
@@ -0,0 +1 @@
1
+ export * from "./Client";
@@ -0,0 +1,46 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { Base } from "../Base";
15
+ import { CommentParser } from "./CommentParser";
16
+ import { CommentReplies } from "./CommentReplies";
17
+ /** Represents a Comment / Reply */
18
+ var Comment = /** @class */ (function (_super) {
19
+ __extends(Comment, _super);
20
+ /** @hidden */
21
+ function Comment(attr) {
22
+ var _this = _super.call(this, attr.client) || this;
23
+ Object.assign(_this, attr);
24
+ _this.replies = new CommentReplies({ client: attr.client, comment: _this });
25
+ return _this;
26
+ }
27
+ /**
28
+ * Load this instance with raw data from Youtube
29
+ *
30
+ * @hidden
31
+ */
32
+ Comment.prototype.load = function (data) {
33
+ CommentParser.loadComment(this, data);
34
+ return this;
35
+ };
36
+ Object.defineProperty(Comment.prototype, "url", {
37
+ /** URL to the video with this comment being highlighted (appears on top of the comment section) */
38
+ get: function () {
39
+ return "https://www.youtube.com/watch?v=" + this.video.id + "&lc=" + this.id;
40
+ },
41
+ enumerable: false,
42
+ configurable: true
43
+ });
44
+ return Comment;
45
+ }(Base));
46
+ export { Comment };
@@ -0,0 +1,45 @@
1
+ import { getContinuationFromItems, mapFilter } from "../../common";
2
+ import { BaseChannel } from "../BaseChannel";
3
+ import { Reply } from "../Reply";
4
+ import { Thumbnails } from "../Thumbnails";
5
+ var CommentParser = /** @class */ (function () {
6
+ function CommentParser() {
7
+ }
8
+ CommentParser.loadComment = function (target, data) {
9
+ var _a = data.comment.commentRenderer, authorText = _a.authorText, authorThumbnail = _a.authorThumbnail, authorEndpoint = _a.authorEndpoint, contentText = _a.contentText, publishedTimeText = _a.publishedTimeText, commentId = _a.commentId, voteCount = _a.voteCount, authorIsChannelOwner = _a.authorIsChannelOwner, pinnedCommentBadge = _a.pinnedCommentBadge, replyCount = _a.replyCount;
10
+ // Basic information
11
+ target.id = commentId;
12
+ target.content = contentText.runs.map(function (r) { return r.text; }).join("");
13
+ target.publishDate = publishedTimeText.runs.shift().text;
14
+ target.likeCount = +((voteCount === null || voteCount === void 0 ? void 0 : voteCount.simpleText) || 0);
15
+ target.isAuthorChannelOwner = authorIsChannelOwner;
16
+ target.isPinned = !!pinnedCommentBadge;
17
+ target.replyCount = replyCount;
18
+ // Reply Continuation
19
+ target.replies.continuation = data.replies
20
+ ? getContinuationFromItems(data.replies.commentRepliesRenderer.contents)
21
+ : undefined;
22
+ // Author
23
+ var browseId = authorEndpoint.browseEndpoint.browseId;
24
+ target.author = new BaseChannel({
25
+ id: browseId,
26
+ name: authorText.simpleText,
27
+ thumbnails: new Thumbnails().load(authorThumbnail.thumbnails),
28
+ client: target.client,
29
+ });
30
+ return target;
31
+ };
32
+ CommentParser.parseContinuation = function (data) {
33
+ var continuationItems = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
34
+ return getContinuationFromItems(continuationItems, ["button", "buttonRenderer", "command"]);
35
+ };
36
+ CommentParser.parseReplies = function (data, comment) {
37
+ var continuationItems = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
38
+ var rawReplies = mapFilter(continuationItems, "commentRenderer");
39
+ return rawReplies.map(function (i) {
40
+ return new Reply({ video: comment.video, comment: comment, client: comment.client }).load(i);
41
+ });
42
+ };
43
+ return CommentParser;
44
+ }());
45
+ export { CommentParser };
@@ -0,0 +1,84 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (_) try {
30
+ 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;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ import { I_END_POINT } from "../../constants";
51
+ import { Continuable } from "../Continuable";
52
+ import { CommentParser } from "./CommentParser";
53
+ /**
54
+ * {@link Continuable} of replies inside a {@link Comment}
55
+ */
56
+ var CommentReplies = /** @class */ (function (_super) {
57
+ __extends(CommentReplies, _super);
58
+ /** @hidden */
59
+ function CommentReplies(_a) {
60
+ var client = _a.client, comment = _a.comment;
61
+ var _this = _super.call(this, { client: client, strictContinuationCheck: true }) || this;
62
+ _this.comment = comment;
63
+ return _this;
64
+ }
65
+ CommentReplies.prototype.fetch = function () {
66
+ return __awaiter(this, void 0, void 0, function () {
67
+ var response, continuation, items;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0: return [4 /*yield*/, this.client.http.post(I_END_POINT + "/next", {
71
+ data: { continuation: this.continuation },
72
+ })];
73
+ case 1:
74
+ response = _a.sent();
75
+ continuation = CommentParser.parseContinuation(response.data);
76
+ items = CommentParser.parseReplies(response.data, this.comment);
77
+ return [2 /*return*/, { continuation: continuation, items: items }];
78
+ }
79
+ });
80
+ });
81
+ };
82
+ return CommentReplies;
83
+ }(Continuable));
84
+ export { CommentReplies };
@@ -0,0 +1 @@
1
+ export * from "./Comment";
@@ -0,0 +1,125 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (_) try {
30
+ 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;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ var __read = (this && this.__read) || function (o, n) {
51
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
52
+ if (!m) return o;
53
+ var i = m.call(o), r, ar = [], e;
54
+ try {
55
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
56
+ }
57
+ catch (error) { e = { error: error }; }
58
+ finally {
59
+ try {
60
+ if (r && !r.done && (m = i["return"])) m.call(i);
61
+ }
62
+ finally { if (e) throw e.error; }
63
+ }
64
+ return ar;
65
+ };
66
+ var __spread = (this && this.__spread) || function () {
67
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
68
+ return ar;
69
+ };
70
+ import { Base } from "../Base";
71
+ /** Represents a continuable list of items `T` (like pagination) */
72
+ var Continuable = /** @class */ (function (_super) {
73
+ __extends(Continuable, _super);
74
+ /** @hidden */
75
+ function Continuable(_a) {
76
+ var client = _a.client, strictContinuationCheck = _a.strictContinuationCheck;
77
+ var _this = _super.call(this, client) || this;
78
+ _this.items = [];
79
+ _this.strictContinuationCheck = !!strictContinuationCheck;
80
+ if (_this.strictContinuationCheck)
81
+ _this.continuation = null;
82
+ return _this;
83
+ }
84
+ /** Fetch next items using continuation token */
85
+ Continuable.prototype.next = function (count) {
86
+ if (count === void 0) { count = 1; }
87
+ return __awaiter(this, void 0, void 0, function () {
88
+ var newItems, i, _a, items, continuation;
89
+ var _b;
90
+ return __generator(this, function (_c) {
91
+ switch (_c.label) {
92
+ case 0:
93
+ newItems = [];
94
+ i = 0;
95
+ _c.label = 1;
96
+ case 1:
97
+ if (!(i < count || count == 0)) return [3 /*break*/, 4];
98
+ if (!this.hasContinuation)
99
+ return [3 /*break*/, 4];
100
+ return [4 /*yield*/, this.fetch()];
101
+ case 2:
102
+ _a = _c.sent(), items = _a.items, continuation = _a.continuation;
103
+ this.continuation = continuation;
104
+ newItems.push.apply(newItems, __spread(items));
105
+ _c.label = 3;
106
+ case 3:
107
+ i++;
108
+ return [3 /*break*/, 1];
109
+ case 4:
110
+ (_b = this.items).push.apply(_b, __spread(newItems));
111
+ return [2 /*return*/, newItems];
112
+ }
113
+ });
114
+ });
115
+ };
116
+ Object.defineProperty(Continuable.prototype, "hasContinuation", {
117
+ get: function () {
118
+ return this.strictContinuationCheck ? this.continuation !== undefined : !!this.continuation;
119
+ },
120
+ enumerable: false,
121
+ configurable: true
122
+ });
123
+ return Continuable;
124
+ }(Base));
125
+ export { Continuable };
@@ -0,0 +1 @@
1
+ export * from "./Continuable";