zcatalyst-cli 1.20.2 → 1.22.0

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 (654) hide show
  1. package/README.md +7 -5
  2. package/lib/api-timer.d.ts +17 -0
  3. package/lib/api-timer.js +2 -2
  4. package/lib/apig-utils.d.ts +41 -0
  5. package/lib/apig-utils.js +32 -32
  6. package/lib/appsail-utils.d.ts +3 -0
  7. package/lib/appsail-utils.js +116 -12
  8. package/lib/archiver.d.ts +47 -0
  9. package/lib/archiver.js +6 -6
  10. package/lib/authentication/constants/auth.d.ts +21 -0
  11. package/lib/authentication/constants/auth.js +37 -0
  12. package/lib/authentication/constants/scopes.d.ts +81 -0
  13. package/lib/{util_modules/constants/lib → authentication/constants}/scopes.js +4 -1
  14. package/lib/authentication/credential.d.ts +39 -0
  15. package/lib/{internal → authentication}/credential.js +63 -46
  16. package/lib/authentication/crypt.d.ts +13 -0
  17. package/lib/authentication/error.d.ts +4 -0
  18. package/lib/authentication/error.js +14 -0
  19. package/lib/authentication/index.d.ts +5 -0
  20. package/lib/authentication/index.js +65 -63
  21. package/lib/authentication/login.d.ts +46 -0
  22. package/lib/authentication/login.js +147 -105
  23. package/lib/authentication/revoke.d.ts +9 -0
  24. package/lib/bin/catalyst.d.ts +2 -0
  25. package/lib/bin/catalyst.js +80 -36
  26. package/lib/cli_table/index.js +3 -2
  27. package/lib/client-utils.d.ts +16 -0
  28. package/lib/client-utils.js +57 -50
  29. package/lib/client.d.ts +21 -0
  30. package/lib/client.js +93 -6
  31. package/lib/code-deck.d.ts +21 -0
  32. package/lib/command_needs/auth.d.ts +2 -0
  33. package/lib/command_needs/auth.js +25 -24
  34. package/lib/command_needs/config.d.ts +4 -0
  35. package/lib/command_needs/rc.d.ts +8 -0
  36. package/lib/command_needs/rc.js +24 -24
  37. package/lib/commands/apig/disable.d.ts +3 -0
  38. package/lib/commands/apig/disable.js +8 -8
  39. package/lib/commands/apig/enable.d.ts +3 -0
  40. package/lib/commands/apig/enable.js +8 -8
  41. package/lib/commands/apig/status.d.ts +18 -0
  42. package/lib/commands/apig/status.js +12 -12
  43. package/lib/commands/appsail/add.d.ts +3 -0
  44. package/lib/commands/appsail/add.js +7 -6
  45. package/lib/commands/appsail/unlink.d.ts +3 -0
  46. package/lib/commands/appsail/unlink.js +43 -0
  47. package/lib/commands/client/delete.d.ts +3 -0
  48. package/lib/commands/client/delete.js +19 -19
  49. package/lib/commands/client/setup.d.ts +3 -0
  50. package/lib/commands/client/setup.js +6 -5
  51. package/lib/commands/codelib/install.d.ts +3 -0
  52. package/lib/commands/codelib/install.js +15 -15
  53. package/lib/commands/config/delete.d.ts +3 -0
  54. package/lib/commands/config/delete.js +2 -2
  55. package/lib/commands/config/get.d.ts +3 -0
  56. package/lib/commands/config/get.js +2 -2
  57. package/lib/commands/config/list.d.ts +3 -0
  58. package/lib/commands/config/list.js +2 -2
  59. package/lib/commands/config/set.d.ts +3 -0
  60. package/lib/commands/config/set.js +2 -2
  61. package/lib/commands/deploy/appsail.d.ts +3 -0
  62. package/lib/commands/deploy/appsail.js +11 -9
  63. package/lib/commands/deploy/index.d.ts +3 -0
  64. package/lib/commands/deploy/index.js +45 -26
  65. package/lib/commands/deploy/slate.d.ts +3 -0
  66. package/lib/commands/deploy/slate.js +2 -2
  67. package/lib/commands/ds/export.d.ts +3 -0
  68. package/lib/commands/ds/export.js +9 -9
  69. package/lib/commands/ds/import.d.ts +3 -0
  70. package/lib/commands/ds/import.js +13 -13
  71. package/lib/commands/ds/status.d.ts +23 -0
  72. package/lib/commands/ds/status.js +12 -11
  73. package/lib/commands/event/generate/index.d.ts +3 -0
  74. package/lib/commands/event/generate/index.js +5 -186
  75. package/lib/commands/event/generate/integ.d.ts +3 -0
  76. package/lib/commands/event/generate/integ.js +4 -4
  77. package/lib/commands/event/generate/job.d.ts +3 -0
  78. package/lib/commands/functions/add.d.ts +3 -0
  79. package/lib/commands/functions/add.js +6 -5
  80. package/lib/commands/functions/config.d.ts +3 -0
  81. package/lib/commands/functions/config.js +5 -5
  82. package/lib/commands/functions/delete.d.ts +3 -0
  83. package/lib/commands/functions/delete.js +19 -18
  84. package/lib/commands/functions/execute.d.ts +3 -0
  85. package/lib/commands/functions/execute.js +202 -0
  86. package/lib/commands/functions/setup.d.ts +3 -0
  87. package/lib/commands/functions/setup.js +6 -5
  88. package/lib/commands/functions/shell.d.ts +3 -0
  89. package/lib/commands/functions/shell.js +32 -28
  90. package/lib/commands/help.d.ts +3 -0
  91. package/lib/commands/help.js +4 -4
  92. package/lib/commands/iac/export.d.ts +3 -0
  93. package/lib/commands/iac/export.js +9 -8
  94. package/lib/commands/iac/import.d.ts +6 -0
  95. package/lib/commands/iac/import.js +23 -22
  96. package/lib/commands/iac/pack.d.ts +3 -0
  97. package/lib/commands/iac/pack.js +13 -13
  98. package/lib/commands/iac/status.d.ts +3 -0
  99. package/lib/commands/iac/status.js +4 -4
  100. package/lib/commands/index.d.ts +3 -0
  101. package/lib/commands/index.js +74 -61
  102. package/lib/commands/init.d.ts +3 -0
  103. package/lib/commands/init.js +17 -11
  104. package/lib/commands/login.d.ts +3 -0
  105. package/lib/commands/login.js +2 -2
  106. package/lib/commands/logout.d.ts +3 -0
  107. package/lib/commands/logout.js +1 -1
  108. package/lib/commands/project/list.d.ts +3 -0
  109. package/lib/commands/project/list.js +7 -6
  110. package/lib/commands/project/reset.d.ts +3 -0
  111. package/lib/commands/project/reset.js +5 -5
  112. package/lib/commands/project/use.d.ts +3 -0
  113. package/lib/commands/project/use.js +13 -11
  114. package/lib/commands/pull.d.ts +3 -0
  115. package/lib/commands/pull.js +16 -15
  116. package/lib/commands/run.d.ts +3 -0
  117. package/lib/commands/run.js +9 -9
  118. package/lib/commands/serve.d.ts +3 -0
  119. package/lib/commands/signals/generate/index.d.ts +3 -0
  120. package/lib/commands/slate/create.d.ts +3 -0
  121. package/lib/commands/slate/create.js +2 -2
  122. package/lib/commands/slate/link.d.ts +3 -0
  123. package/lib/commands/slate/link.js +5 -5
  124. package/lib/commands/slate/unlink.d.ts +3 -0
  125. package/lib/commands/slate/unlink.js +2 -2
  126. package/lib/commands/token/generate.d.ts +3 -0
  127. package/lib/commands/token/generate.js +4 -3
  128. package/lib/commands/token/list.d.ts +3 -0
  129. package/lib/commands/token/list.js +4 -3
  130. package/lib/commands/token/revoke.d.ts +3 -0
  131. package/lib/commands/token/revoke.js +3 -3
  132. package/lib/commands/whoami.d.ts +3 -0
  133. package/lib/commands/whoami.js +8 -8
  134. package/lib/commands/zest/generate/index.d.ts +14 -0
  135. package/lib/commands/zest/generate/index.js +1 -2
  136. package/lib/deploy/features/apig.d.ts +2 -0
  137. package/lib/deploy/features/apig.js +11 -11
  138. package/lib/deploy/features/appsail/index.d.ts +3 -0
  139. package/lib/deploy/features/appsail/index.js +82 -194
  140. package/lib/deploy/features/appsail/pack.d.ts +14 -0
  141. package/lib/deploy/features/appsail/pack.js +130 -0
  142. package/lib/deploy/features/appsail/utils.d.ts +15 -0
  143. package/lib/deploy/features/appsail/utils.js +163 -17
  144. package/lib/deploy/features/client.d.ts +2 -0
  145. package/lib/deploy/features/client.js +5 -4
  146. package/lib/deploy/features/functions/index.d.ts +2 -0
  147. package/lib/deploy/features/functions/index.js +41 -32
  148. package/lib/deploy/features/functions/languages/index.d.ts +4 -0
  149. package/lib/deploy/features/functions/languages/index.js +14 -1
  150. package/lib/deploy/features/functions/utils.d.ts +1 -0
  151. package/lib/deploy/features/functions/utils.js +136 -0
  152. package/lib/deploy/features/index.d.ts +8 -0
  153. package/lib/deploy/features/slate.d.ts +5 -0
  154. package/lib/deploy/features/slate.js +15 -8
  155. package/lib/deploy/index.d.ts +6 -0
  156. package/lib/deploy/index.js +12 -11
  157. package/lib/deploy/util.d.ts +7 -0
  158. package/lib/deploy/util.js +22 -0
  159. package/lib/docs/commands/functions/execute.toml +29 -0
  160. package/lib/docs/endpoints/lib/git-hub.toml +3 -0
  161. package/lib/docs/fn-utils/lib/java/classpath.toml +9 -0
  162. package/lib/docs/fn-utils/lib/java/ensure-java-userconfig.toml +24 -0
  163. package/lib/docs/fn-utils/lib/java/index.toml +15 -0
  164. package/{docs → lib/docs}/option-filter.toml +12 -3
  165. package/lib/docs/util_modules/container.toml +6 -0
  166. package/{docs → lib/docs}/util_modules/project.toml +1 -1
  167. package/lib/endpoints/index.d.ts +119 -0
  168. package/lib/endpoints/index.js +32 -25
  169. package/lib/endpoints/lib/apig.d.ts +17 -0
  170. package/lib/endpoints/lib/apig.js +12 -12
  171. package/lib/endpoints/lib/applogic.d.ts +21 -0
  172. package/lib/endpoints/lib/applogic.js +10 -10
  173. package/lib/endpoints/lib/appsail.d.ts +64 -0
  174. package/lib/endpoints/lib/appsail.js +94 -5
  175. package/lib/endpoints/lib/cache.d.ts +12 -0
  176. package/lib/endpoints/lib/cache.js +8 -8
  177. package/lib/endpoints/lib/catalyst-details.d.ts +8 -0
  178. package/lib/endpoints/lib/catalyst-details.js +2 -2
  179. package/lib/endpoints/lib/client.d.ts +16 -0
  180. package/lib/endpoints/lib/client.js +12 -12
  181. package/lib/endpoints/lib/code-deck.d.ts +10 -0
  182. package/lib/endpoints/lib/code-deck.js +3 -3
  183. package/lib/endpoints/lib/common.d.ts +5 -0
  184. package/lib/endpoints/lib/common.js +2 -2
  185. package/lib/endpoints/lib/datastore.d.ts +11 -0
  186. package/lib/endpoints/lib/datastore.js +6 -6
  187. package/lib/endpoints/lib/ds-bulk.d.ts +46 -0
  188. package/lib/endpoints/lib/ds-bulk.js +12 -12
  189. package/lib/endpoints/lib/env.d.ts +8 -0
  190. package/lib/endpoints/lib/env.js +5 -5
  191. package/lib/endpoints/lib/event-bus.d.ts +10 -0
  192. package/lib/endpoints/lib/event-bus.js +4 -4
  193. package/lib/endpoints/lib/filestore.d.ts +13 -0
  194. package/lib/endpoints/lib/filestore.js +6 -6
  195. package/lib/endpoints/lib/functions.d.ts +24 -0
  196. package/lib/endpoints/lib/functions.js +14 -14
  197. package/lib/endpoints/lib/git-hub.d.ts +16 -0
  198. package/lib/endpoints/lib/git-hub.js +15 -2
  199. package/lib/endpoints/lib/iac.d.ts +43 -0
  200. package/lib/endpoints/lib/iac.js +20 -20
  201. package/lib/endpoints/lib/job-scheduling.d.ts +43 -0
  202. package/lib/endpoints/lib/job-scheduling.js +2 -2
  203. package/lib/endpoints/lib/log.d.ts +10 -0
  204. package/lib/endpoints/lib/org.d.ts +13 -0
  205. package/lib/endpoints/lib/org.js +2 -2
  206. package/lib/endpoints/lib/project.d.ts +18 -0
  207. package/lib/endpoints/lib/project.js +11 -11
  208. package/lib/endpoints/lib/queue.d.ts +14 -0
  209. package/lib/endpoints/lib/queue.js +8 -8
  210. package/lib/endpoints/lib/sdk.d.ts +10 -0
  211. package/lib/endpoints/lib/sdk.js +5 -5
  212. package/lib/endpoints/lib/slate.d.ts +16 -0
  213. package/lib/endpoints/lib/slate.js +8 -24
  214. package/lib/endpoints/lib/stratus.d.ts +15 -0
  215. package/lib/endpoints/lib/tunnel.d.ts +38 -0
  216. package/lib/endpoints/lib/tunnel.js +5 -5
  217. package/lib/endpoints/lib/user.d.ts +8 -0
  218. package/lib/endpoints/lib/user.js +46 -0
  219. package/lib/endpoints/lib/zcql.d.ts +12 -0
  220. package/lib/endpoints/lib/zcql.js +4 -4
  221. package/lib/endpoints/lib/zest.d.ts +73 -0
  222. package/lib/error/context-help.d.ts +1 -0
  223. package/lib/{util_modules → error}/context-help.js +15 -18
  224. package/lib/error/index.d.ts +27 -0
  225. package/lib/{error.js → error/index.js} +18 -14
  226. package/lib/error/utils.d.ts +2 -0
  227. package/lib/error/utils.js +8 -0
  228. package/lib/errorOut.d.ts +3 -0
  229. package/lib/errorOut.js +10 -9
  230. package/lib/errorResponse.d.ts +4 -0
  231. package/lib/event_generate/cache.d.ts +2 -0
  232. package/lib/event_generate/cache.js +3 -3
  233. package/lib/event_generate/custom.d.ts +1 -0
  234. package/lib/event_generate/custom.js +2 -2
  235. package/lib/event_generate/datastore.d.ts +7 -0
  236. package/lib/event_generate/datastore.js +6 -6
  237. package/lib/event_generate/filestore.d.ts +2 -0
  238. package/lib/event_generate/filestore.js +2 -2
  239. package/lib/event_generate/github.d.ts +2 -0
  240. package/lib/event_generate/index.d.ts +2 -0
  241. package/lib/event_generate/index.js +196 -0
  242. package/lib/event_generate/integration/cliq.d.ts +2 -0
  243. package/lib/event_generate/integration/cliq.js +4 -4
  244. package/lib/event_generate/stratus.d.ts +2 -0
  245. package/lib/event_generate/user.d.ts +2 -0
  246. package/lib/event_generate/webapp.d.ts +2 -0
  247. package/lib/execute/caller.d.ts +14 -0
  248. package/lib/execute/caller.js +155 -0
  249. package/lib/execute/index.d.ts +3 -0
  250. package/lib/execute/index.js +87 -0
  251. package/lib/execute-script.d.ts +6 -0
  252. package/lib/execute-script.js +62 -32
  253. package/lib/express_middlewares/apig-matcher.d.ts +3 -0
  254. package/lib/express_middlewares/auth-checker.d.ts +3 -0
  255. package/lib/express_middlewares/authenticator.d.ts +3 -0
  256. package/lib/express_middlewares/authenticator.js +3 -2
  257. package/lib/express_middlewares/cookie-parser.d.ts +3 -0
  258. package/lib/express_middlewares/error-handler.d.ts +3 -0
  259. package/lib/express_middlewares/logger.d.ts +5 -0
  260. package/lib/express_middlewares/logger.js +3 -2
  261. package/lib/express_middlewares/project.d.ts +6 -0
  262. package/lib/express_middlewares/url-rewriter.d.ts +3 -0
  263. package/lib/fn-utils/index.d.ts +10 -0
  264. package/lib/fn-utils/lib/browserLogic.d.ts +2 -0
  265. package/lib/fn-utils/lib/browserLogic.js +7 -6
  266. package/lib/fn-utils/lib/common.d.ts +85 -0
  267. package/lib/fn-utils/lib/common.js +79 -90
  268. package/lib/fn-utils/lib/integ.d.ts +2 -0
  269. package/lib/fn-utils/lib/integ.js +10 -4
  270. package/lib/fn-utils/lib/java/classpath.d.ts +2 -0
  271. package/lib/fn-utils/lib/java/classpath.js +107 -0
  272. package/lib/fn-utils/lib/java/compile.d.ts +4 -0
  273. package/lib/fn-utils/lib/java/compile.js +222 -0
  274. package/lib/fn-utils/lib/java/ensure-java-userconfig.d.ts +22 -0
  275. package/lib/fn-utils/lib/java/ensure-java-userconfig.js +264 -0
  276. package/lib/fn-utils/lib/java/index.d.ts +16 -0
  277. package/lib/fn-utils/lib/java/index.js +254 -0
  278. package/lib/fn-utils/lib/java/keywords.d.ts +2 -0
  279. package/lib/fn-utils/lib/java/keywords.js +71 -0
  280. package/lib/fn-utils/lib/node.d.ts +5 -0
  281. package/lib/fn-utils/lib/node.js +30 -10
  282. package/lib/fn-utils/lib/python.d.ts +3 -0
  283. package/lib/fn-utils/lib/python.js +9 -4
  284. package/lib/fn-watcher.d.ts +8 -0
  285. package/lib/fn-watcher.js +18 -23
  286. package/lib/iac/status/bundle.d.ts +2 -0
  287. package/lib/iac/status/bundle.js +10 -7
  288. package/lib/iac/status/deploy.d.ts +2 -0
  289. package/lib/iac/status/deploy.js +10 -10
  290. package/lib/iac/status/util/index.d.ts +2 -0
  291. package/lib/index.d.ts +2 -0
  292. package/lib/index.js +15 -4
  293. package/lib/init/dependencies/npm-install.d.ts +3 -0
  294. package/lib/init/dependencies/npm-install.js +4 -3
  295. package/lib/init/dependencies/package-json.d.ts +2 -0
  296. package/lib/init/dependencies/package-json.js +3 -3
  297. package/lib/init/dependencies/python/ensure-python.d.ts +2 -0
  298. package/lib/init/dependencies/python/pip-install.d.ts +7 -0
  299. package/lib/init/dependencies/python/pip-install.js +3 -3
  300. package/lib/init/features/appsail/index.d.ts +2 -0
  301. package/lib/init/features/appsail/index.js +48 -124
  302. package/lib/init/features/appsail/utils.d.ts +16 -0
  303. package/lib/init/features/appsail/utils.js +264 -0
  304. package/lib/init/features/client/index.d.ts +2 -0
  305. package/lib/init/features/client/index.js +1 -0
  306. package/lib/init/features/client/initializers/angular.d.ts +2 -0
  307. package/lib/init/features/client/initializers/angular.js +42 -12
  308. package/lib/init/features/client/initializers/basic.d.ts +2 -0
  309. package/lib/init/features/client/initializers/basic.js +2 -2
  310. package/lib/init/features/client/initializers/lyte.d.ts +2 -0
  311. package/lib/init/features/client/initializers/lyte.js +1 -1
  312. package/lib/init/features/client/initializers/react.d.ts +2 -0
  313. package/lib/init/features/client/initializers/react.js +5 -4
  314. package/lib/init/features/client/types.d.ts +10 -0
  315. package/lib/init/features/client/types.js +2 -0
  316. package/lib/init/features/functions/index.d.ts +17 -0
  317. package/lib/init/features/functions/index.js +60 -8
  318. package/lib/init/features/functions/languages/index.d.ts +6 -0
  319. package/lib/init/features/functions/languages/java.d.ts +2 -0
  320. package/lib/init/features/functions/languages/java.js +9 -7
  321. package/lib/init/features/functions/languages/node.d.ts +2 -0
  322. package/lib/init/features/functions/languages/node.js +6 -4
  323. package/lib/init/features/functions/languages/python.d.ts +2 -0
  324. package/lib/init/features/functions/languages/python.js +9 -7
  325. package/lib/init/features/index.d.ts +14 -0
  326. package/lib/init/features/index.js +15 -14
  327. package/lib/init/features/project.d.ts +2 -0
  328. package/lib/init/features/project.js +19 -22
  329. package/lib/init/features/slate/index.d.ts +2 -0
  330. package/lib/init/features/slate/index.js +109 -36
  331. package/lib/init/index.d.ts +2 -0
  332. package/lib/init/index.js +5 -5
  333. package/lib/init/util/client.d.ts +8 -0
  334. package/lib/init/util/client.js +10 -10
  335. package/lib/init/util/common.d.ts +12 -0
  336. package/lib/init/util/common.js +17 -16
  337. package/lib/init/util/functions.d.ts +7 -0
  338. package/lib/init/util/functions.js +3 -3
  339. package/lib/init/util/project.d.ts +3 -0
  340. package/lib/init/util/project.js +4 -4
  341. package/lib/internal/api.d.ts +78 -0
  342. package/lib/internal/api.js +32 -22
  343. package/lib/internal/command.d.ts +40 -0
  344. package/lib/internal/command.js +27 -11
  345. package/lib/internal/config.d.ts +19 -0
  346. package/lib/internal/config.js +4 -5
  347. package/lib/internal/rc.d.ts +44 -0
  348. package/lib/internal/rc.js +9 -9
  349. package/lib/migration/global/1.4.0.d.ts +2 -0
  350. package/lib/migration/global/1.4.0.js +4 -4
  351. package/lib/migration/global/1.6.2.d.ts +2 -0
  352. package/lib/migration/global/1.6.2.js +13 -13
  353. package/lib/migration/index.d.ts +6 -0
  354. package/lib/migration/index.js +19 -18
  355. package/lib/option-filter.d.ts +5 -0
  356. package/lib/option-filter.js +65 -32
  357. package/lib/optional-import.d.ts +2 -0
  358. package/lib/optional-import.js +3 -3
  359. package/lib/plugin-loader.d.ts +6 -0
  360. package/lib/plugin-loader.js +2 -2
  361. package/lib/port-resolver.d.ts +24 -0
  362. package/lib/port-resolver.js +14 -13
  363. package/lib/progress.d.ts +34 -0
  364. package/lib/prompt/index.d.ts +34 -0
  365. package/lib/prompt/index.js +49 -9
  366. package/lib/prompt/types/file-path.d.ts +25 -0
  367. package/lib/prompt/types/search-box.d.ts +56 -0
  368. package/lib/prompt/types/search-box.js +84 -46
  369. package/lib/prompt/types/tree.d.ts +65 -0
  370. package/lib/prompt/types/with-description.d.ts +15 -0
  371. package/lib/prompt/types/with-description.js +74 -0
  372. package/lib/pull/features/apig.d.ts +2 -0
  373. package/lib/pull/features/apig.js +10 -10
  374. package/lib/pull/features/client.d.ts +2 -0
  375. package/lib/pull/features/client.js +11 -10
  376. package/lib/pull/features/functions/index.d.ts +2 -0
  377. package/lib/pull/features/functions/index.js +38 -41
  378. package/lib/pull/features/functions/languages.d.ts +4 -0
  379. package/lib/pull/features/functions/languages.js +3 -3
  380. package/lib/pull/features/index.d.ts +6 -0
  381. package/lib/pull/index.d.ts +2 -0
  382. package/lib/pull/index.js +8 -8
  383. package/lib/repl-server.d.ts +32 -0
  384. package/lib/repl-server.js +8 -8
  385. package/lib/runtime-store.d.ts +3 -0
  386. package/lib/runtime-store.js +6 -12
  387. package/lib/serve/features/apig.d.ts +3 -0
  388. package/lib/serve/features/apig.js +3 -3
  389. package/lib/serve/features/appsail.d.ts +16 -0
  390. package/lib/serve/features/appsail.js +52 -10
  391. package/lib/serve/features/client.d.ts +2 -0
  392. package/lib/serve/features/client.js +1 -1
  393. package/lib/serve/features/index.d.ts +7 -0
  394. package/lib/serve/features/index.js +4 -4
  395. package/lib/serve/features/slate.d.ts +12 -0
  396. package/lib/serve/index.d.ts +2 -0
  397. package/lib/serve/index.js +82 -65
  398. package/lib/serve/server/index.d.ts +37 -0
  399. package/lib/serve/server/index.js +215 -121
  400. package/lib/serve/server/lib/appsail/index.d.ts +6 -0
  401. package/lib/serve/server/lib/appsail/index.js +214 -117
  402. package/lib/serve/server/lib/appsail/start.js +14 -5
  403. package/lib/serve/server/lib/java/index.d.ts +6 -0
  404. package/lib/serve/server/lib/java/index.js +52 -22
  405. package/lib/serve/server/lib/master/appsail.d.ts +5 -0
  406. package/lib/serve/server/lib/master/appsail.js +16 -5
  407. package/lib/serve/server/lib/master/functions.d.ts +5 -0
  408. package/lib/serve/server/lib/master/functions.js +27 -0
  409. package/lib/serve/server/lib/master/index.d.ts +10 -0
  410. package/lib/serve/server/lib/master/index.js +12 -4
  411. package/lib/serve/server/lib/master/slate.d.ts +5 -0
  412. package/lib/serve/server/lib/master/slate.js +4 -17
  413. package/lib/serve/server/lib/master/unknown-req-proxy.d.ts +4 -0
  414. package/lib/serve/server/lib/master/unknown-req-proxy.js +3 -5
  415. package/lib/serve/server/lib/master/utils.d.ts +24 -0
  416. package/lib/serve/server/lib/master/utils.js +12 -6
  417. package/lib/serve/server/lib/master/web-client.d.ts +5 -0
  418. package/lib/serve/server/lib/node/index.d.ts +6 -0
  419. package/lib/serve/server/lib/node/index.js +54 -43
  420. package/lib/serve/server/lib/node/server/bio.js +133 -0
  421. package/lib/serve/server/lib/node/server/browserlogic/browserlogic-puppeteer.js +1 -1
  422. package/lib/serve/server/lib/node/server/index.js +22 -1
  423. package/lib/serve/server/lib/python/index.d.ts +6 -0
  424. package/lib/serve/server/lib/python/index.js +63 -8
  425. package/lib/serve/server/lib/slate/index.d.ts +6 -0
  426. package/lib/serve/server/lib/slate/index.js +30 -33
  427. package/lib/serve/server/lib/slate/static-server.d.ts +7 -0
  428. package/lib/serve/server/lib/slate/static-server.js +24 -24
  429. package/lib/serve/server/lib/web_client/index.d.ts +5 -0
  430. package/lib/serve/server/lib/web_client/index.js +11 -8
  431. package/lib/serve/server/lib/web_client/server.d.ts +7 -0
  432. package/lib/serve/server/lib/web_client/server.js +22 -22
  433. package/lib/serve/server/lib/web_client/types.d.ts +15 -0
  434. package/lib/serve/server/lib/web_client/types.js +2 -0
  435. package/lib/shell/dependencies/http-functions.d.ts +35 -0
  436. package/lib/shell/dependencies/http-functions.js +59 -26
  437. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
  438. package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +51 -10
  439. package/lib/shell/dependencies/invoker/job/node.mjs +2 -2
  440. package/lib/shell/dependencies/non-http-function/fn-execution-handler.d.ts +13 -0
  441. package/lib/shell/dependencies/non-http-function/fn-execution-handler.js +260 -0
  442. package/lib/shell/dependencies/non-http-function/fn-handler.d.ts +30 -0
  443. package/lib/shell/dependencies/non-http-function/fn-handler.js +258 -0
  444. package/lib/shell/dependencies/non-http-function/index.d.ts +20 -0
  445. package/lib/shell/dependencies/non-http-function/index.js +62 -0
  446. package/lib/shell/dependencies/non-http-function/java.d.ts +9 -0
  447. package/lib/shell/dependencies/non-http-function/java.js +42 -0
  448. package/lib/shell/dependencies/non-http-function/node.d.ts +8 -0
  449. package/lib/shell/dependencies/non-http-function/node.js +36 -0
  450. package/lib/shell/dependencies/non-http-function/python.d.ts +5 -0
  451. package/lib/shell/dependencies/non-http-function/python.js +47 -0
  452. package/lib/shell/dependencies/non-http-function/slave-manager.d.ts +23 -0
  453. package/lib/shell/dependencies/non-http-function/slave-manager.js +173 -0
  454. package/lib/shell/dependencies/tunnel-server.d.ts +23 -0
  455. package/lib/shell/dependencies/tunnel-server.js +4 -4
  456. package/lib/shell/index.d.ts +2 -0
  457. package/lib/shell/index.js +31 -25
  458. package/lib/shell/prepare/index.d.ts +4 -0
  459. package/lib/shell/prepare/index.js +9 -27
  460. package/lib/shell/prepare/languages/index.d.ts +6 -0
  461. package/lib/shell/prepare/languages/index.js +20 -5
  462. package/lib/shell/prepare/languages/java.d.ts +3 -0
  463. package/lib/shell/prepare/languages/java.js +6 -14
  464. package/lib/shell/prepare/languages/node.d.ts +3 -0
  465. package/lib/shell/prepare/languages/node.js +14 -1
  466. package/lib/shell/prepare/languages/python.d.ts +3 -0
  467. package/lib/shell/prepare/languages/python.js +13 -2
  468. package/lib/slate-utils.d.ts +12 -0
  469. package/lib/slate-utils.js +7 -1
  470. package/lib/throbber/index.d.ts +36 -0
  471. package/lib/throbber/index.js +11 -7
  472. package/lib/throbber/utils.d.ts +23 -0
  473. package/lib/track.d.ts +2 -0
  474. package/lib/track.js +13 -13
  475. package/lib/userConfig.d.ts +22 -0
  476. package/lib/userConfig.js +18 -8
  477. package/lib/util_modules/config/index.d.ts +6 -0
  478. package/lib/util_modules/config/lib/apig.d.ts +15 -0
  479. package/lib/util_modules/config/lib/apig.js +4 -4
  480. package/lib/util_modules/config/lib/appsail.d.ts +50 -0
  481. package/lib/util_modules/config/lib/appsail.js +96 -26
  482. package/lib/util_modules/config/lib/client.d.ts +20 -0
  483. package/lib/util_modules/config/lib/client.js +19 -6
  484. package/lib/util_modules/config/lib/functions.d.ts +48 -0
  485. package/lib/util_modules/config/lib/functions.js +27 -16
  486. package/lib/util_modules/config/lib/slate.d.ts +106 -0
  487. package/lib/util_modules/config/lib/slate.js +2 -6
  488. package/lib/util_modules/config-store.d.ts +12 -0
  489. package/lib/util_modules/config-store.js +55 -0
  490. package/lib/util_modules/constants/index.d.ts +24 -0
  491. package/lib/util_modules/constants/index.js +1 -5
  492. package/lib/util_modules/constants/lib/apig-rules.d.ts +3 -0
  493. package/lib/util_modules/constants/lib/apig-rules.js +1 -1
  494. package/lib/util_modules/constants/lib/browserLogic.d.ts +20 -0
  495. package/lib/util_modules/constants/lib/cliq-handlers.d.ts +32 -0
  496. package/lib/util_modules/constants/lib/dc-type.d.ts +59 -0
  497. package/lib/util_modules/constants/lib/default.d.ts +48 -0
  498. package/lib/util_modules/constants/lib/default.js +4 -0
  499. package/lib/util_modules/constants/lib/env-path.d.ts +6 -0
  500. package/lib/util_modules/constants/lib/event-action.d.ts +11 -0
  501. package/lib/util_modules/constants/lib/event-source.d.ts +11 -0
  502. package/lib/util_modules/constants/lib/file-names.d.ts +37 -0
  503. package/lib/util_modules/constants/lib/file-names.js +1 -0
  504. package/lib/util_modules/constants/lib/fn-type.d.ts +11 -0
  505. package/lib/util_modules/constants/lib/folder-names.d.ts +9 -0
  506. package/lib/util_modules/constants/lib/iac.d.ts +7 -0
  507. package/lib/util_modules/constants/lib/integ.d.ts +13 -0
  508. package/lib/util_modules/constants/lib/needed-scopes.d.ts +4 -0
  509. package/lib/util_modules/constants/lib/needed-scopes.js +3 -4
  510. package/lib/util_modules/constants/lib/placeholders.d.ts +65 -0
  511. package/lib/util_modules/constants/lib/placeholders.js +2 -1
  512. package/lib/util_modules/constants/lib/plugin.d.ts +27 -0
  513. package/lib/util_modules/constants/lib/ref-mapping.d.ts +15 -0
  514. package/lib/util_modules/constants/lib/regex.d.ts +20 -0
  515. package/lib/util_modules/constants/lib/regex.js +3 -0
  516. package/lib/util_modules/constants/lib/remote-mapping.d.ts +15 -0
  517. package/lib/util_modules/constants/lib/runtime.d.ts +18 -0
  518. package/lib/util_modules/constants/lib/signals-api-names.d.ts +9 -0
  519. package/lib/util_modules/constants/lib/signals-publishers-type.d.ts +7 -0
  520. package/lib/util_modules/constants/lib/signals-publishers.d.ts +9 -0
  521. package/lib/util_modules/constants/lib/template.d.ts +65 -0
  522. package/lib/util_modules/constants/lib/urls.d.ts +26 -0
  523. package/lib/util_modules/constants/lib/urls.js +37 -57
  524. package/lib/util_modules/constants/project.d.ts +4 -0
  525. package/lib/util_modules/container.d.ts +3 -0
  526. package/lib/util_modules/container.js +176 -0
  527. package/lib/util_modules/dc.d.ts +10 -0
  528. package/lib/{dc.js → util_modules/dc.js} +14 -18
  529. package/lib/util_modules/env.d.ts +7 -0
  530. package/lib/util_modules/env.js +3 -2
  531. package/lib/util_modules/fs/index.d.ts +3 -0
  532. package/lib/util_modules/fs/lib/async.d.ts +53 -0
  533. package/lib/util_modules/fs/lib/async.js +30 -1
  534. package/lib/util_modules/fs/lib/sync.d.ts +39 -0
  535. package/lib/util_modules/fs/lib/sync.js +24 -16
  536. package/lib/util_modules/fs/utils.d.ts +1 -0
  537. package/lib/util_modules/global-space.d.ts +1 -0
  538. package/lib/util_modules/js.d.ts +10 -0
  539. package/lib/util_modules/logger/index.d.ts +19 -0
  540. package/lib/util_modules/logger/index.js +80 -0
  541. package/lib/util_modules/logger/utils.d.ts +29 -0
  542. package/lib/util_modules/logger/utils.js +66 -0
  543. package/lib/util_modules/logger/winston.d.ts +9 -0
  544. package/lib/util_modules/logger/winston.js +90 -0
  545. package/lib/util_modules/option.d.ts +5 -0
  546. package/lib/util_modules/option.js +5 -5
  547. package/lib/util_modules/project.d.ts +70 -0
  548. package/lib/util_modules/project.js +26 -20
  549. package/lib/util_modules/runtime-store.d.ts +11 -0
  550. package/lib/util_modules/runtime-store.js +16 -0
  551. package/lib/util_modules/server.d.ts +13 -0
  552. package/lib/util_modules/server.js +78 -1
  553. package/lib/util_modules/shell.d.ts +21 -0
  554. package/lib/util_modules/shell.js +19 -4
  555. package/lib/util_modules/toml.d.ts +2 -0
  556. package/lib/util_modules/{parser/toml.js → toml.js} +3 -3
  557. package/package.json +6 -5
  558. package/scripts/send-notification.js +1 -1
  559. package/templates/event/integ/cliq/command/suggestion_handler.json +1 -1
  560. package/templates/event/integ/cliq/link_preview/action_handler.json +2 -2
  561. package/templates/event/integ/cliq/link_preview/after_send_handler.json +2 -2
  562. package/templates/event/integ/cliq/link_preview/menu_handler.json +2 -2
  563. package/templates/event/integ/cliq/link_preview/preview_handler.json +2 -2
  564. package/templates/init/functions/java/event/sample.java +5 -8
  565. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +3 -3
  566. package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +1 -1
  567. package/templates/init/functions/node/cron/types/cron.d.ts +1 -1
  568. package/templates/init/functions/node/event/sample.js +1 -12
  569. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -3
  570. package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +1 -1
  571. package/templates/init/functions/python/event/sample.py +0 -9
  572. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +3 -3
  573. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +1 -1
  574. package/templates/init/functions/python/integ/cliq/sample.py +1 -12
  575. package/docs/commands/signals/generate/index.toml +0 -19
  576. package/docs/commands/slate/unlink.toml +0 -9
  577. package/docs/commands/zest/generate/index.toml +0 -4
  578. package/docs/endpoints/lib/slate.toml +0 -3
  579. package/docs/fn-utils/lib/ensure-java-userconfig.toml +0 -15
  580. package/docs/fn-utils/lib/java.toml +0 -34
  581. package/docs/serve/server/lib/slate/index.toml +0 -14
  582. package/docs/slate-utils.toml +0 -4
  583. package/docs/util_modules/config/lib/slate.toml +0 -4
  584. package/lib/config-store.js +0 -10
  585. package/lib/fn-utils/lib/ensure-java-userconfig.js +0 -145
  586. package/lib/fn-utils/lib/java.js +0 -512
  587. package/lib/shell/dependencies/local-function.js +0 -483
  588. package/lib/util_modules/char.js +0 -12
  589. package/lib/util_modules/constants/lib/auth.js +0 -37
  590. package/lib/util_modules/logger.js +0 -51
  591. package/lib/winston.js +0 -75
  592. /package/lib/{internal → authentication}/crypt.js +0 -0
  593. /package/{docs/internal → lib/authentication/docs}/credential.toml +0 -0
  594. /package/{docs/authentication → lib/authentication/docs}/index.toml +0 -0
  595. /package/{docs/authentication → lib/authentication/docs}/login.toml +0 -0
  596. /package/{docs → lib/docs}/apig-utils.toml +0 -0
  597. /package/{docs → lib/docs}/client-utils.toml +0 -0
  598. /package/{docs → lib/docs}/command_needs/auth.toml +0 -0
  599. /package/{docs → lib/docs}/command_needs/rc.toml +0 -0
  600. /package/{docs → lib/docs}/commands/apig/disable.toml +0 -0
  601. /package/{docs → lib/docs}/commands/apig/enable.toml +0 -0
  602. /package/{docs → lib/docs}/commands/apig/status.toml +0 -0
  603. /package/{docs → lib/docs}/commands/client/delete.toml +0 -0
  604. /package/{docs → lib/docs}/commands/ds/export.toml +0 -0
  605. /package/{docs → lib/docs}/commands/ds/import.toml +0 -0
  606. /package/{docs → lib/docs}/commands/ds/status.toml +0 -0
  607. /package/{docs → lib/docs}/commands/event/generate/index.toml +0 -0
  608. /package/{docs → lib/docs}/commands/event/generate/integ.toml +0 -0
  609. /package/{docs → lib/docs}/commands/event/generate/job.toml +0 -0
  610. /package/{docs → lib/docs}/commands/functions/config.toml +0 -0
  611. /package/{docs → lib/docs}/commands/functions/delete.toml +0 -0
  612. /package/{docs → lib/docs}/commands/functions/shell.toml +0 -0
  613. /package/{docs → lib/docs}/commands/iac/export.toml +0 -0
  614. /package/{docs → lib/docs}/commands/iac/import.toml +0 -0
  615. /package/{docs → lib/docs}/commands/iac/status.toml +0 -0
  616. /package/{docs → lib/docs}/commands/project/use.toml +0 -0
  617. /package/{docs → lib/docs}/dc.toml +0 -0
  618. /package/{docs → lib/docs}/deploy/features/apig.toml +0 -0
  619. /package/{docs → lib/docs}/deploy/features/functions/index.toml +0 -0
  620. /package/{docs → lib/docs}/endpoints/lib/env.toml +0 -0
  621. /package/{docs → lib/docs}/endpoints/lib/job-scheduling.toml +0 -0
  622. /package/{docs → lib/docs}/event_generate/cache.toml +0 -0
  623. /package/{docs → lib/docs}/event_generate/custom.toml +0 -0
  624. /package/{docs → lib/docs}/event_generate/datastore.toml +0 -0
  625. /package/{docs → lib/docs}/event_generate/filestore.toml +0 -0
  626. /package/{docs → lib/docs}/event_generate/integration/cliq.toml +0 -0
  627. /package/{docs → lib/docs}/execute-script.toml +0 -0
  628. /package/{docs → lib/docs}/fn-utils/lib/common.toml +0 -0
  629. /package/{docs → lib/docs}/fn-utils/lib/node.toml +0 -0
  630. /package/{docs → lib/docs}/fn-utils/lib/python.toml +0 -0
  631. /package/{docs → lib/docs}/iac/status/bundle.toml +0 -0
  632. /package/{docs → lib/docs}/init/dependencies/python/ensure-python.toml +0 -0
  633. /package/{docs → lib/docs}/init/dependencies/python/pip-install.toml +0 -0
  634. /package/{docs → lib/docs}/init/index.toml +0 -0
  635. /package/{docs → lib/docs}/internal/command.toml +0 -0
  636. /package/{docs → lib/docs}/internal/config.toml +0 -0
  637. /package/{docs → lib/docs}/optional-import.toml +0 -0
  638. /package/{docs → lib/docs}/plugin-loader.toml +0 -0
  639. /package/{docs → lib/docs}/port-resolver.toml +0 -0
  640. /package/{docs → lib/docs}/pull/index.toml +0 -0
  641. /package/{docs → lib/docs}/serve/index.toml +0 -0
  642. /package/{docs → lib/docs}/serve/server/index.toml +0 -0
  643. /package/{docs → lib/docs}/serve/server/lib/appsail/index.toml +0 -0
  644. /package/{docs → lib/docs}/serve/server/lib/web_client/server.toml +0 -0
  645. /package/{docs → lib/docs}/shell/dependencies/tunnel-server.toml +0 -0
  646. /package/{docs → lib/docs}/shell/index.toml +0 -0
  647. /package/templates/init/functions/java/{browserLogic → browserlogic}/playwright/.classpath +0 -0
  648. /package/templates/init/functions/java/{browserLogic → browserlogic}/playwright/.project +0 -0
  649. /package/templates/init/functions/java/{browserLogic → browserlogic}/playwright/catalyst-config.json +0 -0
  650. /package/templates/init/functions/java/{browserLogic → browserlogic}/playwright/sample.java +0 -0
  651. /package/templates/init/functions/java/{browserLogic → browserlogic}/selenium/.classpath +0 -0
  652. /package/templates/init/functions/java/{browserLogic → browserlogic}/selenium/.project +0 -0
  653. /package/templates/init/functions/java/{browserLogic → browserlogic}/selenium/catalyst-config.json +0 -0
  654. /package/templates/init/functions/java/{browserLogic → browserlogic}/selenium/sample.java +0 -0
@@ -3,14 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addFnRoutes = void 0;
4
4
  const constants_1 = require("../../../../util_modules/constants");
5
5
  function addFnRoutes(app, details, proxy) {
6
+ if (details.isAlive === false) {
7
+ return;
8
+ }
6
9
  const fnTarget = details.target;
7
10
  app.use(`/server/${fnTarget.name}`, (req, res) => {
11
+ var _a;
12
+ if (!((_a = details.target) === null || _a === void 0 ? void 0 : _a.valid)) {
13
+ res.status(503);
14
+ res.write(JSON.stringify({ data: 'Error connecting with the function' }));
15
+ return;
16
+ }
8
17
  proxy.web(req, res, {
9
18
  target: `http://127.0.0.1:${details.httpPort}${fnTarget.type === constants_1.FN_TYPE.basic ? `/server/${fnTarget.name}/execute` : ''}`,
10
19
  ws: true
11
20
  });
12
21
  });
13
22
  app.use(`/baas/v1/project/:projectId/function/${fnTarget.name}`, (req, res) => {
23
+ var _a;
24
+ if (!((_a = details.target) === null || _a === void 0 ? void 0 : _a.valid)) {
25
+ res.status(503);
26
+ res.write(JSON.stringify({ data: 'Error connecting with the function' }));
27
+ return;
28
+ }
14
29
  proxy.web(req, res, {
15
30
  target: `http://127.0.0.1:${details.httpPort}${fnTarget.type === constants_1.FN_TYPE.basic ? `/server/${fnTarget.name}/execute` : ''}`,
16
31
  ws: true
@@ -18,12 +33,24 @@ function addFnRoutes(app, details, proxy) {
18
33
  });
19
34
  if (fnTarget.id) {
20
35
  app.use(`/server/${fnTarget.id}`, (req, res) => {
36
+ var _a;
37
+ if (!((_a = details.target) === null || _a === void 0 ? void 0 : _a.valid)) {
38
+ res.status(503);
39
+ res.write(JSON.stringify({ data: 'Error connecting with the function' }));
40
+ return;
41
+ }
21
42
  proxy.web(req, res, {
22
43
  target: `http://127.0.0.1:${details.httpPort}${fnTarget.type === constants_1.FN_TYPE.basic ? `/server/${fnTarget.id}/execute` : ''}`,
23
44
  ws: true
24
45
  });
25
46
  });
26
47
  app.use(`/baas/v1/project/:projectId/function/${fnTarget.id}`, (req, res) => {
48
+ var _a;
49
+ if (!((_a = details.target) === null || _a === void 0 ? void 0 : _a.valid)) {
50
+ res.status(503);
51
+ res.write(JSON.stringify({ data: 'Error connecting with the function' }));
52
+ return;
53
+ }
27
54
  proxy.web(req, res, {
28
55
  target: `http://127.0.0.1:${details.httpPort}${fnTarget.type === constants_1.FN_TYPE.basic ? `/server/${fnTarget.id}/execute` : ''}`,
29
56
  ws: true
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import { Server } from 'http';
3
+ import { IServerDetails, TServerTargets } from '../../index';
4
+ import { TAppSailServerDetails } from '../../../features/appsail';
5
+ import { TSlateServerDetails } from '../../../features/slate';
6
+ export default function spinUpMaster(listenPort: number, { otherServerDetails, appSailDetails, slateDetails }: {
7
+ otherServerDetails?: Partial<TServerTargets>;
8
+ appSailDetails?: IServerDetails<TAppSailServerDetails>;
9
+ slateDetails?: IServerDetails<TSlateServerDetails>;
10
+ }): Promise<Server>;
@@ -26,7 +26,7 @@ const url_rewriter_1 = __importDefault(require("../../../../express_middlewares/
26
26
  const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
27
27
  const constants_1 = require("../../../../util_modules/constants");
28
28
  const js_1 = require("../../../../util_modules/js");
29
- const logger_2 = require("../../../../util_modules/logger");
29
+ const index_1 = require("../../../../util_modules/logger/index");
30
30
  const project_2 = require("../../../../util_modules/project");
31
31
  const option_1 = require("../../../../util_modules/option");
32
32
  const server_js_1 = require("../../../../util_modules/server.js");
@@ -97,7 +97,7 @@ function spinUpMaster(listenPort, { otherServerDetails, appSailDetails, slateDet
97
97
  }
98
98
  }
99
99
  const proxy = (0, utils_1.createProxyServer)(listenPort);
100
- const signRedirectUrl = slateDetails ? undefined : '/app/local-redirect';
100
+ const signRedirectUrl = slateDetails ? '/' : '/app/local-redirect';
101
101
  appSailDetails && ((_b = (_a = appSailDetails.target) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.catalyst_auth) === true
102
102
  ? proxy.on('proxyRes', (0, utils_1.proxyResponseHandler)({
103
103
  signInRedirect: appSailDetails.target.config.login_redirect || '/'
@@ -116,6 +116,9 @@ function spinUpMaster(listenPort, { otherServerDetails, appSailDetails, slateDet
116
116
  case 'server': {
117
117
  (_b = otherServerDetails.server) === null || _b === void 0 ? void 0 : _b.forEach((serverDetail) => {
118
118
  var _a;
119
+ if (serverDetail.isAlive === false) {
120
+ return;
121
+ }
119
122
  app.use('/server/' + ((_a = serverDetail.target) === null || _a === void 0 ? void 0 : _a.name), (req, res) => {
120
123
  proxy.web(req, res, {
121
124
  target: `http://127.0.0.1:${serverDetail.httpPort}`
@@ -146,9 +149,14 @@ function spinUpMaster(listenPort, { otherServerDetails, appSailDetails, slateDet
146
149
  });
147
150
  const expressDestroyer = new server_js_1.ConnectionDestroyer(expressServer);
148
151
  expressServer.maxConnections = 100;
149
- process.on('SIGINT', () => expressDestroyer.destroy(false));
152
+ const stopServer = () => expressDestroyer.destroy(!!appSailDetails);
153
+ utils_1.serverEvent.once('stop', () => {
154
+ process.removeListener('SIGINT', stopServer);
155
+ stopServer();
156
+ });
157
+ process.once('SIGINT', stopServer);
150
158
  expressServer.on('close', () => __awaiter(this, void 0, void 0, function* () {
151
- yield proxyDestroyer.destroy().catch((err) => (0, logger_2.debug)(err));
159
+ yield proxyDestroyer.destroy().catch((err) => (0, index_1.debug)(err));
152
160
  }));
153
161
  expressServer.on('upgrade', (...upgradeParam) => {
154
162
  app.emit('upgrade', ...upgradeParam);
@@ -0,0 +1,5 @@
1
+ import Server from 'http-proxy';
2
+ import { IServerDetails } from '../..';
3
+ import { Express, Request, Response } from 'express';
4
+ import { TSlateServerDetails } from '../../../features/slate';
5
+ export declare function addSlateRoutes(app: Express, details: IServerDetails<TSlateServerDetails>, proxy: Server, unknownProxy: (req: Request, res: Response) => void): void;
@@ -11,25 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.addSlateRoutes = void 0;
13
13
  function addSlateRoutes(app, details, proxy, unknownProxy) {
14
- app.use('/__catalyst/sdk/init', (req, res) => __awaiter(this, void 0, void 0, function* () {
14
+ if (!details.isAlive === false) {
15
+ return;
16
+ }
17
+ app.use(['/accounts', '/oauthorize', '/__catalyst'], (req, res) => {
15
18
  req.url = req.originalUrl;
16
19
  unknownProxy(req, res);
17
- }));
18
- app.use(['/accounts', '/oauthorize'], (req, res) => {
19
- req.url = req.originalUrl;
20
- unknownProxy(req, res);
21
- });
22
- app.use('/__catalyst', (req, res) => {
23
- req.url = req.originalUrl;
24
- if (req.url.includes('redirect_url')) {
25
- res.redirect(req.url.split('redirect_url=')[1]);
26
- }
27
- else if (req.url.includes('service_url')) {
28
- res.redirect(req.url.split('service_url=')[1]);
29
- }
30
- else {
31
- unknownProxy(req, res);
32
- }
33
20
  });
34
21
  app.use('/', (req, res) => __awaiter(this, void 0, void 0, function* () {
35
22
  if (req.header('catalyst-component') === 'true') {
@@ -0,0 +1,4 @@
1
+ import express from 'express';
2
+ import Server from 'http-proxy';
3
+ declare const _default: (proxyInstance: Server, masterPort: number, customProxyUrl?: string) => (req: express.Request, res: express.Response) => void;
4
+ export default _default;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
7
- const logger_1 = require("../../../../util_modules/logger");
7
+ const index_1 = require("../../../../util_modules/logger/index");
8
8
  exports.default = (proxyInstance, masterPort, customProxyUrl) => (req, res) => {
9
9
  if (req.url.length === 1 && req.url.startsWith('/')) {
10
10
  res.redirect('/app/');
@@ -15,16 +15,14 @@ exports.default = (proxyInstance, masterPort, customProxyUrl) => (req, res) => {
15
15
  }
16
16
  else if (typeof customProxyUrl === 'string' &&
17
17
  !req.url.match(/^(\/baas|\/app|\/server|\/oauthorize|\/__catalyst).*/g)) {
18
- (0, logger_1.debug)(`proxying "${req.url}" to "${customProxyUrl}"`);
18
+ (0, index_1.debug)(`proxying "${req.url}" to "${customProxyUrl}"`);
19
19
  proxyInstance.web(req, res, {
20
20
  target: customProxyUrl,
21
21
  ws: true,
22
22
  changeOrigin: true,
23
23
  secure: false,
24
24
  headers: {
25
- 'User-Agent': runtime_store_1.default.get('context.cli.package.name') +
26
- '/' +
27
- runtime_store_1.default.get('context.cli.package.version')
25
+ 'User-Agent': runtime_store_1.default.get('cli.package.name') + '/' + runtime_store_1.default.get('cli.package.version')
28
26
  }
29
27
  });
30
28
  }
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ import { IncomingMessage, ServerResponse } from 'http';
3
+ import { IAPIGLocal, IAPIGRules } from '../../../../apig-utils';
4
+ import Server from 'http-proxy';
5
+ import EventEmitter from 'events';
6
+ export interface IMatchRule extends IAPIGRules {
7
+ target_endpoint: string;
8
+ source_endpoint: string;
9
+ params: {
10
+ [x: string]: string;
11
+ };
12
+ }
13
+ declare class ServerEvent extends EventEmitter {
14
+ }
15
+ export declare const serverEvent: ServerEvent;
16
+ export declare const removeSecure: (str: string) => string;
17
+ export declare const redirectByAuth: (req: IncomingMessage, res: ServerResponse, redirectUrl: string) => void;
18
+ export declare const createProxyServer: (port: number) => Server;
19
+ export declare const proxyResponseHandler: ({ systemRoutes, signInRedirect }: {
20
+ systemRoutes?: IAPIGLocal | undefined;
21
+ signInRedirect?: string | undefined;
22
+ }) => (proxyRes: IncomingMessage, req: IncomingMessage, res: ServerResponse) => void;
23
+ export declare const appsailInitJs: () => Promise<string>;
24
+ export {};
@@ -12,14 +12,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.appsailInitJs = exports.proxyResponseHandler = exports.createProxyServer = exports.redirectByAuth = exports.removeSecure = void 0;
15
+ exports.appsailInitJs = exports.proxyResponseHandler = exports.createProxyServer = exports.redirectByAuth = exports.removeSecure = exports.serverEvent = void 0;
16
16
  const http_1 = require("http");
17
17
  const constants_1 = require("../../../../util_modules/constants");
18
18
  const fs_1 = require("../../../../util_modules/fs");
19
19
  const error_1 = __importDefault(require("../../../../error"));
20
20
  const project_1 = require("../../../../util_modules/project");
21
21
  const http_proxy_1 = require("http-proxy");
22
- const logger_1 = require("../../../../util_modules/logger");
22
+ const index_1 = require("../../../../util_modules/logger/index");
23
+ const events_1 = __importDefault(require("events"));
24
+ class ServerEvent extends events_1.default {
25
+ }
26
+ exports.serverEvent = new ServerEvent();
23
27
  const iam_cookies = [
24
28
  'ZD_CSRF_TOKEN',
25
29
  '_iamadt_client',
@@ -71,10 +75,10 @@ const createProxyServer = (port) => {
71
75
  res.end(JSON.stringify({ error: 'unable to serve the request. ECONNRESET.' }));
72
76
  console.log();
73
77
  console.log('Connection reset while trying to serve the request ', req.url);
74
- (0, logger_1.debug)('Connection reset from target URL : ', targetUrl);
78
+ (0, index_1.debug)('Connection reset from target URL : ', targetUrl);
75
79
  console.error(err);
76
80
  })
77
- .on('close', () => (0, logger_1.debug)('proxy closed'));
81
+ .on('close', () => (0, index_1.debug)('proxy closed'));
78
82
  return proxy;
79
83
  };
80
84
  exports.createProxyServer = createProxyServer;
@@ -89,9 +93,11 @@ const proxyResponseHandler = ({ systemRoutes, signInRedirect }) => (proxyRes, re
89
93
  return cookie;
90
94
  });
91
95
  if (req.url.startsWith('/baas') || req.url.startsWith('/__catalyst')) {
92
- if (req.url.includes('/signin-redirect') && signInRedirect) {
96
+ const urlParams = new URLSearchParams(req.url.split('?')[1] || '');
97
+ const redirectUrl = urlParams.get('redirect_url') || urlParams.get('service_url') || signInRedirect;
98
+ if (req.url.includes('/signin-redirect') && redirectUrl) {
93
99
  if (systemRoutes === undefined) {
94
- (0, exports.redirectByAuth)(req, res, signInRedirect);
100
+ (0, exports.redirectByAuth)(req, res, redirectUrl);
95
101
  return;
96
102
  }
97
103
  const sourceRedirectUrl = Object.keys(systemRoutes).find((sourceUrl) => {
@@ -0,0 +1,5 @@
1
+ import { Express, Request, Response } from 'express';
2
+ import { IServerDetails } from '../..';
3
+ import { IClientTarget } from '../web_client/types';
4
+ import Server from 'http-proxy';
5
+ export declare function addWebClientRoutes(app: Express, details: IServerDetails<IClientTarget>, proxy: Server, unknownProxy: (req: Request, res: Response) => void): void;
@@ -0,0 +1,6 @@
1
+ import { ChildProcess } from 'child_process';
2
+ import { IFnTarget } from '../../../../fn-utils/lib/common';
3
+ import { IServerDetails } from '../../index.js';
4
+ import { ContainerEvents } from '@zcatalyst/container-plugin/';
5
+ declare const _default: (details: IServerDetails<IFnTarget>) => Promise<ChildProcess | ContainerEvents>;
6
+ export default _default;
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,21 +46,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
47
  };
25
48
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const ansi_colors_1 = require("ansi-colors");
27
49
  const path_1 = require("path");
28
- const stream_1 = require("stream");
29
50
  const error_1 = __importDefault(require("../../../../error"));
30
- const plugin_loader_1 = __importDefault(require("../../../../plugin-loader"));
31
51
  const runtime_store_1 = __importDefault(require("../../../../runtime-store"));
32
52
  const constants_1 = require("../../../../util_modules/constants");
33
- const logger_1 = require("../../../../util_modules/logger");
53
+ const index_1 = require("../../../../util_modules/logger/index");
34
54
  const project_1 = require("../../../../util_modules/project");
35
55
  const shell_1 = require("../../../../util_modules/shell");
36
- exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, function* () {
37
- var _a, _b, _c, _d, _e, _f, _g;
38
- const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
39
- const _h = details.target, { ['watcher']: _ } = _h, serialisableTarget = __rest(_h, ['watcher']);
56
+ const container_1 = require("../../../../util_modules/container");
57
+ const container_plugin_1 = require("@zcatalyst/container-plugin/");
58
+ exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
59
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
60
+ if (!details.target) {
61
+ throw new error_1.default('Invalid Node function target', { exit: 2 });
62
+ }
40
63
  const projectRoot = runtime_store_1.default.get('project.root');
64
+ const targetSource = (_a = details.target) === null || _a === void 0 ? void 0 : _a.source;
65
+ const codeLocation = (_b = details.target) === null || _b === void 0 ? void 0 : _b.build;
66
+ if ((0, container_1.isContainer)()) {
67
+ (0, index_1.debug)('using container to serve the function: ' + ((_c = details.target) === null || _c === void 0 ? void 0 : _c.name));
68
+ const container = yield Promise.resolve().then(() => __importStar(require('@zcatalyst/container-plugin')));
69
+ details.target.env_var = Object.assign({ X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_d = details.target) === null || _d === void 0 ? void 0 : _d.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, X_ZOHO_CATALYST_CODE_LOCATION: '/catalyst', CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone), X_ZOHO_CATALYST_ORG: (0, project_1.getEnvId)(), X_ZOHO_ADMIN_CRED_TOKEN: 'Unknown', CATALYST_FUNCTION_TYPE: constants_1.REMOTE_REF.functions.type[(_e = details.target) === null || _e === void 0 ? void 0 : _e.type] }, (_f = details.target) === null || _f === void 0 ? void 0 : _f.env_var);
70
+ return container.start({
71
+ details: details,
72
+ projectId: (0, project_1.getProjectId)(),
73
+ ruok: details.debugPort !== undefined && details.debugPort !== -1
74
+ ? container_plugin_1.RUOK.SKIP
75
+ : container_plugin_1.RUOK.FINITE
76
+ });
77
+ }
78
+ const label = `${details.type}[${(_g = details.target) === null || _g === void 0 ? void 0 : _g.name}]`;
79
+ const _o = details.target, { ['watcher']: _ } = _o, serialisableTarget = __rest(_o, ['watcher']);
41
80
  serialisableTarget.index = serialisableTarget.index
42
81
  ? serialisableTarget.index.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build))
43
82
  : undefined;
@@ -45,49 +84,21 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
45
84
  (0, path_1.join)(__dirname, 'server'),
46
85
  details.httpPort + '',
47
86
  JSON.stringify({
48
- index: ((_b = details.target) === null || _b === void 0 ? void 0 : _b.index)
87
+ index: ((_h = details.target) === null || _h === void 0 ? void 0 : _h.index)
49
88
  ? details.target.index.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build))
50
89
  : undefined,
51
- name: (_c = details.target) === null || _c === void 0 ? void 0 : _c.name,
52
- type: (_d = details.target) === null || _d === void 0 ? void 0 : _d.type,
53
- source: (_e = details.target) === null || _e === void 0 ? void 0 : _e.source
90
+ name: (_j = details.target) === null || _j === void 0 ? void 0 : _j.name,
91
+ type: (_k = details.target) === null || _k === void 0 ? void 0 : _k.type,
92
+ source: (_l = details.target) === null || _l === void 0 ? void 0 : _l.source
54
93
  })
55
94
  ];
56
95
  if (details.debugPort !== -1) {
57
- (0, logger_1.labeled)(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
96
+ (0, index_1.labeled)(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
58
97
  opts.unshift('--inspect=' + details.debugPort);
59
98
  }
60
- const targetSource = (_f = details.target) === null || _f === void 0 ? void 0 : _f.source;
61
- const servePlugin = yield (0, plugin_loader_1.default)('functions', 'start', targetSource).catch((err) => (0, logger_1.debug)(err));
62
- if (typeof servePlugin === 'function') {
63
- const logStreamPlugin = yield (0, plugin_loader_1.default)('functions', 'logs', targetSource).catch((err) => (0, logger_1.debug)(err));
64
- if (typeof logStreamPlugin === 'function') {
65
- const stream = yield logStreamPlugin();
66
- if (stream instanceof stream_1.Stream) {
67
- const streamLogFn = (chunk) => (0, logger_1.log)('info', chunk.toString(), true);
68
- stream.on('data', streamLogFn);
69
- }
70
- }
71
- const event = servePlugin(details, masterPort).catch((e) => {
72
- var _a;
73
- const err = error_1.default.getErrorInstance(e, {
74
- fileName: __filename,
75
- skipHelp: false
76
- });
77
- err.errorId = 'SERVE-IDX-1';
78
- err.arg = [
79
- 'functions',
80
- (0, ansi_colors_1.bold)(((_a = details.target.plugins) === null || _a === void 0 ? void 0 : _a.start)[targetSource] || 'start'),
81
- (0, ansi_colors_1.bold)('Error: ') + ansi_colors_1.italic.red(err.message)
82
- ];
83
- throw err;
84
- });
85
- (0, logger_1.labeled)(label, `Plugin : "${runtime_store_1.default.get(`context.functions.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
86
- return event;
87
- }
88
99
  return (0, shell_1.spawn)('node', opts, {
89
- cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)),
100
+ cwd: codeLocation,
90
101
  stdio: 'pipe',
91
- env: Object.assign({ NODE_PATH: targetSource + path_1.sep + 'node_modules', X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_g = details.target) === null || _g === void 0 ? void 0 : _g.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
102
+ env: Object.assign({ NODE_PATH: targetSource + path_1.sep + 'node_modules', X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_m = details.target) === null || _m === void 0 ? void 0 : _m.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone), CHROME_EXECUTABLE_PATH: runtime_store_1.default.get('CHROME_EXECUTABLE', process.env.CHROME_EXECUTABLE_PATH), CHROMEDRIVER_EXECUTABLE_PATH: runtime_store_1.default.get('CHROME_DRIVER_EXECUTABLE', process.env.CHROMEDRIVER_EXECUTABLE_PATH) }, details.target.env_var)
92
103
  }).RAW();
93
104
  });
@@ -0,0 +1,133 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ import { IncomingMessage, Server, ServerResponse } from 'http';
3
+ import { inspect } from 'util';
4
+
5
+ const endTime = 30 * 1000 + Date.now();
6
+
7
+ /**
8
+ *
9
+ * @param {IncomingMessage} req
10
+ * @param {ServerResponse} res
11
+ * @returns
12
+ */
13
+ function buildContext(req, res, locals) {
14
+ const catalystHeaders = {};
15
+ Object.entries(req.headers).forEach(([header, value]) => {
16
+ const _header = header.toLowerCase();
17
+ if (_header.startsWith('x-zc-')) {
18
+ catalystHeaders[_header] = value;
19
+ }
20
+ });
21
+ return {
22
+ catalystHeaders,
23
+ getMaxExecutionTimeMs: () => 30 * 1000, // 30 sec
24
+ getRemainingExecutionTimeMs: () => endTime - Date.now(),
25
+ close: () => {
26
+ const _finalRes = JSON.stringify({
27
+ output: locals.finalResponse || ''
28
+ });
29
+ res.setHeader('Content-Type', 'application/json');
30
+ res.setHeader('Content-Length', _finalRes.length);
31
+ res.write(_finalRes);
32
+ },
33
+ // eslint-disable-next-line no-console
34
+ log: (...params) => console.log(...params)
35
+ };
36
+ }
37
+
38
+ /**
39
+ *
40
+ * @param {IncomingMessage} req
41
+ * @param {ServerResponse} res
42
+ * @returns
43
+ */
44
+ async function buildBasicIO(req, res, locals) {
45
+ const urlParts = new URL(`http://${req.headers.host}${req.url}`).searchParams;
46
+ const userData = JSON.stringify(Object.fromEntries(urlParts.entries()));
47
+
48
+ const body = await new Promise((resolve, reject) => {
49
+ const buff = [];
50
+ req.on('data', (ch) => buff.push(ch));
51
+ req.on('end', () => {
52
+ try {
53
+ const _jsonStr = Buffer.concat(buff).toString();
54
+ resolve(_jsonStr ? JSON.parse(_jsonStr) : {});
55
+ } catch (er) {
56
+ reject(er);
57
+ }
58
+ });
59
+ req.on('error', reject);
60
+ });
61
+ const basicIO = {
62
+ write: (VALUE) => {
63
+ if (!typeof VALUE === 'string') {
64
+ // eslint-disable-next-line no-console
65
+ console.error(`Expected string but ${typeof VALUE} found!.`);
66
+ } else {
67
+ const _res = VALUE.substring(0, 1 * 1024);
68
+ // eslint-disable-next-line no-console
69
+ console.log(_res);
70
+ locals.finalResponse += _res;
71
+ }
72
+ },
73
+ getArgument: (KEY) => userData[KEY] || body[KEY],
74
+ getAllArguments: () => (userData && Object.keys(userData).length > 0 ? userData : body),
75
+ /**
76
+ * @deprecated use get getArgument instead.
77
+ */
78
+ getParameter: (KEY) => {
79
+ // eslint-disable-next-line no-console
80
+ console.error(
81
+ 'CatalystDeprecationWarning: basicIO.getParameter() is deprecated due to usability issues. Please use basicIO.getArgument() method instead.'
82
+ );
83
+ return basicIO.getArgument(KEY);
84
+ },
85
+ /**
86
+ * @deprecated use get getAllArgument instead.
87
+ */
88
+ getAllParameters: () => {
89
+ // eslint-disable-next-line no-console
90
+ console.error(
91
+ 'CatalystDeprecationWarning: basicIO.getAllParameters() is deprecated due to usability issues. Please use basicIO.getAllArgument() method instead.'
92
+ );
93
+ return basicIO.getAllArguments();
94
+ },
95
+ setStatus: (status) => {
96
+ res.statusCode = status;
97
+ }
98
+ };
99
+ return basicIO;
100
+ }
101
+
102
+ /**
103
+ * BasicIO handler
104
+ */
105
+ export default (index, targetName, type) => async (req, res) => {
106
+ try {
107
+ if (index === undefined) {
108
+ throw new Error(`index of ${type} function is undefined`);
109
+ }
110
+ const userModule = await import(index);
111
+ if (type !== 'bio') {
112
+ throw new Error('Invalid URL pattern for the functions type: ' + type);
113
+ }
114
+ if (!('default' in userModule)) {
115
+ throw new Error('Could not find any default export');
116
+ }
117
+ if (typeof userModule.default !== 'function') {
118
+ throw new Error('The default export is not a function');
119
+ }
120
+ const locals = {
121
+ finalResponse: ''
122
+ };
123
+ const context = buildContext(req, res, locals);
124
+ const basicIO = await buildBasicIO(req, res, locals);
125
+ await userModule.default(context, basicIO);
126
+ } catch (e) {
127
+ const errorString = inspect(e);
128
+ // eslint-disable-next-line no-console
129
+ console.error('[' + targetName + '] ' + errorString);
130
+ res.writeHead(500);
131
+ res.end(errorString);
132
+ }
133
+ };
@@ -7,7 +7,7 @@ import PUPPETEER_HANDLER from './utils/puppeteer-handler.js';
7
7
 
8
8
  export const constructFunctionParameters = async (REQUEST, RESPONSE, path) => {
9
9
  const browser = await PUPPETEER_HANDLER.getBrowser(path);
10
- const context = await browser.createIncognitoBrowserContext();
10
+ const context = 'createIncognitoBrowserContext' in browser ? await browser.createIncognitoBrowserContext() : await browser.createBrowserContext();
11
11
  const page = await context.newPage();
12
12
  return [REQUEST, RESPONSE, page];
13
13
  };
@@ -67,7 +67,28 @@ const browserLogicHandler = async (req, res) => {
67
67
  }
68
68
  };
69
69
 
70
- const server = createServer(type === 'browserlogic' ? browserLogicHandler : aioHandler);
70
+ const bioHandler = async (req, res) => {
71
+ return (await import('./bio.js')).default(index, targetName, type)(req, res);
72
+ };
73
+
74
+ function getHandler() {
75
+ switch (type) {
76
+ case 'browserlogic': {
77
+ return browserLogicHandler;
78
+ }
79
+ case 'aio': {
80
+ return aioHandler;
81
+ }
82
+ case 'bio': {
83
+ return bioHandler;
84
+ }
85
+ default: {
86
+ throw Error('Invalid function type: ', type);
87
+ }
88
+ }
89
+ }
90
+
91
+ const server = createServer(getHandler());
71
92
 
72
93
  server.listen(listenPort, '127.0.0.1').on('error', (err) => {
73
94
  // eslint-disable-next-line no-console
@@ -0,0 +1,6 @@
1
+ import { ChildProcess } from 'child_process';
2
+ import { IServerDetails } from '../..';
3
+ import { IFnTarget, PythonFn } from '../../../../fn-utils/lib/common';
4
+ import { ContainerEvents } from '@zcatalyst/container-plugin';
5
+ declare const _default: (details: IServerDetails<IFnTarget<PythonFn>>) => Promise<ChildProcess | ContainerEvents>;
6
+ export default _default;