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,178 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.HotPage = void 0;
40
+ var Hot_1 = require("./Hot");
41
+ var HotStaq_1 = require("./HotStaq");
42
+ /**
43
+ * A page to preprocess.
44
+ */
45
+ var HotPage = /** @class */ (function () {
46
+ function HotPage(copy) {
47
+ if (copy instanceof HotStaq_1.HotStaq) {
48
+ this.processor = copy;
49
+ this.name = "";
50
+ this.testerName = "";
51
+ this.testerMap = "";
52
+ this.route = "";
53
+ this.files = [];
54
+ this.testElements = {};
55
+ this.testPaths = {};
56
+ }
57
+ else {
58
+ this.processor = copy.processor;
59
+ this.name = copy.name || "";
60
+ this.testerName = copy.testerName || "";
61
+ this.testerMap = copy.testerMap || "";
62
+ this.route = copy.route || "";
63
+ this.files = copy.files || [];
64
+ this.testElements = copy.testElements || {};
65
+ this.testPaths = copy.testPaths || {};
66
+ }
67
+ }
68
+ /**
69
+ * Add a file to process. It's recommend to load the file prior to
70
+ * adding it to a page if it's about to be used.
71
+ */
72
+ HotPage.prototype.addFile = function (file) {
73
+ return __awaiter(this, void 0, void 0, function () {
74
+ return __generator(this, function (_a) {
75
+ file.page = this;
76
+ this.files.push(file);
77
+ return [2 /*return*/];
78
+ });
79
+ });
80
+ };
81
+ /**
82
+ * Get the API associated with this page.
83
+ */
84
+ HotPage.prototype.getAPI = function () {
85
+ return (this.processor.api);
86
+ };
87
+ /**
88
+ * Get the tester API associated with this page.
89
+ */
90
+ HotPage.prototype.getTesterAPI = function () {
91
+ return (this.processor.testerAPI);
92
+ };
93
+ /**
94
+ * Add all files in the page. Could decrease page loading performance.
95
+ * It's recommend to load the file prior to adding it to a page.
96
+ */
97
+ HotPage.prototype.load = function (file) {
98
+ return __awaiter(this, void 0, void 0, function () {
99
+ var iIdx, file_1;
100
+ return __generator(this, function (_a) {
101
+ switch (_a.label) {
102
+ case 0:
103
+ iIdx = 0;
104
+ _a.label = 1;
105
+ case 1:
106
+ if (!(iIdx < this.files.length)) return [3 /*break*/, 4];
107
+ file_1 = this.files[iIdx];
108
+ return [4 /*yield*/, file_1.load()];
109
+ case 2:
110
+ _a.sent();
111
+ _a.label = 3;
112
+ case 3:
113
+ iIdx++;
114
+ return [3 /*break*/, 1];
115
+ case 4: return [2 /*return*/];
116
+ }
117
+ });
118
+ });
119
+ };
120
+ /**
121
+ * Process a page and get the result.
122
+ */
123
+ HotPage.prototype.process = function (args) {
124
+ if (args === void 0) { args = null; }
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ var output, iIdx, file, _a;
127
+ return __generator(this, function (_b) {
128
+ switch (_b.label) {
129
+ case 0:
130
+ output = "";
131
+ iIdx = 0;
132
+ _b.label = 1;
133
+ case 1:
134
+ if (!(iIdx < this.files.length)) return [3 /*break*/, 4];
135
+ file = this.files[iIdx];
136
+ Hot_1.Hot.Output = "";
137
+ file.page = this;
138
+ _a = output;
139
+ return [4 /*yield*/, file.process(args)];
140
+ case 2:
141
+ output = _a + _b.sent();
142
+ _b.label = 3;
143
+ case 3:
144
+ iIdx++;
145
+ return [3 /*break*/, 1];
146
+ case 4: return [2 /*return*/, (output)];
147
+ }
148
+ });
149
+ });
150
+ };
151
+ /**
152
+ * Add a test element.
153
+ */
154
+ HotPage.prototype.addTestElement = function (elm) {
155
+ if (this.testElements[elm.name] != null)
156
+ throw new Error("Test element ".concat(elm.name, " already exists!"));
157
+ this.testElements[elm.name] = elm;
158
+ };
159
+ /**
160
+ * Get a test element.
161
+ */
162
+ HotPage.prototype.getTestElement = function (name) {
163
+ if (this.testElements[name] == null)
164
+ throw new Error("Test element ".concat(name, " doest not exist!"));
165
+ return (this.testElements[name]);
166
+ };
167
+ /**
168
+ * Create a test path.
169
+ */
170
+ HotPage.prototype.createTestPath = function (pathName, driverFunc) {
171
+ if (this.testPaths[pathName] != null)
172
+ throw new Error("Test path ".concat(pathName, " already exists!"));
173
+ this.testPaths[pathName] = driverFunc;
174
+ };
175
+ return HotPage;
176
+ }());
177
+ exports.HotPage = HotPage;
178
+ //# sourceMappingURL=HotPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotPage.js","sourceRoot":"","sources":["../../src/HotPage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4B;AAE5B,qCAAoC;AA6CpC;;GAEG;AACH;IAoCC,iBAAa,IAAwB;QAEpC,IAAI,IAAI,YAAY,iBAAO,EAC3B;YACC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;YACf,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;YACvB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;SACpB;aAED;YACC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;YAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;YACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;YACtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YA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,KAAU,SAAyB,CAAC;;;wBAPQ,IAAI,EAAE,CAAA;;4BAUnD,sBAAO,CAAC,MAAM,CAAC,EAAC;;;;KAChB;IAED;;OAEG;IACH,gCAAc,GAAd,UAAgB,GAAmB;QAElC,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI;YACtC,MAAM,IAAI,KAAK,CAAE,uBAAgB,GAAG,CAAC,IAAI,qBAAkB,CAAC,CAAC;QAE9D,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,gCAAc,GAAd,UAAgB,IAAY;QAE3B,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI;YAClC,MAAM,IAAI,KAAK,CAAE,uBAAgB,IAAI,sBAAmB,CAAC,CAAC;QAE3D,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,gCAAc,GAAd,UAAgB,QAAgB,EAAE,UAAuB;QAExD,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI;YACnC,MAAM,IAAI,KAAK,CAAE,oBAAa,QAAQ,qBAAkB,CAAC,CAAC;QAE3D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;IACvC,CAAC;IACF,cAAC;AAAD,CAAC,AA3JD,IA2JC;AA3JY,0BAAO"}
@@ -0,0 +1,82 @@
1
+ import { HotServer } from "./HotServer";
2
+ import { HotRouteMethod, HTTPMethod, ServerExecutionFunction, TestCaseFunction, TestCaseObject } from "./HotRouteMethod";
3
+ import { HotClient } from "./HotClient";
4
+ import { HotLog } from "./HotLog";
5
+ /**
6
+ * The route to use.
7
+ */
8
+ export declare class HotRoute {
9
+ /**
10
+ * The server that maintains the connections.
11
+ */
12
+ connection: HotServer | HotClient;
13
+ /**
14
+ * The associated logger.
15
+ */
16
+ logger: HotLog;
17
+ /**
18
+ * The route.
19
+ */
20
+ route: string;
21
+ /**
22
+ * The version.
23
+ */
24
+ version: string;
25
+ /**
26
+ * The prefix to add to the beginning of each route method.
27
+ */
28
+ prefix: string;
29
+ /**
30
+ * The authorization credentials to be used by the client
31
+ * when connecting to the server.
32
+ */
33
+ authCredentials: any;
34
+ /**
35
+ * The calls that can be made.
36
+ */
37
+ methods: HotRouteMethod[];
38
+ /**
39
+ * The errors and their JSON that can be thrown. Can be:
40
+ * * not_authorized
41
+ */
42
+ errors: {
43
+ [error: string]: any;
44
+ };
45
+ constructor(connection: HotServer | HotClient, route: string, methods?: HotRouteMethod[]);
46
+ /**
47
+ * Create an error JSON object.
48
+ */
49
+ static createError(message: string): any;
50
+ /**
51
+ * Add an API method to this route.
52
+ *
53
+ * @param method The name of the method to add. If a HotRouteMethod is supplied, the
54
+ * rest of the arguments supplied will be ignored.
55
+ */
56
+ addMethod(method: HotRouteMethod | string, executeFunction?: ServerExecutionFunction, type?: HTTPMethod, testCases?: (string | TestCaseFunction)[] | TestCaseFunction[] | TestCaseObject[]): void;
57
+ /**
58
+ * Get a method by it's name.
59
+ */
60
+ getMethod(name: string): HotRouteMethod;
61
+ /**
62
+ * Executes before all routes have been registered.
63
+ */
64
+ onPreRegister: () => Promise<void>;
65
+ /**
66
+ * Executes when first registering this route with Express. If
67
+ * this returns false, the route will not be registered.
68
+ */
69
+ onRegister: () => Promise<boolean>;
70
+ /**
71
+ * Executes after all routes have been registered.
72
+ */
73
+ onPostRegister: () => Promise<void>;
74
+ /**
75
+ * Executes when authorizing a called method.
76
+ * The value returned from here will be passed to onExecute in the
77
+ * called HotRouteMethod. Undefined returning from here will mean
78
+ * the authorization failed.
79
+ */
80
+ onAuthorizeUser: (req: any, res: any) => Promise<any>;
81
+ }
82
+ //# sourceMappingURL=HotRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotRoute.d.ts","sourceRoot":"","sources":["../../src/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IAC1C;;;OAGG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAQ;IAC1C;;OAEG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAQ;IAE3C;;;;;OAKG;IACH,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAQ;CAC7D"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HotRoute = void 0;
4
+ var HotRouteMethod_1 = require("./HotRouteMethod");
5
+ /**
6
+ * The route to use.
7
+ */
8
+ var HotRoute = /** @class */ (function () {
9
+ function HotRoute(connection, route, methods) {
10
+ if (methods === void 0) { methods = []; }
11
+ /**
12
+ * Executes before all routes have been registered.
13
+ */
14
+ this.onPreRegister = null;
15
+ /**
16
+ * Executes when first registering this route with Express. If
17
+ * this returns false, the route will not be registered.
18
+ */
19
+ this.onRegister = null;
20
+ /**
21
+ * Executes after all routes have been registered.
22
+ */
23
+ this.onPostRegister = null;
24
+ /**
25
+ * Executes when authorizing a called method.
26
+ * The value returned from here will be passed to onExecute in the
27
+ * called HotRouteMethod. Undefined returning from here will mean
28
+ * the authorization failed.
29
+ */
30
+ this.onAuthorizeUser = null;
31
+ this.connection = connection;
32
+ this.logger = null;
33
+ if (this.connection != null) {
34
+ if (this.connection.processor != null)
35
+ this.logger = this.connection.processor.logger;
36
+ }
37
+ this.route = route;
38
+ this.version = "v1";
39
+ this.prefix = "";
40
+ this.authCredentials = null;
41
+ this.methods = methods;
42
+ this.errors = {
43
+ "not_authorized": HotRoute.createError("Not authorized.")
44
+ };
45
+ }
46
+ /**
47
+ * Create an error JSON object.
48
+ */
49
+ HotRoute.createError = function (message) {
50
+ return ({ error: message });
51
+ };
52
+ /**
53
+ * Add an API method to this route.
54
+ *
55
+ * @param method The name of the method to add. If a HotRouteMethod is supplied, the
56
+ * rest of the arguments supplied will be ignored.
57
+ */
58
+ HotRoute.prototype.addMethod = function (method, executeFunction, type, testCases) {
59
+ if (executeFunction === void 0) { executeFunction = null; }
60
+ if (type === void 0) { type = HotRouteMethod_1.HTTPMethod.POST; }
61
+ if (testCases === void 0) { testCases = null; }
62
+ if (typeof (method) === "string")
63
+ method = new HotRouteMethod_1.HotRouteMethod(this, method, executeFunction, type, null, null, null, testCases);
64
+ this.methods.push(method);
65
+ };
66
+ /**
67
+ * Get a method by it's name.
68
+ */
69
+ HotRoute.prototype.getMethod = function (name) {
70
+ var foundMethod = null;
71
+ for (var iIdx = 0; iIdx < this.methods.length; iIdx++) {
72
+ var method = this.methods[iIdx];
73
+ if (method.name === name) {
74
+ foundMethod = method;
75
+ break;
76
+ }
77
+ }
78
+ return (foundMethod);
79
+ };
80
+ return HotRoute;
81
+ }());
82
+ exports.HotRoute = HotRoute;
83
+ //# sourceMappingURL=HotRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotRoute.js","sourceRoot":"","sources":["../../src/HotRoute.ts"],"names":[],"mappings":";;;AACA,mDAAyH;AAIzH;;GAEG;AACH;IAqCC,kBAAa,UAAiC,EAAE,KAAa,EAAE,OAA8B;QAA9B,wBAAA,EAAA,YAA8B;QAsE7F;;WAEG;QACH,kBAAa,GAAwB,IAAI,CAAC;QAC1C;;;WAGG;QACH,eAAU,GAA2B,IAAI,CAAC;QAC1C;;WAEG;QACH,mBAAc,GAAwB,IAAI,CAAC;QAE3C;;;;;WAKG;QACH,oBAAe,GAAyC,IAAI,CAAC;QAxF5D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QAEnB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAC3B;YACC,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,IAAI,IAAI;gBACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC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MAAM,CAAC;gBAErB,MAAM;aACN;SACD;QAED,OAAO,CAAC,WAAW,CAAC,CAAC;IACtB,CAAC;IAuBF,eAAC;AAAD,CAAC,AAhID,IAgIC;AAhIY,4BAAQ"}
@@ -0,0 +1,129 @@
1
+ import { HotTestDriver } from "./HotTestDriver";
2
+ import { HotRoute } from "./HotRoute";
3
+ /**
4
+ * Available HTTP methods.
5
+ */
6
+ export declare enum HTTPMethod {
7
+ GET = "get",
8
+ POST = "post"
9
+ }
10
+ /**
11
+ * A function that will be executed by the server when first registering with Express.
12
+ * If this returns false, this route method will not be registered.
13
+ */
14
+ export declare type ServerRegistrationFunction = () => Promise<boolean>;
15
+ /**
16
+ * A function that will be executed by the server.
17
+ */
18
+ export declare type ServerExecutionFunction = (req: any, res: any, authorizedValue: any, jsonObj: any, queryObj: any) => Promise<any>;
19
+ /**
20
+ * A function that will be executed by the client.
21
+ */
22
+ export declare type ClientExecutionFunction = (...args: any[]) => Promise<any>;
23
+ /**
24
+ * A function that will be executed by the server for authorization. Any value
25
+ * returned from this function will be passed to the ServerExecutionFunction.
26
+ * If an undefined value is returned, this indicates the server was not able
27
+ * to authenticate the user, so the ServerExecutionFunction will not be
28
+ * executed.
29
+ */
30
+ export declare type ServerAuthorizationFunction = (req: any, res: any, jsonObj: any, queryObj: any) => Promise<any>;
31
+ /**
32
+ * The test case function to execute.
33
+ */
34
+ export declare type TestCaseFunction = ((driver: HotTestDriver) => Promise<any>) | ((driver: HotTestDriver) => any);
35
+ /**
36
+ * The test case object to pass.
37
+ */
38
+ export interface TestCaseObject {
39
+ /**
40
+ * The name of the test case.
41
+ */
42
+ name: string;
43
+ /**
44
+ * The function to execute.
45
+ */
46
+ func: TestCaseFunction;
47
+ }
48
+ /**
49
+ * An API method to make.
50
+ */
51
+ export declare class HotRouteMethod {
52
+ /**
53
+ * The parent route.
54
+ */
55
+ parentRoute: HotRoute;
56
+ /**
57
+ * The api call name.
58
+ */
59
+ name: string;
60
+ /**
61
+ * The api call name.
62
+ */
63
+ type: HTTPMethod;
64
+ /**
65
+ * Has this method been registered with the server? This
66
+ * prevents the method from being reregistered.
67
+ */
68
+ isRegistered: boolean;
69
+ /**
70
+ * Has this method been registered with the server? This
71
+ * prevents the method from being reregistered.
72
+ */
73
+ executeSetup: boolean;
74
+ /**
75
+ * The authorization credentials to be used by the client
76
+ * when connecting to the server.
77
+ */
78
+ authCredentials: any;
79
+ /**
80
+ * The test case objects to execute during tests.
81
+ */
82
+ testCases: {
83
+ [name: string]: TestCaseObject;
84
+ };
85
+ constructor(route: HotRoute, name: string, onExecute?: ServerExecutionFunction | ClientExecutionFunction, type?: HTTPMethod, onServerAuthorize?: ServerAuthorizationFunction, onRegister?: ServerRegistrationFunction, authCredentials?: any, testCases?: (string | TestCaseFunction)[] | TestCaseFunction[] | TestCaseObject[]);
86
+ /**
87
+ * Executes before all routes have been registered.
88
+ */
89
+ onPreRegister?: () => Promise<void>;
90
+ /**
91
+ * Executes when first registering this method with Express. If
92
+ * this returns false, the method will not be registered.
93
+ */
94
+ onRegister?: ServerRegistrationFunction;
95
+ /**
96
+ * Executes after all routes have been registered.
97
+ */
98
+ onPostRegister?: () => Promise<void>;
99
+ /**
100
+ * Executes when authorizing a called method. If this method
101
+ * is set, this will not call onAuthorize for the parent HotRoute.
102
+ * The value returned from here will be passed to onExecute.
103
+ * Undefined returning from here will mean the authorization failed.
104
+ * If any exceptions are thrown from this function, they will be sent
105
+ * to the server as an { error: string; } object with the exception
106
+ * message as the error.
107
+ */
108
+ onServerAuthorize?: ServerAuthorizationFunction;
109
+ /**
110
+ * Executes when executing a called method from the server side.
111
+ * This will stringify any JSON object and send it as a JSON response.
112
+ * If undefined is returned no response will be sent to the server.
113
+ * So the developer would have to send a response using "res".
114
+ * If any exceptions are thrown from this function, they will be sent
115
+ * to the server as an { error: string; } object with the exception
116
+ * message as the error.
117
+ */
118
+ onServerExecute?: ServerExecutionFunction;
119
+ /**
120
+ * Executes when executing a called method from the client side.
121
+ * @fixme Is this necessary?
122
+ */
123
+ onClientExecute?: ClientExecutionFunction;
124
+ /**
125
+ * Add a new test case.
126
+ */
127
+ addTestCase(newTestCase: TestCaseObject | string | TestCaseFunction, testCaseFunction?: TestCaseFunction): void;
128
+ }
129
+ //# sourceMappingURL=HotRouteMethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotRouteMethod.d.ts","sourceRoot":"","sources":["../../src/HotRouteMethod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;GAEG;AACH,oBAAY,UAAU;IAErB,GAAG,QAAQ;IACX,IAAI,SAAS;CACb;AAED;;;GAGG;AACH,oBAAY,0BAA0B,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAChE;;GAEG;AACH,oBAAY,uBAAuB,GAClC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AACzF;;GAEG;AACH,oBAAY,uBAAuB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AACvE;;;;;;GAMG;AACH,oBAAY,2BAA2B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5G;;GAEG;AACH,oBAAY,gBAAgB,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,KAAK,GAAG,CAAC,CAAC;AAC5G;;GAEG;AACH,MAAM,WAAW,cAAc;IAE9B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GAAG,IAAI;CAgClD"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HotRouteMethod = exports.HTTPMethod = void 0;
4
+ var Hot_1 = require("./Hot");
5
+ var HotServer_1 = require("./HotServer");
6
+ /**
7
+ * Available HTTP methods.
8
+ */
9
+ var HTTPMethod;
10
+ (function (HTTPMethod) {
11
+ HTTPMethod["GET"] = "get";
12
+ HTTPMethod["POST"] = "post";
13
+ })(HTTPMethod = exports.HTTPMethod || (exports.HTTPMethod = {}));
14
+ /**
15
+ * An API method to make.
16
+ */
17
+ var HotRouteMethod = /** @class */ (function () {
18
+ function HotRouteMethod(route, name, onExecute, type, onServerAuthorize, onRegister, authCredentials, testCases) {
19
+ if (onExecute === void 0) { onExecute = null; }
20
+ if (type === void 0) { type = HTTPMethod.POST; }
21
+ if (onServerAuthorize === void 0) { onServerAuthorize = null; }
22
+ if (onRegister === void 0) { onRegister = null; }
23
+ if (authCredentials === void 0) { authCredentials = null; }
24
+ if (testCases === void 0) { testCases = null; }
25
+ this.parentRoute = route;
26
+ this.name = name;
27
+ this.type = type;
28
+ this.isRegistered = false;
29
+ this.executeSetup = false;
30
+ this.authCredentials = authCredentials;
31
+ this.onServerAuthorize = onServerAuthorize;
32
+ this.onRegister = onRegister;
33
+ this.testCases = {};
34
+ if (this.parentRoute.connection.processor.mode === Hot_1.DeveloperMode.Development) {
35
+ if (testCases != null) {
36
+ for (var iIdx = 0; iIdx < testCases.length; iIdx++) {
37
+ var obj = testCases[iIdx];
38
+ if (typeof (obj) === "string") {
39
+ var name_1 = obj;
40
+ var func = testCases[iIdx + 1];
41
+ this.addTestCase(name_1, func);
42
+ iIdx++;
43
+ }
44
+ else
45
+ this.addTestCase(obj);
46
+ }
47
+ }
48
+ }
49
+ if (this.parentRoute.connection instanceof HotServer_1.HotServer)
50
+ this.onServerExecute = onExecute;
51
+ //else
52
+ //this.onClientExecute = onExecute;
53
+ }
54
+ /**
55
+ * Add a new test case.
56
+ */
57
+ HotRouteMethod.prototype.addTestCase = function (newTestCase, testCaseFunction) {
58
+ if (testCaseFunction === void 0) { testCaseFunction = null; }
59
+ if (typeof (newTestCase) === "string") {
60
+ var name_2 = newTestCase;
61
+ var func = testCaseFunction;
62
+ this.testCases[name_2] = {
63
+ name: name_2,
64
+ func: func
65
+ };
66
+ return;
67
+ }
68
+ if (typeof (newTestCase) === "function") {
69
+ var testCaseId = Object.keys(this.testCases).length;
70
+ var name_3 = "".concat(this.parentRoute.route, "/").concat(this.name, " test case ").concat(testCaseId);
71
+ var func = newTestCase;
72
+ this.testCases[name_3] = {
73
+ name: name_3,
74
+ func: func
75
+ };
76
+ return;
77
+ }
78
+ var testCase = newTestCase;
79
+ this.testCases[testCase.name] = testCase;
80
+ };
81
+ return HotRouteMethod;
82
+ }());
83
+ exports.HotRouteMethod = HotRouteMethod;
84
+ //# sourceMappingURL=HotRouteMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotRouteMethod.js","sourceRoot":"","sources":["../../src/HotRouteMethod.ts"],"names":[],"mappings":";;;AAAA,6BAAsC;AAGtC,yCAAwC;AAExC;;GAEG;AACH,IAAY,UAIX;AAJD,WAAY,UAAU;IAErB,yBAAW,CAAA;IACX,2BAAa,CAAA;AACd,CAAC,EAJW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAIrB;AA2CD;;GAEG;AACH;IAoCC,wBAAa,KAAe,EAAE,IAAY,EACzC,SAAmE,EACnE,IAAkC,EAAE,iBAAqD,EACzF,UAA6C,EAAE,eAA2B,EAC1E,SAAuF;QAHvF,0BAAA,EAAA,gBAAmE;QACnE,qBAAA,EAAA,OAAmB,UAAU,CAAC,IAAI;QAAE,kCAAA,EAAA,wBAAqD;QACzF,2BAAA,EAAA,iBAA6C;QAAE,gCAAA,EAAA,sBAA2B;QAC1E,0BAAA,EAAA,gBAAuF;QAEvF,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC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