@kabmo-labs/kabmo 0.44.0 → 0.45.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/client/index.html +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/static/js/{CsvGrid-1t2q46rg.js → CsvGrid-z74weshk.js} +2 -2
- package/dist/client/static/js/{DocxView-301hxnwk.js → DocxView-dpe5x9ab.js} +5 -5
- package/dist/client/static/js/{DrawioView-47bwea5t.js → DrawioView-ftzwjf8v.js} +2 -2
- package/dist/client/static/js/{ImageView-68zdx5ex.js → ImageView-vchn6wyq.js} +1 -1
- package/dist/client/static/js/LayoutWrapper-1x0gnppc.js +2 -0
- package/dist/client/static/js/{Modal-fb9b4gq6.js → Modal-tteg7vtb.js} +18 -18
- package/dist/client/static/js/{PdfView-m64ksepp.js → PdfView-vjec8z3z.js} +1 -1
- package/dist/client/static/js/{SessionsView-zyjwhpzm.js → SessionsView-g7z3fxbp.js} +1 -1
- package/dist/client/static/js/{SheetView-e88sqprx.js → SheetView-hhtfkdhe.js} +25 -25
- package/dist/client/static/js/{SvgPreview-hs9a713t.js → SvgPreview-48n3ex6p.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-fnr5kyqk.js → abnfDiagram-O67JEVCF-bpvzdara.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-bch3nye9.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-7v003363.js → architectureDiagram-NJMV4G6O-xw62cr7j.js} +3 -3
- package/dist/client/static/js/{astro-t9vjc0mc.js → astro-56b0as3q.js} +1 -1
- package/dist/client/static/js/bash-mevzaywf.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-k4mwbw3d.js → blockDiagram-BEXU5L5S-x3a6cgar.js} +4 -4
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-688zq6f4.js → c4Diagram-YGBWAQC7-katvaxbj.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-h0s16pxr.js → classDiagram-v2-NBCMYWYE-bjz4mqqh.js} +3 -3
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-qb2t8qq5.js → cose-bilkent-JH36ORCC-fsn80psf.js} +1 -1
- package/dist/client/static/js/cpp-wk9z0c5g.js +1 -0
- package/dist/client/static/js/css-3w3p9s67.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-vqy5jtnk.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-syhtcr7b.js → cynefinDiagram-VND7K2PF-cfhbsnkm.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-7wgbx6cm.js → dagre-6A5THRUB-j2wt7ns6.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-951cmp5h.js → diagram-22UHCM2B-abrdj714.js} +8 -8
- package/dist/client/static/js/{diagram-3UASUU5V-mvdbqt7b.js → diagram-3UASUU5V-dbn15bxn.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-hkvdtgdm.js → diagram-ATOU4E4O-y79pwf7w.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-bkkz35ca.js → diagram-CDSNMT55-f8ryt86n.js} +2 -2
- package/dist/client/static/js/{diagram-MLGK6HIB-z6pcrkc3.js → diagram-MLGK6HIB-ws7wn3q9.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-mkwf8j4m.js → diagram-MPIPVDR6-zmznrg13.js} +2 -2
- package/dist/client/static/js/{dockerfile-7gd570bm.js → dockerfile-qgc921kw.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-trym26ts.js → ebnfDiagram-ZINNZB2B-y5q7hy1v.js} +1 -1
- package/dist/client/static/js/{elixir-z77c7tfn.js → elixir-12pgbgtq.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-gkhz67v6.js → elk-276RUBZZ-vddwbn6q.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-gkyr5cqs.js → erDiagram-OPXOYQCR-qdqcx4g4.js} +6 -6
- package/dist/client/static/js/{erlang-6vrvh2m6.js → erlang-811btv6p.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-65ph4s3m.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-nh2tb65b.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-1qpme6ks.js → ganttDiagram-FUAMR5RP-763hk9rm.js} +1 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-t45ekjb6.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-wbg3kqak.js → gitGraphDiagram-X574FWY7-bgx1q5nw.js} +4 -4
- package/dist/client/static/js/graphql-027z8sc0.js +1 -0
- package/dist/client/static/js/html-fqda6wxx.js +1 -0
- package/dist/client/static/js/{index-ks23y2cd.js → index-03j5j1j0.js} +2 -2
- package/dist/client/static/js/{index-czedkbmb.js → index-05hx4ftf.js} +2 -2
- package/dist/client/static/js/index-0vk6v4y4.js +2 -0
- package/dist/client/static/js/{index-83pwa9c0.js → index-1nwwvv29.js} +1 -1
- package/dist/client/static/js/{index-31hntzse.js → index-228yzebd.js} +5 -5
- package/dist/client/static/js/{index-xf36nmbm.js → index-2b1wnvez.js} +2 -2
- package/dist/client/static/js/{index-6t21c6jt.js → index-34ff2vq6.js} +2 -2
- package/dist/client/static/js/{index-1923aj4g.js → index-3d21hpk7.js} +2 -2
- package/dist/client/static/js/{index-hfsvwfgw.js → index-3h2mr90j.js} +2 -2
- package/dist/client/static/js/{index-svmzgtcx.js → index-3sqndc9n.js} +2 -2
- package/dist/client/static/js/{index-6gyk52ff.js → index-47wn2gjx.js} +1 -1
- package/dist/client/static/js/{index-6ah5sj5y.js → index-4b5b6g0k.js} +1 -1
- package/dist/client/static/js/{index-53ysgsd2.js → index-5b2vsbcf.js} +1 -1
- package/dist/client/static/js/{index-qm92sf9w.js → index-5mrqfs82.js} +12 -12
- package/dist/client/static/js/{index-62ng8tkj.js → index-61j9qkck.js} +3 -3
- package/dist/client/static/js/index-6bm4pw90.css +1 -0
- package/dist/client/static/js/{index-fj4k07zt.js → index-6sqmhdyv.js} +2 -2
- package/dist/client/static/js/{index-gtkhz0hj.js → index-8dtp7mt0.js} +2 -2
- package/dist/client/static/js/index-a11ptyzf.js +1 -0
- package/dist/client/static/js/{index-nvevymac.js → index-acphtw1r.js} +2 -2
- package/dist/client/static/js/{index-pxm44qfd.js → index-cj39b26c.js} +1 -1
- package/dist/client/static/js/{index-wytdbvax.js → index-dgjerk4w.js} +3 -3
- package/dist/client/static/js/{index-ad4x44d6.js → index-dn6pqym4.js} +6 -6
- package/dist/client/static/js/{index-nr8s5xm9.js → index-ehg2ftnp.js} +2 -2
- package/dist/client/static/js/{index-jbkkwa2q.js → index-f51jxezc.js} +2 -2
- package/dist/client/static/js/index-f7paep2f.js +2 -0
- package/dist/client/static/js/{index-qkjx6521.js → index-f98dhbt4.js} +4 -4
- package/dist/client/static/js/{index-92n96mgd.js → index-fbct0jcf.js} +2 -2
- package/dist/client/static/js/{index-bjqz7swa.js → index-fqatn0vh.js} +1 -1
- package/dist/client/static/js/{index-tzdm1y3z.js → index-gcwmpfr4.js} +2 -2
- package/dist/client/static/js/{index-v5npdwy2.js → index-gmq5pbcv.js} +51 -51
- package/dist/client/static/js/{index-fbpc1wx6.js → index-gzafyqsr.js} +21 -21
- package/dist/client/static/js/{index-4y4hshcx.js → index-gzp4j2h5.js} +2 -2
- package/dist/client/static/js/{index-nqjd3hh5.js → index-h0rmkz9n.js} +2 -2
- package/dist/client/static/js/{index-8trggh1z.js → index-jpp0zm7t.js} +7 -7
- package/dist/client/static/js/{index-qf9x7yet.js → index-kg2sk8cf.js} +1 -1
- package/dist/client/static/js/{index-rpzxrr2d.js → index-mrw7qweg.js} +1 -1
- package/dist/client/static/js/{index-s8bktzpg.js → index-mwm8aptp.js} +1 -1
- package/dist/client/static/js/{index-c3v62nvt.js → index-n1ga63de.js} +2 -2
- package/dist/client/static/js/{index-22whvfdw.js → index-nzhwd6t3.js} +2 -2
- package/dist/client/static/js/{index-tr2pkfs6.js → index-p21mvqc2.js} +2 -2
- package/dist/client/static/js/{index-qsw5edtk.js → index-pfj3sd1n.js} +5 -5
- package/dist/client/static/js/{index-pysqpc5n.js → index-pxq4v81r.js} +2 -2
- package/dist/client/static/js/{index-07yh7qx0.js → index-q76jfb54.js} +1 -1
- package/dist/client/static/js/{index-6s4mrdew.js → index-qt9jc4ck.js} +2 -2
- package/dist/client/static/js/{index-ehacfgwm.js → index-r6e44vkx.js} +1 -1
- package/dist/client/static/js/{index-232nsp2c.js → index-szk3vk8h.js} +1 -1
- package/dist/client/static/js/{index-e6rm5xzj.js → index-t0yv1375.js} +1 -1
- package/dist/client/static/js/{index-n0matkz9.js → index-vgcm2g0g.js} +2 -2
- package/dist/client/static/js/{index-kwpaz891.js → index-vkerrwpa.js} +2 -2
- package/dist/client/static/js/{index-v7bcgh77.js → index-w57zbym7.js} +2 -2
- package/dist/client/static/js/{index-yfjvx4yf.js → index-wqrdgt1g.js} +2 -2
- package/dist/client/static/js/{index-barbpakv.js → index-x2wvq4ae.js} +2 -2
- package/dist/client/static/js/{index-3w845q50.js → index-x7rfmwg8.js} +2 -2
- package/dist/client/static/js/{index-cq98p2rb.js → index-xkwybnf3.js} +179 -179
- package/dist/client/static/js/info-A6RAGUB7-mw29xbwf.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-yebngg8c.js → infoDiagram-VRGFBTTK-e66pw8d9.js} +1 -1
- package/dist/client/static/js/ini-3cx6tmv4.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-kh4nqj6q.js → ishikawaDiagram-OU5B5YK6-ehc0q24d.js} +1 -1
- package/dist/client/static/js/java-zs6qh1dm.js +1 -0
- package/dist/client/static/js/javascript-b9mkygak.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-4khnf8x1.js → journeyDiagram-ZHPQQLJL-hye05qtd.js} +2 -2
- package/dist/client/static/js/jsx-gahhfczw.js +1 -0
- package/dist/client/static/js/{julia-svwxx41e.js → julia-mgsev9df.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-snmq3wq4.js → kanban-definition-PNTS6WVX-vce614m8.js} +6 -6
- package/dist/client/static/js/lua-d8enp14s.js +1 -0
- package/dist/client/static/js/markdown-qetaj4vp.js +1 -0
- package/dist/client/static/js/{mermaid.core-yctw30sk.js → mermaid.core-gc79re5p.js} +7 -7
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-atfv66wq.js → mindmap-definition-NLK3R4M7-ft1whaf5.js} +3 -3
- package/dist/client/static/js/one-dark-pro-rvg5xm1a.js +1 -0
- package/dist/client/static/js/one-light-2b5w3ksh.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-md85wpjq.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-hpbtxjht.js → pegDiagram-GJSIUBJH-2s4ykhaa.js} +1 -1
- package/dist/client/static/js/{perl-mr0ds2ex.js → perl-6n93vjsa.js} +1 -1
- package/dist/client/static/js/{php-5h3wt6tv.js → php-w23nmbtc.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-4grcqnp8.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-9zrtkdr2.js → pieDiagram-5QR66LMP-7h8dp0z3.js} +2 -2
- package/dist/client/static/js/properties-g6tpq003.js +1 -0
- package/dist/client/static/js/python-cy06fzhg.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-xq970vx1.js → quadrantDiagram-O4NWA36T-pteyxjxr.js} +2 -2
- package/dist/client/static/js/r-vw8berfv.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-7j9prhg1.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-g8x2jps1.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-cbg7k68h.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-xfvjk9f8.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-7w97805z.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1g9jchbk.js → railroadDiagram-XR7U4H2S-68z9wdt0.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-ntt088y4.js → requirementDiagram-PLB6GJNP-c08nmey6.js} +3 -3
- package/dist/client/static/js/{ruby-nn836rtq.js → ruby-ag3b3t9t.js} +1 -1
- package/dist/client/static/js/{rust-eygk56y5.js → rust-ke5ec0w5.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-95k8c5v6.js → sankeyDiagram-IPEJSGJF-2r3kvjs5.js} +3 -3
- package/dist/client/static/js/{sass-c2bk03e4.js → sass-x0eez0kp.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-qfvxrwfa.js → sequenceDiagram-PO4LG4MO-ctjycd88.js} +6 -6
- package/dist/client/static/js/{sizeCapture-INFHLROL-0m7dc5nd.js → sizeCapture-INFHLROL-97ndea95.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-femwcn7n.js → stateDiagram-v2-GCMORJYK-aqnmsb96.js} +3 -3
- package/dist/client/static/js/{svelte-bfy1rq5g.js → svelte-tg19by0f.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-5n1qq48r.js → swimlanes-2SLR337P-v50cx1nx.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-e227mz39.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-vdsj18be.js → timeline-definition-EJHVYXUP-1ggrtdcj.js} +4 -4
- package/dist/client/static/js/treeView-Q6P3EWNA-xhf1r6c3.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-4n3j7ekq.js +1 -0
- package/dist/client/static/js/tsx-3dzv8h6k.js +1 -0
- package/dist/client/static/js/typescript-44vs0wn4.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-psjbrprk.js → usecaseDiagram-POWQR4AR-ybcwhpzs.js} +19 -19
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-4yn9kac9.js → vennDiagram-UO4OBE2U-p9ggrt07.js} +4 -4
- package/dist/client/static/js/{vue-0fwtgwj4.js → vue-mhj4sme0.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-fb0py35r.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-js0tbpca.js → wardleyDiagram-VNRHLVJA-v79nb9kx.js} +2 -2
- package/dist/client/static/js/xml-yvv5fn3k.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-svr38ygh.js → xychartDiagram-PMCCYNJV-43thqscz.js} +2 -2
- package/dist/client/static/js/yaml-avewh7n5.js +1 -0
- package/marketplace/marketplace.json +7 -0
- package/marketplace/plugins/github-actions/README.md +142 -0
- package/marketplace/plugins/github-actions/icon.svg +12 -0
- package/marketplace/plugins/github-actions/package.json +30 -0
- package/marketplace/plugins/github-actions/settings-schema.json +27 -0
- package/marketplace/plugins/github-actions/src/app.tsx +32 -0
- package/marketplace/plugins/github-actions/src/panel/Actions.tsx +105 -0
- package/marketplace/plugins/github-actions/src/panel/LogView.tsx +76 -0
- package/marketplace/plugins/github-actions/src/panel/Row.tsx +59 -0
- package/marketplace/plugins/github-actions/src/panel/RunView.tsx +197 -0
- package/marketplace/plugins/github-actions/src/panel/format.ts +74 -0
- package/marketplace/plugins/github-actions/src/panel/index.test.tsx +86 -0
- package/marketplace/plugins/github-actions/src/panel/index.tsx +256 -0
- package/marketplace/plugins/github-actions/src/panel/picker.test.tsx +68 -0
- package/marketplace/plugins/github-actions/src/panel/test-fixtures.ts +98 -0
- package/marketplace/plugins/github-actions/src/panel/test-harness.tsx +175 -0
- package/marketplace/plugins/github-actions/src/protocol.ts +156 -0
- package/marketplace/plugins/github-actions/src/server/github.test.ts +264 -0
- package/marketplace/plugins/github-actions/src/server/github.ts +309 -0
- package/marketplace/plugins/github-actions/src/server/http.test.ts +150 -0
- package/marketplace/plugins/github-actions/src/server/http.ts +202 -0
- package/marketplace/plugins/github-actions/src/server/json.ts +44 -0
- package/marketplace/plugins/github-actions/src/server/logtext.test.ts +84 -0
- package/marketplace/plugins/github-actions/src/server/logtext.ts +59 -0
- package/marketplace/plugins/github-actions/src/server/progress.test.ts +96 -0
- package/marketplace/plugins/github-actions/src/server/progress.ts +62 -0
- package/marketplace/plugins/github-actions/src/server/remote.ts +84 -0
- package/marketplace/plugins/github-actions/src/server/scope.ts +51 -0
- package/marketplace/plugins/github-actions/src/server/token.ts +84 -0
- package/marketplace/plugins/github-actions/src/server.ts +163 -0
- package/marketplace/plugins/github-actions/src/state.test.ts +55 -0
- package/marketplace/plugins/github-actions/src/state.ts +63 -0
- package/marketplace/plugins/github-actions/tsconfig.json +16 -0
- package/package.json +1 -1
- package/src/client/components/mobile/RightSidebar.tsx +164 -66
- package/src/client/components/mobile/header-titlebar.test.tsx +92 -0
- package/src/client/components/mobile/mobile-right-sidebar/Chrome.tsx +179 -0
- package/src/client/components/mobile/panel-chips.test.tsx +12 -0
- package/src/client/components/mobile/panel-chips.tsx +5 -1
- package/src/client/components/mobile/right-drawer-nav.test.tsx +258 -0
- package/src/client/components/settings/apply-side-effects.ts +6 -0
- package/src/client/components/settings/categories/appearance-settings/PanelNavSection.tsx +123 -2
- package/src/client/components/workspace/panel-tabs/Home.tsx +14 -2
- package/src/client/components/workspace/panel-tabs/TabChip.tsx +173 -0
- package/src/client/components/workspace/panel-tabs/TabStrip.test.tsx +118 -0
- package/src/client/components/workspace/panel-tabs/TabStrip.tsx +89 -102
- package/src/client/components/workspace/panel-tabs/index.tsx +9 -1
- package/src/client/hooks/workspace/mobile-right-panel-nav.ts +63 -0
- package/src/client/hooks/workspace/panel-nav.test.ts +39 -1
- package/src/client/lib/ui/control-plate.ts +33 -0
- package/src/server/lib/bundler/titlebar-css.test.ts +5 -3
- package/src/shared/lib/settings/defaults.ts +2 -1
- package/src/shared/lib/workspace/panel-nav.test.ts +36 -0
- package/src/shared/lib/workspace/panel-nav.ts +43 -0
- package/src/shared/types/settings/state.ts +9 -1
- package/dist/client/static/js/LayoutWrapper-vw54s8ra.js +0 -2
- package/dist/client/static/js/architecture-7GRP2DOG-mq93vqx9.js +0 -1
- package/dist/client/static/js/bash-fjzhxy10.js +0 -1
- package/dist/client/static/js/cpp-9f6zkdd4.js +0 -1
- package/dist/client/static/js/css-y4y3qtsb.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-qyg5rjr5.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-15yz245z.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-n1sapfye.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-xtjwv160.js +0 -1
- package/dist/client/static/js/graphql-amk52c95.js +0 -1
- package/dist/client/static/js/html-2y935m7r.js +0 -1
- package/dist/client/static/js/index-19ffgf9a.js +0 -2
- package/dist/client/static/js/index-204ae4vs.js +0 -2
- package/dist/client/static/js/index-n6fbd265.js +0 -1
- package/dist/client/static/js/index-sc7r305t.css +0 -1
- package/dist/client/static/js/info-A6RAGUB7-e31s2xvj.js +0 -1
- package/dist/client/static/js/ini-kemnmt16.js +0 -1
- package/dist/client/static/js/java-caqpfm88.js +0 -1
- package/dist/client/static/js/javascript-zegm06a1.js +0 -1
- package/dist/client/static/js/jsx-bvterpm5.js +0 -1
- package/dist/client/static/js/lua-1hcfm8ya.js +0 -1
- package/dist/client/static/js/markdown-n6na4ykv.js +0 -1
- package/dist/client/static/js/one-dark-pro-c1vnxka7.js +0 -1
- package/dist/client/static/js/one-light-mbxx52p5.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-mtzmsrk4.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-85nwadmj.js +0 -1
- package/dist/client/static/js/properties-nxcks67c.js +0 -1
- package/dist/client/static/js/python-58p0gqn0.js +0 -1
- package/dist/client/static/js/r-eyn8en0g.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-ae3jdajx.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-3m0s7cse.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-pz22c3eb.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-cgqgqq15.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-ts0nmcxb.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-n85hawg8.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-fvpt3hm8.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-4z9s24je.js +0 -1
- package/dist/client/static/js/tsx-fnzxsv25.js +0 -1
- package/dist/client/static/js/typescript-0ppbqrb6.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-73mrhkmy.js +0 -1
- package/dist/client/static/js/xml-v1ytr8qz.js +0 -1
- package/dist/client/static/js/yaml-txrqz62t.js +0 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* GitHub's Actions API, transcribed into this plugin's shapes.
|
|
8
|
+
*
|
|
9
|
+
* The adapter is a pure transcription: it is handed a way to GET (or POST) and
|
|
10
|
+
* answers `RunRow` / `Job` / `LogTail`. That is what makes the mapping testable
|
|
11
|
+
* against a recorded body with no host, no token and no socket — and it is why
|
|
12
|
+
* this module owns neither the cache, the credential nor the timeout.
|
|
13
|
+
*
|
|
14
|
+
* Two measured facts shape it:
|
|
15
|
+
*
|
|
16
|
+
* - **The list payload is ~16 KB per run** (481 KB for thirty), because every row
|
|
17
|
+
* embeds the repository object. `perPage` is therefore clamped low and a full
|
|
18
|
+
* page is reported as truncated rather than claimed complete.
|
|
19
|
+
* - **The job-log endpoint answers `302` to a signed blob URL, and that URL
|
|
20
|
+
* rejects the GitHub token** (`401 InvalidAuthenticationInfo`). The log read
|
|
21
|
+
* therefore follows the redirect MANUALLY and re-requests `Location` with no
|
|
22
|
+
* headers at all.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { Job, LogTail, RunRow, RunVerb, Step } from '../protocol';
|
|
26
|
+
import { stateOf } from '../state';
|
|
27
|
+
import { getJson, authHeaders, type JsonCache } from './http';
|
|
28
|
+
import { asRecord, listAt, listOfStrings, num, text, textAt } from './json';
|
|
29
|
+
import { cleanLog, tailOf } from './logtext';
|
|
30
|
+
|
|
31
|
+
export interface GithubContext {
|
|
32
|
+
apiBase: string;
|
|
33
|
+
slug: string;
|
|
34
|
+
host: string;
|
|
35
|
+
token: string | null;
|
|
36
|
+
/** 1-100; the API clamps above 100 and the panel never wants that page. */
|
|
37
|
+
perPage: number;
|
|
38
|
+
cache: JsonCache;
|
|
39
|
+
fetchImpl?: typeof fetch;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ReadFailure = { ok: false; message: string };
|
|
43
|
+
|
|
44
|
+
function joinUrl(base: string, path: string): string {
|
|
45
|
+
return `${base.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function repoUrl(context: GithubContext, path: string): string {
|
|
49
|
+
return joinUrl(context.apiBase, `/repos/${context.slug}${path}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The page size a read asks for, clamped to what the API accepts. */
|
|
53
|
+
export function pageSize(perPage: number): number {
|
|
54
|
+
return Math.min(100, Math.max(1, Math.round(perPage)));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** One run row, or null when the payload is not a run. */
|
|
58
|
+
export function runOf(raw: unknown): RunRow | null {
|
|
59
|
+
const record = asRecord(raw);
|
|
60
|
+
if (!record) return null;
|
|
61
|
+
const id = num(record.id);
|
|
62
|
+
if (!id) return null;
|
|
63
|
+
const status = text(record.status);
|
|
64
|
+
const conclusion = text(record.conclusion) || null;
|
|
65
|
+
return {
|
|
66
|
+
id,
|
|
67
|
+
name: text(record.name, '(unnamed workflow)'),
|
|
68
|
+
title: text(record.display_title) || text(record.name, '(untitled run)'),
|
|
69
|
+
branch: text(record.head_branch) || null,
|
|
70
|
+
event: text(record.event, 'push'),
|
|
71
|
+
status,
|
|
72
|
+
conclusion,
|
|
73
|
+
state: stateOf(status, conclusion),
|
|
74
|
+
number: num(record.run_number),
|
|
75
|
+
attempt: num(record.run_attempt, 1),
|
|
76
|
+
actor: textAt(record.actor, 'login', 'unknown'),
|
|
77
|
+
createdAt: text(record.created_at),
|
|
78
|
+
startedAt: text(record.run_started_at) || null,
|
|
79
|
+
updatedAt: text(record.updated_at),
|
|
80
|
+
url: text(record.html_url),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** One step, or null when the payload has no name. */
|
|
85
|
+
export function stepOf(raw: unknown): Step | null {
|
|
86
|
+
const record = asRecord(raw);
|
|
87
|
+
if (!record) return null;
|
|
88
|
+
const name = text(record.name);
|
|
89
|
+
if (!name) return null;
|
|
90
|
+
const status = text(record.status);
|
|
91
|
+
const conclusion = text(record.conclusion) || null;
|
|
92
|
+
return {
|
|
93
|
+
number: num(record.number),
|
|
94
|
+
name,
|
|
95
|
+
status,
|
|
96
|
+
conclusion,
|
|
97
|
+
state: stateOf(status, conclusion),
|
|
98
|
+
startedAt: text(record.started_at) || null,
|
|
99
|
+
completedAt: text(record.completed_at) || null,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** One job, or null when the payload has no id. */
|
|
104
|
+
export function jobOf(raw: unknown): Job | null {
|
|
105
|
+
const record = asRecord(raw);
|
|
106
|
+
if (!record) return null;
|
|
107
|
+
const id = num(record.id);
|
|
108
|
+
if (!id) return null;
|
|
109
|
+
const status = text(record.status);
|
|
110
|
+
const conclusion = text(record.conclusion) || null;
|
|
111
|
+
return {
|
|
112
|
+
id,
|
|
113
|
+
name: text(record.name, '(unnamed job)'),
|
|
114
|
+
status,
|
|
115
|
+
conclusion,
|
|
116
|
+
state: stateOf(status, conclusion),
|
|
117
|
+
startedAt: text(record.started_at) || null,
|
|
118
|
+
completedAt: text(record.completed_at) || null,
|
|
119
|
+
runner: text(record.runner_name) || null,
|
|
120
|
+
labels: listOfStrings(record.labels),
|
|
121
|
+
url: text(record.html_url) || null,
|
|
122
|
+
steps: listAt(record.steps)
|
|
123
|
+
.map(stepOf)
|
|
124
|
+
.filter((step): step is Step => step !== null),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface RunPageResult {
|
|
129
|
+
ok: true;
|
|
130
|
+
runs: RunRow[];
|
|
131
|
+
total: number | null;
|
|
132
|
+
truncated: boolean;
|
|
133
|
+
notes: string[];
|
|
134
|
+
authenticated: boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** One page of runs for the repository, optionally narrowed. */
|
|
138
|
+
export async function listRuns(
|
|
139
|
+
context: GithubContext,
|
|
140
|
+
filter: { branch: string; status: string },
|
|
141
|
+
): Promise<RunPageResult | ReadFailure> {
|
|
142
|
+
const params = new URLSearchParams({ per_page: String(pageSize(context.perPage)) });
|
|
143
|
+
if (filter.branch.trim()) params.set('branch', filter.branch.trim());
|
|
144
|
+
if (filter.status.trim()) params.set('status', filter.status.trim());
|
|
145
|
+
|
|
146
|
+
const result = await getJson({
|
|
147
|
+
url: `${repoUrl(context, '/actions/runs')}?${params.toString()}`,
|
|
148
|
+
headers: authHeaders(context.token),
|
|
149
|
+
cache: context.cache,
|
|
150
|
+
...(context.fetchImpl ? { fetchImpl: context.fetchImpl } : {}),
|
|
151
|
+
});
|
|
152
|
+
if (!result.ok) return { ok: false, message: result.message };
|
|
153
|
+
|
|
154
|
+
const payload = asRecord(result.value) ?? {};
|
|
155
|
+
const runs = listAt(payload.workflow_runs)
|
|
156
|
+
.map(runOf)
|
|
157
|
+
.filter((run): run is RunRow => run !== null);
|
|
158
|
+
const authenticated = Boolean(context.token);
|
|
159
|
+
const notes: string[] = [];
|
|
160
|
+
if (!authenticated) {
|
|
161
|
+
notes.push('Reading anonymously: runs and jobs are visible, job logs are not.');
|
|
162
|
+
}
|
|
163
|
+
if (runs.length >= pageSize(context.perPage)) {
|
|
164
|
+
notes.push(`Showing ${runs.length} runs; GitHub has more.`);
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
ok: true,
|
|
168
|
+
runs,
|
|
169
|
+
total: typeof payload.total_count === 'number' ? payload.total_count : null,
|
|
170
|
+
truncated: runs.length >= pageSize(context.perPage),
|
|
171
|
+
notes,
|
|
172
|
+
authenticated,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** One run, by id. */
|
|
177
|
+
export async function getRun(context: GithubContext, id: number): Promise<{ ok: true; run: RunRow } | ReadFailure> {
|
|
178
|
+
const result = await getJson({
|
|
179
|
+
url: repoUrl(context, `/actions/runs/${id}`),
|
|
180
|
+
headers: authHeaders(context.token),
|
|
181
|
+
cache: context.cache,
|
|
182
|
+
...(context.fetchImpl ? { fetchImpl: context.fetchImpl } : {}),
|
|
183
|
+
});
|
|
184
|
+
if (!result.ok) return { ok: false, message: result.message };
|
|
185
|
+
const run = runOf(result.value);
|
|
186
|
+
if (!run) return { ok: false, message: 'GitHub answered a run this panel could not read.' };
|
|
187
|
+
return { ok: true, run };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Every job of a run's latest attempt, with their steps. */
|
|
191
|
+
export async function listJobs(
|
|
192
|
+
context: GithubContext,
|
|
193
|
+
id: number,
|
|
194
|
+
): Promise<{ ok: true; jobs: Job[]; notes: string[] } | ReadFailure> {
|
|
195
|
+
const params = new URLSearchParams({ per_page: '100', filter: 'latest' });
|
|
196
|
+
const result = await getJson({
|
|
197
|
+
url: `${repoUrl(context, `/actions/runs/${id}/jobs`)}?${params.toString()}`,
|
|
198
|
+
headers: authHeaders(context.token),
|
|
199
|
+
cache: context.cache,
|
|
200
|
+
...(context.fetchImpl ? { fetchImpl: context.fetchImpl } : {}),
|
|
201
|
+
});
|
|
202
|
+
if (!result.ok) return { ok: false, message: result.message };
|
|
203
|
+
const payload = asRecord(result.value) ?? {};
|
|
204
|
+
const jobs = listAt(payload.jobs)
|
|
205
|
+
.map(jobOf)
|
|
206
|
+
.filter((job): job is Job => job !== null);
|
|
207
|
+
const notes: string[] = [];
|
|
208
|
+
if (jobs.length >= 100) notes.push('More than 100 jobs; the page is full.');
|
|
209
|
+
return { ok: true, jobs, notes };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** The sentence a thrown fetch becomes. Three call sites, one wording. */
|
|
213
|
+
function unreachable(cause: unknown): string {
|
|
214
|
+
return `Could not reach GitHub: ${cause instanceof Error ? cause.message : String(cause)}`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* One job's log, cleaned and tailed.
|
|
219
|
+
*
|
|
220
|
+
* The first request carries the token and MUST NOT follow the redirect; the
|
|
221
|
+
* second carries nothing. `Range` is not honoured on the signed URL (measured:
|
|
222
|
+
* a `bytes=-2000` request answered `200` with all 63,430 bytes), so the tail is
|
|
223
|
+
* taken after the download rather than asked for.
|
|
224
|
+
*/
|
|
225
|
+
export async function jobLog(
|
|
226
|
+
context: GithubContext,
|
|
227
|
+
jobId: number,
|
|
228
|
+
capBytes: number,
|
|
229
|
+
fetchImpl: typeof fetch = context.fetchImpl ?? fetch,
|
|
230
|
+
): Promise<{ ok: true; log: LogTail } | ReadFailure> {
|
|
231
|
+
if (!context.token) {
|
|
232
|
+
return {
|
|
233
|
+
ok: false,
|
|
234
|
+
message: 'Job logs need a token: GitHub answers 403 to an anonymous read.',
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const url = repoUrl(context, `/actions/jobs/${jobId}/logs`);
|
|
238
|
+
let first: Response;
|
|
239
|
+
try {
|
|
240
|
+
first = await fetchImpl(url, {
|
|
241
|
+
headers: { ...authHeaders(context.token), accept: 'application/vnd.github+json' },
|
|
242
|
+
redirect: 'manual',
|
|
243
|
+
signal: AbortSignal.timeout(20_000),
|
|
244
|
+
});
|
|
245
|
+
} catch (cause) {
|
|
246
|
+
return { ok: false, message: unreachable(cause) };
|
|
247
|
+
}
|
|
248
|
+
if (first.status >= 400) {
|
|
249
|
+
const body = await first.json().catch(() => null);
|
|
250
|
+
const message = typeof asRecord(body)?.message === 'string' ? String(asRecord(body)?.message) : `GitHub answered ${first.status}.`;
|
|
251
|
+
return { ok: false, message: `GitHub refused the log: ${message}` };
|
|
252
|
+
}
|
|
253
|
+
const location = first.headers.get('location');
|
|
254
|
+
if (!location) return { ok: false, message: 'GitHub answered the log request without a download URL.' };
|
|
255
|
+
|
|
256
|
+
let second: Response;
|
|
257
|
+
try {
|
|
258
|
+
second = await fetchImpl(location);
|
|
259
|
+
} catch (cause) {
|
|
260
|
+
return { ok: false, message: `Could not download the log: ${cause instanceof Error ? cause.message : String(cause)}` };
|
|
261
|
+
}
|
|
262
|
+
if (!second.ok) return { ok: false, message: `The log download answered ${second.status}.` };
|
|
263
|
+
|
|
264
|
+
const raw = await second.text();
|
|
265
|
+
const cleaned = cleanLog(raw);
|
|
266
|
+
const { text: tailed, truncated } = tailOf(cleaned, Math.max(1, capBytes));
|
|
267
|
+
return { ok: true, log: { job: String(jobId), text: tailed, bytes: cleaned.length, truncated } };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const VERB_PATH: Readonly<Record<RunVerb, string>> = {
|
|
271
|
+
cancel: 'cancel',
|
|
272
|
+
rerun: 'rerun',
|
|
273
|
+
'rerun-failed': 'rerun-failed-jobs',
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const VERB_DONE: Readonly<Record<RunVerb, string>> = {
|
|
277
|
+
cancel: 'Cancellation requested.',
|
|
278
|
+
rerun: 'Re-run requested.',
|
|
279
|
+
'rerun-failed': 'Re-run of the failed jobs requested.',
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
/** One of the three verbs. A refusal carries GitHub's own sentence. */
|
|
283
|
+
export async function act(
|
|
284
|
+
context: GithubContext,
|
|
285
|
+
id: number,
|
|
286
|
+
verb: RunVerb,
|
|
287
|
+
): Promise<{ ok: true; message: string } | ReadFailure> {
|
|
288
|
+
if (!context.token) {
|
|
289
|
+
return { ok: false, message: 'This verb needs a token: GitHub refuses it anonymously.' };
|
|
290
|
+
}
|
|
291
|
+
const fetchImpl = context.fetchImpl ?? fetch;
|
|
292
|
+
let response: Response;
|
|
293
|
+
try {
|
|
294
|
+
response = await fetchImpl(repoUrl(context, `/actions/runs/${id}/${VERB_PATH[verb]}`), {
|
|
295
|
+
method: 'POST',
|
|
296
|
+
headers: { ...authHeaders(context.token), 'content-length': '0' },
|
|
297
|
+
signal: AbortSignal.timeout(20_000),
|
|
298
|
+
});
|
|
299
|
+
} catch (cause) {
|
|
300
|
+
return { ok: false, message: unreachable(cause) };
|
|
301
|
+
}
|
|
302
|
+
if (response.ok) return { ok: true, message: VERB_DONE[verb] };
|
|
303
|
+
const body = await response.json().catch(() => null);
|
|
304
|
+
const stated = asRecord(body)?.message;
|
|
305
|
+
return {
|
|
306
|
+
ok: false,
|
|
307
|
+
message: typeof stated === 'string' ? stated : `GitHub answered ${response.status}.`,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The conditional read, which is the only reason a 60-second poll is allowed.
|
|
8
|
+
*
|
|
9
|
+
* A second read of an unchanged resource must send the stored validator and must
|
|
10
|
+
* NOT rewrite the cache; a changed one must replace the body and the validator.
|
|
11
|
+
* A failure must be a sentence the panel can render, not a status code.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, expect, test } from 'bun:test';
|
|
15
|
+
|
|
16
|
+
import { cacheKey, describeFailure, getJson, kvCache, type KvLike } from './http';
|
|
17
|
+
|
|
18
|
+
/** An in-memory `api.storage.kv`, so nothing here touches a plugin store. */
|
|
19
|
+
function memoryKv(): KvLike & { entries: Map<string, unknown> } {
|
|
20
|
+
const entries = new Map<string, unknown>();
|
|
21
|
+
return {
|
|
22
|
+
entries,
|
|
23
|
+
read: async <T>(key: string) => entries.get(key) as T | undefined,
|
|
24
|
+
write: async (key, value) => {
|
|
25
|
+
entries.set(key, value);
|
|
26
|
+
},
|
|
27
|
+
remove: async (key) => {
|
|
28
|
+
entries.delete(key);
|
|
29
|
+
},
|
|
30
|
+
keys: async () => [...entries.keys()].sort(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const URL_UNDER_TEST = 'https://api.github.com/repos/kabmo-labs/kabmo/actions/runs?per_page=30';
|
|
35
|
+
|
|
36
|
+
describe('getJson', () => {
|
|
37
|
+
test('stores the etag with the body, and the next read sends it', async () => {
|
|
38
|
+
const kv = memoryKv();
|
|
39
|
+
const cache = kvCache(kv);
|
|
40
|
+
const seen: Array<Record<string, string>> = [];
|
|
41
|
+
let calls = 0;
|
|
42
|
+
const fetchImpl = (async (_url: string, init?: RequestInit) => {
|
|
43
|
+
calls += 1;
|
|
44
|
+
seen.push((init?.headers ?? {}) as Record<string, string>);
|
|
45
|
+
if (calls === 1) {
|
|
46
|
+
return new Response(JSON.stringify({ total_count: 591 }), {
|
|
47
|
+
status: 200,
|
|
48
|
+
headers: { etag: '"abc"', 'content-type': 'application/json' },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return new Response(null, { status: 304, headers: { etag: '"abc"' } });
|
|
52
|
+
}) as unknown as typeof fetch;
|
|
53
|
+
|
|
54
|
+
const first = await getJson({ url: URL_UNDER_TEST, cache, fetchImpl });
|
|
55
|
+
expect(first.ok && first.notModified).toBe(false);
|
|
56
|
+
const second = await getJson({ url: URL_UNDER_TEST, cache, fetchImpl });
|
|
57
|
+
expect(second.ok && second.notModified).toBe(true);
|
|
58
|
+
expect(second.ok && second.value).toEqual({ total_count: 591 });
|
|
59
|
+
expect(seen[1]!['if-none-match']).toBe('"abc"');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('a changed body replaces the stored validator', async () => {
|
|
63
|
+
const kv = memoryKv();
|
|
64
|
+
const cache = kvCache(kv);
|
|
65
|
+
let calls = 0;
|
|
66
|
+
const fetchImpl = (async () => {
|
|
67
|
+
calls += 1;
|
|
68
|
+
return new Response(JSON.stringify({ total_count: calls }), {
|
|
69
|
+
status: 200,
|
|
70
|
+
headers: { etag: `"v${calls}"` },
|
|
71
|
+
});
|
|
72
|
+
}) as unknown as typeof fetch;
|
|
73
|
+
|
|
74
|
+
await getJson({ url: URL_UNDER_TEST, cache, fetchImpl });
|
|
75
|
+
const again = await getJson({ url: URL_UNDER_TEST, cache, fetchImpl });
|
|
76
|
+
expect(again.ok && again.value).toEqual({ total_count: 2 });
|
|
77
|
+
const stored = await cache.read(URL_UNDER_TEST);
|
|
78
|
+
expect(stored?.etag).toBe('"v2"');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('a refusal is a sentence, and a rate limit says when to retry', async () => {
|
|
82
|
+
const cache = kvCache(memoryKv());
|
|
83
|
+
const fetchImpl = (async () =>
|
|
84
|
+
new Response(JSON.stringify({ message: 'API rate limit exceeded' }), {
|
|
85
|
+
status: 403,
|
|
86
|
+
headers: { 'x-ratelimit-remaining': '0', 'x-ratelimit-reset': '1795181467' },
|
|
87
|
+
})) as unknown as typeof fetch;
|
|
88
|
+
|
|
89
|
+
const result = await getJson({ url: URL_UNDER_TEST, cache, fetchImpl });
|
|
90
|
+
expect(result.ok).toBe(false);
|
|
91
|
+
if (!result.ok) {
|
|
92
|
+
expect(result.status).toBe(403);
|
|
93
|
+
expect(result.message).toContain('Rate limit reached');
|
|
94
|
+
expect(result.message).toContain('Try again after');
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('an unreachable host is reported, not thrown', async () => {
|
|
99
|
+
const cache = kvCache(memoryKv());
|
|
100
|
+
const fetchImpl = (async () => {
|
|
101
|
+
throw new Error('getaddrinfo ENOTFOUND api.github.com');
|
|
102
|
+
}) as unknown as typeof fetch;
|
|
103
|
+
const result = await getJson({ url: URL_UNDER_TEST, cache, fetchImpl });
|
|
104
|
+
expect(result.ok).toBe(false);
|
|
105
|
+
if (!result.ok) expect(result.message).toContain('Could not reach GitHub');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('kvCache.invalidate', () => {
|
|
110
|
+
test('drops only the entries under the prefix a write changed', async () => {
|
|
111
|
+
const kv = memoryKv();
|
|
112
|
+
const cache = kvCache(kv);
|
|
113
|
+
await cache.write({ url: 'https://api.github.com/repos/o/r/actions/runs?per_page=30', etag: 'a', body: {}, at: Date.now() });
|
|
114
|
+
await cache.write({ url: 'https://api.github.com/repos/o/r/actions/runs/1/jobs', etag: 'b', body: {}, at: Date.now() });
|
|
115
|
+
await cache.write({ url: 'https://api.github.com/repos/o/r/pulls', etag: 'c', body: {}, at: Date.now() });
|
|
116
|
+
|
|
117
|
+
await cache.invalidate('https://api.github.com/repos/o/r/actions/');
|
|
118
|
+
|
|
119
|
+
expect(await cache.read('https://api.github.com/repos/o/r/actions/runs?per_page=30')).toBeUndefined();
|
|
120
|
+
expect(await cache.read('https://api.github.com/repos/o/r/actions/runs/1/jobs')).toBeUndefined();
|
|
121
|
+
expect(await cache.read('https://api.github.com/repos/o/r/pulls')).toBeDefined();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('a cache key is stable and bounded', () => {
|
|
125
|
+
const key = cacheKey(URL_UNDER_TEST);
|
|
126
|
+
expect(key).toBe(cacheKey(URL_UNDER_TEST));
|
|
127
|
+
expect(key.length).toBeLessThan(60);
|
|
128
|
+
expect(key).not.toBe(cacheKey(`${URL_UNDER_TEST}&branch=main`));
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('describeFailure', () => {
|
|
133
|
+
const headers = (values: Record<string, string>) => new Headers(values);
|
|
134
|
+
|
|
135
|
+
test('an anonymous 403 is about the missing credential, not about scope', () => {
|
|
136
|
+
expect(describeFailure(403, headers({}), false)).toContain('anonymous');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('an authenticated 403 is about the token scope', () => {
|
|
140
|
+
expect(describeFailure(403, headers({}), true)).toContain('scope');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('a 404 on a public read names the private-repository possibility', () => {
|
|
144
|
+
expect(describeFailure(404, headers({}), false)).toContain('private');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('a 401 tells an anonymous reader the endpoint needs a token', () => {
|
|
148
|
+
expect(describeFailure(401, headers({}), false)).toContain('needs a token');
|
|
149
|
+
});
|
|
150
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reading JSON without spending the reader's quota twice.
|
|
8
|
+
*
|
|
9
|
+
* A second read of an unchanged resource is a `304`, and GitHub does not charge
|
|
10
|
+
* a conditional request that answers `304` against the primary limit — measured
|
|
11
|
+
* on this repository: six consecutive conditional reads left
|
|
12
|
+
* `x-ratelimit-remaining` untouched. That is why every list, run and jobs read
|
|
13
|
+
* is conditional, so the ETag is stored with the body rather than derived from it.
|
|
14
|
+
*
|
|
15
|
+
* A failure is a SENTENCE, not a status code: "rate limited, try after 14:20" and
|
|
16
|
+
* "this endpoint needs a token even on a public repository" are different things
|
|
17
|
+
* to do next, and the panel renders whichever it got.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { PluginJson } from '@kabmo-labs/kabmo-sdk';
|
|
21
|
+
|
|
22
|
+
/** One cached read: the body, the validator that describes it, and its age. */
|
|
23
|
+
export interface CacheEntry {
|
|
24
|
+
url: string;
|
|
25
|
+
etag: string | null;
|
|
26
|
+
body: PluginJson;
|
|
27
|
+
at: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The storage a read needs. Injected so the tests never touch a plugin store. */
|
|
31
|
+
export interface JsonCache {
|
|
32
|
+
read(url: string): Promise<CacheEntry | undefined>;
|
|
33
|
+
write(entry: CacheEntry): Promise<void>;
|
|
34
|
+
/** Drop every entry whose URL starts with `prefix` — what a write invalidates. */
|
|
35
|
+
invalidate(prefix: string): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The slice of `api.storage.kv` this module uses. */
|
|
39
|
+
export interface KvLike {
|
|
40
|
+
read<T = PluginJson>(key: string): Promise<T | undefined>;
|
|
41
|
+
write(key: string, value: PluginJson): Promise<void>;
|
|
42
|
+
remove(key: string): Promise<void>;
|
|
43
|
+
keys(): Promise<string[]>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Entries kept before the oldest are dropped. */
|
|
47
|
+
const MAX_ENTRIES = 40;
|
|
48
|
+
const MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
49
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
50
|
+
const USER_AGENT = 'kabmo-actions';
|
|
51
|
+
|
|
52
|
+
/** A stable short key: FNV-1a, because the store's keys are strings. */
|
|
53
|
+
export function cacheKey(url: string): string {
|
|
54
|
+
let hash = 0x811c9dc5;
|
|
55
|
+
for (let index = 0; index < url.length; index += 1) {
|
|
56
|
+
hash ^= url.charCodeAt(index);
|
|
57
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
58
|
+
}
|
|
59
|
+
return `cache:${hash.toString(16).padStart(8, '0')}:${url.length.toString(16)}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A cache over the plugin's own key/value store. */
|
|
63
|
+
export function kvCache(kv: KvLike): JsonCache {
|
|
64
|
+
return {
|
|
65
|
+
async read(url) {
|
|
66
|
+
const entry = await kv.read<CacheEntry>(cacheKey(url));
|
|
67
|
+
return entry && entry.url === url ? entry : undefined;
|
|
68
|
+
},
|
|
69
|
+
async write(entry) {
|
|
70
|
+
await kv.write(cacheKey(entry.url), entry as unknown as PluginJson);
|
|
71
|
+
const keys = await kv.keys();
|
|
72
|
+
const cacheKeys = keys.filter((key) => key.startsWith('cache:'));
|
|
73
|
+
if (cacheKeys.length <= MAX_ENTRIES) return;
|
|
74
|
+
// Prune the oldest: an ETag that never expires would pin a stale body and
|
|
75
|
+
// a store that never shrinks would grow with every filter the user types.
|
|
76
|
+
const entries: Array<{ key: string; at: number }> = [];
|
|
77
|
+
for (const key of cacheKeys) {
|
|
78
|
+
const stored = await kv.read<CacheEntry>(key);
|
|
79
|
+
if (stored) entries.push({ key, at: stored.at });
|
|
80
|
+
}
|
|
81
|
+
entries.sort((a, b) => a.at - b.at);
|
|
82
|
+
for (const stale of entries.slice(0, Math.max(0, entries.length - MAX_ENTRIES))) {
|
|
83
|
+
await kv.remove(stale.key);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
async invalidate(prefix) {
|
|
87
|
+
for (const key of await kv.keys()) {
|
|
88
|
+
if (!key.startsWith('cache:')) continue;
|
|
89
|
+
const stored = await kv.read<CacheEntry>(key);
|
|
90
|
+
if (stored && stored.url.startsWith(prefix)) await kv.remove(key);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The headers a token adds. Absent means an anonymous read. */
|
|
97
|
+
export function authHeaders(token: string | null): Record<string, string> {
|
|
98
|
+
if (!token) return {};
|
|
99
|
+
return { authorization: `Bearer ${token}`, 'x-github-api-version': '2022-11-28' };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Whether a request carries a credential. */
|
|
103
|
+
export function isAuthenticated(headers: Record<string, string> | undefined): boolean {
|
|
104
|
+
return Boolean(headers?.authorization);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** "Try again after HH:MM", from a unix reset or a seconds delay. */
|
|
108
|
+
function resetHint(value: string | null): string {
|
|
109
|
+
const seconds = Number(value);
|
|
110
|
+
if (!Number.isFinite(seconds) || seconds <= 0) return 'Try again later.';
|
|
111
|
+
const at = seconds > 1_000_000_000 ? new Date(seconds * 1000) : new Date(Date.now() + seconds * 1000);
|
|
112
|
+
return `Try again after ${at.toLocaleTimeString()}.`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* What a failed status means to the person reading the panel.
|
|
117
|
+
*
|
|
118
|
+
* `authenticated` matters because the same status means two things: a `403`
|
|
119
|
+
* without a credential is the host refusing an anonymous read, and advising about
|
|
120
|
+
* a token's scope there is advice about a token that was never sent.
|
|
121
|
+
*/
|
|
122
|
+
export function describeFailure(status: number, headers: Headers, authenticated: boolean): string {
|
|
123
|
+
if (status === 401) {
|
|
124
|
+
return authenticated
|
|
125
|
+
? 'GitHub rejected the token (401). Check the plugin setting, GITHUB_TOKEN / GH_TOKEN, or `gh auth login`.'
|
|
126
|
+
: 'This endpoint needs a token (401) even on a public repository.';
|
|
127
|
+
}
|
|
128
|
+
if (status === 403) {
|
|
129
|
+
if (headers.get('x-ratelimit-remaining') === '0') {
|
|
130
|
+
return `Rate limit reached (403). ${resetHint(headers.get('x-ratelimit-reset'))}`;
|
|
131
|
+
}
|
|
132
|
+
return authenticated
|
|
133
|
+
? 'Access refused (403). The token may lack the `repo` / `workflow` scope for this repository.'
|
|
134
|
+
: 'GitHub refused an anonymous read (403). Set a token, or run `gh auth login`.';
|
|
135
|
+
}
|
|
136
|
+
if (status === 404) {
|
|
137
|
+
return authenticated
|
|
138
|
+
? 'Not found (404). The repository may have been renamed, or the token cannot see it.'
|
|
139
|
+
: 'Not found (404). The repository may be private; a private one needs a token.';
|
|
140
|
+
}
|
|
141
|
+
if (status === 429) return `Rate limited (429). ${resetHint(headers.get('retry-after'))}`;
|
|
142
|
+
return `GitHub answered ${status}.`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface GetOptions {
|
|
146
|
+
url: string;
|
|
147
|
+
headers?: Record<string, string>;
|
|
148
|
+
cache: JsonCache;
|
|
149
|
+
fetchImpl?: typeof fetch;
|
|
150
|
+
now?: () => number;
|
|
151
|
+
timeoutMs?: number;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type GetResult =
|
|
155
|
+
| { ok: true; value: PluginJson | undefined; notModified: boolean }
|
|
156
|
+
| { ok: false; status: number; message: string };
|
|
157
|
+
|
|
158
|
+
/** Read one URL as JSON, conditionally. */
|
|
159
|
+
export async function getJson(options: GetOptions): Promise<GetResult> {
|
|
160
|
+
const now = options.now ?? Date.now;
|
|
161
|
+
const entry = await options.cache.read(options.url);
|
|
162
|
+
if (entry && now() - entry.at > MAX_AGE_MS) await options.cache.invalidate(options.url);
|
|
163
|
+
|
|
164
|
+
const headers: Record<string, string> = {
|
|
165
|
+
accept: 'application/vnd.github+json',
|
|
166
|
+
'user-agent': USER_AGENT,
|
|
167
|
+
...options.headers,
|
|
168
|
+
};
|
|
169
|
+
const usable = entry && now() - entry.at <= MAX_AGE_MS ? entry : undefined;
|
|
170
|
+
if (usable?.etag) headers['if-none-match'] = usable.etag;
|
|
171
|
+
|
|
172
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
173
|
+
let response: Response;
|
|
174
|
+
try {
|
|
175
|
+
response = await fetchImpl(options.url, {
|
|
176
|
+
headers,
|
|
177
|
+
signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS),
|
|
178
|
+
});
|
|
179
|
+
} catch (cause) {
|
|
180
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
181
|
+
return { ok: false, status: 0, message: `Could not reach GitHub: ${message}` };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (response.status === 304) {
|
|
185
|
+
return { ok: true, value: usable?.body, notModified: true };
|
|
186
|
+
}
|
|
187
|
+
if (!response.ok) {
|
|
188
|
+
return {
|
|
189
|
+
ok: false,
|
|
190
|
+
status: response.status,
|
|
191
|
+
message: describeFailure(response.status, response.headers, isAuthenticated(options.headers)),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
let body: PluginJson;
|
|
195
|
+
try {
|
|
196
|
+
body = (await response.json()) as PluginJson;
|
|
197
|
+
} catch {
|
|
198
|
+
return { ok: false, status: response.status, message: 'GitHub answered a body that is not JSON.' };
|
|
199
|
+
}
|
|
200
|
+
await options.cache.write({ url: options.url, etag: response.headers.get('etag'), body, at: now() });
|
|
201
|
+
return { ok: true, value: body, notModified: false };
|
|
202
|
+
}
|