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.
Files changed (318) hide show
  1. package/.dockerignore +123 -0
  2. package/.eslintignore +17 -0
  3. package/.eslintrc.js +11 -0
  4. package/.vscode/launch.json +201 -0
  5. package/.vscode/settings.json +2 -0
  6. package/.vscode/tasks.json +88 -0
  7. package/CONTRIBUTING.md +157 -0
  8. package/LICENSE +21 -0
  9. package/README.md +128 -0
  10. package/bin/hotstaq +3 -0
  11. package/bin/hotstaq.cmd +1 -0
  12. package/build/src/Hot.d.ts +167 -0
  13. package/build/src/Hot.d.ts.map +1 -0
  14. package/build/src/Hot.js +365 -0
  15. package/build/src/Hot.js.map +1 -0
  16. package/build/src/HotAPI.d.ts +137 -0
  17. package/build/src/HotAPI.d.ts.map +1 -0
  18. package/build/src/HotAPI.js +353 -0
  19. package/build/src/HotAPI.js.map +1 -0
  20. package/build/src/HotAgentAPI.d.ts +22 -0
  21. package/build/src/HotAgentAPI.d.ts.map +1 -0
  22. package/build/src/HotAgentAPI.js +85 -0
  23. package/build/src/HotAgentAPI.js.map +1 -0
  24. package/build/src/HotAgentRoute.d.ts +17 -0
  25. package/build/src/HotAgentRoute.d.ts.map +1 -0
  26. package/build/src/HotAgentRoute.js +109 -0
  27. package/build/src/HotAgentRoute.js.map +1 -0
  28. package/build/src/HotBuilder.d.ts +52 -0
  29. package/build/src/HotBuilder.d.ts.map +1 -0
  30. package/build/src/HotBuilder.js +242 -0
  31. package/build/src/HotBuilder.js.map +1 -0
  32. package/build/src/HotClient.d.ts +31 -0
  33. package/build/src/HotClient.d.ts.map +1 -0
  34. package/build/src/HotClient.js +19 -0
  35. package/build/src/HotClient.js.map +1 -0
  36. package/build/src/HotComponent.d.ts +118 -0
  37. package/build/src/HotComponent.d.ts.map +1 -0
  38. package/build/src/HotComponent.js +89 -0
  39. package/build/src/HotComponent.js.map +1 -0
  40. package/build/src/HotCreator.d.ts +88 -0
  41. package/build/src/HotCreator.d.ts.map +1 -0
  42. package/build/src/HotCreator.js +445 -0
  43. package/build/src/HotCreator.js.map +1 -0
  44. package/build/src/HotDB.d.ts +69 -0
  45. package/build/src/HotDB.d.ts.map +1 -0
  46. package/build/src/HotDB.js +29 -0
  47. package/build/src/HotDB.js.map +1 -0
  48. package/build/src/HotDBConnectionInterface.d.ts +40 -0
  49. package/build/src/HotDBConnectionInterface.d.ts.map +1 -0
  50. package/build/src/HotDBConnectionInterface.js +3 -0
  51. package/build/src/HotDBConnectionInterface.js.map +1 -0
  52. package/build/src/HotFile.d.ts +134 -0
  53. package/build/src/HotFile.d.ts.map +1 -0
  54. package/build/src/HotFile.js +454 -0
  55. package/build/src/HotFile.js.map +1 -0
  56. package/build/src/HotGenerator.d.ts +80 -0
  57. package/build/src/HotGenerator.d.ts.map +1 -0
  58. package/build/src/HotGenerator.js +342 -0
  59. package/build/src/HotGenerator.js.map +1 -0
  60. package/build/src/HotHTTPServer.d.ts +162 -0
  61. package/build/src/HotHTTPServer.d.ts.map +1 -0
  62. package/build/src/HotHTTPServer.js +863 -0
  63. package/build/src/HotHTTPServer.js.map +1 -0
  64. package/build/src/HotIO.d.ts +47 -0
  65. package/build/src/HotIO.d.ts.map +1 -0
  66. package/build/src/HotIO.js +232 -0
  67. package/build/src/HotIO.js.map +1 -0
  68. package/build/src/HotLog.d.ts +60 -0
  69. package/build/src/HotLog.d.ts.map +1 -0
  70. package/build/src/HotLog.js +126 -0
  71. package/build/src/HotLog.js.map +1 -0
  72. package/build/src/HotPage.d.ts +125 -0
  73. package/build/src/HotPage.d.ts.map +1 -0
  74. package/build/src/HotPage.js +178 -0
  75. package/build/src/HotPage.js.map +1 -0
  76. package/build/src/HotRoute.d.ts +82 -0
  77. package/build/src/HotRoute.d.ts.map +1 -0
  78. package/build/src/HotRoute.js +83 -0
  79. package/build/src/HotRoute.js.map +1 -0
  80. package/build/src/HotRouteMethod.d.ts +129 -0
  81. package/build/src/HotRouteMethod.d.ts.map +1 -0
  82. package/build/src/HotRouteMethod.js +84 -0
  83. package/build/src/HotRouteMethod.js.map +1 -0
  84. package/build/src/HotServer.d.ts +152 -0
  85. package/build/src/HotServer.d.ts.map +1 -0
  86. package/build/src/HotServer.js +109 -0
  87. package/build/src/HotServer.js.map +1 -0
  88. package/build/src/HotSetAsWeb.d.ts +2 -0
  89. package/build/src/HotSetAsWeb.d.ts.map +1 -0
  90. package/build/src/HotSetAsWeb.js +5 -0
  91. package/build/src/HotSetAsWeb.js.map +1 -0
  92. package/build/src/HotStaq.d.ts +603 -0
  93. package/build/src/HotStaq.d.ts.map +1 -0
  94. package/build/src/HotStaq.js +1260 -0
  95. package/build/src/HotStaq.js.map +1 -0
  96. package/build/src/HotStaqWeb.d.ts +18 -0
  97. package/build/src/HotStaqWeb.d.ts.map +1 -0
  98. package/build/src/HotStaqWeb.js +44 -0
  99. package/build/src/HotStaqWeb.js.map +1 -0
  100. package/build/src/HotTestDriver.d.ts +63 -0
  101. package/build/src/HotTestDriver.d.ts.map +1 -0
  102. package/build/src/HotTestDriver.js +187 -0
  103. package/build/src/HotTestDriver.js.map +1 -0
  104. package/build/src/HotTestElement.d.ts +71 -0
  105. package/build/src/HotTestElement.d.ts.map +1 -0
  106. package/build/src/HotTestElement.js +37 -0
  107. package/build/src/HotTestElement.js.map +1 -0
  108. package/build/src/HotTestMap.d.ts +83 -0
  109. package/build/src/HotTestMap.d.ts.map +1 -0
  110. package/build/src/HotTestMap.js +58 -0
  111. package/build/src/HotTestMap.js.map +1 -0
  112. package/build/src/HotTestSeleniumDriver.d.ts +86 -0
  113. package/build/src/HotTestSeleniumDriver.d.ts.map +1 -0
  114. package/build/src/HotTestSeleniumDriver.js +400 -0
  115. package/build/src/HotTestSeleniumDriver.js.map +1 -0
  116. package/build/src/HotTester.d.ts +188 -0
  117. package/build/src/HotTester.d.ts.map +1 -0
  118. package/build/src/HotTester.js +622 -0
  119. package/build/src/HotTester.js.map +1 -0
  120. package/build/src/HotTesterAPI.d.ts +15 -0
  121. package/build/src/HotTesterAPI.d.ts.map +1 -0
  122. package/build/src/HotTesterAPI.js +161 -0
  123. package/build/src/HotTesterAPI.js.map +1 -0
  124. package/build/src/HotTesterMocha.d.ts +50 -0
  125. package/build/src/HotTesterMocha.d.ts.map +1 -0
  126. package/build/src/HotTesterMocha.js +205 -0
  127. package/build/src/HotTesterMocha.js.map +1 -0
  128. package/build/src/HotTesterMochaSelenium.d.ts +70 -0
  129. package/build/src/HotTesterMochaSelenium.d.ts.map +1 -0
  130. package/build/src/HotTesterMochaSelenium.js +257 -0
  131. package/build/src/HotTesterMochaSelenium.js.map +1 -0
  132. package/build/src/HotTesterServer.d.ts +114 -0
  133. package/build/src/HotTesterServer.d.ts.map +1 -0
  134. package/build/src/HotTesterServer.js +575 -0
  135. package/build/src/HotTesterServer.js.map +1 -0
  136. package/build/src/api copy.d.ts +2 -0
  137. package/build/src/api copy.d.ts.map +1 -0
  138. package/build/src/api copy.js +153 -0
  139. package/build/src/api copy.js.map +1 -0
  140. package/build/src/api-web.d.ts +2 -0
  141. package/build/src/api-web.d.ts.map +1 -0
  142. package/build/src/api-web.js +45 -0
  143. package/build/src/api-web.js.map +1 -0
  144. package/build/src/api.d.ts +33 -0
  145. package/build/src/api.d.ts.map +1 -0
  146. package/build/src/api.js +78 -0
  147. package/build/src/api.js.map +1 -0
  148. package/build/src/cli.d.ts +2 -0
  149. package/build/src/cli.d.ts.map +1 -0
  150. package/build/src/cli.js +1040 -0
  151. package/build/src/cli.js.map +1 -0
  152. package/build/src/schemas/HotDBInflux.d.ts +63 -0
  153. package/build/src/schemas/HotDBInflux.d.ts.map +1 -0
  154. package/build/src/schemas/HotDBInflux.js +239 -0
  155. package/build/src/schemas/HotDBInflux.js.map +1 -0
  156. package/build/src/schemas/HotDBMigration.d.ts +19 -0
  157. package/build/src/schemas/HotDBMigration.d.ts.map +1 -0
  158. package/build/src/schemas/HotDBMigration.js +15 -0
  159. package/build/src/schemas/HotDBMigration.js.map +1 -0
  160. package/build/src/schemas/HotDBMySQL.d.ts +65 -0
  161. package/build/src/schemas/HotDBMySQL.d.ts.map +1 -0
  162. package/build/src/schemas/HotDBMySQL.js +387 -0
  163. package/build/src/schemas/HotDBMySQL.js.map +1 -0
  164. package/build/src/schemas/HotDBSchema.d.ts +15 -0
  165. package/build/src/schemas/HotDBSchema.d.ts.map +1 -0
  166. package/build/src/schemas/HotDBSchema.js +19 -0
  167. package/build/src/schemas/HotDBSchema.js.map +1 -0
  168. package/build/src/schemas/influx/InfluxSchema.d.ts +14 -0
  169. package/build/src/schemas/influx/InfluxSchema.d.ts.map +1 -0
  170. package/build/src/schemas/influx/InfluxSchema.js +33 -0
  171. package/build/src/schemas/influx/InfluxSchema.js.map +1 -0
  172. package/build/src/schemas/mysql/MySQLSchema.d.ts +39 -0
  173. package/build/src/schemas/mysql/MySQLSchema.d.ts.map +1 -0
  174. package/build/src/schemas/mysql/MySQLSchema.js +151 -0
  175. package/build/src/schemas/mysql/MySQLSchema.js.map +1 -0
  176. package/build/src/schemas/mysql/MySQLSchemaField.d.ts +168 -0
  177. package/build/src/schemas/mysql/MySQLSchemaField.d.ts.map +1 -0
  178. package/build/src/schemas/mysql/MySQLSchemaField.js +260 -0
  179. package/build/src/schemas/mysql/MySQLSchemaField.js.map +1 -0
  180. package/build/src/schemas/mysql/MySQLSchemaTable.d.ts +49 -0
  181. package/build/src/schemas/mysql/MySQLSchemaTable.d.ts.map +1 -0
  182. package/build/src/schemas/mysql/MySQLSchemaTable.js +310 -0
  183. package/build/src/schemas/mysql/MySQLSchemaTable.js.map +1 -0
  184. package/build-web/HotStaq.js +2 -0
  185. package/build-web/HotStaq.min.js +119 -0
  186. package/build-web/HotStaqTests_HelloWorldAPI.js +133 -0
  187. package/builder/docker/Dockerfile.linux.gen +42 -0
  188. package/builder/docker/README.md +36 -0
  189. package/builder/docker/app/start.sh +8 -0
  190. package/builder/docker/dockerignore +3 -0
  191. package/builder/docker/scripts/build.bat +11 -0
  192. package/builder/docker/scripts/build.sh +11 -0
  193. package/builder/docker/scripts/start-app.bat +7 -0
  194. package/builder/docker/scripts/start-app.sh +7 -0
  195. package/builder/docker/scripts/stop-app.bat +5 -0
  196. package/builder/docker/scripts/stop-app.sh +5 -0
  197. package/builder/docker-compose/docker-compose.gen.yaml +41 -0
  198. package/builder/docker-compose/env-skeleton +4 -0
  199. package/creator/project/.vscode/launch.json +59 -0
  200. package/creator/project/README.md +20 -0
  201. package/creator/project/gitignore +118 -0
  202. package/creator/project/npmignore +118 -0
  203. package/creator/public/api-test.hott +28 -0
  204. package/creator/public/index.hott +12 -0
  205. package/creator/ts/src/AppAPI.ts +30 -0
  206. package/creator/ts/src/HelloWorld.ts +39 -0
  207. package/creator/ts/src/WebExport.ts +7 -0
  208. package/creator/ts/tsconfig-web.json +73 -0
  209. package/creator/ts/tsconfig.json +73 -0
  210. package/creator/ts/webpack-api.config.js +57 -0
  211. package/dbstart.sh +19 -0
  212. package/dbstop.sh +4 -0
  213. package/docs/.nojekyll +1 -0
  214. package/docs/README.md +130 -0
  215. package/docs/classes/Hot.md +477 -0
  216. package/docs/classes/HotAPI.md +369 -0
  217. package/docs/classes/HotClient.md +95 -0
  218. package/docs/classes/HotComponent.md +279 -0
  219. package/docs/classes/HotDB.md +247 -0
  220. package/docs/classes/HotDBInflux.md +404 -0
  221. package/docs/classes/HotDBMigration.md +80 -0
  222. package/docs/classes/HotDBMySQL.md +310 -0
  223. package/docs/classes/HotDBSchema.md +51 -0
  224. package/docs/classes/HotFile.md +353 -0
  225. package/docs/classes/HotHTTPServer.md +700 -0
  226. package/docs/classes/HotLog.md +162 -0
  227. package/docs/classes/HotPage.md +357 -0
  228. package/docs/classes/HotRoute.md +312 -0
  229. package/docs/classes/HotRouteMethod.md +271 -0
  230. package/docs/classes/HotServer.md +311 -0
  231. package/docs/classes/HotStaq.md +1155 -0
  232. package/docs/classes/HotTestDestination.md +58 -0
  233. package/docs/classes/HotTestDriver.md +332 -0
  234. package/docs/classes/HotTestElement.md +88 -0
  235. package/docs/classes/HotTestElementOptions.md +71 -0
  236. package/docs/classes/HotTestMap.md +92 -0
  237. package/docs/classes/HotTestSeleniumDriver.md +542 -0
  238. package/docs/classes/HotTester.md +653 -0
  239. package/docs/classes/HotTesterAPI.md +493 -0
  240. package/docs/classes/HotTesterMocha.md +843 -0
  241. package/docs/classes/HotTesterMochaSelenium.md +896 -0
  242. package/docs/classes/HotTesterServer.md +633 -0
  243. package/docs/classes/InfluxSchema.md +74 -0
  244. package/docs/classes/MySQLSchema.md +199 -0
  245. package/docs/classes/MySQLSchemaField.md +330 -0
  246. package/docs/classes/MySQLSchemaTable.md +176 -0
  247. package/docs/enums/ConnectionStatus.md +43 -0
  248. package/docs/enums/DeveloperMode.md +38 -0
  249. package/docs/enums/EventExecutionType.md +43 -0
  250. package/docs/enums/HTTPMethod.md +32 -0
  251. package/docs/enums/HotDBGenerationType.md +30 -0
  252. package/docs/enums/HotLogLevel.md +88 -0
  253. package/docs/interfaces/HotDBConnectionInterface.md +116 -0
  254. package/docs/interfaces/HotDestination.md +62 -0
  255. package/docs/interfaces/HotSite.md +187 -0
  256. package/docs/interfaces/HotSiteMapPath.md +37 -0
  257. package/docs/interfaces/HotSiteRoute.md +79 -0
  258. package/docs/interfaces/HotStartOptions.md +115 -0
  259. package/docs/interfaces/HotTestPage.md +44 -0
  260. package/docs/interfaces/HotTestStop.md +62 -0
  261. package/docs/interfaces/IHotComponent.md +135 -0
  262. package/docs/interfaces/IHotStaq.md +118 -0
  263. package/docs/interfaces/IHotTestElement.md +54 -0
  264. package/docs/interfaces/IHotTestElementOptions.md +43 -0
  265. package/docs/interfaces/MySQLResults.md +43 -0
  266. package/docs/interfaces/MySQLSchemaFieldResult.md +75 -0
  267. package/docs/modules.md +182 -0
  268. package/package.json +65 -0
  269. package/selenium-start.sh +7 -0
  270. package/selenium-stop.sh +3 -0
  271. package/src/Hot.ts +319 -0
  272. package/src/HotAPI.ts +386 -0
  273. package/src/HotAgentAPI.ts +43 -0
  274. package/src/HotAgentRoute.ts +44 -0
  275. package/src/HotBuilder.ts +221 -0
  276. package/src/HotClient.ts +40 -0
  277. package/src/HotComponent.ts +158 -0
  278. package/src/HotCreator.ts +470 -0
  279. package/src/HotDB.ts +79 -0
  280. package/src/HotDBConnectionInterface.ts +40 -0
  281. package/src/HotFile.ts +617 -0
  282. package/src/HotGenerator.ts +446 -0
  283. package/src/HotHTTPServer.ts +954 -0
  284. package/src/HotIO.ts +160 -0
  285. package/src/HotLog.ts +158 -0
  286. package/src/HotPage.ts +206 -0
  287. package/src/HotRoute.ts +137 -0
  288. package/src/HotRouteMethod.ts +216 -0
  289. package/src/HotServer.ts +211 -0
  290. package/src/HotSetAsWeb.ts +3 -0
  291. package/src/HotStaq.ts +1881 -0
  292. package/src/HotTestDriver.ts +171 -0
  293. package/src/HotTestElement.ts +97 -0
  294. package/src/HotTestMap.ts +130 -0
  295. package/src/HotTestSeleniumDriver.ts +381 -0
  296. package/src/HotTester.ts +696 -0
  297. package/src/HotTesterAPI.ts +126 -0
  298. package/src/HotTesterMocha.ts +133 -0
  299. package/src/HotTesterMochaSelenium.ts +189 -0
  300. package/src/HotTesterServer.ts +551 -0
  301. package/src/api-web.ts +48 -0
  302. package/src/api.ts +103 -0
  303. package/src/cli.ts +1225 -0
  304. package/src/schemas/HotDBInflux.ts +211 -0
  305. package/src/schemas/HotDBMigration.ts +24 -0
  306. package/src/schemas/HotDBMySQL.ts +312 -0
  307. package/src/schemas/HotDBSchema.ts +21 -0
  308. package/src/schemas/influx/InfluxSchema.ts +19 -0
  309. package/src/schemas/mysql/MySQLSchema.ts +90 -0
  310. package/src/schemas/mysql/MySQLSchemaField.ts +408 -0
  311. package/src/schemas/mysql/MySQLSchemaTable.ts +353 -0
  312. package/temp/HotStaqWeb.ts +59 -0
  313. package/tsconfig-generator.json +17 -0
  314. package/tsconfig-web.json +74 -0
  315. package/tsconfig.json +73 -0
  316. package/webpack.config.generator.js +41 -0
  317. package/webpack.config.js +53 -0
  318. package/webpack.config.tests.js +56 -0
@@ -0,0 +1,353 @@
1
+ import { MySQLSchemaField, MySQLSchemaFieldResult } from "./MySQLSchemaField";
2
+ import { HotDBGenerationType } from "../HotDBSchema";
3
+ import { HotDBMySQL } from "../HotDBMySQL";
4
+
5
+ /**
6
+ * The database table.
7
+ */
8
+ export class MySQLSchemaTable
9
+ {
10
+ /**
11
+ * The name of the table.
12
+ */
13
+ name: string;
14
+ /**
15
+ * The table's description.
16
+ */
17
+ description: string;
18
+ /**
19
+ * The fields in the table.
20
+ */
21
+ fields: MySQLSchemaField[];
22
+ /**
23
+ * The table's engine to use.
24
+ */
25
+ engine: string;
26
+ /**
27
+ * The table's charset to use.
28
+ */
29
+ charset: string;
30
+
31
+ constructor (name: string = "", fields: MySQLSchemaField[] = [])
32
+ {
33
+ this.name = name;
34
+ this.description = "";
35
+ this.fields = fields;
36
+ this.engine = "InnoDB";
37
+ this.charset = "utf8";
38
+ }
39
+
40
+ /**
41
+ * Add a field.
42
+ */
43
+ addField (field: MySQLSchemaField): void
44
+ {
45
+ this.fields.push (field);
46
+ }
47
+
48
+ /**
49
+ * Add a field.
50
+ */
51
+ addFields (fields: MySQLSchemaField[]): void
52
+ {
53
+ for (let iIdx = 0; iIdx < this.fields.length; iIdx++)
54
+ {
55
+ let field: MySQLSchemaField = this.fields[iIdx];
56
+ this.fields.push (field);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Generate the db command. If type is set to modify, you must pass a db with an
62
+ * active connection. Since field parsing isn't completely implemented yet, not all
63
+ * fields will be modified correctly. Use modifiying with caution. This will
64
+ * skip checking for:
65
+ * * Binary columnexistingFields
66
+ * * unique
67
+ * * zero-filled
68
+ * * generated column
69
+ */
70
+ async generate (type: HotDBGenerationType = HotDBGenerationType.Create, db: HotDBMySQL = null): Promise<string[]>
71
+ {
72
+ let output: string[] = [];
73
+
74
+ if (type === HotDBGenerationType.Create)
75
+ {
76
+ let primaryKeys: string[] = [];
77
+ let keys: string[] = [];
78
+
79
+ let result: string = `CREATE TABLE IF NOT EXISTS ${this.name} (\n`;
80
+
81
+ // Generate the fields.
82
+ for (let iIdx = 0; iIdx < this.fields.length; iIdx++)
83
+ {
84
+ let field: MySQLSchemaField = this.fields[iIdx];
85
+ let fieldResult: MySQLSchemaFieldResult = await field.generate ();
86
+
87
+ if (fieldResult.primaryKey !== "")
88
+ primaryKeys.push (fieldResult.primaryKey);
89
+
90
+ if (fieldResult.key !== "")
91
+ keys.push (fieldResult.key);
92
+
93
+ result += `${fieldResult.field},\n`;
94
+ }
95
+
96
+ // Generate the primary keys.
97
+ if (primaryKeys.length > 0)
98
+ {
99
+ result += "PRIMARY KEY (";
100
+
101
+ for (let iIdx = 0; iIdx < primaryKeys.length; iIdx++)
102
+ {
103
+ let primaryKey: string = primaryKeys[iIdx];
104
+
105
+ result += `\`${primaryKey}\`,`;
106
+ }
107
+
108
+ result = result.substr (0, (result.length - 1));
109
+ result += "),\n";
110
+ }
111
+
112
+ // Generate the keys.
113
+ if (keys.length > 0)
114
+ {
115
+ for (let iIdx = 0; iIdx < keys.length; iIdx++)
116
+ {
117
+ let key: string = keys[iIdx];
118
+
119
+ result += `${key},\n`;
120
+ }
121
+ }
122
+
123
+ result = result.substr (0, (result.length - 2));
124
+ result += `) ENGINE=${this.engine} DEFAULT CHARSET=${this.charset};\n\n`;
125
+
126
+ output.push (result);
127
+ }
128
+
129
+ if (type === HotDBGenerationType.Modify)
130
+ {
131
+ if (db == null)
132
+ throw new Error ("Cannot modify a database structure when db is null.");
133
+
134
+ let dbresult = await db.query (`describe ${this.name};`);
135
+ let existingFields: MySQLSchemaField[] = [];
136
+ let existingFieldsNames: string[] = [];
137
+ let thisFieldsNames: string[] = [];
138
+
139
+ if (dbresult.error != null)
140
+ throw new Error (`Error while modifying structure ${this.name}, error: ${dbresult.error}`);
141
+
142
+ // Get this fields names.
143
+ for (let iIdx = 0; iIdx < this.fields.length; iIdx++)
144
+ {
145
+ let thisField: MySQLSchemaField = this.fields[iIdx];
146
+
147
+ thisFieldsNames.push (thisField.name);
148
+ }
149
+
150
+ // Get the fields.
151
+ for (let iIdx = 0; iIdx < dbresult.results.length; iIdx++)
152
+ {
153
+ let jsonField = dbresult.results[iIdx];
154
+ let dbfield: MySQLSchemaField = MySQLSchemaField.parse (jsonField);
155
+
156
+ existingFieldsNames.push (dbfield.name);
157
+ existingFields.push (dbfield);
158
+ }
159
+
160
+ let ignoreFields: string[] = [];
161
+
162
+ // Delete any fields missing from this.fields
163
+ for (let iIdx = 0; iIdx < existingFields.length; iIdx++)
164
+ {
165
+ let existingField: MySQLSchemaField = existingFields[iIdx];
166
+ let pos: number = thisFieldsNames.indexOf (existingField.name);
167
+
168
+ if (pos < 0)
169
+ {
170
+ let tempAlter: string =
171
+ `ALTER TABLE ${this.name} DROP COLUMN \`${existingField.name}\`;`;
172
+ ignoreFields.push (existingField.name);
173
+ let result: string = tempAlter;
174
+
175
+ output.push (result);
176
+ }
177
+ }
178
+
179
+ // Add any fields missing from this.fields
180
+ for (let iIdx = 0; iIdx < this.fields.length; iIdx++)
181
+ {
182
+ let thisField: MySQLSchemaField = this.fields[iIdx];
183
+ let pos: number = existingFieldsNames.indexOf (thisField.name);
184
+
185
+ if (pos < 0)
186
+ {
187
+ let generatedField: MySQLSchemaFieldResult = await thisField.generate ();
188
+ let position: string = "";
189
+
190
+ if (iIdx === 0)
191
+ position = "FIRST";
192
+ else
193
+ {
194
+ /// @fixme I could see this causing issues with an existing field's
195
+ /// name being changed down below. Maybe? Maybe not.
196
+ let prevName: string = existingFieldsNames[(iIdx - 1)];
197
+
198
+ if (prevName == null)
199
+ {
200
+ // Is this correct? Since the previous name doesn't exist. Then
201
+ // the previous name must be the previous this.fields name?
202
+ // Basically the previous newly added field name?
203
+ if (this.fields[(iIdx - 1)] != null)
204
+ prevName = this.fields[(iIdx - 1)].name;
205
+ else
206
+ {
207
+ /// @fixme Gotta fix this someday...
208
+ debugger;
209
+ }
210
+ }
211
+
212
+ position = `AFTER \`${prevName}\``;
213
+ }
214
+
215
+ let tempAlter: string =
216
+ `ALTER TABLE ${this.name} ADD COLUMN ${generatedField.field} ${position};`;
217
+ ignoreFields.push (thisField.name);
218
+ let result: string = tempAlter;
219
+
220
+ output.push (result);
221
+ }
222
+ }
223
+
224
+ // See if any columns have moved.
225
+ for (let iIdx = 0; iIdx < existingFields.length; iIdx++)
226
+ {
227
+ let existingField: MySQLSchemaField = existingFields[iIdx];
228
+ let pos: number = thisFieldsNames.indexOf (existingField.name);
229
+
230
+ // This field has been added/deleted, ignore it.
231
+ if (ignoreFields.indexOf (existingField.name) > -1)
232
+ continue;
233
+
234
+ if (pos > -1)
235
+ {
236
+ if (iIdx !== pos)
237
+ {
238
+ let tempAlter: string =
239
+ `ALTER TABLE ${this.name} CHANGE COLUMN \`${existingField.name}\` \`${existingField.name}\` `;
240
+
241
+ let generatedField: MySQLSchemaFieldResult = await existingField.generate ();
242
+ let position: string = "";
243
+
244
+ if (pos === 0)
245
+ position = "FIRST";
246
+ else
247
+ position = `AFTER \`${existingFields[iIdx].name}\``;
248
+
249
+ tempAlter += `${generatedField.field} ${position};\n`;
250
+ let result: string = tempAlter;
251
+
252
+ output.push (result);
253
+ }
254
+ }
255
+ }
256
+
257
+ let checkKeysInFields: string[] = ["name", "dataType", "primaryKey", "notNull",
258
+ "unsignedDataType", "autoIncrement", "defaultValue"];
259
+
260
+ /**
261
+ * Check for any differences between the two tables.
262
+ * Since MySQLSchemaField.parse is missing some fields, this will
263
+ * skip checking for:
264
+ * * Binary column
265
+ * * unique
266
+ * * zero-filled
267
+ * * generated column
268
+ */
269
+ for (let iIdx = 0; iIdx < existingFields.length; iIdx++)
270
+ {
271
+ let existingField: MySQLSchemaField = existingFields[iIdx];
272
+ let existingFieldName: string = existingField.name.toLowerCase ();
273
+ let existingFieldDataType: string = existingField.dataType.toLowerCase ();
274
+
275
+ // This field has been added/deleted, ignore it.
276
+ if (ignoreFields.indexOf (existingField.name) > -1)
277
+ continue;
278
+
279
+ if (this.fields[iIdx] != null)
280
+ {
281
+ let newField: MySQLSchemaField = this.fields[iIdx];
282
+ let newFieldName: string = newField.name.toLowerCase ();
283
+ let newFieldDataType: string = newField.dataType.toLowerCase ();
284
+
285
+ // Check to see if both are exactly the same. If they are, skip.
286
+ if (MySQLSchemaField.compare (existingField, newField, checkKeysInFields) === true)
287
+ continue;
288
+
289
+ let tempAlter: string = `ALTER TABLE ${this.name} CHANGE COLUMN \`${existingField.name}\` `;
290
+
291
+ if (newFieldName !== existingFieldName)
292
+ tempAlter += `\`${newField.name}\` `;
293
+ else
294
+ tempAlter += `\`${existingField.name}\` `;
295
+
296
+ if (newField.autoIncrement === true)
297
+ tempAlter += `AUTO_INCREMENT `;
298
+
299
+ if (newFieldDataType !== existingFieldDataType)
300
+ tempAlter += `\`${newField.dataType}\` `;
301
+ else
302
+ tempAlter += `\`${existingField.dataType}\` `;
303
+
304
+ if (newField.unsignedDataType === true)
305
+ tempAlter += `UNSIGNED `;
306
+
307
+ if (newField.notNull === true)
308
+ tempAlter += `NOT NULL `;
309
+ else
310
+ tempAlter += `NULL `;
311
+
312
+ if (newField.defaultValue !== existingField.defaultValue)
313
+ tempAlter += `DEFAULT ${newField.defaultValue} `;
314
+
315
+ if (newField.primaryKey !== existingField.primaryKey)
316
+ {
317
+ tempAlter += `\n`;
318
+
319
+ if (existingField.primaryKey === true)
320
+ {
321
+ if (newField.primaryKey === true)
322
+ {
323
+ // Do nothing.
324
+ }
325
+ else
326
+ {
327
+ tempAlter += `DROP PRIMARY KEY `;
328
+ }
329
+ }
330
+ else
331
+ {
332
+ if (newField.primaryKey === true)
333
+ {
334
+ tempAlter += `ADD PRIMARY KEY (\`${newField.name}\`)`;
335
+ }
336
+ else
337
+ {
338
+ // Do nothing.
339
+ }
340
+ }
341
+ }
342
+
343
+ tempAlter += ';\n';
344
+ let result: string = tempAlter;
345
+
346
+ output.push (result);
347
+ }
348
+ }
349
+ }
350
+
351
+ return (output);
352
+ }
353
+ }
@@ -0,0 +1,59 @@
1
+ import { HotStaq, IHotStaq, HotStartOptions,
2
+ HotSite, HotSiteRoute, HotSiteMapPath } from "./HotStaq";
3
+ import { Hot, DeveloperMode } from "./Hot";
4
+ import { HotComponent, IHotComponent } from "./HotComponent";
5
+ import { HotFile } from "./HotFile";
6
+ import { HotLog } from "./HotLog";
7
+
8
+ // Server stuff
9
+ import { HotPage } from "./HotPage";
10
+ import { HotRoute } from "./HotRoute";
11
+ import { HotAPI, EventExecutionType } from "./HotAPI";
12
+ import { HotRouteMethod, HTTPMethod, ServerAuthorizationFunction, ServerExecutionFunction } from "./HotRouteMethod";
13
+ import { HotServer } from "./HotServer";
14
+ import { HotClient } from "./HotClient";
15
+
16
+ // Testing stuff
17
+ import { HotTester } from "./HotTester";
18
+ import { HotTesterAPI } from "./HotTesterAPI";
19
+ import { HotTestMap, HotTestDestination, HotTestPath, HotTestPage } from "./HotTestMap";
20
+ import { IHotTestElement, HotTestElement, HotTestElementOptions, IHotTestElementOptions } from "./HotTestElement";
21
+ import { HotTestDriver } from "./HotTestDriver";
22
+
23
+ HotStaq.isWeb = true;
24
+
25
+ export {
26
+ HotStaq,
27
+ HotStartOptions,
28
+ IHotStaq,
29
+ HotSite,
30
+ HotSiteRoute,
31
+ HotSiteMapPath,
32
+ Hot,
33
+ DeveloperMode,
34
+ HotComponent,
35
+ IHotComponent,
36
+ HotAPI,
37
+ EventExecutionType,
38
+ HotFile,
39
+ HotLog,
40
+ HotPage,
41
+ HotRoute,
42
+ HotRouteMethod,
43
+ HTTPMethod,
44
+ ServerAuthorizationFunction,
45
+ ServerExecutionFunction,
46
+ HotServer,
47
+ HotClient,
48
+ HotTester,
49
+ HotTesterAPI,
50
+ HotTestMap,
51
+ HotTestDestination,
52
+ HotTestPath,
53
+ HotTestPage,
54
+ HotTestElement,
55
+ IHotTestElement,
56
+ HotTestElementOptions,
57
+ IHotTestElementOptions,
58
+ HotTestDriver
59
+ };
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2015",
4
+ "module": "none",
5
+ "lib": ["DOM","ES2015"],
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "./build-web/",
10
+ "noImplicitAny": true,
11
+ "esModuleInterop": true
12
+ },
13
+ "include": [],
14
+ "exclude": [
15
+ "node_modules"
16
+ ]
17
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Basic Options */
4
+ // "incremental": true, /* Enable incremental compilation */
5
+ "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
6
+ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
7
+ "lib": [
8
+ "ES6",
9
+ "DOM"
10
+ ], /* Specify library files to be included in the compilation. */
11
+ // "allowJs": true, /* Allow javascript files to be compiled. */
12
+ // "checkJs": true, /* Report errors in .js files. */
13
+ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
14
+ "declaration": true, /* Generates corresponding '.d.ts' file. */
15
+ "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
16
+ "sourceMap": true, /* Generates corresponding '.map' file. */
17
+ // "outFile": "./", /* Concatenate and emit output to single file. */
18
+ "outDir": "./build/", /* Redirect output structure to the directory. */
19
+ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
20
+ // "composite": true, /* Enable project compilation */
21
+ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
22
+ // "removeComments": true, /* Do not emit comments to output. */
23
+ // "noEmit": true, /* Do not emit outputs. */
24
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
25
+ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
26
+ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
27
+
28
+ /* Strict Type-Checking Options */
29
+ //"strict": true, /* Enable all strict type-checking options. */
30
+ "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
31
+ // "strictNullChecks": true, /* Enable strict null checks. */
32
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
33
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
34
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
35
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
36
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
37
+
38
+ /* Additional Checks */
39
+ // "noUnusedLocals": true, /* Report errors on unused locals. */
40
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
41
+ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
42
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
43
+
44
+ /* Module Resolution Options */
45
+ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
46
+ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
47
+ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
48
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
49
+ // "typeRoots": [], /* List of folders to include type definitions from. */
50
+ // "types": [], /* Type declaration files to be included in compilation. */
51
+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
52
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
53
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
54
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
55
+
56
+ /* Source Map Options */
57
+ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
58
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
59
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
60
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
61
+
62
+ /* Experimental Options */
63
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
64
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
65
+ },
66
+ "include": [
67
+ "./src/",
68
+ "./src/HotSetAsWeb.ts",
69
+ "./tests/"
70
+ ],
71
+ "exclude": [
72
+ "./node_modules/"
73
+ ]
74
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Basic Options */
4
+ // "incremental": true, /* Enable incremental compilation */
5
+ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
6
+ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
7
+ "lib": [
8
+ "ES6",
9
+ "DOM"
10
+ ], /* Specify library files to be included in the compilation. */
11
+ // "allowJs": true, /* Allow javascript files to be compiled. */
12
+ // "checkJs": true, /* Report errors in .js files. */
13
+ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
14
+ "declaration": true, /* Generates corresponding '.d.ts' file. */
15
+ "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
16
+ "sourceMap": true, /* Generates corresponding '.map' file. */
17
+ // "outFile": "./", /* Concatenate and emit output to single file. */
18
+ "outDir": "./build/", /* Redirect output structure to the directory. */
19
+ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
20
+ // "composite": true, /* Enable project compilation */
21
+ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
22
+ // "removeComments": true, /* Do not emit comments to output. */
23
+ // "noEmit": true, /* Do not emit outputs. */
24
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
25
+ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
26
+ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
27
+
28
+ /* Strict Type-Checking Options */
29
+ //"strict": true, /* Enable all strict type-checking options. */
30
+ "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
31
+ // "strictNullChecks": true, /* Enable strict null checks. */
32
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
33
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
34
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
35
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
36
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
37
+
38
+ /* Additional Checks */
39
+ // "noUnusedLocals": true, /* Report errors on unused locals. */
40
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
41
+ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
42
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
43
+
44
+ /* Module Resolution Options */
45
+ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
46
+ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
47
+ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
48
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
49
+ // "typeRoots": [], /* List of folders to include type definitions from. */
50
+ // "types": [], /* Type declaration files to be included in compilation. */
51
+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
52
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
53
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
54
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
55
+
56
+ /* Source Map Options */
57
+ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
58
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
59
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
60
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
61
+
62
+ /* Experimental Options */
63
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
64
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
65
+ },
66
+ "include": [
67
+ "./src/",
68
+ "./tests/"
69
+ ],
70
+ "exclude": [
71
+ "./node_modules/"
72
+ ]
73
+ }
@@ -0,0 +1,41 @@
1
+ const webpack = require ("webpack");
2
+
3
+ const fs = require ("fs");
4
+ const ppath = require ("path");
5
+
6
+ let packageVersion = "${WEBPACK_VERSION}";
7
+
8
+ module.exports = {
9
+ entry: "${WEBPACK_ENTRY}",
10
+ devtool: "inline-source-map",
11
+ target: "web",
12
+ module: {
13
+ rules: [{
14
+ test: new RegExp ("\.tsx?$"),
15
+ use: [{
16
+ loader: "ts-loader",
17
+ options: {
18
+ transpileOnly: true,
19
+ configFile: "${WEBPACK_TSCONFIG}"
20
+ }
21
+ }],
22
+ exclude: new RegExp ("node_modules")
23
+ }]
24
+ },
25
+ plugins: [
26
+ new webpack.DefinePlugin ({
27
+ __VERSION__: `\"${packageVersion}\"`
28
+ })
29
+ ],
30
+ resolve: {
31
+ extensions: [".tsx", ".ts", ".js"]
32
+ },
33
+ node: {
34
+ },
35
+ output: {
36
+ filename: "${WEBPACK_OUTPUT_FILE}",
37
+ path: "${WEBPACK_OUTPUT_PATH}",
38
+ library: "${WEBPACK_LIBRARY_NAME}",
39
+ libraryTarget: "umd"
40
+ }
41
+ };
@@ -0,0 +1,53 @@
1
+ const webpack = require ("webpack");
2
+
3
+ const fs = require ("fs");
4
+ const ppath = require ("path");
5
+
6
+ const packageStr = fs.readFileSync (process.cwd () + "/package.json").toString ();
7
+ const packageJSON = JSON.parse (packageStr);
8
+ let packageVersion = packageJSON.version.toString ();
9
+
10
+ module.exports = {
11
+ entry: "./src/api-web.ts",
12
+ devtool: "inline-source-map",
13
+ target: "web",
14
+ module: {
15
+ rules: [{
16
+ test: new RegExp ("\.tsx?$"),
17
+ use: [{
18
+ loader: "ts-loader",
19
+ options: {
20
+ transpileOnly: true,
21
+ configFile: "tsconfig-web.json"
22
+ }
23
+ }],
24
+ exclude: new RegExp ("node_modules")
25
+ }]
26
+ },
27
+ plugins: [
28
+ new webpack.DefinePlugin ({
29
+ __VERSION__: `\"${packageVersion}\"`
30
+ }),
31
+ new webpack.ProvidePlugin ({
32
+ Cookies: "js-cookie/src/js.cookie.js"
33
+ }),
34
+ new webpack.IgnorePlugin ({
35
+ resourceRegExp: /HotHTTPServer|HotTesterMochaSelenium|HotTestSeleniumDriver|HotTesterMocha|express|mysql/
36
+ })
37
+ ],
38
+ resolve: {
39
+ extensions: [".tsx", ".ts", ".js"]
40
+ },
41
+ node: {
42
+ fs: "empty",
43
+ path: "empty",
44
+ net: "empty",
45
+ tls: "empty"
46
+ },
47
+ output: {
48
+ filename: "HotStaq.js",
49
+ path: ppath.resolve (process.cwd (), "build-web"),
50
+ library: "HotStaqWeb",
51
+ libraryTarget: "var"
52
+ }
53
+ };