pp-robot-module 0.2.14

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 (84) hide show
  1. package/README.md +34 -0
  2. package/dist/MR/Ai.d.ts +8 -0
  3. package/dist/MR/Ai.js +24 -0
  4. package/dist/MR/Clipboard.d.ts +20 -0
  5. package/dist/MR/Clipboard.js +60 -0
  6. package/dist/MR/Csv.d.ts +20 -0
  7. package/dist/MR/Csv.js +56 -0
  8. package/dist/MR/Date.d.ts +60 -0
  9. package/dist/MR/Date.js +94 -0
  10. package/dist/MR/DbClient.d.ts +97 -0
  11. package/dist/MR/DbClient.js +269 -0
  12. package/dist/MR/Dialog.d.ts +0 -0
  13. package/dist/MR/Dialog.js +40 -0
  14. package/dist/MR/Excel.d.ts +110 -0
  15. package/dist/MR/Excel.js +316 -0
  16. package/dist/MR/File.d.ts +162 -0
  17. package/dist/MR/File.js +399 -0
  18. package/dist/MR/Hash.d.ts +12 -0
  19. package/dist/MR/Hash.js +21 -0
  20. package/dist/MR/Html.d.ts +38 -0
  21. package/dist/MR/Html.js +163 -0
  22. package/dist/MR/Http.d.ts +33 -0
  23. package/dist/MR/Http.js +121 -0
  24. package/dist/MR/Imap.d.ts +15 -0
  25. package/dist/MR/Imap.js +52 -0
  26. package/dist/MR/Ini.d.ts +31 -0
  27. package/dist/MR/Ini.js +55 -0
  28. package/dist/MR/Keyboard.d.ts +59 -0
  29. package/dist/MR/Keyboard.js +515 -0
  30. package/dist/MR/Log.d.ts +7 -0
  31. package/dist/MR/Log.js +52 -0
  32. package/dist/MR/Mouse.d.ts +51 -0
  33. package/dist/MR/Mouse.js +152 -0
  34. package/dist/MR/Net.d.ts +17 -0
  35. package/dist/MR/Net.js +74 -0
  36. package/dist/MR/Pdf.d.ts +113 -0
  37. package/dist/MR/Pdf.js +197 -0
  38. package/dist/MR/Process.d.ts +46 -0
  39. package/dist/MR/Process.js +106 -0
  40. package/dist/MR/QRcode.d.ts +13 -0
  41. package/dist/MR/QRcode.js +37 -0
  42. package/dist/MR/RedisClient.d.ts +40 -0
  43. package/dist/MR/RedisClient.js +183 -0
  44. package/dist/MR/Regex.d.ts +16 -0
  45. package/dist/MR/Regex.js +20 -0
  46. package/dist/MR/Robot.d.ts +19 -0
  47. package/dist/MR/Robot.js +31 -0
  48. package/dist/MR/Screen.d.ts +20 -0
  49. package/dist/MR/Screen.js +79 -0
  50. package/dist/MR/Smtp.d.ts +21 -0
  51. package/dist/MR/Smtp.js +83 -0
  52. package/dist/MR/String.d.ts +104 -0
  53. package/dist/MR/String.js +166 -0
  54. package/dist/MR/System.d.ts +31 -0
  55. package/dist/MR/System.js +201 -0
  56. package/dist/MR/Validator.d.ts +30 -0
  57. package/dist/MR/Validator.js +104 -0
  58. package/dist/MR/WebBrowser.d.ts +210 -0
  59. package/dist/MR/WebBrowser.js +484 -0
  60. package/dist/MR/WebBrowser2.d.ts +0 -0
  61. package/dist/MR/WebBrowser2.js +504 -0
  62. package/dist/MR/WebElement.d.ts +123 -0
  63. package/dist/MR/WebElement.js +172 -0
  64. package/dist/MR/WebKeyboard.d.ts +21 -0
  65. package/dist/MR/WebKeyboard.js +48 -0
  66. package/dist/MR/WebMouse.d.ts +46 -0
  67. package/dist/MR/WebMouse.js +79 -0
  68. package/dist/MR/Window.d.ts +8 -0
  69. package/dist/MR/Window.js +34 -0
  70. package/dist/MR/Word.d.ts +56 -0
  71. package/dist/MR/Word.js +220 -0
  72. package/dist/MR/Zip.d.ts +25 -0
  73. package/dist/MR/Zip.js +89 -0
  74. package/dist/bin/inputting-method.exe +0 -0
  75. package/dist/bin/keyboard-password.exe +0 -0
  76. package/dist/bin/lock-window.exe +0 -0
  77. package/dist/bin/printer-pdf.exe +0 -0
  78. package/dist/dotenv.d.ts +0 -0
  79. package/dist/dotenv.js +2 -0
  80. package/dist/index.d.ts +54 -0
  81. package/dist/index.js +63 -0
  82. package/dist/util.d.ts +17 -0
  83. package/dist/util.js +41 -0
  84. package/package.json +120 -0
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ ## Installation
2
+ ```
3
+ npm i pp-robot-module
4
+ ```
5
+
6
+ ## Requirements
7
+ ### Installation
8
+ - nodejs v16.20
9
+ - vscode v1.75+
10
+ - vscode extension pp-robot-ide v1.0.0+
11
+
12
+ ### Enviroment
13
+ ```
14
+ 查看.env文件
15
+ ```
16
+
17
+ ## Sample
18
+ ```js
19
+ const { MR } = require('pp-robot-module');
20
+ (async () => {
21
+ await MR.Web.launch()
22
+ await MR.Web.goto('http://example.com/')
23
+ await MR.sleep(3000)
24
+ const headerFrame = await MR.Web.frame('headerFrame')
25
+ await headerFrame.getByRole('link', { name: '登录' }).click()
26
+ const cs= await MR.Web.cookies()
27
+ console.log(cs)
28
+ const conFrame = await MR.Web.frame('conFrame')
29
+ await conFrame.locator('#loginname').fill('test')
30
+ await MR.Web.close()
31
+ })()
32
+
33
+
34
+ ```
@@ -0,0 +1,8 @@
1
+ export declare namespace MR {
2
+ class Ai {
3
+ private constructor();
4
+ static do(): Promise<void>;
5
+ }
6
+ }
7
+ declare const _default: typeof MR.Ai;
8
+ export default _default;
package/dist/MR/Ai.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MR = void 0;
13
+ var MR;
14
+ (function (MR) {
15
+ class Ai {
16
+ constructor() { }
17
+ static do() {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ });
20
+ }
21
+ }
22
+ MR.Ai = Ai;
23
+ })(MR = exports.MR || (exports.MR = {}));
24
+ exports.default = MR.Ai;
@@ -0,0 +1,20 @@
1
+ /// <reference types="node" />
2
+ export declare namespace MR {
3
+ class Clipboard {
4
+ private constructor();
5
+ static copy(params: {
6
+ _msg?: string;
7
+ _file?: string;
8
+ }): Promise<void>;
9
+ static paste(): Promise<void>;
10
+ static copyImg(params: {
11
+ _imgPath: string;
12
+ }): Promise<void>;
13
+ static saveImg(params: {
14
+ _imgPath: string;
15
+ }): Promise<Buffer>;
16
+ static getContent(): Promise<string>;
17
+ }
18
+ }
19
+ declare const _default: typeof MR.Clipboard;
20
+ export default _default;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MR = void 0;
13
+ const clipboard_sys_1 = require("clipboard-sys");
14
+ const Keyboard_1 = require("./Keyboard");
15
+ const Log_1 = require("./Log");
16
+ const File_1 = require("./File");
17
+ var MR;
18
+ (function (MR) {
19
+ class Clipboard {
20
+ constructor() { }
21
+ static copy(params) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ Log_1.default.debug("Clipboard.copy", params);
24
+ if (params._msg)
25
+ return yield clipboard_sys_1.clipboard.writeText(params._msg);
26
+ if (params._file) {
27
+ //readfile
28
+ const _data = yield File_1.default.readFile({ _filename: params._file });
29
+ return yield clipboard_sys_1.clipboard.writeText(_data);
30
+ }
31
+ });
32
+ }
33
+ static paste() {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ Log_1.default.debug("Clipboard.paste");
36
+ yield Keyboard_1.default.Ctrl_V();
37
+ });
38
+ }
39
+ static copyImg(params) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ Log_1.default.debug("Clipboard.copyImg", params);
42
+ return yield clipboard_sys_1.clipboard.writeImage(params._imgPath);
43
+ });
44
+ }
45
+ static saveImg(params) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ Log_1.default.debug("Clipboard.saveImg");
48
+ return yield clipboard_sys_1.clipboard.readImage(params._imgPath);
49
+ });
50
+ }
51
+ static getContent() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ Log_1.default.debug("Clipboard.getContent");
54
+ return yield clipboard_sys_1.clipboard.readText();
55
+ });
56
+ }
57
+ }
58
+ MR.Clipboard = Clipboard;
59
+ })(MR = exports.MR || (exports.MR = {}));
60
+ exports.default = MR.Clipboard;
@@ -0,0 +1,20 @@
1
+ export declare namespace MR {
2
+ class Csv {
3
+ private constructor();
4
+ static fileToJson(params: {
5
+ _filename: string;
6
+ _isHeader?: boolean;
7
+ _delimiter?: string;
8
+ _flatKeys?: boolean;
9
+ }): Promise<any[]>;
10
+ static strToJson(params: {
11
+ _str: string;
12
+ }): Promise<any[]>;
13
+ static jsonToFile(params: {
14
+ _json: any;
15
+ _filename: string;
16
+ }): Promise<any>;
17
+ }
18
+ }
19
+ declare const _default: typeof MR.Csv;
20
+ export default _default;
package/dist/MR/Csv.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MR = void 0;
13
+ const _csv = require("csvtojson");
14
+ const File_1 = require("./File");
15
+ const json_2_csv_1 = require("json-2-csv");
16
+ const Log_1 = require("./Log");
17
+ var MR;
18
+ (function (MR) {
19
+ class Csv {
20
+ constructor() { }
21
+ static fileToJson(params) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ Log_1.default.debug("Csv.fileToJson", params._filename);
24
+ const opt = {};
25
+ if (params._isHeader)
26
+ opt['noheader'] = params._isHeader;
27
+ if (params._delimiter)
28
+ opt['delimiter'] = params._delimiter;
29
+ if (params._flatKeys)
30
+ opt['flatKeys'] = params._flatKeys;
31
+ const jsonArray = yield _csv(opt).fromFile(params._filename);
32
+ return jsonArray;
33
+ });
34
+ }
35
+ static strToJson(params) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ Log_1.default.debug("Csv.strToJson", params);
38
+ const csvRow = yield _csv({
39
+ noheader: true,
40
+ output: "csv"
41
+ }).fromString(params._str);
42
+ return csvRow;
43
+ });
44
+ }
45
+ //json数组保存到 csv
46
+ static jsonToFile(params) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ Log_1.default.debug("Csv.jsonToFile", params._filename);
49
+ const csv = yield (0, json_2_csv_1.json2csv)(params._json);
50
+ return yield File_1.default.outputFile({ _filename: params._filename, _data: csv });
51
+ });
52
+ }
53
+ }
54
+ MR.Csv = Csv;
55
+ })(MR = exports.MR || (exports.MR = {}));
56
+ exports.default = MR.Csv;
@@ -0,0 +1,60 @@
1
+ export declare namespace MR {
2
+ class DateClass {
3
+ private constructor();
4
+ static get(): any;
5
+ static all(): any;
6
+ static now(params?: {
7
+ _format?: string;
8
+ }): any;
9
+ static today(params?: {
10
+ _format?: string;
11
+ }): any;
12
+ static stamp(params?: {
13
+ _type?: 'second' | 'millisecond';
14
+ }): any;
15
+ static strToDate(params: {
16
+ _time: string;
17
+ _format: string;
18
+ }): any;
19
+ static fromNow(params: {
20
+ _time: string;
21
+ }): any;
22
+ static diff(params: {
23
+ _left: string;
24
+ _right: string;
25
+ _type: "day" | "week" | "month" | "year" | "hour" | "minute" | "second" | "millisecond";
26
+ }): any;
27
+ static add(params: {
28
+ _time: string;
29
+ _value: number;
30
+ _type: "day" | "week" | "month" | "year" | "hour" | "minute" | "second" | "millisecond";
31
+ }): any;
32
+ static subtract(params: {
33
+ _time: string;
34
+ _value: number;
35
+ _type: "day" | "week" | "month" | "year" | "hour" | "minute" | "second" | "millisecond";
36
+ }): any;
37
+ static daysInMonth(params: {
38
+ _time: string;
39
+ }): any;
40
+ static compare(params: {
41
+ _action: "same" | "after" | "before";
42
+ _left: string;
43
+ _right: string;
44
+ }): any;
45
+ static isSame(params: {
46
+ _left: string;
47
+ _right: string;
48
+ }): any;
49
+ static isAfter(params: {
50
+ _left: string;
51
+ _right: string;
52
+ }): any;
53
+ static isBefore(params: {
54
+ _left: string;
55
+ _right: string;
56
+ }): any;
57
+ }
58
+ }
59
+ declare const _default: typeof MR.DateClass;
60
+ export default _default;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MR = void 0;
4
+ var dayjs = require('dayjs');
5
+ const Log_1 = require("./Log");
6
+ var MR;
7
+ (function (MR) {
8
+ class DateClass {
9
+ constructor() { }
10
+ static get() {
11
+ Log_1.default.debug("Date.get");
12
+ return dayjs;
13
+ }
14
+ static all() {
15
+ Log_1.default.debug("Date.all");
16
+ return dayjs();
17
+ }
18
+ static now(params = {}) {
19
+ Log_1.default.debug("Date.now", params);
20
+ if (params._format) {
21
+ return dayjs().format(params._format);
22
+ }
23
+ else {
24
+ return dayjs().format('YYYY-MM-DD HH:mm:ss');
25
+ }
26
+ }
27
+ static today(params = {}) {
28
+ Log_1.default.debug("Date.today", params);
29
+ if (params._format) {
30
+ return dayjs().format(params._format);
31
+ }
32
+ else {
33
+ return dayjs().format('YYYY-MM-DD');
34
+ }
35
+ }
36
+ static stamp(params = { _type: 'second' }) {
37
+ Log_1.default.debug("Date.stamp", params);
38
+ if (params._type === 'second') {
39
+ return dayjs().unix();
40
+ }
41
+ else {
42
+ return dayjs().valueOf();
43
+ }
44
+ }
45
+ static strToDate(params) {
46
+ Log_1.default.debug("Date.strToDate", params);
47
+ return dayjs(params._time).format(params._format);
48
+ }
49
+ static fromNow(params) {
50
+ Log_1.default.debug("Date.fromNow", params);
51
+ return dayjs(params._time).fromNow();
52
+ }
53
+ static diff(params) {
54
+ Log_1.default.debug("Date.diff", params);
55
+ const date1 = dayjs(params._left);
56
+ return date1.diff(params._right, params._type);
57
+ }
58
+ static add(params) {
59
+ Log_1.default.debug("Date.add", params);
60
+ return dayjs(params._time).add(params._value, params._type);
61
+ }
62
+ static subtract(params) {
63
+ Log_1.default.debug("Date.subtract", params);
64
+ return dayjs(params._time).subtract(params._value, params._type);
65
+ }
66
+ static daysInMonth(params) {
67
+ Log_1.default.debug("Date.daysInMonth", params);
68
+ return dayjs(params._time).daysInMonth();
69
+ }
70
+ static compare(params) {
71
+ Log_1.default.debug("Date.compare", params);
72
+ if (params._action === 'same')
73
+ return dayjs(params._left).isSame(dayjs(params._right));
74
+ if (params._action === 'after')
75
+ return dayjs(params._left).isAfter(dayjs(params._right));
76
+ if (params._action === 'before')
77
+ return dayjs(params._left).isBefore(dayjs(params._right));
78
+ }
79
+ static isSame(params) {
80
+ Log_1.default.debug("Date.isSame", params);
81
+ return dayjs(params._left).isSame(dayjs(params._right));
82
+ }
83
+ static isAfter(params) {
84
+ Log_1.default.debug("Date.isAfter", params);
85
+ return dayjs(params._left).isAfter(dayjs(params._right));
86
+ }
87
+ static isBefore(params) {
88
+ Log_1.default.debug("Date.isBefore", params);
89
+ return dayjs(params._left).isBefore(dayjs(params._right));
90
+ }
91
+ }
92
+ MR.DateClass = DateClass;
93
+ })(MR = exports.MR || (exports.MR = {}));
94
+ exports.default = MR.DateClass;
@@ -0,0 +1,97 @@
1
+ export declare namespace MR {
2
+ class DbClient {
3
+ private static dbClient;
4
+ _knex: any;
5
+ static get instance(): DbClient;
6
+ private static _dbType;
7
+ private static _dbHost;
8
+ private static _dbPort;
9
+ private static _dbUser;
10
+ private static _dbPassword;
11
+ private static _dbName;
12
+ private static _dbDebug;
13
+ private constructor();
14
+ config(): Promise<void>;
15
+ do(): Promise<void>;
16
+ close(): Promise<void>;
17
+ select(params: {
18
+ _table: string;
19
+ _column?: string;
20
+ _where?: string;
21
+ _limit?: number;
22
+ _offset?: number;
23
+ }): Promise<any>;
24
+ insert(params: {
25
+ _table: string;
26
+ _data: {} | {}[];
27
+ }): Promise<any>;
28
+ update(params: {
29
+ _table: string;
30
+ _data: {};
31
+ _where?: string;
32
+ }): Promise<any>;
33
+ delete(params: {
34
+ _table: string;
35
+ _where?: string;
36
+ }): Promise<any>;
37
+ raw(params: {
38
+ _sql: string;
39
+ } | string): Promise<any>;
40
+ avg(params: {
41
+ _table: string;
42
+ _column: string;
43
+ _where?: string;
44
+ }): Promise<any>;
45
+ count(params: {
46
+ _table: string;
47
+ _column: string;
48
+ _where?: string;
49
+ }): Promise<any>;
50
+ sum(params: {
51
+ _table: string;
52
+ _column: string;
53
+ _where?: string;
54
+ }): Promise<any>;
55
+ min(params: {
56
+ _table: string;
57
+ _column: string;
58
+ _where?: string;
59
+ }): Promise<any>;
60
+ max(params: {
61
+ _table: string;
62
+ _column: string;
63
+ _where?: string;
64
+ }): Promise<any>;
65
+ trx(params?: {}): Promise<any>;
66
+ join(params?: {}): Promise<any>;
67
+ alterTable(params: {
68
+ _table: string;
69
+ }, _callback: Function): Promise<any>;
70
+ createTable(params: {
71
+ _table: string;
72
+ _callback: Function;
73
+ }): Promise<any>;
74
+ schema(params: {
75
+ _table: string;
76
+ }): Promise<any>;
77
+ truncate(params: {
78
+ _table: string;
79
+ }): Promise<any>;
80
+ hasTable(params: {
81
+ _table: string;
82
+ }): Promise<any>;
83
+ dropTable(params: {
84
+ _table: string;
85
+ }): Promise<any>;
86
+ createTableLike(params: {
87
+ _newTable: string;
88
+ _oldTable: string;
89
+ }): Promise<any>;
90
+ renameTable(params: {
91
+ _oldTable: string;
92
+ _newTable: string;
93
+ }): Promise<any>;
94
+ }
95
+ }
96
+ declare const _default: MR.DbClient;
97
+ export default _default;