dirigent-server 0.19.0__tar.gz → 0.20.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/PKG-INFO +5 -5
  2. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/pyproject.toml +5 -5
  3. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/pyproject.toml.orig +5 -5
  4. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/playground.py +159 -3
  5. dirigent_server-0.19.0/src/dirigent_server/static/assets/Alerting-DPHrAbP5.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Alerting-DaeWPtmD.js +1 -1
  6. dirigent_server-0.19.0/src/dirigent_server/static/assets/Blocks-CTbBgJSs.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Blocks-CgKNmzTx.js +1 -1
  7. dirigent_server-0.19.0/src/dirigent_server/static/assets/Connections-CjyNbx7P.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Connections-C8QLqabn.js +1 -1
  8. dirigent_server-0.19.0/src/dirigent_server/static/assets/Dashboard-DSlMoM2G.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Dashboard-Ctln2D1_.js +1 -1
  9. dirigent_server-0.19.0/src/dirigent_server/static/assets/ExamplePanel-Ba6aib_L.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/ExamplePanel-t52rV-xc.js +1 -1
  10. dirigent_server-0.19.0/src/dirigent_server/static/assets/Examples-qo66eKED.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Examples-D_GF1FoJ.js +2 -2
  11. dirigent_server-0.19.0/src/dirigent_server/static/assets/JsonBlock-CZ3pzdQd.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/JsonBlock-ojXBf3xC.js +1 -1
  12. dirigent_server-0.19.0/src/dirigent_server/static/assets/Overview-CZJOH_Ci.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Overview-DQDMn1kh.js +1 -1
  13. dirigent_server-0.19.0/src/dirigent_server/static/assets/Picker-C5k6L204.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Picker-BzRYpj3s.js +1 -1
  14. dirigent_server-0.20.0/src/dirigent_server/static/assets/PipelineEditor-B8xKU23L.js +2 -0
  15. dirigent_server-0.19.0/src/dirigent_server/static/assets/PipelineGraph-D4mIFvg8.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/PipelineGraph-DIcmE3aB.js +1 -1
  16. dirigent_server-0.19.0/src/dirigent_server/static/assets/PipelinePreview-Bh31a8YB.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/PipelinePreview-DNIz5Oe9.js +1 -1
  17. dirigent_server-0.19.0/src/dirigent_server/static/assets/PipelineTab-Cfr2dyAj.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/PipelineTab-Cq5YZYns.js +1 -1
  18. dirigent_server-0.19.0/src/dirigent_server/static/assets/Refusal-B2rlk8VD.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Refusal-DickLwkO.js +1 -1
  19. dirigent_server-0.19.0/src/dirigent_server/static/assets/RunDetail-GgC-1Ma3.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/RunDetail-DjOWNczO.js +3 -3
  20. dirigent_server-0.19.0/src/dirigent_server/static/assets/RunGraph-raonFnyd.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/RunGraph-D6sxqM0W.js +1 -1
  21. dirigent_server-0.20.0/src/dirigent_server/static/assets/SchemaForm-oVYx_dDn.js +1 -0
  22. dirigent_server-0.19.0/src/dirigent_server/static/assets/Schemas-D5uR8yla.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Schemas-CkglczUH.js +1 -1
  23. dirigent_server-0.19.0/src/dirigent_server/static/assets/SettingsDialog-CgALkqHY.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/SettingsDialog-SxFoYOL5.js +1 -1
  24. dirigent_server-0.19.0/src/dirigent_server/static/assets/StarterPicker-CcaWNru5.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/StarterPicker-BmoaI_cF.js +1 -1
  25. dirigent_server-0.19.0/src/dirigent_server/static/assets/StepPorts-PlS_VS4B.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/StepPorts-Ct88rZ3W.js +1 -1
  26. dirigent_server-0.19.0/src/dirigent_server/static/assets/TileCard-DERgB2kj.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/TileCard-UUULdrAd.js +1 -1
  27. dirigent_server-0.19.0/src/dirigent_server/static/assets/Triggers-D5cdnjJV.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Triggers-4Qo_wwjX.js +1 -1
  28. dirigent_server-0.19.0/src/dirigent_server/static/assets/Users-DYxSHyt1.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Users-C4q8b5-R.js +1 -1
  29. dirigent_server-0.19.0/src/dirigent_server/static/assets/WindowedPane-BUe4ZBNS.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/WindowedPane-Dc5ox2RS.js +1 -1
  30. dirigent_server-0.19.0/src/dirigent_server/static/assets/Workers-Bb39s8gk.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/Workers-D7LJK74x.js +1 -1
  31. dirigent_server-0.19.0/src/dirigent_server/static/assets/WorkersTable-Bdjj57jO.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/WorkersTable-BFuSEEhm.js +1 -1
  32. dirigent_server-0.20.0/src/dirigent_server/static/assets/connections-Cp5WCruj.js +1 -0
  33. dirigent_server-0.19.0/src/dirigent_server/static/assets/examples-DDWkSZ2u.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/examples-DB467CTN.js +1 -1
  34. dirigent_server-0.19.0/src/dirigent_server/static/assets/index-Bp4KzK9w.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/index-CzO6Janm.js +2 -2
  35. dirigent_server-0.19.0/src/dirigent_server/static/assets/select-Dl8ZhXSH.js → dirigent_server-0.20.0/src/dirigent_server/static/assets/select-fQgkAQLW.js +1 -1
  36. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/index.html +1 -1
  37. dirigent_server-0.19.0/src/dirigent_server/static/assets/PipelineEditor-B1_fPiWM.js +0 -2
  38. dirigent_server-0.19.0/src/dirigent_server/static/assets/SchemaForm-C08AaK2P.js +0 -1
  39. dirigent_server-0.19.0/src/dirigent_server/static/assets/connections-DsdoSARb.js +0 -1
  40. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/LICENSE +0 -0
  41. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/README.md +0 -0
  42. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/THIRD_PARTY_NOTICES.md +0 -0
  43. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/__init__.py +0 -0
  44. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/app.py +0 -0
  45. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/dependencies.py +0 -0
  46. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/errors.py +0 -0
  47. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/health.py +0 -0
  48. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/logging.py +0 -0
  49. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/messages.py +0 -0
  50. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/pagination.py +0 -0
  51. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/py.typed +0 -0
  52. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/__init__.py +0 -0
  53. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/alerts.py +0 -0
  54. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/auth.py +0 -0
  55. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/blocks.py +0 -0
  56. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/connections.py +0 -0
  57. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/examples.py +0 -0
  58. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/hooks.py +0 -0
  59. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/pipelines.py +0 -0
  60. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/runs.py +0 -0
  61. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/schema.py +0 -0
  62. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/schemas.py +0 -0
  63. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/system.py +0 -0
  64. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/trigger_documents.py +0 -0
  65. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/triggers.py +0 -0
  66. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/users.py +0 -0
  67. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/routes/workers.py +0 -0
  68. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/security.py +0 -0
  69. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/.gitkeep +0 -0
  70. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/AdminOnly-CWzFAkRQ.js +0 -0
  71. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/Breadcrumb-x6p00HyX.js +0 -0
  72. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/CodeEditor-B9sClhqO.js +0 -0
  73. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/CodeEditor-C4OnjBMt.css +0 -0
  74. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/Description-MmXUnb-9.js +0 -0
  75. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/Instant-mr1E5jAK.js +0 -0
  76. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/KindChip-CwU_Xxdy.js +0 -0
  77. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ListTable-D-mI8v9Y.js +0 -0
  78. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/Mark-DQR2php6.js +0 -0
  79. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/Markdown-roa7jpVu.js +0 -0
  80. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/PageState-BLuobMye.js +0 -0
  81. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/Panel-CqrOYByl.js +0 -0
  82. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ProgramReference-DF37mMAT.js +0 -0
  83. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/Segmented-KaDiGiyr.js +0 -0
  84. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/api-Bm1JZLuC.js +0 -0
  85. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/auth-CHgfcdt9.js +0 -0
  86. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/badge-BovCxjd1.js +0 -0
  87. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/blocks-CclbVd8c.js +0 -0
  88. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/chevron-down-DAO3SUWv.js +0 -0
  89. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/chunk-OB3PAWPO-DOp4K52_.js +0 -0
  90. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/codicon-DCmgc-ay.ttf +0 -0
  91. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/copy-BeBwg8IR.js +0 -0
  92. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/dist-DD8kpv1W.js +0 -0
  93. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/docs-CCoB3shg.js +0 -0
  94. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/dropdown-menu-B-6CcHKw.js +0 -0
  95. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/editor.worker-CIvRzd4O.js +0 -0
  96. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/elk-engine-Bm7I_NRI.js +0 -0
  97. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/elk-worker.min-DfmSo98M.js +0 -0
  98. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/file-braces-Ep8AP5Yq.js +0 -0
  99. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/format-B5YbYOY-.js +0 -0
  100. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/glyphs-C1sjljkh.js +0 -0
  101. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  102. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  103. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  104. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  105. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  106. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  107. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  108. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  109. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  110. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  111. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  112. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  113. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  114. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  115. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  116. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  117. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  118. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  119. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  120. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  121. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  122. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  123. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  124. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  125. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  126. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  127. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  128. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  129. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  130. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  131. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
  132. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
  133. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
  134. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
  135. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
  136. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
  137. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/identity-BNZxCf_y.js +0 -0
  138. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/idle-DnO3aHK7.js +0 -0
  139. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/index-CgkcXl1G.css +0 -0
  140. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/input-1fShkFXn.js +0 -0
  141. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/json.worker-fczZDBja.js +0 -0
  142. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/jsonMode-C2rhmYxE.js +0 -0
  143. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/nav-i7bJ0lrA.js +0 -0
  144. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/paging-CpRIkEky.js +0 -0
  145. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/pipelines-Pi3WL8R6.js +0 -0
  146. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/play-CPVSEWx6.js +0 -0
  147. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/preferences-CEibwN5K.js +0 -0
  148. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/preload-helper-BZ1Pz5am.js +0 -0
  149. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/react-CQOZoUwg.js +0 -0
  150. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/resolveAriaLabelledBy-ClHvyYLK.js +0 -0
  151. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/rolldown-runtime-Dd_uD5pT.js +0 -0
  152. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/schemas-7KY_7aIc.js +0 -0
  153. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/shell-CC2rA5mh.js +0 -0
  154. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/sql-NEE52Syq.js +0 -0
  155. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/starters-CgC7I45V.js +0 -0
  156. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/status-Ctx8x8Mf.js +0 -0
  157. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/store-C2zgoyrT.js +0 -0
  158. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/textarea-ljIbN_md.js +0 -0
  159. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/tooltip-D7_KwbOU.js +0 -0
  160. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/triggers-BetQ4Leu.js +0 -0
  161. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/twig-De2hgUGE.js +0 -0
  162. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/use-heartbeat-CBT8848s.js +0 -0
  163. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/use-store-CfRquqZF.js +0 -0
  164. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/users-CTGHiHMA.js +0 -0
  165. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/utils-CT7ZGLfR.js +0 -0
  166. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/with-selector-BXYKoaOE.js +0 -0
  167. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/workers-BH2Za19E.js +0 -0
  168. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/x-Dltw6Vbs.js +0 -0
  169. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/yaml-CLSOANGG.js +0 -0
  170. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/assets/yaml.worker-B2SaT_wA.js +0 -0
  171. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/favicon-32.png +0 -0
  172. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/static/logo.png +0 -0
  173. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/transactions.py +0 -0
  174. {dirigent_server-0.19.0 → dirigent_server-0.20.0}/src/dirigent_server/ui.py +0 -0
@@ -1,16 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dirigent-server
3
- Version: 0.19.0
3
+ Version: 0.20.0
4
4
  Summary: Dirigent FastAPI server: the REST API, its authentication, and the health probes.
5
5
  License-Expression: LicenseRef-Proprietary
6
6
  License-File: LICENSE
7
7
  License-File: THIRD_PARTY_NOTICES.md
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3.13
10
- Requires-Dist: dirigent-client==0.19.0
11
- Requires-Dist: dirigent-common==0.19.0
12
- Requires-Dist: dirigent-core==0.19.0
13
- Requires-Dist: dirigent-examples==0.19.0
10
+ Requires-Dist: dirigent-client==0.20.0
11
+ Requires-Dist: dirigent-common==0.20.0
12
+ Requires-Dist: dirigent-core==0.20.0
13
+ Requires-Dist: dirigent-examples==0.20.0
14
14
  Requires-Dist: fastapi>=0.141.1
15
15
  Requires-Python: >=3.13
16
16
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dirigent-server"
3
- version = "0.19.0"
3
+ version = "0.20.0"
4
4
  description = "Dirigent FastAPI server: the REST API, its authentication, and the health probes."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -14,10 +14,10 @@ classifiers = [
14
14
  "Programming Language :: Python :: 3.13",
15
15
  ]
16
16
  dependencies = [
17
- "dirigent-client==0.19.0",
18
- "dirigent-common==0.19.0",
19
- "dirigent-core==0.19.0",
20
- "dirigent-examples==0.19.0",
17
+ "dirigent-client==0.20.0",
18
+ "dirigent-common==0.20.0",
19
+ "dirigent-core==0.20.0",
20
+ "dirigent-examples==0.20.0",
21
21
  "fastapi>=0.141.1",
22
22
  ]
23
23
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dirigent-server"
3
- version = "0.19.0"
3
+ version = "0.20.0"
4
4
  description = "Dirigent FastAPI server: the REST API, its authentication, and the health probes."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -11,10 +11,10 @@ classifiers = [
11
11
  "Programming Language :: Python :: 3.13",
12
12
  ]
13
13
  dependencies = [
14
- "dirigent-client==0.19.0",
15
- "dirigent-common==0.19.0",
16
- "dirigent-core==0.19.0",
17
- "dirigent-examples==0.19.0",
14
+ "dirigent-client==0.20.0",
15
+ "dirigent-common==0.20.0",
16
+ "dirigent-core==0.20.0",
17
+ "dirigent-examples==0.20.0",
18
18
  "fastapi>=0.141.1",
19
19
  ]
20
20
 
@@ -8,6 +8,17 @@ Every route answers the same envelope. ``kind`` names the answer, ``request`` ho
8
8
  arrived verbatim, and every other key is what the route decided -- the knobs resolved, after
9
9
  defaults and after a seed was drawn. So ``request.args.rows`` is the string that was sent
10
10
  and ``rows`` is the number that was used.
11
+
12
+ ``/playground/stream`` is the one route that cannot repeat the envelope, because a stream has
13
+ one set of headers and many bodies. It sends the envelope as its first line instead, and the
14
+ lines after it carry only what changes.
15
+
16
+ Nothing here generates records. A field map is Faker, Faker lives in the block family that
17
+ contributes ``playground.generate``, and the server does not depend on a block package: blocks
18
+ are contributed through pluginkit and run on workers, and a server-only install in a split
19
+ deployment must not have to carry the built-in block set to serve an API. So the division is
20
+ along what each surface is for -- the routes hand a consumer bytes arriving over time, and the
21
+ blocks put generated data into a pipeline, which is where the field map belongs.
11
22
  """
12
23
 
13
24
  import asyncio
@@ -15,16 +26,18 @@ import base64
15
26
  import binascii
16
27
  import json
17
28
  import secrets
18
- from datetime import timedelta
29
+ import time
30
+ from collections.abc import AsyncIterator
31
+ from datetime import UTC, datetime, timedelta
19
32
  from typing import Annotated, Final
20
33
  from urllib.parse import unquote_plus, urlencode
21
34
 
22
35
  from fastapi import APIRouter, Query, Request, Response
23
36
  from fastapi import status as http_status
24
- from fastapi.responses import JSONResponse
37
+ from fastapi.responses import JSONResponse, StreamingResponse
25
38
  from pydantic import BaseModel, JsonValue
26
39
 
27
- from dirigent_common import Duration
40
+ from dirigent_common import Duration, Size, filler
28
41
  from dirigent_server.errors import Refusal
29
42
  from dirigent_server.messages import (
30
43
  PLAYGROUND_BAD_KNOB,
@@ -78,6 +91,24 @@ FORBIDDEN_HEADERS: Final = frozenset(
78
91
  #: Query names the routes read as knobs, so ``response-headers`` never sets one as a header.
79
92
  RESERVED_ARGS: Final = frozenset({"delay", "status"})
80
93
 
94
+ #: The most messages one stream may be asked for.
95
+ MAX_STREAM_MESSAGES: Final = 100
96
+
97
+ #: The longest gap one stream may be asked to leave between messages.
98
+ MAX_GAP: Final = timedelta(seconds=10)
99
+
100
+ #: The longest a whole stream may take. The gap and the message count multiply, so each one
101
+ #: being inside its own bound is not enough to keep an unauthenticated connection short.
102
+ MAX_SPAN: Final = timedelta(seconds=60)
103
+
104
+ #: The largest filler one stream message may carry. The same ceiling the ``playground.generate``
105
+ #: node puts on its own ``payload``, which is the same filler at the same size.
106
+ MAX_PAYLOAD: Final = 1024 * 1024
107
+
108
+ #: What a stream is served as: one JSON record per line, which is the shape every record this
109
+ #: project emits already has, and what ``jq`` reads a line at a time.
110
+ NDJSON: Final = "application/x-ndjson"
111
+
81
112
  #: The credential ``/playground/auth`` accepts. Public constants, documented as such: they
82
113
  #: protect nothing and unlock nothing but this one route's 200.
83
114
  BASIC_USERNAME: Final = "playground"
@@ -172,6 +203,55 @@ class SetHeaders(Answer):
172
203
  """Every header this answer set, exactly as it was asked to."""
173
204
 
174
205
 
206
+ class StreamOpened(Answer):
207
+ """A stream's first line: the request facts, and every knob the lines after it run under.
208
+
209
+ A stream has one set of headers and many bodies, so the envelope cannot ride on each
210
+ message the way it rides on every other playground answer. It is sent once, here.
211
+ """
212
+
213
+ messages: int
214
+ """How many messages follow this line."""
215
+
216
+ gap_ms: int
217
+ """How long the stream waits before each message, in milliseconds."""
218
+
219
+ payload_bytes: int | None = None
220
+ """How large the filler on each message is, when a payload size was asked for."""
221
+
222
+
223
+ class StreamMessage(BaseModel):
224
+ """One message of a stream, carrying only what the first line could not say in advance."""
225
+
226
+ kind: str = "stream.message"
227
+ """What this line is, which is what a reader dispatches on."""
228
+
229
+ offset: int
230
+ """Its place in the stream, counting from zero."""
231
+
232
+ sent_at: datetime
233
+ """When this message left the instance."""
234
+
235
+ elapsed_ms: int
236
+ """How long after the first line this message left, so a cadence can be measured."""
237
+
238
+ payload: str | None = None
239
+ """The filler that was asked for, when a payload size was set."""
240
+
241
+
242
+ class StreamClosed(BaseModel):
243
+ """A stream's last line, which is how a reader tells an ending from a cut connection."""
244
+
245
+ kind: str = "stream.closed"
246
+ """What this line is, which is what a reader dispatches on."""
247
+
248
+ messages: int
249
+ """How many messages the stream sent."""
250
+
251
+ duration_ms: int
252
+ """How long the whole stream took, from its first line to this one."""
253
+
254
+
175
255
  class Credential(Answer):
176
256
  """A call that presented a credential the playground accepts."""
177
257
 
@@ -401,6 +481,82 @@ async def unreliable(
401
481
  return _answer(answer, code)
402
482
 
403
483
 
484
+ @router.get(
485
+ f"{PREFIX}/stream",
486
+ operation_id="playgroundStream",
487
+ summary="Send a stream of messages instead of one body",
488
+ response_model=None,
489
+ responses={
490
+ 200: {"content": {NDJSON: {}}, "description": "One JSON record per line: an envelope, messages, an end."},
491
+ 422: {"description": "A stream that would run longer than the playground holds a connection open."},
492
+ },
493
+ )
494
+ async def stream(
495
+ request: Request,
496
+ messages: Annotated[
497
+ int,
498
+ Query(ge=1, le=MAX_STREAM_MESSAGES, description="How many messages to send after the envelope."),
499
+ ] = 5,
500
+ every: Annotated[Duration, Query(description="How long to wait before each message, as `250ms` or `2s`.")] = (
501
+ timedelta(seconds=1)
502
+ ),
503
+ payload: Annotated[
504
+ Size | None,
505
+ Query(description="Filler of this size on every message, as `16kb`, to make each one large."),
506
+ ] = None,
507
+ delay: DelayArg = timedelta(0),
508
+ ) -> Response:
509
+ """Send an envelope, then a message every ``every``, then a line saying the stream ended.
510
+
511
+ The one route whose answer arrives in pieces, for a consumer that has to be tested against
512
+ bytes that turn up over time rather than a body that is already whole. It generates
513
+ nothing: a message carries its offset, when it was sent, how long after the envelope that
514
+ was, and the filler a ``payload`` asked for.
515
+ """
516
+ if every < timedelta(0) or every > MAX_GAP:
517
+ raise _bad_knob(f"a gap is between 0 and {int(MAX_GAP.total_seconds())}s")
518
+ if payload is not None and payload > MAX_PAYLOAD:
519
+ raise _bad_knob(f"a payload is at most {MAX_PAYLOAD} bytes")
520
+ if messages * every > MAX_SPAN:
521
+ raise _bad_knob(
522
+ f"{messages} messages {int(every.total_seconds() * 1000)}ms apart would hold the "
523
+ f"connection open longer than {int(MAX_SPAN.total_seconds())}s"
524
+ )
525
+ await _delayed(delay)
526
+ opened = StreamOpened(
527
+ kind="stream",
528
+ request=await _facts(request),
529
+ messages=messages,
530
+ gap_ms=round(every.total_seconds() * 1000),
531
+ payload_bytes=payload,
532
+ )
533
+ return StreamingResponse(
534
+ _lines(opened, every, None if payload is None else filler(payload)),
535
+ media_type=NDJSON,
536
+ # A stream a proxy holds until it is whole is not a stream, and the point of the route
537
+ # is that its pieces arrive apart.
538
+ headers={"cache-control": "no-cache", "x-accel-buffering": "no"},
539
+ )
540
+
541
+
542
+ async def _lines(opened: StreamOpened, every: timedelta, padding: str | None) -> AsyncIterator[str]:
543
+ """The lines one stream sends: the envelope, a message per gap, and the end."""
544
+ started = time.monotonic()
545
+ yield opened.model_dump_json() + "\n"
546
+ for offset in range(opened.messages):
547
+ if every > timedelta(0):
548
+ await asyncio.sleep(every.total_seconds())
549
+ message = StreamMessage(
550
+ offset=offset,
551
+ sent_at=datetime.now(UTC),
552
+ elapsed_ms=round((time.monotonic() - started) * 1000),
553
+ payload=padding,
554
+ )
555
+ yield message.model_dump_json() + "\n"
556
+ closed = StreamClosed(messages=opened.messages, duration_ms=round((time.monotonic() - started) * 1000))
557
+ yield closed.model_dump_json() + "\n"
558
+
559
+
404
560
  @router.get(
405
561
  f"{PREFIX}/response-headers",
406
562
  operation_id="playgroundResponseHeaders",
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{r as n}from"./with-selector-BXYKoaOE.js";import{n as r}from"./chunk-OB3PAWPO-DOp4K52_.js";import{i,r as a}from"./api-Bm1JZLuC.js";import{N as o}from"./dropdown-menu-B-6CcHKw.js";import{r as s}from"./glyphs-C1sjljkh.js";import{n as c,o as l,s as u,t as d}from"./PageState-BLuobMye.js";import{i as f,t as p}from"./ListTable-D-mI8v9Y.js";import{t as m}from"./WindowedPane-BUe4ZBNS.js";import{r as h,t as g}from"./utils-CT7ZGLfR.js";import{i as _,n as v,t as y}from"./tooltip-D7_KwbOU.js";import{d as b,f as x}from"./paging-CpRIkEky.js";import{t as S}from"./input-1fShkFXn.js";import{l as C}from"./format-B5YbYOY-.js";import{t as w}from"./identity-BNZxCf_y.js";import{r as T,t as E,u as D}from"./pipelines-Pi3WL8R6.js";import{Ft as O,It as k,Lt as ee,Mt as te,Nt as ne,O as A,Pt as j,Rt as M,_t as re,b as ie,dt as N,g as P,jt as ae,mt as F,nt as oe,rt as se,st as I,ut as ce,v as L,w as R,y as z}from"./index-Bp4KzK9w.js";import{t as le}from"./Description-MmXUnb-9.js";import{c as ue,f as de,n as fe,o as pe}from"./connections-DsdoSARb.js";import{n as B,t as V}from"./Refusal-B2rlk8VD.js";import{t as H}from"./Instant-mr1E5jAK.js";import{t as me}from"./Segmented-KaDiGiyr.js";import{t as he}from"./Mark-DQR2php6.js";import{t as ge}from"./ProgramReference-DF37mMAT.js";import{t as _e}from"./Picker-C5k6L204.js";import{t as ve}from"./AdminOnly-CWzFAkRQ.js";var ye={name:`bell-plus`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M15 8h6`,key:`8ybuxh`}],[`path`,{d:`M18 5v6`,key:`g5ayrv`}],[`path`,{d:`M20.002 14.464a9 9 0 0 0 .738.863A1 1 0 0 1 20 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 8.75-5.332`,key:`1abcvy`}]]};ye.node;var be=n(ye),xe={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};xe.node;var Se=n(xe),U=e(t(),1),Ce=[`run_failed`,`run_completed_with_errors`,`run_succeeded`,`run_stuck`],W={run_failed:`Failed`,run_completed_with_errors:`Completed with errors`,run_succeeded:`Succeeded`,run_stuck:`Stuck`},we=[`pending`,`sending`,`sent`,`failed`],Te=`0s`;function Ee(e){return e===Te?`none`:e}function De(e){return e.scope===`pipeline`&&e.pipeline!==null?e.pipeline:`every pipeline`}function Oe(e){return e===null?null:`${e} and above`}function ke(e){return e.active&&!e.paused}function Ae(e){return e===`sent`||e===`failed`}function je(e,t=50){let n=new URLSearchParams({limit:String(t)});return e!==null&&n.set(`after`,e),`/alert-rules?${n.toString()}`}function Me(e){return a(je(e))}function Ne(e){return i(`/alert-rules`,`POST`,e)}function Pe(e,t){return i(`/alert-rules/${encodeURIComponent(e)}`,`PATCH`,t)}function Fe(e,t){return Pe(e,{paused:t})}function Ie(e){return a(`/alert-rules/${encodeURIComponent(e)}`,{method:`DELETE`})}var Le={status:``,notifier:``};function Re(e,t,n=50){let r=new URLSearchParams({limit:String(n)});return e.status!==``&&r.set(`status`,e.status),e.notifier!==``&&r.set(`notifier`,e.notifier),t!==null&&r.set(`after`,t),`/notifications?${r.toString()}`}function ze(e,t){return a(Re(e,t))}function Be(e){return a(`/notifications/${encodeURIComponent(e)}`)}function Ve(e){return i(`/notifications/${encodeURIComponent(e)}/$retry`,`POST`,{})}function He(e){return i(`/alert-rules/$test`,`POST`,e)}async function Ue(){return(await a(`/blocks`)).notifiers.map(e=>e.id)}function We(e,t){let n=[];for(let r of e){if(r===`log`){n.push({id:r,notifier:r,connection:null,reachable:!0,last_check_at:null,last_check_healthy:null,last_check_detail:null});continue}let e=t.filter(e=>e.kind===r);if(e.length===0){n.push({id:r,notifier:r,connection:null,reachable:!1,last_check_at:null,last_check_healthy:null,last_check_detail:null});continue}for(let t of e)n.push({id:`${r}:${t.code}`,notifier:r,connection:t.code,reachable:!0,last_check_at:t.last_check_at,last_check_healthy:t.last_check_healthy,last_check_detail:t.last_check_detail})}return Je(n)}function Ge(e){return e.connection??e.notifier}function Ke(e){return e.connection===null?e.notifier===`log`?null:ue(e.notifier):fe(e.connection)}function G(e){if(e.notifier===`log`)return{tone:`good`,label:`ready`,detail:null};if(!e.reachable)return{tone:`quiet`,label:`not set up`,detail:null};let t=pe(e);return{tone:t.tone??`quiet`,label:t.label,detail:t.detail}}var qe={good:0,critical:1,quiet:2};function Je(e){return e.toSorted((e,t)=>{let n=qe[G(e).tone]-qe[G(t).tone];if(n!==0)return n;let r=e.notifier.localeCompare(t.notifier);return r===0?(e.connection??``).localeCompare(t.connection??``):r})}var Ye=/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/u,Xe=/^(?:\d+(?:ms|s|m|h|d|w))+$/u,Ze=`A Jinja template: {{ run.* }} reads the run's pipeline, status, id, error, trigger, duration_ms and url.`,Qe=`A Jinja template over the run's facts; report is the run's report document when it has one.`,K=`text/x-jinja`;function q(e){let t=e.trim();return t===``?null:t}var $e=[{value:`global`,label:`Every pipeline`},{value:`pipeline`,label:`One pipeline`}],et=[{value:``,label:`Any`},...E.map(e=>({value:e,label:e[0].toUpperCase()+e.slice(1)}))];function tt(e){return e===``?null:e}function nt(e){return e===``?null:e}var rt=`The process log`;function it(e,t){let n=t.filter(t=>t.kind!==`log`&&e.includes(t.kind)).map(e=>({row:e,heading:w(e)})).toSorted((e,t)=>e.row.kind.localeCompare(t.row.kind)||e.heading.title.localeCompare(t.heading.title));return[{value:``,label:rt,aside:``,mark:s(`log`)},...n.map(({row:e,heading:t})=>({value:e.code,label:`${t.title} · ${e.kind}`,aside:t.code??``,mark:s(e.kind)}))]}function at(e){if(e.code.trim()===``)return`A rule is addressed by its code, and this one has none.`;if(!Ye.test(e.code.trim()))return`A code is lowercase words joined by - or _.`;if(e.scope===`pipeline`&&e.pipeline===``)return`A rule watching one pipeline names that pipeline, and this one names none.`;if(!Xe.test(e.throttle.trim()))return`A throttle is a duration, such as 15m.`}var J=h();function ot({rule:e,onChanged:t,onDeleted:n,onTest:r}){let[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(null),c=o===e.code,u=z(),d=Oe(e.importance),f=(0,U.useCallback)(e=>ze(Le,e),[]),{state:p}=L(f,lt),m=p.rows.filter(t=>t.rule===e.code);return(0,J.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,J.jsxs)(mt,{thing:e,children:[e.paused&&(0,J.jsx)(pt,{children:`paused`}),!e.active&&(0,J.jsx)(pt,{children:`off`})]}),(0,J.jsx)(le,{text:e.description}),(0,J.jsxs)(`dl`,{className:`space-y-1.5`,children:[(0,J.jsx)(Y,{label:`Event`,children:W[e.event]}),(0,J.jsx)(Y,{label:`Scope`,children:(0,J.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[De(e),d!==null&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d})]})}),(0,J.jsx)(Y,{label:`Delivers through`,children:(0,J.jsx)(ut,{notifier:e.notifier,connection:e.connection})}),(0,J.jsx)(Y,{label:`Throttle`,children:Ee(e.throttle)}),c?(0,J.jsx)(st,{rule:e,onDone:()=>{s(null)},onSaved:e=>{t(e),s(null)}},e.code):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{label:`Subject`,children:(0,J.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-2`,children:[e.template===null?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`none`}):(0,J.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.template}),(0,J.jsx)(l,{why:u.why,children:(0,J.jsx)(x,{variant:`ghost`,size:`xs`,disabled:!u.may,title:u.why,onClick:()=>{s(e.code)},children:`Edit`})})]})}),e.body!==null&&(0,J.jsx)(Y,{label:`Body`,children:(0,J.jsx)(`span`,{className:`line-clamp-3 font-mono text-xs break-words whitespace-pre-wrap`,children:e.body})})]}),(0,J.jsx)(Y,{label:`Last sent`,children:e.last_sent_at===null?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`never`}):(0,J.jsx)(H,{at:e.last_sent_at})})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(l,{why:u.why,children:(0,J.jsx)(x,{variant:`outline`,size:`sm`,disabled:i||!u.may,title:u.why,onClick:()=>{a(!0),Fe(e.code,!e.paused).then(t,B).finally(()=>{a(!1)})},children:e.paused?`Resume`:`Pause`})}),(0,J.jsx)(l,{why:u.why,children:(0,J.jsx)(x,{variant:`outline`,size:`sm`,disabled:!u.may,title:u.why,onClick:r,children:`Send a test`})}),(0,J.jsx)(l,{why:u.why,children:(0,J.jsx)(x,{variant:`outline`,size:`sm`,className:`destructive-action ml-auto`,disabled:i||!u.may,title:u.why,onClick:()=>{a(!0),Ie(e.code).then(n,B).finally(()=>{a(!1)})},children:`Delete`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Recent deliveries`}),!p.read&&(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:`Reading from the server`}),p.read&&m.length===0&&(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:`Nothing sent.`}),(0,J.jsx)(`ul`,{className:`divide-y divide-border`,children:m.map(e=>(0,J.jsxs)(`li`,{className:`row-hover -mx-4 flex items-center gap-2 px-4 py-2`,children:[(0,J.jsx)(R,{status:e.status}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:e.subject}),(0,J.jsx)(H,{className:`shrink-0 text-xs text-faint`,at:e.created_at})]},e.id))})]})]})}function st({rule:e,onDone:t,onSaved:n}){let[r,i]=(0,U.useState)(e.template??``),[a,o]=(0,U.useState)(e.body??``),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1),d=`alert-rule/${e.code}/body`,f=`rule-${e.code}-subject`;return(0,J.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border bg-secondary/30 p-3`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{htmlFor:f,children:`Subject`}),(0,J.jsx)(S,{id:f,className:`font-mono`,spellCheck:!1,autoComplete:`off`,value:r,placeholder:`{{ run.pipeline }} run {{ run.status }}`,onChange:e=>{i(e.target.value)}}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:Ze})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Body`}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:Qe}),(0,J.jsx)(m,{name:`body`,className:`overflow-hidden rounded-md border border-border bg-background`,aside:(0,J.jsx)(ge,{mediaType:K}),windowed:(0,J.jsx)(I,{value:a,mediaType:K,path:d,label:`body, in a window`,className:`min-h-0 flex-1`,onChange:o}),children:(0,J.jsx)(I,{value:a,mediaType:K,path:d,label:`body`,placeholder:`{{ run.pipeline }} ended {{ run.status }}: {{ run.url }}`,className:`h-40 min-h-32`,onChange:o})})]}),s!==null&&(0,J.jsx)(V,{problem:s}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(x,{variant:`ghost`,size:`sm`,onClick:t,children:`Cancel`}),(0,J.jsx)(x,{size:`sm`,disabled:l,onClick:()=>{let i={};if(q(r)!==e.template&&(i.template=q(r)),q(a)!==e.body&&(i.body=q(a)),Object.keys(i).length===0){t();return}u(!0),c(null),Pe(e.code,i).then(n,e=>{c(b(e))}).finally(()=>{u(!1)})},children:l?`Saving`:`Save`})]})]})}function ct({notification:e,onChanged:t}){let[n,i]=(0,U.useState)(!1),a=z();return(0,J.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,J.jsx)(`div`,{className:`space-y-1`,children:(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(R,{status:e.status}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:e.subject})]})}),(0,J.jsxs)(`dl`,{className:`space-y-1.5`,children:[e.rule===null?(0,J.jsx)(Y,{label:`Raised by`,children:(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`a test, not a rule`})}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{label:`Event`,children:W[e.event]}),(0,J.jsx)(Y,{label:`Rule`,children:(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:e.rule})})]}),(0,J.jsx)(Y,{label:`Delivers through`,children:(0,J.jsx)(dt,{notifier:e.notifier,connection:e.connection})}),(0,J.jsx)(Y,{label:`Run`,children:(0,J.jsx)(ft,{notification:e})}),(0,J.jsx)(Y,{label:`Queued`,children:(0,J.jsx)(H,{at:e.created_at})}),e.status===`sent`?(0,J.jsx)(Y,{label:`Sent`,children:(0,J.jsx)(H,{at:e.sent_at})}):(0,J.jsx)(Y,{label:`Next try`,children:(0,J.jsx)(H,{at:e.available_at})}),(0,J.jsxs)(Y,{label:`Attempts`,children:[e.attempt,` of `,e.max_attempts]})]}),e.error!==null&&(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`What the channel said`}),(0,J.jsx)(`p`,{className:`text-xs break-words text-critical`,children:e.error}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:`Only the latest refusal is kept. Earlier attempts are counted, not stored.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(l,{why:a.why,children:(0,J.jsx)(x,{variant:`outline`,size:`sm`,disabled:n||!a.may,title:a.why,onClick:()=>{i(!0),Ve(e.id).then(t,B).finally(()=>{i(!1)})},children:`Retry now`})}),e.run_id!==null&&(0,J.jsx)(x,{variant:`outline`,size:`sm`,render:(0,J.jsx)(r,{to:`/runs/${e.run_id}`}),children:`Open the run`})]})]})}var lt=e=>e.id;function ut({notifier:e,connection:t}){return(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(he,{glyph:s(e)}),(0,J.jsx)(`span`,{className:t===null?`text-sm`:`font-mono text-xs`,children:t??e})]})}function dt({notifier:e,connection:t}){return(0,J.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-sm`,children:e}),t!==null&&(0,J.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:t})]})}function ft({notification:e}){if(e.run_id===null)return(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`no run`});let t=e.run_pipeline??`a run`;return(0,J.jsxs)(r,{className:`text-primary hover:underline`,to:`/runs/${e.run_id}`,children:[(0,J.jsx)(`span`,{className:`text-sm`,children:t}),e.run_started_at!==null&&(0,J.jsx)(H,{className:`ml-1.5 text-xs text-muted-foreground`,at:e.run_started_at})]})}function pt({children:e}){return(0,J.jsx)(`span`,{className:`rounded-sm border border-border px-1.5 text-xs text-muted-foreground`,children:e})}function mt({thing:e,children:t}){let n=w(e);return(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:n.named?`text-sm font-semibold`:`font-mono text-sm font-semibold`,children:n.title}),t,n.code!==null&&(0,J.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:n.code})]})}function Y({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,J.jsx)(`dt`,{className:`w-32 shrink-0 text-xs text-muted-foreground`,children:e}),(0,J.jsx)(`dd`,{className:`min-w-0 text-sm`,children:t})]})}var ht={good:`var(--good)`,critical:`var(--critical)`,quiet:`var(--faint)`},gt=`flex min-h-9 items-center gap-2 rounded-full border border-border bg-card py-1 pr-3 pl-2.5 transition-colors`,X=`hover:bg-muted focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`;function _t({channels:e,read:t}){let n=u(),r=vt(e.length,t);return n?(0,J.jsx)(xt,{channels:e,note:r}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Channels`}),r===null?(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,J.jsx)(`li`,{className:`flex`,children:(0,J.jsx)(yt,{channel:e})},e.id))}):(0,J.jsx)(`p`,{className:r.tone,children:r.text})]})}function vt(e,t){return t?e===0?{text:`No channel is installed.`,tone:`text-sm text-muted-foreground`}:null:{text:`Reading from the server`,tone:`text-sm text-faint`}}function yt({channel:e}){let t=G(e),n=Ke(e),i=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(he,{glyph:s(e.notifier)}),(0,J.jsx)(`span`,{className:`truncate font-mono text-xs font-semibold`,children:Ge(e)}),(0,J.jsx)(Ct,{tone:t.tone})]}),a=n===null?(0,J.jsx)(`button`,{type:`button`,className:g(gt,X),children:i}):(0,J.jsx)(r,{to:n,className:g(gt,X),children:i});return(0,J.jsxs)(y,{children:[(0,J.jsx)(_,{render:a}),(0,J.jsx)(v,{className:`flex-col items-start gap-1`,side:`bottom`,children:(0,J.jsx)(bt,{channel:e,view:t})})]})}function bt({channel:e,view:t}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.notifier,` · `,t.label,e.last_check_at!==null&&(0,J.jsxs)(`span`,{className:`font-normal opacity-70`,children:[` `,C(e.last_check_at)]})]}),e.connection!==null&&(0,J.jsx)(`span`,{className:`font-mono`,children:e.connection}),t.detail!==null&&(0,J.jsx)(`span`,{className:`opacity-70`,children:t.detail})]})}function xt({channels:e,note:t}){let[n,r]=(0,U.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>{r(!n)},className:g(`flex min-h-finger w-full items-center gap-2.5 border-b border-border px-1 text-left`,X),children:[(0,J.jsx)(o,{className:g(`size-4 shrink-0 text-muted-foreground`,n&&`rotate-90`),"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Channels`}),(0,J.jsx)(`span`,{className:`ml-auto flex items-center gap-1.5`,"aria-hidden":!0,children:e.map(e=>(0,J.jsx)(Ct,{tone:G(e).tone},e.id))})]}),n&&(t===null?(0,J.jsx)(`table`,{className:`w-full text-sm`,children:(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsx)(St,{channel:e},e.id))})}):(0,J.jsx)(`p`,{className:t.tone,children:t.text}))]})}function St({channel:e}){let t=G(e),n=Ke(e),i=(0,J.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,J.jsx)(he,{glyph:s(e.notifier)}),(0,J.jsx)(`span`,{className:`truncate font-mono text-xs font-semibold`,children:Ge(e)})]});return(0,J.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,J.jsx)(`td`,{className:`w-0 py-2 pr-2 align-middle`,children:(0,J.jsx)(Ct,{tone:t.tone})}),(0,J.jsx)(`td`,{className:`min-w-0 py-2 align-middle`,children:e.connection===null||n===null?i:(0,J.jsx)(r,{to:n,className:g(`control-link flex items-center rounded-md px-1`,X),children:i})}),(0,J.jsx)(`td`,{className:`w-0 py-2 pl-2 text-right align-middle whitespace-nowrap`,children:t.label===`not set up`&&n!==null?(0,J.jsxs)(r,{to:n,className:g(`control-link inline-flex items-center rounded-md text-xs text-primary-ink`,X),children:[`Set up `,e.notifier]}):e.last_check_at!==null&&(0,J.jsx)(`span`,{className:`text-xs text-faint`,children:C(e.last_check_at)})})]})}function Ct({tone:e}){return(0,J.jsx)(`span`,{className:`status-dot`,style:{"--chip":ht[e]}})}function Z({id:e,label:t,value:n,onChange:r,placeholder:i,mono:a,hint:o}){return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{htmlFor:e,children:t}),(0,J.jsx)(S,{id:e,className:a===!0?`font-mono`:void 0,spellCheck:!1,autoComplete:`off`,value:n,placeholder:i,onChange:e=>{r(e.target.value)}}),o!==void 0&&(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:o})]})}function wt({id:e,options:t,value:n,onChange:r}){return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{htmlFor:e,children:`Deliver through`}),(0,J.jsx)(_e,{id:e,label:`Deliver through`,value:n,options:t,placeholder:`Search by name, kind or code`,onChange:r})]})}var Tt=`0s`,Et=`alert-rule/new/body`,Q=`body`;function Dt({open:e,onOpenChange:t,notifiers:n,connections:r,onCreated:i}){let[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(``),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(`run_failed`),[h,g]=(0,U.useState)(`global`),[_,v]=(0,U.useState)(``),[y,S]=(0,U.useState)(``),[C,w]=(0,U.useState)(``),[T,E]=(0,U.useState)(``),[D,j]=(0,U.useState)(``),[M,re]=(0,U.useState)(Tt),[N,P]=(0,U.useState)(null),[F,oe]=(0,U.useState)(!1),se=Ot(e),ce=z(),L=ie(ce.why,at({code:a,scope:h,pipeline:_,throttle:M}));return(0,J.jsx)(ae,{open:e,onOpenChange:t,children:(0,J.jsxs)(ne,{className:`flex max-h-[calc(100vh-4rem)] flex-col sm:max-w-3xl`,showCloseButton:!1,children:[(0,J.jsx)(k,{children:(0,J.jsx)(ee,{children:`New rule`})}),(0,J.jsxs)(`div`,{className:`-mx-1 min-h-0 flex-1 space-y-4 overflow-y-auto px-1`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,J.jsx)(Z,{id:`rule-code`,label:`Code`,value:a,onChange:o,placeholder:`ops-slack-failed`,mono:!0}),(0,J.jsx)(Z,{id:`rule-name`,label:`Name`,value:s,onChange:c,placeholder:`Tell the ops channel`})]}),(0,J.jsx)(Z,{id:`rule-description`,label:`Description`,value:u,onChange:d,placeholder:`What this rule is for`}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Event`}),(0,J.jsx)(me,{label:`Event`,size:`md`,value:f,options:Ce.map(e=>({value:e,label:W[e]})),onChoose:p})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Scope`}),(0,J.jsx)(me,{label:`Scope`,size:`md`,value:h,options:$e,onChoose:g})]}),h===`pipeline`&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{htmlFor:`rule-pipeline`,children:`Pipeline`}),(0,J.jsx)(_e,{id:`rule-pipeline`,label:`Pipeline`,value:_,options:se,placeholder:`Search by name or code`,onChange:v})]})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Importance`}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:`Only pipelines that matter at least this much.`}),(0,J.jsx)(me,{label:`Importance`,size:`md`,value:y,options:et,onChoose:S})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:(0,J.jsx)(wt,{id:`rule-connection`,options:it(n,r),value:C,onChange:w})}),(0,J.jsx)(Z,{id:`rule-subject`,label:`Subject`,value:T,onChange:E,placeholder:`{{ run.pipeline }} run {{ run.status }}`,mono:!0,hint:Ze}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Body`}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:Qe}),(0,J.jsx)(m,{name:Q,className:`overflow-hidden rounded-md border border-border`,aside:(0,J.jsx)(ge,{mediaType:K}),windowed:(0,J.jsx)(I,{value:D,mediaType:K,path:Et,label:`${Q}, in a window`,className:`min-h-0 flex-1`,onChange:j}),children:(0,J.jsx)(I,{value:D,mediaType:K,path:Et,label:Q,placeholder:`{{ run.pipeline }} ended {{ run.status }}: {{ run.url }}`,className:`h-40 min-h-32`,onChange:j})})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:(0,J.jsx)(Z,{id:`rule-throttle`,label:`Throttle`,value:M,onChange:re,placeholder:`15m`,mono:!0})})]}),N!==null&&(0,J.jsx)(V,{problem:N}),(0,J.jsxs)(O,{children:[(0,J.jsx)(`p`,{className:`mr-auto self-center text-xs text-muted-foreground`,children:`A rule fires when a run settles. Nothing is sent now.`}),(0,J.jsx)(te,{render:(0,J.jsx)(x,{variant:`ghost`}),children:`Close`}),(0,J.jsx)(l,{why:L,children:(0,J.jsx)(x,{disabled:F||L!==void 0,title:L,onClick:()=>{oe(!0),P(null),Ne({code:a.trim(),name:q(s),description:q(u),event:f,scope:h,pipeline:h===`pipeline`?_:null,importance:tt(y),connection:nt(C),template:q(T),body:q(D),throttle:M.trim()}).then(()=>{i(),o(``),c(``),d(``),E(``),j(``),t(!1)},e=>{P(b(e))}).finally(()=>{oe(!1)})},children:F?`Creating`:`Create`})})]})]})})}function Ot(e){let[t,n]=(0,U.useState)([]);return(0,U.useEffect)(()=>{if(!e)return;let t=!0;return D().then(e=>{t&&n(e.toSorted(T).map(e=>{let t=w(e);return{value:e.code,label:t.title,aside:t.code??``}}))},()=>{t&&n([])}),()=>{t=!1}},[e]),t}var kt=1e3,At=6e4,jt=`dirigent test alert`,Mt={connection:``,subject:``};function Nt({open:e,draft:t,onOpenChange:n,notifiers:r,connections:i,onQueued:a,onOpenQueue:o}){let[s,c]=(0,U.useState)(t.connection),[u,d]=(0,U.useState)(t.subject),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(!1),v=Ft(f),y=z(),S=v!==null&&Ae(v.status)?v.id:null;(0,U.useEffect)(()=>{S!==null&&a()},[S]);let C=y.why;return(0,J.jsx)(ae,{open:e,onOpenChange:n,children:(0,J.jsxs)(ne,{className:`sm:max-w-lg`,showCloseButton:!1,children:[(0,J.jsxs)(k,{children:[(0,J.jsx)(ee,{children:`Send a test`}),(0,J.jsx)(j,{children:`The message goes through the same queue a real alert does, and a worker delivers it.`})]}),(0,J.jsx)(wt,{id:`test-connection`,options:it(r,i),value:s,onChange:c}),(0,J.jsx)(Z,{id:`test-subject`,label:`Subject`,value:u,onChange:d,placeholder:jt}),m!==null&&(0,J.jsx)(V,{problem:m}),v!==null&&(0,J.jsx)(Pt,{row:v}),(0,J.jsxs)(O,{children:[(0,J.jsx)(te,{render:(0,J.jsx)(x,{variant:`ghost`}),children:`Close`}),f!==null&&(0,J.jsx)(x,{variant:`outline`,onClick:()=>{o(f)},children:`Open in the queue`}),(0,J.jsx)(l,{why:C,children:(0,J.jsx)(x,{disabled:g||C!==void 0,title:C,onClick:()=>{_(!0),h(null),p(null),He({connection:nt(s),...u.trim()===``?{}:{subject:u.trim()}}).then(e=>{p(e.notification_id),a()},e=>{h(b(e))}).finally(()=>{_(!1)})},children:f===null?`Send`:`Send again`})})]})]})})}function Pt({row:e}){return(0,J.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border bg-secondary/40 p-3`,"data-testid":`test-delivery`,"aria-live":`polite`,children:[(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(R,{status:e.status}),(0,J.jsx)(`span`,{className:`text-sm`,children:e.subject})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.status===`sent`?(0,J.jsxs)(J.Fragment,{children:[`Delivered `,(0,J.jsx)(H,{at:e.sent_at}),`.`]}):e.status===`failed`?(0,J.jsxs)(J.Fragment,{children:[`Given up after `,e.attempt,` of `,e.max_attempts,` attempts.`]}):e.attempt===0?`Queued for the next worker pass.`:(0,J.jsxs)(J.Fragment,{children:[`Attempt `,e.attempt,` of `,e.max_attempts,`, next try`,` `,(0,J.jsx)(H,{at:e.available_at}),`.`]})}),e.error!==null&&(0,J.jsx)(`p`,{className:`text-xs break-words text-critical`,children:e.error})]})}function Ft(e){let[t,n]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(e===null)return;let t=!0,r,i=Date.now()+At,a=()=>{Be(e).then(o=>{t&&(n({id:e,row:o}),!(Ae(o.status)||Date.now()>i)&&(r=setTimeout(a,kt)))},()=>{})};return a(),()=>{t=!1,r!==void 0&&clearTimeout(r)}},[e]),t!==null&&t.id===e?t.row:null}var It=e=>e.id,Lt=e=>e.id;function Rt(){return(0,J.jsx)(ve,{children:(0,J.jsx)(zt,{})})}function zt(){let[e,t]=(0,U.useState)(!1),[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(null),[l,u]=(0,U.useState)({status:``,notifier:``}),[m,h]=(0,U.useState)({}),[g,_]=(0,U.useState)({}),v=L((0,U.useCallback)(e=>Me(e),[]),It),y=L((0,U.useCallback)(e=>ze(l,e),[l]),Lt),b=Vt(),{reload:x}=v,{reload:S}=y,C=(0,U.useMemo)(()=>v.state.rows.map(e=>m[e.id]??e),[m,v.state.rows]),w=(0,U.useMemo)(()=>y.state.rows.map(e=>g[e.id]??e),[g,y.state.rows]),T=C.find(e=>e.id===i)??null,E=w.find(e=>e.id===o)??null,D=(0,U.useCallback)(e=>{r(t=>({draft:e,opened:(t?.opened??0)+1}))},[]);(0,U.useEffect)(()=>(se({note:null,tone:`quiet`,identifier:null}),oe),[]),(0,U.useEffect)(()=>{if(T!==null){let e=T;return ce([{id:`rule`,label:`Rule`,render:()=>(0,J.jsx)(ot,{rule:e,onChanged:e=>{h(t=>({...t,[e.id]:e}))},onDeleted:()=>{a(null),x()},onTest:()=>{D({connection:e.connection??``,subject:``})}})}],{screen:`alerting`})}if(E!==null){let e=E;return ce([{id:`notification`,label:`Notification`,render:()=>(0,J.jsx)(ct,{notification:e,onChanged:e=>{_(t=>({...t,[e.id]:e}))}})}],{screen:`alerting`})}},[E,T,D,x]);let O=z(`admin`),k=O.may;return(0,U.useEffect)(()=>re([...k?[{id:`alerting:rule`,title:`New alert rule`,group:F,screen:!0,icon:be,keywords:[`alert`,`event`,`create`],run:()=>{t(!0)}},{id:`alerting:test`,title:`Send a test through a channel`,group:F,screen:!0,icon:Se,keywords:[`alert`,`notification`,`try`],run:()=>{D(Mt)}}]:[],{id:`alerting:reload`,title:`Read the alert rules again`,group:F,screen:!0,icon:M,keywords:[`refresh`,`reload`],run:()=>{x(),S()}}]),[k,D,S,x]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(d,{title:`Alerting`,aside:(0,J.jsx)(f,{tag:`alerts`}),actions:[{id:`test`,label:`Send a test`,icon:Se,variant:`outline`,disabled:!O.may,why:O.why,onClick:()=>{D(Mt)}},{id:`rule`,label:`New rule`,icon:be,disabled:!O.may,why:O.why,onClick:()=>{t(!0)}}]}),(0,J.jsx)(`section`,{className:`mb-6 space-y-2`,children:(0,J.jsx)(_t,{channels:b.rows,read:b.read})}),(0,J.jsxs)(`section`,{className:`space-y-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Rules`}),(0,J.jsx)(c,{loading:!v.state.read,problem:v.state.problem,empty:C.length===0,emptyMessage:`No rules.`,children:(0,J.jsx)(p,{columns:Ut,rows:C,rowKey:It,rowClassName:e=>ke(e)?void 0:`opacity-60`,reading:v.state.reading,next:v.state.next,onMore:v.more,noun:`rules`,onSelect:e=>{s(null),a(e.id),N()},selected:e=>e.id===i})})]}),(0,J.jsxs)(`section`,{className:`mt-8 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Notifications`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(P,{label:`Status`,value:l.status,anything:`Any status`,options:we.map(e=>({value:e,label:e,mark:(0,J.jsx)(R,{status:e})})),onChange:e=>{u(t=>({...t,status:e}))}}),(0,J.jsx)(P,{label:`Notifier`,value:l.notifier,anything:`Any notifier`,options:Bt(b.rows),onChange:e=>{u(t=>({...t,notifier:e}))}})]})]}),(0,J.jsx)(c,{loading:!y.state.read,problem:y.state.problem,empty:w.length===0,emptyMessage:`Nothing queued.`,children:(0,J.jsx)(p,{columns:Wt,rows:w,rowKey:Lt,reading:y.state.reading,next:y.state.next,onMore:y.more,noun:`notifications`,onSelect:e=>{a(null),s(e.id),N()},selected:e=>e.id===o})})]}),(0,J.jsx)(Dt,{open:e,onOpenChange:t,notifiers:$(b.rows),connections:b.connections,onCreated:x}),(0,J.jsx)(Nt,{open:n!==null,draft:n?.draft??Mt,onOpenChange:e=>{e||r(null)},notifiers:$(b.rows),connections:b.connections,onQueued:S,onOpenQueue:e=>{r(null),a(null),s(e),S(),N()}},n?.opened??0)]})}function $(e){return[...new Set(e.map(e=>e.notifier))]}function Bt(e){return $(e).map(e=>({value:e,label:e}))}function Vt(){let[e,t]=(0,U.useState)(null),[n,r]=(0,U.useState)(null);return(0,U.useEffect)(()=>{let e=!0;return Ue().then(n=>{e&&t(n)},()=>{e&&t([])}),de().then(t=>{e&&r(t.items)},()=>{e&&r([])}),()=>{e=!1}},[]),{rows:(0,U.useMemo)(()=>We(e??[],n??[]),[n,e]),connections:n??[],read:e!==null&&n!==null}}function Ht({rule:e}){let t=Oe(e.importance);return(0,J.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,J.jsx)(`span`,{className:e.scope===`pipeline`?`font-mono text-xs`:`text-sm`,children:De(e)}),t!==null&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})}var Ut=[{id:`rule`,header:`Rule`,kind:`title`,cell:e=>{let t=w(e);return(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,J.jsx)(`span`,{className:g(`truncate`,t.named?`text-sm font-medium`:`font-mono text-sm font-medium`),title:t.title,children:t.title}),t.code!==null&&(0,J.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,title:t.code,children:t.code})]})}},{id:`event`,header:`Event`,cell:e=>(0,J.jsx)(`span`,{className:`text-sm`,children:W[e.event]})},{id:`scope`,header:`Scope`,cell:e=>(0,J.jsx)(Ht,{rule:e})},{id:`delivers`,header:`Delivers through`,cell:e=>(0,J.jsx)(ut,{notifier:e.notifier,connection:e.connection})},{id:`throttle`,header:`Throttle`,className:`font-mono text-xs`,cell:e=>(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:Ee(e.throttle)})},{id:`sent`,header:`Last sent`,className:`text-xs`,cell:e=>e.last_sent_at===null?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`never`}):(0,J.jsx)(H,{className:`text-muted-foreground`,at:e.last_sent_at})},{id:`live`,header:`State`,cell:e=>e.paused?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`paused`}):e.active?(0,J.jsx)(`span`,{className:`text-xs text-good`,children:`active`}):(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`off`})}],Wt=[{id:`status`,header:`Status`,cell:e=>(0,J.jsx)(R,{status:e.status})},{id:`subject`,header:`Subject`,kind:`prose`,cell:e=>(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm`,title:e.subject,children:e.subject}),e.error!==null&&(0,J.jsx)(`span`,{className:`truncate text-xs text-critical`,title:e.error,children:e.error})]})},{id:`delivers`,header:`Delivers through`,cell:e=>(0,J.jsx)(dt,{notifier:e.notifier,connection:e.connection})},{id:`run`,header:`Run`,cell:e=>(0,J.jsx)(ft,{notification:e})},{id:`queued`,header:`Queued`,className:`text-xs`,cell:e=>(0,J.jsx)(H,{className:`text-muted-foreground`,at:e.created_at})},{id:`sent`,header:`Sent`,className:`text-xs`,cell:e=>e.status===`sent`?(0,J.jsx)(H,{className:`text-muted-foreground`,at:e.sent_at}):e.attempt>0?(0,J.jsxs)(`span`,{className:`text-faint`,children:[e.attempt,` of `,e.max_attempts,` attempts`]}):null}];export{Rt as AdminAlerting};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{r as n}from"./with-selector-BXYKoaOE.js";import{n as r}from"./chunk-OB3PAWPO-DOp4K52_.js";import{i,r as a}from"./api-Bm1JZLuC.js";import{N as o}from"./dropdown-menu-B-6CcHKw.js";import{r as s}from"./glyphs-C1sjljkh.js";import{n as c,o as l,s as u,t as d}from"./PageState-BLuobMye.js";import{i as f,t as p}from"./ListTable-D-mI8v9Y.js";import{t as m}from"./WindowedPane-Dc5ox2RS.js";import{r as h,t as g}from"./utils-CT7ZGLfR.js";import{i as _,n as v,t as y}from"./tooltip-D7_KwbOU.js";import{d as b,f as x}from"./paging-CpRIkEky.js";import{t as S}from"./input-1fShkFXn.js";import{l as C}from"./format-B5YbYOY-.js";import{t as w}from"./identity-BNZxCf_y.js";import{r as T,t as E,u as D}from"./pipelines-Pi3WL8R6.js";import{Ft as O,It as k,Lt as ee,Mt as te,Nt as ne,O as A,Pt as j,Rt as M,_t as re,b as ie,dt as N,g as P,jt as ae,mt as F,nt as oe,rt as se,st as I,ut as ce,v as L,w as R,y as z}from"./index-CzO6Janm.js";import{t as le}from"./Description-MmXUnb-9.js";import{c as ue,f as de,n as fe,o as pe}from"./connections-Cp5WCruj.js";import{n as B,t as V}from"./Refusal-DickLwkO.js";import{t as H}from"./Instant-mr1E5jAK.js";import{t as me}from"./Segmented-KaDiGiyr.js";import{t as he}from"./Mark-DQR2php6.js";import{t as ge}from"./ProgramReference-DF37mMAT.js";import{t as _e}from"./Picker-BzRYpj3s.js";import{t as ve}from"./AdminOnly-CWzFAkRQ.js";var ye={name:`bell-plus`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M15 8h6`,key:`8ybuxh`}],[`path`,{d:`M18 5v6`,key:`g5ayrv`}],[`path`,{d:`M20.002 14.464a9 9 0 0 0 .738.863A1 1 0 0 1 20 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 8.75-5.332`,key:`1abcvy`}]]};ye.node;var be=n(ye),xe={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};xe.node;var Se=n(xe),U=e(t(),1),Ce=[`run_failed`,`run_completed_with_errors`,`run_succeeded`,`run_stuck`],W={run_failed:`Failed`,run_completed_with_errors:`Completed with errors`,run_succeeded:`Succeeded`,run_stuck:`Stuck`},we=[`pending`,`sending`,`sent`,`failed`],Te=`0s`;function Ee(e){return e===Te?`none`:e}function De(e){return e.scope===`pipeline`&&e.pipeline!==null?e.pipeline:`every pipeline`}function Oe(e){return e===null?null:`${e} and above`}function ke(e){return e.active&&!e.paused}function Ae(e){return e===`sent`||e===`failed`}function je(e,t=50){let n=new URLSearchParams({limit:String(t)});return e!==null&&n.set(`after`,e),`/alert-rules?${n.toString()}`}function Me(e){return a(je(e))}function Ne(e){return i(`/alert-rules`,`POST`,e)}function Pe(e,t){return i(`/alert-rules/${encodeURIComponent(e)}`,`PATCH`,t)}function Fe(e,t){return Pe(e,{paused:t})}function Ie(e){return a(`/alert-rules/${encodeURIComponent(e)}`,{method:`DELETE`})}var Le={status:``,notifier:``};function Re(e,t,n=50){let r=new URLSearchParams({limit:String(n)});return e.status!==``&&r.set(`status`,e.status),e.notifier!==``&&r.set(`notifier`,e.notifier),t!==null&&r.set(`after`,t),`/notifications?${r.toString()}`}function ze(e,t){return a(Re(e,t))}function Be(e){return a(`/notifications/${encodeURIComponent(e)}`)}function Ve(e){return i(`/notifications/${encodeURIComponent(e)}/$retry`,`POST`,{})}function He(e){return i(`/alert-rules/$test`,`POST`,e)}async function Ue(){return(await a(`/blocks`)).notifiers.map(e=>e.id)}function We(e,t){let n=[];for(let r of e){if(r===`log`){n.push({id:r,notifier:r,connection:null,reachable:!0,last_check_at:null,last_check_healthy:null,last_check_detail:null});continue}let e=t.filter(e=>e.kind===r);if(e.length===0){n.push({id:r,notifier:r,connection:null,reachable:!1,last_check_at:null,last_check_healthy:null,last_check_detail:null});continue}for(let t of e)n.push({id:`${r}:${t.code}`,notifier:r,connection:t.code,reachable:!0,last_check_at:t.last_check_at,last_check_healthy:t.last_check_healthy,last_check_detail:t.last_check_detail})}return Je(n)}function Ge(e){return e.connection??e.notifier}function Ke(e){return e.connection===null?e.notifier===`log`?null:ue(e.notifier):fe(e.connection)}function G(e){if(e.notifier===`log`)return{tone:`good`,label:`ready`,detail:null};if(!e.reachable)return{tone:`quiet`,label:`not set up`,detail:null};let t=pe(e);return{tone:t.tone??`quiet`,label:t.label,detail:t.detail}}var qe={good:0,critical:1,quiet:2};function Je(e){return e.toSorted((e,t)=>{let n=qe[G(e).tone]-qe[G(t).tone];if(n!==0)return n;let r=e.notifier.localeCompare(t.notifier);return r===0?(e.connection??``).localeCompare(t.connection??``):r})}var Ye=/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/u,Xe=/^(?:\d+(?:ms|s|m|h|d|w))+$/u,Ze=`A Jinja template: {{ run.* }} reads the run's pipeline, status, id, error, trigger, duration_ms and url.`,Qe=`A Jinja template over the run's facts; report is the run's report document when it has one.`,K=`text/x-jinja`;function q(e){let t=e.trim();return t===``?null:t}var $e=[{value:`global`,label:`Every pipeline`},{value:`pipeline`,label:`One pipeline`}],et=[{value:``,label:`Any`},...E.map(e=>({value:e,label:e[0].toUpperCase()+e.slice(1)}))];function tt(e){return e===``?null:e}function nt(e){return e===``?null:e}var rt=`The process log`;function it(e,t){let n=t.filter(t=>t.kind!==`log`&&e.includes(t.kind)).map(e=>({row:e,heading:w(e)})).toSorted((e,t)=>e.row.kind.localeCompare(t.row.kind)||e.heading.title.localeCompare(t.heading.title));return[{value:``,label:rt,aside:``,mark:s(`log`)},...n.map(({row:e,heading:t})=>({value:e.code,label:`${t.title} · ${e.kind}`,aside:t.code??``,mark:s(e.kind)}))]}function at(e){if(e.code.trim()===``)return`A rule is addressed by its code, and this one has none.`;if(!Ye.test(e.code.trim()))return`A code is lowercase words joined by - or _.`;if(e.scope===`pipeline`&&e.pipeline===``)return`A rule watching one pipeline names that pipeline, and this one names none.`;if(!Xe.test(e.throttle.trim()))return`A throttle is a duration, such as 15m.`}var J=h();function ot({rule:e,onChanged:t,onDeleted:n,onTest:r}){let[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(null),c=o===e.code,u=z(),d=Oe(e.importance),f=(0,U.useCallback)(e=>ze(Le,e),[]),{state:p}=L(f,lt),m=p.rows.filter(t=>t.rule===e.code);return(0,J.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,J.jsxs)(mt,{thing:e,children:[e.paused&&(0,J.jsx)(pt,{children:`paused`}),!e.active&&(0,J.jsx)(pt,{children:`off`})]}),(0,J.jsx)(le,{text:e.description}),(0,J.jsxs)(`dl`,{className:`space-y-1.5`,children:[(0,J.jsx)(Y,{label:`Event`,children:W[e.event]}),(0,J.jsx)(Y,{label:`Scope`,children:(0,J.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[De(e),d!==null&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d})]})}),(0,J.jsx)(Y,{label:`Delivers through`,children:(0,J.jsx)(ut,{notifier:e.notifier,connection:e.connection})}),(0,J.jsx)(Y,{label:`Throttle`,children:Ee(e.throttle)}),c?(0,J.jsx)(st,{rule:e,onDone:()=>{s(null)},onSaved:e=>{t(e),s(null)}},e.code):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{label:`Subject`,children:(0,J.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-2`,children:[e.template===null?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`none`}):(0,J.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.template}),(0,J.jsx)(l,{why:u.why,children:(0,J.jsx)(x,{variant:`ghost`,size:`xs`,disabled:!u.may,title:u.why,onClick:()=>{s(e.code)},children:`Edit`})})]})}),e.body!==null&&(0,J.jsx)(Y,{label:`Body`,children:(0,J.jsx)(`span`,{className:`line-clamp-3 font-mono text-xs break-words whitespace-pre-wrap`,children:e.body})})]}),(0,J.jsx)(Y,{label:`Last sent`,children:e.last_sent_at===null?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`never`}):(0,J.jsx)(H,{at:e.last_sent_at})})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(l,{why:u.why,children:(0,J.jsx)(x,{variant:`outline`,size:`sm`,disabled:i||!u.may,title:u.why,onClick:()=>{a(!0),Fe(e.code,!e.paused).then(t,B).finally(()=>{a(!1)})},children:e.paused?`Resume`:`Pause`})}),(0,J.jsx)(l,{why:u.why,children:(0,J.jsx)(x,{variant:`outline`,size:`sm`,disabled:!u.may,title:u.why,onClick:r,children:`Send a test`})}),(0,J.jsx)(l,{why:u.why,children:(0,J.jsx)(x,{variant:`outline`,size:`sm`,className:`destructive-action ml-auto`,disabled:i||!u.may,title:u.why,onClick:()=>{a(!0),Ie(e.code).then(n,B).finally(()=>{a(!1)})},children:`Delete`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Recent deliveries`}),!p.read&&(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:`Reading from the server`}),p.read&&m.length===0&&(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:`Nothing sent.`}),(0,J.jsx)(`ul`,{className:`divide-y divide-border`,children:m.map(e=>(0,J.jsxs)(`li`,{className:`row-hover -mx-4 flex items-center gap-2 px-4 py-2`,children:[(0,J.jsx)(R,{status:e.status}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:e.subject}),(0,J.jsx)(H,{className:`shrink-0 text-xs text-faint`,at:e.created_at})]},e.id))})]})]})}function st({rule:e,onDone:t,onSaved:n}){let[r,i]=(0,U.useState)(e.template??``),[a,o]=(0,U.useState)(e.body??``),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1),d=`alert-rule/${e.code}/body`,f=`rule-${e.code}-subject`;return(0,J.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-border bg-secondary/30 p-3`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{htmlFor:f,children:`Subject`}),(0,J.jsx)(S,{id:f,className:`font-mono`,spellCheck:!1,autoComplete:`off`,value:r,placeholder:`{{ run.pipeline }} run {{ run.status }}`,onChange:e=>{i(e.target.value)}}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:Ze})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Body`}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:Qe}),(0,J.jsx)(m,{name:`body`,className:`overflow-hidden rounded-md border border-border bg-background`,aside:(0,J.jsx)(ge,{mediaType:K}),windowed:(0,J.jsx)(I,{value:a,mediaType:K,path:d,label:`body, in a window`,className:`min-h-0 flex-1`,onChange:o}),children:(0,J.jsx)(I,{value:a,mediaType:K,path:d,label:`body`,placeholder:`{{ run.pipeline }} ended {{ run.status }}: {{ run.url }}`,className:`h-40 min-h-32`,onChange:o})})]}),s!==null&&(0,J.jsx)(V,{problem:s}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(x,{variant:`ghost`,size:`sm`,onClick:t,children:`Cancel`}),(0,J.jsx)(x,{size:`sm`,disabled:l,onClick:()=>{let i={};if(q(r)!==e.template&&(i.template=q(r)),q(a)!==e.body&&(i.body=q(a)),Object.keys(i).length===0){t();return}u(!0),c(null),Pe(e.code,i).then(n,e=>{c(b(e))}).finally(()=>{u(!1)})},children:l?`Saving`:`Save`})]})]})}function ct({notification:e,onChanged:t}){let[n,i]=(0,U.useState)(!1),a=z();return(0,J.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,J.jsx)(`div`,{className:`space-y-1`,children:(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(R,{status:e.status}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:e.subject})]})}),(0,J.jsxs)(`dl`,{className:`space-y-1.5`,children:[e.rule===null?(0,J.jsx)(Y,{label:`Raised by`,children:(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`a test, not a rule`})}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{label:`Event`,children:W[e.event]}),(0,J.jsx)(Y,{label:`Rule`,children:(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:e.rule})})]}),(0,J.jsx)(Y,{label:`Delivers through`,children:(0,J.jsx)(dt,{notifier:e.notifier,connection:e.connection})}),(0,J.jsx)(Y,{label:`Run`,children:(0,J.jsx)(ft,{notification:e})}),(0,J.jsx)(Y,{label:`Queued`,children:(0,J.jsx)(H,{at:e.created_at})}),e.status===`sent`?(0,J.jsx)(Y,{label:`Sent`,children:(0,J.jsx)(H,{at:e.sent_at})}):(0,J.jsx)(Y,{label:`Next try`,children:(0,J.jsx)(H,{at:e.available_at})}),(0,J.jsxs)(Y,{label:`Attempts`,children:[e.attempt,` of `,e.max_attempts]})]}),e.error!==null&&(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`What the channel said`}),(0,J.jsx)(`p`,{className:`text-xs break-words text-critical`,children:e.error}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:`Only the latest refusal is kept. Earlier attempts are counted, not stored.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(l,{why:a.why,children:(0,J.jsx)(x,{variant:`outline`,size:`sm`,disabled:n||!a.may,title:a.why,onClick:()=>{i(!0),Ve(e.id).then(t,B).finally(()=>{i(!1)})},children:`Retry now`})}),e.run_id!==null&&(0,J.jsx)(x,{variant:`outline`,size:`sm`,render:(0,J.jsx)(r,{to:`/runs/${e.run_id}`}),children:`Open the run`})]})]})}var lt=e=>e.id;function ut({notifier:e,connection:t}){return(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(he,{glyph:s(e)}),(0,J.jsx)(`span`,{className:t===null?`text-sm`:`font-mono text-xs`,children:t??e})]})}function dt({notifier:e,connection:t}){return(0,J.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-sm`,children:e}),t!==null&&(0,J.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:t})]})}function ft({notification:e}){if(e.run_id===null)return(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`no run`});let t=e.run_pipeline??`a run`;return(0,J.jsxs)(r,{className:`text-primary hover:underline`,to:`/runs/${e.run_id}`,children:[(0,J.jsx)(`span`,{className:`text-sm`,children:t}),e.run_started_at!==null&&(0,J.jsx)(H,{className:`ml-1.5 text-xs text-muted-foreground`,at:e.run_started_at})]})}function pt({children:e}){return(0,J.jsx)(`span`,{className:`rounded-sm border border-border px-1.5 text-xs text-muted-foreground`,children:e})}function mt({thing:e,children:t}){let n=w(e);return(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:n.named?`text-sm font-semibold`:`font-mono text-sm font-semibold`,children:n.title}),t,n.code!==null&&(0,J.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:n.code})]})}function Y({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,J.jsx)(`dt`,{className:`w-32 shrink-0 text-xs text-muted-foreground`,children:e}),(0,J.jsx)(`dd`,{className:`min-w-0 text-sm`,children:t})]})}var ht={good:`var(--good)`,critical:`var(--critical)`,quiet:`var(--faint)`},gt=`flex min-h-9 items-center gap-2 rounded-full border border-border bg-card py-1 pr-3 pl-2.5 transition-colors`,X=`hover:bg-muted focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`;function _t({channels:e,read:t}){let n=u(),r=vt(e.length,t);return n?(0,J.jsx)(xt,{channels:e,note:r}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Channels`}),r===null?(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,J.jsx)(`li`,{className:`flex`,children:(0,J.jsx)(yt,{channel:e})},e.id))}):(0,J.jsx)(`p`,{className:r.tone,children:r.text})]})}function vt(e,t){return t?e===0?{text:`No channel is installed.`,tone:`text-sm text-muted-foreground`}:null:{text:`Reading from the server`,tone:`text-sm text-faint`}}function yt({channel:e}){let t=G(e),n=Ke(e),i=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(he,{glyph:s(e.notifier)}),(0,J.jsx)(`span`,{className:`truncate font-mono text-xs font-semibold`,children:Ge(e)}),(0,J.jsx)(Ct,{tone:t.tone})]}),a=n===null?(0,J.jsx)(`button`,{type:`button`,className:g(gt,X),children:i}):(0,J.jsx)(r,{to:n,className:g(gt,X),children:i});return(0,J.jsxs)(y,{children:[(0,J.jsx)(_,{render:a}),(0,J.jsx)(v,{className:`flex-col items-start gap-1`,side:`bottom`,children:(0,J.jsx)(bt,{channel:e,view:t})})]})}function bt({channel:e,view:t}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.notifier,` · `,t.label,e.last_check_at!==null&&(0,J.jsxs)(`span`,{className:`font-normal opacity-70`,children:[` `,C(e.last_check_at)]})]}),e.connection!==null&&(0,J.jsx)(`span`,{className:`font-mono`,children:e.connection}),t.detail!==null&&(0,J.jsx)(`span`,{className:`opacity-70`,children:t.detail})]})}function xt({channels:e,note:t}){let[n,r]=(0,U.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>{r(!n)},className:g(`flex min-h-finger w-full items-center gap-2.5 border-b border-border px-1 text-left`,X),children:[(0,J.jsx)(o,{className:g(`size-4 shrink-0 text-muted-foreground`,n&&`rotate-90`),"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Channels`}),(0,J.jsx)(`span`,{className:`ml-auto flex items-center gap-1.5`,"aria-hidden":!0,children:e.map(e=>(0,J.jsx)(Ct,{tone:G(e).tone},e.id))})]}),n&&(t===null?(0,J.jsx)(`table`,{className:`w-full text-sm`,children:(0,J.jsx)(`tbody`,{children:e.map(e=>(0,J.jsx)(St,{channel:e},e.id))})}):(0,J.jsx)(`p`,{className:t.tone,children:t.text}))]})}function St({channel:e}){let t=G(e),n=Ke(e),i=(0,J.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,J.jsx)(he,{glyph:s(e.notifier)}),(0,J.jsx)(`span`,{className:`truncate font-mono text-xs font-semibold`,children:Ge(e)})]});return(0,J.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,J.jsx)(`td`,{className:`w-0 py-2 pr-2 align-middle`,children:(0,J.jsx)(Ct,{tone:t.tone})}),(0,J.jsx)(`td`,{className:`min-w-0 py-2 align-middle`,children:e.connection===null||n===null?i:(0,J.jsx)(r,{to:n,className:g(`control-link flex items-center rounded-md px-1`,X),children:i})}),(0,J.jsx)(`td`,{className:`w-0 py-2 pl-2 text-right align-middle whitespace-nowrap`,children:t.label===`not set up`&&n!==null?(0,J.jsxs)(r,{to:n,className:g(`control-link inline-flex items-center rounded-md text-xs text-primary-ink`,X),children:[`Set up `,e.notifier]}):e.last_check_at!==null&&(0,J.jsx)(`span`,{className:`text-xs text-faint`,children:C(e.last_check_at)})})]})}function Ct({tone:e}){return(0,J.jsx)(`span`,{className:`status-dot`,style:{"--chip":ht[e]}})}function Z({id:e,label:t,value:n,onChange:r,placeholder:i,mono:a,hint:o}){return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{htmlFor:e,children:t}),(0,J.jsx)(S,{id:e,className:a===!0?`font-mono`:void 0,spellCheck:!1,autoComplete:`off`,value:n,placeholder:i,onChange:e=>{r(e.target.value)}}),o!==void 0&&(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:o})]})}function wt({id:e,options:t,value:n,onChange:r}){return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{htmlFor:e,children:`Deliver through`}),(0,J.jsx)(_e,{id:e,label:`Deliver through`,value:n,options:t,placeholder:`Search by name, kind or code`,onChange:r})]})}var Tt=`0s`,Et=`alert-rule/new/body`,Q=`body`;function Dt({open:e,onOpenChange:t,notifiers:n,connections:r,onCreated:i}){let[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(``),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(`run_failed`),[h,g]=(0,U.useState)(`global`),[_,v]=(0,U.useState)(``),[y,S]=(0,U.useState)(``),[C,w]=(0,U.useState)(``),[T,E]=(0,U.useState)(``),[D,j]=(0,U.useState)(``),[M,re]=(0,U.useState)(Tt),[N,P]=(0,U.useState)(null),[F,oe]=(0,U.useState)(!1),se=Ot(e),ce=z(),L=ie(ce.why,at({code:a,scope:h,pipeline:_,throttle:M}));return(0,J.jsx)(ae,{open:e,onOpenChange:t,children:(0,J.jsxs)(ne,{className:`flex max-h-[calc(100vh-4rem)] flex-col sm:max-w-3xl`,showCloseButton:!1,children:[(0,J.jsx)(k,{children:(0,J.jsx)(ee,{children:`New rule`})}),(0,J.jsxs)(`div`,{className:`-mx-1 min-h-0 flex-1 space-y-4 overflow-y-auto px-1`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,J.jsx)(Z,{id:`rule-code`,label:`Code`,value:a,onChange:o,placeholder:`ops-slack-failed`,mono:!0}),(0,J.jsx)(Z,{id:`rule-name`,label:`Name`,value:s,onChange:c,placeholder:`Tell the ops channel`})]}),(0,J.jsx)(Z,{id:`rule-description`,label:`Description`,value:u,onChange:d,placeholder:`What this rule is for`}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Event`}),(0,J.jsx)(me,{label:`Event`,size:`md`,value:f,options:Ce.map(e=>({value:e,label:W[e]})),onChoose:p})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Scope`}),(0,J.jsx)(me,{label:`Scope`,size:`md`,value:h,options:$e,onChoose:g})]}),h===`pipeline`&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{htmlFor:`rule-pipeline`,children:`Pipeline`}),(0,J.jsx)(_e,{id:`rule-pipeline`,label:`Pipeline`,value:_,options:se,placeholder:`Search by name or code`,onChange:v})]})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Importance`}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:`Only pipelines that matter at least this much.`}),(0,J.jsx)(me,{label:`Importance`,size:`md`,value:y,options:et,onChoose:S})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:(0,J.jsx)(wt,{id:`rule-connection`,options:it(n,r),value:C,onChange:w})}),(0,J.jsx)(Z,{id:`rule-subject`,label:`Subject`,value:T,onChange:E,placeholder:`{{ run.pipeline }} run {{ run.status }}`,mono:!0,hint:Ze}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(A,{children:`Body`}),(0,J.jsx)(`p`,{className:`text-xs text-faint`,children:Qe}),(0,J.jsx)(m,{name:Q,className:`overflow-hidden rounded-md border border-border`,aside:(0,J.jsx)(ge,{mediaType:K}),windowed:(0,J.jsx)(I,{value:D,mediaType:K,path:Et,label:`${Q}, in a window`,className:`min-h-0 flex-1`,onChange:j}),children:(0,J.jsx)(I,{value:D,mediaType:K,path:Et,label:Q,placeholder:`{{ run.pipeline }} ended {{ run.status }}: {{ run.url }}`,className:`h-40 min-h-32`,onChange:j})})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:(0,J.jsx)(Z,{id:`rule-throttle`,label:`Throttle`,value:M,onChange:re,placeholder:`15m`,mono:!0})})]}),N!==null&&(0,J.jsx)(V,{problem:N}),(0,J.jsxs)(O,{children:[(0,J.jsx)(`p`,{className:`mr-auto self-center text-xs text-muted-foreground`,children:`A rule fires when a run settles. Nothing is sent now.`}),(0,J.jsx)(te,{render:(0,J.jsx)(x,{variant:`ghost`}),children:`Close`}),(0,J.jsx)(l,{why:L,children:(0,J.jsx)(x,{disabled:F||L!==void 0,title:L,onClick:()=>{oe(!0),P(null),Ne({code:a.trim(),name:q(s),description:q(u),event:f,scope:h,pipeline:h===`pipeline`?_:null,importance:tt(y),connection:nt(C),template:q(T),body:q(D),throttle:M.trim()}).then(()=>{i(),o(``),c(``),d(``),E(``),j(``),t(!1)},e=>{P(b(e))}).finally(()=>{oe(!1)})},children:F?`Creating`:`Create`})})]})]})})}function Ot(e){let[t,n]=(0,U.useState)([]);return(0,U.useEffect)(()=>{if(!e)return;let t=!0;return D().then(e=>{t&&n(e.toSorted(T).map(e=>{let t=w(e);return{value:e.code,label:t.title,aside:t.code??``}}))},()=>{t&&n([])}),()=>{t=!1}},[e]),t}var kt=1e3,At=6e4,jt=`dirigent test alert`,Mt={connection:``,subject:``};function Nt({open:e,draft:t,onOpenChange:n,notifiers:r,connections:i,onQueued:a,onOpenQueue:o}){let[s,c]=(0,U.useState)(t.connection),[u,d]=(0,U.useState)(t.subject),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(!1),v=Ft(f),y=z(),S=v!==null&&Ae(v.status)?v.id:null;(0,U.useEffect)(()=>{S!==null&&a()},[S]);let C=y.why;return(0,J.jsx)(ae,{open:e,onOpenChange:n,children:(0,J.jsxs)(ne,{className:`sm:max-w-lg`,showCloseButton:!1,children:[(0,J.jsxs)(k,{children:[(0,J.jsx)(ee,{children:`Send a test`}),(0,J.jsx)(j,{children:`The message goes through the same queue a real alert does, and a worker delivers it.`})]}),(0,J.jsx)(wt,{id:`test-connection`,options:it(r,i),value:s,onChange:c}),(0,J.jsx)(Z,{id:`test-subject`,label:`Subject`,value:u,onChange:d,placeholder:jt}),m!==null&&(0,J.jsx)(V,{problem:m}),v!==null&&(0,J.jsx)(Pt,{row:v}),(0,J.jsxs)(O,{children:[(0,J.jsx)(te,{render:(0,J.jsx)(x,{variant:`ghost`}),children:`Close`}),f!==null&&(0,J.jsx)(x,{variant:`outline`,onClick:()=>{o(f)},children:`Open in the queue`}),(0,J.jsx)(l,{why:C,children:(0,J.jsx)(x,{disabled:g||C!==void 0,title:C,onClick:()=>{_(!0),h(null),p(null),He({connection:nt(s),...u.trim()===``?{}:{subject:u.trim()}}).then(e=>{p(e.notification_id),a()},e=>{h(b(e))}).finally(()=>{_(!1)})},children:f===null?`Send`:`Send again`})})]})]})})}function Pt({row:e}){return(0,J.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border bg-secondary/40 p-3`,"data-testid":`test-delivery`,"aria-live":`polite`,children:[(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(R,{status:e.status}),(0,J.jsx)(`span`,{className:`text-sm`,children:e.subject})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.status===`sent`?(0,J.jsxs)(J.Fragment,{children:[`Delivered `,(0,J.jsx)(H,{at:e.sent_at}),`.`]}):e.status===`failed`?(0,J.jsxs)(J.Fragment,{children:[`Given up after `,e.attempt,` of `,e.max_attempts,` attempts.`]}):e.attempt===0?`Queued for the next worker pass.`:(0,J.jsxs)(J.Fragment,{children:[`Attempt `,e.attempt,` of `,e.max_attempts,`, next try`,` `,(0,J.jsx)(H,{at:e.available_at}),`.`]})}),e.error!==null&&(0,J.jsx)(`p`,{className:`text-xs break-words text-critical`,children:e.error})]})}function Ft(e){let[t,n]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(e===null)return;let t=!0,r,i=Date.now()+At,a=()=>{Be(e).then(o=>{t&&(n({id:e,row:o}),!(Ae(o.status)||Date.now()>i)&&(r=setTimeout(a,kt)))},()=>{})};return a(),()=>{t=!1,r!==void 0&&clearTimeout(r)}},[e]),t!==null&&t.id===e?t.row:null}var It=e=>e.id,Lt=e=>e.id;function Rt(){return(0,J.jsx)(ve,{children:(0,J.jsx)(zt,{})})}function zt(){let[e,t]=(0,U.useState)(!1),[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(null),[l,u]=(0,U.useState)({status:``,notifier:``}),[m,h]=(0,U.useState)({}),[g,_]=(0,U.useState)({}),v=L((0,U.useCallback)(e=>Me(e),[]),It),y=L((0,U.useCallback)(e=>ze(l,e),[l]),Lt),b=Vt(),{reload:x}=v,{reload:S}=y,C=(0,U.useMemo)(()=>v.state.rows.map(e=>m[e.id]??e),[m,v.state.rows]),w=(0,U.useMemo)(()=>y.state.rows.map(e=>g[e.id]??e),[g,y.state.rows]),T=C.find(e=>e.id===i)??null,E=w.find(e=>e.id===o)??null,D=(0,U.useCallback)(e=>{r(t=>({draft:e,opened:(t?.opened??0)+1}))},[]);(0,U.useEffect)(()=>(se({note:null,tone:`quiet`,identifier:null}),oe),[]),(0,U.useEffect)(()=>{if(T!==null){let e=T;return ce([{id:`rule`,label:`Rule`,render:()=>(0,J.jsx)(ot,{rule:e,onChanged:e=>{h(t=>({...t,[e.id]:e}))},onDeleted:()=>{a(null),x()},onTest:()=>{D({connection:e.connection??``,subject:``})}})}],{screen:`alerting`})}if(E!==null){let e=E;return ce([{id:`notification`,label:`Notification`,render:()=>(0,J.jsx)(ct,{notification:e,onChanged:e=>{_(t=>({...t,[e.id]:e}))}})}],{screen:`alerting`})}},[E,T,D,x]);let O=z(`admin`),k=O.may;return(0,U.useEffect)(()=>re([...k?[{id:`alerting:rule`,title:`New alert rule`,group:F,screen:!0,icon:be,keywords:[`alert`,`event`,`create`],run:()=>{t(!0)}},{id:`alerting:test`,title:`Send a test through a channel`,group:F,screen:!0,icon:Se,keywords:[`alert`,`notification`,`try`],run:()=>{D(Mt)}}]:[],{id:`alerting:reload`,title:`Read the alert rules again`,group:F,screen:!0,icon:M,keywords:[`refresh`,`reload`],run:()=>{x(),S()}}]),[k,D,S,x]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(d,{title:`Alerting`,aside:(0,J.jsx)(f,{tag:`alerts`}),actions:[{id:`test`,label:`Send a test`,icon:Se,variant:`outline`,disabled:!O.may,why:O.why,onClick:()=>{D(Mt)}},{id:`rule`,label:`New rule`,icon:be,disabled:!O.may,why:O.why,onClick:()=>{t(!0)}}]}),(0,J.jsx)(`section`,{className:`mb-6 space-y-2`,children:(0,J.jsx)(_t,{channels:b.rows,read:b.read})}),(0,J.jsxs)(`section`,{className:`space-y-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Rules`}),(0,J.jsx)(c,{loading:!v.state.read,problem:v.state.problem,empty:C.length===0,emptyMessage:`No rules.`,children:(0,J.jsx)(p,{columns:Ut,rows:C,rowKey:It,rowClassName:e=>ke(e)?void 0:`opacity-60`,reading:v.state.reading,next:v.state.next,onMore:v.more,noun:`rules`,onSelect:e=>{s(null),a(e.id),N()},selected:e=>e.id===i})})]}),(0,J.jsxs)(`section`,{className:`mt-8 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Notifications`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(P,{label:`Status`,value:l.status,anything:`Any status`,options:we.map(e=>({value:e,label:e,mark:(0,J.jsx)(R,{status:e})})),onChange:e=>{u(t=>({...t,status:e}))}}),(0,J.jsx)(P,{label:`Notifier`,value:l.notifier,anything:`Any notifier`,options:Bt(b.rows),onChange:e=>{u(t=>({...t,notifier:e}))}})]})]}),(0,J.jsx)(c,{loading:!y.state.read,problem:y.state.problem,empty:w.length===0,emptyMessage:`Nothing queued.`,children:(0,J.jsx)(p,{columns:Wt,rows:w,rowKey:Lt,reading:y.state.reading,next:y.state.next,onMore:y.more,noun:`notifications`,onSelect:e=>{a(null),s(e.id),N()},selected:e=>e.id===o})})]}),(0,J.jsx)(Dt,{open:e,onOpenChange:t,notifiers:$(b.rows),connections:b.connections,onCreated:x}),(0,J.jsx)(Nt,{open:n!==null,draft:n?.draft??Mt,onOpenChange:e=>{e||r(null)},notifiers:$(b.rows),connections:b.connections,onQueued:S,onOpenQueue:e=>{r(null),a(null),s(e),S(),N()}},n?.opened??0)]})}function $(e){return[...new Set(e.map(e=>e.notifier))]}function Bt(e){return $(e).map(e=>({value:e,label:e}))}function Vt(){let[e,t]=(0,U.useState)(null),[n,r]=(0,U.useState)(null);return(0,U.useEffect)(()=>{let e=!0;return Ue().then(n=>{e&&t(n)},()=>{e&&t([])}),de().then(t=>{e&&r(t.items)},()=>{e&&r([])}),()=>{e=!1}},[]),{rows:(0,U.useMemo)(()=>We(e??[],n??[]),[n,e]),connections:n??[],read:e!==null&&n!==null}}function Ht({rule:e}){let t=Oe(e.importance);return(0,J.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,J.jsx)(`span`,{className:e.scope===`pipeline`?`font-mono text-xs`:`text-sm`,children:De(e)}),t!==null&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})}var Ut=[{id:`rule`,header:`Rule`,kind:`title`,cell:e=>{let t=w(e);return(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,J.jsx)(`span`,{className:g(`truncate`,t.named?`text-sm font-medium`:`font-mono text-sm font-medium`),title:t.title,children:t.title}),t.code!==null&&(0,J.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,title:t.code,children:t.code})]})}},{id:`event`,header:`Event`,cell:e=>(0,J.jsx)(`span`,{className:`text-sm`,children:W[e.event]})},{id:`scope`,header:`Scope`,cell:e=>(0,J.jsx)(Ht,{rule:e})},{id:`delivers`,header:`Delivers through`,cell:e=>(0,J.jsx)(ut,{notifier:e.notifier,connection:e.connection})},{id:`throttle`,header:`Throttle`,className:`font-mono text-xs`,cell:e=>(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:Ee(e.throttle)})},{id:`sent`,header:`Last sent`,className:`text-xs`,cell:e=>e.last_sent_at===null?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`never`}):(0,J.jsx)(H,{className:`text-muted-foreground`,at:e.last_sent_at})},{id:`live`,header:`State`,cell:e=>e.paused?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`paused`}):e.active?(0,J.jsx)(`span`,{className:`text-xs text-good`,children:`active`}):(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`off`})}],Wt=[{id:`status`,header:`Status`,cell:e=>(0,J.jsx)(R,{status:e.status})},{id:`subject`,header:`Subject`,kind:`prose`,cell:e=>(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm`,title:e.subject,children:e.subject}),e.error!==null&&(0,J.jsx)(`span`,{className:`truncate text-xs text-critical`,title:e.error,children:e.error})]})},{id:`delivers`,header:`Delivers through`,cell:e=>(0,J.jsx)(dt,{notifier:e.notifier,connection:e.connection})},{id:`run`,header:`Run`,cell:e=>(0,J.jsx)(ft,{notification:e})},{id:`queued`,header:`Queued`,className:`text-xs`,cell:e=>(0,J.jsx)(H,{className:`text-muted-foreground`,at:e.created_at})},{id:`sent`,header:`Sent`,className:`text-xs`,cell:e=>e.status===`sent`?(0,J.jsx)(H,{className:`text-muted-foreground`,at:e.sent_at}):e.attempt>0?(0,J.jsxs)(`span`,{className:`text-faint`,children:[e.attempt,` of `,e.max_attempts,` attempts`]}):null}];export{Rt as AdminAlerting};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{n}from"./chunk-OB3PAWPO-DOp4K52_.js";import{n as r,t as i}from"./PageState-BLuobMye.js";import{i as a,t as o}from"./ListTable-D-mI8v9Y.js";import{r as s}from"./utils-CT7ZGLfR.js";import{C as c,_ as l,dt as u,nt as d,rt as f,ut as p}from"./index-Bp4KzK9w.js";import{t as m}from"./Markdown-roa7jpVu.js";import{n as h,r as g}from"./Panel-CqrOYByl.js";import{a as _,c as v,l as y,n as b,o as x,r as S,t as C}from"./blocks-CclbVd8c.js";import{y as w}from"./connections-DsdoSARb.js";import{l as T,r as E}from"./examples-DDWkSZ2u.js";import{t as D}from"./KindChip-CwU_Xxdy.js";var O=e(t(),1),k=s(),A=e=>e.id,j=[{key:`scheme`,title:`Storage schemes`,noun:`schemes`},{key:`notifier`,title:`Notifiers`,noun:`notifiers`},{key:`connection`,title:`Connection kinds`,noun:`connection kinds`}],M=e=>t=>`${e}:${t.id}`,N=()=>{};function P(){let[e,t]=(0,O.useState)(``),[n,s]=(0,O.useState)(null),{value:m,problem:h,read:g}=l(v),y=l(T),b=(0,O.useMemo)(()=>E(y.value??[]),[y.value]),S=(0,O.useMemo)(()=>m?.blocks??[],[m]),w=(0,O.useMemo)(()=>_(S,e),[S,e]),D=(0,O.useMemo)(()=>C(w),[w]),P=(0,O.useMemo)(()=>x(m?.storage_schemes??[],e),[m,e]),I=(0,O.useMemo)(()=>x(m?.notifiers??[],e),[m,e]),B=(0,O.useMemo)(()=>x(m?.connection_kinds??[],e),[m,e]),V=(0,O.useMemo)(()=>F(b),[b]),H=S.find(e=>`block:${e.id}`===n)??null,U={scheme:P,notifier:I,connection:B},W=j.flatMap(e=>U[e.key].map(t=>({registry:e,entry:t}))).find(({registry:e,entry:t})=>M(e.key)(t)===n)??null;(0,O.useEffect)(()=>{if(g)return f({note:null,tone:`quiet`,identifier:null}),d},[S,g,m]),(0,O.useEffect)(()=>{if(H!==null)return p([{id:`block`,label:`Block`,render:()=>(0,k.jsx)(z,{entry:H})}],{screen:`blocks`});if(W!==null){let{registry:e,entry:t}=W;return p([{id:`entry`,label:e.title,render:()=>(0,k.jsx)(R,{entry:t})}],{screen:`blocks`})}},[H,W]);let G=(0,O.useCallback)(e=>{s(`block:${e.id}`),u()},[]);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(i,{title:`Blocks`,aside:(0,k.jsx)(a,{tag:`blocks`})}),(0,k.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:(0,k.jsx)(c,{value:e,label:`Search blocks by id or summary`,onChange:t})}),(0,k.jsx)(r,{loading:!g,problem:h,empty:w.length===0&&P.length===0&&I.length===0&&B.length===0,emptyMessage:S.length===0?`No blocks installed — plugins contribute them.`:`Nothing in the catalog matches that.`,children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[D.map(([e,t])=>(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-1.5 font-mono text-xs font-semibold tracking-wide text-faint uppercase`,children:e}),(0,k.jsx)(o,{chrome:{footer:!1},columns:V,rows:t,rowKey:A,reading:!1,next:null,onMore:N,noun:`blocks`,onSelect:G,selected:e=>`block:${e.id}`===n})]},e)),j.map(e=>{let t=U[e.key];return t.length===0?null:(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-1.5 font-mono text-xs font-semibold tracking-wide text-faint uppercase`,children:e.title}),(0,k.jsx)(o,{chrome:{footer:!1},columns:L(e.key),rows:t,rowKey:M(e.key),reading:!1,next:null,onMore:N,noun:e.noun,onSelect:t=>{s(M(e.key)(t)),u()},selected:t=>M(e.key)(t)===n})]},e.key)})]})})]})}function F(e){return[{id:`block`,header:`Block`,kind:`title`,cell:e=>(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,k.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:e.summary,children:e.summary})]})},{id:`kind`,header:`Kind`,className:`min-w-32 whitespace-nowrap`,cell:e=>(0,k.jsx)(D,{kind:e.kind})},{id:`examples`,header:`Examples`,className:`min-w-28 whitespace-nowrap`,cell:t=>(0,k.jsx)(I,{id:t.id,many:e.get(t.id)??0})},{id:`plugin`,header:`Plugin`,className:`min-w-36 font-mono text-xs whitespace-nowrap`,cell:e=>(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:e.plugin})}]}function I({id:e,many:t}){if(t===0)return(0,k.jsx)(`span`,{className:`text-xs text-faint`,children:`none`});let r=`${String(t)} ${t===1?`example`:`examples`}`;return(0,k.jsx)(n,{className:`text-xs text-primary-ink hover:underline`,to:`/examples?block=${encodeURIComponent(e)}`,title:`The shipped documents that require ${e}`,onClick:e=>{e.stopPropagation()},children:r})}function L(e){let t=e===`scheme`?`storage`:e;return[{id:`entry`,header:`Entry`,kind:`title`,cell:e=>{let t=typeof e.config_schema.description==`string`?e.config_schema.description:``;return(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,k.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:t,children:t})]})}},{id:`kind`,header:`Kind`,className:`min-w-32 whitespace-nowrap`,cell:()=>(0,k.jsx)(D,{kind:t})},{id:`plugin`,header:`Plugin`,className:`min-w-36 font-mono text-xs whitespace-nowrap`,cell:e=>(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:e.plugin})}]}function R({entry:e}){let t=(0,O.useMemo)(()=>w(e.config_schema),[e]),n=typeof e.config_schema.description==`string`?e.config_schema.description:null;return(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:e.id}),n!==null&&(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n}),(0,k.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:(0,k.jsx)(h,{term:`plugin`,detail:e.plugin})})]}),(0,k.jsx)(g,{title:`Config`,children:t.length===0?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This takes no configuration.`}):(0,k.jsx)(`div`,{className:`flex flex-col gap-4`,children:t.map(e=>(0,k.jsx)(B,{field:e},e.name))})})]})}function z({entry:e}){let t=(0,O.useMemo)(()=>w(e.config_schema),[e]),n=S(e);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,k.jsx)(`p`,{children:(0,k.jsx)(D,{kind:e.kind})}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.summary})]}),(0,k.jsx)(g,{title:`Facts`,children:(0,k.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:n.map(e=>(0,k.jsx)(h,{term:e.term,detail:e.detail},e.term))})}),(0,k.jsx)(g,{title:`Config`,children:t.length===0?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This block takes no configuration.`}):(0,k.jsx)(`div`,{className:`flex flex-col gap-4`,children:t.map(e=>(0,k.jsx)(B,{field:e},e.name))})})]})}function B({field:e}){let t=b(e);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,k.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.name}),(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:y(e)}),e.required&&(0,k.jsx)(`span`,{className:`text-xs text-primary`,children:`required`}),e.hint!==null&&(0,k.jsx)(`span`,{className:`text-xs text-faint`,children:e.hint}),t!==null&&(0,k.jsxs)(`span`,{className:`text-xs text-faint`,children:[`default `,t]})]}),e.options.length>0&&(0,k.jsx)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:e.options.map(e=>e.label).join(` · `)}),e.help!==null&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,k.jsx)(m,{text:e.help})})]})}export{P as Blocks};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{n}from"./chunk-OB3PAWPO-DOp4K52_.js";import{n as r,t as i}from"./PageState-BLuobMye.js";import{i as a,t as o}from"./ListTable-D-mI8v9Y.js";import{r as s}from"./utils-CT7ZGLfR.js";import{C as c,_ as l,dt as u,nt as d,rt as f,ut as p}from"./index-CzO6Janm.js";import{t as m}from"./Markdown-roa7jpVu.js";import{n as h,r as g}from"./Panel-CqrOYByl.js";import{a as _,c as v,l as y,n as b,o as x,r as S,t as C}from"./blocks-CclbVd8c.js";import{b as w}from"./connections-Cp5WCruj.js";import{l as T,r as E}from"./examples-DB467CTN.js";import{t as D}from"./KindChip-CwU_Xxdy.js";var O=e(t(),1),k=s(),A=e=>e.id,j=[{key:`scheme`,title:`Storage schemes`,noun:`schemes`},{key:`notifier`,title:`Notifiers`,noun:`notifiers`},{key:`connection`,title:`Connection kinds`,noun:`connection kinds`}],M=e=>t=>`${e}:${t.id}`,N=()=>{};function P(){let[e,t]=(0,O.useState)(``),[n,s]=(0,O.useState)(null),{value:m,problem:h,read:g}=l(v),y=l(T),b=(0,O.useMemo)(()=>E(y.value??[]),[y.value]),S=(0,O.useMemo)(()=>m?.blocks??[],[m]),w=(0,O.useMemo)(()=>_(S,e),[S,e]),D=(0,O.useMemo)(()=>C(w),[w]),P=(0,O.useMemo)(()=>x(m?.storage_schemes??[],e),[m,e]),I=(0,O.useMemo)(()=>x(m?.notifiers??[],e),[m,e]),B=(0,O.useMemo)(()=>x(m?.connection_kinds??[],e),[m,e]),V=(0,O.useMemo)(()=>F(b),[b]),H=S.find(e=>`block:${e.id}`===n)??null,U={scheme:P,notifier:I,connection:B},W=j.flatMap(e=>U[e.key].map(t=>({registry:e,entry:t}))).find(({registry:e,entry:t})=>M(e.key)(t)===n)??null;(0,O.useEffect)(()=>{if(g)return f({note:null,tone:`quiet`,identifier:null}),d},[S,g,m]),(0,O.useEffect)(()=>{if(H!==null)return p([{id:`block`,label:`Block`,render:()=>(0,k.jsx)(z,{entry:H})}],{screen:`blocks`});if(W!==null){let{registry:e,entry:t}=W;return p([{id:`entry`,label:e.title,render:()=>(0,k.jsx)(R,{entry:t})}],{screen:`blocks`})}},[H,W]);let G=(0,O.useCallback)(e=>{s(`block:${e.id}`),u()},[]);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(i,{title:`Blocks`,aside:(0,k.jsx)(a,{tag:`blocks`})}),(0,k.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:(0,k.jsx)(c,{value:e,label:`Search blocks by id or summary`,onChange:t})}),(0,k.jsx)(r,{loading:!g,problem:h,empty:w.length===0&&P.length===0&&I.length===0&&B.length===0,emptyMessage:S.length===0?`No blocks installed — plugins contribute them.`:`Nothing in the catalog matches that.`,children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[D.map(([e,t])=>(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-1.5 font-mono text-xs font-semibold tracking-wide text-faint uppercase`,children:e}),(0,k.jsx)(o,{chrome:{footer:!1},columns:V,rows:t,rowKey:A,reading:!1,next:null,onMore:N,noun:`blocks`,onSelect:G,selected:e=>`block:${e.id}`===n})]},e)),j.map(e=>{let t=U[e.key];return t.length===0?null:(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-1.5 font-mono text-xs font-semibold tracking-wide text-faint uppercase`,children:e.title}),(0,k.jsx)(o,{chrome:{footer:!1},columns:L(e.key),rows:t,rowKey:M(e.key),reading:!1,next:null,onMore:N,noun:e.noun,onSelect:t=>{s(M(e.key)(t)),u()},selected:t=>M(e.key)(t)===n})]},e.key)})]})})]})}function F(e){return[{id:`block`,header:`Block`,kind:`title`,cell:e=>(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,k.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:e.summary,children:e.summary})]})},{id:`kind`,header:`Kind`,className:`min-w-32 whitespace-nowrap`,cell:e=>(0,k.jsx)(D,{kind:e.kind})},{id:`examples`,header:`Examples`,className:`min-w-28 whitespace-nowrap`,cell:t=>(0,k.jsx)(I,{id:t.id,many:e.get(t.id)??0})},{id:`plugin`,header:`Plugin`,className:`min-w-36 font-mono text-xs whitespace-nowrap`,cell:e=>(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:e.plugin})}]}function I({id:e,many:t}){if(t===0)return(0,k.jsx)(`span`,{className:`text-xs text-faint`,children:`none`});let r=`${String(t)} ${t===1?`example`:`examples`}`;return(0,k.jsx)(n,{className:`text-xs text-primary-ink hover:underline`,to:`/examples?block=${encodeURIComponent(e)}`,title:`The shipped documents that require ${e}`,onClick:e=>{e.stopPropagation()},children:r})}function L(e){let t=e===`scheme`?`storage`:e;return[{id:`entry`,header:`Entry`,kind:`title`,cell:e=>{let t=typeof e.config_schema.description==`string`?e.config_schema.description:``;return(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,k.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:t,children:t})]})}},{id:`kind`,header:`Kind`,className:`min-w-32 whitespace-nowrap`,cell:()=>(0,k.jsx)(D,{kind:t})},{id:`plugin`,header:`Plugin`,className:`min-w-36 font-mono text-xs whitespace-nowrap`,cell:e=>(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:e.plugin})}]}function R({entry:e}){let t=(0,O.useMemo)(()=>w(e.config_schema),[e]),n=typeof e.config_schema.description==`string`?e.config_schema.description:null;return(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:e.id}),n!==null&&(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n}),(0,k.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:(0,k.jsx)(h,{term:`plugin`,detail:e.plugin})})]}),(0,k.jsx)(g,{title:`Config`,children:t.length===0?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This takes no configuration.`}):(0,k.jsx)(`div`,{className:`flex flex-col gap-4`,children:t.map(e=>(0,k.jsx)(B,{field:e},e.name))})})]})}function z({entry:e}){let t=(0,O.useMemo)(()=>w(e.config_schema),[e]),n=S(e);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,k.jsx)(`p`,{children:(0,k.jsx)(D,{kind:e.kind})}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.summary})]}),(0,k.jsx)(g,{title:`Facts`,children:(0,k.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:n.map(e=>(0,k.jsx)(h,{term:e.term,detail:e.detail},e.term))})}),(0,k.jsx)(g,{title:`Config`,children:t.length===0?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This block takes no configuration.`}):(0,k.jsx)(`div`,{className:`flex flex-col gap-4`,children:t.map(e=>(0,k.jsx)(B,{field:e},e.name))})})]})}function B({field:e}){let t=b(e);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,k.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.name}),(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:y(e)}),e.required&&(0,k.jsx)(`span`,{className:`text-xs text-primary`,children:`required`}),e.hint!==null&&(0,k.jsx)(`span`,{className:`text-xs text-faint`,children:e.hint}),t!==null&&(0,k.jsxs)(`span`,{className:`text-xs text-faint`,children:[`default `,t]})]}),e.options.length>0&&(0,k.jsx)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:e.options.map(e=>e.label).join(` · `)}),e.help!==null&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,k.jsx)(m,{text:e.help})})]})}export{P as Blocks};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{r as n}from"./with-selector-BXYKoaOE.js";import{c as r,l as i,u as a}from"./chunk-OB3PAWPO-DOp4K52_.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-Dl8ZhXSH.js";import{r as d}from"./glyphs-C1sjljkh.js";import{n as f,o as p,t as m}from"./PageState-BLuobMye.js";import{i as h,n as g,t as _}from"./ListTable-D-mI8v9Y.js";import{r as v,t as y}from"./utils-CT7ZGLfR.js";import{i as b,n as x,t as S}from"./tooltip-D7_KwbOU.js";import{d as C,f as w}from"./paging-CpRIkEky.js";import{t as T}from"./input-1fShkFXn.js";import{t as E}from"./SchemaForm-C08AaK2P.js";import{t as D}from"./textarea-ljIbN_md.js";import{t as O}from"./use-store-CfRquqZF.js";import{d as k,l as A,s as j}from"./format-B5YbYOY-.js";import{t as M}from"./identity-BNZxCf_y.js";import{Ft as N,It as P,Lt as F,Mt as ee,Nt as te,O as I,Pt as ne,Rt as L,_ as R,_t as z,b as B,dt as V,gt as H,jt as re,k as U,nt as W,rt as G,ut as ie,v as ae,y as K}from"./index-Bp4KzK9w.js";import{t as q}from"./Description-MmXUnb-9.js";import{F as J,P as oe,S as se,a as ce,d as le,f as ue,g as de,h as fe,i as pe,l as me,n as he,o as ge,p as _e,s as ve,t as ye,u as be}from"./connections-DsdoSARb.js";import{n as xe,t as Se}from"./Refusal-B2rlk8VD.js";import{t as Ce}from"./KindChip-CwU_Xxdy.js";import{t as Y}from"./Instant-mr1E5jAK.js";import{t as X}from"./Mark-DQR2php6.js";var we={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};we.node;var Te=n(we),Z=e(t(),1),Q=v(),Ee={good:`var(--good)`,critical:`var(--critical)`};function De(e){return e===null?`var(--faint)`:Ee[e]}function $({view:e,className:t}){return(0,Q.jsxs)(`span`,{className:y(`flex items-center gap-2 text-xs`,t),children:[(0,Q.jsx)(`span`,{className:`status-dot`,style:{"--chip":De(e.tone)},"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:y(`whitespace-nowrap`,e.tone===null&&`text-faint`),children:e.label})]})}function Oe({id:e,name:t,stored:n,value:r,onChange:i}){return(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(I,{htmlFor:e,className:`font-mono text-sm font-medium`,children:t}),(0,Q.jsx)(T,{id:e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>{i(e.target.value)},placeholder:n?`stored — typing replaces it, blank keeps it`:`not set — type to set one`})]})}function ke({connection:e,schema:t,onSaved:n}){let r=O(U),[i,a]=(0,Z.useState)(e.name??``),[o,s]=(0,Z.useState)(e.description??``),[c,l]=(0,Z.useState)(()=>Me(e)),[u,f]=(0,Z.useState)({}),[m,h]=(0,Z.useState)(()=>new Set),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),S=M(e),A=(0,Z.useMemo)(()=>je(e,t),[e,t]),j=(0,Z.useMemo)(()=>oe(A,c),[A,c]),N=K(`admin`),P=B(N.why,se(j,m)?void 0:`A setting above is not what this kind accepts.`);return(0,Q.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{glyph:d(e.kind,r)}),(0,Q.jsx)(`span`,{className:S.named?`text-sm font-semibold`:`font-mono text-sm font-semibold`,children:S.title}),S.code!==null&&(0,Q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:S.code}),(0,Q.jsx)(Ce,{kind:e.kind})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Created `,(0,Q.jsx)(Y,{at:e.created_at}),k(e.created_at,e.updated_at)&&(0,Q.jsxs)(Q.Fragment,{children:[` · updated `,(0,Q.jsx)(Y,{at:e.updated_at})]})]}),(0,Q.jsx)(Ae,{connection:e}),(0,Q.jsx)(q,{text:e.description})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(I,{htmlFor:`connection-name`,children:`Name`}),(0,Q.jsx)(T,{id:`connection-name`,value:i,onChange:e=>{a(e.target.value),x(!1)},placeholder:`What to call this on screen`}),(0,Q.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Display only. Every reference to this credential is by its code, `,e.code,`.`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(I,{htmlFor:`connection-description`,children:`Description`}),(0,Q.jsx)(D,{id:`connection-description`,className:`h-24`,value:o,onChange:e=>{s(e.target.value),x(!1)},placeholder:`What this credential is for. Markdown is rendered.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-faint uppercase`,children:`Settings`}),(0,Q.jsx)(E,{fields:A,values:c,problems:j,onChange:(e,t)=>{l(n=>({...n,[e]:t})),x(!1)},onUnreadable:(e,t)=>{h(n=>J(n,e,t))}}),e.secret_fields.map(t=>(0,Q.jsx)(Oe,{id:`secret-${t}`,name:t,stored:Ne(e.config[t]),value:u[t]??``,onChange:e=>{f(n=>({...n,[t]:e})),x(!1)}},t))]}),g!==null&&(0,Q.jsx)(Se,{problem:g}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{why:P,children:(0,Q.jsx)(w,{size:`sm`,onClick:()=>{let t=me(e,Fe(e,c,u),Pe(i),Pe(o));if(t===null){x(!0);return}y(!0),_(null),fe(e.code,t).then(e=>{f({}),x(!0),n(e)},e=>{_(C(e))}).finally(()=>{y(!1)})},disabled:v||P!==void 0,title:P,children:v?`Saving`:`Save`})}),b&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saved.`})]})]})}function Ae({connection:e}){let t=ge(e);return(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{view:t}),t.checkedAt!==null&&(0,Q.jsxs)(`span`,{className:`text-xs text-faint`,children:[`checked `,(0,Q.jsx)(Y,{at:t.checkedAt})]})]}),t.detail!==null&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.detail})]})}function je(e,t){let n=new Set(e.secret_fields);return t===null?Object.keys(e.config).filter(e=>!n.has(e)).map(t=>({name:t,kind:typeof e.config[t]==`string`?`text`:`json`,help:null,required:!1,nullable:!0,fallback:void 0,options:[],mediaType:null,refers:null,hint:null,placeholder:``,bounds:{},accepts:[],holds:[]})):_e(t,e.secret_fields)}function Me(e){let t=new Set(e.secret_fields),n={};for(let[r,i]of Object.entries(e.config))t.has(r)||(n[r]=i);return n}function Ne(e){return e!=null}function Pe(e){let t=e.trim();return t===``?null:t}function Fe(e,t,n){let r={};for(let[n,i]of Object.entries(t))Object.is(i,e.config[n])||(r[n]=i);for(let[e,t]of Object.entries(n))t!==``&&(r[e]=t);return r}function Ie({open:e,kinds:t,startKind:n=``,onOpenChange:r,onCreated:i}){let[a,d]=(0,Z.useState)(``),[f,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(n),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)({}),[x,S]=(0,Z.useState)({}),[O,k]=(0,Z.useState)(()=>new Set),[A,j]=(0,Z.useState)(()=>new Set),[M,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(null),[V,H]=(0,Z.useState)(!1),U=t.find(e=>e.id===h)??null,W=_e(U?.config_schema??null,U?.secret_fields??[]),G=oe(W,y),ie=M?void 0:O,ae=K(`admin`),q=B(ae.why,Re(a,h,G,A));return(0,Q.jsx)(re,{open:e,onOpenChange:r,children:(0,Q.jsxs)(te,{className:`sm:max-w-xl`,showCloseButton:!1,children:[(0,Q.jsxs)(P,{children:[(0,Q.jsx)(F,{children:`New connection`}),(0,Q.jsx)(ne,{children:`Secret fields are sealed on the way in and never read back out.`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(I,{htmlFor:`connection-code`,children:`Code`}),(0,Q.jsx)(T,{id:`connection-code`,className:`font-mono`,value:a,onChange:e=>{d(e.target.value)},placeholder:`postman-echo`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(I,{htmlFor:`connection-kind`,children:`Kind`}),(0,Q.jsxs)(u,{value:h,onValueChange:e=>{g(String(e)),b({}),S({}),k(new Set),j(new Set),L(!1)},children:[(0,Q.jsx)(s,{id:`connection-kind`,className:`w-full font-mono`,children:(0,Q.jsx)(o,{placeholder:`Choose a kind`,children:U===null?void 0:()=>(0,Q.jsx)(Le,{kind:U.id})})}),(0,Q.jsx)(c,{children:t.map(e=>(0,Q.jsx)(l,{value:e.id,className:`font-mono`,children:(0,Q.jsx)(Le,{kind:e.id})},e.id))})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(I,{htmlFor:`connection-name-new`,children:`Name`}),(0,Q.jsx)(T,{id:`connection-name-new`,value:f,onChange:e=>{m(e.target.value)},placeholder:`What to call it on screen. Optional; nothing references it.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(I,{htmlFor:`connection-description-new`,children:`Description`}),(0,Q.jsx)(D,{id:`connection-description-new`,className:`h-24`,value:_,onChange:e=>{v(e.target.value)},placeholder:`What this credential is for. Markdown is rendered.`})]}),U!==null&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-faint uppercase`,children:`Settings`}),(0,Q.jsxs)(`div`,{className:`max-h-[40vh] space-y-3 overflow-y-auto pr-1`,children:[(0,Q.jsx)(E,{fields:W,values:y,problems:G,stated:ie,onChange:(e,t)=>{b(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r})},onTouch:e=>{k(t=>t.has(e)?t:new Set(t).add(e))},onUnreadable:(e,t)=>{j(n=>J(n,e,t))}}),U.secret_fields.map(e=>(0,Q.jsx)(Oe,{id:`new-secret-${e}`,name:e,stored:!1,value:x[e]??``,onChange:t=>{S(n=>({...n,[e]:t}))}},e))]})]}),R!==null&&(0,Q.jsx)(Se,{problem:R}),(0,Q.jsxs)(N,{children:[(0,Q.jsx)(ee,{render:(0,Q.jsx)(w,{variant:`ghost`}),children:`Close`}),(0,Q.jsx)(p,{why:q,children:(0,Q.jsx)(w,{disabled:V||q!==void 0,title:q,onClick:()=>{L(!0),H(!0),z(null),ce({code:a.trim(),name:ze(f),kind:h,description:ze(_),config:ve(y,x)}).then(e=>{i(e),d(``),m(``),v(``),g(n),b({}),S({}),k(new Set),j(new Set),L(!1),r(!1)},e=>{z(C(e))}).finally(()=>{H(!1)})},children:V?`Creating`:`Create`})})]})]})})}function Le({kind:e}){let t=O(U);return(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{glyph:d(e,t)}),e]})}function Re(e,t,n,r){if(e.trim()===``)return`A connection is addressed by its code, and this one has none.`;if(t===``)return`No kind is chosen, and a connection is a credential of one kind.`;if(r.size>0)return`A setting below holds text that is not a value.`;if(!se(n,r))return`A setting below is not what its kind accepts.`}function ze(e){let t=e.trim();return t===``?null:t}var Be=e=>e.code;function Ve(){let{code:e=null}=i(),t=r(),[n,o]=a(),s=n.get(`new`),[c,l]=(0,Z.useState)(!1),u=c||s!==null,[d,g]=(0,Z.useState)({}),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),{state:S,more:C,reload:T}=ae(ue,Be),E=(0,Z.useMemo)(()=>S.rows.map(e=>d[e.code]??e),[d,S.rows]),D=E.find(t=>t.code===e)??null,O=(0,Z.useCallback)(()=>e===null||D!==null?Promise.resolve(null):be(e),[e,D]),k=R(O).value,A=D??(k===null?null:d[k.code]??k);(0,Z.useEffect)(()=>{e!==null&&V()},[e]);let j=(0,Z.useCallback)(e=>{g(t=>({...t,[e.code]:e}))},[]),M=(0,Z.useCallback)(e=>{y(e.code),ye(e.code).then(t=>{j(de(e,t,new Date().toISOString()))},xe).finally(()=>{y(null)})},[j]),N=e!==null||u;(0,Z.useEffect)(()=>{if(!N||b!==null)return;let e=!0;return le().then(t=>{e&&x(t)},()=>{}),()=>{e=!1}},[b,N]),(0,Z.useEffect)(()=>{let e=pe(E);if(e===null){W();return}return G({note:e,tone:`quiet`,identifier:null}),W},[E]),(0,Z.useEffect)(()=>{if(A===null)return;let e=b?.find(e=>e.id===A.kind)?.config_schema??null;return ie([{id:`connection`,label:`Connection`,render:()=>(0,Q.jsx)(ke,{connection:A,schema:e,onSaved:j},A.code)}],{screen:`connections`})},[j,b,A]);let P=K(`admin`),F=P.may;(0,Z.useEffect)(()=>z([...F?[{id:`connections:new`,title:`New connection`,group:H,screen:!0,icon:Te,keywords:[`credential`,`create`,`add`],run:()=>{l(!0)}}]:[],{id:`connections:reload`,title:`Read the connections listing again`,group:H,screen:!0,icon:L,keywords:[`refresh`,`reload`],run:T}]),[F,T]);let ee=(0,Z.useMemo)(()=>He(M,v,P.why),[M,v,P.why]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(m,{title:`Connections`,aside:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{tag:`connections`}),(0,Q.jsx)(p,{why:P.why,children:(0,Q.jsxs)(w,{size:`sm`,"aria-label":`New connection`,disabled:!P.may,title:P.why,onClick:()=>{l(!0)},children:[(0,Q.jsx)(Te,{"aria-hidden":!0}),`New`]})})]})}),(0,Q.jsx)(f,{loading:!S.read,problem:S.problem,empty:E.length===0,emptyMessage:`No connections.`,children:(0,Q.jsx)(_,{columns:ee,rows:E,rowKey:Be,reading:S.reading,next:S.next,onMore:C,noun:`connections`,onSelect:e=>{t(he(e.code),{replace:!0})},selected:t=>t.code===e})}),(0,Q.jsx)(Ie,{open:u,kinds:b??[],startKind:s??``,onOpenChange:e=>{l(e),!e&&s!==null&&(n.delete(`new`),o(n,{replace:!0}))},onCreated:()=>{T()}},s??``)]})}function He(e,t,n){return[{id:`connection`,header:`Connection`,kind:`title`,cell:e=>(0,Q.jsx)(Ue,{row:e})},{id:`health`,header:`Health`,cell:e=>(0,Q.jsx)(We,{row:e})},{id:`checked`,header:`Checked`,className:`text-xs`,cell:e=>e.last_check_at===null?null:(0,Q.jsx)(Ge,{at:e.last_check_at})},{id:`check`,header:``,className:`py-1 text-right`,cell:r=>(0,Q.jsx)(p,{why:n,children:(0,Q.jsx)(w,{variant:`outline`,size:`icon-lg`,"aria-label":`Check ${r.code}`,disabled:t===r.code||n!==void 0,title:n??`Check now`,onClick:t=>{t.stopPropagation(),e(r)},children:(0,Q.jsx)(L,{className:y(t===r.code&&`animate-spin`),"aria-hidden":!0})})})}]}function Ue({row:e}){let t=M(e),n=O(U);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(X,{glyph:d(e.kind,n)}),(0,Q.jsx)(`span`,{className:y(`truncate font-semibold`,!t.named&&`font-mono`),title:t.title,children:t.title}),t.code!==null&&(0,Q.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,title:t.code,children:t.code}),(0,Q.jsx)(Ce,{kind:e.kind})]})}function We({row:e}){let t=ge(e),n=g();return t.detail===null||n?(0,Q.jsx)($,{view:t}):(0,Q.jsxs)(S,{children:[(0,Q.jsx)(b,{render:(0,Q.jsx)(`button`,{type:`button`,className:`rounded-sm focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)($,{view:t})})}),(0,Q.jsx)(x,{side:`bottom`,children:t.detail})]})}function Ge({at:e}){return(0,Q.jsx)(`span`,{className:`text-muted-foreground`,title:j(e),children:A(e)})}export{Ve as Connections};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{r as n}from"./with-selector-BXYKoaOE.js";import{c as r,l as i,u as a}from"./chunk-OB3PAWPO-DOp4K52_.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-fQgkAQLW.js";import{r as d}from"./glyphs-C1sjljkh.js";import{n as f,o as p,t as m}from"./PageState-BLuobMye.js";import{i as h,n as g,t as _}from"./ListTable-D-mI8v9Y.js";import{r as v,t as y}from"./utils-CT7ZGLfR.js";import{i as b,n as x,t as S}from"./tooltip-D7_KwbOU.js";import{d as C,f as w}from"./paging-CpRIkEky.js";import{t as T}from"./input-1fShkFXn.js";import{t as E}from"./SchemaForm-oVYx_dDn.js";import{t as D}from"./textarea-ljIbN_md.js";import{t as O}from"./use-store-CfRquqZF.js";import{d as k,l as A,s as j}from"./format-B5YbYOY-.js";import{t as M}from"./identity-BNZxCf_y.js";import{Ft as N,It as P,Lt as F,Mt as ee,Nt as te,O as I,Pt as ne,Rt as L,_ as R,_t as z,b as B,dt as V,gt as H,jt as re,k as U,nt as W,rt as G,ut as ie,v as ae,y as K}from"./index-CzO6Janm.js";import{t as q}from"./Description-MmXUnb-9.js";import{C as J,I as oe,L as se,a as ce,d as le,f as ue,g as de,h as fe,i as pe,l as me,n as he,o as ge,p as _e,s as ve,t as ye,u as be}from"./connections-Cp5WCruj.js";import{n as xe,t as Se}from"./Refusal-DickLwkO.js";import{t as Ce}from"./KindChip-CwU_Xxdy.js";import{t as Y}from"./Instant-mr1E5jAK.js";import{t as X}from"./Mark-DQR2php6.js";var we={name:`plug-zap`,size:24,node:[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]],aliases:[`plug-zap-2`]};we.node;var Te=n(we),Z=e(t(),1),Q=v(),Ee={good:`var(--good)`,critical:`var(--critical)`};function De(e){return e===null?`var(--faint)`:Ee[e]}function $({view:e,className:t}){return(0,Q.jsxs)(`span`,{className:y(`flex items-center gap-2 text-xs`,t),children:[(0,Q.jsx)(`span`,{className:`status-dot`,style:{"--chip":De(e.tone)},"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:y(`whitespace-nowrap`,e.tone===null&&`text-faint`),children:e.label})]})}function Oe({id:e,name:t,stored:n,value:r,onChange:i}){return(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(I,{htmlFor:e,className:`font-mono text-sm font-medium`,children:t}),(0,Q.jsx)(T,{id:e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>{i(e.target.value)},placeholder:n?`stored — typing replaces it, blank keeps it`:`not set — type to set one`})]})}function ke({connection:e,schema:t,onSaved:n}){let r=O(U),[i,a]=(0,Z.useState)(e.name??``),[o,s]=(0,Z.useState)(e.description??``),[c,l]=(0,Z.useState)(()=>Me(e)),[u,f]=(0,Z.useState)({}),[m,h]=(0,Z.useState)(()=>new Set),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),S=M(e),A=(0,Z.useMemo)(()=>je(e,t),[e,t]),j=(0,Z.useMemo)(()=>oe(A,c),[A,c]),N=K(`admin`),P=B(N.why,J(j,m)?void 0:`A setting above is not what this kind accepts.`);return(0,Q.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{glyph:d(e.kind,r)}),(0,Q.jsx)(`span`,{className:S.named?`text-sm font-semibold`:`font-mono text-sm font-semibold`,children:S.title}),S.code!==null&&(0,Q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:S.code}),(0,Q.jsx)(Ce,{kind:e.kind})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Created `,(0,Q.jsx)(Y,{at:e.created_at}),k(e.created_at,e.updated_at)&&(0,Q.jsxs)(Q.Fragment,{children:[` · updated `,(0,Q.jsx)(Y,{at:e.updated_at})]})]}),(0,Q.jsx)(Ae,{connection:e}),(0,Q.jsx)(q,{text:e.description})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(I,{htmlFor:`connection-name`,children:`Name`}),(0,Q.jsx)(T,{id:`connection-name`,value:i,onChange:e=>{a(e.target.value),x(!1)},placeholder:`What to call this on screen`}),(0,Q.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Display only. Every reference to this credential is by its code, `,e.code,`.`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(I,{htmlFor:`connection-description`,children:`Description`}),(0,Q.jsx)(D,{id:`connection-description`,className:`h-24`,value:o,onChange:e=>{s(e.target.value),x(!1)},placeholder:`What this credential is for. Markdown is rendered.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-faint uppercase`,children:`Settings`}),(0,Q.jsx)(E,{fields:A,values:c,problems:j,onChange:(e,t)=>{l(n=>({...n,[e]:t})),x(!1)},onUnreadable:(e,t)=>{h(n=>se(n,e,t))}}),e.secret_fields.map(t=>(0,Q.jsx)(Oe,{id:`secret-${t}`,name:t,stored:Ne(e.config[t]),value:u[t]??``,onChange:e=>{f(n=>({...n,[t]:e})),x(!1)}},t))]}),g!==null&&(0,Q.jsx)(Se,{problem:g}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{why:P,children:(0,Q.jsx)(w,{size:`sm`,onClick:()=>{let t=me(e,Fe(e,c,u),Pe(i),Pe(o));if(t===null){x(!0);return}y(!0),_(null),fe(e.code,t).then(e=>{f({}),x(!0),n(e)},e=>{_(C(e))}).finally(()=>{y(!1)})},disabled:v||P!==void 0,title:P,children:v?`Saving`:`Save`})}),b&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saved.`})]})]})}function Ae({connection:e}){let t=ge(e);return(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{view:t}),t.checkedAt!==null&&(0,Q.jsxs)(`span`,{className:`text-xs text-faint`,children:[`checked `,(0,Q.jsx)(Y,{at:t.checkedAt})]})]}),t.detail!==null&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.detail})]})}function je(e,t){let n=new Set(e.secret_fields);return t===null?Object.keys(e.config).filter(e=>!n.has(e)).map(t=>({name:t,kind:typeof e.config[t]==`string`?`text`:`json`,help:null,required:!1,nullable:!0,fallback:void 0,options:[],mediaType:null,refers:null,hint:null,placeholder:``,bounds:{},accepts:[],holds:[]})):_e(t,e.secret_fields)}function Me(e){let t=new Set(e.secret_fields),n={};for(let[r,i]of Object.entries(e.config))t.has(r)||(n[r]=i);return n}function Ne(e){return e!=null}function Pe(e){let t=e.trim();return t===``?null:t}function Fe(e,t,n){let r={};for(let[n,i]of Object.entries(t))Object.is(i,e.config[n])||(r[n]=i);for(let[e,t]of Object.entries(n))t!==``&&(r[e]=t);return r}function Ie({open:e,kinds:t,startKind:n=``,onOpenChange:r,onCreated:i}){let[a,d]=(0,Z.useState)(``),[f,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(n),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)({}),[x,S]=(0,Z.useState)({}),[O,k]=(0,Z.useState)(()=>new Set),[A,j]=(0,Z.useState)(()=>new Set),[M,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(null),[V,H]=(0,Z.useState)(!1),U=t.find(e=>e.id===h)??null,W=_e(U?.config_schema??null,U?.secret_fields??[]),G=oe(W,y),ie=M?void 0:O,ae=K(`admin`),q=B(ae.why,Re(a,h,G,A));return(0,Q.jsx)(re,{open:e,onOpenChange:r,children:(0,Q.jsxs)(te,{className:`sm:max-w-xl`,showCloseButton:!1,children:[(0,Q.jsxs)(P,{children:[(0,Q.jsx)(F,{children:`New connection`}),(0,Q.jsx)(ne,{children:`Secret fields are sealed on the way in and never read back out.`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(I,{htmlFor:`connection-code`,children:`Code`}),(0,Q.jsx)(T,{id:`connection-code`,className:`font-mono`,value:a,onChange:e=>{d(e.target.value)},placeholder:`postman-echo`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(I,{htmlFor:`connection-kind`,children:`Kind`}),(0,Q.jsxs)(u,{value:h,onValueChange:e=>{g(String(e)),b({}),S({}),k(new Set),j(new Set),L(!1)},children:[(0,Q.jsx)(s,{id:`connection-kind`,className:`w-full font-mono`,children:(0,Q.jsx)(o,{placeholder:`Choose a kind`,children:U===null?void 0:()=>(0,Q.jsx)(Le,{kind:U.id})})}),(0,Q.jsx)(c,{children:t.map(e=>(0,Q.jsx)(l,{value:e.id,className:`font-mono`,children:(0,Q.jsx)(Le,{kind:e.id})},e.id))})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(I,{htmlFor:`connection-name-new`,children:`Name`}),(0,Q.jsx)(T,{id:`connection-name-new`,value:f,onChange:e=>{m(e.target.value)},placeholder:`What to call it on screen. Optional; nothing references it.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(I,{htmlFor:`connection-description-new`,children:`Description`}),(0,Q.jsx)(D,{id:`connection-description-new`,className:`h-24`,value:_,onChange:e=>{v(e.target.value)},placeholder:`What this credential is for. Markdown is rendered.`})]}),U!==null&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold tracking-wide text-faint uppercase`,children:`Settings`}),(0,Q.jsxs)(`div`,{className:`max-h-[40vh] space-y-3 overflow-y-auto pr-1`,children:[(0,Q.jsx)(E,{fields:W,values:y,problems:G,stated:ie,onChange:(e,t)=>{b(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r})},onTouch:e=>{k(t=>t.has(e)?t:new Set(t).add(e))},onUnreadable:(e,t)=>{j(n=>se(n,e,t))}}),U.secret_fields.map(e=>(0,Q.jsx)(Oe,{id:`new-secret-${e}`,name:e,stored:!1,value:x[e]??``,onChange:t=>{S(n=>({...n,[e]:t}))}},e))]})]}),R!==null&&(0,Q.jsx)(Se,{problem:R}),(0,Q.jsxs)(N,{children:[(0,Q.jsx)(ee,{render:(0,Q.jsx)(w,{variant:`ghost`}),children:`Close`}),(0,Q.jsx)(p,{why:q,children:(0,Q.jsx)(w,{disabled:V||q!==void 0,title:q,onClick:()=>{L(!0),H(!0),z(null),ce({code:a.trim(),name:ze(f),kind:h,description:ze(_),config:ve(y,x)}).then(e=>{i(e),d(``),m(``),v(``),g(n),b({}),S({}),k(new Set),j(new Set),L(!1),r(!1)},e=>{z(C(e))}).finally(()=>{H(!1)})},children:V?`Creating`:`Create`})})]})]})})}function Le({kind:e}){let t=O(U);return(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{glyph:d(e,t)}),e]})}function Re(e,t,n,r){if(e.trim()===``)return`A connection is addressed by its code, and this one has none.`;if(t===``)return`No kind is chosen, and a connection is a credential of one kind.`;if(r.size>0)return`A setting below holds text that is not a value.`;if(!J(n,r))return`A setting below is not what its kind accepts.`}function ze(e){let t=e.trim();return t===``?null:t}var Be=e=>e.code;function Ve(){let{code:e=null}=i(),t=r(),[n,o]=a(),s=n.get(`new`),[c,l]=(0,Z.useState)(!1),u=c||s!==null,[d,g]=(0,Z.useState)({}),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),{state:S,more:C,reload:T}=ae(ue,Be),E=(0,Z.useMemo)(()=>S.rows.map(e=>d[e.code]??e),[d,S.rows]),D=E.find(t=>t.code===e)??null,O=(0,Z.useCallback)(()=>e===null||D!==null?Promise.resolve(null):be(e),[e,D]),k=R(O).value,A=D??(k===null?null:d[k.code]??k);(0,Z.useEffect)(()=>{e!==null&&V()},[e]);let j=(0,Z.useCallback)(e=>{g(t=>({...t,[e.code]:e}))},[]),M=(0,Z.useCallback)(e=>{y(e.code),ye(e.code).then(t=>{j(de(e,t,new Date().toISOString()))},xe).finally(()=>{y(null)})},[j]),N=e!==null||u;(0,Z.useEffect)(()=>{if(!N||b!==null)return;let e=!0;return le().then(t=>{e&&x(t)},()=>{}),()=>{e=!1}},[b,N]),(0,Z.useEffect)(()=>{let e=pe(E);if(e===null){W();return}return G({note:e,tone:`quiet`,identifier:null}),W},[E]),(0,Z.useEffect)(()=>{if(A===null)return;let e=b?.find(e=>e.id===A.kind)?.config_schema??null;return ie([{id:`connection`,label:`Connection`,render:()=>(0,Q.jsx)(ke,{connection:A,schema:e,onSaved:j},A.code)}],{screen:`connections`})},[j,b,A]);let P=K(`admin`),F=P.may;(0,Z.useEffect)(()=>z([...F?[{id:`connections:new`,title:`New connection`,group:H,screen:!0,icon:Te,keywords:[`credential`,`create`,`add`],run:()=>{l(!0)}}]:[],{id:`connections:reload`,title:`Read the connections listing again`,group:H,screen:!0,icon:L,keywords:[`refresh`,`reload`],run:T}]),[F,T]);let ee=(0,Z.useMemo)(()=>He(M,v,P.why),[M,v,P.why]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(m,{title:`Connections`,aside:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{tag:`connections`}),(0,Q.jsx)(p,{why:P.why,children:(0,Q.jsxs)(w,{size:`sm`,"aria-label":`New connection`,disabled:!P.may,title:P.why,onClick:()=>{l(!0)},children:[(0,Q.jsx)(Te,{"aria-hidden":!0}),`New`]})})]})}),(0,Q.jsx)(f,{loading:!S.read,problem:S.problem,empty:E.length===0,emptyMessage:`No connections.`,children:(0,Q.jsx)(_,{columns:ee,rows:E,rowKey:Be,reading:S.reading,next:S.next,onMore:C,noun:`connections`,onSelect:e=>{t(he(e.code),{replace:!0})},selected:t=>t.code===e})}),(0,Q.jsx)(Ie,{open:u,kinds:b??[],startKind:s??``,onOpenChange:e=>{l(e),!e&&s!==null&&(n.delete(`new`),o(n,{replace:!0}))},onCreated:()=>{T()}},s??``)]})}function He(e,t,n){return[{id:`connection`,header:`Connection`,kind:`title`,cell:e=>(0,Q.jsx)(Ue,{row:e})},{id:`health`,header:`Health`,cell:e=>(0,Q.jsx)(We,{row:e})},{id:`checked`,header:`Checked`,className:`text-xs`,cell:e=>e.last_check_at===null?null:(0,Q.jsx)(Ge,{at:e.last_check_at})},{id:`check`,header:``,className:`py-1 text-right`,cell:r=>(0,Q.jsx)(p,{why:n,children:(0,Q.jsx)(w,{variant:`outline`,size:`icon-lg`,"aria-label":`Check ${r.code}`,disabled:t===r.code||n!==void 0,title:n??`Check now`,onClick:t=>{t.stopPropagation(),e(r)},children:(0,Q.jsx)(L,{className:y(t===r.code&&`animate-spin`),"aria-hidden":!0})})})}]}function Ue({row:e}){let t=M(e),n=O(U);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(X,{glyph:d(e.kind,n)}),(0,Q.jsx)(`span`,{className:y(`truncate font-semibold`,!t.named&&`font-mono`),title:t.title,children:t.title}),t.code!==null&&(0,Q.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,title:t.code,children:t.code}),(0,Q.jsx)(Ce,{kind:e.kind})]})}function We({row:e}){let t=ge(e),n=g();return t.detail===null||n?(0,Q.jsx)($,{view:t}):(0,Q.jsxs)(S,{children:[(0,Q.jsx)(b,{render:(0,Q.jsx)(`button`,{type:`button`,className:`rounded-sm focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)($,{view:t})})}),(0,Q.jsx)(x,{side:`bottom`,children:t.detail})]})}function Ge({at:e}){return(0,Q.jsx)(`span`,{className:`text-muted-foreground`,title:j(e),children:A(e)})}export{Ve as Connections};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{c as n,n as r}from"./chunk-OB3PAWPO-DOp4K52_.js";import{n as i,r as a}from"./glyphs-C1sjljkh.js";import{i as o,n as s,r as c,t as l}from"./PageState-BLuobMye.js";import{i as u,t as d}from"./ListTable-D-mI8v9Y.js";import{r as f,t as p}from"./utils-CT7ZGLfR.js";import{t as m}from"./use-store-CfRquqZF.js";import{t as h}from"./auth-CHgfcdt9.js";import{v as g}from"./format-B5YbYOY-.js";import{t as _}from"./use-heartbeat-CBT8848s.js";import{t as v}from"./identity-BNZxCf_y.js";import{m as y}from"./pipelines-Pi3WL8R6.js";import{Rt as b,_ as x,_t as S,ht as C,k as w,l as T,m as E,t as D,u as O,w as k}from"./index-Bp4KzK9w.js";import{f as A,i as j,o as M,r as N}from"./connections-DsdoSARb.js";import{t as P}from"./Instant-mr1E5jAK.js";import{t as F}from"./Mark-DQR2php6.js";import{f as ee,i as I,p as te,r as ne,s as re,t as ie,u as ae}from"./TileCard-DERgB2kj.js";import{a as oe,i as L,r as R}from"./workers-BH2Za19E.js";import{f as z,s as B}from"./triggers-BetQ4Leu.js";var V=e(t(),1),H=f(),U={neutral:`bg-muted-foreground`,good:`bg-good`,info:`bg-info`,warning:`bg-warning`,critical:`bg-critical`};function W({rows:e,note:t,reading:n}){let i=m(h).identity?.role??null;return(0,H.jsx)(c,{className:`gap-0 p-0`,children:(0,H.jsxs)(o,{className:`flex h-full flex-col p-0`,children:[(0,H.jsxs)(`div`,{className:`space-y-1 px-3 py-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Health`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n?`Reading from the server`:`The workers claiming work, and every connection.`})]}),(0,H.jsx)(`ul`,{className:`max-h-64 grow overflow-y-auto`,children:e.map(e=>{let t=e.kind===`connection`?`/connections`:i===`admin`?`/admin/workers`:null,n=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,H.jsx)(`span`,{className:p(`size-2 shrink-0 rounded-full`,U[e.tone]),"aria-hidden":!0}),e.mark===null?(0,H.jsx)(`span`,{className:`size-4 shrink-0`,"aria-hidden":!0}):(0,H.jsx)(F,{glyph:e.mark})]}),(0,H.jsx)(`span`,{className:`max-w-[55%] min-w-[6ch] truncate font-mono text-xs`,title:e.label,children:e.label}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline justify-end gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,title:e.detail,children:e.detail}),e.at!==null&&(0,H.jsx)(P,{className:`shrink-0 text-xs text-faint`,at:e.at})]})]});return(0,H.jsx)(`li`,{className:`border-t border-border`,children:t===null?(0,H.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 px-3 py-1.5`,children:n}):(0,H.jsx)(r,{to:t,className:`control-link flex min-w-0 items-center gap-2 px-3 py-1.5 hover:bg-accent/60`,children:n})},`${e.kind}:${e.id}`)})}),(0,H.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-xs text-muted-foreground`,children:t})]})})}function G(e,t){return`${String(e)}${t.next===null?``:`+`}`}function K(e,t){return e===0?`neutral`:t}function q(e,t){return e.items.filter(e=>e.status===t).length}function se(e,t,n){let r=(t,n,r)=>{if(e===null)return null;let i=q(e,t);return{id:t,label:n,value:G(i,e),note:``,tone:K(i,r),to:O({...D,status:t,since:`24h`})}},i=(e,t,n,r,i)=>{if(i===null)return null;let a=i.items.length;return{id:e,label:t,value:G(a,i),note:a===0?``:r,tone:K(a,n),to:O({...D,status:e})}};return[{id:`runs`,tile:e===null?null:{id:`runs`,label:`Runs`,value:G(e.items.length,e),note:`Last 24 hours.`,tone:`neutral`,to:O({...D,since:`24h`})}},{id:`succeeded`,tile:r(`succeeded`,`Succeeded`,`good`)},{id:`failed`,tile:r(`failed`,`Failed`,`critical`)},{id:`completed_with_errors`,tile:r(`completed_with_errors`,`With errors`,`warning`)},{id:`running`,tile:i(`running`,`Running`,`info`,`Being worked on now.`,t)},{id:`queued`,tile:i(`queued`,`Queued`,`neutral`,`Waiting for a worker.`,n)}]}var J=36e5,Y=864e5;function ce(e,t){let n=e+t*6e4;return Math.floor(n/J)*J-t*6e4}function le(e,t){let n=e+t*6e4;return Math.floor((n%Y+Y)%Y/J)}function ue(e,t,n,r=24){let i=ce(t.getTime(),n)-(r-1)*J,a=Array.from({length:r},(e,t)=>{let r=i+t*J;return{start:r,hour:le(r,n),succeeded:0,withErrors:0,failed:0,total:0}});for(let t of e){let e=Date.parse(t.created_at);if(Number.isNaN(e))continue;let n=Math.floor((e-i)/J);if(n<0||n>=r)continue;let o=a[n];o.total+=1,t.status===`succeeded`?o.succeeded+=1:t.status===`completed_with_errors`?o.withErrors+=1:t.status===`failed`&&(o.failed+=1)}return a}function X(e){return e.succeeded+e.withErrors+e.failed}function de(e){return e.reduce((e,t)=>Math.max(e,X(t)),0)}function fe(e){let t=t=>e.reduce((e,n)=>e+t(n),0),n=t(e=>e.total);if(n===0)return`No run was started in the last 24 hours.`;let r=[`${String(t(e=>e.succeeded))} succeeded`,`${String(t(e=>e.withErrors))} finished with errors`,`${String(t(e=>e.failed))} failed`];return`${String(n)} runs started in the last 24 hours, by the hour: ${r.join(`, `)}.`}function pe(e,t,n=i){let r=e.map(e=>{let t=R(e);return{id:e.id,kind:`worker`,mark:null,label:e.name,tone:t===null?`good`:I(t),detail:t===null?`worker · ${String(e.concurrency)} ${e.concurrency===1?`slot`:`slots`}`:L(t),at:t===null?null:e.last_seen_at}}),o=t.map(e=>{let t=M(e);return{id:e.id,kind:`connection`,mark:a(e.kind,n),label:e.code,tone:t.tone??`neutral`,detail:me(t),at:e.last_check_at}});return[...r,...o]}function me(e){switch(e.state){case`unchecked`:return`never checked`;case`unverified`:return`not verified`;case`healthy`:return e.detail??`healthy`;case`failed`:return e.detail??`did not answer`}}function he(e,t){let n=e.filter(e=>R(e)===null).length,{healthy:r,total:i}=N(t),a=[];if(e.length===0?a.push(`no worker has registered`):n<e.length&&a.push(`${String(n)} of ${String(e.length)} workers healthy`),r<i){let e=j(t,`connections`);e!==null&&a.push(e)}if(a.length>0){let e=a.join(` · `);return`${e.charAt(0).toUpperCase()}${e.slice(1)}.`}return t.length===0?`Every worker is healthy, and this instance holds no connections.`:`Every worker and every connection is healthy.`}function ge(e,t,n=6){return[...e,...t].toSorted((e,t)=>Date.parse(t.created_at)-Date.parse(e.created_at)).slice(0,n)}function _e(e,t=6){return e.flatMap(e=>{let t=B(e.schedule);return t.kind===`due`?[{...e,at:t.at}]:[]}).toSorted((e,t)=>Date.parse(e.at)-Date.parse(t.at)).slice(0,t)}async function ve(e){let t=e.filter(e=>e.schedules>0);return(await Promise.all(t.map(async e=>(await z(e.code,null)).items.map(t=>({pipeline:e.code,schedule:t}))))).flat()}async function ye(){let e=await y(null);return{pipelines:e.items,schedules:await ve(e.items)}}var be=6,Z=[{id:`failed`,label:`Failed`,fill:`bg-status-failed/80`},{id:`withErrors`,label:`With errors`,fill:`bg-status-completed-with-errors/80`},{id:`succeeded`,label:`Succeeded`,fill:`bg-status-succeeded/75`}];function xe(e){let t=`${String(e.hour).padStart(2,`0`)}:00`;if(e.total===0)return`${t} — nothing ran`;let n=Z.filter(t=>e[t.id]>0).map(t=>`${String(e[t.id])} ${t.label.toLowerCase()}`),r=n.length===0?`none finished`:n.join(`, `);return`${t} — ${String(e.total)} started, ${r}`}function Se({buckets:e,reading:t,className:n}){let r=de(e);return(0,H.jsx)(c,{className:p(`gap-0 p-0`,n),children:(0,H.jsxs)(o,{className:`space-y-3 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runs over time`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t?`Reading from the server`:`Every run started in the last 24 hours, by the hour it started in.`})]}),(0,H.jsx)(`ul`,{className:`flex items-center gap-3`,children:Z.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:p(`size-2 shrink-0 rounded-sm`,e.fill),"aria-hidden":!0}),e.label]},e.id))})]}),(0,H.jsx)(`div`,{className:`flex h-32 items-end gap-px`,role:`img`,"aria-label":fe(e),children:e.map(e=>(0,H.jsxs)(`div`,{className:`flex h-full flex-1 flex-col justify-end rounded-sm hover:bg-accent/40`,title:xe(e),children:[Z.map(t=>e[t.id]===0?null:(0,H.jsx)(`div`,{className:p(`min-h-0.5 w-full`,t.fill),style:{height:`${String(e[t.id]/Math.max(r,1)*100)}%`}},t.id)),X(e)===0&&(0,H.jsx)(`div`,{className:`h-px w-full bg-border`})]},e.start))}),(0,H.jsx)(`div`,{className:`flex gap-px font-mono text-xs text-faint`,"aria-hidden":!0,children:e.map((e,t)=>(0,H.jsx)(`span`,{className:`flex-1 text-center`,children:t%be===0?`${String(e.hour).padStart(2,`0`)}`:``},e.start))})]})})}function Ce(){let e=m(w),t=x((0,V.useCallback)(()=>T({...D,since:`24h`},null,500),[])),r=x((0,V.useCallback)(()=>T({...D,status:`running`},null),[])),i=x((0,V.useCallback)(()=>T({...D,status:`queued`},null),[])),a=x((0,V.useCallback)(()=>T({...D,status:`failed`},null),[])),o=x((0,V.useCallback)(()=>T({...D,status:`completed_with_errors`},null),[])),c=x(ye),f=x((0,V.useCallback)(()=>oe(null),[])),h=x((0,V.useCallback)(()=>A(null),[])),{again:v}=t,{again:y}=r,{again:O}=i,{again:k}=a,{again:j}=o,{again:M}=c,{again:N}=f,{again:P}=h,F=(0,V.useCallback)(()=>{v(),y(),O(),k(),j(),M(),N(),P()},[M,P,v,k,j,O,y,N]);(0,V.useEffect)(()=>S([{id:`dashboard:refresh`,title:`Refresh the dashboard`,group:C,screen:!0,icon:b,keywords:[`refresh`,`reload`,`home`],run:F}]),[F]);let I=n();_(F,m(E));let L=ge(r.value?.items??[],i.value?.items??[]),R=ae(re(a.value?.items??[],o.value?.items??[]),c.value?.pipelines??[]),z=_e(c.value?.schedules??[]),B=se(t.value,r.value,i.value),U=new Date,G=ue(t.value?.items??[],U,g(U)),K=f.problem===null&&h.problem===null;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(l,{title:`Dashboard`,aside:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(u,{tag:`runs`}),(0,H.jsx)(te,{onRefresh:F})]})}),(0,H.jsx)(`div`,{className:`mb-3 grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:B.map(e=>e.tile===null?(0,H.jsx)(ne,{},e.id):(0,H.jsx)(ie,{tile:e.tile},e.id))}),(0,H.jsxs)(`div`,{className:`mb-6 grid gap-3 xl:grid-cols-3`,children:[(0,H.jsx)(`div`,{className:p(K?`xl:col-span-2`:`xl:col-span-3`),children:t.problem===null?(0,H.jsx)(Se,{buckets:G,reading:!t.read}):(0,H.jsx)(s,{loading:!1,problem:t.problem,empty:!1,children:null})}),K&&(0,H.jsx)(W,{rows:pe(f.value?.items??[],h.value?.items??[],e),note:he(f.value?.items??[],h.value?.items??[]),reading:!f.read||!h.read})]}),(0,H.jsx)(Q,{title:`Right now`,to:`/runs`,children:(0,H.jsx)(s,{loading:!r.read||!i.read,problem:r.problem??i.problem,empty:L.length===0,emptyMessage:`Nothing is running and nothing is waiting.`,children:(0,H.jsx)(d,{chrome:{footer:!1},columns:we,rows:L,rowKey:e=>e.id,reading:!1,next:null,onMore:$,noun:`runs`,onSelect:e=>void I(`/runs/${e.id}`)})})}),(0,H.jsx)(Q,{title:`Needs a look`,to:`/runs`,children:(0,H.jsx)(s,{loading:!a.read||!o.read,problem:a.problem??o.problem,empty:R.length===0,emptyMessage:`Nothing has failed or finished with errors.`,children:(0,H.jsx)(d,{chrome:{footer:!1},columns:ee,rows:R,rowKey:e=>e.run.id,reading:!1,next:null,onMore:$,noun:`runs`,onSelect:e=>void I(`/runs/${e.run.id}`)})})}),(0,H.jsx)(Q,{title:`Next fires`,to:`/triggers`,children:(0,H.jsx)(s,{loading:!c.read,problem:c.problem,empty:z.length===0,emptyMessage:`No schedule is due to fire.`,children:(0,H.jsx)(d,{chrome:{footer:!1},columns:Te,rows:z,rowKey:e=>`${e.pipeline}:${e.schedule.code}`,reading:!1,next:null,onMore:$,noun:`firings`,onSelect:e=>void I(`/pipelines/${encodeURIComponent(e.pipeline)}`)})})})]})}function Q({title:e,to:t,children:n}){return(0,H.jsxs)(`section`,{className:`mb-6 space-y-2 last:mb-0`,children:[(0,H.jsx)(`div`,{className:`space-y-1`,children:(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:(0,H.jsx)(r,{to:t,className:`hover:text-primary`,children:e})})}),n]})}var $=()=>{},we=[{id:`status`,header:`Status`,cell:e=>(0,H.jsx)(k,{status:e.status})},{id:`pipeline`,header:`Pipeline`,cell:e=>(0,H.jsx)(`span`,{className:`font-mono text-sm`,children:v({code:e.pipeline}).title})},{id:`since`,header:`Since`,className:`text-right`,cell:e=>(0,H.jsx)(P,{className:`text-xs text-faint`,at:e.started_at??e.created_at})}],Te=[{id:`pipeline`,header:`Pipeline`,cell:e=>(0,H.jsx)(`span`,{className:`font-mono text-sm`,children:v({code:e.pipeline}).title})},{id:`schedule`,header:`Schedule`,cell:e=>{let t=v(e.schedule);return(0,H.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,H.jsx)(`span`,{className:p(`truncate text-xs`,t.named?`text-foreground`:`font-mono`),children:t.title}),t.code!==null&&(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:t.code})]})}},{id:`fires`,header:`Fires`,className:`text-right`,cell:e=>(0,H.jsx)(P,{className:`text-xs text-faint`,at:e.at})}];export{Ce as Dashboard};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{c as n,n as r}from"./chunk-OB3PAWPO-DOp4K52_.js";import{n as i,r as a}from"./glyphs-C1sjljkh.js";import{i as o,n as s,r as c,t as l}from"./PageState-BLuobMye.js";import{i as u,t as d}from"./ListTable-D-mI8v9Y.js";import{r as f,t as p}from"./utils-CT7ZGLfR.js";import{t as m}from"./use-store-CfRquqZF.js";import{t as h}from"./auth-CHgfcdt9.js";import{v as g}from"./format-B5YbYOY-.js";import{t as _}from"./use-heartbeat-CBT8848s.js";import{t as v}from"./identity-BNZxCf_y.js";import{m as y}from"./pipelines-Pi3WL8R6.js";import{Rt as b,_ as x,_t as S,ht as C,k as w,l as T,m as E,t as D,u as O,w as k}from"./index-CzO6Janm.js";import{f as A,i as j,o as M,r as N}from"./connections-Cp5WCruj.js";import{t as P}from"./Instant-mr1E5jAK.js";import{t as F}from"./Mark-DQR2php6.js";import{f as ee,i as I,p as te,r as ne,s as re,t as ie,u as ae}from"./TileCard-UUULdrAd.js";import{a as oe,i as L,r as R}from"./workers-BH2Za19E.js";import{f as z,s as B}from"./triggers-BetQ4Leu.js";var V=e(t(),1),H=f(),U={neutral:`bg-muted-foreground`,good:`bg-good`,info:`bg-info`,warning:`bg-warning`,critical:`bg-critical`};function W({rows:e,note:t,reading:n}){let i=m(h).identity?.role??null;return(0,H.jsx)(c,{className:`gap-0 p-0`,children:(0,H.jsxs)(o,{className:`flex h-full flex-col p-0`,children:[(0,H.jsxs)(`div`,{className:`space-y-1 px-3 py-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Health`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n?`Reading from the server`:`The workers claiming work, and every connection.`})]}),(0,H.jsx)(`ul`,{className:`max-h-64 grow overflow-y-auto`,children:e.map(e=>{let t=e.kind===`connection`?`/connections`:i===`admin`?`/admin/workers`:null,n=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,H.jsx)(`span`,{className:p(`size-2 shrink-0 rounded-full`,U[e.tone]),"aria-hidden":!0}),e.mark===null?(0,H.jsx)(`span`,{className:`size-4 shrink-0`,"aria-hidden":!0}):(0,H.jsx)(F,{glyph:e.mark})]}),(0,H.jsx)(`span`,{className:`max-w-[55%] min-w-[6ch] truncate font-mono text-xs`,title:e.label,children:e.label}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline justify-end gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,title:e.detail,children:e.detail}),e.at!==null&&(0,H.jsx)(P,{className:`shrink-0 text-xs text-faint`,at:e.at})]})]});return(0,H.jsx)(`li`,{className:`border-t border-border`,children:t===null?(0,H.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 px-3 py-1.5`,children:n}):(0,H.jsx)(r,{to:t,className:`control-link flex min-w-0 items-center gap-2 px-3 py-1.5 hover:bg-accent/60`,children:n})},`${e.kind}:${e.id}`)})}),(0,H.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-xs text-muted-foreground`,children:t})]})})}function G(e,t){return`${String(e)}${t.next===null?``:`+`}`}function K(e,t){return e===0?`neutral`:t}function q(e,t){return e.items.filter(e=>e.status===t).length}function se(e,t,n){let r=(t,n,r)=>{if(e===null)return null;let i=q(e,t);return{id:t,label:n,value:G(i,e),note:``,tone:K(i,r),to:O({...D,status:t,since:`24h`})}},i=(e,t,n,r,i)=>{if(i===null)return null;let a=i.items.length;return{id:e,label:t,value:G(a,i),note:a===0?``:r,tone:K(a,n),to:O({...D,status:e})}};return[{id:`runs`,tile:e===null?null:{id:`runs`,label:`Runs`,value:G(e.items.length,e),note:`Last 24 hours.`,tone:`neutral`,to:O({...D,since:`24h`})}},{id:`succeeded`,tile:r(`succeeded`,`Succeeded`,`good`)},{id:`failed`,tile:r(`failed`,`Failed`,`critical`)},{id:`completed_with_errors`,tile:r(`completed_with_errors`,`With errors`,`warning`)},{id:`running`,tile:i(`running`,`Running`,`info`,`Being worked on now.`,t)},{id:`queued`,tile:i(`queued`,`Queued`,`neutral`,`Waiting for a worker.`,n)}]}var J=36e5,Y=864e5;function ce(e,t){let n=e+t*6e4;return Math.floor(n/J)*J-t*6e4}function le(e,t){let n=e+t*6e4;return Math.floor((n%Y+Y)%Y/J)}function ue(e,t,n,r=24){let i=ce(t.getTime(),n)-(r-1)*J,a=Array.from({length:r},(e,t)=>{let r=i+t*J;return{start:r,hour:le(r,n),succeeded:0,withErrors:0,failed:0,total:0}});for(let t of e){let e=Date.parse(t.created_at);if(Number.isNaN(e))continue;let n=Math.floor((e-i)/J);if(n<0||n>=r)continue;let o=a[n];o.total+=1,t.status===`succeeded`?o.succeeded+=1:t.status===`completed_with_errors`?o.withErrors+=1:t.status===`failed`&&(o.failed+=1)}return a}function X(e){return e.succeeded+e.withErrors+e.failed}function de(e){return e.reduce((e,t)=>Math.max(e,X(t)),0)}function fe(e){let t=t=>e.reduce((e,n)=>e+t(n),0),n=t(e=>e.total);if(n===0)return`No run was started in the last 24 hours.`;let r=[`${String(t(e=>e.succeeded))} succeeded`,`${String(t(e=>e.withErrors))} finished with errors`,`${String(t(e=>e.failed))} failed`];return`${String(n)} runs started in the last 24 hours, by the hour: ${r.join(`, `)}.`}function pe(e,t,n=i){let r=e.map(e=>{let t=R(e);return{id:e.id,kind:`worker`,mark:null,label:e.name,tone:t===null?`good`:I(t),detail:t===null?`worker · ${String(e.concurrency)} ${e.concurrency===1?`slot`:`slots`}`:L(t),at:t===null?null:e.last_seen_at}}),o=t.map(e=>{let t=M(e);return{id:e.id,kind:`connection`,mark:a(e.kind,n),label:e.code,tone:t.tone??`neutral`,detail:me(t),at:e.last_check_at}});return[...r,...o]}function me(e){switch(e.state){case`unchecked`:return`never checked`;case`unverified`:return`not verified`;case`healthy`:return e.detail??`healthy`;case`failed`:return e.detail??`did not answer`}}function he(e,t){let n=e.filter(e=>R(e)===null).length,{healthy:r,total:i}=N(t),a=[];if(e.length===0?a.push(`no worker has registered`):n<e.length&&a.push(`${String(n)} of ${String(e.length)} workers healthy`),r<i){let e=j(t,`connections`);e!==null&&a.push(e)}if(a.length>0){let e=a.join(` · `);return`${e.charAt(0).toUpperCase()}${e.slice(1)}.`}return t.length===0?`Every worker is healthy, and this instance holds no connections.`:`Every worker and every connection is healthy.`}function ge(e,t,n=6){return[...e,...t].toSorted((e,t)=>Date.parse(t.created_at)-Date.parse(e.created_at)).slice(0,n)}function _e(e,t=6){return e.flatMap(e=>{let t=B(e.schedule);return t.kind===`due`?[{...e,at:t.at}]:[]}).toSorted((e,t)=>Date.parse(e.at)-Date.parse(t.at)).slice(0,t)}async function ve(e){let t=e.filter(e=>e.schedules>0);return(await Promise.all(t.map(async e=>(await z(e.code,null)).items.map(t=>({pipeline:e.code,schedule:t}))))).flat()}async function ye(){let e=await y(null);return{pipelines:e.items,schedules:await ve(e.items)}}var be=6,Z=[{id:`failed`,label:`Failed`,fill:`bg-status-failed/80`},{id:`withErrors`,label:`With errors`,fill:`bg-status-completed-with-errors/80`},{id:`succeeded`,label:`Succeeded`,fill:`bg-status-succeeded/75`}];function xe(e){let t=`${String(e.hour).padStart(2,`0`)}:00`;if(e.total===0)return`${t} — nothing ran`;let n=Z.filter(t=>e[t.id]>0).map(t=>`${String(e[t.id])} ${t.label.toLowerCase()}`),r=n.length===0?`none finished`:n.join(`, `);return`${t} — ${String(e.total)} started, ${r}`}function Se({buckets:e,reading:t,className:n}){let r=de(e);return(0,H.jsx)(c,{className:p(`gap-0 p-0`,n),children:(0,H.jsxs)(o,{className:`space-y-3 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runs over time`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t?`Reading from the server`:`Every run started in the last 24 hours, by the hour it started in.`})]}),(0,H.jsx)(`ul`,{className:`flex items-center gap-3`,children:Z.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:p(`size-2 shrink-0 rounded-sm`,e.fill),"aria-hidden":!0}),e.label]},e.id))})]}),(0,H.jsx)(`div`,{className:`flex h-32 items-end gap-px`,role:`img`,"aria-label":fe(e),children:e.map(e=>(0,H.jsxs)(`div`,{className:`flex h-full flex-1 flex-col justify-end rounded-sm hover:bg-accent/40`,title:xe(e),children:[Z.map(t=>e[t.id]===0?null:(0,H.jsx)(`div`,{className:p(`min-h-0.5 w-full`,t.fill),style:{height:`${String(e[t.id]/Math.max(r,1)*100)}%`}},t.id)),X(e)===0&&(0,H.jsx)(`div`,{className:`h-px w-full bg-border`})]},e.start))}),(0,H.jsx)(`div`,{className:`flex gap-px font-mono text-xs text-faint`,"aria-hidden":!0,children:e.map((e,t)=>(0,H.jsx)(`span`,{className:`flex-1 text-center`,children:t%be===0?`${String(e.hour).padStart(2,`0`)}`:``},e.start))})]})})}function Ce(){let e=m(w),t=x((0,V.useCallback)(()=>T({...D,since:`24h`},null,500),[])),r=x((0,V.useCallback)(()=>T({...D,status:`running`},null),[])),i=x((0,V.useCallback)(()=>T({...D,status:`queued`},null),[])),a=x((0,V.useCallback)(()=>T({...D,status:`failed`},null),[])),o=x((0,V.useCallback)(()=>T({...D,status:`completed_with_errors`},null),[])),c=x(ye),f=x((0,V.useCallback)(()=>oe(null),[])),h=x((0,V.useCallback)(()=>A(null),[])),{again:v}=t,{again:y}=r,{again:O}=i,{again:k}=a,{again:j}=o,{again:M}=c,{again:N}=f,{again:P}=h,F=(0,V.useCallback)(()=>{v(),y(),O(),k(),j(),M(),N(),P()},[M,P,v,k,j,O,y,N]);(0,V.useEffect)(()=>S([{id:`dashboard:refresh`,title:`Refresh the dashboard`,group:C,screen:!0,icon:b,keywords:[`refresh`,`reload`,`home`],run:F}]),[F]);let I=n();_(F,m(E));let L=ge(r.value?.items??[],i.value?.items??[]),R=ae(re(a.value?.items??[],o.value?.items??[]),c.value?.pipelines??[]),z=_e(c.value?.schedules??[]),B=se(t.value,r.value,i.value),U=new Date,G=ue(t.value?.items??[],U,g(U)),K=f.problem===null&&h.problem===null;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(l,{title:`Dashboard`,aside:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(u,{tag:`runs`}),(0,H.jsx)(te,{onRefresh:F})]})}),(0,H.jsx)(`div`,{className:`mb-3 grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:B.map(e=>e.tile===null?(0,H.jsx)(ne,{},e.id):(0,H.jsx)(ie,{tile:e.tile},e.id))}),(0,H.jsxs)(`div`,{className:`mb-6 grid gap-3 xl:grid-cols-3`,children:[(0,H.jsx)(`div`,{className:p(K?`xl:col-span-2`:`xl:col-span-3`),children:t.problem===null?(0,H.jsx)(Se,{buckets:G,reading:!t.read}):(0,H.jsx)(s,{loading:!1,problem:t.problem,empty:!1,children:null})}),K&&(0,H.jsx)(W,{rows:pe(f.value?.items??[],h.value?.items??[],e),note:he(f.value?.items??[],h.value?.items??[]),reading:!f.read||!h.read})]}),(0,H.jsx)(Q,{title:`Right now`,to:`/runs`,children:(0,H.jsx)(s,{loading:!r.read||!i.read,problem:r.problem??i.problem,empty:L.length===0,emptyMessage:`Nothing is running and nothing is waiting.`,children:(0,H.jsx)(d,{chrome:{footer:!1},columns:we,rows:L,rowKey:e=>e.id,reading:!1,next:null,onMore:$,noun:`runs`,onSelect:e=>void I(`/runs/${e.id}`)})})}),(0,H.jsx)(Q,{title:`Needs a look`,to:`/runs`,children:(0,H.jsx)(s,{loading:!a.read||!o.read,problem:a.problem??o.problem,empty:R.length===0,emptyMessage:`Nothing has failed or finished with errors.`,children:(0,H.jsx)(d,{chrome:{footer:!1},columns:ee,rows:R,rowKey:e=>e.run.id,reading:!1,next:null,onMore:$,noun:`runs`,onSelect:e=>void I(`/runs/${e.run.id}`)})})}),(0,H.jsx)(Q,{title:`Next fires`,to:`/triggers`,children:(0,H.jsx)(s,{loading:!c.read,problem:c.problem,empty:z.length===0,emptyMessage:`No schedule is due to fire.`,children:(0,H.jsx)(d,{chrome:{footer:!1},columns:Te,rows:z,rowKey:e=>`${e.pipeline}:${e.schedule.code}`,reading:!1,next:null,onMore:$,noun:`firings`,onSelect:e=>void I(`/pipelines/${encodeURIComponent(e.pipeline)}`)})})})]})}function Q({title:e,to:t,children:n}){return(0,H.jsxs)(`section`,{className:`mb-6 space-y-2 last:mb-0`,children:[(0,H.jsx)(`div`,{className:`space-y-1`,children:(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:(0,H.jsx)(r,{to:t,className:`hover:text-primary`,children:e})})}),n]})}var $=()=>{},we=[{id:`status`,header:`Status`,cell:e=>(0,H.jsx)(k,{status:e.status})},{id:`pipeline`,header:`Pipeline`,cell:e=>(0,H.jsx)(`span`,{className:`font-mono text-sm`,children:v({code:e.pipeline}).title})},{id:`since`,header:`Since`,className:`text-right`,cell:e=>(0,H.jsx)(P,{className:`text-xs text-faint`,at:e.started_at??e.created_at})}],Te=[{id:`pipeline`,header:`Pipeline`,cell:e=>(0,H.jsx)(`span`,{className:`font-mono text-sm`,children:v({code:e.pipeline}).title})},{id:`schedule`,header:`Schedule`,cell:e=>{let t=v(e.schedule);return(0,H.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,H.jsx)(`span`,{className:p(`truncate text-xs`,t.named?`text-foreground`:`font-mono`),children:t.title}),t.code!==null&&(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:t.code})]})}},{id:`fires`,header:`Fires`,className:`text-right`,cell:e=>(0,H.jsx)(P,{className:`text-xs text-faint`,at:e.at})}];export{Ce as Dashboard};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{n}from"./PageState-BLuobMye.js";import{t as r}from"./WindowedPane-BUe4ZBNS.js";import{r as i,t as a}from"./utils-CT7ZGLfR.js";import{f as o}from"./paging-CpRIkEky.js";import{t as s}from"./identity-BNZxCf_y.js";import{D as c,_ as l,st as u}from"./index-Bp4KzK9w.js";import{t as d}from"./Description-MmXUnb-9.js";import{n as f,r as p}from"./Panel-CqrOYByl.js";import{t as m}from"./badge-BovCxjd1.js";import{f as h,n as g,u as _}from"./examples-DDWkSZ2u.js";import{t as v}from"./starters-CgC7I45V.js";var y=e(t(),1),b=i(),x=`The document`,S={connection:`connection`,schema:`schema`,block:`block`,pipeline:`pipeline`,storage:`storage`,worker:`worker tag`};function C({example:e,holdings:t,onUse:i}){let C=e.code,E=l((0,y.useCallback)(()=>_(C),[C])),D=s(e),O=(0,y.useMemo)(()=>h(e.requires,t),[e.requires,t]),k=g(e),A=e.tags.filter(e=>e!==v),j=E.value?.source??``;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsx)(`h2`,{className:a(`text-sm font-semibold`,!D.named&&`font-mono`),children:D.title}),D.code!==null&&(0,b.jsx)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:D.code}),(e.starter||k!==null)&&(0,b.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 pt-0.5`,children:[e.starter&&(0,b.jsx)(m,{variant:`outline`,children:`Starter`}),k!==null&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:k})]}),(0,b.jsx)(d,{text:e.description})]}),A.length>0&&(0,b.jsx)(`p`,{className:`flex flex-wrap items-center gap-1`,children:A.map(e=>(0,b.jsx)(c,{tag:e},e))}),(0,b.jsx)(p,{title:`Facts`,children:(0,b.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:[(0,b.jsx)(f,{term:`plugin`,detail:e.plugin}),(0,b.jsx)(f,{term:`shelf`,detail:e.shelf===``?`the root`:e.shelf}),E.value!==null&&(0,b.jsx)(f,{term:`path`,detail:(0,b.jsx)(`span`,{className:`font-mono break-all`,children:E.value.path})})]})}),(0,b.jsx)(p,{title:`Requires`,children:O.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This document requires nothing in particular of an instance.`}):(0,b.jsx)(`ul`,{className:`space-y-1 text-xs`,children:O.map(e=>(0,b.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,b.jsx)(`span`,{className:`text-faint`,children:S[e.kind]}),(0,b.jsx)(`span`,{className:`font-mono break-all`,children:e.name}),(0,b.jsx)(`span`,{className:a(`ml-auto shrink-0`,T(e)),children:w(e)})]},`${e.kind}:${e.name}`))})}),(0,b.jsx)(p,{title:`Source`,children:!E.read||E.problem!==null?(0,b.jsx)(n,{loading:!E.read,problem:E.problem,empty:!1,children:null}):(0,b.jsx)(r,{name:x,className:`overflow-hidden rounded-md border border-border`,windowed:(0,b.jsx)(u,{value:j,path:`example-${C}-window`,label:`${x}, in a window`,className:`min-h-0 flex-1`,readOnly:!0}),children:(0,b.jsx)(u,{value:j,path:`example-${C}`,label:x,className:`h-72 min-h-40`,readOnly:!0})})}),e.starter&&(0,b.jsx)(o,{size:`sm`,className:`self-start`,disabled:E.value===null,onClick:()=>{i(j,C)},children:`Use as starter`})]})}function w(e){return e.met===null?`not checked`:e.met?`here`:`missing`}function T(e){return e.met===null?`text-faint`:e.met?`text-good`:`text-critical`}export{C as ExamplePanel};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{n}from"./PageState-BLuobMye.js";import{t as r}from"./WindowedPane-Dc5ox2RS.js";import{r as i,t as a}from"./utils-CT7ZGLfR.js";import{f as o}from"./paging-CpRIkEky.js";import{t as s}from"./identity-BNZxCf_y.js";import{D as c,_ as l,st as u}from"./index-CzO6Janm.js";import{t as d}from"./Description-MmXUnb-9.js";import{n as f,r as p}from"./Panel-CqrOYByl.js";import{t as m}from"./badge-BovCxjd1.js";import{f as h,n as g,u as _}from"./examples-DB467CTN.js";import{t as v}from"./starters-CgC7I45V.js";var y=e(t(),1),b=i(),x=`The document`,S={connection:`connection`,schema:`schema`,block:`block`,pipeline:`pipeline`,storage:`storage`,worker:`worker tag`};function C({example:e,holdings:t,onUse:i}){let C=e.code,E=l((0,y.useCallback)(()=>_(C),[C])),D=s(e),O=(0,y.useMemo)(()=>h(e.requires,t),[e.requires,t]),k=g(e),A=e.tags.filter(e=>e!==v),j=E.value?.source??``;return(0,b.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsx)(`h2`,{className:a(`text-sm font-semibold`,!D.named&&`font-mono`),children:D.title}),D.code!==null&&(0,b.jsx)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:D.code}),(e.starter||k!==null)&&(0,b.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 pt-0.5`,children:[e.starter&&(0,b.jsx)(m,{variant:`outline`,children:`Starter`}),k!==null&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:k})]}),(0,b.jsx)(d,{text:e.description})]}),A.length>0&&(0,b.jsx)(`p`,{className:`flex flex-wrap items-center gap-1`,children:A.map(e=>(0,b.jsx)(c,{tag:e},e))}),(0,b.jsx)(p,{title:`Facts`,children:(0,b.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:[(0,b.jsx)(f,{term:`plugin`,detail:e.plugin}),(0,b.jsx)(f,{term:`shelf`,detail:e.shelf===``?`the root`:e.shelf}),E.value!==null&&(0,b.jsx)(f,{term:`path`,detail:(0,b.jsx)(`span`,{className:`font-mono break-all`,children:E.value.path})})]})}),(0,b.jsx)(p,{title:`Requires`,children:O.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This document requires nothing in particular of an instance.`}):(0,b.jsx)(`ul`,{className:`space-y-1 text-xs`,children:O.map(e=>(0,b.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,b.jsx)(`span`,{className:`text-faint`,children:S[e.kind]}),(0,b.jsx)(`span`,{className:`font-mono break-all`,children:e.name}),(0,b.jsx)(`span`,{className:a(`ml-auto shrink-0`,T(e)),children:w(e)})]},`${e.kind}:${e.name}`))})}),(0,b.jsx)(p,{title:`Source`,children:!E.read||E.problem!==null?(0,b.jsx)(n,{loading:!E.read,problem:E.problem,empty:!1,children:null}):(0,b.jsx)(r,{name:x,className:`overflow-hidden rounded-md border border-border`,windowed:(0,b.jsx)(u,{value:j,path:`example-${C}-window`,label:`${x}, in a window`,className:`min-h-0 flex-1`,readOnly:!0}),children:(0,b.jsx)(u,{value:j,path:`example-${C}`,label:x,className:`h-72 min-h-40`,readOnly:!0})})}),e.starter&&(0,b.jsx)(o,{size:`sm`,className:`self-start`,disabled:E.value===null,onClick:()=>{i(j,C)},children:`Use as starter`})]})}function w(e){return e.met===null?`not checked`:e.met?`here`:`missing`}function T(e){return e.met===null?`text-faint`:e.met?`text-good`:`text-critical`}export{C as ExamplePanel};