@yinuo-ngm/server 1.0.15 → 1.0.17

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 (349) hide show
  1. package/lib/app.js +3 -15
  2. package/lib/common/editor.js +2 -2
  3. package/lib/env.d.ts +1 -0
  4. package/lib/env.js +1 -0
  5. package/lib/plugins/error-handler.plugin.d.ts +2 -2
  6. package/lib/plugins/error-handler.plugin.js +97 -88
  7. package/lib/plugins/ws/topics/nginx.ws.js +2 -1
  8. package/lib/plugins/ws/topics/svn.ws.d.ts +2 -1
  9. package/lib/plugins/ws/topics/svn.ws.js +3 -2
  10. package/lib/plugins/ws/topics/syslog.ws.d.ts +1 -1
  11. package/lib/plugins/ws/topics/task.ws.d.ts +2 -1
  12. package/lib/plugins/ws/topics/task.ws.js +2 -1
  13. package/lib/plugins/ws/ws.context.d.ts +1 -1
  14. package/lib/plugins/ws/ws.plugin.js +4 -3
  15. package/lib/plugins/ws/ws.router.d.ts +2 -2
  16. package/lib/plugins/ws/ws.router.js +8 -7
  17. package/lib/routes/api-client/collection.routes.js +8 -6
  18. package/lib/routes/api-client/env.routes.js +4 -3
  19. package/lib/routes/api-client/history.routes.js +3 -2
  20. package/lib/routes/api-client/hub-token.routes.js +32 -10
  21. package/lib/routes/api-client/request.routes.js +7 -6
  22. package/lib/routes/api-client/send.routes.js +3 -2
  23. package/lib/routes/config.routes.js +5 -5
  24. package/lib/routes/hub.routes.js +10 -10
  25. package/lib/routes/index.js +2 -0
  26. package/lib/routes/nginx/nginx-lifecycle.routes.js +4 -0
  27. package/lib/routes/nginx/nginx-route.context.js +23 -7
  28. package/lib/routes/nginx/nginx-server.routes.js +158 -6
  29. package/lib/routes/node-version.routes.d.ts +2 -0
  30. package/lib/routes/node-version.routes.js +56 -0
  31. package/lib/routes/project.routes.js +14 -9
  32. package/lib/routes/rss.routes.js +3 -3
  33. package/lib/routes/sprite-browse.routes.js +21 -6
  34. package/lib/routes/sprite.routes.js +18 -12
  35. package/lib/routes/static-files.routes.js +21 -5
  36. package/lib/routes/svn.routes.js +5 -3
  37. package/lib/routes/system.routes.js +20 -1
  38. package/lib/routes/task.routes.js +10 -3
  39. package/package.json +13 -6
  40. package/www/3rdpartylicenses.txt +66 -118
  41. package/www/browser/chunk-2L7NUOMX.js +2 -0
  42. package/www/browser/chunk-2NZJ7CN2.js +20 -0
  43. package/www/browser/chunk-3CM4SKDO.js +15 -0
  44. package/www/browser/chunk-3I7BQCXS.js +1 -0
  45. package/www/browser/chunk-3M56F2S2.js +1 -0
  46. package/www/browser/chunk-3OHBKMAA.js +1 -0
  47. package/www/browser/chunk-3XNNQFWR.js +1 -0
  48. package/www/browser/chunk-4BRW6LCZ.js +4 -0
  49. package/www/browser/chunk-4LBSLURA.js +1 -0
  50. package/www/browser/chunk-4X42HB6N.js +2 -0
  51. package/www/browser/chunk-5DYX4DUX.js +11 -0
  52. package/www/browser/chunk-6SYVDN5L.js +1 -0
  53. package/www/browser/chunk-6YYNHZ2A.js +1 -0
  54. package/www/browser/chunk-75W3GVSO.js +1 -0
  55. package/www/browser/chunk-7U44RF5F.js +63 -0
  56. package/www/browser/chunk-AELTP6YN.js +1 -0
  57. package/www/browser/chunk-AMXRL4GR.js +1 -0
  58. package/www/browser/chunk-AV2ZODEH.js +1 -0
  59. package/www/browser/chunk-AZ6SIMYH.js +1 -0
  60. package/www/browser/chunk-B3C35ET3.js +2 -0
  61. package/www/browser/chunk-BTQIUVTQ.js +1 -0
  62. package/www/browser/chunk-CN5J4WNO.js +1 -0
  63. package/www/browser/chunk-D2ODDESN.js +1 -0
  64. package/www/browser/chunk-DE6E23ET.js +1 -0
  65. package/www/browser/chunk-DIJPUYIA.js +1 -0
  66. package/www/browser/chunk-DLGJD6YU.js +4 -0
  67. package/www/browser/chunk-EEDA5U4V.js +1 -0
  68. package/www/browser/chunk-FK6Z4HLL.js +1 -0
  69. package/www/browser/chunk-FL6GDGHW.js +1 -0
  70. package/www/browser/chunk-FXCG34QS.js +1 -0
  71. package/www/browser/chunk-H2USFIYR.js +1 -0
  72. package/www/browser/chunk-H5HGMOE6.js +1 -0
  73. package/www/browser/chunk-HB3HECPD.js +1 -0
  74. package/www/browser/chunk-HDNG236Q.js +1 -0
  75. package/www/browser/chunk-HFZLJHYR.js +1 -0
  76. package/www/browser/chunk-HJTXXSMC.js +1 -0
  77. package/www/browser/chunk-HUMCWAKJ.js +3 -0
  78. package/www/browser/chunk-IKB3EQCP.js +2 -0
  79. package/www/browser/chunk-K7PESFPY.js +1 -0
  80. package/www/browser/chunk-KRYMOHYF.js +2 -0
  81. package/www/browser/chunk-M4QRBV3K.js +1 -0
  82. package/www/browser/chunk-N2PELLMM.js +30 -0
  83. package/www/browser/chunk-ONXBYGIG.js +1 -0
  84. package/www/browser/chunk-OSBDR36P.js +1 -0
  85. package/www/browser/chunk-OZCK4XVV.js +1 -0
  86. package/www/browser/chunk-QJP5F735.js +1 -0
  87. package/www/browser/chunk-RGOYDY7H.js +1 -0
  88. package/www/browser/chunk-UJKK4A7Y.js +1 -0
  89. package/www/browser/chunk-WD2EKZQC.js +1 -0
  90. package/www/browser/chunk-WUA5JFDD.js +1 -0
  91. package/www/browser/chunk-XLFHB7RS.js +3 -0
  92. package/www/browser/chunk-YNW4HEJO.js +37 -0
  93. package/www/browser/chunk-ZTDLWBW5.js +1 -0
  94. package/www/browser/dark.css +1 -30433
  95. package/www/browser/default.css +1 -30149
  96. package/www/browser/index.html +3 -3
  97. package/www/browser/main-N64WJCHX.js +34 -0
  98. package/www/browser/scripts-U25HCVEI.js +6 -0
  99. package/www/browser/styles-ROAHD7MY.css +1 -0
  100. package/www/browser/add-widget-drawer.component.css.map +0 -7
  101. package/www/browser/advanced-editor.component.css.map +0 -7
  102. package/www/browser/api-client.component.css.map +0 -7
  103. package/www/browser/api-history-drawer.component.css.map +0 -7
  104. package/www/browser/app.css.map +0 -7
  105. package/www/browser/attachment-viewer.component.css.map +0 -7
  106. package/www/browser/auth-editor.component.css.map +0 -7
  107. package/www/browser/body-editor.component.css.map +0 -7
  108. package/www/browser/chunk-2YSUXBGC.js +0 -627
  109. package/www/browser/chunk-2YSUXBGC.js.map +0 -1
  110. package/www/browser/chunk-3G2GEOPV.js +0 -456
  111. package/www/browser/chunk-3G2GEOPV.js.map +0 -1
  112. package/www/browser/chunk-3L72DF3R.js +0 -1683
  113. package/www/browser/chunk-3L72DF3R.js.map +0 -1
  114. package/www/browser/chunk-3MCIETCQ.js +0 -8279
  115. package/www/browser/chunk-3MCIETCQ.js.map +0 -1
  116. package/www/browser/chunk-665WC4RU.js +0 -5383
  117. package/www/browser/chunk-665WC4RU.js.map +0 -1
  118. package/www/browser/chunk-6QMSEZPT.js +0 -10044
  119. package/www/browser/chunk-6QMSEZPT.js.map +0 -1
  120. package/www/browser/chunk-6TBQERYX.js +0 -280
  121. package/www/browser/chunk-6TBQERYX.js.map +0 -1
  122. package/www/browser/chunk-6UW4MRJZ.js +0 -43
  123. package/www/browser/chunk-6UW4MRJZ.js.map +0 -7
  124. package/www/browser/chunk-6XUMIL3W.js +0 -5495
  125. package/www/browser/chunk-6XUMIL3W.js.map +0 -1
  126. package/www/browser/chunk-724YOJI3.js +0 -903
  127. package/www/browser/chunk-724YOJI3.js.map +0 -1
  128. package/www/browser/chunk-766T7YES.js +0 -437
  129. package/www/browser/chunk-766T7YES.js.map +0 -1
  130. package/www/browser/chunk-7FC7DN65.js +0 -728
  131. package/www/browser/chunk-7FC7DN65.js.map +0 -1
  132. package/www/browser/chunk-APGQRYWX.js +0 -156
  133. package/www/browser/chunk-APGQRYWX.js.map +0 -7
  134. package/www/browser/chunk-AQHSGTHS.js +0 -1960
  135. package/www/browser/chunk-AQHSGTHS.js.map +0 -1
  136. package/www/browser/chunk-CTOEAJQK.js +0 -40
  137. package/www/browser/chunk-CTOEAJQK.js.map +0 -7
  138. package/www/browser/chunk-DEGQJKKZ.js +0 -409
  139. package/www/browser/chunk-DEGQJKKZ.js.map +0 -1
  140. package/www/browser/chunk-DIJX2663.js +0 -1166
  141. package/www/browser/chunk-DIJX2663.js.map +0 -1
  142. package/www/browser/chunk-E4XD4GLT.js +0 -427
  143. package/www/browser/chunk-E4XD4GLT.js.map +0 -1
  144. package/www/browser/chunk-EQOY6A3M.js +0 -212
  145. package/www/browser/chunk-EQOY6A3M.js.map +0 -1
  146. package/www/browser/chunk-ETTBRXVA.js +0 -2643
  147. package/www/browser/chunk-ETTBRXVA.js.map +0 -1
  148. package/www/browser/chunk-FLSUSPBD.js +0 -5569
  149. package/www/browser/chunk-FLSUSPBD.js.map +0 -1
  150. package/www/browser/chunk-FZNHBEAZ.js +0 -102
  151. package/www/browser/chunk-FZNHBEAZ.js.map +0 -1
  152. package/www/browser/chunk-GJC7CZIJ.js +0 -361
  153. package/www/browser/chunk-GJC7CZIJ.js.map +0 -7
  154. package/www/browser/chunk-GMCNMOTD.js +0 -844
  155. package/www/browser/chunk-GMCNMOTD.js.map +0 -7
  156. package/www/browser/chunk-H43HGCRW.js +0 -198
  157. package/www/browser/chunk-H43HGCRW.js.map +0 -7
  158. package/www/browser/chunk-J447GBHM.js +0 -160
  159. package/www/browser/chunk-J447GBHM.js.map +0 -1
  160. package/www/browser/chunk-JN3VOWP7.js +0 -384
  161. package/www/browser/chunk-JN3VOWP7.js.map +0 -1
  162. package/www/browser/chunk-KSHAGY2M.js +0 -399
  163. package/www/browser/chunk-KSHAGY2M.js.map +0 -7
  164. package/www/browser/chunk-KV72AKOD.js +0 -59
  165. package/www/browser/chunk-KV72AKOD.js.map +0 -7
  166. package/www/browser/chunk-LAVMY2SJ.js +0 -26
  167. package/www/browser/chunk-LAVMY2SJ.js.map +0 -7
  168. package/www/browser/chunk-LLRVGHG5.js +0 -73
  169. package/www/browser/chunk-LLRVGHG5.js.map +0 -7
  170. package/www/browser/chunk-LPME4AJ3.js +0 -196
  171. package/www/browser/chunk-LPME4AJ3.js.map +0 -1
  172. package/www/browser/chunk-LVPSURVU.js +0 -4615
  173. package/www/browser/chunk-LVPSURVU.js.map +0 -1
  174. package/www/browser/chunk-MMPO7QLO.js +0 -4146
  175. package/www/browser/chunk-MMPO7QLO.js.map +0 -7
  176. package/www/browser/chunk-O7LB6VFM.js +0 -1953
  177. package/www/browser/chunk-O7LB6VFM.js.map +0 -1
  178. package/www/browser/chunk-P5CWA4FO.js +0 -685
  179. package/www/browser/chunk-P5CWA4FO.js.map +0 -1
  180. package/www/browser/chunk-RBWIWNTL.js +0 -203
  181. package/www/browser/chunk-RBWIWNTL.js.map +0 -7
  182. package/www/browser/chunk-RUXJCM3V.js +0 -26199
  183. package/www/browser/chunk-RUXJCM3V.js.map +0 -1
  184. package/www/browser/chunk-S77VVYUZ.js +0 -168
  185. package/www/browser/chunk-S77VVYUZ.js.map +0 -1
  186. package/www/browser/chunk-SCXPYFOB.js +0 -4316
  187. package/www/browser/chunk-SCXPYFOB.js.map +0 -1
  188. package/www/browser/chunk-SS73S33S.js +0 -471
  189. package/www/browser/chunk-SS73S33S.js.map +0 -7
  190. package/www/browser/chunk-T6UAOWNP.js +0 -600
  191. package/www/browser/chunk-T6UAOWNP.js.map +0 -1
  192. package/www/browser/chunk-TEW4MY4J.js +0 -148
  193. package/www/browser/chunk-TEW4MY4J.js.map +0 -7
  194. package/www/browser/chunk-TVORF3SF.js +0 -82
  195. package/www/browser/chunk-TVORF3SF.js.map +0 -7
  196. package/www/browser/chunk-UAN42EUZ.js +0 -2147
  197. package/www/browser/chunk-UAN42EUZ.js.map +0 -1
  198. package/www/browser/chunk-ULOHDK7Y.js +0 -1
  199. package/www/browser/chunk-ULOHDK7Y.js.map +0 -7
  200. package/www/browser/chunk-UYJ3FVRV.js +0 -3978
  201. package/www/browser/chunk-UYJ3FVRV.js.map +0 -1
  202. package/www/browser/chunk-VXHZMSDM.js +0 -5509
  203. package/www/browser/chunk-VXHZMSDM.js.map +0 -1
  204. package/www/browser/chunk-VYNQPZQO.js +0 -281
  205. package/www/browser/chunk-VYNQPZQO.js.map +0 -1
  206. package/www/browser/chunk-W3J23PZI.js +0 -9213
  207. package/www/browser/chunk-W3J23PZI.js.map +0 -1
  208. package/www/browser/chunk-W5HGHCQT.js +0 -1642
  209. package/www/browser/chunk-W5HGHCQT.js.map +0 -7
  210. package/www/browser/chunk-XF5H7E4L.js +0 -4723
  211. package/www/browser/chunk-XF5H7E4L.js.map +0 -1
  212. package/www/browser/chunk-XNFNEBMY.js +0 -398
  213. package/www/browser/chunk-XNFNEBMY.js.map +0 -7
  214. package/www/browser/chunk-XQY5SPGI.js +0 -30811
  215. package/www/browser/chunk-XQY5SPGI.js.map +0 -1
  216. package/www/browser/chunk-Y7JBZHNK.js +0 -514
  217. package/www/browser/chunk-Y7JBZHNK.js.map +0 -1
  218. package/www/browser/chunk-YWHRP4X3.js +0 -406
  219. package/www/browser/chunk-YWHRP4X3.js.map +0 -1
  220. package/www/browser/chunk-Z7FJIV62.js +0 -95
  221. package/www/browser/chunk-Z7FJIV62.js.map +0 -7
  222. package/www/browser/chunk-ZBZHXS46.js +0 -1674
  223. package/www/browser/chunk-ZBZHXS46.js.map +0 -1
  224. package/www/browser/chunk-ZZA5NVAI.js +0 -735
  225. package/www/browser/chunk-ZZA5NVAI.js.map +0 -1
  226. package/www/browser/collection-modal.component.css.map +0 -7
  227. package/www/browser/collection-tree-item.component.css.map +0 -7
  228. package/www/browser/collection-tree.component.css.map +0 -7
  229. package/www/browser/config-change-bar-component.css.map +0 -7
  230. package/www/browser/config-item-component.css.map +0 -7
  231. package/www/browser/config-nav-component.css.map +0 -7
  232. package/www/browser/config-section-component.css.map +0 -7
  233. package/www/browser/create-summary-aside.component.css.map +0 -7
  234. package/www/browser/curl-actions.component.css.map +0 -7
  235. package/www/browser/dark.css.map +0 -7
  236. package/www/browser/dashboard-canvas.component.css.map +0 -7
  237. package/www/browser/dashboard.component.css.map +0 -7
  238. package/www/browser/default.css.map +0 -7
  239. package/www/browser/detail-item-card.component.css.map +0 -7
  240. package/www/browser/ellipsis-text.component.css.map +0 -7
  241. package/www/browser/env-modal.component.css.map +0 -7
  242. package/www/browser/env-picker.component.css.map +0 -7
  243. package/www/browser/feedback.component.css.map +0 -7
  244. package/www/browser/fs-explorer.component.css.map +0 -7
  245. package/www/browser/git-import-modal.component.css.map +0 -7
  246. package/www/browser/hub-v2-personal-token-modal.component.css.map +0 -7
  247. package/www/browser/issue-action-area.component.css.map +0 -7
  248. package/www/browser/issue-add-participants-dialog.component.css.map +0 -7
  249. package/www/browser/issue-assign-dialog.component.css.map +0 -7
  250. package/www/browser/issue-attachment-area.component.css.map +0 -7
  251. package/www/browser/issue-base-info-area.component.css.map +0 -7
  252. package/www/browser/issue-branches.component.css.map +0 -7
  253. package/www/browser/issue-close-dialog.component.css.map +0 -7
  254. package/www/browser/issue-collaborators-panel.component.css.map +0 -7
  255. package/www/browser/issue-comment-editor.component.css.map +0 -7
  256. package/www/browser/issue-create-branch-dialog.component.css.map +0 -7
  257. package/www/browser/issue-description-area.component.css.map +0 -7
  258. package/www/browser/issue-detail.component.css.map +0 -7
  259. package/www/browser/issue-resolve-dialog.component.css.map +0 -7
  260. package/www/browser/issue-start-own-branch-dialog.component.css.map +0 -7
  261. package/www/browser/issues-list-table.component.css.map +0 -7
  262. package/www/browser/issues.component.css.map +0 -7
  263. package/www/browser/kill-port-widget.component.css.map +0 -7
  264. package/www/browser/kv-table.component.css.map +0 -7
  265. package/www/browser/layout-footer.component.css.map +0 -7
  266. package/www/browser/layout-header.component.css.map +0 -7
  267. package/www/browser/layout-menu.component.css.map +0 -7
  268. package/www/browser/layout-project-nav.component.css.map +0 -7
  269. package/www/browser/layout-sidebar.component.css.map +0 -7
  270. package/www/browser/layout.component.css.map +0 -7
  271. package/www/browser/less-viewport-component.css.map +0 -7
  272. package/www/browser/main.js +0 -1872
  273. package/www/browser/main.js.map +0 -1
  274. package/www/browser/markdown-viewer.component.css.map +0 -7
  275. package/www/browser/news-feed-widget.component.css.map +0 -7
  276. package/www/browser/ng-devtool.component.css.map +0 -7
  277. package/www/browser/nginx-config-editor.component.css.map +0 -7
  278. package/www/browser/nginx-log-viewer.component.css.map +0 -7
  279. package/www/browser/nginx-secondary-logs-tab.component.css.map +0 -7
  280. package/www/browser/nginx-secondary-perf-tab.component.css.map +0 -7
  281. package/www/browser/nginx-secondary-settings-tab.component.css.map +0 -7
  282. package/www/browser/nginx-secondary-ssl-tab.component.css.map +0 -7
  283. package/www/browser/nginx-secondary-test-tab.component.css.map +0 -7
  284. package/www/browser/nginx-secondary-traffic-tab.component.css.map +0 -7
  285. package/www/browser/nginx-secondary-upstream-tab.component.css.map +0 -7
  286. package/www/browser/nginx-section-card.component.css.map +0 -7
  287. package/www/browser/nginx-server-drawer.component.css.map +0 -7
  288. package/www/browser/nginx-server-list.component.css.map +0 -7
  289. package/www/browser/nginx-stat-card.component.css.map +0 -7
  290. package/www/browser/nginx.component.css.map +0 -7
  291. package/www/browser/page-layout.component.css.map +0 -7
  292. package/www/browser/pick-workspace-modal.component.css.map +0 -7
  293. package/www/browser/polyfills.js +0 -26584
  294. package/www/browser/polyfills.js.map +0 -7
  295. package/www/browser/project-conf.component.css.map +0 -7
  296. package/www/browser/project-create-modal.component.css.map +0 -7
  297. package/www/browser/project-create.component.css.map +0 -7
  298. package/www/browser/project-deps.component.css.map +0 -7
  299. package/www/browser/project-edit-modal.component.css.map +0 -7
  300. package/www/browser/project-import.component.css.map +0 -7
  301. package/www/browser/project-item-popover.component.css.map +0 -7
  302. package/www/browser/project-item.component.css.map +0 -7
  303. package/www/browser/project-list.component.css.map +0 -7
  304. package/www/browser/projects.component.css.map +0 -7
  305. package/www/browser/quick-task-widget.component.css.map +0 -7
  306. package/www/browser/rd-action-area.component.css.map +0 -7
  307. package/www/browser/rd-advance-stage-dialog.component.css.map +0 -7
  308. package/www/browser/rd-block-dialog.component.css.map +0 -7
  309. package/www/browser/rd-create-dialog.component.css.map +0 -7
  310. package/www/browser/rd-detail.component.css.map +0 -7
  311. package/www/browser/rd-item-card.component.css.map +0 -7
  312. package/www/browser/rd-list-board.component.css.map +0 -7
  313. package/www/browser/rd-list-table.component.css.map +0 -7
  314. package/www/browser/rd.component.css.map +0 -7
  315. package/www/browser/request-collections.component.css.map +0 -7
  316. package/www/browser/request-editor.component.css.map +0 -7
  317. package/www/browser/request-list-item.component.css.map +0 -7
  318. package/www/browser/request-list.component.css.map +0 -7
  319. package/www/browser/request-tabs-bar.component.css.map +0 -7
  320. package/www/browser/request-tabs.component.css.map +0 -7
  321. package/www/browser/request-urlbar.component.css.map +0 -7
  322. package/www/browser/response-viewer.component.css.map +0 -7
  323. package/www/browser/scripts.js +0 -245
  324. package/www/browser/scripts.js.map +0 -7
  325. package/www/browser/setting.component.css.map +0 -7
  326. package/www/browser/sprite-conf-modal.component.css.map +0 -7
  327. package/www/browser/sprite-icons-panel-component.css.map +0 -7
  328. package/www/browser/sprite-images-panel-component.css.map +0 -7
  329. package/www/browser/sprite-result-tabs.component.css.map +0 -7
  330. package/www/browser/sprite-viewport-component.css.map +0 -7
  331. package/www/browser/sprite.component.css.map +0 -7
  332. package/www/browser/step-advance.component.css.map +0 -7
  333. package/www/browser/step-basic.component.css.map +0 -7
  334. package/www/browser/step-config.component.css.map +0 -7
  335. package/www/browser/step-features.component.css.map +0 -7
  336. package/www/browser/step-preset.component.css.map +0 -7
  337. package/www/browser/step-summary-aside.component.css.map +0 -7
  338. package/www/browser/styles.css +0 -258
  339. package/www/browser/styles.css.map +0 -7
  340. package/www/browser/system-log.component.css.map +0 -7
  341. package/www/browser/task-actions.component.css.map +0 -7
  342. package/www/browser/task-console.component.css.map +0 -7
  343. package/www/browser/task-header.component.css.map +0 -7
  344. package/www/browser/task-list.component.css.map +0 -7
  345. package/www/browser/tasks.component.css.map +0 -7
  346. package/www/browser/terminal-view.component.css.map +0 -7
  347. package/www/browser/welcome-widget.component.css.map +0 -7
  348. package/www/browser/widget-base.component.css.map +0 -7
  349. package/www/browser/widget-host.component.css.map +0 -7
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiClientHubTokenRoutes = apiClientHubTokenRoutes;
4
- const core_1 = require("@yinuo-ngm/core");
4
+ const errors_1 = require("@yinuo-ngm/errors");
5
5
  const api_1 = require("@yinuo-ngm/api");
6
6
  const node_stream_1 = require("node:stream");
7
7
  function normalizeNonEmptyString(value, field) {
8
8
  if (typeof value !== "string" || value.trim() === "") {
9
- throw new core_1.AppError("BAD_REQUEST", `${field} is required`);
9
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, `${field} is required`);
10
10
  }
11
11
  return value.trim();
12
12
  }
@@ -32,13 +32,13 @@ async function resolveHubTokenConfig(app, body, tokenType) {
32
32
  return { baseUrl: inlineBaseUrl, token: inlineToken };
33
33
  }
34
34
  if (!body.projectId) {
35
- throw new core_1.AppError("BAD_REQUEST", "projectId is required when baseUrl/token are not provided");
35
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "projectId is required when baseUrl/token are not provided");
36
36
  }
37
37
  const project = await app.core.project.get(body.projectId);
38
38
  const config = readHubTokenConfigFromProject(project);
39
39
  const resolvedToken = tokenType === "personal" ? body.personalToken?.trim() || config.personalToken : config.token;
40
40
  if (!config.baseUrl || !resolvedToken) {
41
- throw new core_1.AppError("BAD_REQUEST", tokenType === "personal"
41
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, tokenType === "personal"
42
42
  ? "project hub-v2 config missing (NGM_HUB_V2_BASE_URL/NGM_HUB_V2_PERSONAL_TOKEN)"
43
43
  : "project hub-v2 config missing (NGM_HUB_V2_BASE_URL/NGM_HUB_V2_TOKEN)");
44
44
  }
@@ -59,7 +59,7 @@ async function apiClientHubTokenRoutes(fastify) {
59
59
  const response = await requestHubApiRaw(baseUrl, "/api/token", token, "GET", normalizedPath);
60
60
  if (!response.ok) {
61
61
  const payload = await parseJson(response);
62
- throw new core_1.AppError("BAD_REQUEST", payload?.message || `hub-v2 request failed (${response.status})`, {
62
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, payload?.message || `hub-v2 request failed (${response.status})`, {
63
63
  status: response.status,
64
64
  response: payload,
65
65
  });
@@ -81,7 +81,29 @@ async function apiClientHubTokenRoutes(fastify) {
81
81
  const response = await requestHubApiRaw(baseUrl, "/api/token", token, "GET", normalizedPath);
82
82
  if (!response.ok) {
83
83
  const payload = await parseJson(response);
84
- throw new core_1.AppError("BAD_REQUEST", payload?.message || `hub-v2 request failed (${response.status})`, {
84
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, payload?.message || `hub-v2 request failed (${response.status})`, {
85
+ status: response.status,
86
+ response: payload,
87
+ });
88
+ }
89
+ copyRawResponseHeaders(response, reply);
90
+ const body = response.body;
91
+ if (!body) {
92
+ return reply.status(response.status).send();
93
+ }
94
+ return reply.status(response.status).send(node_stream_1.Readable.fromWeb(body));
95
+ });
96
+ fastify.get("/projects/:projectId/rd-items/:itemId/uploads/:uploadId/raw", async (req, reply) => {
97
+ const params = (req.params ?? {});
98
+ const projectId = normalizeNonEmptyString(params.projectId, "projectId");
99
+ const itemId = normalizeNonEmptyString(params.itemId, "itemId");
100
+ const uploadId = normalizeNonEmptyString(params.uploadId, "uploadId");
101
+ const { baseUrl, token, projectKey } = await resolveHubTokenConfig(fastify, { projectId }, "project");
102
+ const normalizedPath = normalizeHubTokenPath(`/rd-items/${itemId}/uploads/${uploadId}/raw`, projectKey);
103
+ const response = await requestHubApiRaw(baseUrl, "/api/token", token, "GET", normalizedPath);
104
+ if (!response.ok) {
105
+ const payload = await parseJson(response);
106
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, payload?.message || `hub-v2 request failed (${response.status})`, {
85
107
  status: response.status,
86
108
  response: payload,
87
109
  });
@@ -184,14 +206,14 @@ async function requestHubApi(baseUrl, apiPrefix, token, method, path, query, bod
184
206
  });
185
207
  const payload = await parseJson(response);
186
208
  if (!response.ok) {
187
- throw new core_1.AppError("BAD_REQUEST", payload?.message || `hub-v2 request failed (${response.status})`, {
209
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, payload?.message || `hub-v2 request failed (${response.status})`, {
188
210
  status: response.status,
189
211
  response: payload,
190
212
  });
191
213
  }
192
214
  if (payload && typeof payload === "object" && "code" in payload) {
193
215
  if (payload.code !== "OK") {
194
- throw new core_1.AppError("BAD_REQUEST", payload.message || "hub-v2 response error", {
216
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, payload.message || "hub-v2 response error", {
195
217
  response: payload,
196
218
  });
197
219
  }
@@ -237,7 +259,7 @@ function assertPathProjectSegmentNotLocalProjectId(path, projectId) {
237
259
  }
238
260
  const projectSegment = (matched[1] ?? "").trim();
239
261
  if (projectSegment && projectSegment === localProjectId) {
240
- throw new core_1.AppError("BAD_REQUEST", "path must use projectKey (or business relative path), not local projectId");
262
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "path must use projectKey (or business relative path), not local projectId");
241
263
  }
242
264
  }
243
265
  function normalizeHubTokenPath(path, projectKey) {
@@ -249,7 +271,7 @@ function normalizeHubTokenPath(path, projectKey) {
249
271
  return `/projects/${key}${rest}`;
250
272
  }
251
273
  if (!projectKey) {
252
- throw new core_1.AppError("BAD_REQUEST", "projectKey is required when path does not include /projects/:projectKey");
274
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "projectKey is required when path does not include /projects/:projectKey");
253
275
  }
254
276
  return `/projects/${projectKey}${p}`;
255
277
  }
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiClientRequestsRoutes = apiClientRequestsRoutes;
4
+ const errors_1 = require("@yinuo-ngm/errors");
4
5
  function parseScope(q) {
5
6
  const scope = (q?.scope ?? "project");
6
7
  const projectId = q?.projectId;
7
8
  if (scope === "project" && !projectId) {
8
- throw new Error("projectId is required when scope=project");
9
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "projectId is required when scope=project");
9
10
  }
10
11
  return { scope, projectId };
11
12
  }
@@ -30,9 +31,9 @@ async function apiClientRequestsRoutes(fastify) {
30
31
  const body = req.body;
31
32
  const scope = body?.scope ?? "project";
32
33
  if (scope === "project" && !body.projectId)
33
- throw new Error("projectId is required when scope=project");
34
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "projectId is required when scope=project");
34
35
  if (!body?.request?.id)
35
- throw new Error("request.id is required");
36
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "request.id is required");
36
37
  await api.saveRequest(body.request, scope, body.projectId);
37
38
  return { id: body.request.id };
38
39
  });
@@ -40,12 +41,12 @@ async function apiClientRequestsRoutes(fastify) {
40
41
  const body = req.body;
41
42
  const scope = body?.scope ?? "project";
42
43
  if (scope === "project" && !body.projectId)
43
- throw new Error("projectId is required when scope=project");
44
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "projectId is required when scope=project");
44
45
  if (!body?.request?.id)
45
- throw new Error("request.id is required");
46
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "request.id is required");
46
47
  const old = await api.getRequest(body.request.id, scope, body.projectId);
47
48
  if (!old)
48
- throw new Error("request not found: " + body.request.id);
49
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.NOT_FOUND, "request not found: " + body.request.id);
49
50
  const updated = {
50
51
  ...old,
51
52
  ...body.request,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiClientSendRoutes = apiClientSendRoutes;
4
+ const errors_1 = require("@yinuo-ngm/errors");
4
5
  const hub_cookie_jar_1 = require("./hub-cookie-jar");
5
6
  async function apiClientSendRoutes(fastify) {
6
7
  const api = fastify.api;
@@ -8,9 +9,9 @@ async function apiClientSendRoutes(fastify) {
8
9
  const body = req.body;
9
10
  const scope = body.scope ?? "project";
10
11
  if (scope === "project" && !body.projectId)
11
- throw new Error("projectId is required when scope=project");
12
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "projectId is required when scope=project");
12
13
  if (!body.request && !body.requestId)
13
- throw new Error("request or requestId is required");
14
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "request or requestId is required");
14
15
  const useCookieJar = body.useCookieJar !== false;
15
16
  const sessionKey = body.sessionKey ?? `${scope}:${body.projectId ?? "global"}:${body.envId ?? "default"}`;
16
17
  if (body.clearCookieJar) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = configRoutes;
4
- const core_1 = require("@yinuo-ngm/core");
4
+ const errors_1 = require("@yinuo-ngm/errors");
5
5
  const editor_1 = require("../common/editor");
6
6
  async function configRoutes(fastify) {
7
7
  fastify.get("/catalog/:projectId", async (req) => {
@@ -17,7 +17,7 @@ async function configRoutes(fastify) {
17
17
  const body = req.body;
18
18
  const next = body?.raw ?? body?.data;
19
19
  if (next === undefined) {
20
- throw new core_1.AppError("CONFIG_WRITE_FAILED", "missing body.raw or body.data", { projectId, docId });
20
+ throw new errors_1.CoreError(errors_1.CoreErrorCodes.CONFIG_WRITE_FAILED, "missing body.raw or body.data", { projectId, docId });
21
21
  }
22
22
  return await fastify.core.config.writeDoc(projectId, docId, next);
23
23
  });
@@ -29,7 +29,7 @@ async function configRoutes(fastify) {
29
29
  return { ok: true };
30
30
  }
31
31
  catch (e) {
32
- throw new core_1.AppError("EDITOR_LAUNCH_FAILED", e?.message || "openInEditor failed");
32
+ throw new errors_1.CoreError(errors_1.CoreErrorCodes.EDITOR_LAUNCH_FAILED, e?.message || "openInEditor failed");
33
33
  }
34
34
  });
35
35
  fastify.get("/readSchema/:projectId/:domainId", async (req) => {
@@ -41,7 +41,7 @@ async function configRoutes(fastify) {
41
41
  const body = req.body;
42
42
  const vm = body?.vm;
43
43
  if (vm === undefined) {
44
- throw new core_1.AppError("BAD_REQUEST", "missing body.vm");
44
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "missing body.vm");
45
45
  }
46
46
  await fastify.core.config.writeDomainSchema(projectId, domainId, vm);
47
47
  return {
@@ -58,7 +58,7 @@ async function configRoutes(fastify) {
58
58
  const body = req.body;
59
59
  const vm = body?.vm;
60
60
  if (vm === undefined) {
61
- throw new core_1.AppError("BAD_REQUEST", "missing body.vm");
61
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "missing body.vm");
62
62
  }
63
63
  return await fastify.core.config.diffDomainSchema(projectId, domainId, vm);
64
64
  });
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = hubRoutes;
4
- const core_1 = require("@yinuo-ngm/core");
4
+ const errors_1 = require("@yinuo-ngm/errors");
5
5
  const DEFAULT_HUB_PUBLIC_BASE_URL = "http://192.168.1.31:7070/api/public";
6
6
  function normalizeText(value, maxLen, fieldName) {
7
7
  if (value === undefined || value === null)
8
8
  return undefined;
9
9
  if (typeof value !== "string") {
10
- throw new core_1.AppError("BAD_REQUEST", `${fieldName} must be string`);
10
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, `${fieldName} must be string`);
11
11
  }
12
12
  const text = value.trim();
13
13
  if (text.length > maxLen) {
14
- throw new core_1.AppError("BAD_REQUEST", `${fieldName} length must <= ${maxLen}`);
14
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, `${fieldName} length must <= ${maxLen}`);
15
15
  }
16
16
  return text;
17
17
  }
18
18
  function validateBody(input) {
19
19
  if (!input || typeof input !== "object") {
20
- throw new core_1.AppError("BAD_REQUEST", "invalid feedback payload");
20
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "invalid feedback payload");
21
21
  }
22
22
  const body = input;
23
23
  const category = body.category;
@@ -29,13 +29,13 @@ function validateBody(input) {
29
29
  const clientVersion = normalizeText(body.clientVersion, 60, "clientVersion");
30
30
  const osInfo = normalizeText(body.osInfo, 200, "osInfo");
31
31
  if (!category || !["bug", "suggestion", "feature", "other"].includes(category)) {
32
- throw new core_1.AppError("BAD_REQUEST", "invalid feedback category");
32
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "invalid feedback category");
33
33
  }
34
34
  if (!title) {
35
- throw new core_1.AppError("BAD_REQUEST", "feedback title is required");
35
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "feedback title is required");
36
36
  }
37
37
  if (!content) {
38
- throw new core_1.AppError("BAD_REQUEST", "feedback content is required");
38
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, "feedback content is required");
39
39
  }
40
40
  return {
41
41
  category,
@@ -82,7 +82,7 @@ async function hubRoutes(app) {
82
82
  });
83
83
  }
84
84
  catch (error) {
85
- throw new core_1.AppError("UNKNOWN_ERROR", "failed to connect hub service", { cause: error?.message || String(error), targetUrl });
85
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.UNKNOWN_ERROR, "failed to connect hub service", { cause: error?.message || String(error), targetUrl });
86
86
  }
87
87
  let payload = null;
88
88
  try {
@@ -93,10 +93,10 @@ async function hubRoutes(app) {
93
93
  }
94
94
  if (!response.ok) {
95
95
  const message = payload?.message || `hub response error (${response.status})`;
96
- throw new core_1.AppError("UNKNOWN_ERROR", message, { status: response.status, payload });
96
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.UNKNOWN_ERROR, message, { status: response.status, payload });
97
97
  }
98
98
  if (payload?.code !== "OK") {
99
- throw new core_1.AppError("UNKNOWN_ERROR", payload?.message || "hub feedback submit failed", { payload });
99
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.UNKNOWN_ERROR, payload?.message || "hub feedback submit failed", { payload });
100
100
  }
101
101
  return payload?.data ?? payload;
102
102
  });
@@ -19,6 +19,7 @@ const svn_routes_1 = __importDefault(require("./svn.routes"));
19
19
  const sprite_browse_routes_1 = __importDefault(require("./sprite-browse.routes"));
20
20
  const static_files_routes_1 = __importDefault(require("./static-files.routes"));
21
21
  const hub_routes_1 = __importDefault(require("./hub.routes"));
22
+ const node_version_routes_1 = __importDefault(require("./node-version.routes"));
22
23
  async function routes(fastify) {
23
24
  await fastify.register(system_routes_1.default);
24
25
  await fastify.register(task_routes_1.default, { prefix: '/api/tasks' });
@@ -40,4 +41,5 @@ async function routes(fastify) {
40
41
  await fastify.register(api_client_1.apiClientCollectionsRoutes, { prefix: '/api/client/collections' });
41
42
  await fastify.register(api_client_1.apiClientHubTokenRoutes, { prefix: '/api/client/hub-token' });
42
43
  await fastify.register(nginx_routes_1.nginxRoutes, { prefix: '/api/nginx' });
44
+ await fastify.register(node_version_routes_1.default, { prefix: '/api/node-version' });
43
45
  }
@@ -65,6 +65,10 @@ function registerNginxLifecycleRoutes(context) {
65
65
  success: true,
66
66
  });
67
67
  });
68
+ fastify.get('/local-ip', async (_request, reply) => {
69
+ const result = await nginx.service.getLocalIp();
70
+ return reply.send(result);
71
+ });
68
72
  fastify.post('/start', async (_request, reply) => {
69
73
  const result = await nginx.service.start();
70
74
  if (result.success) {
@@ -2,23 +2,39 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNginxRouteContext = createNginxRouteContext;
4
4
  exports.sendBadRequest = sendBadRequest;
5
+ const promises_1 = require("fs/promises");
5
6
  const path_1 = require("path");
6
- const core_1 = require("@yinuo-ngm/core");
7
+ const errors_1 = require("@yinuo-ngm/errors");
7
8
  function createNginxRouteContext(fastify) {
8
9
  const nginx = fastify.nginx;
9
10
  const normalizeFsPath = (filePath) => (0, path_1.resolve)(filePath).replace(/\\/g, '/').toLowerCase();
10
11
  const ensureManageableConfigFile = async (rawPath) => {
11
12
  const filePath = rawPath?.trim();
12
13
  if (!filePath) {
13
- throw new Error('配置文件路径不能为空');
14
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, '配置文件路径不能为空');
14
15
  }
15
16
  const included = await nginx.config.getIncludedConfigs();
16
- const includedSet = new Set(included.map(item => normalizeFsPath(item)));
17
- const normalizedTarget = normalizeFsPath(filePath);
17
+ const includedSet = new Set();
18
+ for (const item of included) {
19
+ try {
20
+ includedSet.add(normalizeFsPath(await (0, promises_1.realpath)(item)));
21
+ }
22
+ catch {
23
+ includedSet.add(normalizeFsPath((0, path_1.resolve)(item)));
24
+ }
25
+ }
26
+ const resolvedTarget = (0, path_1.resolve)(filePath);
27
+ let normalizedTarget;
28
+ try {
29
+ normalizedTarget = normalizeFsPath(await (0, promises_1.realpath)(resolvedTarget));
30
+ }
31
+ catch {
32
+ normalizedTarget = normalizeFsPath(resolvedTarget);
33
+ }
18
34
  if (!includedSet.has(normalizedTarget)) {
19
- throw new Error('配置文件不在当前可管理列表中');
35
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.OP_NOT_FOUND, '配置文件不在当前可管理列表中');
20
36
  }
21
- return (0, path_1.resolve)(filePath);
37
+ return resolvedTarget;
22
38
  };
23
39
  return {
24
40
  fastify,
@@ -29,7 +45,7 @@ function createNginxRouteContext(fastify) {
29
45
  }
30
46
  function sendBadRequest(reply, error) {
31
47
  const message = error instanceof Error ? error.message : String(error ?? '未知错误');
32
- throw new core_1.AppError('BAD_REQUEST', message, {
48
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, message, {
33
49
  route: reply.request?.url,
34
50
  method: reply.request?.method,
35
51
  });
@@ -1,16 +1,80 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerNginxServerRoutes = registerNginxServerRoutes;
4
- const core_1 = require("@yinuo-ngm/core");
4
+ const errors_1 = require("@yinuo-ngm/errors");
5
5
  const nginx_route_context_1 = require("./nginx-route.context");
6
6
  function registerNginxServerRoutes(context) {
7
7
  const { fastify, nginx } = context;
8
+ const buildRuntimeStatus = (enabled, nginxRunning, pendingReload) => {
9
+ if (!enabled) {
10
+ return 'disabled';
11
+ }
12
+ if (nginxRunning === null) {
13
+ return 'unknown';
14
+ }
15
+ if (pendingReload) {
16
+ return 'pending';
17
+ }
18
+ return nginxRunning ? 'running' : 'stopped';
19
+ };
20
+ const parseIsoMs = (value) => {
21
+ const text = String(value || '').trim();
22
+ if (!text) {
23
+ return null;
24
+ }
25
+ const ms = Date.parse(text);
26
+ return Number.isFinite(ms) ? ms : null;
27
+ };
28
+ const isServerPendingReload = (server, nginxRunning, lastAppliedAt) => {
29
+ if (!server.enabled || !nginxRunning) {
30
+ return false;
31
+ }
32
+ if (lastAppliedAt === null) {
33
+ return false;
34
+ }
35
+ const changedAt = parseIsoMs(server.updatedAt) ?? parseIsoMs(server.createdAt);
36
+ if (changedAt === null) {
37
+ return false;
38
+ }
39
+ return changedAt > lastAppliedAt;
40
+ };
41
+ const resolveActor = (request) => {
42
+ const directHeader = request.headers['x-ngm-user'] || request.headers['x-user'] || request.headers['x-username'];
43
+ if (typeof directHeader === 'string' && directHeader.trim()) {
44
+ return directHeader.trim();
45
+ }
46
+ const user = request?.user;
47
+ if (typeof user?.name === 'string' && user.name.trim()) {
48
+ return user.name.trim();
49
+ }
50
+ if (typeof user?.username === 'string' && user.username.trim()) {
51
+ return user.username.trim();
52
+ }
53
+ if (typeof user?.id === 'string' && user.id.trim()) {
54
+ return user.id.trim();
55
+ }
56
+ return undefined;
57
+ };
8
58
  fastify.get('/servers', async (_request, reply) => {
9
59
  try {
10
60
  const servers = await nginx.server.getAllServers();
61
+ let nginxRunning = null;
62
+ let lastAppliedAt = null;
63
+ try {
64
+ const status = await nginx.service.getStatus();
65
+ nginxRunning = Boolean(status.isRunning);
66
+ lastAppliedAt = nginx.service.getLastConfigAppliedAt();
67
+ }
68
+ catch {
69
+ nginxRunning = null;
70
+ }
71
+ const enriched = servers.map(server => ({
72
+ ...server,
73
+ runtimeStatus: buildRuntimeStatus(Boolean(server.enabled), nginxRunning, isServerPendingReload(server, nginxRunning, lastAppliedAt)),
74
+ }));
11
75
  return reply.send({
12
76
  success: true,
13
- servers,
77
+ servers: enriched,
14
78
  });
15
79
  }
16
80
  catch (error) {
@@ -22,11 +86,25 @@ function registerNginxServerRoutes(context) {
22
86
  try {
23
87
  const server = await nginx.server.getServer(id);
24
88
  if (!server) {
25
- throw new core_1.AppError('NOT_FOUND', 'Server 不存在');
89
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.NOT_FOUND, 'Server 不存在');
90
+ }
91
+ let nginxRunning = null;
92
+ let lastAppliedAt = null;
93
+ try {
94
+ const status = await nginx.service.getStatus();
95
+ nginxRunning = Boolean(status.isRunning);
96
+ lastAppliedAt = nginx.service.getLastConfigAppliedAt();
26
97
  }
98
+ catch {
99
+ nginxRunning = null;
100
+ }
101
+ const enriched = {
102
+ ...server,
103
+ runtimeStatus: buildRuntimeStatus(Boolean(server.enabled), nginxRunning, isServerPendingReload(server, nginxRunning, lastAppliedAt)),
104
+ };
27
105
  return reply.send({
28
106
  success: true,
29
- server,
107
+ server: enriched,
30
108
  });
31
109
  }
32
110
  catch (error) {
@@ -35,7 +113,11 @@ function registerNginxServerRoutes(context) {
35
113
  });
36
114
  fastify.post('/servers', async (request, reply) => {
37
115
  try {
38
- const server = await nginx.server.createServer(request.body);
116
+ const actor = resolveActor(request);
117
+ const payload = actor
118
+ ? { ...request.body, createdBy: request.body?.createdBy || actor }
119
+ : { ...request.body };
120
+ const server = await nginx.server.createServer(payload);
39
121
  return reply.send({
40
122
  success: true,
41
123
  server,
@@ -61,9 +143,26 @@ function registerNginxServerRoutes(context) {
61
143
  fastify.delete('/servers/:id', async (request, reply) => {
62
144
  const { id } = request.params;
63
145
  try {
64
- await nginx.server.deleteServer(id);
146
+ const result = await nginx.server.deleteServer(id);
147
+ return reply.send({
148
+ success: true,
149
+ snapshotId: result.snapshotId,
150
+ });
151
+ }
152
+ catch (error) {
153
+ return (0, nginx_route_context_1.sendBadRequest)(reply, error);
154
+ }
155
+ });
156
+ fastify.post('/servers/restore-deleted', async (request, reply) => {
157
+ try {
158
+ const snapshotId = String(request.body?.snapshotId || '').trim();
159
+ if (!snapshotId) {
160
+ throw new errors_1.GlobalError(errors_1.GlobalErrorCodes.BAD_REQUEST, 'snapshotId 不能为空');
161
+ }
162
+ const server = await nginx.server.restoreDeletedServer(snapshotId);
65
163
  return reply.send({
66
164
  success: true,
165
+ server,
67
166
  });
68
167
  }
69
168
  catch (error) {
@@ -94,4 +193,57 @@ function registerNginxServerRoutes(context) {
94
193
  return (0, nginx_route_context_1.sendBadRequest)(reply, error);
95
194
  }
96
195
  });
196
+ fastify.post('/servers/import/parse', async (request, reply) => {
197
+ try {
198
+ const content = String(request.body?.content || '').trim();
199
+ if (!content) {
200
+ return reply.send({
201
+ success: true,
202
+ candidates: [],
203
+ });
204
+ }
205
+ const candidates = await nginx.server.parseImportCandidates(content);
206
+ return reply.send({
207
+ success: true,
208
+ candidates,
209
+ });
210
+ }
211
+ catch (error) {
212
+ return (0, nginx_route_context_1.sendBadRequest)(reply, error);
213
+ }
214
+ });
215
+ fastify.post('/servers/import/analyze', async (request, reply) => {
216
+ try {
217
+ const requests = Array.isArray(request.body?.requests) ? request.body.requests : [];
218
+ const candidates = await nginx.server.analyzeImportRequests(requests);
219
+ return reply.send({
220
+ success: true,
221
+ candidates,
222
+ });
223
+ }
224
+ catch (error) {
225
+ return (0, nginx_route_context_1.sendBadRequest)(reply, error);
226
+ }
227
+ });
228
+ fastify.post('/servers/validate-ssl-paths', async (request, reply) => {
229
+ try {
230
+ const certPath = String(request.body?.sslCert || '').trim();
231
+ const keyPath = String(request.body?.sslKey || '').trim();
232
+ const cert = certPath
233
+ ? await nginx.service.validateFileReadable(certPath)
234
+ : { exists: false, readable: false, error: '证书路径为空' };
235
+ const key = keyPath
236
+ ? await nginx.service.validateFileReadable(keyPath)
237
+ : { exists: false, readable: false, error: '私钥路径为空' };
238
+ return reply.send({
239
+ success: true,
240
+ valid: cert.exists && cert.readable && key.exists && key.readable,
241
+ cert,
242
+ key,
243
+ });
244
+ }
245
+ catch (error) {
246
+ return (0, nginx_route_context_1.sendBadRequest)(reply, error);
247
+ }
248
+ });
97
249
  }
@@ -0,0 +1,2 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ export default function nodeVersionRoutes(fastify: FastifyInstance): Promise<void>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = nodeVersionRoutes;
4
+ const errors_1 = require("@yinuo-ngm/errors");
5
+ async function nodeVersionRoutes(fastify) {
6
+ fastify.get('/current', async () => {
7
+ const service = fastify.core.nodeVersion;
8
+ return await service.getCurrentVersion();
9
+ });
10
+ fastify.post('/switch', async (req) => {
11
+ const { version } = req.body || {};
12
+ if (!version) {
13
+ throw new errors_1.CoreError(errors_1.CoreErrorCodes.VERSION_REQUIRED, '请指定要切换的 Node 版本', {});
14
+ }
15
+ const service = fastify.core.nodeVersion;
16
+ return await service.switchVersion(version);
17
+ });
18
+ fastify.post('/project-requirement', async (req) => {
19
+ const { projectPath } = req.body || {};
20
+ if (!projectPath) {
21
+ throw new errors_1.CoreError(errors_1.CoreErrorCodes.PROJECT_PATH_REQUIRED, '请指定项目路径', {});
22
+ }
23
+ const service = fastify.core.nodeVersion;
24
+ return await service.detectProjectRequirement(projectPath);
25
+ });
26
+ fastify.post('/install', async (req) => {
27
+ const { version } = req.body || {};
28
+ if (!version) {
29
+ throw new errors_1.CoreError(errors_1.CoreErrorCodes.VERSION_REQUIRED, '请指定要安装的 Node 版本', {});
30
+ }
31
+ const service = fastify.core.nodeVersion;
32
+ const result = await service.installNodeVersion(version);
33
+ return result;
34
+ });
35
+ fastify.post('/uninstall', async (req) => {
36
+ const { version } = req.body || {};
37
+ if (!version) {
38
+ throw new errors_1.CoreError(errors_1.CoreErrorCodes.VERSION_REQUIRED, '请指定要卸载的 Node 版本', {});
39
+ }
40
+ const service = fastify.core.nodeVersion;
41
+ const success = await service.uninstallNodeVersion(version);
42
+ return { success };
43
+ });
44
+ fastify.post('/write-engine-config', async (req) => {
45
+ const { projectPath, version } = req.body || {};
46
+ if (!projectPath) {
47
+ throw new errors_1.CoreError(errors_1.CoreErrorCodes.PROJECT_PATH_REQUIRED, '请指定项目路径', {});
48
+ }
49
+ if (!version) {
50
+ throw new errors_1.CoreError(errors_1.CoreErrorCodes.VERSION_REQUIRED, '请指定版本要求', {});
51
+ }
52
+ const service = fastify.core.nodeVersion;
53
+ const success = await service.writeEngineConfig(projectPath, version);
54
+ return { success };
55
+ });
56
+ }