@nger/fk-upload 1.0.40 → 1.0.43

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.
@@ -5,7 +5,7 @@ export declare class LoginController {
5
5
  cookies: Map<string, Map<string, string>>;
6
6
  constructor(db: Db);
7
7
  login(loginId: string, ctx: Context): Promise<any>;
8
- relogin(token: string, loginId: string, ctx: Context): Promise<"login fail : username or password error" | undefined>;
8
+ relogin(token: string, loginId: string, ctx: Context): Promise<string>;
9
9
  private tryLogin;
10
10
  logDog(arg0: number, arg1: number): void;
11
11
  private loginSuccess;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  const url = new URL(window.location.href);
3
2
  const WS_PORT = Reflect.get(window, 'WS_PORT');
4
3
  const socket = new WebSocket(`ws://${url.hostname}:${WS_PORT}`);
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Db } from '@nger/typeorm';
2
3
  import { Context } from 'koa';
3
4
  import { CryptoService } from '@nger/utils';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Db } from '@nger/typeorm';
2
3
  import { Context } from 'koa';
3
4
  import { TaskService } from './tasks/task.service';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare class FkUploadCodeController {
2
3
  upload(loginId: string): JSX.Element;
3
4
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface Nav {
2
3
  title: string;
3
4
  link: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare class ErrorController {
2
3
  error(msg: string): JSX.Element;
3
4
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Db } from '@nger/typeorm';
2
3
  export declare class HelpController {
3
4
  private db;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare class Player {
2
3
  player(): JSX.Element;
3
4
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { TaskService } from './tasks/task.service';
2
3
  import { Client } from '@nger/redis';
3
4
  import { Context } from 'koa';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Config } from '@nger/core';
2
3
  import { Db } from '@nger/typeorm';
3
4
  import { Context } from 'koa';
@@ -12,6 +12,8 @@ const fs_extra_1 = require("fs-extra");
12
12
  const path_1 = require("path");
13
13
  const typeorm_1 = require("@nger/typeorm");
14
14
  const entities_1 = require("../../entities");
15
+ const rxjs_1 = require("rxjs");
16
+ const operators_1 = require("rxjs/operators");
15
17
  /**
16
18
  * upload and task
17
19
  */
@@ -20,6 +22,7 @@ class DownloadTask extends rabbitmq_1.Task {
20
22
  super(actions_1.DOWNLOAD_ACTION);
21
23
  }
22
24
  async handle(injector, next) {
25
+ const db = injector.get(typeorm_1.Db);
23
26
  const task = injector.get(rabbitmq_1.DATA);
24
27
  const complete = injector.get(rabbitmq_1.COMPLETE);
25
28
  const fail = injector.get(rabbitmq_1.FAIL);
@@ -33,10 +36,18 @@ class DownloadTask extends rabbitmq_1.Task {
33
36
  }
34
37
  });
35
38
  let total = 0;
39
+ let length = 0;
36
40
  let md5 = ``;
41
+ console.log(`download ${url}`);
42
+ const sub = new rxjs_1.Subject();
43
+ sub.pipe((0, operators_1.throttleTime)(1000), (0, operators_1.switchMap)((size) => {
44
+ console.log(`download ${task.filename}: ${length}`);
45
+ return db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { size });
46
+ })).subscribe();
37
47
  // get split size
38
48
  req.on('data', (buf) => {
39
49
  length += buf.length;
50
+ sub.next(length);
40
51
  writeStream.write(buf, (err) => {
41
52
  if (err)
42
53
  fail();
@@ -44,6 +55,7 @@ class DownloadTask extends rabbitmq_1.Task {
44
55
  });
45
56
  req.on('end', async () => {
46
57
  writeStream.end();
58
+ sub.complete();
47
59
  const fileMd5 = await (0, md5_file_1.default)(task.path);
48
60
  const isEqual = md5 === fileMd5;
49
61
  console.log(`file download success ${task.filename}, check result is ${isEqual}`);
@@ -163,6 +163,7 @@ let FkService = class FkService {
163
163
  task.uploadUrl = fullUrl;
164
164
  }
165
165
  }
166
+ console.log(`uploading ${index / task.totalChunks}`);
166
167
  index = index + 1;
167
168
  } while (!complete);
168
169
  // upload complete
@@ -26,13 +26,18 @@ class ScheduleTask extends rabbitmq_1.Task {
26
26
  const run = async () => {
27
27
  const accounts = await db.manager.find(entities_1.FkLoginEntity, {});
28
28
  const w7Usernames = accounts.map(account => account.w7Username);
29
+ console.log(`accounts`, accounts);
29
30
  const users = await w7.manager.find(w7_1.W7UsersEntity, { where: { username: (0, typeorm_2.In)(w7Usernames) } });
30
31
  const uids = users.map(user => user.uid);
31
32
  const uniAccounts = await w7.manager.find(w7_1.W7UniAccountEntity, { where: { createUid: (0, typeorm_2.In)(uids) } });
32
33
  const uniacids = uniAccounts.map(a => a.uniacid);
34
+ console.log(`uniacids`, uniacids);
33
35
  const tasks = await db.manager.find(entities_1.FkDownloadTaskEntity, { select: ['topicId'] });
34
36
  const ids = tasks.map(task => task.topicId);
35
- const topics = await w7.manager.find(w7_1.W7ChatTopicEntity, { where: { uniacid: (0, typeorm_2.In)(uniacids), id: (0, typeorm_2.Not)((0, typeorm_2.In)(ids)) } });
37
+ console.log(`topic ids`, ids);
38
+ const date = new Date('2022-05-10');
39
+ const topics = await w7.manager.find(w7_1.W7ChatTopicEntity, { where: { uniacid: (0, typeorm_2.In)(uniacids), id: (0, typeorm_2.Not)((0, typeorm_2.In)(ids)), createTime: Math.floor(date.getTime() / 1000) } });
40
+ console.log(`topics`, topics);
36
41
  topics.map(async (topic) => {
37
42
  if (topic.thirdUrl) {
38
43
  const uniacid = topic.uniacid;
@@ -5,5 +5,5 @@ export declare class UploadTaskController {
5
5
  constructor(db: Db);
6
6
  uploadTask(filename: string): Promise<{
7
7
  msg: string;
8
- } | undefined>;
8
+ }>;
9
9
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Db } from '@nger/typeorm';
2
3
  import { Context } from 'koa';
3
4
  export declare class UploadController {
@@ -4,7 +4,6 @@ exports.UploadController = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@nger/core");
6
6
  const http_1 = require("@nger/http");
7
- const react_1 = tslib_1.__importDefault(require("react"));
8
7
  const form_data_1 = tslib_1.__importDefault(require("form-data"));
9
8
  const axios_1 = tslib_1.__importDefault(require("axios"));
10
9
  const typeorm_1 = require("@nger/typeorm");
@@ -15,6 +14,7 @@ const url_1 = require("url");
15
14
  const fs_extra_1 = require("fs-extra");
16
15
  const request_1 = tslib_1.__importDefault(require("request"));
17
16
  const component_1 = require("./component");
17
+ const react_1 = tslib_1.__importDefault(require("react"));
18
18
  let UploadController = class UploadController {
19
19
  db;
20
20
  constructor(db) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.40",
3
+ "version": "1.0.43",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",
@@ -20,7 +20,7 @@
20
20
  "@nger/w7": "^1.0.0",
21
21
  "@nger/ws": "^1.0.0",
22
22
  "@types/download": "^8.0.1",
23
- "@types/react": "^18.0.5",
23
+ "@types/react": "^18.0.8",
24
24
  "@types/request": "^2.48.8",
25
25
  "axios": "^0.26.1",
26
26
  "cids": "^1.1.9",
@@ -29,7 +29,7 @@
29
29
  "fs-extra": "^10.1.0",
30
30
  "md5-file": "^5.0.0",
31
31
  "multihashing-async": "^2.1.4",
32
- "react": "^18.0.0",
32
+ "react": "^18.1.0",
33
33
  "request": "^2.88.2"
34
34
  },
35
35
  "scripts": {
package/pnpm-lock.yaml CHANGED
@@ -11,7 +11,7 @@ specifiers:
11
11
  '@nger/w7': workspace:^1.0.0
12
12
  '@nger/ws': workspace:^1.0.0
13
13
  '@types/download': ^8.0.1
14
- '@types/react': ^18.0.5
14
+ '@types/react': ^18.0.8
15
15
  '@types/request': ^2.48.8
16
16
  axios: ^0.26.1
17
17
  cids: ^1.1.9
@@ -20,7 +20,7 @@ specifiers:
20
20
  fs-extra: ^10.1.0
21
21
  md5-file: ^5.0.0
22
22
  multihashing-async: ^2.1.4
23
- react: ^18.0.0
23
+ react: ^18.1.0
24
24
  request: ^2.88.2
25
25
 
26
26
  dependencies:
@@ -30,7 +30,7 @@ dependencies:
30
30
  '@nger/rabbitmq': link:../rabbitmq
31
31
  '@nger/redis': link:../redis
32
32
  '@nger/schedule': link:../schedule
33
- '@nger/typeorm': link:../package
33
+ '@nger/typeorm': link:../typeorm
34
34
  '@nger/w7': link:../w7
35
35
  '@nger/ws': link:../ws
36
36
  '@types/download': 8.0.1