hotstaq 0.5.24
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/.eslintignore +17 -0
- package/.eslintrc.js +11 -0
- package/.vscode/launch.json +199 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +78 -0
- package/CONTRIBUTING.md +157 -0
- package/README.md +126 -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 +130 -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 +239 -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 +92 -0
- package/build/src/HotCreator.d.ts.map +1 -0
- package/build/src/HotCreator.js +465 -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/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 +39 -0
- package/build/src/HotIO.d.ts.map +1 -0
- package/build/src/HotIO.js +195 -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 +601 -0
- package/build/src/HotStaq.d.ts.map +1 -0
- package/build/src/HotStaq.js +1258 -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 +82 -0
- package/build/src/HotTestSeleniumDriver.d.ts.map +1 -0
- package/build/src/HotTestSeleniumDriver.js +398 -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 +623 -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.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 +935 -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 +125 -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 +128 -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 +1153 -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 +529 -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 +162 -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 +378 -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 +482 -0
- package/src/HotDB.ts +79 -0
- package/src/HotDBConnectionInterface.ts +40 -0
- package/src/HotFile.ts +617 -0
- package/src/HotHTTPServer.ts +954 -0
- package/src/HotIO.ts +128 -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 +1877 -0
- package/src/HotStaqWeb.ts +59 -0
- package/src/HotTestDriver.ts +172 -0
- package/src/HotTestElement.ts +97 -0
- package/src/HotTestMap.ts +130 -0
- package/src/HotTestSeleniumDriver.ts +374 -0
- package/src/HotTester.ts +697 -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.ts +102 -0
- package/src/cli.ts +1147 -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/tsconfig-web.json +74 -0
- package/tsconfig.json +73 -0
- package/webpack.config.js +51 -0
- package/webpack.config.tests.js +56 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { HotStaq } from "../../HotStaq";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The resulting data from a generated field.
|
|
5
|
+
*/
|
|
6
|
+
export interface MySQLSchemaFieldResult
|
|
7
|
+
{
|
|
8
|
+
/**
|
|
9
|
+
* The field to be entered.
|
|
10
|
+
*/
|
|
11
|
+
field?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The primary key to be added.
|
|
14
|
+
*/
|
|
15
|
+
primaryKey?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The key to be added.
|
|
18
|
+
*/
|
|
19
|
+
key?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The constraint to be added.
|
|
22
|
+
*/
|
|
23
|
+
constraint?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The foreign key to be added.
|
|
26
|
+
*/
|
|
27
|
+
foreignKey?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The database field.
|
|
32
|
+
*/
|
|
33
|
+
export interface IMySQLSchemaField
|
|
34
|
+
{
|
|
35
|
+
/**
|
|
36
|
+
* The name of the field.
|
|
37
|
+
*/
|
|
38
|
+
name: string;
|
|
39
|
+
/**
|
|
40
|
+
* The data type, be sure to include the length of the
|
|
41
|
+
* data type here as well.
|
|
42
|
+
*/
|
|
43
|
+
dataType: string;
|
|
44
|
+
/**
|
|
45
|
+
* Set as a primary key.
|
|
46
|
+
*/
|
|
47
|
+
primaryKey?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Set as a not null.
|
|
50
|
+
*/
|
|
51
|
+
notNull?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Set as a unique index.
|
|
54
|
+
*/
|
|
55
|
+
uniqueIndex?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Set as a binary column.
|
|
58
|
+
*/
|
|
59
|
+
binaryColumn?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Set as an unsigned data type.
|
|
62
|
+
*/
|
|
63
|
+
unsignedDataType?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* If this column is a number, fill with zeroes.
|
|
66
|
+
*/
|
|
67
|
+
fillZeroes?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Set as an auto incrementing column.
|
|
70
|
+
*/
|
|
71
|
+
autoIncrement?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Set as a generated column.
|
|
74
|
+
*/
|
|
75
|
+
generatedColumn?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Set the default value. If this is set to null, a
|
|
78
|
+
* MySQL NULL value will be used.
|
|
79
|
+
*/
|
|
80
|
+
defaultValue?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Set the string to be used when setting the default
|
|
83
|
+
* value. The default is: '
|
|
84
|
+
*/
|
|
85
|
+
strAroundDefaultValue?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The database field.
|
|
90
|
+
*/
|
|
91
|
+
export class MySQLSchemaField implements IMySQLSchemaField
|
|
92
|
+
{
|
|
93
|
+
/**
|
|
94
|
+
* The name of the field.
|
|
95
|
+
*/
|
|
96
|
+
name: string;
|
|
97
|
+
/**
|
|
98
|
+
* The data type, be sure to include the length of the
|
|
99
|
+
* data type here as well.
|
|
100
|
+
*/
|
|
101
|
+
dataType: string;
|
|
102
|
+
/**
|
|
103
|
+
* Set as a primary key.
|
|
104
|
+
*/
|
|
105
|
+
primaryKey: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Set as a not null.
|
|
108
|
+
*/
|
|
109
|
+
notNull: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Set as a unique index.
|
|
112
|
+
*/
|
|
113
|
+
uniqueIndex: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Set as a binary column.
|
|
116
|
+
*/
|
|
117
|
+
binaryColumn: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Set as an unsigned data type.
|
|
120
|
+
*/
|
|
121
|
+
unsignedDataType: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* If this column is a number, fill with zeroes.
|
|
124
|
+
*/
|
|
125
|
+
fillZeroes: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Set as an auto incrementing column.
|
|
128
|
+
*/
|
|
129
|
+
autoIncrement: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Set as a generated column.
|
|
132
|
+
*/
|
|
133
|
+
generatedColumn: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Set the default value. If this is set to null, a
|
|
136
|
+
* MySQL NULL value will be used.
|
|
137
|
+
*/
|
|
138
|
+
defaultValue: string;
|
|
139
|
+
/**
|
|
140
|
+
* Set the string to be used when setting the default
|
|
141
|
+
* value. The default is: '
|
|
142
|
+
*/
|
|
143
|
+
strAroundDefaultValue: string;
|
|
144
|
+
|
|
145
|
+
constructor (name: string | IMySQLSchemaField, dataType: string = "", defaultValue: string = "",
|
|
146
|
+
primaryKey: boolean = false, notNull: boolean = true, uniqueIndex: boolean = false,
|
|
147
|
+
binaryColumn: boolean = false, unsignedDataType: boolean = false,
|
|
148
|
+
fillZeroes: boolean = false, autoIncrement: boolean = false,
|
|
149
|
+
generatedColumn: boolean = false, strAroundDefaultValue: string = "'")
|
|
150
|
+
{
|
|
151
|
+
if (typeof (name) === "string")
|
|
152
|
+
{
|
|
153
|
+
this.name = name;
|
|
154
|
+
this.dataType = dataType;
|
|
155
|
+
this.primaryKey = primaryKey;
|
|
156
|
+
this.notNull = notNull;
|
|
157
|
+
this.uniqueIndex = uniqueIndex;
|
|
158
|
+
this.binaryColumn = binaryColumn;
|
|
159
|
+
this.unsignedDataType = unsignedDataType;
|
|
160
|
+
this.fillZeroes = fillZeroes;
|
|
161
|
+
this.autoIncrement = autoIncrement;
|
|
162
|
+
this.generatedColumn = generatedColumn;
|
|
163
|
+
this.defaultValue = defaultValue;
|
|
164
|
+
this.strAroundDefaultValue = strAroundDefaultValue;
|
|
165
|
+
}
|
|
166
|
+
else
|
|
167
|
+
{
|
|
168
|
+
this.name = name.name;
|
|
169
|
+
this.dataType = name.dataType;
|
|
170
|
+
this.primaryKey = name.primaryKey != null ? name.primaryKey : primaryKey;
|
|
171
|
+
this.notNull = name.notNull != null ? name.notNull : notNull;
|
|
172
|
+
this.uniqueIndex = name.uniqueIndex != null ? name.uniqueIndex : uniqueIndex;
|
|
173
|
+
this.binaryColumn = name.binaryColumn != null ? name.binaryColumn : binaryColumn;
|
|
174
|
+
this.unsignedDataType = name.unsignedDataType != null ? name.unsignedDataType : unsignedDataType;
|
|
175
|
+
this.fillZeroes = name.fillZeroes != null ? name.fillZeroes : fillZeroes;
|
|
176
|
+
this.autoIncrement = name.autoIncrement != null ? name.autoIncrement : autoIncrement;
|
|
177
|
+
this.generatedColumn = name.generatedColumn != null ? name.generatedColumn : generatedColumn;
|
|
178
|
+
this.defaultValue = name.defaultValue === undefined ? defaultValue : name.defaultValue;
|
|
179
|
+
this.strAroundDefaultValue =
|
|
180
|
+
name.strAroundDefaultValue === undefined ? strAroundDefaultValue : name.strAroundDefaultValue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (this.dataType == null)
|
|
184
|
+
throw new Error (`No data type given for field ${this.name}`)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Compare two different fields. This will iterate through all keys in each field. Any
|
|
189
|
+
* string values found will have stringFilter applied to it, removing everything that
|
|
190
|
+
* is in that stringFilter regex. Additionally for any empty strings found it will
|
|
191
|
+
* compare to any undefined/null on the other side, and treat them as the same.
|
|
192
|
+
*
|
|
193
|
+
* @param field1 The first field to compare.
|
|
194
|
+
* @param field2 The second field to compare.
|
|
195
|
+
* @param onlyKeys Only compare using the provided keys. If set to null, this will compare
|
|
196
|
+
* using all of the keys in these objects.
|
|
197
|
+
* @param stringFilter The regex to be used to help make any filters on any detected
|
|
198
|
+
* strings. The default regex provided will remove any whitespaces, single/doube quotes,
|
|
199
|
+
* back ticks, and parenthesis. If this is set to null, it will not be used.
|
|
200
|
+
*/
|
|
201
|
+
static compare (field1: MySQLSchemaField, field2: MySQLSchemaField, onlyKeys: string[] = null,
|
|
202
|
+
stringFilter: RegExp = new RegExp ("(\\s+|\\'+|\\\"+|\\`+|\\(+|\\)+)", "g")): boolean
|
|
203
|
+
{
|
|
204
|
+
if (onlyKeys == null)
|
|
205
|
+
{
|
|
206
|
+
onlyKeys = ["name", "dataType", "primaryKey", "notNull",
|
|
207
|
+
"uniqueIndex", "binaryColumn", "unsignedDataType",
|
|
208
|
+
"fillZeroes", "autoIncrement", "generatedColumn",
|
|
209
|
+
"defaultValue"];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Go through each key in both fields and compare the values.
|
|
213
|
+
for (let iIdx = 0; iIdx < onlyKeys.length; iIdx++)
|
|
214
|
+
{
|
|
215
|
+
let key: string = onlyKeys[iIdx];
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
let field1Value = field1[key];
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
let field2Value = field2[key];
|
|
220
|
+
|
|
221
|
+
if (stringFilter != null)
|
|
222
|
+
{
|
|
223
|
+
// If the key is a string, make them lowercase, remove any
|
|
224
|
+
// spaces and compare.
|
|
225
|
+
if (typeof (field1Value) === "string")
|
|
226
|
+
{
|
|
227
|
+
if ((field1Value != null) && (field2Value != null))
|
|
228
|
+
{
|
|
229
|
+
field1Value = field1Value.toLowerCase ();
|
|
230
|
+
field2Value = field2Value.toLowerCase ();
|
|
231
|
+
field1Value = field1Value.replace (stringFilter, "");
|
|
232
|
+
field2Value = field2Value.replace (stringFilter, "");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Make exceptions here for when field1Value or field2Value is null
|
|
236
|
+
if (field1Value == "")
|
|
237
|
+
{
|
|
238
|
+
if (field2Value == null)
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (field2Value == "")
|
|
243
|
+
{
|
|
244
|
+
if (field1Value == null)
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (field1Value !== field2Value)
|
|
251
|
+
return (false);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return (true);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Parse a JSON object and get a MySQLSchemaField object from it.
|
|
259
|
+
* Warning! This is only partially implemented. This will not check
|
|
260
|
+
* the following fields:
|
|
261
|
+
* * Binary column
|
|
262
|
+
* * unique
|
|
263
|
+
* * zero-filled
|
|
264
|
+
* * generated column
|
|
265
|
+
*/
|
|
266
|
+
static parse (json: any): MySQLSchemaField
|
|
267
|
+
{
|
|
268
|
+
let result: MySQLSchemaField = new MySQLSchemaField ("");
|
|
269
|
+
|
|
270
|
+
if (json["name"] != null)
|
|
271
|
+
result.name = json["name"];
|
|
272
|
+
|
|
273
|
+
if (json["Name"] != null)
|
|
274
|
+
result.name = json["Name"];
|
|
275
|
+
|
|
276
|
+
if (json["field"] != null)
|
|
277
|
+
result.name = json["field"];
|
|
278
|
+
|
|
279
|
+
if (json["Field"] != null)
|
|
280
|
+
result.name = json["Field"];
|
|
281
|
+
|
|
282
|
+
if (json["Type"] != null)
|
|
283
|
+
{
|
|
284
|
+
result.dataType = json["Type"];
|
|
285
|
+
const pos: number = result.dataType.indexOf ("unsigned");
|
|
286
|
+
|
|
287
|
+
if (pos > -1)
|
|
288
|
+
{
|
|
289
|
+
result.dataType = result.dataType.substr (0, (pos - 1));
|
|
290
|
+
result.unsignedDataType = true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (json["Null"] != null)
|
|
295
|
+
result.notNull = !HotStaq.parseBoolean (json["Null"]);
|
|
296
|
+
|
|
297
|
+
if (json["Key"] != null)
|
|
298
|
+
{
|
|
299
|
+
let keyType: string = json["Key"];
|
|
300
|
+
|
|
301
|
+
keyType = keyType.toLowerCase ();
|
|
302
|
+
|
|
303
|
+
if (keyType === "pri")
|
|
304
|
+
result.primaryKey = true;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (json["Extra"] != null)
|
|
308
|
+
{
|
|
309
|
+
let extraValue: string = json["Extra"];
|
|
310
|
+
|
|
311
|
+
extraValue = extraValue.toLowerCase ();
|
|
312
|
+
|
|
313
|
+
if (extraValue === "auto_increment")
|
|
314
|
+
result.autoIncrement = true;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (json["Default"] != null)
|
|
318
|
+
result.defaultValue = json["Default"];
|
|
319
|
+
|
|
320
|
+
return (result);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Generate the db command.
|
|
325
|
+
*/
|
|
326
|
+
async generate (): Promise<MySQLSchemaFieldResult>
|
|
327
|
+
{
|
|
328
|
+
let result: MySQLSchemaFieldResult = {
|
|
329
|
+
"field": "",
|
|
330
|
+
"constraint": "",
|
|
331
|
+
"foreignKey": "",
|
|
332
|
+
"primaryKey": "",
|
|
333
|
+
"key": ""
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
let additionalStr: string = "";
|
|
337
|
+
let defaultValue: string = this.defaultValue;
|
|
338
|
+
const lowerDataType: string = this.dataType.toLowerCase ();
|
|
339
|
+
let strAroundDefaultValue: string = this.strAroundDefaultValue;
|
|
340
|
+
|
|
341
|
+
if ((lowerDataType.indexOf ("int") > 0) ||
|
|
342
|
+
(lowerDataType.indexOf ("float") > 0) ||
|
|
343
|
+
(lowerDataType.indexOf ("decimal") > 0))
|
|
344
|
+
{
|
|
345
|
+
strAroundDefaultValue = "";
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if ((lowerDataType.indexOf ("date") > 0) ||
|
|
349
|
+
(lowerDataType.indexOf ("time") > 0) ||
|
|
350
|
+
(lowerDataType.indexOf ("year") > 0))
|
|
351
|
+
{
|
|
352
|
+
strAroundDefaultValue = "";
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (this.unsignedDataType === true)
|
|
356
|
+
additionalStr += "unsigned ";
|
|
357
|
+
|
|
358
|
+
if (this.notNull === true)
|
|
359
|
+
{
|
|
360
|
+
additionalStr += "NOT NULL ";
|
|
361
|
+
|
|
362
|
+
if (defaultValue === null)
|
|
363
|
+
throw new Error (`Field ${this.name} cannot have a default value of null when notNull is set to true.`);
|
|
364
|
+
|
|
365
|
+
if (defaultValue !== "")
|
|
366
|
+
defaultValue = `${strAroundDefaultValue}${defaultValue}${strAroundDefaultValue}`;
|
|
367
|
+
}
|
|
368
|
+
else
|
|
369
|
+
{
|
|
370
|
+
additionalStr += "NULL ";
|
|
371
|
+
|
|
372
|
+
if (defaultValue === null)
|
|
373
|
+
defaultValue = "NULL";
|
|
374
|
+
else
|
|
375
|
+
defaultValue = `${strAroundDefaultValue}${defaultValue}${strAroundDefaultValue}`;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (this.autoIncrement === true)
|
|
379
|
+
additionalStr += "AUTO_INCREMENT ";
|
|
380
|
+
|
|
381
|
+
if (defaultValue === "")
|
|
382
|
+
{
|
|
383
|
+
if ((lowerDataType.indexOf ("int") > 0) ||
|
|
384
|
+
(lowerDataType.indexOf ("float") > 0) ||
|
|
385
|
+
(lowerDataType.indexOf ("decimal") > 0))
|
|
386
|
+
{
|
|
387
|
+
defaultValue = `0`;
|
|
388
|
+
}
|
|
389
|
+
else
|
|
390
|
+
defaultValue = `${strAroundDefaultValue}${strAroundDefaultValue}`;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
let defaultValueStr: string = "";
|
|
394
|
+
|
|
395
|
+
if (this.autoIncrement === false)
|
|
396
|
+
defaultValueStr = ` DEFAULT ${defaultValue}`;
|
|
397
|
+
|
|
398
|
+
result.field = `\`${this.name}\` ${this.dataType} ${additionalStr}${defaultValueStr}`;
|
|
399
|
+
|
|
400
|
+
if (this.primaryKey === true)
|
|
401
|
+
result.primaryKey = `${this.name}`;
|
|
402
|
+
|
|
403
|
+
if (this.uniqueIndex === true)
|
|
404
|
+
result.key = `UNIQUE KEY \`${this.name}_UNIQUE\` (\`${this.name}\`)`;
|
|
405
|
+
|
|
406
|
+
return (result);
|
|
407
|
+
}
|
|
408
|
+
}
|