nestjs-web-console 1.0.2 → 1.0.3

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 (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +66 -66
  3. package/dist/console.types.d.ts +75 -75
  4. package/dist/console.types.js +15 -15
  5. package/dist/controllers/web.console.controller.d.ts +1 -1
  6. package/dist/controllers/web.console.controller.js +690 -675
  7. package/dist/filters/http-exception.filter.d.ts +4 -4
  8. package/dist/filters/http-exception.filter.js +50 -50
  9. package/dist/index.d.ts +8 -8
  10. package/dist/index.js +24 -24
  11. package/dist/services/all.commands.d.ts +3 -3
  12. package/dist/services/all.commands.js +13 -13
  13. package/dist/services/processors/base/console.command.d.ts +8 -8
  14. package/dist/services/processors/base/console.command.js +27 -27
  15. package/dist/services/processors/base/invalid.command.d.ts +5 -5
  16. package/dist/services/processors/base/invalid.command.js +14 -14
  17. package/dist/services/processors/base/not-logged.command.d.ts +5 -5
  18. package/dist/services/processors/base/not-logged.command.js +10 -10
  19. package/dist/services/processors/bash.command.d.ts +7 -7
  20. package/dist/services/processors/bash.command.js +102 -102
  21. package/dist/services/processors/clear-screen.command.d.ts +6 -6
  22. package/dist/services/processors/clear-screen.command.js +30 -30
  23. package/dist/services/processors/cmd.command.d.ts +7 -7
  24. package/dist/services/processors/cmd.command.js +99 -99
  25. package/dist/services/processors/help.command.d.ts +7 -7
  26. package/dist/services/processors/help.command.js +41 -41
  27. package/dist/services/processors/index.d.ts +8 -8
  28. package/dist/services/processors/index.js +24 -24
  29. package/dist/services/processors/invite.command.d.ts +9 -9
  30. package/dist/services/processors/invite.command.js +76 -76
  31. package/dist/services/processors/join.command.d.ts +8 -8
  32. package/dist/services/processors/join.command.js +108 -108
  33. package/dist/services/processors/login.command.d.ts +14 -14
  34. package/dist/services/processors/login.command.js +69 -69
  35. package/dist/services/processors/logout.command.d.ts +6 -6
  36. package/dist/services/processors/logout.command.js +30 -30
  37. package/dist/services/remote.console.service.d.ts +30 -30
  38. package/dist/services/remote.console.service.js +107 -107
  39. package/dist/services/temp.file.service.d.ts +25 -23
  40. package/dist/services/temp.file.service.js +102 -90
  41. package/dist/services/web.console.service.d.ts +57 -57
  42. package/dist/services/web.console.service.js +437 -437
  43. package/dist/web.console.module.d.ts +6 -6
  44. package/dist/web.console.module.js +87 -87
  45. package/dist.zip +0 -0
  46. package/package.json +5 -5
  47. package/tsconfig.json +18 -18
@@ -1,107 +1,107 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.RemoteConsoleService = void 0;
16
- const common_1 = require("@nestjs/common");
17
- const lodash_1 = __importDefault(require("lodash"));
18
- const web_console_service_1 = require("./web.console.service");
19
- let RemoteConsoleService = class RemoteConsoleService {
20
- constructor(webConsoleService) {
21
- Object.defineProperty(this, "webConsoleService", {
22
- enumerable: true,
23
- configurable: true,
24
- writable: true,
25
- value: webConsoleService
26
- });
27
- Object.defineProperty(this, "openInvitations", {
28
- enumerable: true,
29
- configurable: true,
30
- writable: true,
31
- value: {}
32
- });
33
- }
34
- isJoined(remoteName) {
35
- return (0, lodash_1.default)(this.webConsoleService.session).values().some(x => { var _a; return ((_a = x.joinedConnection) === null || _a === void 0 ? void 0 : _a.name) == remoteName; });
36
- }
37
- inviteThisConsole(remoteName, version, path) {
38
- if (!remoteName)
39
- throw new common_1.BadRequestException('name cannot be empty');
40
- let result = {
41
- joined: this.isJoined(remoteName)
42
- };
43
- if (result.joined)
44
- return result;
45
- const existingInvitation = this.openInvitations[remoteName];
46
- const expireAction = () => {
47
- delete this.openInvitations[remoteName];
48
- };
49
- if (existingInvitation) {
50
- clearTimeout(existingInvitation.expireTimer);
51
- existingInvitation.expireTimer = setTimeout(expireAction, 4000);
52
- }
53
- else {
54
- this.openInvitations[remoteName] = {
55
- expireTimer: setTimeout(expireAction, 4000),
56
- version,
57
- path
58
- };
59
- }
60
- return result;
61
- }
62
- async pumpStream(input) {
63
- if (!input.name)
64
- throw new common_1.BadRequestException('name cannot be empty');
65
- const session = (0, lodash_1.default)(this.webConsoleService.session).values().find(x => { var _a; return ((_a = x.joinedConnection) === null || _a === void 0 ? void 0 : _a.name) == input.name; });
66
- if (!session)
67
- throw new common_1.BadRequestException('connection closed');
68
- if (!session.joinedConnection)
69
- throw new common_1.BadRequestException('Connection was closed by remote end');
70
- //override running states if a command is about to be sent
71
- if (session.joinedConnection.command != null) {
72
- if (!session.joinedConnection.running)
73
- input.running = true;
74
- else if (session.joinedConnection.readLine)
75
- input.readLine = false;
76
- }
77
- Object.assign(session.joinedConnection, input);
78
- session.joinedConnection.onStream.call(this);
79
- const command = session.joinedConnection.command;
80
- session.joinedConnection.command = null;
81
- return { command };
82
- }
83
- async closeFromRemote(remoteName) {
84
- var _a;
85
- if (!remoteName)
86
- throw new common_1.BadRequestException('name cannot be empty');
87
- const session = (0, lodash_1.default)(this.webConsoleService.session).values().find(x => { var _a; return ((_a = x.joinedConnection) === null || _a === void 0 ? void 0 : _a.name) == remoteName; });
88
- if (session) {
89
- session.cancel = true;
90
- (_a = session.onCancel) === null || _a === void 0 ? void 0 : _a.call(this);
91
- if (session.readLineCallback) {
92
- session.readLineCallback(null);
93
- session.logs += '</div>';
94
- session.readLineCallback = null;
95
- }
96
- session.logs += '<div>Connection was closed by remote end</div><br/>';
97
- session.running = false;
98
- session.joinedConnection = null;
99
- }
100
- return { success: true };
101
- }
102
- };
103
- RemoteConsoleService = __decorate([
104
- (0, common_1.Injectable)(),
105
- __metadata("design:paramtypes", [web_console_service_1.WebConsoleService])
106
- ], RemoteConsoleService);
107
- exports.RemoteConsoleService = RemoteConsoleService;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.RemoteConsoleService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const lodash_1 = __importDefault(require("lodash"));
18
+ const web_console_service_1 = require("./web.console.service");
19
+ let RemoteConsoleService = class RemoteConsoleService {
20
+ constructor(webConsoleService) {
21
+ Object.defineProperty(this, "webConsoleService", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: webConsoleService
26
+ });
27
+ Object.defineProperty(this, "openInvitations", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: {}
32
+ });
33
+ }
34
+ isJoined(remoteName) {
35
+ return (0, lodash_1.default)(this.webConsoleService.session).values().some(x => { var _a; return ((_a = x.joinedConnection) === null || _a === void 0 ? void 0 : _a.name) == remoteName; });
36
+ }
37
+ inviteThisConsole(remoteName, version, path) {
38
+ if (!remoteName)
39
+ throw new common_1.BadRequestException('name cannot be empty');
40
+ let result = {
41
+ joined: this.isJoined(remoteName)
42
+ };
43
+ if (result.joined)
44
+ return result;
45
+ const existingInvitation = this.openInvitations[remoteName];
46
+ const expireAction = () => {
47
+ delete this.openInvitations[remoteName];
48
+ };
49
+ if (existingInvitation) {
50
+ clearTimeout(existingInvitation.expireTimer);
51
+ existingInvitation.expireTimer = setTimeout(expireAction, 4000);
52
+ }
53
+ else {
54
+ this.openInvitations[remoteName] = {
55
+ expireTimer: setTimeout(expireAction, 4000),
56
+ version,
57
+ path
58
+ };
59
+ }
60
+ return result;
61
+ }
62
+ async pumpStream(input) {
63
+ if (!input.name)
64
+ throw new common_1.BadRequestException('name cannot be empty');
65
+ const session = (0, lodash_1.default)(this.webConsoleService.session).values().find(x => { var _a; return ((_a = x.joinedConnection) === null || _a === void 0 ? void 0 : _a.name) == input.name; });
66
+ if (!session)
67
+ throw new common_1.BadRequestException('connection closed');
68
+ if (!session.joinedConnection)
69
+ throw new common_1.BadRequestException('Connection was closed by remote end');
70
+ //override running states if a command is about to be sent
71
+ if (session.joinedConnection.command != null) {
72
+ if (!session.joinedConnection.running)
73
+ input.running = true;
74
+ else if (session.joinedConnection.readLine)
75
+ input.readLine = false;
76
+ }
77
+ Object.assign(session.joinedConnection, input);
78
+ session.joinedConnection.onStream.call(this);
79
+ const command = session.joinedConnection.command;
80
+ session.joinedConnection.command = null;
81
+ return { command };
82
+ }
83
+ async closeFromRemote(remoteName) {
84
+ var _a;
85
+ if (!remoteName)
86
+ throw new common_1.BadRequestException('name cannot be empty');
87
+ const session = (0, lodash_1.default)(this.webConsoleService.session).values().find(x => { var _a; return ((_a = x.joinedConnection) === null || _a === void 0 ? void 0 : _a.name) == remoteName; });
88
+ if (session) {
89
+ session.cancel = true;
90
+ (_a = session.onCancel) === null || _a === void 0 ? void 0 : _a.call(this);
91
+ if (session.readLineCallback) {
92
+ session.readLineCallback(null);
93
+ session.logs += '</div>';
94
+ session.readLineCallback = null;
95
+ }
96
+ session.logs += '<div>Connection was closed by remote end</div><br/>';
97
+ session.running = false;
98
+ session.joinedConnection = null;
99
+ }
100
+ return { success: true };
101
+ }
102
+ };
103
+ RemoteConsoleService = __decorate([
104
+ (0, common_1.Injectable)(),
105
+ __metadata("design:paramtypes", [web_console_service_1.WebConsoleService])
106
+ ], RemoteConsoleService);
107
+ exports.RemoteConsoleService = RemoteConsoleService;
@@ -1,23 +1,25 @@
1
- import { ConsoleOptions } from "../console.types";
2
- export declare class TempFileService {
3
- consoleOptions: ConsoleOptions;
4
- private files;
5
- write(file: FileModel): void;
6
- read(name: string): FileModel;
7
- delete(name: string): void;
8
- getUrl(name: string): string;
9
- private deleteExpired;
10
- }
11
- export interface FileModel {
12
- name: string;
13
- content: any;
14
- type: 'csv' | 'html';
15
- expiresAt?: number;
16
- }
17
- export interface TempFileModel extends FileModel {
18
- name: string;
19
- content: any;
20
- type: 'csv' | 'html';
21
- createdAt?: number;
22
- updatedAt?: number;
23
- }
1
+ import { ConsoleOptions } from "../console.types";
2
+ import { ApplicationConfig } from "@nestjs/core";
3
+ export declare class TempFileService {
4
+ consoleOptions: ConsoleOptions;
5
+ appConfig: ApplicationConfig;
6
+ private files;
7
+ write(file: FileModel): void;
8
+ read(name: string): FileModel;
9
+ delete(name: string): void;
10
+ getUrl(name: string): string;
11
+ private deleteExpired;
12
+ }
13
+ export interface FileModel {
14
+ name: string;
15
+ content: any;
16
+ type: 'csv' | 'html';
17
+ expiresAt?: number;
18
+ }
19
+ export interface TempFileModel extends FileModel {
20
+ name: string;
21
+ content: any;
22
+ type: 'csv' | 'html';
23
+ createdAt?: number;
24
+ updatedAt?: number;
25
+ }
@@ -1,90 +1,102 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TempFileService = void 0;
13
- const common_1 = require("@nestjs/common");
14
- let TempFileService = class TempFileService {
15
- constructor() {
16
- Object.defineProperty(this, "consoleOptions", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
- Object.defineProperty(this, "files", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: []
27
- });
28
- }
29
- write(file) {
30
- const exists = this.files.find(x => x.name == file.name);
31
- if (exists) {
32
- exists.content = file.content;
33
- exists.updatedAt = Date.now();
34
- exists.expiresAt = file.expiresAt;
35
- if (exists.expiresAt) {
36
- const timeout = exists.expiresAt - Date.now();
37
- if (timeout > 0)
38
- setTimeout(() => this.deleteExpired(exists.name, exists.expiresAt), exists.expiresAt - Date.now());
39
- else {
40
- console.log('Deleting already expired existing file');
41
- this.deleteExpired(exists.name, exists.expiresAt);
42
- }
43
- }
44
- }
45
- else {
46
- const tempFile = file;
47
- tempFile.createdAt = Date.now();
48
- tempFile.updatedAt = Date.now();
49
- if (tempFile.expiresAt) {
50
- const timeout = tempFile.expiresAt - Date.now();
51
- if (timeout > 0) {
52
- this.files.push(tempFile);
53
- setTimeout(() => this.deleteExpired(tempFile.name, tempFile.expiresAt), tempFile.expiresAt - Date.now());
54
- }
55
- else {
56
- console.log('Not adding already expired new file');
57
- }
58
- }
59
- else
60
- this.files.push(tempFile);
61
- }
62
- }
63
- read(name) {
64
- const exists = this.files.find(x => x.name == name);
65
- if (!exists)
66
- throw new common_1.BadRequestException('File not found');
67
- return exists;
68
- }
69
- delete(name) {
70
- const index = this.files.findIndex(x => x.name == name);
71
- if (index > -1)
72
- this.files.splice(index, 1);
73
- }
74
- getUrl(name) {
75
- return `/${this.consoleOptions['endpoint'] || 'console'}/file/${name}`;
76
- }
77
- deleteExpired(name, expiresAt) {
78
- const index = this.files.findIndex(x => x.name == name && x.expiresAt == expiresAt);
79
- if (index > -1)
80
- this.files.splice(index, 1);
81
- }
82
- };
83
- __decorate([
84
- (0, common_1.Inject)('CONFIG_ROOT_OPTIONS'),
85
- __metadata("design:type", Object)
86
- ], TempFileService.prototype, "consoleOptions", void 0);
87
- TempFileService = __decorate([
88
- (0, common_1.Injectable)()
89
- ], TempFileService);
90
- exports.TempFileService = TempFileService;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TempFileService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const core_1 = require("@nestjs/core");
15
+ let TempFileService = class TempFileService {
16
+ constructor() {
17
+ Object.defineProperty(this, "consoleOptions", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "appConfig", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ Object.defineProperty(this, "files", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: []
34
+ });
35
+ }
36
+ write(file) {
37
+ const exists = this.files.find(x => x.name == file.name);
38
+ if (exists) {
39
+ exists.content = file.content;
40
+ exists.updatedAt = Date.now();
41
+ exists.expiresAt = file.expiresAt;
42
+ if (exists.expiresAt) {
43
+ const timeout = exists.expiresAt - Date.now();
44
+ if (timeout > 0)
45
+ setTimeout(() => this.deleteExpired(exists.name, exists.expiresAt), exists.expiresAt - Date.now());
46
+ else {
47
+ console.log('Deleting already expired existing file');
48
+ this.deleteExpired(exists.name, exists.expiresAt);
49
+ }
50
+ }
51
+ }
52
+ else {
53
+ const tempFile = file;
54
+ tempFile.createdAt = Date.now();
55
+ tempFile.updatedAt = Date.now();
56
+ if (tempFile.expiresAt) {
57
+ const timeout = tempFile.expiresAt - Date.now();
58
+ if (timeout > 0) {
59
+ this.files.push(tempFile);
60
+ setTimeout(() => this.deleteExpired(tempFile.name, tempFile.expiresAt), tempFile.expiresAt - Date.now());
61
+ }
62
+ else {
63
+ console.log('Not adding already expired new file');
64
+ }
65
+ }
66
+ else
67
+ this.files.push(tempFile);
68
+ }
69
+ }
70
+ read(name) {
71
+ const exists = this.files.find(x => x.name == name);
72
+ if (!exists)
73
+ throw new common_1.BadRequestException('File not found');
74
+ return exists;
75
+ }
76
+ delete(name) {
77
+ const index = this.files.findIndex(x => x.name == name);
78
+ if (index > -1)
79
+ this.files.splice(index, 1);
80
+ }
81
+ getUrl(name) {
82
+ const globalPrefix = this.appConfig.getGlobalPrefix();
83
+ return `${globalPrefix || ''}/${this.consoleOptions['endpoint'] || 'console'}/file/${name}`;
84
+ }
85
+ deleteExpired(name, expiresAt) {
86
+ const index = this.files.findIndex(x => x.name == name && x.expiresAt == expiresAt);
87
+ if (index > -1)
88
+ this.files.splice(index, 1);
89
+ }
90
+ };
91
+ __decorate([
92
+ (0, common_1.Inject)('CONFIG_ROOT_OPTIONS'),
93
+ __metadata("design:type", Object)
94
+ ], TempFileService.prototype, "consoleOptions", void 0);
95
+ __decorate([
96
+ (0, common_1.Inject)(core_1.ApplicationConfig),
97
+ __metadata("design:type", core_1.ApplicationConfig)
98
+ ], TempFileService.prototype, "appConfig", void 0);
99
+ TempFileService = __decorate([
100
+ (0, common_1.Injectable)()
101
+ ], TempFileService);
102
+ exports.TempFileService = TempFileService;
@@ -1,57 +1,57 @@
1
- import { ModuleRef } from "@nestjs/core";
2
- import express from "express";
3
- import { ConsoleOptions, ReadArgMap, ReadArgOptions, ReadLineOptions, SessionObject } from "../console.types";
4
- import { ConsoleCommand } from "./processors/base/console.command";
5
- import { InvalidCommand } from "./processors/base/invalid.command";
6
- import { NotLoggedCommand } from "./processors/base/not-logged.command";
7
- export declare class WebConsoleService {
8
- private moduleRef;
9
- allCommands: ConsoleCommand[];
10
- session: {
11
- [sessionId: string]: SessionObject;
12
- };
13
- consoleOptions: ConsoleOptions;
14
- constructor(moduleRef: ModuleRef);
15
- parse(commandLine: string, session: SessionObject): {
16
- cmd: InvalidCommand;
17
- arg: string;
18
- };
19
- createInvalidCommand(rawCommand: string, command: string): {
20
- cmd: InvalidCommand;
21
- arg: string;
22
- };
23
- createNotLoggedCommand(rawCommand: string, command: string): {
24
- cmd: NotLoggedCommand;
25
- arg: string;
26
- };
27
- log(session: SessionObject, text: string): void;
28
- toTable(entities: any[] | any, noColumns?: boolean): string;
29
- readLine(session: SessionObject, title: string, opts?: ReadLineOptions): Promise<string>;
30
- parseArgs(arg: string): any[];
31
- longWorkFactory: (session: SessionObject) => (process: (progress: (current: number, max: number) => void) => Promise<any>) => Promise<void>;
32
- loopFactory: (session: SessionObject) => <T>(items: T[], process: (item: T, i: number) => Promise<any>) => Promise<void>;
33
- readArgs(session: SessionObject, arg: string, mapList: ReadArgMap[], parameters?: ReadArgOptions): Promise<string[]>;
34
- getSession(req: express.Request, res: express.Response): SessionObject;
35
- escapeHtml(unsafe: any): any;
36
- makeId: (length: any) => string;
37
- private _readArgs;
38
- private clearExpired;
39
- private getAppCookies;
40
- }
41
- export interface CommandProcessParameters {
42
- rawCommand: string;
43
- arg: string;
44
- session: SessionObject;
45
- req: express.Request;
46
- res: express.Response;
47
- ip: string;
48
- logRaw(text: string): any;
49
- logTable(entities: any[] | any, noColumns?: boolean): any;
50
- log(...text: any[]): any;
51
- readArgs(mapList: ReadArgMap[], parameters?: ReadArgOptions): Promise<string[]>;
52
- readLine(title?: string, opts?: ReadLineOptions): Promise<string>;
53
- parseArgs(arg?: string): string[];
54
- toTable(entities: any[] | any, noColumns?: boolean): string;
55
- longWork(process: (progress: (current: number, max: number) => void) => Promise<any>): Promise<void>;
56
- loop<T>(items: T[], process: (item: T, i: number) => Promise<any>): Promise<void>;
57
- }
1
+ import { ModuleRef } from "@nestjs/core";
2
+ import express from "express";
3
+ import { ConsoleOptions, ReadArgMap, ReadArgOptions, ReadLineOptions, SessionObject } from "../console.types";
4
+ import { ConsoleCommand } from "./processors/base/console.command";
5
+ import { InvalidCommand } from "./processors/base/invalid.command";
6
+ import { NotLoggedCommand } from "./processors/base/not-logged.command";
7
+ export declare class WebConsoleService {
8
+ private moduleRef;
9
+ allCommands: ConsoleCommand[];
10
+ session: {
11
+ [sessionId: string]: SessionObject;
12
+ };
13
+ consoleOptions: ConsoleOptions;
14
+ constructor(moduleRef: ModuleRef);
15
+ parse(commandLine: string, session: SessionObject): {
16
+ cmd: InvalidCommand;
17
+ arg: string;
18
+ };
19
+ createInvalidCommand(rawCommand: string, command: string): {
20
+ cmd: InvalidCommand;
21
+ arg: string;
22
+ };
23
+ createNotLoggedCommand(rawCommand: string, command: string): {
24
+ cmd: NotLoggedCommand;
25
+ arg: string;
26
+ };
27
+ log(session: SessionObject, text: string): void;
28
+ toTable(entities: any[] | any, noColumns?: boolean): string;
29
+ readLine(session: SessionObject, title: string, opts?: ReadLineOptions): Promise<string>;
30
+ parseArgs(arg: string): any[];
31
+ longWorkFactory: (session: SessionObject) => (process: (progress: (current: number, max: number) => void) => Promise<any>) => Promise<void>;
32
+ loopFactory: (session: SessionObject) => <T>(items: T[], process: (item: T, i: number) => Promise<any>) => Promise<void>;
33
+ readArgs(session: SessionObject, arg: string, mapList: ReadArgMap[], parameters?: ReadArgOptions): Promise<string[]>;
34
+ getSession(req: express.Request, res: express.Response): SessionObject;
35
+ escapeHtml(unsafe: any): any;
36
+ makeId: (length: any) => string;
37
+ private _readArgs;
38
+ private clearExpired;
39
+ private getAppCookies;
40
+ }
41
+ export interface CommandProcessParameters {
42
+ rawCommand: string;
43
+ arg: string;
44
+ session: SessionObject;
45
+ req: express.Request;
46
+ res: express.Response;
47
+ ip: string;
48
+ logRaw(text: string): any;
49
+ logTable(entities: any[] | any, noColumns?: boolean): any;
50
+ log(...text: any[]): any;
51
+ readArgs(mapList: ReadArgMap[], parameters?: ReadArgOptions): Promise<string[]>;
52
+ readLine(title?: string, opts?: ReadLineOptions): Promise<string>;
53
+ parseArgs(arg?: string): string[];
54
+ toTable(entities: any[] | any, noColumns?: boolean): string;
55
+ longWork(process: (progress: (current: number, max: number) => void) => Promise<any>): Promise<void>;
56
+ loop<T>(items: T[], process: (item: T, i: number) => Promise<any>): Promise<void>;
57
+ }