@cc-monitoring/proxy-core 0.2.2 → 0.3.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.
- package/dist/docs/404.html +1 -1
- package/dist/docs/assets/{app.Ds2Uxv4L.js → app.Dc46Hlqp.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BN6hB8Jr.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.D7iOFhKw.js → VPLocalSearchBox.Snq5jR6J.js} +1 -1
- package/dist/docs/assets/chunks/{theme.BkZlTt1N.js → theme.XLtxGM-l.js} +2 -2
- package/dist/docs/index.html +2 -2
- package/dist/docs/overview.html +2 -2
- package/dist/docs/packages-utils.html +2 -2
- package/dist/docs/proxy-admin/env-and-build.html +2 -2
- package/dist/docs/proxy-admin/index.html +2 -2
- package/dist/docs/proxy-admin/layout-and-menu.html +2 -2
- package/dist/docs/proxy-admin/pages.html +2 -2
- package/dist/docs/proxy-admin/routing-and-auth.html +2 -2
- package/dist/docs/proxy-admin/services-and-mock.html +2 -2
- package/dist/docs/proxy-cli/api-layer.html +2 -2
- package/dist/docs/proxy-cli/app-shell.html +2 -2
- package/dist/docs/proxy-cli/components-common.html +2 -2
- package/dist/docs/proxy-cli/components-config.html +2 -2
- package/dist/docs/proxy-cli/components-requests.html +2 -2
- package/dist/docs/proxy-cli/components-stats.html +2 -2
- package/dist/docs/proxy-cli/components-status.html +2 -2
- package/dist/docs/proxy-cli/data-hooks.html +2 -2
- package/dist/docs/proxy-cli/index.html +2 -2
- package/dist/docs/proxy-cli/utils-and-i18n.html +2 -2
- package/dist/docs/proxy-core/chat-api.html +2 -2
- package/dist/docs/proxy-core/cli.html +2 -2
- package/dist/docs/proxy-core/config.html +2 -2
- package/dist/docs/proxy-core/data-layer.html +2 -2
- package/dist/docs/proxy-core/entry.html +2 -2
- package/dist/docs/proxy-core/index.html +2 -2
- package/dist/docs/proxy-core/pm2.html +2 -2
- package/dist/docs/proxy-core/providers.html +2 -2
- package/dist/docs/proxy-core/proxy.html +2 -2
- package/dist/docs/proxy-core/stats.html +2 -2
- package/dist/docs/proxy-core/tool.html +2 -2
- package/dist/docs/proxy-core/ui-routes.html +2 -2
- package/dist/docs/proxy-core/utilities.html +2 -2
- package/dist/docs/quickstart.html +2 -2
- package/dist/docs/request-flow.html +2 -2
- package/dist/server/__tests__/server.test.js +9 -1
- package/dist/server/__tests__/ui-route.test.js +8 -0
- package/dist/server/ui-route.js +113 -7
- package/dist/ui/assets/{1c-C7KZRvh6.js → 1c-Bx3CHH-I.js} +1 -1
- package/dist/ui/assets/{abnf-rbH4BYgb.js → abnf-NN4-iXDM.js} +1 -1
- package/dist/ui/assets/{abnfDiagram-VRR7QNED-CsrlZpVI.js → abnfDiagram-VRR7QNED-CXFZgDk7.js} +1 -1
- package/dist/ui/assets/{accesslog-wfx95i3E.js → accesslog-Bq9x4vSZ.js} +1 -1
- package/dist/ui/assets/{actionscript-BuxOQp2d.js → actionscript-CeaB6gjT.js} +1 -1
- package/dist/ui/assets/{ada-DehwW43k.js → ada-DObFDSC6.js} +1 -1
- package/dist/ui/assets/{angelscript-7gUy6Szo.js → angelscript-4pIbuWPH.js} +1 -1
- package/dist/ui/assets/{apache-DiOm0xtk.js → apache-w0LzP4me.js} +1 -1
- package/dist/ui/assets/{applescript-S2nImy_n.js → applescript-DXpD6Cc9.js} +1 -1
- package/dist/ui/assets/{arc-z1ZaQVy6.js → arc-Dtt1H4m8.js} +1 -1
- package/dist/ui/assets/{arcade-L8f7yWXC.js → arcade-D_zU9Djr.js} +1 -1
- package/dist/ui/assets/{architectureDiagram-ZJ3FMSHR-DT32VHeA.js → architectureDiagram-ZJ3FMSHR-C0E_eQDM.js} +1 -1
- package/dist/ui/assets/{arduino-D1nseRl0.js → arduino-BnmN_xp_.js} +1 -1
- package/dist/ui/assets/{armasm-DEAwmgFt.js → armasm-CH_xJaHf.js} +1 -1
- package/dist/ui/assets/{asciidoc-ChomWxo-.js → asciidoc-BlvZZ-hO.js} +1 -1
- package/dist/ui/assets/{aspectj-BcME-nXH.js → aspectj-DP5DdFKQ.js} +1 -1
- package/dist/ui/assets/{autohotkey-Dqoy8CWy.js → autohotkey-Cy7dy_B1.js} +1 -1
- package/dist/ui/assets/{autoit-DUmEmEI6.js → autoit-BmQwjQdM.js} +1 -1
- package/dist/ui/assets/{avrasm-B4CJIKtz.js → avrasm-fcPy4w1X.js} +1 -1
- package/dist/ui/assets/{awk-B6lV4WP7.js → awk-AlcwGSdk.js} +1 -1
- package/dist/ui/assets/{axapta-waVtTHBQ.js → axapta-NyMN6Mvz.js} +1 -1
- package/dist/ui/assets/{bash-ClPMFOBq.js → bash-Bn3yyTUs.js} +1 -1
- package/dist/ui/assets/{basic-Cz7me10H.js → basic-gp9eOjjv.js} +1 -1
- package/dist/ui/assets/{blockDiagram-677ZJIJ3-B27Rw2hP.js → blockDiagram-677ZJIJ3-BHAadGGo.js} +1 -1
- package/dist/ui/assets/{bnf-CjGNwAqq.js → bnf-DRAiK-_J.js} +1 -1
- package/dist/ui/assets/{brainfuck-CElobNvg.js → brainfuck-IYgPavhh.js} +1 -1
- package/dist/ui/assets/{coq-DHEZl785.js → c-Dht0EgwX.js} +1 -1
- package/dist/ui/assets/{c-like-D2GuWIZ_.js → c-like-B7T39dtK.js} +1 -1
- package/dist/ui/assets/{c4Diagram-LMCZKHZV-CSlrdDty.js → c4Diagram-LMCZKHZV-4cXT8R9f.js} +1 -1
- package/dist/ui/assets/{cal-BCRzq2sw.js → cal-DmXm_WLX.js} +1 -1
- package/dist/ui/assets/{capnproto-B99yx9xO.js → capnproto-Cb-rKd-Z.js} +1 -1
- package/dist/ui/assets/{ceylon-U_Jt92FS.js → ceylon-Bn2aNwEq.js} +1 -1
- package/dist/ui/assets/channel-BgAIihW-.js +1 -0
- package/dist/ui/assets/{chunk-2Q5K7J3B-BaNBaSzk.js → chunk-2Q5K7J3B-B3N_AddF.js} +1 -1
- package/dist/ui/assets/{chunk-32BRIVSS-C0nNm0HI.js → chunk-32BRIVSS-CW7iU3gE.js} +1 -1
- package/dist/ui/assets/{chunk-5VM5RSS4-jU6Zpw3b.js → chunk-5VM5RSS4-M8Ep3dJD.js} +1 -1
- package/dist/ui/assets/{chunk-EX3LRPZG-OXn_ntaE.js → chunk-EX3LRPZG-t2hCXH-v.js} +1 -1
- package/dist/ui/assets/{chunk-JWPE2WC7-_mz_TEbK.js → chunk-JWPE2WC7-rQK8maXo.js} +1 -1
- package/dist/ui/assets/{chunk-MOJQB5TN-DDc6cTc4.js → chunk-MOJQB5TN-BpU7vp3L.js} +1 -1
- package/dist/ui/assets/{chunk-RYQCIY6F-BQGpYEj2.js → chunk-RYQCIY6F-CJVNOulR.js} +1 -1
- package/dist/ui/assets/{chunk-V7JOEXUC-DcO6-4IE.js → chunk-V7JOEXUC-B--maww3.js} +1 -1
- package/dist/ui/assets/{chunk-VR4S4FIN-B_TVu9q6.js → chunk-VR4S4FIN-QJ5u9nSh.js} +1 -1
- package/dist/ui/assets/{chunk-XXDRQBXY-B6NyPvzj.js → chunk-XXDRQBXY-BcM9JOXa.js} +1 -1
- package/dist/ui/assets/classDiagram-OUVF2IWQ-0fsnUoNI.js +1 -0
- package/dist/ui/assets/classDiagram-v2-EOCWNBFH-0fsnUoNI.js +1 -0
- package/dist/ui/assets/{clean-BNABeqNs.js → clean-BCfhFoON.js} +1 -1
- package/dist/ui/assets/{clojure-ycs5E59I.js → clojure-DtnBj8eB.js} +1 -1
- package/dist/ui/assets/{clojure-repl-12Je9P3M.js → clojure-repl-D8X-urCW.js} +1 -1
- package/dist/ui/assets/{cmake-DmGk_v86.js → cmake-BH2RXBgt.js} +1 -1
- package/dist/ui/assets/{coffeescript-B1EFylGU.js → coffeescript-CuoLiQ_d.js} +1 -1
- package/dist/ui/assets/{c-Nl_NBAVi.js → coq-BYVsAo31.js} +1 -1
- package/dist/ui/assets/{cos-ClTPEnh8.js → cos-t-cDfrf6.js} +1 -1
- package/dist/ui/assets/{cose-bilkent-JH36ORCC-CruFl-Br.js → cose-bilkent-JH36ORCC-CYip_9u7.js} +1 -1
- package/dist/ui/assets/{cpp-CuI3hcw2.js → cpp-Cgv0dQ7g.js} +1 -1
- package/dist/ui/assets/{crmsh-BBCigZ9H.js → crmsh-7pr1Pq_e.js} +1 -1
- package/dist/ui/assets/{crystal-WqP1T2aP.js → crystal-BHZFifeV.js} +1 -1
- package/dist/ui/assets/{csharp-DX3AsWFr.js → csharp-CVMfBRGF.js} +1 -1
- package/dist/ui/assets/{csp-TwswWkBb.js → csp-NEBRDuZY.js} +1 -1
- package/dist/ui/assets/{css-gwfIC6qG.js → css-B0fbMkoQ.js} +1 -1
- package/dist/ui/assets/{cynefin-VYW2F7L2-Dk2bpbUZ.js → cynefin-VYW2F7L2-CycR2u2l.js} +1 -1
- package/dist/ui/assets/{cynefinDiagram-TSTJHNR4-D0cyq-BR.js → cynefinDiagram-TSTJHNR4-CvXYb5em.js} +1 -1
- package/dist/ui/assets/{d-dQjHiE7p.js → d-AzA6F7Ab.js} +1 -1
- package/dist/ui/assets/{dagre-VKFMJZFB-C-LrlEPD.js → dagre-VKFMJZFB-6NuSYMRG.js} +1 -1
- package/dist/ui/assets/{dart-yF24zq-M.js → dart-D0VXSwKi.js} +1 -1
- package/dist/ui/assets/{delphi-BoiD3RGE.js → delphi-B-bkLmCx.js} +1 -1
- package/dist/ui/assets/{diagram-FQU43EPY-BWEIklCL.js → diagram-FQU43EPY-CNNW_5O7.js} +1 -1
- package/dist/ui/assets/{diagram-G47NLZAW-0wUTN3Un.js → diagram-G47NLZAW-C60bRph-.js} +1 -1
- package/dist/ui/assets/{diagram-NH7WQ7WH-DBRO9o2w.js → diagram-NH7WQ7WH-CwERNWac.js} +1 -1
- package/dist/ui/assets/{diagram-OA4YK3LP-ezdq3ga2.js → diagram-OA4YK3LP-9XSTmf1Z.js} +1 -1
- package/dist/ui/assets/{diagram-WEI45ONY-etUIUVG6.js → diagram-WEI45ONY-h8K41_YA.js} +1 -1
- package/dist/ui/assets/{diff-d3MWGLkm.js → diff-Ch9RlEn8.js} +1 -1
- package/dist/ui/assets/{django-B3WbiOe4.js → django-C00rhzcB.js} +1 -1
- package/dist/ui/assets/{dns-NCrqim6V.js → dns-C5MKVde0.js} +1 -1
- package/dist/ui/assets/{dockerfile-CJ13MF6I.js → dockerfile-BpRaVDMB.js} +1 -1
- package/dist/ui/assets/{dos-Db7mY7hS.js → dos-CjQOJ_vn.js} +1 -1
- package/dist/ui/assets/{dsconfig-CgWMXu7p.js → dsconfig-3zd3UkyN.js} +1 -1
- package/dist/ui/assets/{dts-pg7x_twV.js → dts-Bb6PtK5T.js} +1 -1
- package/dist/ui/assets/{dust-C4AV7EjX.js → dust-BEJKezIa.js} +1 -1
- package/dist/ui/assets/{ebnf-C6W2hGVW.js → ebnf-5-TvfsoC.js} +1 -1
- package/dist/ui/assets/{ebnfDiagram-CCIWWBDH-4ylTuIqX.js → ebnfDiagram-CCIWWBDH-CRmIjeas.js} +1 -1
- package/dist/ui/assets/{elixir-CVB0pKqP.js → elixir-B6gSEyen.js} +1 -1
- package/dist/ui/assets/{elm--paTSGXv.js → elm-rR0aqyyf.js} +1 -1
- package/dist/ui/assets/{erDiagram-Q63AITRT-BRiGNkzo.js → erDiagram-Q63AITRT-DS3jYOq8.js} +1 -1
- package/dist/ui/assets/{erb-BG7KEhq6.js → erb-DUu22Jxg.js} +1 -1
- package/dist/ui/assets/{erlang-CYx4313K.js → erlang-C0m-R-6W.js} +1 -1
- package/dist/ui/assets/{erlang-repl-B1eR2_h4.js → erlang-repl-B7O2MhlI.js} +1 -1
- package/dist/ui/assets/{excel-Bo5gFhmE.js → excel-CIqnqFs1.js} +1 -1
- package/dist/ui/assets/{fix-DyCMTt3D.js → fix-Ds9tcTzQ.js} +1 -1
- package/dist/ui/assets/{flix-C3soTHxZ.js → flix-ByzuevTB.js} +1 -1
- package/dist/ui/assets/{flowDiagram-23GEKE2U-DnRu-msA.js → flowDiagram-23GEKE2U-B9F3S_Hl.js} +1 -1
- package/dist/ui/assets/{fortran-BAZ3TbMZ.js → fortran-DieSVGx5.js} +1 -1
- package/dist/ui/assets/{fsharp-CbXyiiTK.js → fsharp-DGP8m6H3.js} +1 -1
- package/dist/ui/assets/{gams-KyiDoPo0.js → gams-BiLGBohb.js} +1 -1
- package/dist/ui/assets/{ganttDiagram-NO4QXBWP-Dv28Wx1X.js → ganttDiagram-NO4QXBWP-CHiCWnJt.js} +1 -1
- package/dist/ui/assets/{gauss-B30tuE0E.js → gauss-Btl1fjJ0.js} +1 -1
- package/dist/ui/assets/{gcode-CcXQsQ65.js → gcode-DWl2YoL_.js} +1 -1
- package/dist/ui/assets/{gherkin-DASYHsIF.js → gherkin-D42ESIJ2.js} +1 -1
- package/dist/ui/assets/{gitGraphDiagram-IHSO6WYX-BJtz0wJv.js → gitGraphDiagram-IHSO6WYX-0pEKZnJg.js} +1 -1
- package/dist/ui/assets/{glsl-DsT445zJ.js → glsl-Dx1QhGIM.js} +1 -1
- package/dist/ui/assets/{gml-DI6qhLW8.js → gml-f0noEVTB.js} +1 -1
- package/dist/ui/assets/{go-CozWfkZh.js → go-DXT6c-0g.js} +1 -1
- package/dist/ui/assets/{golo-B0Q1mPx2.js → golo-D3NuJxTg.js} +1 -1
- package/dist/ui/assets/{gradle-BXIM-MF0.js → gradle-CUsTLc_e.js} +1 -1
- package/dist/ui/assets/{groovy-B5kuMJx3.js → groovy-BIkOcIpQ.js} +1 -1
- package/dist/ui/assets/{haml-B33XkhhN.js → haml-C5jI7YVN.js} +1 -1
- package/dist/ui/assets/{handlebars-CTKK0IeI.js → handlebars-UOvbWwDx.js} +1 -1
- package/dist/ui/assets/{haskell-QC_Q0V7u.js → haskell-DuO_Av2n.js} +1 -1
- package/dist/ui/assets/{haxe-yu-BgqN3.js → haxe-C0Cg5Hjh.js} +1 -1
- package/dist/ui/assets/{hsp-B3PG_u1G.js → hsp-CTDajZig.js} +1 -1
- package/dist/ui/assets/{htmlbars-D0njKLFp.js → htmlbars-_ITuCkOs.js} +1 -1
- package/dist/ui/assets/{http-Uyrnk7HS.js → http-Dr26PHfb.js} +1 -1
- package/dist/ui/assets/{hy-BlM3DnRp.js → hy-B-ThgV4T.js} +1 -1
- package/dist/ui/assets/index-C0fxlU9d.css +10 -0
- package/dist/ui/assets/{index-OZSlpEc0.js → index-CpQr158p.js} +3 -3
- package/dist/ui/assets/{index-NRrk4g4A.js → index-CwcnuNUs.js} +9 -9
- package/dist/ui/assets/{infoDiagram-FWYZ7A6U-DmQUKgjT.js → infoDiagram-FWYZ7A6U-ClKPOdlx.js} +1 -1
- package/dist/ui/assets/{inform7-CD6URK1q.js → inform7-D7JYYkX9.js} +1 -1
- package/dist/ui/assets/{ini-Bbj8w5ZO.js → ini-BZwCkFAf.js} +1 -1
- package/dist/ui/assets/{irpf90-BFmWsqzg.js → irpf90-omMve0rd.js} +1 -1
- package/dist/ui/assets/{isbl-CjYXfO56.js → isbl-C4xosfum.js} +1 -1
- package/dist/ui/assets/{ishikawaDiagram-FXEZZL3T-O7SLJb62.js → ishikawaDiagram-FXEZZL3T-PtbNBMgh.js} +1 -1
- package/dist/ui/assets/{java-BZnlVMI-.js → java-CWjWDe7Q.js} +1 -1
- package/dist/ui/assets/{javascript-Dma1Dwxh.js → javascript-C3dxrGuA.js} +1 -1
- package/dist/ui/assets/{jboss-cli-CEhyxkPd.js → jboss-cli-CJE7m0Y-.js} +1 -1
- package/dist/ui/assets/{journeyDiagram-5HDEW3XC-MpkkQY0B.js → journeyDiagram-5HDEW3XC-DgK9V4yg.js} +1 -1
- package/dist/ui/assets/{json-H5mfZ7Pi.js → json-DFUiNV7v.js} +1 -1
- package/dist/ui/assets/{julia-1nG6sJ0r.js → julia-CUTHpx8X.js} +1 -1
- package/dist/ui/assets/{julia-repl-CntcEG_W.js → julia-repl-_ZaQqdrz.js} +1 -1
- package/dist/ui/assets/{kanban-definition-HUTT4EX6-Db3VE7EX.js → kanban-definition-HUTT4EX6-BFrDfKdv.js} +1 -1
- package/dist/ui/assets/{kotlin-CPhttT28.js → kotlin-CrYjQYp8.js} +1 -1
- package/dist/ui/assets/{lasso-wS7HnKYr.js → lasso-CAiVg9m2.js} +1 -1
- package/dist/ui/assets/{latex-CgljIIKP.js → latex-BkxnXIrT.js} +1 -1
- package/dist/ui/assets/{ldif-C-TvljGO.js → ldif-CBOqxiN7.js} +1 -1
- package/dist/ui/assets/{leaf-BwLmF5QE.js → leaf-CbBZyOGH.js} +1 -1
- package/dist/ui/assets/{less-F0U3RAHy.js → less-Ca6uLPP0.js} +1 -1
- package/dist/ui/assets/{lisp-DyC1zr7v.js → lisp-0Cm7_Bzv.js} +1 -1
- package/dist/ui/assets/{livecodeserver-BiriPZPr.js → livecodeserver-B7ka0vFT.js} +1 -1
- package/dist/ui/assets/{livescript-DGM8pJWq.js → livescript-CGmWmcLd.js} +1 -1
- package/dist/ui/assets/{llvm-CtkKHWXn.js → llvm-DCVMvkrH.js} +1 -1
- package/dist/ui/assets/{lsl-Cjhhnjis.js → lsl-PVrTScpn.js} +1 -1
- package/dist/ui/assets/{lua-DLOv5eaM.js → lua-BTo3z2Ux.js} +1 -1
- package/dist/ui/assets/{makefile-B4dtBkQe.js → makefile-DJGh9r9C.js} +1 -1
- package/dist/ui/assets/{markdown-ePkodRQ8.js → markdown-BOloL-q7.js} +1 -1
- package/dist/ui/assets/{mathematica-CQQE1ZQG.js → mathematica-CtMMQM2V.js} +1 -1
- package/dist/ui/assets/{matlab-Cs5-JNnJ.js → matlab-Bfg_AWdR.js} +1 -1
- package/dist/ui/assets/{maxima-QE9z-w99.js → maxima-B2cdS7BY.js} +1 -1
- package/dist/ui/assets/{mel-BURbyN_f.js → mel-BvfPvpYI.js} +1 -1
- package/dist/ui/assets/{mercury-BitxBHU_.js → mercury-B6KgNIai.js} +1 -1
- package/dist/ui/assets/{mindmap-definition-LN4V7U3C-Bw4ydjz9.js → mindmap-definition-LN4V7U3C-BkeXo5If.js} +1 -1
- package/dist/ui/assets/{mipsasm-BlgfMbba.js → mipsasm-Csras-cD.js} +1 -1
- package/dist/ui/assets/{mizar-GVN5xqbG.js → mizar-C3WDI1-X.js} +1 -1
- package/dist/ui/assets/{mojolicious-BIe0_SWG.js → mojolicious-MnD2Whic.js} +1 -1
- package/dist/ui/assets/{monkey-Sk3HOegY.js → monkey-DLvUPYTI.js} +1 -1
- package/dist/ui/assets/{moonscript-CKzK_qTZ.js → moonscript-B0XEb3R3.js} +1 -1
- package/dist/ui/assets/{n1ql-CvydJYtK.js → n1ql-BMRF54sY.js} +1 -1
- package/dist/ui/assets/{nginx-BtJg8II3.js → nginx-DqUyeHb8.js} +1 -1
- package/dist/ui/assets/{nim-D8i-ABzP.js → nim-3xwg8mOL.js} +1 -1
- package/dist/ui/assets/{nix-B9yyBUw5.js → nix-ByTkLdcH.js} +1 -1
- package/dist/ui/assets/{node-repl-B4XEsNMv.js → node-repl-sGSuIUFG.js} +1 -1
- package/dist/ui/assets/{nsis-ChyN_1fJ.js → nsis-Dng5mFSM.js} +1 -1
- package/dist/ui/assets/{objectivec-DnetjEAi.js → objectivec-DSQ8vb7n.js} +1 -1
- package/dist/ui/assets/{ocaml-BrcMYDF8.js → ocaml-BHOhEgRu.js} +1 -1
- package/dist/ui/assets/{openscad-DsR3_5rd.js → openscad-DcUxQ-FQ.js} +1 -1
- package/dist/ui/assets/{oxygene-CJcqHbSp.js → oxygene-DNlmqhsR.js} +1 -1
- package/dist/ui/assets/{parser3-rLPmuX0l.js → parser3-DIR98Q6n.js} +1 -1
- package/dist/ui/assets/{pegDiagram-2B236MQR-B45-e_3g.js → pegDiagram-2B236MQR-BrXp_1_9.js} +1 -1
- package/dist/ui/assets/{perl-D1P4EjI7.js → perl-16cY7fyu.js} +1 -1
- package/dist/ui/assets/{pf-Cw-eylMK.js → pf-KrAq2BW7.js} +1 -1
- package/dist/ui/assets/{pgsql-CgP7PN1J.js → pgsql-BV1Z2bjp.js} +1 -1
- package/dist/ui/assets/{php-DI1wNKqt.js → php-FGjYSZqs.js} +1 -1
- package/dist/ui/assets/{php-template-B0K4ynh6.js → php-template-B1OW86WT.js} +1 -1
- package/dist/ui/assets/{pieDiagram-ENE6RG2P-CNnGOE0h.js → pieDiagram-ENE6RG2P-Bh0bhWSa.js} +1 -1
- package/dist/ui/assets/{plaintext-BEk_4pPM.js → plaintext-Cvn_UgSv.js} +1 -1
- package/dist/ui/assets/{pony-F76a7Unf.js → pony-CRWnA3MR.js} +1 -1
- package/dist/ui/assets/{powershell-Drv4DLdv.js → powershell-Cwn155MZ.js} +1 -1
- package/dist/ui/assets/{processing-CNka_lTw.js → processing-BS6-1lrQ.js} +1 -1
- package/dist/ui/assets/{profile-awY_Eplf.js → profile-C45OLQrv.js} +1 -1
- package/dist/ui/assets/{prolog-C5qzaqI4.js → prolog-C5YafSzY.js} +1 -1
- package/dist/ui/assets/{properties-D5qt9E1z.js → properties-BULd-Zhg.js} +1 -1
- package/dist/ui/assets/{protobuf-Bi8ASQx6.js → protobuf-Qf1IuG5l.js} +1 -1
- package/dist/ui/assets/{puppet-DRmUQ-KT.js → puppet-93XdQvnn.js} +1 -1
- package/dist/ui/assets/{purebasic-CoXKqxfT.js → purebasic-DlYNScQP.js} +1 -1
- package/dist/ui/assets/{python-W0cqezvd.js → python-D-Do6-F0.js} +1 -1
- package/dist/ui/assets/{python-repl-CxrHJNSQ.js → python-repl-DGutP04w.js} +1 -1
- package/dist/ui/assets/{q-Ckg0nbZC.js → q-lmgfrySy.js} +1 -1
- package/dist/ui/assets/{qml-Dxe5R2xD.js → qml-BbjX_mSU.js} +1 -1
- package/dist/ui/assets/{quadrantDiagram-ABIIQ3AL-CNwsTWzK.js → quadrantDiagram-ABIIQ3AL-B891FOO8.js} +1 -1
- package/dist/ui/assets/{r-Cz_ed3iA.js → r--x8NzO9N.js} +1 -1
- package/dist/ui/assets/{railroadDiagram-RFXS5EU6-BNZ8bh79.js → railroadDiagram-RFXS5EU6-R3O-GKNe.js} +1 -1
- package/dist/ui/assets/{reasonml-D4d-OlE3.js → reasonml-DwHsAflh.js} +1 -1
- package/dist/ui/assets/{requirementDiagram-TGXJPOKE-C2CgrWHx.js → requirementDiagram-TGXJPOKE-D4l_xEXt.js} +1 -1
- package/dist/ui/assets/{rib-DxeIIMvO.js → rib-DMJNtDwV.js} +1 -1
- package/dist/ui/assets/{roboconf-nIWJYVLh.js → roboconf-BNNGTvHr.js} +1 -1
- package/dist/ui/assets/{routeros-BjUh3h-m.js → routeros-BF7SVruD.js} +1 -1
- package/dist/ui/assets/{rsl-oNTr7uJS.js → rsl-1EHeIZqp.js} +1 -1
- package/dist/ui/assets/{ruby-BtH0edki.js → ruby-B-v_BYYp.js} +1 -1
- package/dist/ui/assets/{ruleslanguage-uj_5EYxA.js → ruleslanguage-GFeEMSdK.js} +1 -1
- package/dist/ui/assets/{rust-DbdkZ_sq.js → rust-ApqGtMhh.js} +1 -1
- package/dist/ui/assets/{sankeyDiagram-HTMAVEWB-16qZ8WVd.js → sankeyDiagram-HTMAVEWB-Dc-2lhBq.js} +1 -1
- package/dist/ui/assets/{sas-qD47QRwD.js → sas-YkxX6N9_.js} +1 -1
- package/dist/ui/assets/{scala-CwuOkN9e.js → scala-BpHi86GZ.js} +1 -1
- package/dist/ui/assets/{scheme-DdIlarQo.js → scheme-D889qY8Y.js} +1 -1
- package/dist/ui/assets/{scilab-Bx8vbirN.js → scilab-C3l-bcRx.js} +1 -1
- package/dist/ui/assets/{scss-CUPdZpVN.js → scss-D0iGASxm.js} +1 -1
- package/dist/ui/assets/{sequenceDiagram-DBY2YBRQ-BdEfz6xT.js → sequenceDiagram-DBY2YBRQ-DvppgciC.js} +1 -1
- package/dist/ui/assets/{shell-BajESx14.js → shell-PUnaEPCO.js} +1 -1
- package/dist/ui/assets/{sizeCapture-X5ZJPWSS-aVvYdwOp.js → sizeCapture-X5ZJPWSS-DhvIbxXs.js} +1 -1
- package/dist/ui/assets/{smali-3askOdPh.js → smali-Du_dF9hl.js} +1 -1
- package/dist/ui/assets/{smalltalk-BxL_ZFXR.js → smalltalk-CSr2Gc1v.js} +1 -1
- package/dist/ui/assets/{sml-CdbQXx5B.js → sml-D3zkvzP2.js} +1 -1
- package/dist/ui/assets/{sqf-CofNG_K6.js → sqf-BZQ34qEZ.js} +1 -1
- package/dist/ui/assets/{sql-C41Co4Cj.js → sql-BFKScMsf.js} +1 -1
- package/dist/ui/assets/{sql_more-XpCEwTjD.js → sql_more-C2Lc_Qqq.js} +1 -1
- package/dist/ui/assets/{stan-BEGVpGor.js → stan-CzY8VdxU.js} +1 -1
- package/dist/ui/assets/{stata-892sgSff.js → stata-9GxyhPpV.js} +1 -1
- package/dist/ui/assets/{stateDiagram-2N3HPSRC-DAPoOWtx.js → stateDiagram-2N3HPSRC-CM63y6f0.js} +1 -1
- package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-OA9dcuA9.js +1 -0
- package/dist/ui/assets/{step21-2ZAu8khe.js → step21-BpK_Zw3v.js} +1 -1
- package/dist/ui/assets/{stylus-D814tFaD.js → stylus-DQ4k28M4.js} +1 -1
- package/dist/ui/assets/{subunit-DEpZ85KD.js → subunit-C6ciOPNF.js} +1 -1
- package/dist/ui/assets/{swift-ClEw79Mw.js → swift-CJfqqSbT.js} +1 -1
- package/dist/ui/assets/{swimlanes-5IMT3BWC-DFGRjclX.js → swimlanes-5IMT3BWC-DS6_HNF7.js} +2 -2
- package/dist/ui/assets/swimlanesDiagram-G3AALYLV-BLEnJU_R.js +8 -0
- package/dist/ui/assets/{taggerscript-ukufG6Ek.js → taggerscript-VouMmJ_v.js} +1 -1
- package/dist/ui/assets/{tap-CTp3nMDX.js → tap-wXCy18ot.js} +1 -1
- package/dist/ui/assets/{tcl-t5Zp339F.js → tcl-ewDOmCFX.js} +1 -1
- package/dist/ui/assets/{thrift-DdarrdrF.js → thrift-BfFA03rE.js} +1 -1
- package/dist/ui/assets/{timeline-definition-FHXFAJF6-BS-C26Qb.js → timeline-definition-FHXFAJF6-Dz2m6S6x.js} +1 -1
- package/dist/ui/assets/{tp-CtojFa_d.js → tp-HGBcpNf9.js} +1 -1
- package/dist/ui/assets/{twig-BPsxcesM.js → twig-nrQZ0pw8.js} +1 -1
- package/dist/ui/assets/{typescript-6kEdCx2Q.js → typescript-B7tNYFEQ.js} +1 -1
- package/dist/ui/assets/{vala-D1DlBeT3.js → vala-BIjQtoo6.js} +1 -1
- package/dist/ui/assets/{vbnet-Bn6rfnXu.js → vbnet-Bbspccm6.js} +1 -1
- package/dist/ui/assets/{vbscript-TF83cChH.js → vbscript-C45_QgOy.js} +1 -1
- package/dist/ui/assets/{vbscript-html-CAkjMpQ-.js → vbscript-html-DlF2QBc7.js} +1 -1
- package/dist/ui/assets/{vennDiagram-L72KCM5P-Bt9uXi7H.js → vennDiagram-L72KCM5P-BPEphYtX.js} +1 -1
- package/dist/ui/assets/{verilog-DloD_4TS.js → verilog-BSitd8W0.js} +1 -1
- package/dist/ui/assets/{vhdl-DCUu0H1k.js → vhdl-C1bbeiC4.js} +1 -1
- package/dist/ui/assets/{vim-C1KMXofx.js → vim-DchwbT8X.js} +1 -1
- package/dist/ui/assets/{wardleyDiagram-EHGQE667-CRJZVMiO.js → wardleyDiagram-EHGQE667-BttTCoBT.js} +1 -1
- package/dist/ui/assets/{x86asm-DLhmDcw-.js → x86asm-vARxMUvn.js} +1 -1
- package/dist/ui/assets/{xl-D-Q0_1ob.js → xl-dx63vvXo.js} +1 -1
- package/dist/ui/assets/{xml-DT0X-CDl.js → xml-BUnj27wL.js} +1 -1
- package/dist/ui/assets/{xquery-D5QCuduM.js → xquery-T7gpnf0e.js} +1 -1
- package/dist/ui/assets/{xychartDiagram-FW5EYKEG-CLh0FXSc.js → xychartDiagram-FW5EYKEG-BfrNhdrG.js} +1 -1
- package/dist/ui/assets/{yaml-cRNpmbtO.js → yaml-xRgQKzeL.js} +1 -1
- package/dist/ui/assets/{zephir-Bgo4Omj1.js → zephir-Yu6l5qJj.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/__tests__/knowledge-store.test.js +86 -5
- package/dist/utils/__tests__/pi-browser-tools.test.d.ts +1 -0
- package/dist/utils/__tests__/pi-browser-tools.test.js +30 -0
- package/dist/utils/__tests__/pi-crawl-tools.test.d.ts +1 -0
- package/dist/utils/__tests__/pi-crawl-tools.test.js +315 -0
- package/dist/utils/__tests__/pi-dedup-reconcile.test.d.ts +1 -0
- package/dist/utils/__tests__/pi-dedup-reconcile.test.js +89 -0
- package/dist/utils/__tests__/pi-dedup.test.d.ts +1 -0
- package/dist/utils/__tests__/pi-dedup.test.js +106 -0
- package/dist/utils/__tests__/pi-learn-orchestrator.test.d.ts +1 -0
- package/dist/utils/__tests__/pi-learn-orchestrator.test.js +885 -0
- package/dist/utils/__tests__/pi-runtime-json.test.d.ts +1 -0
- package/dist/utils/__tests__/pi-runtime-json.test.js +11 -0
- package/dist/utils/__tests__/web-crawler.test.d.ts +1 -0
- package/dist/utils/__tests__/web-crawler.test.js +69 -0
- package/dist/utils/knowledge-store.d.ts +2 -0
- package/dist/utils/knowledge-store.js +32 -6
- package/dist/utils/pi-browser-tools.d.ts +2 -0
- package/dist/utils/pi-browser-tools.js +11 -2
- package/dist/utils/pi-crawl-tools.d.ts +62 -0
- package/dist/utils/pi-crawl-tools.js +298 -0
- package/dist/utils/pi-dedup.d.ts +62 -0
- package/dist/utils/pi-dedup.js +218 -0
- package/dist/utils/pi-learn-orchestrator.d.ts +44 -0
- package/dist/utils/pi-learn-orchestrator.js +431 -0
- package/dist/utils/pi-runtime.d.ts +23 -1
- package/dist/utils/pi-runtime.js +255 -68
- package/dist/utils/web-crawler.d.ts +13 -0
- package/dist/utils/web-crawler.js +64 -0
- package/package.json +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BwFhuAyr.js +0 -1
- package/dist/ui/assets/channel-BTNstqrR.js +0 -1
- package/dist/ui/assets/classDiagram-OUVF2IWQ-DEEnAFj7.js +0 -1
- package/dist/ui/assets/classDiagram-v2-EOCWNBFH-DEEnAFj7.js +0 -1
- package/dist/ui/assets/index-WPLwx8h5.css +0 -10
- package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-BljEUN9T.js +0 -1
- package/dist/ui/assets/swimlanesDiagram-G3AALYLV-BTfd8GBV.js +0 -8
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { promises as fsp } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
// Mock ego-browser:默认 navigate / close 均经 runEgoBrowser 子进程
|
|
5
|
+
jest.mock('../pi-browser-tools.js', () => ({
|
|
6
|
+
runEgoBrowser: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
import { runEgoBrowser } from '../pi-browser-tools.js';
|
|
9
|
+
import { CrawlGuard, createCrawlTools } from '../pi-crawl-tools.js';
|
|
10
|
+
const mockRunEgoBrowser = runEgoBrowser;
|
|
11
|
+
/** 构造一张 url -> 页面 的图;未登记的 URL navigate 抛错(模拟抓取失败) */
|
|
12
|
+
function makeGraphNav(graph) {
|
|
13
|
+
return async (url) => {
|
|
14
|
+
const page = graph[url];
|
|
15
|
+
if (!page)
|
|
16
|
+
throw new Error(`fixture missing: ${url}`);
|
|
17
|
+
return { ...page };
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
let tmpDir;
|
|
21
|
+
const docsDir = () => path.join(tmpDir, 'docs');
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
tmpDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'crawl-tools-'));
|
|
24
|
+
mockRunEgoBrowser.mockReset();
|
|
25
|
+
});
|
|
26
|
+
afterEach(async () => {
|
|
27
|
+
await fsp.rm(tmpDir, { recursive: true, force: true });
|
|
28
|
+
});
|
|
29
|
+
describe('CrawlGuard.open', () => {
|
|
30
|
+
it('入口页登记为 depth 0 并返回页面信息', async () => {
|
|
31
|
+
const guard = new CrawlGuard({
|
|
32
|
+
entryUrl: 'https://pi.dev/',
|
|
33
|
+
docsDir: docsDir(),
|
|
34
|
+
slug: 'pi',
|
|
35
|
+
navigate: makeGraphNav({
|
|
36
|
+
'https://pi.dev/': { title: 'Pi', text: 'A text', links: ['https://pi.dev/b'] },
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
const page = await guard.open();
|
|
40
|
+
expect(page).toEqual({
|
|
41
|
+
url: 'https://pi.dev/',
|
|
42
|
+
title: 'Pi',
|
|
43
|
+
text: 'A text',
|
|
44
|
+
links: ['https://pi.dev/b'],
|
|
45
|
+
});
|
|
46
|
+
expect(guard.savedCount).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
it('入口 URL 非法时抛错', async () => {
|
|
49
|
+
const guard = new CrawlGuard({
|
|
50
|
+
entryUrl: 'not a url',
|
|
51
|
+
docsDir: docsDir(),
|
|
52
|
+
slug: 'pi',
|
|
53
|
+
navigate: makeGraphNav({}),
|
|
54
|
+
});
|
|
55
|
+
await expect(guard.open()).rejects.toThrow();
|
|
56
|
+
});
|
|
57
|
+
it('未注入 navigate 时默认走 runEgoBrowser 并解析 JSON', async () => {
|
|
58
|
+
mockRunEgoBrowser.mockResolvedValue(JSON.stringify({ title: 'T', text: 'X', links: ['https://pi.dev/b'] }));
|
|
59
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi' });
|
|
60
|
+
const page = await guard.open();
|
|
61
|
+
expect(page.title).toBe('T');
|
|
62
|
+
expect(page.text).toBe('X');
|
|
63
|
+
expect(page.links).toEqual(['https://pi.dev/b']);
|
|
64
|
+
// 抓取脚本 timeoutMs 60000,URL 以 JSON 字面量注入
|
|
65
|
+
expect(mockRunEgoBrowser).toHaveBeenCalledWith(expect.any(String), { timeoutMs: 60000 });
|
|
66
|
+
expect(mockRunEgoBrowser.mock.calls[0][0]).toContain(JSON.stringify('https://pi.dev/'));
|
|
67
|
+
expect(mockRunEgoBrowser.mock.calls[0][0]).toContain('await task.newPage()');
|
|
68
|
+
});
|
|
69
|
+
it('浏览器输出 JSON parse 失败时抛错', async () => {
|
|
70
|
+
mockRunEgoBrowser.mockResolvedValue('not-json');
|
|
71
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi' });
|
|
72
|
+
await expect(guard.open()).rejects.toThrow(/parse/);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('CrawlGuard.visit', () => {
|
|
76
|
+
let graph;
|
|
77
|
+
beforeEach(() => {
|
|
78
|
+
graph = {
|
|
79
|
+
'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b'] },
|
|
80
|
+
'https://pi.dev/b': { title: 'B', text: 'B text', links: ['https://pi.dev/c'] },
|
|
81
|
+
'https://pi.dev/c': { title: 'C', text: 'C text', links: [] },
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
it('同站子页推进深度(0 → 1),登记状态并返回页面信息', async () => {
|
|
85
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(graph) });
|
|
86
|
+
await guard.open();
|
|
87
|
+
const page = await guard.visit('https://pi.dev/b');
|
|
88
|
+
expect(page).toEqual({ url: 'https://pi.dev/b', title: 'B', text: 'B text', links: ['https://pi.dev/c'] });
|
|
89
|
+
// 再访问 c:当前深度 1 + 1 = 2 > maxDepth(1) → 拒绝
|
|
90
|
+
await expect(guard.visit('https://pi.dev/c')).rejects.toThrow(/max-depth/);
|
|
91
|
+
});
|
|
92
|
+
it('跨站链接 throw cross-site', async () => {
|
|
93
|
+
graph['https://pi.dev/'].links.push('https://other.com/x');
|
|
94
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(graph) });
|
|
95
|
+
await guard.open();
|
|
96
|
+
await expect(guard.visit('https://other.com/x')).rejects.toThrow(/cross-site/);
|
|
97
|
+
});
|
|
98
|
+
it('二进制资源链接 throw', async () => {
|
|
99
|
+
graph['https://pi.dev/'].links.push('https://pi.dev/file.pdf');
|
|
100
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(graph) });
|
|
101
|
+
await guard.open();
|
|
102
|
+
await expect(guard.visit('https://pi.dev/file.pdf')).rejects.toThrow();
|
|
103
|
+
});
|
|
104
|
+
it('已访问(seen,含纯锚点归一)throw seen', async () => {
|
|
105
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(graph) });
|
|
106
|
+
await guard.open();
|
|
107
|
+
await expect(guard.visit('https://pi.dev/#section')).rejects.toThrow(/seen/);
|
|
108
|
+
});
|
|
109
|
+
it('maxDepth=0 时任何子页 throw max-depth', async () => {
|
|
110
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', maxDepth: 0, navigate: makeGraphNav(graph) });
|
|
111
|
+
await guard.open();
|
|
112
|
+
await expect(guard.visit('https://pi.dev/b')).rejects.toThrow(/max-depth/);
|
|
113
|
+
});
|
|
114
|
+
it('maxPages=1 时将达页数上限 throw max-pages', async () => {
|
|
115
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', maxPages: 1, navigate: makeGraphNav(graph) });
|
|
116
|
+
await guard.open();
|
|
117
|
+
await expect(guard.visit('https://pi.dev/b')).rejects.toThrow(/max-pages/);
|
|
118
|
+
});
|
|
119
|
+
it('BFS 深度:A links=[B,E],visit B(d1) 后再 visit E 仍为 d1(线性深度旧实现会误拒)', async () => {
|
|
120
|
+
const bfsGraph = {
|
|
121
|
+
'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b', 'https://pi.dev/e'] },
|
|
122
|
+
'https://pi.dev/b': { title: 'B', text: 'B text', links: [] },
|
|
123
|
+
'https://pi.dev/e': { title: 'E', text: 'E text', links: [] },
|
|
124
|
+
};
|
|
125
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(bfsGraph) });
|
|
126
|
+
await guard.open();
|
|
127
|
+
await guard.visit('https://pi.dev/b');
|
|
128
|
+
// E 由入口 A 链接,真实 BFS 深度=1,必须可访问
|
|
129
|
+
const page = await guard.visit('https://pi.dev/e');
|
|
130
|
+
expect(page.url).toBe('https://pi.dev/e');
|
|
131
|
+
const depthByUrl = guard.depthByUrl;
|
|
132
|
+
expect(depthByUrl.get('https://pi.dev/e')).toBe(1);
|
|
133
|
+
});
|
|
134
|
+
it('A links=[B]、B links=[C]:visit B(d1) 后 C 为 d2 > maxDepth,仍 throw max-depth', async () => {
|
|
135
|
+
const chainGraph = {
|
|
136
|
+
'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b'] },
|
|
137
|
+
'https://pi.dev/b': { title: 'B', text: 'B text', links: ['https://pi.dev/c'] },
|
|
138
|
+
'https://pi.dev/c': { title: 'C', text: 'C text', links: [] },
|
|
139
|
+
};
|
|
140
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(chainGraph) });
|
|
141
|
+
await guard.open();
|
|
142
|
+
await guard.visit('https://pi.dev/b');
|
|
143
|
+
await expect(guard.visit('https://pi.dev/c')).rejects.toThrow(/max-depth/);
|
|
144
|
+
});
|
|
145
|
+
it('同一页被 d0 和 d1 两个来源链接时,深度取 min=1', async () => {
|
|
146
|
+
const sharedGraph = {
|
|
147
|
+
'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b', 'https://pi.dev/e'] },
|
|
148
|
+
'https://pi.dev/b': { title: 'B', text: 'B text', links: ['https://pi.dev/e'] },
|
|
149
|
+
'https://pi.dev/e': { title: 'E', text: 'E text', links: [] },
|
|
150
|
+
};
|
|
151
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(sharedGraph) });
|
|
152
|
+
await guard.open();
|
|
153
|
+
await guard.visit('https://pi.dev/b');
|
|
154
|
+
// E 同时被 A(d0) 和 B(d1) 链接,取最短来源 → d1
|
|
155
|
+
await guard.visit('https://pi.dev/e');
|
|
156
|
+
const depthByUrl = guard.depthByUrl;
|
|
157
|
+
expect(depthByUrl.get('https://pi.dev/e')).toBe(1);
|
|
158
|
+
});
|
|
159
|
+
it('未被任何已抓页链接的同站 URL → throw not linked(不放行幻觉 URL)', async () => {
|
|
160
|
+
const guard = new CrawlGuard({
|
|
161
|
+
entryUrl: 'https://pi.dev/',
|
|
162
|
+
docsDir: docsDir(),
|
|
163
|
+
slug: 'pi',
|
|
164
|
+
navigate: makeGraphNav({ 'https://pi.dev/': { title: 'A', text: 'A text', links: [] } }),
|
|
165
|
+
});
|
|
166
|
+
await guard.open();
|
|
167
|
+
await expect(guard.visit('https://pi.dev/ghost')).rejects.toThrow(/not linked from any crawled page/);
|
|
168
|
+
});
|
|
169
|
+
it('navigate reject 时 seen 不增加:再次 visit 同 URL 不报 seen(失败页不占名额)', async () => {
|
|
170
|
+
const nav = jest.fn(async (url) => {
|
|
171
|
+
if (url === 'https://pi.dev/b')
|
|
172
|
+
throw new Error('nav boom');
|
|
173
|
+
return { title: 'A', text: 'A text', links: ['https://pi.dev/b'] };
|
|
174
|
+
});
|
|
175
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: nav });
|
|
176
|
+
await guard.open();
|
|
177
|
+
await expect(guard.visit('https://pi.dev/b')).rejects.toThrow(/nav boom/);
|
|
178
|
+
// 第二次仍因抓取失败报错,而不是 seen;seen 集合保持只有入口
|
|
179
|
+
await expect(guard.visit('https://pi.dev/b')).rejects.toThrow(/nav boom/);
|
|
180
|
+
const seen = guard.seen;
|
|
181
|
+
expect(seen.size).toBe(1);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
describe('CrawlGuard.saveSource', () => {
|
|
185
|
+
it('按 source-NNN.md 落盘,内容含 Source 头,savedCount 递增', async () => {
|
|
186
|
+
const dir = docsDir();
|
|
187
|
+
const guard = new CrawlGuard({
|
|
188
|
+
entryUrl: 'https://pi.dev/',
|
|
189
|
+
docsDir: dir,
|
|
190
|
+
slug: 'pi',
|
|
191
|
+
navigate: makeGraphNav({
|
|
192
|
+
'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b'] },
|
|
193
|
+
'https://pi.dev/b': { title: 'B', text: 'B text', links: [] },
|
|
194
|
+
}),
|
|
195
|
+
});
|
|
196
|
+
await guard.open();
|
|
197
|
+
expect(guard.saveSource('https://pi.dev/')).toEqual({ savedCount: 1, reused: false });
|
|
198
|
+
await guard.visit('https://pi.dev/b');
|
|
199
|
+
expect(guard.saveSource('https://pi.dev/b')).toEqual({ savedCount: 2, reused: false });
|
|
200
|
+
const sourcesDir = path.join(dir, 'pi', 'sources');
|
|
201
|
+
const f1 = await fsp.readFile(path.join(sourcesDir, 'source-001.md'), 'utf8');
|
|
202
|
+
expect(f1).toBe('Source: https://pi.dev/\n\nA text');
|
|
203
|
+
const f2 = await fsp.readFile(path.join(sourcesDir, 'source-002.md'), 'utf8');
|
|
204
|
+
expect(f2).toBe('Source: https://pi.dev/b\n\nB text');
|
|
205
|
+
});
|
|
206
|
+
it('未抓取过的 URL saveSource throw', async () => {
|
|
207
|
+
const guard = new CrawlGuard({
|
|
208
|
+
entryUrl: 'https://pi.dev/',
|
|
209
|
+
docsDir: docsDir(),
|
|
210
|
+
slug: 'pi',
|
|
211
|
+
navigate: makeGraphNav({ 'https://pi.dev/': { title: 'A', text: 'A', links: [] } }),
|
|
212
|
+
});
|
|
213
|
+
await guard.open();
|
|
214
|
+
expect(() => guard.saveSource('https://pi.dev/ghost')).toThrow(/not crawled/);
|
|
215
|
+
});
|
|
216
|
+
it('同页重复 save_source:不写重复文件、reused=true、savedCount 不重复增', async () => {
|
|
217
|
+
const dir = docsDir();
|
|
218
|
+
const guard = new CrawlGuard({
|
|
219
|
+
entryUrl: 'https://pi.dev/',
|
|
220
|
+
docsDir: dir,
|
|
221
|
+
slug: 'pi',
|
|
222
|
+
navigate: makeGraphNav({ 'https://pi.dev/': { title: 'A', text: 'A text', links: [] } }),
|
|
223
|
+
});
|
|
224
|
+
await guard.open();
|
|
225
|
+
const r1 = guard.saveSource('https://pi.dev/');
|
|
226
|
+
const r2 = guard.saveSource('https://pi.dev/');
|
|
227
|
+
expect(r1).toEqual({ savedCount: 1, reused: false });
|
|
228
|
+
expect(r2).toEqual({ savedCount: 1, reused: true });
|
|
229
|
+
expect(guard.savedCount).toBe(1);
|
|
230
|
+
const files = await fsp.readdir(path.join(dir, 'pi', 'sources'));
|
|
231
|
+
expect(files).toEqual(['source-001.md']);
|
|
232
|
+
});
|
|
233
|
+
it('空正文页 saveSource throw empty page', async () => {
|
|
234
|
+
const guard = new CrawlGuard({
|
|
235
|
+
entryUrl: 'https://pi.dev/',
|
|
236
|
+
docsDir: docsDir(),
|
|
237
|
+
slug: 'pi',
|
|
238
|
+
navigate: makeGraphNav({
|
|
239
|
+
'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b'] },
|
|
240
|
+
'https://pi.dev/b': { title: 'B', text: ' \n ', links: [] },
|
|
241
|
+
}),
|
|
242
|
+
});
|
|
243
|
+
await guard.open();
|
|
244
|
+
await guard.visit('https://pi.dev/b');
|
|
245
|
+
expect(() => guard.saveSource('https://pi.dev/b')).toThrow(/empty page/);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
describe('CrawlGuard.close', () => {
|
|
249
|
+
it('no-op:不起 ego-browser 进程,也不抛错', async () => {
|
|
250
|
+
const guard = new CrawlGuard({
|
|
251
|
+
entryUrl: 'https://pi.dev/',
|
|
252
|
+
docsDir: docsDir(),
|
|
253
|
+
slug: 'pi',
|
|
254
|
+
navigate: makeGraphNav({ 'https://pi.dev/': { title: 'A', text: 'A text', links: [] } }),
|
|
255
|
+
});
|
|
256
|
+
await expect(guard.close()).resolves.toBeUndefined();
|
|
257
|
+
expect(mockRunEgoBrowser).not.toHaveBeenCalled();
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
describe('CrawlGuard signal 透传', () => {
|
|
261
|
+
it('open/visit 把 abort signal 转发给 runEgoBrowser', async () => {
|
|
262
|
+
mockRunEgoBrowser.mockResolvedValue(JSON.stringify({ title: 'A', text: 'A text', links: ['https://pi.dev/b'] }));
|
|
263
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi' });
|
|
264
|
+
const signal = new AbortController().signal;
|
|
265
|
+
await guard.open(signal);
|
|
266
|
+
expect(mockRunEgoBrowser).toHaveBeenNthCalledWith(1, expect.any(String), { timeoutMs: 60000, signal });
|
|
267
|
+
await guard.visit('https://pi.dev/b', signal);
|
|
268
|
+
expect(mockRunEgoBrowser).toHaveBeenNthCalledWith(2, expect.any(String), { timeoutMs: 60000, signal });
|
|
269
|
+
});
|
|
270
|
+
it('crawl_open/crawl_visit 的 execute 把 signal 透传给 guard.navigate', async () => {
|
|
271
|
+
const nav = jest.fn(async () => ({ title: 'A', text: 'A text', links: ['https://pi.dev/b'] }));
|
|
272
|
+
const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: nav });
|
|
273
|
+
const tools = createCrawlTools(guard);
|
|
274
|
+
const byName = Object.fromEntries(tools.map((t) => [t.name, t]));
|
|
275
|
+
const signal = new AbortController().signal;
|
|
276
|
+
await byName.crawl_open.execute('id-1', {}, signal, undefined, {});
|
|
277
|
+
expect(nav).toHaveBeenNthCalledWith(1, 'https://pi.dev/', signal);
|
|
278
|
+
await byName.crawl_visit.execute('id-2', { url: 'https://pi.dev/b' }, signal, undefined, {});
|
|
279
|
+
expect(nav).toHaveBeenNthCalledWith(2, 'https://pi.dev/b', signal);
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
describe('createCrawlTools', () => {
|
|
283
|
+
function makeGuard() {
|
|
284
|
+
return new CrawlGuard({
|
|
285
|
+
entryUrl: 'https://pi.dev/',
|
|
286
|
+
docsDir: docsDir(),
|
|
287
|
+
slug: 'pi',
|
|
288
|
+
navigate: makeGraphNav({
|
|
289
|
+
'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b', 'https://other.com/x'] },
|
|
290
|
+
'https://pi.dev/b': { title: 'B', text: 'B text', links: [] },
|
|
291
|
+
}),
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
it('提供 crawl_open/crawl_visit/save_source/crawl_finish 四个工具', () => {
|
|
295
|
+
const tools = createCrawlTools(makeGuard());
|
|
296
|
+
expect(tools.map((t) => t.name)).toEqual(['crawl_open', 'crawl_visit', 'save_source', 'crawl_finish']);
|
|
297
|
+
});
|
|
298
|
+
it('工具错误以可读文本返回(不抛异常)', async () => {
|
|
299
|
+
mockRunEgoBrowser.mockResolvedValue('closed');
|
|
300
|
+
const guard = makeGuard();
|
|
301
|
+
const tools = createCrawlTools(guard);
|
|
302
|
+
const byName = Object.fromEntries(tools.map((t) => [t.name, t]));
|
|
303
|
+
const textOf = (res) => res.content.map((c) => c.text ?? '').join('\n');
|
|
304
|
+
// execute 签名 5 参(id/params/signal/onUpdate/ctx),测试只需前 2 个
|
|
305
|
+
const call = (tool, params) => tool.execute('id', params, undefined, undefined, undefined);
|
|
306
|
+
const openRes = await call(byName.crawl_open, {});
|
|
307
|
+
expect(textOf(openRes)).toContain('https://pi.dev/');
|
|
308
|
+
const badRes = await call(byName.crawl_visit, { url: 'https://other.com/x' });
|
|
309
|
+
expect(textOf(badRes)).toMatch(/error:.*cross-site/);
|
|
310
|
+
const saveRes = await call(byName.save_source, { url: 'https://pi.dev/' });
|
|
311
|
+
expect(textOf(saveRes)).toContain('"savedCount":1');
|
|
312
|
+
const finishRes = await call(byName.crawl_finish, {});
|
|
313
|
+
expect(textOf(finishRes)).toContain('"finished":true');
|
|
314
|
+
});
|
|
315
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
jest.mock('../pi-runtime.js', () => ({ runJsonPrompt: jest.fn() }));
|
|
2
|
+
import { mkdtemp, mkdir, writeFile } from 'fs/promises';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { runJsonPrompt } from '../pi-runtime.js';
|
|
6
|
+
import { reconcileTopics, readAllTopics, readTopicDetail, mintSlug } from '../pi-dedup.js';
|
|
7
|
+
const mockJson = runJsonPrompt;
|
|
8
|
+
let tmp;
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
tmp = await mkdtemp(path.join(os.tmpdir(), 'pi-dedup-'));
|
|
11
|
+
mockJson.mockReset();
|
|
12
|
+
});
|
|
13
|
+
test('预筛命中 → 调 LLM,match=true 透传 targetSlug/mergedTitle/itemsToAdd', async () => {
|
|
14
|
+
mockJson.mockResolvedValue({ match: true, targetSlug: 'a', mergedTitle: 'M', mergedSummary: 's',
|
|
15
|
+
confidence: 0.62, itemsToAdd: [{ id: 'x', title: 'X', oneLine: 'x' }] });
|
|
16
|
+
const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: true,
|
|
17
|
+
candidate: { slug: 'new', title: 'React Hooks', tags: [] },
|
|
18
|
+
targets: [{ slug: 'a', title: 'React Hooks', summary: '', tags: [], chunks: [] }] });
|
|
19
|
+
expect(r.match).toBe(true);
|
|
20
|
+
expect(r.targetSlug).toBe('a');
|
|
21
|
+
expect(r.itemsToAdd).toHaveLength(1);
|
|
22
|
+
});
|
|
23
|
+
test('LLM 抛错(坏 JSON)→ 安全返回 match=false', async () => {
|
|
24
|
+
mockJson.mockRejectedValue(new Error('no json object in response'));
|
|
25
|
+
await expect(reconcileTopics({ port: 1, docsDir: tmp, wantItems: false,
|
|
26
|
+
candidate: { slug: 'new', title: 'T', tags: [] },
|
|
27
|
+
targets: [{ slug: 'a', title: 'T', summary: '', tags: [], chunks: [] }] }))
|
|
28
|
+
.resolves.toMatchObject({ match: false });
|
|
29
|
+
});
|
|
30
|
+
test('正载荷回显候选自身 slug(未提供的目标)→ match=false', async () => {
|
|
31
|
+
mockJson.mockResolvedValue({ match: true, targetSlug: 'new', mergedTitle: 'M',
|
|
32
|
+
mergedSummary: 's', itemsToAdd: [] });
|
|
33
|
+
const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: true,
|
|
34
|
+
candidate: { slug: 'new', title: 'React Hooks', tags: [] },
|
|
35
|
+
targets: [{ slug: 'a', title: 'React Hooks', summary: '', tags: [], chunks: [] }] });
|
|
36
|
+
expect(r).toEqual({ match: false });
|
|
37
|
+
});
|
|
38
|
+
test('正载荷缺 mergedTitle → match=false', async () => {
|
|
39
|
+
mockJson.mockResolvedValue({ match: true, targetSlug: 'a', mergedSummary: 's', itemsToAdd: [] });
|
|
40
|
+
const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: true,
|
|
41
|
+
candidate: { slug: 'new', title: 'React Hooks', tags: [] },
|
|
42
|
+
targets: [{ slug: 'a', title: 'React Hooks', summary: '', tags: [], chunks: [] }] });
|
|
43
|
+
expect(r).toEqual({ match: false });
|
|
44
|
+
});
|
|
45
|
+
test('空目标 → 不调 LLM,match=false', async () => {
|
|
46
|
+
const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: false,
|
|
47
|
+
candidate: { slug: 'new', title: 'zzz', tags: [] }, targets: [] });
|
|
48
|
+
expect(r).toEqual({ match: false });
|
|
49
|
+
expect(mockJson).not.toHaveBeenCalled();
|
|
50
|
+
});
|
|
51
|
+
test('预筛空且目标>20 → 不调 LLM,match=false', async () => {
|
|
52
|
+
const targets = Array.from({ length: 21 }, (_, i) => ({ slug: `s${i}`, title: `Distinct ${i}`, summary: '', tags: [], chunks: [] }));
|
|
53
|
+
const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: false,
|
|
54
|
+
candidate: { slug: 'new', title: 'zzzz-noise', tags: [] }, targets });
|
|
55
|
+
expect(r.match).toBe(false);
|
|
56
|
+
expect(mockJson).not.toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
test('readAllTopics: 返回 index.json 的 topics', async () => {
|
|
59
|
+
await writeFile(path.join(tmp, 'index.json'), JSON.stringify({
|
|
60
|
+
topics: [{ slug: 'a', title: 'A', summary: '', tags: [] }],
|
|
61
|
+
}));
|
|
62
|
+
await expect(readAllTopics(tmp)).resolves.toMatchObject([{ slug: 'a', title: 'A' }]);
|
|
63
|
+
});
|
|
64
|
+
test('readAllTopics: 空/缺失目录返回 []', async () => {
|
|
65
|
+
await expect(readAllTopics(tmp)).resolves.toEqual([]);
|
|
66
|
+
});
|
|
67
|
+
describe('mintSlug', () => {
|
|
68
|
+
test('LLM 返回合法且空闲的 slug → 直接使用', async () => {
|
|
69
|
+
mockJson.mockResolvedValue({ slug: 'react-hooks' });
|
|
70
|
+
await expect(mintSlug({ port: 1, title: 'React Hooks', existing: [] })).resolves.toBe('react-hooks');
|
|
71
|
+
});
|
|
72
|
+
test('LLM 返回非法 slug → 降级 slugFromLabel(title)', async () => {
|
|
73
|
+
mockJson.mockResolvedValue({ slug: 'Bad Slug!' });
|
|
74
|
+
await expect(mintSlug({ port: 1, title: 'Hello World', existing: [] })).resolves.toBe('hello-world');
|
|
75
|
+
});
|
|
76
|
+
test('LLM slug 与 slugFromLabel(title) 均被占 → 追加 -2', async () => {
|
|
77
|
+
mockJson.mockResolvedValue({ slug: 'my-topic' });
|
|
78
|
+
await expect(mintSlug({ port: 1, title: 'My Topic', existing: ['my-topic'] }))
|
|
79
|
+
.resolves.toBe('my-topic-2');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
test('readTopicDetail: 返回 <slug>/index.json 解析结果;缺失返回 null', async () => {
|
|
83
|
+
await mkdir(path.join(tmp, 'a'));
|
|
84
|
+
await writeFile(path.join(tmp, 'a', 'index.json'), JSON.stringify({
|
|
85
|
+
slug: 'a', title: 'A', summary: 's', tags: ['t'], chunks: [],
|
|
86
|
+
}));
|
|
87
|
+
await expect(readTopicDetail(tmp, 'a')).resolves.toMatchObject({ slug: 'a', chunks: [] });
|
|
88
|
+
await expect(readTopicDetail(tmp, 'missing')).resolves.toBeNull();
|
|
89
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
jest.mock('../pi-runtime.js', () => ({ runJsonPrompt: jest.fn() }));
|
|
2
|
+
import { findCandidates, mergeTopics, assertNoOldDirs } from '../pi-dedup.js';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
// ---- mergeTopics / assertNoOldDirs:真实 tmpDir 手工铺盘 ----
|
|
7
|
+
const pad3 = (n) => String(n).padStart(3, '0');
|
|
8
|
+
// 铺一个 topic:sources 为正文数组(按序 source-NNN);chunks 为 { id?, body }
|
|
9
|
+
function layoutTopic(docsDir, slug, opts = {}) {
|
|
10
|
+
const topicDir = path.join(docsDir, slug);
|
|
11
|
+
fs.mkdirSync(path.join(topicDir, 'sources'), { recursive: true });
|
|
12
|
+
fs.mkdirSync(path.join(topicDir, 'chunks'), { recursive: true });
|
|
13
|
+
for (let i = 0; i < (opts.sources ?? []).length; i++) {
|
|
14
|
+
fs.writeFileSync(path.join(topicDir, 'sources', `source-${pad3(i + 1)}.md`), opts.sources[i]);
|
|
15
|
+
}
|
|
16
|
+
const chunks = (opts.chunks ?? []).map((c, i) => {
|
|
17
|
+
const id = c.id ?? `chunk-${pad3(i + 1)}`;
|
|
18
|
+
fs.writeFileSync(path.join(topicDir, 'chunks', `${id}.md`), c.body);
|
|
19
|
+
return { id, title: id, summary: '', tags: [] };
|
|
20
|
+
});
|
|
21
|
+
fs.writeFileSync(path.join(topicDir, 'index.json'), JSON.stringify({ slug, title: slug, summary: '', tags: [], chunks }));
|
|
22
|
+
}
|
|
23
|
+
function writeRoot(docsDir, slugs) {
|
|
24
|
+
fs.writeFileSync(path.join(docsDir, 'index.json'), JSON.stringify({ topics: slugs.map(slug => ({ slug, title: slug, summary: '', tags: [] })) }));
|
|
25
|
+
}
|
|
26
|
+
function freshTmp() {
|
|
27
|
+
return fs.mkdtempSync(path.join(os.tmpdir(), 'pi-dedup-'));
|
|
28
|
+
}
|
|
29
|
+
test('findCandidates: title 归一相等命中并排前', () => {
|
|
30
|
+
const topics = [
|
|
31
|
+
{ slug: 'a', title: 'React Hooks', summary: '', tags: [] },
|
|
32
|
+
{ slug: 'b', title: 'Other', summary: '', tags: [] },
|
|
33
|
+
];
|
|
34
|
+
expect(findCandidates({ title: 'react hooks!', tags: [] }, topics).map(t => t.slug)).toEqual(['a']);
|
|
35
|
+
});
|
|
36
|
+
test('findCandidates: tag 相交命中', () => {
|
|
37
|
+
const topics = [{ slug: 'c', title: 'X', summary: '', tags: ['state-management'] }];
|
|
38
|
+
expect(findCandidates({ title: 'zzz', tags: ['State Management'] }, topics)).toHaveLength(1);
|
|
39
|
+
});
|
|
40
|
+
test('findCandidates: 无命中返回 []', () => {
|
|
41
|
+
expect(findCandidates({ title: 'qqq', tags: [] }, [{ slug: 'd', title: 'rrr', summary: '', tags: [] }])).toEqual([]);
|
|
42
|
+
});
|
|
43
|
+
test('mergeTopics: 两边都有 → sources 续号、chunks 重编号、refs 合并、根 index 移除 src', () => {
|
|
44
|
+
const tmp = freshTmp();
|
|
45
|
+
layoutTopic(tmp, 'dsta', { sources: ['dst source'], chunks: [{ body: 'dst chunk' }] });
|
|
46
|
+
layoutTopic(tmp, 'newb', { sources: ['src source'], chunks: [{ body: 'src c1' }, { body: 'src c2' }] });
|
|
47
|
+
writeRoot(tmp, ['dsta', 'newb', 'other']);
|
|
48
|
+
expect(mergeTopics(tmp, 'newb', 'dsta')).toBe(3);
|
|
49
|
+
expect(fs.readdirSync(path.join(tmp, 'dsta', 'sources')).sort())
|
|
50
|
+
.toEqual(['source-001.md', 'source-002.md']);
|
|
51
|
+
expect(fs.readdirSync(path.join(tmp, 'dsta', 'chunks')).sort())
|
|
52
|
+
.toEqual(['chunk-001.md', 'chunk-002.md', 'chunk-003.md']);
|
|
53
|
+
// src 目录已删;根 index 无 newb,其余保留
|
|
54
|
+
expect(fs.existsSync(path.join(tmp, 'newb'))).toBe(false);
|
|
55
|
+
const root = JSON.parse(fs.readFileSync(path.join(tmp, 'index.json'), 'utf8'));
|
|
56
|
+
expect(root.topics.map((t) => t.slug)).toEqual(['dsta', 'other']);
|
|
57
|
+
// refs 已合并进 dst index
|
|
58
|
+
const dstIndex = JSON.parse(fs.readFileSync(path.join(tmp, 'dsta', 'index.json'), 'utf8'));
|
|
59
|
+
expect(dstIndex.chunks.map((c) => c.id))
|
|
60
|
+
.toEqual(['chunk-001', 'chunk-002', 'chunk-003']);
|
|
61
|
+
});
|
|
62
|
+
test('mergeTopics: src 无 chunks(门1)→ 只移 sources,返回 dst 原 chunk 数', () => {
|
|
63
|
+
const tmp = freshTmp();
|
|
64
|
+
layoutTopic(tmp, 'dsta', { sources: ['dst source'], chunks: [{ body: 'dst chunk' }] });
|
|
65
|
+
layoutTopic(tmp, 'newb', { sources: ['src source 1', 'src source 2'] });
|
|
66
|
+
writeRoot(tmp, ['dsta', 'newb']);
|
|
67
|
+
expect(mergeTopics(tmp, 'newb', 'dsta')).toBe(1);
|
|
68
|
+
expect(fs.readdirSync(path.join(tmp, 'dsta', 'chunks')).sort()).toEqual(['chunk-001.md']);
|
|
69
|
+
expect(fs.readdirSync(path.join(tmp, 'dsta', 'sources')).sort())
|
|
70
|
+
.toEqual(['source-001.md', 'source-002.md', 'source-003.md']);
|
|
71
|
+
});
|
|
72
|
+
test('mergeTopics: dst 无 chunks(门0)→ src chunks 从 chunk-001 起重编号并入', () => {
|
|
73
|
+
const tmp = freshTmp();
|
|
74
|
+
layoutTopic(tmp, 'dsta', {});
|
|
75
|
+
layoutTopic(tmp, 'newb', { chunks: [{ body: 'src c1' }, { body: 'src c2' }] });
|
|
76
|
+
writeRoot(tmp, ['dsta', 'newb']);
|
|
77
|
+
expect(mergeTopics(tmp, 'newb', 'dsta')).toBe(2);
|
|
78
|
+
expect(fs.readdirSync(path.join(tmp, 'dsta', 'chunks')).sort())
|
|
79
|
+
.toEqual(['chunk-001.md', 'chunk-002.md']);
|
|
80
|
+
expect(fs.readFileSync(path.join(tmp, 'dsta', 'chunks', 'chunk-001.md'), 'utf8')).toBe('src c1');
|
|
81
|
+
expect(fs.readFileSync(path.join(tmp, 'dsta', 'chunks', 'chunk-002.md'), 'utf8')).toBe('src c2');
|
|
82
|
+
});
|
|
83
|
+
test('mergeTopics: chunk 正文逐字不变(含花括号与换行)', () => {
|
|
84
|
+
const tmp = freshTmp();
|
|
85
|
+
layoutTopic(tmp, 'dsta', { chunks: [{ body: 'dst chunk' }] });
|
|
86
|
+
const body = '{\n "key": "值 {braces}\n换行"\n}\n最后一行\n';
|
|
87
|
+
layoutTopic(tmp, 'newb', { chunks: [{ body }] });
|
|
88
|
+
writeRoot(tmp, ['dsta', 'newb']);
|
|
89
|
+
mergeTopics(tmp, 'newb', 'dsta');
|
|
90
|
+
// src chunk-001 偏移为 dst chunk-002,正文逐字一致
|
|
91
|
+
expect(fs.readFileSync(path.join(tmp, 'dsta', 'chunks', 'chunk-002.md'), 'utf8')).toBe(body);
|
|
92
|
+
});
|
|
93
|
+
test('mergeTopics: src 与 dst 相同 → 抛错防自合并', () => {
|
|
94
|
+
const tmp = freshTmp();
|
|
95
|
+
layoutTopic(tmp, 't', {});
|
|
96
|
+
writeRoot(tmp, ['t']);
|
|
97
|
+
expect(() => mergeTopics(tmp, 't', 't')).toThrow('mergeTopics: src 与 dst 相同');
|
|
98
|
+
});
|
|
99
|
+
test('assertNoOldDirs: 存在 x.old → 抛精确错误;无 → 不抛', () => {
|
|
100
|
+
const withOld = freshTmp();
|
|
101
|
+
fs.mkdirSync(path.join(withOld, 'x.old'));
|
|
102
|
+
expect(() => assertNoOldDirs(withOld)).toThrow('检测到未清理的旁挂目录 x.old,请手工处理后再学习');
|
|
103
|
+
const clean = freshTmp();
|
|
104
|
+
fs.mkdirSync(path.join(clean, 'normal-slug'));
|
|
105
|
+
expect(() => assertNoOldDirs(clean)).not.toThrow();
|
|
106
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|