fishpi 0.0.52 → 0.0.54

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/lib/article.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApiResponse, ArticlePost, ArticleListType, ArticleDetail, VoteStatus, ArticleList, ArticleType } from './typing';
1
+ import { ApiResponse, ArticlePost, ArticleListType, ArticleDetail, ArticleList, ArticleType, VoteType } from './typing';
2
2
  import ReconnectingWebSocket from 'reconnecting-websocket';
3
3
  declare class Article {
4
4
  private _apiKey;
@@ -35,11 +35,23 @@ declare class Article {
35
35
  * @param tag 指定查询标签,可选
36
36
  * @returns 文章列表
37
37
  */
38
- list({ type, page, tag }: {
38
+ list({ type, page, size, tag }: {
39
39
  type: ArticleListType;
40
40
  page?: number;
41
+ size?: number;
41
42
  tag?: string;
42
43
  }): Promise<ApiResponse<ArticleList>>;
44
+ /**
45
+ * 查询文章列表
46
+ * @param type 查询类型
47
+ * @param tag 指定查询标签,可选
48
+ * @returns 文章列表
49
+ */
50
+ listByUser({ user, page, size }: {
51
+ user: string;
52
+ page?: number;
53
+ size?: number;
54
+ }): Promise<ApiResponse<ArticleList>>;
43
55
  /**
44
56
  * 查询用户文章列表
45
57
  * @param userName 用户名
@@ -66,7 +78,7 @@ declare class Article {
66
78
  vote(id: string, type: 'up' | 'down'): Promise<{
67
79
  code: number;
68
80
  msg?: string;
69
- type?: VoteStatus;
81
+ type?: VoteType;
70
82
  }>;
71
83
  /**
72
84
  * 感谢文章
package/lib/article.js CHANGED
@@ -155,27 +155,55 @@ var Article = /** @class */ (function () {
155
155
  * @returns 文章列表
156
156
  */
157
157
  Article.prototype.list = function (_a) {
158
- var type = _a.type, _b = _a.page, page = _b === void 0 ? 1 : _b, tag = _a.tag;
158
+ var type = _a.type, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.size, size = _c === void 0 ? 20 : _c, tag = _a.tag;
159
159
  return __awaiter(this, void 0, void 0, function () {
160
160
  var rsp, e_3;
161
- return __generator(this, function (_c) {
162
- switch (_c.label) {
161
+ return __generator(this, function (_d) {
162
+ switch (_d.label) {
163
163
  case 0:
164
- _c.trys.push([0, 2, , 3]);
164
+ _d.trys.push([0, 2, , 3]);
165
165
  return [4 /*yield*/, (0, utils_1.request)({
166
- url: "api/articles/".concat(tag !== undefined ? "tag/".concat(tag) : 'recent').concat(type, "?p=").concat(page, "&").concat(this._apiKey ? "apiKey=".concat(this._apiKey) : ''),
166
+ url: "api/articles/".concat(tag !== undefined ? "tag/".concat(tag) : 'recent').concat(type, "?p=").concat(page, "&size=").concat(size, "&").concat(this._apiKey ? "apiKey=".concat(this._apiKey) : ''),
167
167
  })];
168
168
  case 1:
169
- rsp = _c.sent();
169
+ rsp = _d.sent();
170
170
  return [2 /*return*/, rsp];
171
171
  case 2:
172
- e_3 = _c.sent();
172
+ e_3 = _d.sent();
173
173
  throw e_3;
174
174
  case 3: return [2 /*return*/];
175
175
  }
176
176
  });
177
177
  });
178
178
  };
179
+ /**
180
+ * 查询文章列表
181
+ * @param type 查询类型
182
+ * @param tag 指定查询标签,可选
183
+ * @returns 文章列表
184
+ */
185
+ Article.prototype.listByUser = function (_a) {
186
+ var user = _a.user, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.size, size = _c === void 0 ? 20 : _c;
187
+ return __awaiter(this, void 0, void 0, function () {
188
+ var rsp, e_4;
189
+ return __generator(this, function (_d) {
190
+ switch (_d.label) {
191
+ case 0:
192
+ _d.trys.push([0, 2, , 3]);
193
+ return [4 /*yield*/, (0, utils_1.request)({
194
+ url: "api/user/".concat(user, "articles?p=").concat(page, "&size=").concat(size, "&").concat(this._apiKey ? "apiKey=".concat(this._apiKey) : ''),
195
+ })];
196
+ case 1:
197
+ rsp = _d.sent();
198
+ return [2 /*return*/, rsp];
199
+ case 2:
200
+ e_4 = _d.sent();
201
+ throw e_4;
202
+ case 3: return [2 /*return*/];
203
+ }
204
+ });
205
+ });
206
+ };
179
207
  /**
180
208
  * 查询用户文章列表
181
209
  * @param userName 用户名
@@ -184,7 +212,7 @@ var Article = /** @class */ (function () {
184
212
  Article.prototype.userArticles = function (_a) {
185
213
  var userName = _a.userName, _b = _a.page, page = _b === void 0 ? 1 : _b;
186
214
  return __awaiter(this, void 0, void 0, function () {
187
- var rsp, e_4;
215
+ var rsp, e_5;
188
216
  return __generator(this, function (_c) {
189
217
  switch (_c.label) {
190
218
  case 0:
@@ -196,8 +224,8 @@ var Article = /** @class */ (function () {
196
224
  rsp = _c.sent();
197
225
  return [2 /*return*/, rsp];
198
226
  case 2:
199
- e_4 = _c.sent();
200
- throw e_4;
227
+ e_5 = _c.sent();
228
+ throw e_5;
201
229
  case 3: return [2 /*return*/];
202
230
  }
203
231
  });
@@ -211,7 +239,7 @@ var Article = /** @class */ (function () {
211
239
  Article.prototype.detail = function (id, p) {
212
240
  if (p === void 0) { p = 1; }
213
241
  return __awaiter(this, void 0, void 0, function () {
214
- var rsp, i, i, e_5;
242
+ var rsp, i, i, e_6;
215
243
  return __generator(this, function (_a) {
216
244
  switch (_a.label) {
217
245
  case 0:
@@ -230,8 +258,8 @@ var Article = /** @class */ (function () {
230
258
  }
231
259
  return [2 /*return*/, rsp];
232
260
  case 2:
233
- e_5 = _a.sent();
234
- throw e_5;
261
+ e_6 = _a.sent();
262
+ throw e_6;
235
263
  case 3: return [2 /*return*/];
236
264
  }
237
265
  });
@@ -245,7 +273,7 @@ var Article = /** @class */ (function () {
245
273
  */
246
274
  Article.prototype.vote = function (id, type) {
247
275
  return __awaiter(this, void 0, void 0, function () {
248
- var rsp, e_6;
276
+ var rsp, e_7;
249
277
  return __generator(this, function (_a) {
250
278
  switch (_a.label) {
251
279
  case 0:
@@ -262,8 +290,8 @@ var Article = /** @class */ (function () {
262
290
  rsp = _a.sent();
263
291
  return [2 /*return*/, rsp];
264
292
  case 2:
265
- e_6 = _a.sent();
266
- throw e_6;
293
+ e_7 = _a.sent();
294
+ throw e_7;
267
295
  case 3: return [2 /*return*/];
268
296
  }
269
297
  });
@@ -275,7 +303,7 @@ var Article = /** @class */ (function () {
275
303
  */
276
304
  Article.prototype.thank = function (id) {
277
305
  return __awaiter(this, void 0, void 0, function () {
278
- var rsp, e_7;
306
+ var rsp, e_8;
279
307
  return __generator(this, function (_a) {
280
308
  switch (_a.label) {
281
309
  case 0:
@@ -291,8 +319,8 @@ var Article = /** @class */ (function () {
291
319
  rsp = _a.sent();
292
320
  return [2 /*return*/, rsp];
293
321
  case 2:
294
- e_7 = _a.sent();
295
- throw e_7;
322
+ e_8 = _a.sent();
323
+ throw e_8;
296
324
  case 3: return [2 /*return*/];
297
325
  }
298
326
  });
@@ -304,7 +332,7 @@ var Article = /** @class */ (function () {
304
332
  */
305
333
  Article.prototype.follow = function (followingId) {
306
334
  return __awaiter(this, void 0, void 0, function () {
307
- var rsp, e_8;
335
+ var rsp, e_9;
308
336
  return __generator(this, function (_a) {
309
337
  switch (_a.label) {
310
338
  case 0:
@@ -321,8 +349,8 @@ var Article = /** @class */ (function () {
321
349
  rsp = _a.sent();
322
350
  return [2 /*return*/, rsp];
323
351
  case 2:
324
- e_8 = _a.sent();
325
- throw e_8;
352
+ e_9 = _a.sent();
353
+ throw e_9;
326
354
  case 3: return [2 /*return*/];
327
355
  }
328
356
  });
@@ -334,7 +362,7 @@ var Article = /** @class */ (function () {
334
362
  */
335
363
  Article.prototype.watch = function (followingId) {
336
364
  return __awaiter(this, void 0, void 0, function () {
337
- var rsp, e_9;
365
+ var rsp, e_10;
338
366
  return __generator(this, function (_a) {
339
367
  switch (_a.label) {
340
368
  case 0:
@@ -351,8 +379,8 @@ var Article = /** @class */ (function () {
351
379
  rsp = _a.sent();
352
380
  return [2 /*return*/, rsp];
353
381
  case 2:
354
- e_9 = _a.sent();
355
- throw e_9;
382
+ e_10 = _a.sent();
383
+ throw e_10;
356
384
  case 3: return [2 /*return*/];
357
385
  }
358
386
  });
@@ -364,7 +392,7 @@ var Article = /** @class */ (function () {
364
392
  */
365
393
  Article.prototype.reward = function (id) {
366
394
  return __awaiter(this, void 0, void 0, function () {
367
- var rsp, e_10;
395
+ var rsp, e_11;
368
396
  return __generator(this, function (_a) {
369
397
  switch (_a.label) {
370
398
  case 0:
@@ -380,8 +408,8 @@ var Article = /** @class */ (function () {
380
408
  rsp = _a.sent();
381
409
  return [2 /*return*/, rsp];
382
410
  case 2:
383
- e_10 = _a.sent();
384
- throw e_10;
411
+ e_11 = _a.sent();
412
+ throw e_11;
385
413
  case 3: return [2 /*return*/];
386
414
  }
387
415
  });
@@ -393,7 +421,7 @@ var Article = /** @class */ (function () {
393
421
  */
394
422
  Article.prototype.heat = function (id) {
395
423
  return __awaiter(this, void 0, void 0, function () {
396
- var rsp, e_11;
424
+ var rsp, e_12;
397
425
  return __generator(this, function (_a) {
398
426
  switch (_a.label) {
399
427
  case 0:
@@ -408,8 +436,8 @@ var Article = /** @class */ (function () {
408
436
  throw new Error(rsp.msg);
409
437
  return [2 /*return*/, rsp.articleHeat];
410
438
  case 2:
411
- e_11 = _a.sent();
412
- throw e_11;
439
+ e_12 = _a.sent();
440
+ throw e_12;
413
441
  case 3: return [2 /*return*/];
414
442
  }
415
443
  });
@@ -1,4 +1,4 @@
1
- import { ApiResponse, BreezemoonContent } from './typing';
1
+ import { ApiResponse, BreezemoonContent, BreezemoonList } from './typing';
2
2
  declare class Breezemoon {
3
3
  private _apiKey;
4
4
  constructor(token?: string);
@@ -16,6 +16,12 @@ declare class Breezemoon {
16
16
  code: number;
17
17
  breezemoons: Array<BreezemoonContent>;
18
18
  }>;
19
+ /**
20
+ * 获取清风明月列表
21
+ * @param page 消息页码
22
+ * @param size 每页个数
23
+ */
24
+ listByUser(user: string, page?: number, size?: number): Promise<ApiResponse<BreezemoonList>>;
19
25
  /**
20
26
  * 发送清风明月
21
27
  * @param content 内容
package/lib/breezemoon.js CHANGED
@@ -81,13 +81,41 @@ var Breezemoon = /** @class */ (function () {
81
81
  });
82
82
  });
83
83
  };
84
+ /**
85
+ * 获取清风明月列表
86
+ * @param page 消息页码
87
+ * @param size 每页个数
88
+ */
89
+ Breezemoon.prototype.listByUser = function (user, page, size) {
90
+ if (page === void 0) { page = 1; }
91
+ if (size === void 0) { size = 20; }
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ var rsp, e_2;
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0:
97
+ _a.trys.push([0, 2, , 3]);
98
+ return [4 /*yield*/, (0, utils_1.request)({
99
+ url: "api/user/".concat(user, "breezemoons?p=").concat(page, "&size=").concat(size, "&apiKey=").concat(this._apiKey)
100
+ })];
101
+ case 1:
102
+ rsp = _a.sent();
103
+ return [2 /*return*/, rsp];
104
+ case 2:
105
+ e_2 = _a.sent();
106
+ throw e_2;
107
+ case 3: return [2 /*return*/];
108
+ }
109
+ });
110
+ });
111
+ };
84
112
  /**
85
113
  * 发送清风明月
86
114
  * @param content 内容
87
115
  */
88
116
  Breezemoon.prototype.send = function (content) {
89
117
  return __awaiter(this, void 0, void 0, function () {
90
- var rsp, e_2;
118
+ var rsp, e_3;
91
119
  return __generator(this, function (_a) {
92
120
  switch (_a.label) {
93
121
  case 0:
@@ -104,8 +132,8 @@ var Breezemoon = /** @class */ (function () {
104
132
  rsp = _a.sent();
105
133
  return [2 /*return*/, rsp];
106
134
  case 2:
107
- e_2 = _a.sent();
108
- throw e_2;
135
+ e_3 = _a.sent();
136
+ throw e_3;
109
137
  case 3: return [2 /*return*/];
110
138
  }
111
139
  });
package/lib/chatroom.js CHANGED
@@ -327,7 +327,7 @@ var ChatRoom = /** @class */ (function () {
327
327
  })];
328
328
  case 1:
329
329
  rsp = _a.sent();
330
- mat = rsp.match(/>发送弹幕每次将花费\s*<b>([-0-9]+)<\/b>\s*([^<]*?)<\/div>/);
330
+ mat = rsp.match(/barragerCost">([-0-9]+)<\/span><\/b>\s*<span id="barragerUnit">([^<]*?)<\//);
331
331
  if (mat) {
332
332
  return [2 /*return*/, {
333
333
  cost: parseInt(mat[1]),
@@ -532,10 +532,8 @@ var ChatRoom = /** @class */ (function () {
532
532
  userOId = msg.userOId, oId = msg.oId, time = msg.time, userName = msg.userName, userNickname = msg.userNickname, userAvatarURL = msg.userAvatarURL, content = msg.content, md = msg.md, client = msg.client;
533
533
  try {
534
534
  data_1 = JSON.parse(content);
535
- if (data_1.msgType === 'redPacket') {
536
- content = data_1;
537
- msg.type = 'redPacket';
538
- }
535
+ content = data_1;
536
+ msg.type = data_1.msgType;
539
537
  }
540
538
  catch (e) { }
541
539
  data = { userOId: userOId, oId: oId, time: time, userName: userName, userNickname: userNickname, userAvatarURL: userAvatarURL, content: content, md: md, client: client, via: (0, utils_1.clientToVia)(client) };
package/lib/comment.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApiResponse, CommentPost, VoteStatus } from './typing';
1
+ import { ApiResponse, CommentPost, VoteType } from './typing';
2
2
  declare class Comment {
3
3
  private _apiKey;
4
4
  constructor(token?: string);
@@ -33,7 +33,7 @@ declare class Comment {
33
33
  vote(id: string, type: 'up' | 'down'): Promise<{
34
34
  code: number;
35
35
  msg?: string;
36
- type?: VoteStatus;
36
+ type?: VoteType;
37
37
  }>;
38
38
  /**
39
39
  * 评论感谢
package/lib/index.js CHANGED
@@ -443,6 +443,7 @@ var FishPi = /** @class */ (function () {
443
443
  data = new FormData();
444
444
  files.forEach(function (f) { return data.append('file[]', require('fs').readFileSync(f.toString()), require('path').basename(f.toString())); });
445
445
  }
446
+ data.append('apiKey', this.apiKey);
446
447
  _b.label = 3;
447
448
  case 3:
448
449
  _b.trys.push([3, 5, , 6]);
package/lib/typing.d.ts CHANGED
@@ -657,6 +657,10 @@ export interface ChatRoomMessage {
657
657
  * 消息 Id
658
658
  */
659
659
  oId: string;
660
+ /**
661
+ * 发送用户 Id
662
+ */
663
+ userOId: string;
660
664
  /**
661
665
  * 发送者用户名
662
666
  */
@@ -1226,6 +1230,22 @@ export interface NoticeSystem {
1226
1230
  */
1227
1231
  createTime: string;
1228
1232
  }
1233
+ /**
1234
+ * 用户清风明月列表
1235
+ */
1236
+ export interface BreezemoonList {
1237
+ /**
1238
+ * 分页信息
1239
+ */
1240
+ pagination: {
1241
+ paginationPageCount: number;
1242
+ paginationPageNums: Array<number>;
1243
+ };
1244
+ /**
1245
+ * 清风明月列表
1246
+ */
1247
+ breezemoons: Array<BreezemoonContent>;
1248
+ }
1229
1249
  export interface BreezemoonContent {
1230
1250
  /**
1231
1251
  * 发布者用户名
@@ -1829,7 +1849,7 @@ export interface ArticleDetail {
1829
1849
  */
1830
1850
  articleQnAOfferPoint: number;
1831
1851
  /**
1832
- * 作者头像缩略图
1852
+ * 文章缩略图
1833
1853
  */
1834
1854
  articleThumbnailURL: string;
1835
1855
  /**
@@ -2267,7 +2287,7 @@ export declare enum ArticleListType {
2267
2287
  /**
2268
2288
  * 点赞类型
2269
2289
  */
2270
- export declare enum VoteStatus {
2290
+ export declare enum VoteType {
2271
2291
  /**
2272
2292
  * 点赞
2273
2293
  */
package/lib/typing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArticleListType = exports.ArticleStatus = exports.YesNoStatus = exports.VoteStatus = exports.PublicStatus = exports.ArticleType = exports.ReportType = exports.ReportDataType = exports.NoticeType = exports.ChatRoomMessageType = exports.ChatMessageType = exports.ChatContentType = exports.ClientType = exports.MetalBase = exports.MetalAttr = exports.RedPacketType = exports.GestureType = exports.UserAppRole = exports.DataType = void 0;
3
+ exports.VoteType = exports.ArticleListType = exports.ArticleStatus = exports.YesNoStatus = exports.VoteStatus = exports.PublicStatus = exports.ArticleType = exports.ReportType = exports.ReportDataType = exports.NoticeType = exports.ChatRoomMessageType = exports.ChatMessageType = exports.ChatContentType = exports.ClientType = exports.MetalBase = exports.MetalAttr = exports.RedPacketType = exports.GestureType = exports.UserAppRole = exports.DataType = void 0;
4
4
  var utils_1 = require("./utils");
5
5
  /**
6
6
  * 数据类型
@@ -581,13 +581,14 @@ var ArticleListType;
581
581
  /**
582
582
  * 点赞类型
583
583
  */
584
- (function (VoteStatus) {
584
+ var VoteType;
585
+ (function (VoteType) {
585
586
  /**
586
587
  * 点赞
587
588
  */
588
- VoteStatus[VoteStatus["Voted"] = 0] = "Voted";
589
+ VoteType[VoteType["Voted"] = 0] = "Voted";
589
590
  /**
590
591
  * 取消点赞
591
592
  */
592
- VoteStatus[VoteStatus["Unvote"] = -1] = "Unvote";
593
- })(VoteStatus = exports.VoteStatus || (exports.VoteStatus = {}));
593
+ VoteType[VoteType["Unvote"] = -1] = "Unvote";
594
+ })(VoteType = exports.VoteType || (exports.VoteType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fishpi",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "description": "A Package to use API of fishpi.",
5
5
  "main": "./lib/index.js",
6
6
  "files": [