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,342 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __generator = (this && this.__generator) || function (thisArg, body) {
31
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
32
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
33
+ function verb(n) { return function (v) { return step([n, v]); }; }
34
+ function step(op) {
35
+ if (f) throw new TypeError("Generator is already executing.");
36
+ while (_) try {
37
+ 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;
38
+ if (y = 0, t) op = [op[0] & 2, t.value];
39
+ switch (op[0]) {
40
+ case 0: case 1: t = op; break;
41
+ case 4: _.label++; return { value: op[1], done: false };
42
+ case 5: _.label++; y = op[1]; op = [0]; continue;
43
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
44
+ default:
45
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
46
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
47
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
48
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
49
+ if (t[2]) _.ops.pop();
50
+ _.trys.pop(); continue;
51
+ }
52
+ op = body.call(thisArg, _);
53
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
54
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
55
+ }
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.HotGenerator = void 0;
59
+ var ppath = __importStar(require("path"));
60
+ var HotIO_1 = require("./HotIO");
61
+ var HotStaq_1 = require("./HotStaq");
62
+ var HotHTTPServer_1 = require("./HotHTTPServer");
63
+ /**
64
+ * Generates stuff like API
65
+ */
66
+ var HotGenerator = /** @class */ (function () {
67
+ function HotGenerator(logger) {
68
+ this.hotsites = [];
69
+ this.api = true;
70
+ this.generateType = "javascript";
71
+ this.compileTS = true;
72
+ this.tsconfigPath = ppath.normalize("".concat(__dirname, "/../../tsconfig-generator.json"));
73
+ this.webpackConfigPath = ppath.normalize("".concat(__dirname, "/../../webpack.config.generator.js"));
74
+ this.optimizeJS = false;
75
+ this.logger = logger;
76
+ this.outputDir = ppath.normalize("".concat(process.cwd(), "/build-web/"));
77
+ }
78
+ /**
79
+ * Get the base url from the HotSite.
80
+ */
81
+ HotGenerator.prototype.getBaseUrlFromHotSite = function (processor, apiServer, loadedAPI, baseAPIUrl) {
82
+ if (baseAPIUrl === void 0) { baseAPIUrl = ""; }
83
+ if (baseAPIUrl === "")
84
+ baseAPIUrl = "http://127.0.0.1:".concat(apiServer.ports.http);
85
+ var foundAPIUrl = baseAPIUrl;
86
+ // Attempt to find the base url from the HotSite's API.
87
+ if (processor.hotSite != null) {
88
+ if (processor.hotSite.apis != null) {
89
+ for (var key in processor.hotSite.apis) {
90
+ var tempAPI = processor.hotSite.apis[key];
91
+ if (tempAPI.apiName != null) {
92
+ if (tempAPI.apiName === loadedAPI.exportedClassName) {
93
+ if (tempAPI.url != null)
94
+ foundAPIUrl = tempAPI.url;
95
+ break;
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return (foundAPIUrl);
102
+ };
103
+ /**
104
+ * Start the API server.
105
+ */
106
+ HotGenerator.prototype.startAPIServer = function (processor, loadedAPI) {
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ var server, baseAPIUrl, foundModulePath, apiJS, apiClass, api;
109
+ var _this = this;
110
+ return __generator(this, function (_a) {
111
+ server = new HotHTTPServer_1.HotHTTPServer(processor);
112
+ baseAPIUrl = this.getBaseUrlFromHotSite(processor, server, loadedAPI);
113
+ process.chdir(process.cwd());
114
+ foundModulePath = require.resolve(loadedAPI.path, { paths: [process.cwd()] });
115
+ apiJS = require(foundModulePath);
116
+ apiClass = apiJS[loadedAPI.exportedClassName];
117
+ api = new apiClass(baseAPIUrl, server);
118
+ server.logger.verbose("Loaded API class: ".concat(loadedAPI.exportedClassName));
119
+ server.processor.api = api;
120
+ server.api = api;
121
+ // Add this since this is an API server only.
122
+ server.addRoute("/", function (req, res) { return __awaiter(_this, void 0, void 0, function () {
123
+ return __generator(this, function (_a) {
124
+ res.json({ "status": "ok" });
125
+ return [2 /*return*/];
126
+ });
127
+ }); });
128
+ //server.serverType = "API Server";
129
+ //await server.listen ();
130
+ return [2 /*return*/, ({ api: api, baseAPIUrl: baseAPIUrl })];
131
+ });
132
+ });
133
+ };
134
+ /**
135
+ * Generate the API.
136
+ *
137
+ * @fixme Needs tests!
138
+ */
139
+ HotGenerator.prototype.generateAPI = function (processor, apis) {
140
+ return __awaiter(this, void 0, void 0, function () {
141
+ var outputDir, iIdx, hotsite, numAPIs, _a, _b, _i, key, loadedAPI, libraryName, apiName, serverResult, apiFileContent, _c, _d, _e, key2, route, routeName, iJdx, method, methodName, outputFile, outputFileExtension, timestamp, tsconfigObj, _f, _g, temptsconfig, content, tempWebpackConfig, ex_1;
142
+ return __generator(this, function (_h) {
143
+ switch (_h.label) {
144
+ case 0:
145
+ if (!(this.api === true)) return [3 /*break*/, 25];
146
+ outputDir = ppath.normalize("".concat(this.outputDir, "/"));
147
+ return [4 /*yield*/, HotIO_1.HotIO.exists(outputDir)];
148
+ case 1:
149
+ if (!((_h.sent()) === false)) return [3 /*break*/, 3];
150
+ return [4 /*yield*/, HotIO_1.HotIO.mkdir(outputDir)];
151
+ case 2:
152
+ _h.sent();
153
+ _h.label = 3;
154
+ case 3:
155
+ iIdx = 0;
156
+ _h.label = 4;
157
+ case 4:
158
+ if (!(iIdx < this.hotsites.length)) return [3 /*break*/, 25];
159
+ hotsite = this.hotsites[iIdx];
160
+ if (hotsite.apis === null) {
161
+ this.logger.info("HotSite \"".concat(hotsite.name, "\" contains no APIs. Skipping..."));
162
+ return [3 /*break*/, 24];
163
+ }
164
+ numAPIs = Object.keys(hotsite.apis).length;
165
+ if (numAPIs < 1) {
166
+ this.logger.info("HotSite \"".concat(hotsite.name, "\" contains no APIs. Skipping..."));
167
+ return [3 /*break*/, 24];
168
+ }
169
+ _a = [];
170
+ for (_b in hotsite.apis)
171
+ _a.push(_b);
172
+ _i = 0;
173
+ _h.label = 5;
174
+ case 5:
175
+ if (!(_i < _a.length)) return [3 /*break*/, 24];
176
+ key = _a[_i];
177
+ loadedAPI = apis[key];
178
+ libraryName = hotsite.apis[key].libraryName;
179
+ apiName = hotsite.apis[key].apiName;
180
+ if (libraryName == null) {
181
+ this.logger.info("Web API \"".concat(key, "\" from HotSite \"").concat(hotsite.name, "\" does not have a libraryName!"));
182
+ return [3 /*break*/, 23];
183
+ }
184
+ if (apiName == null) {
185
+ this.logger.info("Web API \"".concat(key, "\" from HotSite \"").concat(hotsite.name, "\" does not have an apiName!"));
186
+ return [3 /*break*/, 23];
187
+ }
188
+ this.logger.info("Generating Web API \"".concat(key, "\" from HotSite \"").concat(hotsite.name, "\"..."));
189
+ return [4 /*yield*/, this.startAPIServer(processor, loadedAPI)];
190
+ case 6:
191
+ serverResult = _h.sent();
192
+ apiFileContent = "";
193
+ _c = [];
194
+ for (_d in serverResult.api.routes)
195
+ _c.push(_d);
196
+ _e = 0;
197
+ _h.label = 7;
198
+ case 7:
199
+ if (!(_e < _c.length)) return [3 /*break*/, 22];
200
+ key2 = _c[_e];
201
+ route = serverResult.api.routes[key2];
202
+ routeName = route.route;
203
+ apiFileContent += this.getContent(this.generateType, "header", { routeName: routeName, baseAPIUrl: serverResult.baseAPIUrl,
204
+ libraryName: libraryName, apiName: apiName });
205
+ for (iJdx = 0; iJdx < route.methods.length; iJdx++) {
206
+ method = route.methods[iJdx];
207
+ methodName = method.name;
208
+ apiFileContent += this.getContent(this.generateType, "function", { methodName: methodName, routeVersion: route.version,
209
+ routeName: routeName, methodType: method.type.toUpperCase(),
210
+ libraryName: libraryName, apiName: apiName });
211
+ }
212
+ apiFileContent += this.getContent(this.generateType, "footer", { libraryName: libraryName, apiName: apiName, routeName: routeName });
213
+ outputFile = ppath.normalize("".concat(outputDir, "/").concat(libraryName, "_").concat(apiName));
214
+ outputFileExtension = ".ts";
215
+ if (this.generateType === "javascript") {
216
+ this.compileTS = false;
217
+ outputFileExtension = ".js";
218
+ }
219
+ return [4 /*yield*/, HotIO_1.HotIO.writeTextFile("".concat(outputFile).concat(outputFileExtension), apiFileContent)];
220
+ case 8:
221
+ _h.sent();
222
+ if (!(this.compileTS === true)) return [3 /*break*/, 19];
223
+ this.logger.info("Compiling TypeScript...");
224
+ timestamp = Date.now().toString();
225
+ _g = (_f = JSON).parse;
226
+ return [4 /*yield*/, HotIO_1.HotIO.readTextFile(this.tsconfigPath)];
227
+ case 9:
228
+ tsconfigObj = _g.apply(_f, [_h.sent()]);
229
+ tsconfigObj.compilerOptions.outDir = outputDir;
230
+ tsconfigObj.files = ["".concat(outputFile).concat(outputFileExtension)];
231
+ temptsconfig = ppath.normalize("".concat(outputDir, "/tsconfig-generator-temp-").concat(timestamp, ".json"));
232
+ return [4 /*yield*/, HotIO_1.HotIO.writeTextFile(temptsconfig, JSON.stringify(tsconfigObj, null, 4))];
233
+ case 10:
234
+ _h.sent();
235
+ return [4 /*yield*/, HotIO_1.HotIO.readTextFile(this.webpackConfigPath)];
236
+ case 11:
237
+ content = _h.sent();
238
+ tempWebpackConfig = ppath.normalize("".concat(outputDir, "/webpack.config.generator-temp-").concat(timestamp, ".js"));
239
+ content = HotStaq_1.HotStaq.replaceKey(content, "WEBPACK_VERSION", "1.0.0");
240
+ content = HotStaq_1.HotStaq.replaceKey(content, "WEBPACK_ENTRY", "".concat(outputFile).concat(outputFileExtension));
241
+ content = HotStaq_1.HotStaq.replaceKey(content, "WEBPACK_TSCONFIG", temptsconfig);
242
+ content = HotStaq_1.HotStaq.replaceKey(content, "WEBPACK_IGNORE_PLUGINS_REGEX", "null");
243
+ content = HotStaq_1.HotStaq.replaceKey(content, "WEBPACK_OUTPUT_FILE", "".concat(libraryName, "_").concat(apiName, ".js"));
244
+ content = HotStaq_1.HotStaq.replaceKey(content, "WEBPACK_OUTPUT_PATH", outputDir);
245
+ content = HotStaq_1.HotStaq.replaceKey(content, "WEBPACK_LIBRARY_NAME", "".concat(libraryName, "_").concat(apiName));
246
+ return [4 /*yield*/, HotIO_1.HotIO.writeTextFile(tempWebpackConfig, content)];
247
+ case 12:
248
+ _h.sent();
249
+ _h.label = 13;
250
+ case 13:
251
+ _h.trys.push([13, 15, , 16]);
252
+ // Build the TypeScript so it can run in a web browser.
253
+ return [4 /*yield*/, HotIO_1.HotIO.exec("cd ".concat(outputDir, " && webpack --mode=production -c ").concat(tempWebpackConfig))];
254
+ case 14:
255
+ // Build the TypeScript so it can run in a web browser.
256
+ _h.sent();
257
+ return [3 /*break*/, 16];
258
+ case 15:
259
+ ex_1 = _h.sent();
260
+ return [3 /*break*/, 16];
261
+ case 16: return [4 /*yield*/, HotIO_1.HotIO.rm(temptsconfig)];
262
+ case 17:
263
+ _h.sent();
264
+ return [4 /*yield*/, HotIO_1.HotIO.rm(tempWebpackConfig)];
265
+ case 18:
266
+ _h.sent();
267
+ this.logger.info("Finished compiling TypeScript...");
268
+ _h.label = 19;
269
+ case 19:
270
+ if (!(this.optimizeJS === true)) return [3 /*break*/, 21];
271
+ this.logger.info("Optimizing JavaScript...");
272
+ return [4 /*yield*/, HotIO_1.HotIO.exec("npx google-closure-compiler --js=".concat(outputFile, ".js --js_output_file=").concat(outputFile, ".min.js"))];
273
+ case 20:
274
+ _h.sent();
275
+ this.logger.info("Finished optimizing JavaScript...");
276
+ _h.label = 21;
277
+ case 21:
278
+ _e++;
279
+ return [3 /*break*/, 7];
280
+ case 22:
281
+ this.logger.info("Finished generating Web API \"".concat(key, "\" from HotSite \"").concat(hotsite.name, "\"..."));
282
+ _h.label = 23;
283
+ case 23:
284
+ _i++;
285
+ return [3 /*break*/, 5];
286
+ case 24:
287
+ iIdx++;
288
+ return [3 /*break*/, 4];
289
+ case 25: return [2 /*return*/];
290
+ }
291
+ });
292
+ });
293
+ };
294
+ /**
295
+ * Get the content.
296
+ */
297
+ HotGenerator.prototype.getContent = function (type, contentPart, data) {
298
+ var content = "";
299
+ if (type === "javascript")
300
+ content = this.getJavaScriptContent(contentPart, data);
301
+ if (type === "typescript")
302
+ content = this.getTypeScriptContent(contentPart, data);
303
+ return (content);
304
+ };
305
+ /**
306
+ * Get the Typescript content.
307
+ */
308
+ HotGenerator.prototype.getTypeScriptContent = function (contentPart, data) {
309
+ var content = "";
310
+ if (contentPart === "header") {
311
+ content = "\nimport { HotAPI } from \"HotStaq\";\n\n/**\n * The ".concat(data.routeName, " API route.\n */\nexport class ").concat(data.routeName, " extends HotAPI\n{\n\t/**\n\t * The base url to make calls to.\n\t */\n\tbaseUrl: string;\n\n\tconstructor (baseUrl: string = \"").concat(data.baseAPIUrl, "\")\n\t{\n\t\tthis.baseUrl = baseUrl;\n\t}\n\n");
312
+ }
313
+ if (contentPart === "function") {
314
+ content = "\n\t/**\n\t * The ".concat(data.methodName, " method.\n\t */\n\tasync ").concat(data.methodName, " (jsonObj: any): Promise<any>\n\t{\n\t\tconst response = await fetch (`${this.baseUrl}/").concat(data.routeVersion, "/").concat(data.route, "/").concat(data.methodName, "`, {\n\t\t\t\t\"method\": \"").concat(data.methodType, "\",\n\t\t\t\t\"headers\": {\n\t\t\t\t\t\"Accept\": \"application/json\",\n\t\t\t\t\t\"Content-Type\": \"application/json\"\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify (jsonObj)\n\t\t\t});\n\t\tconst result = response.json ();\n\n\t\treturn (result);\n\t}\n\n");
315
+ }
316
+ if (contentPart === "footer") {
317
+ content = "\n}\n";
318
+ }
319
+ return (content);
320
+ };
321
+ /**
322
+ * Get the JavaScript content.
323
+ */
324
+ HotGenerator.prototype.getJavaScriptContent = function (contentPart, data) {
325
+ var content = "";
326
+ if (contentPart === "header") {
327
+ content =
328
+ "if (typeof (".concat(data.libraryName, ") === \"undefined\")\n\t").concat(data.libraryName, " = {};\n\nvar HotAPIGlobal = HotAPI;\n\nif (typeof (HotAPIGlobal) === \"undefined\")\n\tHotAPIGlobal = window.HotAPI;\n\n/**\n * The ").concat(data.routeName, " API route.\n */\nclass ").concat(data.routeName, " extends HotAPIGlobal\n{\n\tconstructor (baseUrl, connection, db)\n\t{\n\t\tif (baseUrl == null)\n\t\t\tbaseUrl = \"").concat(data.baseAPIUrl, "\";\n\n\t\tsuper (baseUrl, connection, db);\n\n\t\t/**\n\t\t * The base url to make calls to.\n\t\t */\n\t\tthis.baseUrl = baseUrl;\n\t}\n");
329
+ }
330
+ if (contentPart === "function") {
331
+ content = "\n\t/**\n\t * The ".concat(data.methodName, " method.\n\t */\n\t").concat(data.methodName, " (jsonObj)\n\t{\n\t\tvar promise = new Promise (function (resolve, reject)\n\t\t\t{\n\t\t\t\tfetch (`${this.baseUrl}/").concat(data.routeVersion, "/").concat(data.routeName, "/").concat(data.methodName, "`, {\n\t\t\t\t\t\t\"method\": \"").concat(data.methodType, "\",\n\t\t\t\t\t\t\"headers\": {\n\t\t\t\t\t\t\t\"Accept\": \"application/json\",\n\t\t\t\t\t\t\t\"Content-Type\": \"application/json\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: JSON.stringify (jsonObj)\n\t\t\t\t\t}).then (function (response)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar result = response.json ();\n\n\t\t\t\t\t\t\tresolve (result);\n\t\t\t\t\t\t});\n\t\t\t});\n\n\t\treturn (promise);\n\t}\n\n");
332
+ }
333
+ if (contentPart === "footer") {
334
+ content =
335
+ "\n}\n\n".concat(data.libraryName, ".").concat(data.apiName, " = ").concat(data.routeName, ";\n");
336
+ }
337
+ return (content);
338
+ };
339
+ return HotGenerator;
340
+ }());
341
+ exports.HotGenerator = HotGenerator;
342
+ //# sourceMappingURL=HotGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotGenerator.js","sourceRoot":"","sources":["../../src/HotGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA8B;AAC9B,iCAAgC;AAEhC,qCAA6C;AAE7C,iDAAgD;AAKhD;;GAEG;AACH;IAyCC,sBAAa,MAAc;QAE1B,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,IA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gbC;AAhbY,oCAAY"}
@@ -0,0 +1,162 @@
1
+ /// <reference types="node" />
2
+ import * as http from "http";
3
+ import * as https from "https";
4
+ import express from "express";
5
+ import { Files } from "formidable";
6
+ import { HotServer } from "./HotServer";
7
+ import { HotStaq } from "./HotStaq";
8
+ import { HotRoute } from "./HotRoute";
9
+ import { HTTPMethod } from "./HotRouteMethod";
10
+ /**
11
+ * A static route.
12
+ */
13
+ export interface StaticRoute {
14
+ /**
15
+ * The route to the files.
16
+ */
17
+ route?: string;
18
+ /**
19
+ * The absolute path to the location of the files to
20
+ * serve on this machine.
21
+ */
22
+ localPath?: string;
23
+ }
24
+ /**
25
+ * A HTTP server.
26
+ */
27
+ export declare class HotHTTPServer extends HotServer {
28
+ /**
29
+ * The express app to use.
30
+ */
31
+ expressApp: express.Express;
32
+ /**
33
+ * The HTTP listener to use.
34
+ */
35
+ httpListener: http.Server;
36
+ /**
37
+ * The HTTPS listener to use.
38
+ */
39
+ httpsListener: https.Server;
40
+ /**
41
+ * The static files and folders to serve.
42
+ */
43
+ staticRoutes: StaticRoute[];
44
+ /**
45
+ * Any non-static routes that need to be added. These
46
+ * will be added during the preregistration phase, before
47
+ * all API routes are added.
48
+ */
49
+ routes: {
50
+ /**
51
+ * The type of route.
52
+ */
53
+ type: HTTPMethod;
54
+ /**
55
+ * The type of route.
56
+ */
57
+ route: string;
58
+ /**
59
+ * The method to execute when this route is hit.
60
+ */
61
+ method: (req: express.Request, res: express.Response) => Promise<void>;
62
+ }[];
63
+ /**
64
+ * Serve hott files when requested. This value will be overwritten by whatever
65
+ * value is set to server.serveHottFiles in HotSite.json.
66
+ */
67
+ serveHottFiles: boolean;
68
+ /**
69
+ * Do not serve these hott files.
70
+ */
71
+ ignoreHottFiles: {
72
+ [name: string]: boolean;
73
+ };
74
+ /**
75
+ * The associated info with any hott files served. All values here will be
76
+ * overwritten by whatever values are set in the server object in HotSite.json.
77
+ */
78
+ hottFilesAssociatedInfo: {
79
+ /**
80
+ * The default name for a served Hott file.
81
+ */
82
+ name: string;
83
+ /**
84
+ * The base url for a hott file.
85
+ */
86
+ url: string;
87
+ /**
88
+ * The JavaScript source path.
89
+ */
90
+ jsSrcPath: string;
91
+ };
92
+ constructor(processor: HotStaq | HotServer, httpPort?: number, httpsPort?: number);
93
+ /**
94
+ * Add a static route.
95
+ */
96
+ addStaticRoute(route: string | StaticRoute, localPath?: string): void;
97
+ /**
98
+ * Add a route. This will be registered before any APIs are registered.
99
+ */
100
+ addRoute(route: string, method: (req: express.Request, res: express.Response) => Promise<void>, type?: HTTPMethod): void;
101
+ /**
102
+ * Serve a directory. This is an alias for addStaticRoute.
103
+ */
104
+ serveDirectory(route: string | StaticRoute, localPath?: string): void;
105
+ /**
106
+ * Register a static route with Express.
107
+ */
108
+ registerStaticRoute(route: StaticRoute): void;
109
+ /**
110
+ * Get a static route.
111
+ */
112
+ getStaticRoute(route: string): StaticRoute;
113
+ /**
114
+ * Register a route.
115
+ */
116
+ registerRoute(route: HotRoute): Promise<void>;
117
+ /**
118
+ * Check if a file exists.
119
+ */
120
+ static checkIfFileExists(filepath: string): Promise<boolean>;
121
+ /**
122
+ * The routes to add before registering a route.
123
+ */
124
+ preregisterRoute(): void;
125
+ /**
126
+ * Get all files uploaded.
127
+ */
128
+ static getFileUploads(req: express.Request, options?: any): Promise<Files>;
129
+ /**
130
+ * Set the error handlers. This will create two express routes at the bottom of the
131
+ * route stack. The first will be to capture any 404 errors, the second would be to
132
+ * catch any remaining errors.
133
+ */
134
+ setErrorHandlingRoutes(handle404?: (req: express.Request, res: express.Response, next: any) => void, handleOther?: (err: any, req: express.Request, res: express.Response, next: any) => void): void;
135
+ /**
136
+ * Clear the last two express routes, which are reserved for the
137
+ * error handlers.
138
+ */
139
+ clearErrorHandlingRoutes(): void;
140
+ /**
141
+ * Start listening for requests.
142
+ */
143
+ listen(): Promise<void>;
144
+ /**
145
+ * Start the server.
146
+ *
147
+ * @param localStaticPath The public path that contains the HTML, Hott files, images, and
148
+ * all public content. This can also be an array of StaticRoutes.
149
+ * @param httpPort The HTTP port to listen on .
150
+ * @param httpsPort The HTTPS port to listen on.
151
+ * @param processor The HotStaq or parent server being used for communication.
152
+ */
153
+ static startServer(localStaticPath?: string | StaticRoute[], httpPort?: number, httpsPort?: number, processor?: HotServer | HotStaq): Promise<{
154
+ processor: HotServer | HotStaq;
155
+ server: HotHTTPServer;
156
+ }>;
157
+ /**
158
+ * Shutdown the server.
159
+ */
160
+ shutdown(): Promise<void>;
161
+ }
162
+ //# sourceMappingURL=HotHTTPServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotHTTPServer.d.ts","sourceRoot":"","sources":["../../src/HotHTTPServer.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAU,KAAK,EAAgB,MAAM,YAAY,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9D;;GAEG;AACH,MAAM,WAAW,WAAW;IAE3B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAE3C;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC;IAC1B;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B;;;;OAI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