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
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { InfluxDB, ClientOptions, WriteApi, QueryApi, FluxTableMetaData, flux, Point } from "@influxdata/influxdb-client";
|
|
2
|
+
|
|
3
|
+
import { ConnectionStatus, HotDB } from "../HotDB";
|
|
4
|
+
import { HotDBConnectionInterface } from "../HotDBConnectionInterface";
|
|
5
|
+
import { InfluxSchema } from "./influx/InfluxSchema";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The Influx database connection.
|
|
9
|
+
*/
|
|
10
|
+
export class HotDBInflux extends HotDB<InfluxDB, void, InfluxSchema>
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* The Influx write api.
|
|
14
|
+
*/
|
|
15
|
+
writeApi: WriteApi;
|
|
16
|
+
/**
|
|
17
|
+
* The Influx query api.
|
|
18
|
+
*/
|
|
19
|
+
queryApi: QueryApi;
|
|
20
|
+
|
|
21
|
+
constructor (db: InfluxDB = null, type: string = "influx", schema: InfluxSchema = null)
|
|
22
|
+
{
|
|
23
|
+
super (db, type, schema);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Connect to the database.
|
|
28
|
+
*/
|
|
29
|
+
async connect (connectionInfo: HotDBConnectionInterface): Promise<any[]>
|
|
30
|
+
{
|
|
31
|
+
return (new Promise<any[]> ((resolve, reject) =>
|
|
32
|
+
{
|
|
33
|
+
let influxConnection: ClientOptions = {
|
|
34
|
+
"url": connectionInfo.server
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (connectionInfo.org == null)
|
|
38
|
+
throw new Error (`An org must be specified when connecting to Influx.`);
|
|
39
|
+
|
|
40
|
+
if (connectionInfo.database == null)
|
|
41
|
+
throw new Error (`A database (aka bucket) must be specified when connecting to Influx.`);
|
|
42
|
+
|
|
43
|
+
if (connectionInfo.token != null)
|
|
44
|
+
influxConnection.token = connectionInfo.token;
|
|
45
|
+
else
|
|
46
|
+
{
|
|
47
|
+
// This is mostly for Influx 1.8
|
|
48
|
+
influxConnection.token = `${connectionInfo.username}:${connectionInfo.password}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try
|
|
52
|
+
{
|
|
53
|
+
this.connectionStatus = ConnectionStatus.Connecting;
|
|
54
|
+
this.db = new InfluxDB (influxConnection);
|
|
55
|
+
|
|
56
|
+
this.writeApi = this.db.getWriteApi (connectionInfo.org, connectionInfo.database);
|
|
57
|
+
this.queryApi = this.db.getQueryApi (connectionInfo.org);
|
|
58
|
+
|
|
59
|
+
this.connectionStatus = ConnectionStatus.Connected;
|
|
60
|
+
resolve ([true]);
|
|
61
|
+
}
|
|
62
|
+
catch (ex)
|
|
63
|
+
{
|
|
64
|
+
throw new Error (ex.message);
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
multiQuery: undefined;
|
|
70
|
+
queryOne: undefined;
|
|
71
|
+
//syncAllTables: undefined;
|
|
72
|
+
syncTable: undefined;
|
|
73
|
+
tableCheck: undefined;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Checks to see if this has a database connection.
|
|
77
|
+
*/
|
|
78
|
+
protected dbCheck (): void
|
|
79
|
+
{
|
|
80
|
+
if (this.db == null)
|
|
81
|
+
throw new Error ("Not connected to a database!");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Write to the database. This will only store the point. It will not send to the database
|
|
86
|
+
* unless sendPoints is called.
|
|
87
|
+
*/
|
|
88
|
+
addPoint (point: Point): void
|
|
89
|
+
{
|
|
90
|
+
if (this.queryApi == null)
|
|
91
|
+
throw new Error ("The Influx query API is not instantiated! Is Influx connected?");
|
|
92
|
+
|
|
93
|
+
this.writeApi.writePoint (point);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Write to the database. This will only store the points. It will not send to the database
|
|
98
|
+
* unless sendPoints is called.
|
|
99
|
+
*/
|
|
100
|
+
addPoints (points: Point[]): void
|
|
101
|
+
{
|
|
102
|
+
if (this.queryApi == null)
|
|
103
|
+
throw new Error ("The Influx query API is not instantiated! Is Influx connected?");
|
|
104
|
+
|
|
105
|
+
this.writeApi.writePoints (points);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Writes all stored points to the database.
|
|
110
|
+
*/
|
|
111
|
+
async sendPoints (): Promise<void>
|
|
112
|
+
{
|
|
113
|
+
if (this.queryApi == null)
|
|
114
|
+
throw new Error ("The Influx query API is not instantiated! Is Influx connected?");
|
|
115
|
+
|
|
116
|
+
return (new Promise<void> ((resolve, reject) =>
|
|
117
|
+
{
|
|
118
|
+
this.writeApi.close ().then (() =>
|
|
119
|
+
{
|
|
120
|
+
resolve ();
|
|
121
|
+
})
|
|
122
|
+
.catch ((ex) =>
|
|
123
|
+
{
|
|
124
|
+
throw new Error (ex.message);
|
|
125
|
+
});
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Write to the database. This will call close and send the point immediately to the database.
|
|
131
|
+
* Do not use this to send lots of data. If you're sending batches of data, be sure to use
|
|
132
|
+
* writePoints.
|
|
133
|
+
*/
|
|
134
|
+
async write (point: Point): Promise<void>
|
|
135
|
+
{
|
|
136
|
+
if (this.queryApi == null)
|
|
137
|
+
throw new Error ("The Influx query API is not instantiated! Is Influx connected?");
|
|
138
|
+
|
|
139
|
+
this.addPoint (point);
|
|
140
|
+
|
|
141
|
+
return (this.sendPoints ());
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Write points to the database. This will call close and send the point immediately to the database.
|
|
146
|
+
*/
|
|
147
|
+
async writePoints (points: Point[]): Promise<void>
|
|
148
|
+
{
|
|
149
|
+
if (this.queryApi == null)
|
|
150
|
+
throw new Error ("The Influx query API is not instantiated! Is Influx connected?");
|
|
151
|
+
|
|
152
|
+
this.addPoints (points);
|
|
153
|
+
|
|
154
|
+
return (this.sendPoints ());
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The query to make.
|
|
159
|
+
*/
|
|
160
|
+
async query (queryString: string, values: any[] = [],
|
|
161
|
+
nextFunc: (row: string[], tableMeta: FluxTableMetaData) => void = null,
|
|
162
|
+
errorFunc: (error: Error) => void = null): Promise<void>
|
|
163
|
+
{
|
|
164
|
+
if (this.queryApi == null)
|
|
165
|
+
throw new Error ("The Influx query API is not instantiated! Is Influx connected?");
|
|
166
|
+
|
|
167
|
+
return (new Promise<void> (async (resolve, reject) =>
|
|
168
|
+
{
|
|
169
|
+
let ary = [{ raw: [queryString] }];
|
|
170
|
+
|
|
171
|
+
for (let iIdx = 0; iIdx < values.length; iIdx++)
|
|
172
|
+
{
|
|
173
|
+
let value: any = values[iIdx];
|
|
174
|
+
|
|
175
|
+
ary.push (value);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/// @fixme Is this correct? wtf? Hardly any documentation on TemplateStringsArray or flux usage.
|
|
179
|
+
let inputQuery: TemplateStringsArray = String.raw.apply (String, ary);
|
|
180
|
+
|
|
181
|
+
this.queryApi.queryRows (inputQuery, {
|
|
182
|
+
"next": (row: string[], tableMeta: FluxTableMetaData) =>
|
|
183
|
+
{
|
|
184
|
+
if (nextFunc != null)
|
|
185
|
+
nextFunc (row, tableMeta);
|
|
186
|
+
},
|
|
187
|
+
"error": (errorObj: Error) =>
|
|
188
|
+
{
|
|
189
|
+
if (errorFunc != null)
|
|
190
|
+
errorFunc (errorObj);
|
|
191
|
+
},
|
|
192
|
+
"complete": () =>
|
|
193
|
+
{
|
|
194
|
+
resolve ();
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Disconnect from the server.
|
|
202
|
+
*/
|
|
203
|
+
async disconnect (): Promise<void>
|
|
204
|
+
{
|
|
205
|
+
this.dbCheck ();
|
|
206
|
+
|
|
207
|
+
this.queryApi = null;
|
|
208
|
+
await this.writeApi.close ();
|
|
209
|
+
this.db = null;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration data related to table changes.
|
|
3
|
+
*/
|
|
4
|
+
export abstract class HotDBMigration
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* The version of this migration. **NOTE USE WHOLE INTEGERS ONLY**
|
|
8
|
+
*/
|
|
9
|
+
version: number;
|
|
10
|
+
|
|
11
|
+
constructor (version: number = 1)
|
|
12
|
+
{
|
|
13
|
+
this.version = version;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Executes when migrating the table upwards.
|
|
18
|
+
*/
|
|
19
|
+
abstract up (): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Executes when migrating the table downwards, or undoing actions.
|
|
22
|
+
*/
|
|
23
|
+
abstract down (): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import * as mysql from "mysql";
|
|
2
|
+
|
|
3
|
+
import * as ppath from "path";
|
|
4
|
+
import * as vm from "vm";
|
|
5
|
+
|
|
6
|
+
import { ConnectionStatus, HotDB } from "../HotDB";
|
|
7
|
+
import { HotDBConnectionInterface } from "../HotDBConnectionInterface";
|
|
8
|
+
import { HotIO } from "../HotIO";
|
|
9
|
+
import { HotDBMigration } from "./HotDBMigration";
|
|
10
|
+
import { MySQLSchema } from "./mysql/MySQLSchema";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The database results.
|
|
14
|
+
*/
|
|
15
|
+
export interface MySQLResults
|
|
16
|
+
{
|
|
17
|
+
error: any;
|
|
18
|
+
results: any;
|
|
19
|
+
fields: mysql.FieldInfo[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The MySQL database connection.
|
|
24
|
+
*/
|
|
25
|
+
export class HotDBMySQL extends HotDB<mysql.Connection, MySQLResults, MySQLSchema>
|
|
26
|
+
{
|
|
27
|
+
constructor (db: mysql.Connection = null, type: string = "mysql", schema: MySQLSchema = null)
|
|
28
|
+
{
|
|
29
|
+
super (db, type, schema);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Connect to the database.
|
|
34
|
+
*/
|
|
35
|
+
async connect (connectionInfo: HotDBConnectionInterface): Promise<any[]>
|
|
36
|
+
{
|
|
37
|
+
return (new Promise<any[]> ((resolve, reject) =>
|
|
38
|
+
{
|
|
39
|
+
this.connectionStatus = ConnectionStatus.Connecting;
|
|
40
|
+
this.db = mysql.createConnection ({
|
|
41
|
+
host: connectionInfo.server,
|
|
42
|
+
user: connectionInfo.username,
|
|
43
|
+
password: connectionInfo.password,
|
|
44
|
+
port: connectionInfo.port,
|
|
45
|
+
database: connectionInfo.database
|
|
46
|
+
});
|
|
47
|
+
this.db.connect ((err: mysql.MysqlError, ...args: any[]): void =>
|
|
48
|
+
{
|
|
49
|
+
if (err != null)
|
|
50
|
+
{
|
|
51
|
+
this.connectionStatus = ConnectionStatus.Disconnected;
|
|
52
|
+
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.connectionStatus = ConnectionStatus.Connected;
|
|
57
|
+
resolve (args[0]);
|
|
58
|
+
});
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Checks to see if this has a database connection.
|
|
64
|
+
*/
|
|
65
|
+
protected dbCheck (): void
|
|
66
|
+
{
|
|
67
|
+
if (this.db == null)
|
|
68
|
+
throw new Error ("Not connected to a database!");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Synchronize all tables.
|
|
73
|
+
*/
|
|
74
|
+
/*async syncAllTables (migrationsDirectory: string, throwErrors: boolean = true): Promise<boolean>
|
|
75
|
+
{
|
|
76
|
+
this.dbCheck ();
|
|
77
|
+
|
|
78
|
+
const migrationsPath: string = ppath.normalize (migrationsDirectory);
|
|
79
|
+
|
|
80
|
+
if (await HotIO.exists (migrationsPath) === false)
|
|
81
|
+
throw new Error (`Migrations directory ${migrationsDirectory} does not exist.`);
|
|
82
|
+
|
|
83
|
+
let files: string[] = await HotIO.listFiles (migrationsPath);
|
|
84
|
+
let versions: {
|
|
85
|
+
version: number;
|
|
86
|
+
fileContent: string;
|
|
87
|
+
}[] = [];
|
|
88
|
+
|
|
89
|
+
for (let iIdx = 0; iIdx < files.length; iIdx++)
|
|
90
|
+
{
|
|
91
|
+
let file: string = ppath.normalize (files[iIdx]);
|
|
92
|
+
let fileContent: string = await HotIO.readTextFile (file);
|
|
93
|
+
|
|
94
|
+
let context = { HotDBMigration: HotDBMigration, db: this, migrationPath: file };
|
|
95
|
+
vm.createContext (context);
|
|
96
|
+
let migrationVersion: any = vm.runInContext (
|
|
97
|
+
`${fileContent}
|
|
98
|
+
let migration = new Migration ();
|
|
99
|
+
return (migration.version);
|
|
100
|
+
`, context);
|
|
101
|
+
|
|
102
|
+
versions.push ({ version: migrationVersion, fileContent: fileContent });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
versions.sort ();
|
|
106
|
+
|
|
107
|
+
await this.syncMigrationsTableTracker ();
|
|
108
|
+
|
|
109
|
+
let madeModifications: boolean = false;
|
|
110
|
+
|
|
111
|
+
for (let tableName in this.schema.tables)
|
|
112
|
+
{
|
|
113
|
+
let tempResult: boolean = await this.syncTable (tableName, throwErrors);
|
|
114
|
+
|
|
115
|
+
if (tempResult === true)
|
|
116
|
+
madeModifications = true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return (madeModifications);
|
|
120
|
+
}*/
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Synchronize a table. This will create/modify the table based on whether it
|
|
124
|
+
* exists, and if there's been any changes to any fields.
|
|
125
|
+
*/
|
|
126
|
+
/*async syncTable (tableName: string, throwErrors: boolean = true): Promise<boolean>
|
|
127
|
+
{
|
|
128
|
+
this.dbCheck ();
|
|
129
|
+
|
|
130
|
+
let tableExists: boolean = await this.tableCheck (tableName);
|
|
131
|
+
let madeModifications: boolean = false;
|
|
132
|
+
|
|
133
|
+
if (tableExists === false)
|
|
134
|
+
{
|
|
135
|
+
let structure: string[] = await this.schema.generateTableStructure (tableName);
|
|
136
|
+
// This should always be structure[0]. There should only be 1 string to process
|
|
137
|
+
// for a newly created table.
|
|
138
|
+
let tempResults = await this.query (structure[0], []);
|
|
139
|
+
|
|
140
|
+
if (tempResults.error == null)
|
|
141
|
+
madeModifications = true;
|
|
142
|
+
else
|
|
143
|
+
{
|
|
144
|
+
if (throwErrors === true)
|
|
145
|
+
throw new Error (`Error while creating table ${tableName}: ${tempResults.error.message}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
{*/
|
|
150
|
+
/*let structure: string[] = await this.schema.generateTableStructure (
|
|
151
|
+
tableName, HotDBGenerationType.Modify, this);
|
|
152
|
+
let tempResults = await this.multiQuery (structure);
|
|
153
|
+
|
|
154
|
+
for (let iIdx = 0; iIdx < tempResults.length; iIdx++)
|
|
155
|
+
{
|
|
156
|
+
let results = tempResults[iIdx];
|
|
157
|
+
|
|
158
|
+
if (results.error != null)
|
|
159
|
+
{
|
|
160
|
+
madeModifications = false;
|
|
161
|
+
|
|
162
|
+
if (throwErrors === true)
|
|
163
|
+
throw new Error (`Error while creating table ${tableName}: ${results.error.message}`);
|
|
164
|
+
}
|
|
165
|
+
else
|
|
166
|
+
madeModifications = true;
|
|
167
|
+
}*/
|
|
168
|
+
/*}
|
|
169
|
+
|
|
170
|
+
return (madeModifications);
|
|
171
|
+
}*/
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sync the migrations table tracker. This keeps track of all database table migrations.
|
|
175
|
+
* If the "migrations" table is missing, it will be created.
|
|
176
|
+
*/
|
|
177
|
+
async syncMigrationsTableTracker (): Promise<void>
|
|
178
|
+
{
|
|
179
|
+
if (await this.tableCheck ("migrations") === false)
|
|
180
|
+
{
|
|
181
|
+
/// @todo Verify that this actually created.
|
|
182
|
+
await this.db.query (`create table if not exists migrations (
|
|
183
|
+
version datetime not null
|
|
184
|
+
);`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Checks if the table exists.
|
|
190
|
+
*/
|
|
191
|
+
async tableCheck (tableName: string): Promise<boolean>
|
|
192
|
+
{
|
|
193
|
+
this.dbCheck ();
|
|
194
|
+
|
|
195
|
+
let tableExists: boolean = await new Promise<boolean> ((resolve, reject) =>
|
|
196
|
+
{
|
|
197
|
+
this.db.query ("SELECT table_name FROM information_schema.tables where table_name = ?;", [tableName],
|
|
198
|
+
(err: mysql.MysqlError, results: any, fields: mysql.FieldInfo[]) =>
|
|
199
|
+
{
|
|
200
|
+
let result: boolean = false;
|
|
201
|
+
|
|
202
|
+
if (results != null)
|
|
203
|
+
{
|
|
204
|
+
if (results.length > 0)
|
|
205
|
+
result = true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
resolve (result);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return (tableExists);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The query to make.
|
|
217
|
+
*/
|
|
218
|
+
async query (queryString: string, values: any[] = []): Promise<MySQLResults>
|
|
219
|
+
{
|
|
220
|
+
this.dbCheck ();
|
|
221
|
+
|
|
222
|
+
let dbresults: MySQLResults = await new Promise<MySQLResults> ((resolve, reject) =>
|
|
223
|
+
{
|
|
224
|
+
this.db.query (queryString, values,
|
|
225
|
+
(err: mysql.MysqlError, results: any, fields: mysql.FieldInfo[]) =>
|
|
226
|
+
{
|
|
227
|
+
resolve ({ error: err, results: results, fields: fields });
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
return (dbresults);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Make a single query. If there are no results, null will be in MySQLResults.results
|
|
236
|
+
*/
|
|
237
|
+
async queryOne (queryString: string, values: any[] = []): Promise<MySQLResults>
|
|
238
|
+
{
|
|
239
|
+
this.dbCheck ();
|
|
240
|
+
|
|
241
|
+
let dbresults: MySQLResults = await new Promise<MySQLResults> ((resolve, reject) =>
|
|
242
|
+
{
|
|
243
|
+
this.db.query (queryString, values,
|
|
244
|
+
(err: mysql.MysqlError, results: any, fields: mysql.FieldInfo[]) =>
|
|
245
|
+
{
|
|
246
|
+
let tempResults = null;
|
|
247
|
+
|
|
248
|
+
if (results != null)
|
|
249
|
+
{
|
|
250
|
+
if (results.length > 0)
|
|
251
|
+
tempResults = results[0];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
resolve ({ error: err, results: tempResults, fields: fields });
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
return (dbresults);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Make multiple queries. **Warning! This can be a security vulnerability
|
|
263
|
+
* if misused! Ideally this should only be used when making changes to tables!
|
|
264
|
+
* Additionally, this could overwhelm the server and each command sent is not
|
|
265
|
+
* guaranteed to be done in order.**
|
|
266
|
+
*/
|
|
267
|
+
async multiQuery (queryStrings: string[] | { query: string; values: any[]; }[]): Promise<MySQLResults[]>
|
|
268
|
+
{
|
|
269
|
+
this.dbCheck ();
|
|
270
|
+
|
|
271
|
+
let alldbresults: MySQLResults[] = [];
|
|
272
|
+
let promises = [];
|
|
273
|
+
|
|
274
|
+
for (let iIdx = 0; iIdx < queryStrings.length; iIdx++)
|
|
275
|
+
{
|
|
276
|
+
/// @fixme This could overwhelm the server, and each query most likely will
|
|
277
|
+
/// not be done in a deterministic order. Consider adding a 5-10ms delay between
|
|
278
|
+
/// each query.
|
|
279
|
+
promises.push (new Promise<MySQLResults> ((resolve, reject) =>
|
|
280
|
+
{
|
|
281
|
+
let queryString: string | { query: string; values: any[]; } = queryStrings[iIdx];
|
|
282
|
+
let queryValues: any[] = [];
|
|
283
|
+
|
|
284
|
+
if (typeof (queryString) !== "string")
|
|
285
|
+
{
|
|
286
|
+
queryValues = queryString.values;
|
|
287
|
+
queryString = queryString.query;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
this.db.query (queryString, queryValues,
|
|
291
|
+
(err: mysql.MysqlError, results: any, fields: mysql.FieldInfo[]) =>
|
|
292
|
+
{
|
|
293
|
+
resolve ({ error: err, results: results, fields: fields });
|
|
294
|
+
});
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
alldbresults = await Promise.all (promises);
|
|
299
|
+
|
|
300
|
+
return (alldbresults);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Disconnect from the server.
|
|
305
|
+
*/
|
|
306
|
+
async disconnect (): Promise<void>
|
|
307
|
+
{
|
|
308
|
+
this.dbCheck ();
|
|
309
|
+
|
|
310
|
+
this.db.destroy ();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export enum HotDBGenerationType
|
|
2
|
+
{
|
|
3
|
+
Create,
|
|
4
|
+
Modify
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The parent database schema.
|
|
9
|
+
*/
|
|
10
|
+
export class HotDBSchema
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* The name of this schema.
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
|
|
17
|
+
constructor (name: string)
|
|
18
|
+
{
|
|
19
|
+
this.name = name;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HotDBSchema } from "../HotDBSchema";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The Influx schema.
|
|
5
|
+
*/
|
|
6
|
+
export class InfluxSchema extends HotDBSchema
|
|
7
|
+
{
|
|
8
|
+
/**
|
|
9
|
+
* The buckets in this schema.
|
|
10
|
+
*/
|
|
11
|
+
buckets: { [name: string]: any };
|
|
12
|
+
|
|
13
|
+
constructor (name: string)
|
|
14
|
+
{
|
|
15
|
+
super (name);
|
|
16
|
+
|
|
17
|
+
this.buckets = {};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { MySQLSchemaTable } from "./MySQLSchemaTable";
|
|
2
|
+
import { MySQLSchemaField } from "./MySQLSchemaField";
|
|
3
|
+
import { HotDBSchema, HotDBGenerationType } from "../HotDBSchema";
|
|
4
|
+
import { HotDBMySQL } from "../HotDBMySQL";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The MySQL schema.
|
|
8
|
+
*/
|
|
9
|
+
export class MySQLSchema extends HotDBSchema
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* The tables in this schema.
|
|
13
|
+
*/
|
|
14
|
+
tables: { [name: string]: MySQLSchemaTable };
|
|
15
|
+
|
|
16
|
+
constructor (name: string)
|
|
17
|
+
{
|
|
18
|
+
super (name);
|
|
19
|
+
|
|
20
|
+
this.tables = {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Add a table to this schema.
|
|
25
|
+
*/
|
|
26
|
+
addTable (table: MySQLSchemaTable): void
|
|
27
|
+
{
|
|
28
|
+
this.tables[table.name] = table;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Add a field to a table.
|
|
33
|
+
*/
|
|
34
|
+
addFieldToTable (tableName: string, field: MySQLSchemaField)
|
|
35
|
+
{
|
|
36
|
+
if (this.tables[tableName] == null)
|
|
37
|
+
throw new Error (`Table ${tableName} does not exist!`);
|
|
38
|
+
|
|
39
|
+
this.tables[tableName].fields.push (field);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Add a field to a table.
|
|
44
|
+
*/
|
|
45
|
+
addFieldsToTable (tableName: string, fields: MySQLSchemaField[])
|
|
46
|
+
{
|
|
47
|
+
if (this.tables[tableName] == null)
|
|
48
|
+
throw new Error (`Table ${tableName} does not exist!`);
|
|
49
|
+
|
|
50
|
+
for (let iIdx = 0; iIdx < fields.length; iIdx++)
|
|
51
|
+
{
|
|
52
|
+
let field: MySQLSchemaField = fields[iIdx];
|
|
53
|
+
this.tables[tableName].fields.push (field);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Generate a table's structure. If type is set to modify, you must pass a db with an
|
|
59
|
+
* active connection.
|
|
60
|
+
*/
|
|
61
|
+
async generateTableStructure (tableName: string,
|
|
62
|
+
type: HotDBGenerationType = HotDBGenerationType.Create, db: HotDBMySQL = null): Promise<string[]>
|
|
63
|
+
{
|
|
64
|
+
if (this.tables[tableName] == null)
|
|
65
|
+
throw new Error (`Unable to generate table structure for ${tableName}. Table doesn't exist.`);
|
|
66
|
+
|
|
67
|
+
let table: MySQLSchemaTable = this.tables[tableName];
|
|
68
|
+
let generatedStructure: string[] = await table.generate (type, db);
|
|
69
|
+
|
|
70
|
+
return (generatedStructure);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Generate the entire db structure. If type is set to modify, you must pass a db with an
|
|
75
|
+
* active connection.
|
|
76
|
+
*/
|
|
77
|
+
async generateStructure (type: HotDBGenerationType = HotDBGenerationType.Create, db: HotDBMySQL = null): Promise<string[][]>
|
|
78
|
+
{
|
|
79
|
+
let result: string[][] = [];
|
|
80
|
+
|
|
81
|
+
for (let key in this.tables)
|
|
82
|
+
{
|
|
83
|
+
let generatedStructure: string[] = await this.generateTableStructure (key, type, db);
|
|
84
|
+
|
|
85
|
+
result.push (generatedStructure);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return (result);
|
|
89
|
+
}
|
|
90
|
+
}
|