hotstaq 0.5.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.
- package/.dockerignore +123 -0
- package/.eslintignore +17 -0
- package/.eslintrc.js +11 -0
- package/.vscode/launch.json +201 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +88 -0
- package/CONTRIBUTING.md +157 -0
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/bin/hotstaq +3 -0
- package/bin/hotstaq.cmd +1 -0
- package/build/src/Hot.d.ts +167 -0
- package/build/src/Hot.d.ts.map +1 -0
- package/build/src/Hot.js +365 -0
- package/build/src/Hot.js.map +1 -0
- package/build/src/HotAPI.d.ts +137 -0
- package/build/src/HotAPI.d.ts.map +1 -0
- package/build/src/HotAPI.js +353 -0
- package/build/src/HotAPI.js.map +1 -0
- package/build/src/HotAgentAPI.d.ts +22 -0
- package/build/src/HotAgentAPI.d.ts.map +1 -0
- package/build/src/HotAgentAPI.js +85 -0
- package/build/src/HotAgentAPI.js.map +1 -0
- package/build/src/HotAgentRoute.d.ts +17 -0
- package/build/src/HotAgentRoute.d.ts.map +1 -0
- package/build/src/HotAgentRoute.js +109 -0
- package/build/src/HotAgentRoute.js.map +1 -0
- package/build/src/HotBuilder.d.ts +52 -0
- package/build/src/HotBuilder.d.ts.map +1 -0
- package/build/src/HotBuilder.js +242 -0
- package/build/src/HotBuilder.js.map +1 -0
- package/build/src/HotClient.d.ts +31 -0
- package/build/src/HotClient.d.ts.map +1 -0
- package/build/src/HotClient.js +19 -0
- package/build/src/HotClient.js.map +1 -0
- package/build/src/HotComponent.d.ts +118 -0
- package/build/src/HotComponent.d.ts.map +1 -0
- package/build/src/HotComponent.js +89 -0
- package/build/src/HotComponent.js.map +1 -0
- package/build/src/HotCreator.d.ts +88 -0
- package/build/src/HotCreator.d.ts.map +1 -0
- package/build/src/HotCreator.js +445 -0
- package/build/src/HotCreator.js.map +1 -0
- package/build/src/HotDB.d.ts +69 -0
- package/build/src/HotDB.d.ts.map +1 -0
- package/build/src/HotDB.js +29 -0
- package/build/src/HotDB.js.map +1 -0
- package/build/src/HotDBConnectionInterface.d.ts +40 -0
- package/build/src/HotDBConnectionInterface.d.ts.map +1 -0
- package/build/src/HotDBConnectionInterface.js +3 -0
- package/build/src/HotDBConnectionInterface.js.map +1 -0
- package/build/src/HotFile.d.ts +134 -0
- package/build/src/HotFile.d.ts.map +1 -0
- package/build/src/HotFile.js +454 -0
- package/build/src/HotFile.js.map +1 -0
- package/build/src/HotGenerator.d.ts +80 -0
- package/build/src/HotGenerator.d.ts.map +1 -0
- package/build/src/HotGenerator.js +342 -0
- package/build/src/HotGenerator.js.map +1 -0
- package/build/src/HotHTTPServer.d.ts +162 -0
- package/build/src/HotHTTPServer.d.ts.map +1 -0
- package/build/src/HotHTTPServer.js +863 -0
- package/build/src/HotHTTPServer.js.map +1 -0
- package/build/src/HotIO.d.ts +47 -0
- package/build/src/HotIO.d.ts.map +1 -0
- package/build/src/HotIO.js +232 -0
- package/build/src/HotIO.js.map +1 -0
- package/build/src/HotLog.d.ts +60 -0
- package/build/src/HotLog.d.ts.map +1 -0
- package/build/src/HotLog.js +126 -0
- package/build/src/HotLog.js.map +1 -0
- package/build/src/HotPage.d.ts +125 -0
- package/build/src/HotPage.d.ts.map +1 -0
- package/build/src/HotPage.js +178 -0
- package/build/src/HotPage.js.map +1 -0
- package/build/src/HotRoute.d.ts +82 -0
- package/build/src/HotRoute.d.ts.map +1 -0
- package/build/src/HotRoute.js +83 -0
- package/build/src/HotRoute.js.map +1 -0
- package/build/src/HotRouteMethod.d.ts +129 -0
- package/build/src/HotRouteMethod.d.ts.map +1 -0
- package/build/src/HotRouteMethod.js +84 -0
- package/build/src/HotRouteMethod.js.map +1 -0
- package/build/src/HotServer.d.ts +152 -0
- package/build/src/HotServer.d.ts.map +1 -0
- package/build/src/HotServer.js +109 -0
- package/build/src/HotServer.js.map +1 -0
- package/build/src/HotSetAsWeb.d.ts +2 -0
- package/build/src/HotSetAsWeb.d.ts.map +1 -0
- package/build/src/HotSetAsWeb.js +5 -0
- package/build/src/HotSetAsWeb.js.map +1 -0
- package/build/src/HotStaq.d.ts +603 -0
- package/build/src/HotStaq.d.ts.map +1 -0
- package/build/src/HotStaq.js +1260 -0
- package/build/src/HotStaq.js.map +1 -0
- package/build/src/HotStaqWeb.d.ts +18 -0
- package/build/src/HotStaqWeb.d.ts.map +1 -0
- package/build/src/HotStaqWeb.js +44 -0
- package/build/src/HotStaqWeb.js.map +1 -0
- package/build/src/HotTestDriver.d.ts +63 -0
- package/build/src/HotTestDriver.d.ts.map +1 -0
- package/build/src/HotTestDriver.js +187 -0
- package/build/src/HotTestDriver.js.map +1 -0
- package/build/src/HotTestElement.d.ts +71 -0
- package/build/src/HotTestElement.d.ts.map +1 -0
- package/build/src/HotTestElement.js +37 -0
- package/build/src/HotTestElement.js.map +1 -0
- package/build/src/HotTestMap.d.ts +83 -0
- package/build/src/HotTestMap.d.ts.map +1 -0
- package/build/src/HotTestMap.js +58 -0
- package/build/src/HotTestMap.js.map +1 -0
- package/build/src/HotTestSeleniumDriver.d.ts +86 -0
- package/build/src/HotTestSeleniumDriver.d.ts.map +1 -0
- package/build/src/HotTestSeleniumDriver.js +400 -0
- package/build/src/HotTestSeleniumDriver.js.map +1 -0
- package/build/src/HotTester.d.ts +188 -0
- package/build/src/HotTester.d.ts.map +1 -0
- package/build/src/HotTester.js +622 -0
- package/build/src/HotTester.js.map +1 -0
- package/build/src/HotTesterAPI.d.ts +15 -0
- package/build/src/HotTesterAPI.d.ts.map +1 -0
- package/build/src/HotTesterAPI.js +161 -0
- package/build/src/HotTesterAPI.js.map +1 -0
- package/build/src/HotTesterMocha.d.ts +50 -0
- package/build/src/HotTesterMocha.d.ts.map +1 -0
- package/build/src/HotTesterMocha.js +205 -0
- package/build/src/HotTesterMocha.js.map +1 -0
- package/build/src/HotTesterMochaSelenium.d.ts +70 -0
- package/build/src/HotTesterMochaSelenium.d.ts.map +1 -0
- package/build/src/HotTesterMochaSelenium.js +257 -0
- package/build/src/HotTesterMochaSelenium.js.map +1 -0
- package/build/src/HotTesterServer.d.ts +114 -0
- package/build/src/HotTesterServer.d.ts.map +1 -0
- package/build/src/HotTesterServer.js +575 -0
- package/build/src/HotTesterServer.js.map +1 -0
- package/build/src/api copy.d.ts +2 -0
- package/build/src/api copy.d.ts.map +1 -0
- package/build/src/api copy.js +153 -0
- package/build/src/api copy.js.map +1 -0
- package/build/src/api-web.d.ts +2 -0
- package/build/src/api-web.d.ts.map +1 -0
- package/build/src/api-web.js +45 -0
- package/build/src/api-web.js.map +1 -0
- package/build/src/api.d.ts +33 -0
- package/build/src/api.d.ts.map +1 -0
- package/build/src/api.js +78 -0
- package/build/src/api.js.map +1 -0
- package/build/src/cli.d.ts +2 -0
- package/build/src/cli.d.ts.map +1 -0
- package/build/src/cli.js +1040 -0
- package/build/src/cli.js.map +1 -0
- package/build/src/schemas/HotDBInflux.d.ts +63 -0
- package/build/src/schemas/HotDBInflux.d.ts.map +1 -0
- package/build/src/schemas/HotDBInflux.js +239 -0
- package/build/src/schemas/HotDBInflux.js.map +1 -0
- package/build/src/schemas/HotDBMigration.d.ts +19 -0
- package/build/src/schemas/HotDBMigration.d.ts.map +1 -0
- package/build/src/schemas/HotDBMigration.js +15 -0
- package/build/src/schemas/HotDBMigration.js.map +1 -0
- package/build/src/schemas/HotDBMySQL.d.ts +65 -0
- package/build/src/schemas/HotDBMySQL.d.ts.map +1 -0
- package/build/src/schemas/HotDBMySQL.js +387 -0
- package/build/src/schemas/HotDBMySQL.js.map +1 -0
- package/build/src/schemas/HotDBSchema.d.ts +15 -0
- package/build/src/schemas/HotDBSchema.d.ts.map +1 -0
- package/build/src/schemas/HotDBSchema.js +19 -0
- package/build/src/schemas/HotDBSchema.js.map +1 -0
- package/build/src/schemas/influx/InfluxSchema.d.ts +14 -0
- package/build/src/schemas/influx/InfluxSchema.d.ts.map +1 -0
- package/build/src/schemas/influx/InfluxSchema.js +33 -0
- package/build/src/schemas/influx/InfluxSchema.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchema.d.ts +39 -0
- package/build/src/schemas/mysql/MySQLSchema.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchema.js +151 -0
- package/build/src/schemas/mysql/MySQLSchema.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaField.d.ts +168 -0
- package/build/src/schemas/mysql/MySQLSchemaField.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaField.js +260 -0
- package/build/src/schemas/mysql/MySQLSchemaField.js.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.d.ts +49 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.d.ts.map +1 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.js +310 -0
- package/build/src/schemas/mysql/MySQLSchemaTable.js.map +1 -0
- package/build-web/HotStaq.js +2 -0
- package/build-web/HotStaq.min.js +119 -0
- package/build-web/HotStaqTests_HelloWorldAPI.js +133 -0
- package/builder/docker/Dockerfile.linux.gen +42 -0
- package/builder/docker/README.md +36 -0
- package/builder/docker/app/start.sh +8 -0
- package/builder/docker/dockerignore +3 -0
- package/builder/docker/scripts/build.bat +11 -0
- package/builder/docker/scripts/build.sh +11 -0
- package/builder/docker/scripts/start-app.bat +7 -0
- package/builder/docker/scripts/start-app.sh +7 -0
- package/builder/docker/scripts/stop-app.bat +5 -0
- package/builder/docker/scripts/stop-app.sh +5 -0
- package/builder/docker-compose/docker-compose.gen.yaml +41 -0
- package/builder/docker-compose/env-skeleton +4 -0
- package/creator/project/.vscode/launch.json +59 -0
- package/creator/project/README.md +20 -0
- package/creator/project/gitignore +118 -0
- package/creator/project/npmignore +118 -0
- package/creator/public/api-test.hott +28 -0
- package/creator/public/index.hott +12 -0
- package/creator/ts/src/AppAPI.ts +30 -0
- package/creator/ts/src/HelloWorld.ts +39 -0
- package/creator/ts/src/WebExport.ts +7 -0
- package/creator/ts/tsconfig-web.json +73 -0
- package/creator/ts/tsconfig.json +73 -0
- package/creator/ts/webpack-api.config.js +57 -0
- package/dbstart.sh +19 -0
- package/dbstop.sh +4 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +130 -0
- package/docs/classes/Hot.md +477 -0
- package/docs/classes/HotAPI.md +369 -0
- package/docs/classes/HotClient.md +95 -0
- package/docs/classes/HotComponent.md +279 -0
- package/docs/classes/HotDB.md +247 -0
- package/docs/classes/HotDBInflux.md +404 -0
- package/docs/classes/HotDBMigration.md +80 -0
- package/docs/classes/HotDBMySQL.md +310 -0
- package/docs/classes/HotDBSchema.md +51 -0
- package/docs/classes/HotFile.md +353 -0
- package/docs/classes/HotHTTPServer.md +700 -0
- package/docs/classes/HotLog.md +162 -0
- package/docs/classes/HotPage.md +357 -0
- package/docs/classes/HotRoute.md +312 -0
- package/docs/classes/HotRouteMethod.md +271 -0
- package/docs/classes/HotServer.md +311 -0
- package/docs/classes/HotStaq.md +1155 -0
- package/docs/classes/HotTestDestination.md +58 -0
- package/docs/classes/HotTestDriver.md +332 -0
- package/docs/classes/HotTestElement.md +88 -0
- package/docs/classes/HotTestElementOptions.md +71 -0
- package/docs/classes/HotTestMap.md +92 -0
- package/docs/classes/HotTestSeleniumDriver.md +542 -0
- package/docs/classes/HotTester.md +653 -0
- package/docs/classes/HotTesterAPI.md +493 -0
- package/docs/classes/HotTesterMocha.md +843 -0
- package/docs/classes/HotTesterMochaSelenium.md +896 -0
- package/docs/classes/HotTesterServer.md +633 -0
- package/docs/classes/InfluxSchema.md +74 -0
- package/docs/classes/MySQLSchema.md +199 -0
- package/docs/classes/MySQLSchemaField.md +330 -0
- package/docs/classes/MySQLSchemaTable.md +176 -0
- package/docs/enums/ConnectionStatus.md +43 -0
- package/docs/enums/DeveloperMode.md +38 -0
- package/docs/enums/EventExecutionType.md +43 -0
- package/docs/enums/HTTPMethod.md +32 -0
- package/docs/enums/HotDBGenerationType.md +30 -0
- package/docs/enums/HotLogLevel.md +88 -0
- package/docs/interfaces/HotDBConnectionInterface.md +116 -0
- package/docs/interfaces/HotDestination.md +62 -0
- package/docs/interfaces/HotSite.md +187 -0
- package/docs/interfaces/HotSiteMapPath.md +37 -0
- package/docs/interfaces/HotSiteRoute.md +79 -0
- package/docs/interfaces/HotStartOptions.md +115 -0
- package/docs/interfaces/HotTestPage.md +44 -0
- package/docs/interfaces/HotTestStop.md +62 -0
- package/docs/interfaces/IHotComponent.md +135 -0
- package/docs/interfaces/IHotStaq.md +118 -0
- package/docs/interfaces/IHotTestElement.md +54 -0
- package/docs/interfaces/IHotTestElementOptions.md +43 -0
- package/docs/interfaces/MySQLResults.md +43 -0
- package/docs/interfaces/MySQLSchemaFieldResult.md +75 -0
- package/docs/modules.md +182 -0
- package/package.json +65 -0
- package/selenium-start.sh +7 -0
- package/selenium-stop.sh +3 -0
- package/src/Hot.ts +319 -0
- package/src/HotAPI.ts +386 -0
- package/src/HotAgentAPI.ts +43 -0
- package/src/HotAgentRoute.ts +44 -0
- package/src/HotBuilder.ts +221 -0
- package/src/HotClient.ts +40 -0
- package/src/HotComponent.ts +158 -0
- package/src/HotCreator.ts +470 -0
- package/src/HotDB.ts +79 -0
- package/src/HotDBConnectionInterface.ts +40 -0
- package/src/HotFile.ts +617 -0
- package/src/HotGenerator.ts +446 -0
- package/src/HotHTTPServer.ts +954 -0
- package/src/HotIO.ts +160 -0
- package/src/HotLog.ts +158 -0
- package/src/HotPage.ts +206 -0
- package/src/HotRoute.ts +137 -0
- package/src/HotRouteMethod.ts +216 -0
- package/src/HotServer.ts +211 -0
- package/src/HotSetAsWeb.ts +3 -0
- package/src/HotStaq.ts +1881 -0
- package/src/HotTestDriver.ts +171 -0
- package/src/HotTestElement.ts +97 -0
- package/src/HotTestMap.ts +130 -0
- package/src/HotTestSeleniumDriver.ts +381 -0
- package/src/HotTester.ts +696 -0
- package/src/HotTesterAPI.ts +126 -0
- package/src/HotTesterMocha.ts +133 -0
- package/src/HotTesterMochaSelenium.ts +189 -0
- package/src/HotTesterServer.ts +551 -0
- package/src/api-web.ts +48 -0
- package/src/api.ts +103 -0
- package/src/cli.ts +1225 -0
- package/src/schemas/HotDBInflux.ts +211 -0
- package/src/schemas/HotDBMigration.ts +24 -0
- package/src/schemas/HotDBMySQL.ts +312 -0
- package/src/schemas/HotDBSchema.ts +21 -0
- package/src/schemas/influx/InfluxSchema.ts +19 -0
- package/src/schemas/mysql/MySQLSchema.ts +90 -0
- package/src/schemas/mysql/MySQLSchemaField.ts +408 -0
- package/src/schemas/mysql/MySQLSchemaTable.ts +353 -0
- package/temp/HotStaqWeb.ts +59 -0
- package/tsconfig-generator.json +17 -0
- package/tsconfig-web.json +74 -0
- package/tsconfig.json +73 -0
- package/webpack.config.generator.js +41 -0
- package/webpack.config.js +53 -0
- package/webpack.config.tests.js +56 -0
package/src/HotIO.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as fse from "fs-extra";
|
|
3
|
+
|
|
4
|
+
const util = require ("util");
|
|
5
|
+
const asyncExec = util.promisify (require ("child_process").exec);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Handles IO for the server.
|
|
9
|
+
*/
|
|
10
|
+
export class HotIO
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Read a text file.
|
|
14
|
+
*/
|
|
15
|
+
static async readTextFile (path: string): Promise<string>
|
|
16
|
+
{
|
|
17
|
+
return (await new Promise (
|
|
18
|
+
(resolve: any, reject: any): void =>
|
|
19
|
+
{
|
|
20
|
+
fs.readFile (path, (err: NodeJS.ErrnoException, data: Buffer): void =>
|
|
21
|
+
{
|
|
22
|
+
if (err != null)
|
|
23
|
+
throw err;
|
|
24
|
+
|
|
25
|
+
let content: string = data.toString ();
|
|
26
|
+
|
|
27
|
+
resolve (content);
|
|
28
|
+
});
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Write to a text file.
|
|
34
|
+
*/
|
|
35
|
+
static async writeTextFile (path: string, content: string): Promise<string>
|
|
36
|
+
{
|
|
37
|
+
return (await new Promise (
|
|
38
|
+
(resolve: any, reject: any): void =>
|
|
39
|
+
{
|
|
40
|
+
fs.writeFile (path, content, (err: NodeJS.ErrnoException): void =>
|
|
41
|
+
{
|
|
42
|
+
if (err != null)
|
|
43
|
+
throw err;
|
|
44
|
+
|
|
45
|
+
resolve ();
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Make a directory.
|
|
52
|
+
*/
|
|
53
|
+
static async mkdir (path: string): Promise<void>
|
|
54
|
+
{
|
|
55
|
+
return (await new Promise (
|
|
56
|
+
(resolve: any, reject: any): void =>
|
|
57
|
+
{
|
|
58
|
+
fs.mkdir (path, { recursive: true },
|
|
59
|
+
(err: NodeJS.ErrnoException, path: string) =>
|
|
60
|
+
{
|
|
61
|
+
if (err != null)
|
|
62
|
+
throw err;
|
|
63
|
+
|
|
64
|
+
resolve ();
|
|
65
|
+
});
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Delete a file.
|
|
71
|
+
*/
|
|
72
|
+
static async rm (path: string): Promise<void>
|
|
73
|
+
{
|
|
74
|
+
return (await new Promise (
|
|
75
|
+
(resolve: any, reject: any): void =>
|
|
76
|
+
{
|
|
77
|
+
fs.rm (path,
|
|
78
|
+
(err: NodeJS.ErrnoException) =>
|
|
79
|
+
{
|
|
80
|
+
if (err != null)
|
|
81
|
+
throw err;
|
|
82
|
+
|
|
83
|
+
resolve ();
|
|
84
|
+
});
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Copy files to a location.
|
|
90
|
+
*/
|
|
91
|
+
static async copyFiles (src: string, dest: string): Promise<void>
|
|
92
|
+
{
|
|
93
|
+
return (fse.copy (src, dest));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Copy a file to a location.
|
|
98
|
+
*/
|
|
99
|
+
static async copyFile (src: string, dest: string, flags?: number): Promise<void>
|
|
100
|
+
{
|
|
101
|
+
return (fse.copyFile (src, dest, flags));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Move a file to a location.
|
|
106
|
+
*/
|
|
107
|
+
static async moveFile (src: string, dest: string, options: fse.MoveOptions = { overwrite: false }): Promise<void>
|
|
108
|
+
{
|
|
109
|
+
return (fse.move (src, dest, options));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Checks if a file is at a location.
|
|
114
|
+
*/
|
|
115
|
+
static async exists (path: string): Promise<boolean>
|
|
116
|
+
{
|
|
117
|
+
return (new Promise<boolean> ((resolve, reject) =>
|
|
118
|
+
{
|
|
119
|
+
fs.stat (path, (err: NodeJS.ErrnoException, stats: fs.Stats) =>
|
|
120
|
+
{
|
|
121
|
+
if (err != null)
|
|
122
|
+
{
|
|
123
|
+
if (err.code === "ENOENT")
|
|
124
|
+
resolve (false);
|
|
125
|
+
else
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
resolve (true);
|
|
130
|
+
});
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* List files at a location.
|
|
136
|
+
*/
|
|
137
|
+
static async listFiles (path: string): Promise<string[]>
|
|
138
|
+
{
|
|
139
|
+
return (new Promise<string[]> ((resolve, reject) =>
|
|
140
|
+
{
|
|
141
|
+
fs.readdir (path, (err: NodeJS.ErrnoException, files: string[]) =>
|
|
142
|
+
{
|
|
143
|
+
if (err != null)
|
|
144
|
+
throw err;
|
|
145
|
+
|
|
146
|
+
resolve (files);
|
|
147
|
+
});
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Execute a command.
|
|
153
|
+
*/
|
|
154
|
+
static async exec (cmd: string): Promise<string>
|
|
155
|
+
{
|
|
156
|
+
let output = await asyncExec (cmd);
|
|
157
|
+
|
|
158
|
+
return (output.stdout);
|
|
159
|
+
}
|
|
160
|
+
}
|
package/src/HotLog.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The logging level.
|
|
3
|
+
*/
|
|
4
|
+
export enum HotLogLevel
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* Prints only info messages.
|
|
8
|
+
*/
|
|
9
|
+
Info,
|
|
10
|
+
/**
|
|
11
|
+
* Prints only warning messages.
|
|
12
|
+
*/
|
|
13
|
+
Warning,
|
|
14
|
+
/**
|
|
15
|
+
* Prints only error messages.
|
|
16
|
+
*/
|
|
17
|
+
Error,
|
|
18
|
+
/**
|
|
19
|
+
* Prints all messages.
|
|
20
|
+
*/
|
|
21
|
+
Verbose,
|
|
22
|
+
/**
|
|
23
|
+
* Prints all messages, except verbose.
|
|
24
|
+
*/
|
|
25
|
+
All,
|
|
26
|
+
/**
|
|
27
|
+
* Doesn't print any message.
|
|
28
|
+
*/
|
|
29
|
+
None
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The logger.
|
|
34
|
+
*/
|
|
35
|
+
export class HotLog
|
|
36
|
+
{
|
|
37
|
+
/**
|
|
38
|
+
* The logging level.
|
|
39
|
+
*/
|
|
40
|
+
logLevel: HotLogLevel;
|
|
41
|
+
|
|
42
|
+
constructor (logLevel: HotLogLevel = HotLogLevel.All)
|
|
43
|
+
{
|
|
44
|
+
this.logLevel = logLevel;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Log a message.
|
|
49
|
+
*/
|
|
50
|
+
log (level: HotLogLevel, message: string)
|
|
51
|
+
{
|
|
52
|
+
if (this.logLevel === HotLogLevel.Verbose)
|
|
53
|
+
{
|
|
54
|
+
if (level === HotLogLevel.Error)
|
|
55
|
+
this.error (message);
|
|
56
|
+
|
|
57
|
+
if (level === HotLogLevel.Warning)
|
|
58
|
+
this.warning (message);
|
|
59
|
+
|
|
60
|
+
if ((level === HotLogLevel.Info) ||
|
|
61
|
+
(level === HotLogLevel.Verbose))
|
|
62
|
+
{
|
|
63
|
+
this.info (message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (this.logLevel === HotLogLevel.All)
|
|
68
|
+
{
|
|
69
|
+
if (level === HotLogLevel.Error)
|
|
70
|
+
this.error (message);
|
|
71
|
+
|
|
72
|
+
if (level === HotLogLevel.Warning)
|
|
73
|
+
this.warning (message);
|
|
74
|
+
|
|
75
|
+
if (level === HotLogLevel.Info)
|
|
76
|
+
this.info (message);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (this.logLevel === HotLogLevel.Error)
|
|
80
|
+
{
|
|
81
|
+
if (level === HotLogLevel.Error)
|
|
82
|
+
this.error (message);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (this.logLevel === HotLogLevel.Warning)
|
|
86
|
+
{
|
|
87
|
+
if (level === HotLogLevel.Warning)
|
|
88
|
+
this.warning (message);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (this.logLevel === HotLogLevel.Info)
|
|
92
|
+
{
|
|
93
|
+
if (level === HotLogLevel.Info)
|
|
94
|
+
this.info (message);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Log a verbose message.
|
|
100
|
+
*/
|
|
101
|
+
verbose (message: string)
|
|
102
|
+
{
|
|
103
|
+
if (this.logLevel === HotLogLevel.Verbose)
|
|
104
|
+
console.info (message);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Log a message.
|
|
109
|
+
*/
|
|
110
|
+
info (message: string)
|
|
111
|
+
{
|
|
112
|
+
if ((this.logLevel === HotLogLevel.All) ||
|
|
113
|
+
(this.logLevel === HotLogLevel.Verbose) ||
|
|
114
|
+
(this.logLevel === HotLogLevel.Info))
|
|
115
|
+
{
|
|
116
|
+
console.info (message);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Log a warning.
|
|
122
|
+
*/
|
|
123
|
+
warning (message: string)
|
|
124
|
+
{
|
|
125
|
+
if ((this.logLevel === HotLogLevel.All) ||
|
|
126
|
+
(this.logLevel === HotLogLevel.Verbose) ||
|
|
127
|
+
(this.logLevel === HotLogLevel.Warning))
|
|
128
|
+
{
|
|
129
|
+
console.warn (message);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Log an error message.
|
|
135
|
+
*/
|
|
136
|
+
error (message: string | Error)
|
|
137
|
+
{
|
|
138
|
+
if ((this.logLevel === HotLogLevel.All) ||
|
|
139
|
+
(this.logLevel === HotLogLevel.Verbose) ||
|
|
140
|
+
(this.logLevel === HotLogLevel.Error))
|
|
141
|
+
{
|
|
142
|
+
let msg: string = "";
|
|
143
|
+
|
|
144
|
+
if (typeof (message) === "string")
|
|
145
|
+
msg = message;
|
|
146
|
+
else
|
|
147
|
+
{
|
|
148
|
+
if (message.message != null)
|
|
149
|
+
msg = message.message;
|
|
150
|
+
|
|
151
|
+
if (message.stack != null)
|
|
152
|
+
msg = message.stack;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
console.error (msg);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
package/src/HotPage.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { Hot } from "./Hot";
|
|
2
|
+
import { HotFile } from "./HotFile";
|
|
3
|
+
import { HotStaq } from "./HotStaq";
|
|
4
|
+
import { HotAPI } from "./HotAPI";
|
|
5
|
+
import { HotTestElement } from "./HotTestElement";
|
|
6
|
+
import { HotTestMap, HotTestPath } from "./HotTestMap";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A page to preprocess.
|
|
10
|
+
*/
|
|
11
|
+
export interface IHotPage
|
|
12
|
+
{
|
|
13
|
+
/**
|
|
14
|
+
* The processor to use.
|
|
15
|
+
*/
|
|
16
|
+
processor: HotStaq;
|
|
17
|
+
/**
|
|
18
|
+
* The name of the page.
|
|
19
|
+
*/
|
|
20
|
+
name?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The route used to get to this page.
|
|
23
|
+
*/
|
|
24
|
+
route?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The name of the page. File ordering matters here.
|
|
27
|
+
* Every file is processed incrementally.
|
|
28
|
+
*/
|
|
29
|
+
files?: HotFile[];
|
|
30
|
+
/**
|
|
31
|
+
* The associated tester name.
|
|
32
|
+
*/
|
|
33
|
+
testerName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The associated tester map.
|
|
36
|
+
*/
|
|
37
|
+
testerMap?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The elements to test on this page.
|
|
40
|
+
*/
|
|
41
|
+
testElements?: { [name: string]: HotTestElement; };
|
|
42
|
+
/**
|
|
43
|
+
* The test paths to test on this page.
|
|
44
|
+
*/
|
|
45
|
+
testPaths?: { [name: string]: HotTestPath; };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A page to preprocess.
|
|
50
|
+
*/
|
|
51
|
+
export class HotPage implements IHotPage
|
|
52
|
+
{
|
|
53
|
+
/**
|
|
54
|
+
* The processor to use.
|
|
55
|
+
*/
|
|
56
|
+
processor: HotStaq;
|
|
57
|
+
/**
|
|
58
|
+
* The name of the page.
|
|
59
|
+
*/
|
|
60
|
+
name: string;
|
|
61
|
+
/**
|
|
62
|
+
* The route used to get to this page.
|
|
63
|
+
*/
|
|
64
|
+
route: string;
|
|
65
|
+
/**
|
|
66
|
+
* The name of the page. File ordering matters here.
|
|
67
|
+
* Every file is processed incrementally.
|
|
68
|
+
*/
|
|
69
|
+
files: HotFile[];
|
|
70
|
+
/**
|
|
71
|
+
* The associated tester name.
|
|
72
|
+
*/
|
|
73
|
+
testerName: string;
|
|
74
|
+
/**
|
|
75
|
+
* The associated tester map.
|
|
76
|
+
*/
|
|
77
|
+
testerMap: string;
|
|
78
|
+
/**
|
|
79
|
+
* The elements to test on this page.
|
|
80
|
+
*/
|
|
81
|
+
testElements: { [name: string]: HotTestElement; };
|
|
82
|
+
/**
|
|
83
|
+
* The test paths to test on this page.
|
|
84
|
+
*/
|
|
85
|
+
testPaths: { [name: string]: HotTestPath; };
|
|
86
|
+
|
|
87
|
+
constructor (copy: IHotPage | HotStaq)
|
|
88
|
+
{
|
|
89
|
+
if (copy instanceof HotStaq)
|
|
90
|
+
{
|
|
91
|
+
this.processor = copy;
|
|
92
|
+
this.name = "";
|
|
93
|
+
this.testerName = "";
|
|
94
|
+
this.testerMap = "";
|
|
95
|
+
this.route = "";
|
|
96
|
+
this.files = [];
|
|
97
|
+
this.testElements = {};
|
|
98
|
+
this.testPaths = {};
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
{
|
|
102
|
+
this.processor = copy.processor;
|
|
103
|
+
this.name = copy.name || "";
|
|
104
|
+
this.testerName = copy.testerName || "";
|
|
105
|
+
this.testerMap = copy.testerMap || "";
|
|
106
|
+
this.route = copy.route || "";
|
|
107
|
+
this.files = copy.files || [];
|
|
108
|
+
this.testElements = copy.testElements || {};
|
|
109
|
+
this.testPaths = copy.testPaths || {};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Add a file to process. It's recommend to load the file prior to
|
|
115
|
+
* adding it to a page if it's about to be used.
|
|
116
|
+
*/
|
|
117
|
+
async addFile (file: HotFile): Promise<void>
|
|
118
|
+
{
|
|
119
|
+
file.page = this;
|
|
120
|
+
|
|
121
|
+
this.files.push (file);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Get the API associated with this page.
|
|
126
|
+
*/
|
|
127
|
+
getAPI (): HotAPI
|
|
128
|
+
{
|
|
129
|
+
return (this.processor.api);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get the tester API associated with this page.
|
|
134
|
+
*/
|
|
135
|
+
getTesterAPI (): HotAPI
|
|
136
|
+
{
|
|
137
|
+
return (this.processor.testerAPI);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Add all files in the page. Could decrease page loading performance.
|
|
142
|
+
* It's recommend to load the file prior to adding it to a page.
|
|
143
|
+
*/
|
|
144
|
+
async load (file: HotFile): Promise<void>
|
|
145
|
+
{
|
|
146
|
+
for (let iIdx = 0; iIdx < this.files.length; iIdx++)
|
|
147
|
+
{
|
|
148
|
+
let file: HotFile = this.files[iIdx];
|
|
149
|
+
|
|
150
|
+
await file.load ();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Process a page and get the result.
|
|
156
|
+
*/
|
|
157
|
+
async process (args: any = null): Promise<string>
|
|
158
|
+
{
|
|
159
|
+
let output: string = "";
|
|
160
|
+
|
|
161
|
+
for (let iIdx = 0; iIdx < this.files.length; iIdx++)
|
|
162
|
+
{
|
|
163
|
+
let file: HotFile = this.files[iIdx];
|
|
164
|
+
|
|
165
|
+
Hot.Output = "";
|
|
166
|
+
file.page = this;
|
|
167
|
+
|
|
168
|
+
output += await file.process (args);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return (output);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Add a test element.
|
|
176
|
+
*/
|
|
177
|
+
addTestElement (elm: HotTestElement): void
|
|
178
|
+
{
|
|
179
|
+
if (this.testElements[elm.name] != null)
|
|
180
|
+
throw new Error (`Test element ${elm.name} already exists!`);
|
|
181
|
+
|
|
182
|
+
this.testElements[elm.name] = elm;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Get a test element.
|
|
187
|
+
*/
|
|
188
|
+
getTestElement (name: string): HotTestElement
|
|
189
|
+
{
|
|
190
|
+
if (this.testElements[name] == null)
|
|
191
|
+
throw new Error (`Test element ${name} doest not exist!`);
|
|
192
|
+
|
|
193
|
+
return (this.testElements[name]);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Create a test path.
|
|
198
|
+
*/
|
|
199
|
+
createTestPath (pathName: string, driverFunc: HotTestPath): void
|
|
200
|
+
{
|
|
201
|
+
if (this.testPaths[pathName] != null)
|
|
202
|
+
throw new Error (`Test path ${pathName} already exists!`);
|
|
203
|
+
|
|
204
|
+
this.testPaths[pathName] = driverFunc;
|
|
205
|
+
}
|
|
206
|
+
}
|
package/src/HotRoute.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { HotServer } from "./HotServer";
|
|
2
|
+
import { HotRouteMethod, HTTPMethod, ServerExecutionFunction, TestCaseFunction, TestCaseObject } from "./HotRouteMethod";
|
|
3
|
+
import { HotClient } from "./HotClient";
|
|
4
|
+
import { HotLog } from "./HotLog";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The route to use.
|
|
8
|
+
*/
|
|
9
|
+
export class HotRoute
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* The server that maintains the connections.
|
|
13
|
+
*/
|
|
14
|
+
connection: HotServer | HotClient;
|
|
15
|
+
/**
|
|
16
|
+
* The associated logger.
|
|
17
|
+
*/
|
|
18
|
+
logger: HotLog;
|
|
19
|
+
/**
|
|
20
|
+
* The route.
|
|
21
|
+
*/
|
|
22
|
+
route: string;
|
|
23
|
+
/**
|
|
24
|
+
* The version.
|
|
25
|
+
*/
|
|
26
|
+
version: string;
|
|
27
|
+
/**
|
|
28
|
+
* The prefix to add to the beginning of each route method.
|
|
29
|
+
*/
|
|
30
|
+
prefix: string;
|
|
31
|
+
/**
|
|
32
|
+
* The authorization credentials to be used by the client
|
|
33
|
+
* when connecting to the server.
|
|
34
|
+
*/
|
|
35
|
+
authCredentials: any;
|
|
36
|
+
/**
|
|
37
|
+
* The calls that can be made.
|
|
38
|
+
*/
|
|
39
|
+
methods: HotRouteMethod[];
|
|
40
|
+
/**
|
|
41
|
+
* The errors and their JSON that can be thrown. Can be:
|
|
42
|
+
* * not_authorized
|
|
43
|
+
*/
|
|
44
|
+
errors: { [error: string]: any };
|
|
45
|
+
|
|
46
|
+
constructor (connection: HotServer | HotClient, route: string, methods: HotRouteMethod[] = [])
|
|
47
|
+
{
|
|
48
|
+
this.connection = connection;
|
|
49
|
+
this.logger = null;
|
|
50
|
+
|
|
51
|
+
if (this.connection != null)
|
|
52
|
+
{
|
|
53
|
+
if (this.connection.processor != null)
|
|
54
|
+
this.logger = this.connection.processor.logger;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.route = route;
|
|
58
|
+
this.version = "v1";
|
|
59
|
+
this.prefix = "";
|
|
60
|
+
this.authCredentials = null;
|
|
61
|
+
this.methods = methods;
|
|
62
|
+
this.errors = {
|
|
63
|
+
"not_authorized": HotRoute.createError ("Not authorized.")
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Create an error JSON object.
|
|
69
|
+
*/
|
|
70
|
+
static createError (message: string): any
|
|
71
|
+
{
|
|
72
|
+
return ({ error: message });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Add an API method to this route.
|
|
77
|
+
*
|
|
78
|
+
* @param method The name of the method to add. If a HotRouteMethod is supplied, the
|
|
79
|
+
* rest of the arguments supplied will be ignored.
|
|
80
|
+
*/
|
|
81
|
+
addMethod (
|
|
82
|
+
method: HotRouteMethod | string,
|
|
83
|
+
executeFunction: ServerExecutionFunction = null,
|
|
84
|
+
type: HTTPMethod = HTTPMethod.POST,
|
|
85
|
+
testCases: (string | TestCaseFunction)[] | TestCaseFunction[] | TestCaseObject[] = null
|
|
86
|
+
): void
|
|
87
|
+
{
|
|
88
|
+
if (typeof (method) === "string")
|
|
89
|
+
method = new HotRouteMethod (this, method, executeFunction, type, null, null, null, testCases);
|
|
90
|
+
|
|
91
|
+
this.methods.push (method);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get a method by it's name.
|
|
96
|
+
*/
|
|
97
|
+
getMethod (name: string): HotRouteMethod
|
|
98
|
+
{
|
|
99
|
+
let foundMethod: HotRouteMethod = null;
|
|
100
|
+
|
|
101
|
+
for (let iIdx = 0; iIdx < this.methods.length; iIdx++)
|
|
102
|
+
{
|
|
103
|
+
let method: HotRouteMethod = this.methods[iIdx];
|
|
104
|
+
|
|
105
|
+
if (method.name === name)
|
|
106
|
+
{
|
|
107
|
+
foundMethod = method;
|
|
108
|
+
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (foundMethod);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Executes before all routes have been registered.
|
|
118
|
+
*/
|
|
119
|
+
onPreRegister: () => Promise<void> = null;
|
|
120
|
+
/**
|
|
121
|
+
* Executes when first registering this route with Express. If
|
|
122
|
+
* this returns false, the route will not be registered.
|
|
123
|
+
*/
|
|
124
|
+
onRegister: () => Promise<boolean> = null;
|
|
125
|
+
/**
|
|
126
|
+
* Executes after all routes have been registered.
|
|
127
|
+
*/
|
|
128
|
+
onPostRegister: () => Promise<void> = null;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Executes when authorizing a called method.
|
|
132
|
+
* The value returned from here will be passed to onExecute in the
|
|
133
|
+
* called HotRouteMethod. Undefined returning from here will mean
|
|
134
|
+
* the authorization failed.
|
|
135
|
+
*/
|
|
136
|
+
onAuthorizeUser: (req: any, res: any) => Promise<any> = null;
|
|
137
|
+
}
|