@sava-info-systems/api-maker-with-extensions 1.0.0-alpha

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 (496) hide show
  1. package/.env +22 -0
  2. package/.nvmrc +1 -0
  3. package/3rdpartylicenses.txt +18 -0
  4. package/README.md +30 -0
  5. package/assets-deployment/.env +41 -0
  6. package/assets-deployment/config/keyfile +16 -0
  7. package/assets-deployment/config/mongodb_api_maker.yml +33 -0
  8. package/assets-deployment/config/redis_api_maker.yml +26 -0
  9. package/assets-deployment/installation_steps.sh +184 -0
  10. package/assets-deployment/mongo_script.js +33 -0
  11. package/dist/1025.js +1 -0
  12. package/dist/1464.js +1 -0
  13. package/dist/148.js +1 -0
  14. package/dist/1558.js +1 -0
  15. package/dist/1617.js +1 -0
  16. package/dist/1678.js +1 -0
  17. package/dist/1754.js +1 -0
  18. package/dist/1840.js +1 -0
  19. package/dist/1928.js +1 -0
  20. package/dist/1957.js +1 -0
  21. package/dist/2140.js +1 -0
  22. package/dist/2295.js +1 -0
  23. package/dist/2443.js +1 -0
  24. package/dist/2473.js +1 -0
  25. package/dist/2714.js +1 -0
  26. package/dist/2908.js +1 -0
  27. package/dist/3139.js +1 -0
  28. package/dist/3450.js +1 -0
  29. package/dist/3rdpartylicenses.txt +395 -0
  30. package/dist/4110.js +1 -0
  31. package/dist/4181.js +1 -0
  32. package/dist/4186.js +1 -0
  33. package/dist/4211.js +1 -0
  34. package/dist/4575.js +1 -0
  35. package/dist/4842.js +1 -0
  36. package/dist/485.js +1 -0
  37. package/dist/4895.js +1 -0
  38. package/dist/5334.js +1 -0
  39. package/dist/5421.js +1 -0
  40. package/dist/5679.js +1 -0
  41. package/dist/5761.js +1 -0
  42. package/dist/6236.js +1 -0
  43. package/dist/6393.js +1 -0
  44. package/dist/6401.js +1 -0
  45. package/dist/6925.js +1 -0
  46. package/dist/7368.js +1 -0
  47. package/dist/7436.js +1 -0
  48. package/dist/7470.js +1 -0
  49. package/dist/7649.js +1 -0
  50. package/dist/7975.js +1 -0
  51. package/dist/7987.js +1 -0
  52. package/dist/8125.js +1 -0
  53. package/dist/8266.js +1 -0
  54. package/dist/8296.js +1 -0
  55. package/dist/8374.js +1 -0
  56. package/dist/8682.js +1 -0
  57. package/dist/8841.js +1 -0
  58. package/dist/885.js +1 -0
  59. package/dist/891.js +1 -0
  60. package/dist/913.js +1 -0
  61. package/dist/9208.js +1 -0
  62. package/dist/9243.js +1 -0
  63. package/dist/9939.js +1 -0
  64. package/dist/assets/images/banner/default_package_banner.jpg +0 -0
  65. package/dist/assets/images/bg/world.svg +3 -0
  66. package/dist/assets/images/cloud/setup-on-server.svg +51 -0
  67. package/dist/assets/images/icons/adminuser.png +0 -0
  68. package/dist/assets/images/icons/api-group.svg +10 -0
  69. package/dist/assets/images/icons/api-user.svg +9 -0
  70. package/dist/assets/images/icons/aws.svg +5 -0
  71. package/dist/assets/images/icons/bug.svg +1 -0
  72. package/dist/assets/images/icons/bulkschema.svg +5 -0
  73. package/dist/assets/images/icons/comparator.svg +5 -0
  74. package/dist/assets/images/icons/custom.svg +9 -0
  75. package/dist/assets/images/icons/database.svg +12 -0
  76. package/dist/assets/images/icons/db-m.svg +28 -0
  77. package/dist/assets/images/icons/default_package_icon.svg +41 -0
  78. package/dist/assets/images/icons/deployset.png +0 -0
  79. package/dist/assets/images/icons/dev.svg +9 -0
  80. package/dist/assets/images/icons/diagram.svg +7 -0
  81. package/dist/assets/images/icons/event.png +0 -0
  82. package/dist/assets/images/icons/film-movies-icon.svg +14 -0
  83. package/dist/assets/images/icons/finder.svg +11 -0
  84. package/dist/assets/images/icons/git.svg +1 -0
  85. package/dist/assets/images/icons/house.svg +50 -0
  86. package/dist/assets/images/icons/i18n.svg +9 -0
  87. package/dist/assets/images/icons/increment.svg +4 -0
  88. package/dist/assets/images/icons/license.png +0 -0
  89. package/dist/assets/images/icons/log-profile.svg +9 -0
  90. package/dist/assets/images/icons/log.svg +9 -0
  91. package/dist/assets/images/icons/masters.png +0 -0
  92. package/dist/assets/images/icons/nodes.svg +3 -0
  93. package/dist/assets/images/icons/notes.svg +23 -0
  94. package/dist/assets/images/icons/npm.svg +1 -0
  95. package/dist/assets/images/icons/process_initializers.svg +13 -0
  96. package/dist/assets/images/icons/redis.png +0 -0
  97. package/dist/assets/images/icons/redis.svg +9 -0
  98. package/dist/assets/images/icons/sandbox.svg +4 -0
  99. package/dist/assets/images/icons/schedulers.svg +12 -0
  100. package/dist/assets/images/icons/secret.svg +9 -0
  101. package/dist/assets/images/icons/systems.svg +9 -0
  102. package/dist/assets/images/icons/testing.svg +4 -0
  103. package/dist/assets/images/icons/third-party.svg +9 -0
  104. package/dist/assets/images/icons/typescript.svg +11 -0
  105. package/dist/assets/images/icons/utility.svg +7 -0
  106. package/dist/assets/images/icons/vulnerability.svg +12 -0
  107. package/dist/assets/images/icons/web.svg +10 -0
  108. package/dist/assets/images/instancesIcon/mariadb.png +0 -0
  109. package/dist/assets/images/instancesIcon/microsoft-sql-server.png +0 -0
  110. package/dist/assets/images/instancesIcon/mongodb.png +0 -0
  111. package/dist/assets/images/instancesIcon/my-sql.svg +159 -0
  112. package/dist/assets/images/instancesIcon/oracle.png +0 -0
  113. package/dist/assets/images/instancesIcon/postgresql.png +0 -0
  114. package/dist/assets/images/logo/API Maker Logo 2021 black.svg +47 -0
  115. package/dist/assets/images/logo/API Maker Logo 2021.svg +49 -0
  116. package/dist/assets/images/logo/discord-icon.svg +8 -0
  117. package/dist/assets/images/logo/dollar.svg +7 -0
  118. package/dist/assets/images/logo/logo.svg +41 -0
  119. package/dist/assets/images/logo/logo_cloud.svg +15 -0
  120. package/dist/assets/images/logo/logo_docs.svg +15 -0
  121. package/dist/assets/images/logo/logo_store.svg +17 -0
  122. package/dist/assets/images/logo/logo_store_new.svg +33 -0
  123. package/dist/assets/images/logo/rupee.svg +7 -0
  124. package/dist/assets/images/logo/sava-logo.png +0 -0
  125. package/dist/assets/images/logo/store_logo.svg +11 -0
  126. package/dist/assets/images/payment/failed.svg +3 -0
  127. package/dist/assets/images/payment/success.svg +3 -0
  128. package/dist/assets/images/svg/MARIA_DB.svg +3 -0
  129. package/dist/assets/images/svg/MONGO_DB.svg +5 -0
  130. package/dist/assets/images/svg/MYSQL_DB.svg +3 -0
  131. package/dist/assets/images/svg/Microsoft_SQL_Server_DB_No_Logo.svg +6 -0
  132. package/dist/assets/images/svg/Oracle_DB_No_Logo.svg +6 -0
  133. package/dist/assets/images/svg/POSTGRE_SQL_DB.svg +9 -0
  134. package/dist/assets/images/svg/Ti_DB.svg +5 -0
  135. package/dist/assets/images/svg/Xtra_DB.svg +19 -0
  136. package/dist/assets/images/svg/placeholder_thumbnail_json.svg +3 -0
  137. package/dist/assets/images/svg/serve_static_website_icon.svg +37 -0
  138. package/dist/assets/images/svg/single_obj.svg +3 -0
  139. package/dist/assets/json/am_docs.json +203 -0
  140. package/dist/assets/lib/svg-pan-zoom.d.ts +261 -0
  141. package/dist/assets/lib/svg-pan-zoom.min.js +3 -0
  142. package/dist/assets/monaco-assets/configurations/cpp.json +34 -0
  143. package/dist/assets/monaco-assets/configurations/csharp.json +32 -0
  144. package/dist/assets/monaco-assets/configurations/dart.json +29 -0
  145. package/dist/assets/monaco-assets/configurations/go.json +37 -0
  146. package/dist/assets/monaco-assets/configurations/java.json +33 -0
  147. package/dist/assets/monaco-assets/configurations/javascript.json +140 -0
  148. package/dist/assets/monaco-assets/configurations/json.json +22 -0
  149. package/dist/assets/monaco-assets/configurations/python.json +56 -0
  150. package/dist/assets/monaco-assets/configurations/ruby.json +31 -0
  151. package/dist/assets/monaco-assets/configurations/rust.json +34 -0
  152. package/dist/assets/monaco-assets/configurations/swift.json +27 -0
  153. package/dist/assets/monaco-assets/configurations/typescript.json +140 -0
  154. package/dist/assets/monaco-assets/configurations/xml.json +39 -0
  155. package/dist/assets/monaco-assets/configurations/yaml.json +35 -0
  156. package/dist/assets/monaco-assets/grammars/cpp.tmLanguage.json +16309 -0
  157. package/dist/assets/monaco-assets/grammars/csharp.tmLanguage.json +4984 -0
  158. package/dist/assets/monaco-assets/grammars/dart.tmLanguage.json +521 -0
  159. package/dist/assets/monaco-assets/grammars/go.tmLanguage.json +1017 -0
  160. package/dist/assets/monaco-assets/grammars/java.tmLanguage.json +1855 -0
  161. package/dist/assets/monaco-assets/grammars/javascript.tmLanguage.json +5914 -0
  162. package/dist/assets/monaco-assets/grammars/json.tmLanguage.json +213 -0
  163. package/dist/assets/monaco-assets/grammars/magicpython.tmLanguage.json +4213 -0
  164. package/dist/assets/monaco-assets/grammars/ruby.tmLanguage.json +2775 -0
  165. package/dist/assets/monaco-assets/grammars/rust.tmLanguage.json +1170 -0
  166. package/dist/assets/monaco-assets/grammars/swift.tmLanguage.json +3303 -0
  167. package/dist/assets/monaco-assets/grammars/typescript.tmLanguage.json +5665 -0
  168. package/dist/assets/monaco-assets/grammars/xml.tmLanguage.json +387 -0
  169. package/dist/assets/monaco-assets/grammars/yaml.tmLanguage.json +621 -0
  170. package/dist/assets/monaco-assets/onig.wasm +0 -0
  171. package/dist/assets/music/notification.mp3 +0 -0
  172. package/dist/assets/primeng-theme/primeng-theme-overrides.scss +130 -0
  173. package/dist/assets/primeng-theme/theme.css +1 -0
  174. package/dist/assets/schema-types/InterfaceProps.ts +509 -0
  175. package/dist/assets/schema-types/store-types.ts +170 -0
  176. package/dist/assets/schema-types/types.ts +1529 -0
  177. package/dist/assets/styles/bootstrap-overrides.scss +94 -0
  178. package/dist/assets/styles/colors-dark.scss +128 -0
  179. package/dist/assets/styles/colors-light.scss +22 -0
  180. package/dist/assets/styles/fonts/JetBrainsMonoRegular.ttf +0 -0
  181. package/dist/assets/styles/fonts/Verdana.ttf +0 -0
  182. package/dist/assets/styles/monaco-editor-overrides.scss +0 -0
  183. package/dist/assets/styles/out/bootstrap-overrides.css +2 -0
  184. package/dist/assets/styles/out/bootstrap-overrides.css.map +1 -0
  185. package/dist/assets/styles/out/colors-dark.css +2 -0
  186. package/dist/assets/styles/out/colors-dark.css.map +1 -0
  187. package/dist/assets/styles/out/colors-light.css +2 -0
  188. package/dist/assets/styles/out/colors-light.css.map +1 -0
  189. package/dist/assets/styles/out/monaco-editor-overrides.css +2 -0
  190. package/dist/assets/styles/out/monaco-editor-overrides.css.map +1 -0
  191. package/dist/assets/styles/out/styles.css +2 -0
  192. package/dist/assets/styles/out/styles.css.map +1 -0
  193. package/dist/assets/styles/out/variables.css +2 -0
  194. package/dist/assets/styles/out/variables.css.map +1 -0
  195. package/dist/assets/styles/root-styles.css +118 -0
  196. package/dist/assets/styles/styles.scss +356 -0
  197. package/dist/assets/styles/variables.scss +18 -0
  198. package/dist/color.png +0 -0
  199. package/dist/common.js +1 -0
  200. package/dist/favicon.ico +0 -0
  201. package/dist/hue.png +0 -0
  202. package/dist/index.html +147 -0
  203. package/dist/main.js +1 -0
  204. package/dist/polyfills.js +1 -0
  205. package/dist/primeicons.eot +0 -0
  206. package/dist/primeicons.svg +292 -0
  207. package/dist/primeicons.ttf +0 -0
  208. package/dist/primeicons.woff +0 -0
  209. package/dist/primeicons.woff2 +0 -0
  210. package/dist/runtime.js +1 -0
  211. package/dist/styles.css +1 -0
  212. package/license.txt +2 -0
  213. package/local.env +23 -0
  214. package/main.js +1 -0
  215. package/package.json +198 -0
  216. package/sandbox/.dockerignore +2 -0
  217. package/sandbox/Dockerfile +32 -0
  218. package/sandbox/assets/schema-types/store-types.js +165 -0
  219. package/sandbox/assets/schema-types/types.js +331 -0
  220. package/sandbox/package.json +28 -0
  221. package/sandbox/sandbox.js +1 -0
  222. package/sandbox/src/utils/VmInit.js +11 -0
  223. package/src/assets/schema-types/store-types.ts +170 -0
  224. package/src/assets/schema-types/types.ts +1529 -0
  225. package/src/json/DefaultUsers.json +18 -0
  226. package/src/public/css/bootstrap-slate.min.css +12 -0
  227. package/src/public/css/styles.css +4 -0
  228. package/src/public/dist-db-masters/3rdpartylicenses.txt +312 -0
  229. package/src/public/dist-db-masters/browser/assets/themes/arya-blue/fonts/Inter-italic.var.woff2 +0 -0
  230. package/src/public/dist-db-masters/browser/assets/themes/arya-blue/fonts/Inter-roman.var.woff2 +0 -0
  231. package/src/public/dist-db-masters/browser/assets/themes/arya-blue/theme.css +6310 -0
  232. package/src/public/dist-db-masters/browser/assets/themes/arya-green/fonts/Inter-italic.var.woff2 +0 -0
  233. package/src/public/dist-db-masters/browser/assets/themes/arya-green/fonts/Inter-roman.var.woff2 +0 -0
  234. package/src/public/dist-db-masters/browser/assets/themes/arya-green/theme.css +6310 -0
  235. package/src/public/dist-db-masters/browser/assets/themes/arya-orange/fonts/Inter-italic.var.woff2 +0 -0
  236. package/src/public/dist-db-masters/browser/assets/themes/arya-orange/fonts/Inter-roman.var.woff2 +0 -0
  237. package/src/public/dist-db-masters/browser/assets/themes/arya-orange/theme.css +6310 -0
  238. package/src/public/dist-db-masters/browser/assets/themes/arya-purple/fonts/Inter-italic.var.woff2 +0 -0
  239. package/src/public/dist-db-masters/browser/assets/themes/arya-purple/fonts/Inter-roman.var.woff2 +0 -0
  240. package/src/public/dist-db-masters/browser/assets/themes/arya-purple/theme.css +6310 -0
  241. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-amber/fonts/Inter-italic.var.woff2 +0 -0
  242. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-amber/fonts/Inter-roman.var.woff2 +0 -0
  243. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-amber/theme.css +7722 -0
  244. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-blue/fonts/Inter-italic.var.woff2 +0 -0
  245. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-blue/fonts/Inter-roman.var.woff2 +0 -0
  246. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-blue/theme.css +7722 -0
  247. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-cyan/fonts/Inter-italic.var.woff2 +0 -0
  248. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-cyan/fonts/Inter-roman.var.woff2 +0 -0
  249. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-cyan/theme.css +7722 -0
  250. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-green/fonts/Inter-italic.var.woff2 +0 -0
  251. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-green/fonts/Inter-roman.var.woff2 +0 -0
  252. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-green/theme.css +7722 -0
  253. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-indigo/fonts/Inter-italic.var.woff2 +0 -0
  254. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-indigo/fonts/Inter-roman.var.woff2 +0 -0
  255. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-indigo/theme.css +7722 -0
  256. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-lime/fonts/Inter-italic.var.woff2 +0 -0
  257. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-lime/fonts/Inter-roman.var.woff2 +0 -0
  258. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-lime/theme.css +7722 -0
  259. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-noir/fonts/Inter-italic.var.woff2 +0 -0
  260. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-noir/fonts/Inter-roman.var.woff2 +0 -0
  261. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-noir/theme.css +7722 -0
  262. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-pink/fonts/Inter-italic.var.woff2 +0 -0
  263. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-pink/fonts/Inter-roman.var.woff2 +0 -0
  264. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-pink/theme.css +7722 -0
  265. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-purple/fonts/Inter-italic.var.woff2 +0 -0
  266. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-purple/fonts/Inter-roman.var.woff2 +0 -0
  267. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-purple/theme.css +7722 -0
  268. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-teal/fonts/Inter-italic.var.woff2 +0 -0
  269. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-teal/fonts/Inter-roman.var.woff2 +0 -0
  270. package/src/public/dist-db-masters/browser/assets/themes/aura-dark-teal/theme.css +7722 -0
  271. package/src/public/dist-db-masters/browser/assets/themes/aura-light-amber/fonts/Inter-italic.var.woff2 +0 -0
  272. package/src/public/dist-db-masters/browser/assets/themes/aura-light-amber/fonts/Inter-roman.var.woff2 +0 -0
  273. package/src/public/dist-db-masters/browser/assets/themes/aura-light-amber/theme.css +7723 -0
  274. package/src/public/dist-db-masters/browser/assets/themes/aura-light-blue/fonts/Inter-italic.var.woff2 +0 -0
  275. package/src/public/dist-db-masters/browser/assets/themes/aura-light-blue/fonts/Inter-roman.var.woff2 +0 -0
  276. package/src/public/dist-db-masters/browser/assets/themes/aura-light-blue/theme.css +7723 -0
  277. package/src/public/dist-db-masters/browser/assets/themes/aura-light-cyan/fonts/Inter-italic.var.woff2 +0 -0
  278. package/src/public/dist-db-masters/browser/assets/themes/aura-light-cyan/fonts/Inter-roman.var.woff2 +0 -0
  279. package/src/public/dist-db-masters/browser/assets/themes/aura-light-cyan/theme.css +7723 -0
  280. package/src/public/dist-db-masters/browser/assets/themes/aura-light-green/fonts/Inter-italic.var.woff2 +0 -0
  281. package/src/public/dist-db-masters/browser/assets/themes/aura-light-green/fonts/Inter-roman.var.woff2 +0 -0
  282. package/src/public/dist-db-masters/browser/assets/themes/aura-light-green/theme.css +7723 -0
  283. package/src/public/dist-db-masters/browser/assets/themes/aura-light-indigo/fonts/Inter-italic.var.woff2 +0 -0
  284. package/src/public/dist-db-masters/browser/assets/themes/aura-light-indigo/fonts/Inter-roman.var.woff2 +0 -0
  285. package/src/public/dist-db-masters/browser/assets/themes/aura-light-indigo/theme.css +7723 -0
  286. package/src/public/dist-db-masters/browser/assets/themes/aura-light-lime/fonts/Inter-italic.var.woff2 +0 -0
  287. package/src/public/dist-db-masters/browser/assets/themes/aura-light-lime/fonts/Inter-roman.var.woff2 +0 -0
  288. package/src/public/dist-db-masters/browser/assets/themes/aura-light-lime/theme.css +7723 -0
  289. package/src/public/dist-db-masters/browser/assets/themes/aura-light-noir/fonts/Inter-italic.var.woff2 +0 -0
  290. package/src/public/dist-db-masters/browser/assets/themes/aura-light-noir/fonts/Inter-roman.var.woff2 +0 -0
  291. package/src/public/dist-db-masters/browser/assets/themes/aura-light-noir/theme.css +7731 -0
  292. package/src/public/dist-db-masters/browser/assets/themes/aura-light-pink/fonts/Inter-italic.var.woff2 +0 -0
  293. package/src/public/dist-db-masters/browser/assets/themes/aura-light-pink/fonts/Inter-roman.var.woff2 +0 -0
  294. package/src/public/dist-db-masters/browser/assets/themes/aura-light-pink/theme.css +7723 -0
  295. package/src/public/dist-db-masters/browser/assets/themes/aura-light-purple/fonts/Inter-italic.var.woff2 +0 -0
  296. package/src/public/dist-db-masters/browser/assets/themes/aura-light-purple/fonts/Inter-roman.var.woff2 +0 -0
  297. package/src/public/dist-db-masters/browser/assets/themes/aura-light-purple/theme.css +7723 -0
  298. package/src/public/dist-db-masters/browser/assets/themes/aura-light-teal/fonts/Inter-italic.var.woff2 +0 -0
  299. package/src/public/dist-db-masters/browser/assets/themes/aura-light-teal/fonts/Inter-roman.var.woff2 +0 -0
  300. package/src/public/dist-db-masters/browser/assets/themes/aura-light-teal/theme.css +7723 -0
  301. package/src/public/dist-db-masters/browser/assets/themes/bootstrap4-dark-blue/theme.css +6304 -0
  302. package/src/public/dist-db-masters/browser/assets/themes/bootstrap4-dark-purple/theme.css +6304 -0
  303. package/src/public/dist-db-masters/browser/assets/themes/bootstrap4-light-blue/theme.css +6304 -0
  304. package/src/public/dist-db-masters/browser/assets/themes/bootstrap4-light-purple/theme.css +6304 -0
  305. package/src/public/dist-db-masters/browser/assets/themes/fluent-light/theme.css +6439 -0
  306. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-amber/fonts/Inter-italic.var.woff2 +0 -0
  307. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-amber/fonts/Inter-roman.var.woff2 +0 -0
  308. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-amber/theme.css +6404 -0
  309. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-blue/fonts/Inter-italic.var.woff2 +0 -0
  310. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-blue/fonts/Inter-roman.var.woff2 +0 -0
  311. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-blue/theme.css +6404 -0
  312. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-cyan/fonts/Inter-italic.var.woff2 +0 -0
  313. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-cyan/fonts/Inter-roman.var.woff2 +0 -0
  314. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-cyan/theme.css +6404 -0
  315. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-green/fonts/Inter-italic.var.woff2 +0 -0
  316. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-green/fonts/Inter-roman.var.woff2 +0 -0
  317. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-green/theme.css +6404 -0
  318. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-indigo/fonts/Inter-italic.var.woff2 +0 -0
  319. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-indigo/fonts/Inter-roman.var.woff2 +0 -0
  320. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-indigo/theme.css +6404 -0
  321. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-pink/fonts/Inter-italic.var.woff2 +0 -0
  322. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-pink/fonts/Inter-roman.var.woff2 +0 -0
  323. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-pink/theme.css +6404 -0
  324. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-purple/fonts/Inter-italic.var.woff2 +0 -0
  325. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-purple/fonts/Inter-roman.var.woff2 +0 -0
  326. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-purple/theme.css +6404 -0
  327. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-teal/fonts/Inter-italic.var.woff2 +0 -0
  328. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-teal/fonts/Inter-roman.var.woff2 +0 -0
  329. package/src/public/dist-db-masters/browser/assets/themes/lara-dark-teal/theme.css +6404 -0
  330. package/src/public/dist-db-masters/browser/assets/themes/lara-light-amber/fonts/Inter-italic.var.woff2 +0 -0
  331. package/src/public/dist-db-masters/browser/assets/themes/lara-light-amber/fonts/Inter-roman.var.woff2 +0 -0
  332. package/src/public/dist-db-masters/browser/assets/themes/lara-light-amber/theme.css +6340 -0
  333. package/src/public/dist-db-masters/browser/assets/themes/lara-light-blue/fonts/Inter-italic.var.woff2 +0 -0
  334. package/src/public/dist-db-masters/browser/assets/themes/lara-light-blue/fonts/Inter-roman.var.woff2 +0 -0
  335. package/src/public/dist-db-masters/browser/assets/themes/lara-light-blue/theme.css +6340 -0
  336. package/src/public/dist-db-masters/browser/assets/themes/lara-light-cyan/fonts/Inter-italic.var.woff2 +0 -0
  337. package/src/public/dist-db-masters/browser/assets/themes/lara-light-cyan/fonts/Inter-roman.var.woff2 +0 -0
  338. package/src/public/dist-db-masters/browser/assets/themes/lara-light-cyan/theme.css +6340 -0
  339. package/src/public/dist-db-masters/browser/assets/themes/lara-light-green/fonts/Inter-italic.var.woff2 +0 -0
  340. package/src/public/dist-db-masters/browser/assets/themes/lara-light-green/fonts/Inter-roman.var.woff2 +0 -0
  341. package/src/public/dist-db-masters/browser/assets/themes/lara-light-green/theme.css +6340 -0
  342. package/src/public/dist-db-masters/browser/assets/themes/lara-light-indigo/fonts/Inter-italic.var.woff2 +0 -0
  343. package/src/public/dist-db-masters/browser/assets/themes/lara-light-indigo/fonts/Inter-roman.var.woff2 +0 -0
  344. package/src/public/dist-db-masters/browser/assets/themes/lara-light-indigo/theme.css +6340 -0
  345. package/src/public/dist-db-masters/browser/assets/themes/lara-light-pink/fonts/Inter-italic.var.woff2 +0 -0
  346. package/src/public/dist-db-masters/browser/assets/themes/lara-light-pink/fonts/Inter-roman.var.woff2 +0 -0
  347. package/src/public/dist-db-masters/browser/assets/themes/lara-light-pink/theme.css +6340 -0
  348. package/src/public/dist-db-masters/browser/assets/themes/lara-light-purple/fonts/Inter-italic.var.woff2 +0 -0
  349. package/src/public/dist-db-masters/browser/assets/themes/lara-light-purple/fonts/Inter-roman.var.woff2 +0 -0
  350. package/src/public/dist-db-masters/browser/assets/themes/lara-light-purple/theme.css +6340 -0
  351. package/src/public/dist-db-masters/browser/assets/themes/lara-light-teal/fonts/Inter-italic.var.woff2 +0 -0
  352. package/src/public/dist-db-masters/browser/assets/themes/lara-light-teal/fonts/Inter-roman.var.woff2 +0 -0
  353. package/src/public/dist-db-masters/browser/assets/themes/lara-light-teal/theme.css +6340 -0
  354. package/src/public/dist-db-masters/browser/assets/themes/luna-amber/theme.css +6255 -0
  355. package/src/public/dist-db-masters/browser/assets/themes/luna-blue/theme.css +6255 -0
  356. package/src/public/dist-db-masters/browser/assets/themes/luna-green/theme.css +6255 -0
  357. package/src/public/dist-db-masters/browser/assets/themes/luna-pink/theme.css +6255 -0
  358. package/src/public/dist-db-masters/browser/assets/themes/md-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-500.woff +0 -0
  359. package/src/public/dist-db-masters/browser/assets/themes/md-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-500.woff2 +0 -0
  360. package/src/public/dist-db-masters/browser/assets/themes/md-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-700.woff +0 -0
  361. package/src/public/dist-db-masters/browser/assets/themes/md-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-700.woff2 +0 -0
  362. package/src/public/dist-db-masters/browser/assets/themes/md-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-regular.woff +0 -0
  363. package/src/public/dist-db-masters/browser/assets/themes/md-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-regular.woff2 +0 -0
  364. package/src/public/dist-db-masters/browser/assets/themes/md-dark-deeppurple/theme.css +7915 -0
  365. package/src/public/dist-db-masters/browser/assets/themes/md-dark-indigo/fonts/roboto-v20-latin-ext_latin-500.woff +0 -0
  366. package/src/public/dist-db-masters/browser/assets/themes/md-dark-indigo/fonts/roboto-v20-latin-ext_latin-500.woff2 +0 -0
  367. package/src/public/dist-db-masters/browser/assets/themes/md-dark-indigo/fonts/roboto-v20-latin-ext_latin-700.woff +0 -0
  368. package/src/public/dist-db-masters/browser/assets/themes/md-dark-indigo/fonts/roboto-v20-latin-ext_latin-700.woff2 +0 -0
  369. package/src/public/dist-db-masters/browser/assets/themes/md-dark-indigo/fonts/roboto-v20-latin-ext_latin-regular.woff +0 -0
  370. package/src/public/dist-db-masters/browser/assets/themes/md-dark-indigo/fonts/roboto-v20-latin-ext_latin-regular.woff2 +0 -0
  371. package/src/public/dist-db-masters/browser/assets/themes/md-dark-indigo/theme.css +7915 -0
  372. package/src/public/dist-db-masters/browser/assets/themes/md-light-deeppurple/fonts/roboto-v20-latin-ext_latin-500.woff +0 -0
  373. package/src/public/dist-db-masters/browser/assets/themes/md-light-deeppurple/fonts/roboto-v20-latin-ext_latin-500.woff2 +0 -0
  374. package/src/public/dist-db-masters/browser/assets/themes/md-light-deeppurple/fonts/roboto-v20-latin-ext_latin-700.woff +0 -0
  375. package/src/public/dist-db-masters/browser/assets/themes/md-light-deeppurple/fonts/roboto-v20-latin-ext_latin-700.woff2 +0 -0
  376. package/src/public/dist-db-masters/browser/assets/themes/md-light-deeppurple/fonts/roboto-v20-latin-ext_latin-regular.woff +0 -0
  377. package/src/public/dist-db-masters/browser/assets/themes/md-light-deeppurple/fonts/roboto-v20-latin-ext_latin-regular.woff2 +0 -0
  378. package/src/public/dist-db-masters/browser/assets/themes/md-light-deeppurple/theme.css +7915 -0
  379. package/src/public/dist-db-masters/browser/assets/themes/md-light-indigo/fonts/roboto-v20-latin-ext_latin-500.woff +0 -0
  380. package/src/public/dist-db-masters/browser/assets/themes/md-light-indigo/fonts/roboto-v20-latin-ext_latin-500.woff2 +0 -0
  381. package/src/public/dist-db-masters/browser/assets/themes/md-light-indigo/fonts/roboto-v20-latin-ext_latin-700.woff +0 -0
  382. package/src/public/dist-db-masters/browser/assets/themes/md-light-indigo/fonts/roboto-v20-latin-ext_latin-700.woff2 +0 -0
  383. package/src/public/dist-db-masters/browser/assets/themes/md-light-indigo/fonts/roboto-v20-latin-ext_latin-regular.woff +0 -0
  384. package/src/public/dist-db-masters/browser/assets/themes/md-light-indigo/fonts/roboto-v20-latin-ext_latin-regular.woff2 +0 -0
  385. package/src/public/dist-db-masters/browser/assets/themes/md-light-indigo/theme.css +7915 -0
  386. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-500.woff +0 -0
  387. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-500.woff2 +0 -0
  388. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-700.woff +0 -0
  389. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-700.woff2 +0 -0
  390. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-regular.woff +0 -0
  391. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-deeppurple/fonts/roboto-v20-latin-ext_latin-regular.woff2 +0 -0
  392. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-deeppurple/theme.css +7915 -0
  393. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-indigo/fonts/roboto-v20-latin-ext_latin-500.woff +0 -0
  394. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-indigo/fonts/roboto-v20-latin-ext_latin-500.woff2 +0 -0
  395. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-indigo/fonts/roboto-v20-latin-ext_latin-700.woff +0 -0
  396. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-indigo/fonts/roboto-v20-latin-ext_latin-700.woff2 +0 -0
  397. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-indigo/fonts/roboto-v20-latin-ext_latin-regular.woff +0 -0
  398. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-indigo/fonts/roboto-v20-latin-ext_latin-regular.woff2 +0 -0
  399. package/src/public/dist-db-masters/browser/assets/themes/mdc-dark-indigo/theme.css +7915 -0
  400. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-deeppurple/fonts/roboto-v20-latin-ext_latin-500.woff +0 -0
  401. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-deeppurple/fonts/roboto-v20-latin-ext_latin-500.woff2 +0 -0
  402. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-deeppurple/fonts/roboto-v20-latin-ext_latin-700.woff +0 -0
  403. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-deeppurple/fonts/roboto-v20-latin-ext_latin-700.woff2 +0 -0
  404. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-deeppurple/fonts/roboto-v20-latin-ext_latin-regular.woff +0 -0
  405. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-deeppurple/fonts/roboto-v20-latin-ext_latin-regular.woff2 +0 -0
  406. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-deeppurple/theme.css +7915 -0
  407. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-indigo/fonts/roboto-v20-latin-ext_latin-500.woff +0 -0
  408. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-indigo/fonts/roboto-v20-latin-ext_latin-500.woff2 +0 -0
  409. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-indigo/fonts/roboto-v20-latin-ext_latin-700.woff +0 -0
  410. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-indigo/fonts/roboto-v20-latin-ext_latin-700.woff2 +0 -0
  411. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-indigo/fonts/roboto-v20-latin-ext_latin-regular.woff +0 -0
  412. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-indigo/fonts/roboto-v20-latin-ext_latin-regular.woff2 +0 -0
  413. package/src/public/dist-db-masters/browser/assets/themes/mdc-light-indigo/theme.css +7915 -0
  414. package/src/public/dist-db-masters/browser/assets/themes/mira/fonts/Inter-Bold.woff +0 -0
  415. package/src/public/dist-db-masters/browser/assets/themes/mira/fonts/Inter-Bold.woff2 +0 -0
  416. package/src/public/dist-db-masters/browser/assets/themes/mira/fonts/Inter-Medium.woff +0 -0
  417. package/src/public/dist-db-masters/browser/assets/themes/mira/fonts/Inter-Medium.woff2 +0 -0
  418. package/src/public/dist-db-masters/browser/assets/themes/mira/fonts/Inter-Regular.woff +0 -0
  419. package/src/public/dist-db-masters/browser/assets/themes/mira/fonts/Inter-Regular.woff2 +0 -0
  420. package/src/public/dist-db-masters/browser/assets/themes/mira/fonts/Inter-SemiBold.woff +0 -0
  421. package/src/public/dist-db-masters/browser/assets/themes/mira/fonts/Inter-SemiBold.woff2 +0 -0
  422. package/src/public/dist-db-masters/browser/assets/themes/mira/theme.css +6517 -0
  423. package/src/public/dist-db-masters/browser/assets/themes/nano/theme.css +6290 -0
  424. package/src/public/dist-db-masters/browser/assets/themes/nova/theme.css +6270 -0
  425. package/src/public/dist-db-masters/browser/assets/themes/nova-accent/theme.css +6280 -0
  426. package/src/public/dist-db-masters/browser/assets/themes/nova-alt/theme.css +6282 -0
  427. package/src/public/dist-db-masters/browser/assets/themes/rhea/theme.css +6258 -0
  428. package/src/public/dist-db-masters/browser/assets/themes/saga-blue/theme.css +6307 -0
  429. package/src/public/dist-db-masters/browser/assets/themes/saga-green/theme.css +6307 -0
  430. package/src/public/dist-db-masters/browser/assets/themes/saga-orange/theme.css +6307 -0
  431. package/src/public/dist-db-masters/browser/assets/themes/saga-purple/theme.css +6307 -0
  432. package/src/public/dist-db-masters/browser/assets/themes/soho-dark/fonts/lato-v17-latin-ext_latin-300.woff +0 -0
  433. package/src/public/dist-db-masters/browser/assets/themes/soho-dark/fonts/lato-v17-latin-ext_latin-300.woff2 +0 -0
  434. package/src/public/dist-db-masters/browser/assets/themes/soho-dark/fonts/lato-v17-latin-ext_latin-700.woff +0 -0
  435. package/src/public/dist-db-masters/browser/assets/themes/soho-dark/fonts/lato-v17-latin-ext_latin-700.woff2 +0 -0
  436. package/src/public/dist-db-masters/browser/assets/themes/soho-dark/fonts/lato-v17-latin-ext_latin-regular.woff +0 -0
  437. package/src/public/dist-db-masters/browser/assets/themes/soho-dark/fonts/lato-v17-latin-ext_latin-regular.woff2 +0 -0
  438. package/src/public/dist-db-masters/browser/assets/themes/soho-dark/theme.css +6283 -0
  439. package/src/public/dist-db-masters/browser/assets/themes/soho-light/fonts/lato-v17-latin-ext_latin-300.woff +0 -0
  440. package/src/public/dist-db-masters/browser/assets/themes/soho-light/fonts/lato-v17-latin-ext_latin-300.woff2 +0 -0
  441. package/src/public/dist-db-masters/browser/assets/themes/soho-light/fonts/lato-v17-latin-ext_latin-700.woff +0 -0
  442. package/src/public/dist-db-masters/browser/assets/themes/soho-light/fonts/lato-v17-latin-ext_latin-700.woff2 +0 -0
  443. package/src/public/dist-db-masters/browser/assets/themes/soho-light/fonts/lato-v17-latin-ext_latin-regular.woff +0 -0
  444. package/src/public/dist-db-masters/browser/assets/themes/soho-light/fonts/lato-v17-latin-ext_latin-regular.woff2 +0 -0
  445. package/src/public/dist-db-masters/browser/assets/themes/soho-light/theme.css +6337 -0
  446. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-Bold.woff +0 -0
  447. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-Bold.woff2 +0 -0
  448. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-Light.woff +0 -0
  449. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-Light.woff2 +0 -0
  450. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-Medium.woff +0 -0
  451. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-Medium.woff2 +0 -0
  452. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-Regular.woff +0 -0
  453. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-Regular.woff2 +0 -0
  454. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-SemiBold.woff +0 -0
  455. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/fonts/Inter-SemiBold.woff2 +0 -0
  456. package/src/public/dist-db-masters/browser/assets/themes/tailwind-light/theme.css +6403 -0
  457. package/src/public/dist-db-masters/browser/assets/themes/vela-blue/theme.css +6310 -0
  458. package/src/public/dist-db-masters/browser/assets/themes/vela-green/theme.css +6310 -0
  459. package/src/public/dist-db-masters/browser/assets/themes/vela-orange/theme.css +6310 -0
  460. package/src/public/dist-db-masters/browser/assets/themes/vela-purple/theme.css +6310 -0
  461. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/fonts/poppins-v15-latin-ext_latin-300.woff +0 -0
  462. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/fonts/poppins-v15-latin-ext_latin-300.woff2 +0 -0
  463. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/fonts/poppins-v15-latin-ext_latin-600.woff +0 -0
  464. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/fonts/poppins-v15-latin-ext_latin-600.woff2 +0 -0
  465. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/fonts/poppins-v15-latin-ext_latin-700.woff +0 -0
  466. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/fonts/poppins-v15-latin-ext_latin-700.woff2 +0 -0
  467. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/fonts/poppins-v15-latin-ext_latin-regular.woff +0 -0
  468. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/fonts/poppins-v15-latin-ext_latin-regular.woff2 +0 -0
  469. package/src/public/dist-db-masters/browser/assets/themes/viva-dark/theme.css +6444 -0
  470. package/src/public/dist-db-masters/browser/assets/themes/viva-light/fonts/poppins-v15-latin-ext_latin-300.woff +0 -0
  471. package/src/public/dist-db-masters/browser/assets/themes/viva-light/fonts/poppins-v15-latin-ext_latin-300.woff2 +0 -0
  472. package/src/public/dist-db-masters/browser/assets/themes/viva-light/fonts/poppins-v15-latin-ext_latin-600.woff +0 -0
  473. package/src/public/dist-db-masters/browser/assets/themes/viva-light/fonts/poppins-v15-latin-ext_latin-600.woff2 +0 -0
  474. package/src/public/dist-db-masters/browser/assets/themes/viva-light/fonts/poppins-v15-latin-ext_latin-700.woff +0 -0
  475. package/src/public/dist-db-masters/browser/assets/themes/viva-light/fonts/poppins-v15-latin-ext_latin-700.woff2 +0 -0
  476. package/src/public/dist-db-masters/browser/assets/themes/viva-light/fonts/poppins-v15-latin-ext_latin-regular.woff +0 -0
  477. package/src/public/dist-db-masters/browser/assets/themes/viva-light/fonts/poppins-v15-latin-ext_latin-regular.woff2 +0 -0
  478. package/src/public/dist-db-masters/browser/assets/themes/viva-light/theme.css +6445 -0
  479. package/src/public/dist-db-masters/browser/favicon.ico +0 -0
  480. package/src/public/dist-db-masters/browser/index.html +23 -0
  481. package/src/public/dist-db-masters/browser/main.js +116 -0
  482. package/src/public/dist-db-masters/browser/media/color.png +0 -0
  483. package/src/public/dist-db-masters/browser/media/hue.png +0 -0
  484. package/src/public/dist-db-masters/browser/media/primeicons.eot +0 -0
  485. package/src/public/dist-db-masters/browser/media/primeicons.svg +345 -0
  486. package/src/public/dist-db-masters/browser/media/primeicons.ttf +0 -0
  487. package/src/public/dist-db-masters/browser/media/primeicons.woff +0 -0
  488. package/src/public/dist-db-masters/browser/media/primeicons.woff2 +0 -0
  489. package/src/public/dist-db-masters/browser/polyfills.js +2 -0
  490. package/src/public/dist-db-masters/browser/styles.css +1 -0
  491. package/src/public/index.hbs +174 -0
  492. package/src/tools/install.js +37 -0
  493. package/src/tools/install_utils/InstallFromWeb.js +1636 -0
  494. package/src/tools/install_utils/SetEnvInFrontend.js +76 -0
  495. package/src/tools/install_utils/TSUtils.js +33 -0
  496. package/src/tools/set-env-in-frontend.js +11 -0
@@ -0,0 +1,1636 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Upload to : https://images.apimaker.dev/prod/am-cloud/am-init-scripts
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const child_process = require("child_process");
7
+ const loading = require("loading-cli");
8
+ const colors = require("colors-cli");
9
+ const os = require("os");
10
+ const mongodb = require("mongodb");
11
+ const ioredis_1 = require("ioredis");
12
+ const JSON5 = require("json5");
13
+ const { NumberPrompt, Input, BooleanPrompt } = require('enquirer');
14
+ const isDefaultInstallation = process.argv.indexOf('--default') >= 0;
15
+ class InstallFromWeb {
16
+ constructor() {
17
+ this.characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789';
18
+ this.swapSize = 0;
19
+ this.isDocker = false;
20
+ this.CADDY_FILE_NAME = 'Caddyfile';
21
+ this.mongo = {
22
+ port: 0,
23
+ username: '',
24
+ password: '',
25
+ };
26
+ this.redis = {
27
+ port: 0,
28
+ password: '',
29
+ };
30
+ this.am = {
31
+ port: 0,
32
+ wsPort: 0,
33
+ portOriginal: 38246,
34
+ portOriginalWS: 38245,
35
+ passCommunication: '',
36
+ passJWT: '',
37
+ passDBEncryptDecrypt: '',
38
+ // for secondary server
39
+ secondary: {
40
+ serverName: '',
41
+ connectionStrings: {
42
+ mongodb: '',
43
+ redisInternal: '',
44
+ redisExternal: '',
45
+ },
46
+ },
47
+ };
48
+ this.config = {
49
+ IP: '',
50
+ installSSL: false,
51
+ beHost: '',
52
+ beWSHost: '',
53
+ feHost: '',
54
+ // skip some installations
55
+ oldEnvExists: false,
56
+ installMongo: true,
57
+ installRedis: true,
58
+ // calculated properties from caddyFile
59
+ fullUrlOfBE: '',
60
+ fullUrlOfWS: '',
61
+ fullUrlOfFE: '',
62
+ startAMCommand: '',
63
+ stopAMCommand: '',
64
+ installType: EInstallationType.PRIMARY,
65
+ };
66
+ this.envFileD = {}; // env file data parsed in JSON.
67
+ this.os = {
68
+ Ubuntu20: false,
69
+ Ubuntu22: false,
70
+ Ubuntu23: false,
71
+ Ubuntu24: false,
72
+ };
73
+ // </editor-fold>
74
+ }
75
+ async main() {
76
+ try {
77
+ this.registerProcessHooks();
78
+ await this.isPrimaryOrSecondaryServer();
79
+ // Set and validate system
80
+ await this.printFlagsInfo();
81
+ await this.isRootUserProvided();
82
+ await this.setHome();
83
+ await this.setNodeHome();
84
+ await this.isUbuntu();
85
+ await this.isAVXSupported();
86
+ await this.isDiskSizeEnough();
87
+ await this.loadExistingEnvironments();
88
+ await this.getIPAddressOfServer();
89
+ await this.wantToInstallSSL();
90
+ await this.setSwapPartition();
91
+ await this.createDefaultDirectories();
92
+ await this.isDockerInstalled();
93
+ // Get user inputs in advance
94
+ if (this.config.installType === EInstallationType.PRIMARY)
95
+ await this.installInPrimaryServer();
96
+ else if (this.config.installType === EInstallationType.SECONDARY)
97
+ await this.installInSecondaryServer();
98
+ console.log('\n');
99
+ console.log('❤️ Thank you for using API Maker, Enjoy !! ❤️');
100
+ console.log('\n');
101
+ process.exit(0); // Need to exit because one promise of caddy is not done yet.
102
+ }
103
+ catch (e) {
104
+ console.error(e);
105
+ process.exit(1);
106
+ }
107
+ }
108
+ async installInPrimaryServer() {
109
+ await this.getSSLHosts(); // IP is used in this
110
+ await this.getMongoInputsFromUser();
111
+ await this.getRedisInputsFromUser();
112
+ await this.getAPIMakerUserInputs();
113
+ // Begin installation
114
+ await this.aptUpdate();
115
+ await this.installMake();
116
+ await this.installD2DiagramLibrary();
117
+ await this.installDockerIfNotInstalled();
118
+ await this.installFreshMongoDB();
119
+ await this.installFreshRedis();
120
+ await this.printPostInstallCommands();
121
+ await this.userExecutedMongoCommand();
122
+ await this.installOracleClient();
123
+ const calculatedStrings = await this.calculateMongoAndRedisConnectionStrings();
124
+ await this.writeEnvFileInConfigDirectory('primary', calculatedStrings.mongoDBConnectionString, calculatedStrings.redisConnectionStringInternal, calculatedStrings.redisConnectionStringExternal);
125
+ await this.syncEnvDataInFrontend();
126
+ // Start processes
127
+ await this.startAPIMakerBackendProcess();
128
+ this.calculateURLs();
129
+ // Caddy server & it's file processing.
130
+ await this.stopCaddy(true);
131
+ await this.sleep(2000);
132
+ await this.isPort80Free();
133
+ await this.installCaddyIfNotInstalled();
134
+ await this.writeCaddyFile();
135
+ await this.restartCaddy();
136
+ await this.startPM2ProcessOnRestart();
137
+ await this.printPM2ProcessList();
138
+ // Print section
139
+ this.printAllSetupConfigurations();
140
+ this.printEndpointSummary();
141
+ this.printDefaultUsers();
142
+ this.printStartAndStopCommands();
143
+ }
144
+ async installInSecondaryServer() {
145
+ await this.getSSLHosts(); // IP is used in this
146
+ await this.getAPIMakerUserInputs();
147
+ // Begin installation
148
+ await this.aptUpdate();
149
+ await this.installMake();
150
+ await this.installD2DiagramLibrary();
151
+ await this.installDockerIfNotInstalled();
152
+ await this.installOracleClient();
153
+ await this.writeEnvFileInConfigDirectory(this.am.secondary.serverName, this.am.secondary.connectionStrings.mongodb, this.am.secondary.connectionStrings.redisInternal, this.am.secondary.connectionStrings.redisExternal);
154
+ // Start processes
155
+ await this.startAPIMakerBackendProcess();
156
+ this.calculateURLs();
157
+ // Caddy server & it's file processing.
158
+ await this.stopCaddy(true);
159
+ await this.sleep(2000);
160
+ await this.isPort80Free();
161
+ await this.installCaddyIfNotInstalled();
162
+ await this.writeCaddyFile();
163
+ await this.restartCaddy();
164
+ await this.startPM2ProcessOnRestart();
165
+ await this.printPM2ProcessList();
166
+ // Print section
167
+ this.printAllSetupConfigurations();
168
+ this.printEndpointSummary();
169
+ this.printStartAndStopCommands();
170
+ this.printSecondaryServerAttachInformation();
171
+ }
172
+ registerProcessHooks() {
173
+ // eslint-disable-next-line n/handle-callback-err
174
+ process.on('unhandledRejection', (error, promise) => {
175
+ // console.log('Oh Lord! We forgot to handle a promise rejection here: ', promise);
176
+ // console.log('The error was: ', error);
177
+ // console.log(error);
178
+ });
179
+ // eslint-disable-next-line n/handle-callback-err
180
+ process.on('uncaughtException', function (error, origin) {
181
+ // console.log(error);
182
+ });
183
+ }
184
+ async loadExistingEnvironments() {
185
+ const envPath = path.join(this.HOME, 'config', '.env');
186
+ if (fs.existsSync(envPath)) {
187
+ this.config.oldEnvExists = true;
188
+ const dotenv = require('dotenv');
189
+ this.envFileD = dotenv.parse(fs.readFileSync(envPath, { encoding: 'utf8' }));
190
+ console.log(`🔶 Using existing environment variable settings from : ${envPath}`);
191
+ }
192
+ }
193
+ async printFlagsInfo() {
194
+ if (isDefaultInstallation)
195
+ console.log(`🟦 Default Installation selected`);
196
+ }
197
+ async setHome() {
198
+ this.HOME = (await this.runCommandSilent(`echo $HOME`, '/')).trim();
199
+ console.log(`✅ HOME : ${this.HOME}`);
200
+ }
201
+ async setNodeHome() {
202
+ const fullNodePath = (await this.runCommandSilent(`which node`, '/')).trim();
203
+ this.NODE_HOME = path.dirname(fullNodePath.trim());
204
+ console.log(`✅ NODE_HOME : ${this.NODE_HOME}`);
205
+ }
206
+ async isUbuntu() {
207
+ const output = await this.runCommandSilent(`cat /etc/os-release`, '/');
208
+ if (output.indexOf('VERSION_ID="22') >= 0) {
209
+ console.log(`✅ Ubuntu 22`);
210
+ this.os.Ubuntu22 = true;
211
+ }
212
+ else if (output.indexOf('VERSION_ID="23') >= 0) {
213
+ this.os.Ubuntu23 = true;
214
+ console.log(`✅ Ubuntu 23`);
215
+ }
216
+ else if (output.indexOf('VERSION_ID="24') >= 0) {
217
+ // this.os.Ubuntu24 = true;
218
+ // console.log(`✅ Ubuntu 24`);
219
+ throw new Error(`❌ Ubuntu 24 is not supported right now. Follow us on X @api_maker for latest updates.`);
220
+ }
221
+ else if (output.indexOf('VERSION_ID="20') >= 0) {
222
+ this.os.Ubuntu20 = true;
223
+ console.log(`✅ Ubuntu 20`);
224
+ }
225
+ else {
226
+ if (output.indexOf('NAME="Ubuntu"') >= 0) {
227
+ console.log(`⚠️ [Ubuntu 22 | Ubuntu 20 | Ubuntu 23] not found, but you can try.`);
228
+ console.log(`👉 If docker installation fails, try installing docker manually and try again.`);
229
+ }
230
+ else
231
+ throw new Error(`❌ Operating System is not Ubuntu.`);
232
+ }
233
+ }
234
+ async isAVXSupported() {
235
+ const output = await this.runCommandSilent(`cat /proc/cpuinfo`, '/');
236
+ if (output.toLowerCase().indexOf('avx') >= 0)
237
+ console.log(`✅ AVX Supported`);
238
+ else
239
+ console.log(`⚠️ AVX is not supported. It is required by MongoDB`);
240
+ }
241
+ /**
242
+ * df -hP
243
+ * ---- Output ----
244
+ * Filesystem Size Used Avail Use% Mounted on
245
+ * tmpfs 96M 1.2M 95M 2% /run
246
+ * /dev/sda 25G 8.2G 15G 36% /
247
+ * tmpfs 479M 0 479M 0% /dev/shm
248
+ * tmpfs 5.0M 0 5.0M 0% /run/lock
249
+ * tmpfs 96M 4.0K 96M 1% /run/user/0
250
+ * overlay 25G 8.2G 15G 36% /var/lib/docker/overlay2/cfc9fc672e96ac1ab40940bb4eaef996362a7c77713296f62dac58f2b7dc570d/merged
251
+ * overlay 25G 8.2G 15G 36% /var/lib/docker/overlay2/83a4b1be8586d950f818f6e8fb1db7d7aa4095c1827cd4b00ee437f6c905b82a/merged
252
+ */
253
+ async isDiskSizeEnough() {
254
+ try {
255
+ const output = await this.runCommandSilent(`df -hP`, '/');
256
+ const lines = output.split('\n');
257
+ for (const line of lines) {
258
+ const words = line.split(' ').map(w => (w || '').trim()).filter(w => !!w);
259
+ const lastWord = words[words.length - 1];
260
+ if (lastWord === '/') {
261
+ const totalDiskSize = Number(words[1].replace('G', ''));
262
+ if (totalDiskSize >= 20)
263
+ console.log(`✅ Disk size is good enough : ${words[1]}`);
264
+ else
265
+ console.log(`✴️ Disk size is not good enough : ${words[1]}`);
266
+ break;
267
+ }
268
+ }
269
+ }
270
+ catch (e) {
271
+ console.log(`✴️ Please make sure disk size is greater than 20GB`);
272
+ // console.log(e);
273
+ }
274
+ }
275
+ async isRootUserProvided() {
276
+ const output = await this.runCommandSilent(`whoami`, '/');
277
+ if (output.indexOf('root') >= 0)
278
+ console.log(`✅ Root user provided`);
279
+ else
280
+ throw new Error(`❌ Please provide root user.`);
281
+ }
282
+ async isPrimaryOrSecondaryServer() {
283
+ const prompt = new Input({
284
+ message: ' Is this primary[P]|secondary[S] server (P|S)?',
285
+ initial: 'P',
286
+ validate: (userInput) => {
287
+ const upper = (userInput || '').toUpperCase();
288
+ if (upper === 'P') {
289
+ this.config.installType = EInstallationType.PRIMARY;
290
+ return true;
291
+ }
292
+ else if (upper === 'S') {
293
+ this.config.installType = EInstallationType.SECONDARY;
294
+ return true;
295
+ }
296
+ else
297
+ return 'P = Primary, S = Secondary';
298
+ },
299
+ });
300
+ await prompt.run();
301
+ }
302
+ async getIPAddressOfServer() {
303
+ let getIPAddress;
304
+ try {
305
+ getIPAddress = await this.runCommandSilent(`curl -s https://ipinfo.io/ip`, '/');
306
+ getIPAddress = getIPAddress.trim();
307
+ if (this.isValidIpAddress(getIPAddress)) {
308
+ this.config.IP = getIPAddress;
309
+ // return; // Do not return. Take it from user also because for some severs it can be value of gateway IP address.
310
+ }
311
+ }
312
+ catch (e) {
313
+ }
314
+ const prompt = new Input({
315
+ message: ' Please enter public IP address of this server',
316
+ initial: getIPAddress,
317
+ validate: (userInput) => {
318
+ if (this.isValidIpAddress(userInput))
319
+ return true;
320
+ else
321
+ return 'Please provide valid IP address.';
322
+ },
323
+ });
324
+ this.config.IP = await prompt.run();
325
+ }
326
+ async wantToInstallSSL() {
327
+ const prompt = new BooleanPrompt({
328
+ message: ' Do you want to install SSL?',
329
+ initial: false,
330
+ });
331
+ this.config.installSSL = await prompt.run();
332
+ }
333
+ async wantToInstallMongoDB() {
334
+ const prompt = new BooleanPrompt({
335
+ message: ' Do you want to re-install MongoDB?',
336
+ initial: false,
337
+ });
338
+ this.config.installMongo = await prompt.run();
339
+ }
340
+ async wantToInstallRedis() {
341
+ const prompt = new BooleanPrompt({
342
+ message: ' Do you want to re-install Redis?',
343
+ initial: false,
344
+ });
345
+ this.config.installRedis = await prompt.run();
346
+ }
347
+ async getSSLHosts() {
348
+ if (!this.config.installSSL)
349
+ return;
350
+ const promptBE = new Input({
351
+ message: ' Please enter domain for backend',
352
+ validate: async (userInput) => {
353
+ return await this.getValidHostFromUser(userInput);
354
+ },
355
+ });
356
+ this.config.beHost = await promptBE.run();
357
+ const promptWS = new Input({
358
+ message: ' Please enter domain for backend WebSocket',
359
+ validate: async (userInput) => {
360
+ return await this.getValidHostFromUser(userInput);
361
+ },
362
+ });
363
+ this.config.beWSHost = await promptWS.run();
364
+ if (this.config.installType === EInstallationType.PRIMARY) {
365
+ const promptFE = new Input({
366
+ message: ' Please enter domain for frontend admin panel',
367
+ validate: async (userInput) => {
368
+ return await this.getValidHostFromUser(userInput);
369
+ },
370
+ });
371
+ this.config.feHost = await promptFE.run();
372
+ }
373
+ }
374
+ // <editor-fold desc="Set swap partition">
375
+ async setSwapPartition() {
376
+ const MIN_SWAP_SIZE = 2000 * os.cpus().length;
377
+ const output = await this.runCommandSilent(`free --mebi`, '/');
378
+ const currentSwapSize = this.getSwapMemorySizeFromCommandOutput(output);
379
+ if (currentSwapSize <= MIN_SWAP_SIZE) {
380
+ const prompt = new NumberPrompt({
381
+ message: ' Please enter swap size',
382
+ initial: MIN_SWAP_SIZE,
383
+ validate: (userInput) => {
384
+ if (userInput < MIN_SWAP_SIZE)
385
+ return `Minimum swap size should be ${MIN_SWAP_SIZE}`;
386
+ return true;
387
+ },
388
+ });
389
+ const userSwapSize = isDefaultInstallation ? MIN_SWAP_SIZE : await prompt.run();
390
+ this.showLoading(`Setting swap partition of size ${MIN_SWAP_SIZE}...`);
391
+ // Just in case old swap is running, so stop it and create new one.
392
+ try {
393
+ await this.runCommandSilent(`swapoff /var/swap.img`, '/');
394
+ }
395
+ catch (e) {
396
+ }
397
+ await this.runCommandSilent([
398
+ `cd /var`,
399
+ `touch swap.img`,
400
+ `chmod 600 swap.img`,
401
+ `dd if=/dev/zero of=/var/swap.img bs=1024k count=${userSwapSize + 200}`,
402
+ `mkswap /var/swap.img`,
403
+ `swapon /var/swap.img`,
404
+ `echo "/var/swap.img none swap sw 0 0" >> /etc/fstab`,
405
+ ].join('\n'), '/');
406
+ this.hideLoading();
407
+ this.swapSize = userSwapSize;
408
+ console.log(`✅ Swap size set to ${userSwapSize}`);
409
+ }
410
+ else {
411
+ this.swapSize = currentSwapSize;
412
+ console.log(`✅ Swap size is ${currentSwapSize}`);
413
+ }
414
+ }
415
+ // Duplicate code
416
+ getSwapMemorySizeFromCommandOutput(output) {
417
+ const lines = output.split('\n');
418
+ let totalSwap = 0;
419
+ for (let line of lines) {
420
+ line = (line || '').trim().toLowerCase();
421
+ if (line.startsWith('swap')) {
422
+ const lineSections = line.split(' ');
423
+ let index = 0;
424
+ for (const section of lineSections) {
425
+ if (!section)
426
+ continue;
427
+ if (index === 1) {
428
+ totalSwap += Number(section.trim());
429
+ break;
430
+ }
431
+ index++;
432
+ }
433
+ }
434
+ }
435
+ return totalSwap;
436
+ }
437
+ // </editor-fold>
438
+ async createDefaultDirectories() {
439
+ await fs.promises.mkdir(path.join(this.HOME, 'config'), { recursive: true });
440
+ await fs.promises.mkdir(path.join(this.HOME, 'logs'), { recursive: true });
441
+ await fs.promises.mkdir(path.join(this.HOME, 'docker-data'), { recursive: true });
442
+ }
443
+ async isDockerInstalled() {
444
+ try {
445
+ const dockerVersion = await this.runCommandSilent(`docker --version`, '/');
446
+ console.log(`✅ Docker found : ${dockerVersion.trim()}`);
447
+ this.isDocker = true;
448
+ return;
449
+ }
450
+ catch (e) {
451
+ }
452
+ this.isDocker = false;
453
+ }
454
+ async aptUpdate() {
455
+ try {
456
+ this.showLoading('apt update...');
457
+ await this.runCommandSilent(`apt update`, '/');
458
+ this.hideLoading();
459
+ console.log(`✅ apt update`);
460
+ }
461
+ catch (e) {
462
+ }
463
+ }
464
+ async installMake() {
465
+ try {
466
+ const makeVersion = await this.runCommandSilent(`make -version`, '/');
467
+ console.log(`✅ Make : ${makeVersion.trim().split('\n')[0]}`);
468
+ }
469
+ catch (e) {
470
+ this.showLoading('Installing make...');
471
+ await this.runCommandSilent(`apt-get install -y make`, '/');
472
+ const makePath = await this.runCommandSilent(`which make`, '/');
473
+ this.hideLoading();
474
+ console.log(`✅ make installed on path: ${makePath.trim()}`);
475
+ }
476
+ }
477
+ async installD2DiagramLibrary() {
478
+ try {
479
+ const d2LibVersion = await this.runCommandSilent(`d2 --version`, '/');
480
+ console.log(`✅ D2 : ${d2LibVersion.trim()}`);
481
+ }
482
+ catch (e) {
483
+ this.showLoading('Installing D2...');
484
+ await this.runCommandSilent(`curl -fsSL https://d2lang.com/install.sh | sh -s --`, '/');
485
+ const d2Path = await this.runCommandSilent(`which d2`, '/');
486
+ this.hideLoading();
487
+ console.log(`✅ D2 diagram library installed on path: ${d2Path.trim()}`);
488
+ }
489
+ }
490
+ async installDockerIfNotInstalled() {
491
+ try {
492
+ const dockerVersion = await this.runCommandSilent(`docker --version`, '/');
493
+ console.log(`✅ ${dockerVersion.trim()}`);
494
+ const dockerComposeVersion = await this.runCommandSilent(`docker-compose --version`, '/');
495
+ console.log(`✅ ${dockerComposeVersion.trim()}`);
496
+ }
497
+ catch (e) {
498
+ this.showLoading('Installing Docker...');
499
+ if (this.os.Ubuntu20) {
500
+ await this.runCommandSilent([
501
+ `apt-get install -y apt-transport-https ca-certificates curl software-properties-common`,
502
+ `curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -`,
503
+ `add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"`,
504
+ `apt-get install -y docker-ce docker-compose`,
505
+ ].join('\n'), '/');
506
+ }
507
+ else {
508
+ // if (this.os.Ubuntu22 || this.os.Ubuntu23 || this.os.Ubuntu24)
509
+ await this.runCommandSilent([
510
+ `for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do apt-get remove $pkg; done`,
511
+ `apt-get update`,
512
+ `apt-get install -y ca-certificates curl gnupg`,
513
+ `install -m 0755 -d /etc/apt/keyrings`,
514
+ `curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor --batch --yes -o /etc/apt/keyrings/docker.gpg`,
515
+ `chmod a+r /etc/apt/keyrings/docker.gpg`,
516
+ `echo \\`,
517
+ `"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \\`,
518
+ `$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \\`,
519
+ `tee /etc/apt/sources.list.d/docker.list > /dev/null`,
520
+ `apt-get update`,
521
+ `apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose`,
522
+ ].join('\n'), '/');
523
+ }
524
+ this.hideLoading();
525
+ console.log(`✅ Docker installed`);
526
+ }
527
+ }
528
+ // <editor-fold desc="MongoDB Installation">
529
+ async getMongoInputsFromUser() {
530
+ if (this.config.oldEnvExists && this.envFileD[EInstallEnv.am__mongo_db_connection]) {
531
+ await this.wantToInstallMongoDB();
532
+ }
533
+ if (!this.config.installMongo) {
534
+ console.log(`👍 MongoDB install skipped. Old connection string will be used. Data will not lost.`);
535
+ return;
536
+ }
537
+ if (this.isDocker) {
538
+ try {
539
+ await this.runCommandSilent(`docker-compose --project-name api_maker -f ${this.HOME}/config/mongodb_api_maker.yml stop`, '/');
540
+ console.log(`✅ MongoDB container stopped`);
541
+ }
542
+ catch (e) {
543
+ }
544
+ }
545
+ if (!isDefaultInstallation)
546
+ console.log(`———— #MongoDB Section ————`);
547
+ this.mongo.port = await this.getMongoPortFromUser();
548
+ this.mongo.username = await this.getMongoUsernameFromUser();
549
+ this.mongo.password = await this.getMongoPasswordFromUser();
550
+ if (!isDefaultInstallation)
551
+ console.log(`——————————————————————————`);
552
+ }
553
+ async installFreshMongoDB() {
554
+ if (!this.config.installMongo)
555
+ return;
556
+ console.log(`⏳ MongoDB Installing...`);
557
+ const oldDataFolder = path.join(this.HOME, 'docker-data', 'mongodb_api_maker');
558
+ this.showLoading('Installing MongoDB');
559
+ await this.writeMongoDBKeyFile();
560
+ await this.writeDCFileForMongoDB(this.mongo.port, this.mongo.username, this.mongo.password);
561
+ await this.runCommandSilent(`docker-compose --project-name api_maker -f ${this.HOME}/config/mongodb_api_maker.yml stop`, '/');
562
+ await this.runCommandSilent(`rm -rf ${oldDataFolder}`, '/');
563
+ await this.runCommandSilent(`docker-compose --project-name api_maker -f ${this.HOME}/config/mongodb_api_maker.yml up -d`, '/');
564
+ this.hideLoading();
565
+ console.log(` ✔ [Remove] : ${oldDataFolder}`);
566
+ console.log(`✅ MongoDB Installed`);
567
+ }
568
+ async writeMongoDBKeyFile() {
569
+ const keyFilePath = path.join(this.HOME, 'config', 'keyfile');
570
+ await fs.promises.writeFile(keyFilePath, [
571
+ '3ZlDTasYgr9tvXxcoZqeZkyWuhmPlssi1bLdVU+95+tintw007UY4THzRuV/yzMm',
572
+ 'BOGl40q+JTJ6f8TXCjBwJT+nid9OoqoGAczoFqAjlAayuY4Qmv8Iv38XEJHAAx/U',
573
+ 'WC/HTCOodCHo9YBBYQ68uSTVzx47Nyp/z+CR3b1f9rA0hX9zkm/H3B96Vu7lhkJ1',
574
+ '1wxpRlQ8udj2LrcZ0cAuMDCcuGDsa5Nydg3OEHs4PHzdIdDm+LB2YavsOGEyM422',
575
+ 'vPXH7pX1VAag1Br1CMmJijegau83SLJZN875TC+sWelKjH7nb1i/nWqsabThpnIu',
576
+ 'wpb+pl5vvJGxq21qZysz/8ZT7YgD6FMJoTMdFw6+MAXe0OiHlZUW5m6DPs9VL9wa',
577
+ 'CJXyU97UULmxHTUO4+7MoxwoGL/59vspgytBOpXRrOlnAepbLDOwTK4jyz3cfx1P',
578
+ '6xqdctgDAuDLp3yqK/GovpWxTHaWlSaqgqMfiqZptwWUR08uhzx9SI6buqr1lWrz',
579
+ 'SkFLQICOZ+Cjdb845/grloftBS1zDNflgLgY75Wzut8X6swEFebfyA3HRNOLh7pm',
580
+ '4fEGNTf3OnwAhDj18y943NfVyKlb57Tl33rAj0xDsb2ku+Ug71xOjkdrTtKczczD',
581
+ 'rsVUWtyiMieN1oivO9Ss1e/bbHfTyUlqfNlXSo4wqVS6wqnPQOYX6JeSPowvYdf4',
582
+ 'J1D/iSiPlqKiy28T/KUq+h04VMCCJUFW6a87yRczT1lp4F5bWzhzY6Of3ebok9hS',
583
+ '/KlYm4/uegDFMC+Rd/EWaagGwgL5KBHbvkgGz65uOxlTVJzGiZngKUrs8RmIlOXH',
584
+ 'SynnwFHUP7jSUAedZjxlWkt9b7U5rSXAPnFhhW4QNoeccnrqcJcS2lQQA8wSD6ur',
585
+ '2jo73kLVAcesAAoZ8jNBZxQOO7y4/9m7v5zCj0VJ2BIrCtwqEYUtCuMH06JkecCU',
586
+ 'DBm/m13f7WpUd2mvZk6ULc/D8n03',
587
+ ].join('\n'), { encoding: 'utf8' });
588
+ console.log(` ✔ [Write] : ${keyFilePath}`);
589
+ }
590
+ async writeDCFileForMongoDB(mongoPort, mongoUsername, mongoPassword) {
591
+ const mongodbDCFilePath = path.join(this.HOME, 'config', 'mongodb_api_maker.yml');
592
+ await fs.promises.writeFile(mongodbDCFilePath, [
593
+ `version: "3.7"`,
594
+ `services:`,
595
+ ` mongodb_api_maker:`,
596
+ ` image: mongo:6.0.2`,
597
+ ` container_name: mongodb_api_maker`,
598
+ ` restart: always`,
599
+ ` environment: # Not working without username and pass. So keep it.`,
600
+ ` - MONGO_INITDB_ROOT_USERNAME=${mongoUsername}`,
601
+ ` - MONGO_INITDB_ROOT_PASSWORD=${mongoPassword}`,
602
+ ` - MONGO_REPLICA_SET_NAME=rs0`,
603
+ ` volumes:`,
604
+ ` - ${this.HOME}/docker-data/mongodb_api_maker/data:/data/db`,
605
+ ` - ./keyfile:/opt/keyfile`,
606
+ ` ports:`,
607
+ ` - ${mongoPort}:27017`,
608
+ ` entrypoint:`,
609
+ ` - bash`,
610
+ ` - -c`,
611
+ ` - |`,
612
+ ` chmod 400 /opt/keyfile`,
613
+ ` chown 999:999 /opt/keyfile`,
614
+ ` exec docker-entrypoint.sh $$@`,
615
+ ` command: "mongod --bind_ip_all --keyFile /opt/keyfile --replSet rs0 --quiet"`,
616
+ ` logging:`,
617
+ ` driver: "json-file"`,
618
+ ` options:`,
619
+ ` max-size: "5m"`,
620
+ ` max-file: "3"`,
621
+ ``,
622
+ ].join('\n'), { encoding: 'utf8' });
623
+ console.log(` ✔ [Write] : ${mongodbDCFilePath}`);
624
+ }
625
+ async getMongoPortFromUser() {
626
+ const defaultMongoPort = 38248;
627
+ const prompt = new NumberPrompt({
628
+ message: ' Please enter MongoDB port',
629
+ initial: defaultMongoPort,
630
+ validate: async (userInput) => {
631
+ if (userInput < 2000)
632
+ return 'Port should be greater than 2000-60000';
633
+ else if (userInput > 60000)
634
+ return 'Port should be between 2000-60000';
635
+ const isPortFree = await this.isGivenPortFree(userInput);
636
+ if (isPortFree)
637
+ return true;
638
+ else
639
+ return `Port ${userInput} is not free.`;
640
+ },
641
+ });
642
+ return isDefaultInstallation ? defaultMongoPort : await prompt.run();
643
+ }
644
+ async getMongoUsernameFromUser() {
645
+ const defaultMongoUser = 'api_maker_user';
646
+ const prompt = new Input({
647
+ message: ' Please enter MongoDB username',
648
+ initial: defaultMongoUser,
649
+ validate: (userInput) => {
650
+ if (userInput.length < 4)
651
+ return 'Username length should be between 4-32';
652
+ else if (userInput.length > 32)
653
+ return 'Username length should be between 4-32';
654
+ return true;
655
+ },
656
+ });
657
+ return isDefaultInstallation ? defaultMongoUser : await prompt.run();
658
+ }
659
+ async getMongoPasswordFromUser() {
660
+ const mongoPass = this.getRandomString(20);
661
+ const prompt = new Input({
662
+ message: ' Please enter MongoDB password',
663
+ initial: mongoPass,
664
+ validate: (userInput) => {
665
+ if (userInput.length < 4)
666
+ return 'Password length should be between 4-32';
667
+ else if (userInput.length > 32)
668
+ return 'Password length should be between 4-32';
669
+ if (this.isAlphaNumericalValidPass(userInput))
670
+ return true;
671
+ return 'Password can only contain [a-z, A-Z, 0-9, _], special characters creates issue in setup automation process.';
672
+ },
673
+ });
674
+ return isDefaultInstallation ? mongoPass : await prompt.run();
675
+ }
676
+ // </editor-fold>
677
+ // <editor-fold desc="Redis Installation">
678
+ async getRedisInputsFromUser() {
679
+ if (this.config.oldEnvExists && this.envFileD[EInstallEnv.am__redisInternal]) {
680
+ await this.wantToInstallRedis();
681
+ }
682
+ if (!this.config.installRedis) {
683
+ console.log(`👍 Redis install skipped. Old connection string will be used. Data will not lost.`);
684
+ return;
685
+ }
686
+ if (this.isDocker) {
687
+ try {
688
+ await this.runCommandSilent(`docker-compose --project-name api_maker -f ${this.HOME}/config/redis_api_maker.yml stop`, '/');
689
+ console.log(`✅ Redis container stopped`);
690
+ }
691
+ catch (e) {
692
+ }
693
+ }
694
+ if (!isDefaultInstallation)
695
+ console.log(`———— #Redis Section ——————`);
696
+ this.redis.port = await this.getRedisPortFromUser();
697
+ this.redis.password = await this.getRedisPasswordFromUser();
698
+ if (!isDefaultInstallation)
699
+ console.log(`——————————————————————————`);
700
+ }
701
+ async installFreshRedis() {
702
+ if (!this.config.installRedis)
703
+ return;
704
+ console.log(`⏳ Redis Installing...`);
705
+ const oldDataFolder = path.join(this.HOME, 'docker-data', 'redis_api_maker');
706
+ this.showLoading('Installing Redis');
707
+ await this.writeDCFileForRedis(this.redis.port, this.redis.password);
708
+ await this.runCommandSilent(`docker-compose --project-name api_maker -f ${this.HOME}/config/redis_api_maker.yml stop`, '/');
709
+ await this.runCommandSilent(`rm -rf ${oldDataFolder}`, '/');
710
+ await this.runCommandSilent(`docker-compose --project-name api_maker -f ${this.HOME}/config/redis_api_maker.yml up -d`, '/');
711
+ this.hideLoading();
712
+ console.log(` ✔ [Remove] : ${oldDataFolder}`);
713
+ console.log(`✅ Redis Installed`);
714
+ }
715
+ async getRedisPortFromUser() {
716
+ const defaultRedisPort = 7479;
717
+ const prompt = new NumberPrompt({
718
+ message: ' Please enter Redis port',
719
+ initial: defaultRedisPort,
720
+ validate: async (userInput) => {
721
+ if (userInput < 2000)
722
+ return 'Port should be greater than 2000-60000';
723
+ else if (userInput > 60000)
724
+ return 'Port should be between 2000-60000';
725
+ else if (this.mongo.port === userInput)
726
+ return 'It should not be same as MongoDB port.';
727
+ const isPortFree = await this.isGivenPortFree(userInput);
728
+ if (isPortFree)
729
+ return true;
730
+ else
731
+ return `Port ${userInput} is not free.`;
732
+ },
733
+ });
734
+ return isDefaultInstallation ? defaultRedisPort : await prompt.run();
735
+ }
736
+ async getRedisPasswordFromUser() {
737
+ const redisPass = this.getRandomString(20);
738
+ const prompt = new Input({
739
+ message: ' Please enter Redis password',
740
+ initial: redisPass,
741
+ validate: (userInput) => {
742
+ if (userInput.length < 4)
743
+ return 'Password length should be between 4-32';
744
+ else if (userInput.length > 32)
745
+ return 'Password length should be between 4-32';
746
+ if (this.isAlphaNumericalValidPass(userInput))
747
+ return true;
748
+ return 'Password can only contain [a-z, A-Z, 0-9, _], special characters creates issue in setup automation process.';
749
+ },
750
+ });
751
+ return isDefaultInstallation ? redisPass : await prompt.run();
752
+ }
753
+ async writeDCFileForRedis(redisPort, redisPassword) {
754
+ const redisDCFilePath = path.join(this.HOME, 'config', 'redis_api_maker.yml');
755
+ await fs.promises.writeFile(redisDCFilePath, [
756
+ `version: "3.7"`,
757
+ `networks:`,
758
+ ` redis_api_maker-network:`,
759
+ ` driver: bridge`,
760
+ `services:`,
761
+ ` redis_api_maker:`,
762
+ ` image: 'redis:7.0.5-alpine'`,
763
+ ` restart: always`,
764
+ ` container_name: redis_api_maker`,
765
+ ` environment:`,
766
+ ` - REDIS_PORT_NUMBER=${redisPort}`,
767
+ ` ports:`,
768
+ ` - '${redisPort}:6379'`,
769
+ ` command: redis-server --loglevel warning --requirepass ${redisPassword}`,
770
+ ` volumes:`,
771
+ ` - ${this.HOME}/docker-data/redis_api_maker:/data`,
772
+ ` networks:`,
773
+ ` - redis_api_maker-network`,
774
+ ` logging:`,
775
+ ` driver: "json-file"`,
776
+ ` options:`,
777
+ ` max-size: "5m"`,
778
+ ` max-file: "3"`,
779
+ ``,
780
+ ].join('\n'), { encoding: 'utf8' });
781
+ console.log(` ✔ [Write] : ${redisDCFilePath}`);
782
+ }
783
+ // </editor-fold>
784
+ async printPostInstallCommands() {
785
+ if (!this.config.installMongo)
786
+ return;
787
+ const mongoContainerID = (await this.runCommandSilent(`docker ps -aqf "name=mongodb_api_maker"`, '/')).trim();
788
+ console.log(`\n\n`);
789
+ console.log(`👉 Run below 3 commands in separate terminal.`);
790
+ console.log(`——————————————————————————————————————————————————————————————————————————————————————`);
791
+ console.log(colors.cyan(`docker exec -it ${mongoContainerID} /bin/bash # Go inside docker container`));
792
+ console.log(colors.green(`mongosh -u ${this.mongo.username} -p ${this.mongo.password} # Go inside mongo shell`));
793
+ console.log(`——————————————————————————————————————————————————————————————————————————————————————`);
794
+ console.log(colors.yellow([
795
+ `rs.initiate({`,
796
+ ` _id : "rs0",`,
797
+ ` members: [`,
798
+ ` { _id: 0, host: "127.0.0.1:27017" }`,
799
+ ` ]`,
800
+ `});`,
801
+ `db.getSiblingDB("admin").updateUser(`,
802
+ ` "${this.mongo.username}",`,
803
+ ` {`,
804
+ ` customData: {},`,
805
+ ` roles: [`,
806
+ ` { "role": "root", "db": "admin" },`,
807
+ ` { "role": "readAnyDatabase", "db": "admin" },`,
808
+ ` { "role": "readWriteAnyDatabase", "db": "admin" },`,
809
+ ` { "role": "userAdminAnyDatabase", "db": "admin" },`,
810
+ ` { "role": "dbAdminAnyDatabase", "db": "admin" },`,
811
+ ` { "role": "backup", "db": "admin" },`,
812
+ ` { "role": "restore", "db": "admin" },`,
813
+ ` { "role": "clusterAdmin", "db": "admin" },`,
814
+ ` { "role": "clusterManager", "db": "admin" },`,
815
+ ` { "role": "clusterMonitor", "db": "admin" },`,
816
+ ` { "role": "hostManager", "db": "admin" },`,
817
+ ` { "role": "dbAdmin", "db": "admin" },`,
818
+ ` { "role": "dbOwner", "db": "admin" },`,
819
+ ` { "role": "userAdmin", "db": "admin" },`,
820
+ ` ],`,
821
+ ` }`,
822
+ `);`,
823
+ ].join('\n')));
824
+ console.log(`——————————————————————————————————————————————————————————————————————————————————————`);
825
+ console.log(`\n\n`);
826
+ }
827
+ async userExecutedMongoCommand() {
828
+ if (!this.config.installMongo)
829
+ return;
830
+ const prompt = new Input({
831
+ message: ` Type 'done' once above commands executed in separate terminal`,
832
+ initial: '',
833
+ validate: (userInput) => {
834
+ userInput = userInput.trim().toUpperCase();
835
+ if (userInput !== 'DONE')
836
+ return `Please type 'done' once you execute above commands in separate terminal.`;
837
+ return true;
838
+ },
839
+ });
840
+ return await prompt.run();
841
+ }
842
+ async installOracleClient() {
843
+ if (fs.existsSync(`/opt/oracle/instantclient/ojdbc8.jar`)) {
844
+ console.log(`👍 Oracle Client Exists`);
845
+ return;
846
+ }
847
+ this.showLoading('Oracle Client Installing...');
848
+ await this.runCommandSilent([
849
+ `apt-get -yq install unzip`,
850
+ `apt-get -yq install make`,
851
+ ``,
852
+ `# Install oracledb prerequisites`,
853
+ `rm -rf /opt/oracle`,
854
+ `mkdir -p /opt/oracle`,
855
+ `cd /opt/oracle`,
856
+ `wget -q https://images.apimaker.dev/prod/am-cloud/binaries/oracle-clients/21.8.0/instantclient-basic-linuxx64.zip`,
857
+ `unzip instantclient-basic-linuxx64.zip`,
858
+ `apt-get install -y libaio1=0.3.112-13build1`,
859
+ `sh -c "echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf"`,
860
+ `ldconfig`,
861
+ ].join('\n'), '/');
862
+ this.hideLoading();
863
+ console.log(`✅ Oracle Client Installed`);
864
+ }
865
+ // <editor-fold desc="Write .env file">
866
+ async getAPIMakerUserInputs() {
867
+ // Stop AM BE process if exists
868
+ try {
869
+ await this.runCommandSilent(`pm2 delete api_maker_be`, '/');
870
+ }
871
+ catch (e) {
872
+ }
873
+ if (!isDefaultInstallation)
874
+ console.log(`———— #API Maker Section ———`);
875
+ this.am.port = await this.getAPIMakerBackendPort();
876
+ this.am.wsPort = await this.getAPIMakerWSPort();
877
+ this.am.passCommunication = await this.getPassCommunication();
878
+ this.am.passJWT = await this.getPassJWT();
879
+ this.am.passDBEncryptDecrypt = await this.getPassDBEncryptDecrypt();
880
+ if (this.config.installType === EInstallationType.SECONDARY) {
881
+ this.am.secondary.serverName = await this.getSecondaryServerName();
882
+ this.am.secondary.connectionStrings.mongodb = await this.getSecondaryMongoDBConnectionString();
883
+ this.am.secondary.connectionStrings.redisInternal = await this.getSecondaryRedisInternalConnectionString();
884
+ this.am.secondary.connectionStrings.redisExternal = await this.getSecondaryRedisExternalConnectionString();
885
+ }
886
+ if (!isDefaultInstallation)
887
+ console.log(`——————————————————————————`);
888
+ }
889
+ async calculateMongoAndRedisConnectionStrings() {
890
+ let mongoDBConnectionString;
891
+ let redisConnectionStringInternal;
892
+ let redisConnectionStringExternal;
893
+ if (this.config.installMongo) {
894
+ mongoDBConnectionString = `mongodb://${this.mongo.username}:${this.mongo.password}@127.0.0.1:${this.mongo.port}/api_maker_db?authSource=admin&replicaSet=rs0&directConnection=true`;
895
+ }
896
+ else
897
+ mongoDBConnectionString = this.envFileD[EInstallEnv.am__mongo_db_connection];
898
+ if (this.config.installRedis) {
899
+ redisConnectionStringInternal = `{"nodes": [{port:${this.redis.port}, host:"127.0.0.1", pass: "${this.redis.password}"}]}`;
900
+ redisConnectionStringExternal = `{"nodes": [{port:${this.redis.port}, host:"127.0.0.1", pass: "${this.redis.password}"}], redisValueExpireInSeconds: 7200, maxCharsResToCache: 1000000}`;
901
+ }
902
+ else {
903
+ redisConnectionStringInternal = this.envFileD[EInstallEnv.am__redisInternal];
904
+ redisConnectionStringExternal = this.envFileD[EInstallEnv.am__redisExternal];
905
+ }
906
+ return {
907
+ mongoDBConnectionString,
908
+ redisConnectionStringInternal,
909
+ redisConnectionStringExternal,
910
+ };
911
+ }
912
+ async writeEnvFileInConfigDirectory(serverName, mongoDBConnectionString, redisConnectionStringInternal, redisConnectionStringExternal) {
913
+ const BE_HOST_PORT = this.config.installSSL ? `https://${this.config.beHost}` : `http://${this.config.IP}:${this.am.port}`;
914
+ const envFilePath = path.join(this.HOME, 'config', '.env');
915
+ let fullExternalString = ``;
916
+ if (redisConnectionStringExternal)
917
+ fullExternalString = `am__redisExternal='${redisConnectionStringExternal}'`;
918
+ await fs.promises.writeFile(envFilePath, [
919
+ `# You can set environment variables in this file to override package.json "am" object values.`,
920
+ `# Docs Link : https://www.npmjs.com/package/dotenv/v/16.0.3`,
921
+ ``,
922
+ `# Do not remove below environment variables.`,
923
+ `NODE_PRESERVE_SYMLINKS=1`,
924
+ `NODE_ENV=production`,
925
+ ``,
926
+ `# API Maker admin panel frontend will try to connect to backend on this host and "am__port" will be appended automatically.`,
927
+ `BE_HOST_PORT="${BE_HOST_PORT}" # 👈 http://127.0.0.1:38246 or https://example.com`,
928
+ ``,
929
+ `# Required environment variables. You can set them in package.json also and remove from here.`,
930
+ `am__serverName=${serverName} # To go inside the object in package.json am, you can use "__" double underscore.`,
931
+ `am__processTitle=api_maker_be`,
932
+ `am__port=${this.am.portOriginal}`,
933
+ `am__wsPort=${this.am.portOriginalWS}`,
934
+ `am__cpuCount=AUTO`,
935
+ `am__mongo_db_connection="${mongoDBConnectionString}"`,
936
+ `am__redisInternal='${redisConnectionStringInternal}'`,
937
+ `${fullExternalString}`,
938
+ `am__passCommunication="${this.am.passCommunication}"`,
939
+ `am__passJWT="${this.am.passJWT}"`,
940
+ `am__passDBEncryptDecrypt="${this.am.passDBEncryptDecrypt}" # 👈 Set this random of 32 characters, it is used to encrypt/decrypt database & repository data.`,
941
+ ``,
942
+ ].join('\n'), { encoding: 'utf8' });
943
+ console.log(`✅ Env file written to ${envFilePath}`);
944
+ }
945
+ async getAPIMakerBackendPort() {
946
+ const defaultAMBEPort = 8080;
947
+ const prompt = new NumberPrompt({
948
+ message: ' Please enter port number to run API Maker backend service',
949
+ initial: defaultAMBEPort,
950
+ validate: async (userInput) => {
951
+ if (userInput < 2000)
952
+ return 'Port should be greater than 2000-60000';
953
+ else if (userInput > 60000)
954
+ return 'Port should be between 2000-60000';
955
+ else if (this.mongo.port === userInput)
956
+ return 'It should not be same as MongoDB port.';
957
+ else if (this.redis.port === userInput)
958
+ return 'It should not be same as Redis port.';
959
+ const isPortFree = await this.isGivenPortFree(userInput);
960
+ if (isPortFree)
961
+ return true;
962
+ else
963
+ return `Port ${userInput} is not free.`;
964
+ },
965
+ });
966
+ return isDefaultInstallation ? defaultAMBEPort : await prompt.run();
967
+ }
968
+ async getAPIMakerWSPort() {
969
+ const defaultWSPort = 8081;
970
+ const prompt = new NumberPrompt({
971
+ message: ' Please enter port number to run API Maker backend WebSocket service',
972
+ initial: defaultWSPort,
973
+ validate: async (userInput) => {
974
+ if (userInput < 2000)
975
+ return 'Port should be greater than 2000-60000';
976
+ else if (userInput > 60000)
977
+ return 'Port should be between 2000-60000';
978
+ else if (this.mongo.port === userInput)
979
+ return 'It should not be same as MongoDB port.';
980
+ else if (this.redis.port === userInput)
981
+ return 'It should not be same as Redis port.';
982
+ else if (this.am.port === userInput || this.am.portOriginal === userInput || this.am.portOriginalWS === userInput)
983
+ return 'It should not be same as API Maker backend service port.';
984
+ const isPortFree = await this.isGivenPortFree(userInput);
985
+ if (isPortFree)
986
+ return true;
987
+ else
988
+ return `Port ${userInput} is not free.`;
989
+ },
990
+ });
991
+ return isDefaultInstallation ? defaultWSPort : await prompt.run();
992
+ }
993
+ async getPassCommunication() {
994
+ let passCommunication;
995
+ let appendText = '';
996
+ if (this.config.installType === EInstallationType.PRIMARY) {
997
+ passCommunication = this.envFileD[EInstallEnv.am__passCommunication] || this.getRandomString(20);
998
+ }
999
+ else if (this.config.installType === EInstallationType.SECONDARY) {
1000
+ passCommunication = this.envFileD[EInstallEnv.am__passCommunication];
1001
+ appendText = ' (Use value of primary server)';
1002
+ }
1003
+ const prompt = new Input({
1004
+ message: ` Please provide passCommunication${appendText}`,
1005
+ initial: passCommunication,
1006
+ validate: (userInput) => {
1007
+ if (userInput.length < 20)
1008
+ return 'Minimum length should be 20';
1009
+ if (this.isAlphaNumericalValidPass(userInput))
1010
+ return true;
1011
+ return 'Password can only contain [a-z, A-Z, 0-9, _], special characters creates issue in setup automation process.';
1012
+ },
1013
+ });
1014
+ if (this.config.installType === EInstallationType.PRIMARY) {
1015
+ return isDefaultInstallation ? passCommunication : await prompt.run();
1016
+ }
1017
+ else if (this.config.installType === EInstallationType.SECONDARY) {
1018
+ return await prompt.run();
1019
+ }
1020
+ }
1021
+ async getPassJWT() {
1022
+ let passJWT;
1023
+ let appendText = '';
1024
+ if (this.config.installType === EInstallationType.PRIMARY) {
1025
+ passJWT = this.envFileD[EInstallEnv.am__passJWT] || this.getRandomString(20);
1026
+ }
1027
+ else if (this.config.installType === EInstallationType.SECONDARY) {
1028
+ passJWT = this.envFileD[EInstallEnv.am__passJWT];
1029
+ appendText = ' (Use value of primary server)';
1030
+ }
1031
+ const prompt = new Input({
1032
+ message: ` Please provide passJWT${appendText}`,
1033
+ initial: passJWT,
1034
+ validate: (userInput) => {
1035
+ if (userInput.length < 20)
1036
+ return 'Minimum length should be 20';
1037
+ if (this.isAlphaNumericalValidPass(userInput))
1038
+ return true;
1039
+ return 'Password can only contain [a-z, A-Z, 0-9, _], special characters creates issue in setup automation process.';
1040
+ },
1041
+ });
1042
+ if (this.config.installType === EInstallationType.PRIMARY) {
1043
+ return isDefaultInstallation ? passJWT : await prompt.run();
1044
+ }
1045
+ else if (this.config.installType === EInstallationType.SECONDARY) {
1046
+ return await prompt.run();
1047
+ }
1048
+ }
1049
+ async getPassDBEncryptDecrypt() {
1050
+ let passDB;
1051
+ let appendText = '';
1052
+ if (this.config.installType === EInstallationType.PRIMARY) {
1053
+ passDB = this.envFileD[EInstallEnv.am__passDBEncryptDecrypt] || this.getRandomString(32);
1054
+ }
1055
+ else if (this.config.installType === EInstallationType.SECONDARY) {
1056
+ passDB = this.envFileD[EInstallEnv.am__passDBEncryptDecrypt];
1057
+ appendText = ' (Use value of primary server)';
1058
+ }
1059
+ const prompt = new Input({
1060
+ message: ` Please provide passDBEncryptDecrypt 32 chars${appendText}`,
1061
+ initial: passDB,
1062
+ validate: (userInput) => {
1063
+ if (userInput.length !== 32)
1064
+ return 'Length should be 32 characters';
1065
+ if (this.isAlphaNumericalValidPass(userInput))
1066
+ return true;
1067
+ return 'Password can only contain [a-z, A-Z, 0-9, _], special characters creates issue in setup automation process.';
1068
+ },
1069
+ });
1070
+ if (this.config.installType === EInstallationType.PRIMARY) {
1071
+ return isDefaultInstallation ? passDB : await prompt.run();
1072
+ }
1073
+ else if (this.config.installType === EInstallationType.SECONDARY) {
1074
+ return await prompt.run();
1075
+ }
1076
+ }
1077
+ async getSecondaryServerName() {
1078
+ const serverName = this.envFileD[EInstallEnv.am__serverName];
1079
+ const prompt = new Input({
1080
+ message: ` Please provide secondary server name`,
1081
+ initial: serverName || 'Secondary_1',
1082
+ validate: (userInput) => {
1083
+ if (!userInput || userInput.length < 2)
1084
+ return 'Please provide valid server name.';
1085
+ return true;
1086
+ },
1087
+ });
1088
+ return isDefaultInstallation ? serverName : await prompt.run();
1089
+ }
1090
+ async getSecondaryMongoDBConnectionString() {
1091
+ const mongoConnectionString = this.envFileD[EInstallEnv.am__mongo_db_connection];
1092
+ const prompt = new Input({
1093
+ message: ` Please provide API Maker's mongodb connection string`,
1094
+ initial: mongoConnectionString,
1095
+ validate: async (userInput) => {
1096
+ return await this.validateMongoDBConnectionString(userInput);
1097
+ },
1098
+ });
1099
+ return isDefaultInstallation ? mongoConnectionString : await prompt.run();
1100
+ }
1101
+ async getSecondaryRedisInternalConnectionString() {
1102
+ const internalRedisConnectionString = this.envFileD[EInstallEnv.am__redisInternal];
1103
+ const prompt = new Input({
1104
+ message: ` Please provide API Maker's internal redis connection string`,
1105
+ initial: internalRedisConnectionString,
1106
+ validate: async (userInput) => {
1107
+ return await this.canConnectToRedis(userInput);
1108
+ },
1109
+ });
1110
+ return isDefaultInstallation ? internalRedisConnectionString : await prompt.run();
1111
+ }
1112
+ async getSecondaryRedisExternalConnectionString() {
1113
+ const internalRedisConnectionString = this.envFileD[EInstallEnv.am__redisExternal];
1114
+ const prompt = new Input({
1115
+ message: ` Please provide External redis connection string (Optional)`,
1116
+ initial: internalRedisConnectionString,
1117
+ validate: async (userInput) => {
1118
+ return await this.canConnectToRedis(userInput);
1119
+ },
1120
+ });
1121
+ return isDefaultInstallation ? internalRedisConnectionString : await prompt.run();
1122
+ }
1123
+ // </editor-fold>
1124
+ async syncEnvDataInFrontend() {
1125
+ await globalData.SetEnvInFrontend.main(globalData.appRoot, path.join(this.HOME, 'config', '.env'));
1126
+ }
1127
+ async startAPIMakerBackendProcess() {
1128
+ this.showLoading('Starting API Maker backend...');
1129
+ const nodeProcessSizeShouldBe = this.getNodejsMaxOldSpaceValue();
1130
+ // Start command duplicate // Stop command duplicate
1131
+ this.config.stopAMCommand = `${this.NODE_HOME}/pm2 delete api_maker_be`;
1132
+ this.config.startAMCommand = `cd ${globalData.appRoot} && export PATH=${this.NODE_HOME}:/opt/oracle/instantclient:$PATH && ${this.NODE_HOME}/pm2 -a start main.js --node-args="--max-old-space-size=${nodeProcessSizeShouldBe}" --name api_maker_be --log "${this.HOME}/logs/api_maker_be.txt" --log-date-format 'DD-MM-YYYY HH:mm:ss Z' -- --envPath=${this.HOME}/config/.env`;
1133
+ await this.runCommandSilent([
1134
+ `cd ${globalData.appRoot}`,
1135
+ `${this.NODE_HOME}/pm2 kill`,
1136
+ `rm -rf ${this.HOME}/.pm2`,
1137
+ `${this.NODE_HOME}/pm2 --version || ${this.NODE_HOME}/npm install -g pm2@5.3.0`,
1138
+ `export PATH=${this.NODE_HOME}:/opt/oracle/instantclient:$PATH`,
1139
+ this.config.stopAMCommand,
1140
+ `rm -rf ${this.HOME}/logs/api_maker_be.txt`,
1141
+ this.config.startAMCommand,
1142
+ ].join('\n'), '/');
1143
+ this.hideLoading();
1144
+ console.log(`🚀 API Maker backend process started.`);
1145
+ }
1146
+ async isPort80Free() {
1147
+ const isPort80FreeOut = await this.isGivenPortFree(80);
1148
+ if (isPort80FreeOut)
1149
+ console.log(`✅ Port 80 is available.`);
1150
+ else {
1151
+ try {
1152
+ await this.runCommandSilent(`caddy version`, '/');
1153
+ await this.stopCaddy(false);
1154
+ }
1155
+ catch (e) {
1156
+ }
1157
+ const isPort80FreeOutTemp = await this.isGivenPortFree(80);
1158
+ if (!isPort80FreeOutTemp)
1159
+ throw new Error(`❌ Port 80 is not free.`);
1160
+ else
1161
+ console.log(`✅ Port 80 is available.`);
1162
+ }
1163
+ }
1164
+ async installCaddyIfNotInstalled() {
1165
+ try {
1166
+ const caddyVersionOutput = await this.runCommandSilent(`caddy version`, '/');
1167
+ console.log(`✅ ${caddyVersionOutput.trim()}`);
1168
+ }
1169
+ catch (e) {
1170
+ this.showLoading('Installing Caddy...');
1171
+ await this.runCommandSilent([
1172
+ `apt-get install -y debian-keyring=2021.12.24`,
1173
+ `apt-get install -y debian-archive-keyring=2021.1.1ubuntu2`,
1174
+ `apt-get install -y apt-transport-https=2.4.8`,
1175
+ ``,
1176
+ `curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor --batch --yes -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg`,
1177
+ `curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list`,
1178
+ `apt update -yq`,
1179
+ ``,
1180
+ `apt-get install -y caddy=2.6.4`,
1181
+ ].join('\n'), '/');
1182
+ this.hideLoading();
1183
+ console.log(`✅ Caddy installed`);
1184
+ }
1185
+ }
1186
+ calculateURLs() {
1187
+ // They are used to print at the end.
1188
+ if (this.config.installSSL) {
1189
+ this.config.fullUrlOfBE = `https://${this.config.beHost}`;
1190
+ this.config.fullUrlOfWS = `https://${this.config.beWSHost}`;
1191
+ }
1192
+ else {
1193
+ this.config.fullUrlOfBE = `http://${this.config.IP}:${this.am.port}`;
1194
+ this.config.fullUrlOfWS = `http://${this.config.IP}:${this.am.wsPort}`;
1195
+ }
1196
+ if (this.config.installType === EInstallationType.PRIMARY) {
1197
+ if (this.config.installSSL)
1198
+ this.config.fullUrlOfFE = `https://${this.config.feHost}`;
1199
+ else
1200
+ this.config.fullUrlOfFE = `http://${this.config.IP}:80`;
1201
+ }
1202
+ }
1203
+ /**
1204
+ * Installation process overrides Caddyfile.
1205
+ *
1206
+ * Get JSON from caddyfile using below tool
1207
+ * https://caddapto.vercel.app/
1208
+ *
1209
+ * caddy adapt —config Caddyfile —adapter Caddyfile
1210
+ * -- It will print JSON output of Caddyfile.
1211
+ * caddy adapt --config /path/to/Caddyfile --pretty
1212
+ *
1213
+ */
1214
+ async writeCaddyFile() {
1215
+ const caddyFilePath = path.join(this.HOME, 'config', this.CADDY_FILE_NAME);
1216
+ let feSection = [];
1217
+ const secondaryBackends = await this.getExistingSecondaryServers(this.am.portOriginal);
1218
+ const secondaryBackendsWS = await this.getExistingSecondaryServers(this.am.portOriginalWS);
1219
+ if (this.config.installType === EInstallationType.PRIMARY) {
1220
+ feSection = [
1221
+ `${this.config.fullUrlOfFE} {`,
1222
+ ` root * ${globalData.appRoot}/dist`,
1223
+ ` file_server`,
1224
+ ` encode zstd gzip`,
1225
+ ` try_files {path} /`,
1226
+ `}`,
1227
+ ];
1228
+ }
1229
+ await fs.promises.writeFile(caddyFilePath, [
1230
+ ``,
1231
+ `{`,
1232
+ ` # Disable admin API`,
1233
+ ` admin off`,
1234
+ ``,
1235
+ ` log {`,
1236
+ ` level ERROR`,
1237
+ ` output discard`,
1238
+ ` }`,
1239
+ `}`,
1240
+ ``,
1241
+ `${this.config.fullUrlOfBE} {`,
1242
+ ` reverse_proxy 127.0.0.1:${this.am.portOriginal} ${secondaryBackends}`,
1243
+ `}`,
1244
+ ``,
1245
+ `${this.config.fullUrlOfWS} {`,
1246
+ ` reverse_proxy 127.0.0.1:${this.am.portOriginalWS} ${secondaryBackendsWS}`,
1247
+ `}`,
1248
+ ``,
1249
+ ...feSection,
1250
+ ``,
1251
+ ``,
1252
+ ].join('\n'), { encoding: 'utf8' });
1253
+ console.log(` ✔ [Write] : ${caddyFilePath}`);
1254
+ if (secondaryBackends)
1255
+ console.log(` ✔ [Secondary Servers BE] : ${secondaryBackends}`);
1256
+ if (secondaryBackends)
1257
+ console.log(` ✔ [Secondary Servers WS] : ${secondaryBackendsWS}`);
1258
+ }
1259
+ async getExistingSecondaryServers(port) {
1260
+ const caddyFilePath = path.join(this.HOME, 'config', this.CADDY_FILE_NAME);
1261
+ let secondaryServers = '';
1262
+ const reverseProxyLine = `reverse_proxy 127.0.0.1:${port}`;
1263
+ if (fs.existsSync(caddyFilePath)) {
1264
+ const content = fs.readFileSync(caddyFilePath, { encoding: 'utf8' });
1265
+ const lines = content.split('\n');
1266
+ for (const line of lines) {
1267
+ if (line.indexOf(reverseProxyLine) >= 0) {
1268
+ secondaryServers = line.replace(reverseProxyLine, '').trim();
1269
+ }
1270
+ }
1271
+ }
1272
+ return secondaryServers;
1273
+ }
1274
+ async restartCaddy() {
1275
+ const caddyConfigPath = path.join(this.HOME, 'config', this.CADDY_FILE_NAME);
1276
+ await this.stopCaddy(false);
1277
+ // caddy run --config caddyfile.json // this is working fine for json file no need to pass jsonc adapter.
1278
+ this.runCommandSilent([
1279
+ `/usr/bin/caddy start --config ${caddyConfigPath}`,
1280
+ ].join('\n'), '/').then();
1281
+ console.log(`✅ ${caddyConfigPath}`);
1282
+ }
1283
+ async stopCaddy(printStopLog) {
1284
+ try {
1285
+ await this.runCommandSilent([
1286
+ `/usr/bin/caddy stop > /dev/null`,
1287
+ `/usr/bin/systemctl stop caddy > /dev/null`,
1288
+ `pkill caddy`,
1289
+ ].join('\n'), '/');
1290
+ await this.sleep(2000);
1291
+ if (printStopLog)
1292
+ console.log(`✅ Caddy service stopped and ports released.`);
1293
+ }
1294
+ catch (e) {
1295
+ }
1296
+ }
1297
+ async startPM2ProcessOnRestart() {
1298
+ await this.runCommandSilent([
1299
+ `export PATH=${this.NODE_HOME}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin`,
1300
+ `${this.NODE_HOME}/pm2 startup`,
1301
+ `systemctl enable pm2-root`,
1302
+ `${this.NODE_HOME}/pm2 save`,
1303
+ ].join('\n'), '/');
1304
+ }
1305
+ async printPM2ProcessList() {
1306
+ const pm2List = await this.runCommandSilent([
1307
+ `${this.NODE_HOME}/pm2 list`,
1308
+ ].join('\n'), '/');
1309
+ console.log('');
1310
+ console.log(pm2List);
1311
+ }
1312
+ printAllSetupConfigurations() {
1313
+ console.log('\n');
1314
+ console.log(colors.cyan(`———— # Setup Configurations (Saved in ${this.HOME}/config/.env file) ————`));
1315
+ let onlyPrimaryFields = {};
1316
+ if (this.config.installType === EInstallationType.PRIMARY) {
1317
+ onlyPrimaryFields = {
1318
+ 'MongoDB Port': this.mongo.port,
1319
+ 'MongoDB Username': this.mongo.username,
1320
+ 'MongoDB Password': this.mongo.password,
1321
+ 'Redis Port': this.redis.port,
1322
+ 'Redis Password': this.redis.password,
1323
+ 'AM Frontend Port': this.config.installSSL ? '443' : '80',
1324
+ };
1325
+ }
1326
+ console.table({
1327
+ 'Installation Directory': globalData.appRoot,
1328
+ 'Config Directory': `${this.HOME}/config`,
1329
+ 'Logs Directory': `${this.HOME}/logs`,
1330
+ 'Docker Data Directory': `${this.HOME}/docker-data`,
1331
+ '—————————————————————————————': `—————————————————————————————`,
1332
+ IP: this.config.IP,
1333
+ ...onlyPrimaryFields,
1334
+ 'AM Port': this.am.port,
1335
+ 'AM WebSocket Port': this.am.wsPort,
1336
+ 'Pass Communication': this.am.passCommunication,
1337
+ 'Password JWT': this.am.passJWT,
1338
+ 'Password DB Encrypt Decrypt': this.am.passDBEncryptDecrypt,
1339
+ });
1340
+ }
1341
+ printEndpointSummary() {
1342
+ console.log('');
1343
+ console.log(colors.cyan('———— # Important URLs ————'));
1344
+ const parsedUrl = new URL(this.config.fullUrlOfWS);
1345
+ let onlyPrimaryFields = {};
1346
+ if (this.config.installType === EInstallationType.PRIMARY) {
1347
+ onlyPrimaryFields = {
1348
+ 'Frontend Admin Panel': this.config.fullUrlOfFE,
1349
+ };
1350
+ }
1351
+ console.table({
1352
+ ...onlyPrimaryFields,
1353
+ 'Backend APIs': this.config.fullUrlOfBE,
1354
+ 'Backend WebSocket endpoint': this.config.installSSL ? `wss://${parsedUrl.hostname}` : `ws://${parsedUrl.hostname}:${this.am.wsPort}`,
1355
+ });
1356
+ }
1357
+ printDefaultUsers() {
1358
+ console.log('\n');
1359
+ console.log(colors.cyan('———— # Default User Credentials ————'));
1360
+ console.table({
1361
+ 'root@root.com': `R00t_123456789`,
1362
+ 'admin@admin.com': `Admin_123456789`,
1363
+ });
1364
+ }
1365
+ printStartAndStopCommands() {
1366
+ console.log('\n');
1367
+ console.log(colors.cyan('———— # Commands to start/stop API Maker processes ————'));
1368
+ console.log('————————————————————————————————————————————————————————————————');
1369
+ console.log(`[START] : ${this.config.startAMCommand}`);
1370
+ console.log('');
1371
+ console.log(`[STOP] : ${this.config.stopAMCommand}`);
1372
+ console.log('————————————————————————————————————————————————————————————————');
1373
+ }
1374
+ printSecondaryServerAttachInformation() {
1375
+ let beHostPort, wsHostPort;
1376
+ if (this.config.installSSL) {
1377
+ beHostPort = `${this.config.beHost}:${this.am.portOriginal}`;
1378
+ wsHostPort = `${this.config.beWSHost}:${this.am.portOriginalWS}`;
1379
+ }
1380
+ else {
1381
+ beHostPort = `${this.config.IP}:${this.am.portOriginal}`;
1382
+ wsHostPort = `${this.config.IP}:${this.am.portOriginalWS}`;
1383
+ }
1384
+ const caddyConfigPath = path.join(this.HOME, 'config', this.CADDY_FILE_NAME);
1385
+ const caddyStartCommand = `/usr/bin/caddy start --config ${caddyConfigPath}`;
1386
+ const caddyStartCommandForeground = `/usr/bin/caddy run --config ${caddyConfigPath}`;
1387
+ console.log('\n');
1388
+ console.log(colors.red('———— # Attach secondary server to primary server ————'));
1389
+ console.log('————————————————————————————————————————————————————————————————');
1390
+ console.log(`👉 You can directly hit APIs of this secondary server.`);
1391
+ console.log(` Although if you want to keep one endpoint for all APIs, modify one line in "~/config/Caddyfile" of primary server as below.`);
1392
+ console.log(`[CHANGE] : "reverse_proxy 127.0.0.1:38246" -> "reverse_proxy 127.0.0.1:38246 __all_secondary_servers_list__"`);
1393
+ console.log(`[CHANGE] : "reverse_proxy 127.0.0.1:38245" -> "reverse_proxy 127.0.0.1:38245 __all_secondary_servers_ws_list__"`);
1394
+ console.log(colors.yellow(`———————————— Example ————————————`));
1395
+ console.log(`[Ex 1] : "reverse_proxy 127.0.0.1:38246" -> "reverse_proxy 127.0.0.1:38246 ${beHostPort} example1.com:38246 172.105.48.196:38246"`);
1396
+ console.log(`[Ex 2] : "reverse_proxy 127.0.0.1:38245" -> "reverse_proxy 127.0.0.1:38245 ${wsHostPort} example1.com:38245 172.105.48.196:38245"`);
1397
+ console.log(colors.yellow(`———————————— Caddy stop & start commands to run in primary server ————————————`));
1398
+ console.log(`# Caddy server stop commands `);
1399
+ console.log(`/usr/bin/caddy stop > /dev/null`);
1400
+ console.log(`/usr/bin/systemctl stop caddy > /dev/null`);
1401
+ console.log(`pkill caddy`);
1402
+ console.log(`# Caddy server start commands`);
1403
+ console.log(`${caddyStartCommand}`);
1404
+ console.log(`# ${caddyStartCommandForeground}`);
1405
+ console.log('————————————————————————————————————————————————————————————————');
1406
+ }
1407
+ // <editor-fold desc="Utility Functions">
1408
+ showLoading(text) {
1409
+ this.load = loading(colors.green(` ${text}`)).start();
1410
+ }
1411
+ hideLoading() {
1412
+ this.load.stop();
1413
+ }
1414
+ runCommandSilent(runCommand, workingDir) {
1415
+ return new Promise((resolve, reject) => {
1416
+ if (runCommand) {
1417
+ const options = {};
1418
+ if (workingDir)
1419
+ options.cwd = workingDir;
1420
+ child_process.exec(runCommand, options, (error, stdout, stderr) => {
1421
+ if (error) {
1422
+ reject(error);
1423
+ }
1424
+ else if (stderr) {
1425
+ resolve(undefined);
1426
+ }
1427
+ else {
1428
+ resolve(stdout);
1429
+ }
1430
+ });
1431
+ }
1432
+ else
1433
+ resolve(undefined);
1434
+ });
1435
+ }
1436
+ async download(url) {
1437
+ const response = await fetch(url);
1438
+ return response.text();
1439
+ }
1440
+ ;
1441
+ getRandomString(size) {
1442
+ let result = '';
1443
+ const charactersLength = this.characters.length;
1444
+ for (let i = 0; i < size; i++)
1445
+ result += this.characters.charAt(Math.floor(Math.random() * charactersLength));
1446
+ return result;
1447
+ }
1448
+ isAlphaNumericalValidPass(userInput) {
1449
+ const strRegex = /^[a-z0-9_A-Z]+$/i;
1450
+ return strRegex.test(userInput);
1451
+ }
1452
+ isValidIpAddress(ipaddress) {
1453
+ return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress);
1454
+ }
1455
+ isGivenPortFree(port) {
1456
+ return new Promise((resolve) => {
1457
+ const net = require('net');
1458
+ const server = net.createServer();
1459
+ server.once('error', function () {
1460
+ resolve(false);
1461
+ });
1462
+ server.once('listening', function () {
1463
+ server.close();
1464
+ resolve(true);
1465
+ });
1466
+ server.listen(port);
1467
+ });
1468
+ }
1469
+ async getValidHostFromUser(userInput) {
1470
+ if (this.isValidIpAddress(userInput))
1471
+ return 'Host should not be IP address. It should be domain name.';
1472
+ if (userInput.startsWith('https')) {
1473
+ const urlTemp = new URL(userInput);
1474
+ return `Please provide domain name without protocol. ex: ${urlTemp.hostname}`;
1475
+ }
1476
+ const pingError = `"ping -c 1 ${userInput}" should point to this "${this.config.IP}" IP address.`;
1477
+ try {
1478
+ const pingOutput = await this.runCommandSilent(`ping -c 1 ${userInput}`, '/');
1479
+ if (pingOutput.indexOf(this.config.IP) >= 0)
1480
+ return true;
1481
+ else
1482
+ return pingError;
1483
+ }
1484
+ catch (e) {
1485
+ return pingError;
1486
+ }
1487
+ }
1488
+ async sleep(millis) {
1489
+ return new Promise((resolve) => {
1490
+ setTimeout(() => {
1491
+ resolve();
1492
+ }, millis);
1493
+ });
1494
+ }
1495
+ /**
1496
+ * MB = bytes/(1024 * 1024)
1497
+ * Get value in MB
1498
+ */
1499
+ getNodejsMaxOldSpaceValue() {
1500
+ const cpuCount = os.cpus().length;
1501
+ const memory = os.totalmem(); // It is multiplied by 1024.
1502
+ const memoryForOneCpu = Math.ceil(memory / cpuCount);
1503
+ const calculatedValue = Math.ceil(((75 * memoryForOneCpu) / 100) / (1024 * 1024));
1504
+ if (calculatedValue <= 800)
1505
+ return 1024;
1506
+ else
1507
+ return calculatedValue;
1508
+ }
1509
+ async validateMongoDBConnectionString(connString) {
1510
+ try {
1511
+ const client = await mongodb.MongoClient.connect(connString, {});
1512
+ return true;
1513
+ }
1514
+ catch (e) {
1515
+ return e.message; // It is working fine with address not found error.
1516
+ }
1517
+ }
1518
+ // Duplicate : canConnectToRedis
1519
+ canConnectToRedis(connString) {
1520
+ const connectionObj = JSON5.parse(connString);
1521
+ return new Promise((resolve) => {
1522
+ let resolved = false;
1523
+ const tempResolve = (value) => {
1524
+ if (resolved)
1525
+ return;
1526
+ else {
1527
+ resolved = true;
1528
+ resolve(value);
1529
+ }
1530
+ };
1531
+ try {
1532
+ let redisConnection;
1533
+ if (connectionObj.nodes?.length > 1) {
1534
+ const commonClusterOptions = { clusterRetryStrategy: this.getRetryStrategySilent };
1535
+ redisConnection = new ioredis_1.default.Cluster(connectionObj.nodes, {
1536
+ enableOfflineQueue: false,
1537
+ enableReadyCheck: false,
1538
+ ...commonClusterOptions,
1539
+ });
1540
+ }
1541
+ else if (connectionObj.nodes?.length === 1) {
1542
+ redisConnection = new ioredis_1.default({
1543
+ port: connectionObj?.nodes?.[0]?.port,
1544
+ host: connectionObj?.nodes?.[0]?.host,
1545
+ password: connectionObj?.nodes?.[0]?.pass,
1546
+ autoResendUnfulfilledCommands: false,
1547
+ retryStrategy: this.getRetryStrategy,
1548
+ reconnectOnError() {
1549
+ return false;
1550
+ },
1551
+ enableReadyCheck: false,
1552
+ });
1553
+ }
1554
+ else
1555
+ tempResolve('Invalid details provided for redis connection.');
1556
+ redisConnection.on('error', (e) => {
1557
+ tempResolve(e.message);
1558
+ this.closeRedisConnection(redisConnection);
1559
+ });
1560
+ redisConnection.on('connect', (input) => {
1561
+ if (connectionObj?.nodes?.[0]?.pass) {
1562
+ redisConnection.auth(connectionObj?.nodes?.[0]?.pass, (err, res) => {
1563
+ if (err) {
1564
+ tempResolve(err.message);
1565
+ this.closeRedisConnection(redisConnection);
1566
+ }
1567
+ else {
1568
+ tempResolve(true);
1569
+ this.closeRedisConnection(redisConnection);
1570
+ }
1571
+ });
1572
+ }
1573
+ else {
1574
+ tempResolve(true);
1575
+ this.closeRedisConnection(redisConnection);
1576
+ }
1577
+ });
1578
+ }
1579
+ catch (e) {
1580
+ tempResolve(e.message);
1581
+ }
1582
+ });
1583
+ }
1584
+ // Duplicate : canConnectToRedis
1585
+ closeRedisConnection(redisConn) {
1586
+ try {
1587
+ redisConn.quit();
1588
+ redisConn.disconnect();
1589
+ redisConn.removeAllListeners('error');
1590
+ redisConn.removeAllListeners('connect');
1591
+ }
1592
+ catch (e) {
1593
+ }
1594
+ }
1595
+ // Duplicate : canConnectToRedis
1596
+ getRetryStrategy(times) {
1597
+ console.log(`[${new Date().toISOString()}] Redis retry attempt ${times}`);
1598
+ return 5000;
1599
+ }
1600
+ // Duplicate : canConnectToRedis
1601
+ getRetryStrategySilent(times) {
1602
+ return 5000;
1603
+ }
1604
+ testEmojiWidth() {
1605
+ console.log(`✴️ Disk size is not good enough`);
1606
+ console.log(`✅ Disk size is good enoug`);
1607
+ console.log(`❌ Please provide root user.`);
1608
+ console.log(`☑️ Redis install skipped. Old connection st`);
1609
+ console.log(`👍 Redis install skipped. Old connection st`);
1610
+ console.log(`⚠️ [Ubuntu 22 | Ubuntu 20 | Ubuntu 23] not found, but you can try.`);
1611
+ console.log(`👉 If docker installation fails, try installing docker manually and try again.`);
1612
+ console.log(`🟦 Default Installation selected`);
1613
+ console.log(`🚀 API Maker backend process started.`);
1614
+ console.log('❤️ Thank you for using API Maker, Enjoy !! ❤️');
1615
+ console.log(`🖇️ Secondary server installation type.`);
1616
+ }
1617
+ }
1618
+ var EInstallEnv;
1619
+ (function (EInstallEnv) {
1620
+ EInstallEnv["am__serverName"] = "am__serverName";
1621
+ EInstallEnv["am__mongo_db_connection"] = "am__mongo_db_connection";
1622
+ EInstallEnv["am__redisInternal"] = "am__redisInternal";
1623
+ EInstallEnv["am__redisExternal"] = "am__redisExternal";
1624
+ EInstallEnv["am__passCommunication"] = "am__passCommunication";
1625
+ EInstallEnv["am__passJWT"] = "am__passJWT";
1626
+ EInstallEnv["am__passDBEncryptDecrypt"] = "am__passDBEncryptDecrypt";
1627
+ // Do not use below because user inputs are in Caddyfile, and we are not reading that.
1628
+ // am__port = 'am__port',
1629
+ // am__wsPort = 'am__wsPort',
1630
+ })(EInstallEnv || (EInstallEnv = {}));
1631
+ var EInstallationType;
1632
+ (function (EInstallationType) {
1633
+ EInstallationType["PRIMARY"] = "PRIMARY";
1634
+ EInstallationType["SECONDARY"] = "SECONDARY";
1635
+ })(EInstallationType || (EInstallationType = {}));
1636
+ (new InstallFromWeb()).main().then();