@hotmeshio/long-tail 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +1 -0
  2. package/build/api/escalations/helpers.js +4 -2
  3. package/build/api/settings.js +3 -0
  4. package/build/services/agent/index.d.ts +11 -0
  5. package/build/services/agent/index.js +32 -0
  6. package/build/services/agent/sql.d.ts +7 -0
  7. package/build/services/agent/sql.js +32 -1
  8. package/build/services/agent/subscription-sql.d.ts +6 -0
  9. package/build/services/agent/subscription-sql.js +32 -1
  10. package/build/services/agent/subscriptions.d.ts +6 -0
  11. package/build/services/agent/subscriptions.js +23 -0
  12. package/build/services/config/index.d.ts +1 -1
  13. package/build/services/config/index.js +2 -1
  14. package/build/services/config/write.d.ts +10 -0
  15. package/build/services/config/write.js +49 -2
  16. package/build/services/domain/seed.d.ts +12 -5
  17. package/build/services/domain/seed.js +25 -6
  18. package/build/services/mcp/db.d.ts +16 -0
  19. package/build/services/mcp/db.js +24 -0
  20. package/build/services/mcp/sql.d.ts +8 -0
  21. package/build/services/mcp/sql.js +24 -1
  22. package/build/services/role/seed.d.ts +21 -0
  23. package/build/services/role/seed.js +113 -0
  24. package/build/services/role/sql.d.ts +8 -0
  25. package/build/services/role/sql.js +24 -1
  26. package/build/services/topics/index.d.ts +2 -0
  27. package/build/services/topics/index.js +7 -0
  28. package/build/services/topics/sql.d.ts +2 -0
  29. package/build/services/topics/sql.js +5 -1
  30. package/build/services/topics/system-topics.d.ts +3 -2
  31. package/build/services/topics/system-topics.js +4 -3
  32. package/build/services/user/index.d.ts +1 -1
  33. package/build/services/user/index.js +2 -1
  34. package/build/services/user/roles.d.ts +8 -0
  35. package/build/services/user/roles.js +29 -0
  36. package/build/services/user/sql.d.ts +6 -0
  37. package/build/services/user/sql.js +9 -1
  38. package/build/services/user/sso-provision.js +14 -3
  39. package/build/start/apply-report.d.ts +26 -0
  40. package/build/start/apply-report.js +65 -0
  41. package/build/start/config.js +8 -1
  42. package/build/start/workers.js +170 -33
  43. package/build/tsconfig.tsbuildinfo +1 -1
  44. package/build/types/auth.d.ts +27 -1
  45. package/build/types/index.d.ts +1 -1
  46. package/build/types/startup.d.ts +108 -4
  47. package/dashboard/dist/assets/{AdminDashboard-DpTZG5EL.js → AdminDashboard-D2unnS2b.js} +2 -2
  48. package/dashboard/dist/assets/{AdminDashboard-DpTZG5EL.js.map → AdminDashboard-D2unnS2b.js.map} +1 -1
  49. package/dashboard/dist/assets/{AgentConfigPage-DVTL0NvC.js → AgentConfigPage-CBkf403g.js} +2 -2
  50. package/dashboard/dist/assets/{AgentConfigPage-DVTL0NvC.js.map → AgentConfigPage-CBkf403g.js.map} +1 -1
  51. package/dashboard/dist/assets/{AgentDetailPage-DOLKNPJl.js → AgentDetailPage-CAIU3yzo.js} +2 -2
  52. package/dashboard/dist/assets/{AgentDetailPage-DOLKNPJl.js.map → AgentDetailPage-CAIU3yzo.js.map} +1 -1
  53. package/dashboard/dist/assets/{AgentsPage-DiOZu6Xb.js → AgentsPage-qP9fWMyT.js} +2 -2
  54. package/dashboard/dist/assets/{AgentsPage-DiOZu6Xb.js.map → AgentsPage-qP9fWMyT.js.map} +1 -1
  55. package/dashboard/dist/assets/{AvailableEscalationsPage-CY5lfx27.js → AvailableEscalationsPage-DvWaiafI.js} +2 -2
  56. package/dashboard/dist/assets/{AvailableEscalationsPage-CY5lfx27.js.map → AvailableEscalationsPage-DvWaiafI.js.map} +1 -1
  57. package/dashboard/dist/assets/{BotPicker-ButjLJr2.js → BotPicker-BN-MKITV.js} +2 -2
  58. package/dashboard/dist/assets/{BotPicker-ButjLJr2.js.map → BotPicker-BN-MKITV.js.map} +1 -1
  59. package/dashboard/dist/assets/{CapabilitiesPage-CW_r2OlX.js → CapabilitiesPage-CJfmWokN.js} +2 -2
  60. package/dashboard/dist/assets/{CapabilitiesPage-CW_r2OlX.js.map → CapabilitiesPage-CJfmWokN.js.map} +1 -1
  61. package/dashboard/dist/assets/{CollapsibleSection-BOGRyCfm.js → CollapsibleSection-BvMHlHyt.js} +2 -2
  62. package/dashboard/dist/assets/{CollapsibleSection-BOGRyCfm.js.map → CollapsibleSection-BvMHlHyt.js.map} +1 -1
  63. package/dashboard/dist/assets/{CountdownTimer-UcHYZSg1.js → CountdownTimer-By4rbMDN.js} +2 -2
  64. package/dashboard/dist/assets/{CountdownTimer-UcHYZSg1.js.map → CountdownTimer-By4rbMDN.js.map} +1 -1
  65. package/dashboard/dist/assets/{CredentialsPage-A7OFYVsX.js → CredentialsPage-2TvvRwGJ.js} +2 -2
  66. package/dashboard/dist/assets/{CredentialsPage-A7OFYVsX.js.map → CredentialsPage-2TvvRwGJ.js.map} +1 -1
  67. package/dashboard/dist/assets/{CronLabel-Dve2Udsm.js → CronLabel-HxmsDSnV.js} +2 -2
  68. package/dashboard/dist/assets/{CronLabel-Dve2Udsm.js.map → CronLabel-HxmsDSnV.js.map} +1 -1
  69. package/dashboard/dist/assets/{CustomDurationPicker-BoPrA-Em.js → CustomDurationPicker-8Ao-1pKA.js} +2 -2
  70. package/dashboard/dist/assets/{CustomDurationPicker-BoPrA-Em.js.map → CustomDurationPicker-8Ao-1pKA.js.map} +1 -1
  71. package/dashboard/dist/assets/{ElapsedCell-B114P5mb.js → ElapsedCell-BkRu9Xpd.js} +2 -2
  72. package/dashboard/dist/assets/{ElapsedCell-B114P5mb.js.map → ElapsedCell-BkRu9Xpd.js.map} +1 -1
  73. package/dashboard/dist/assets/{EntityTimelinePanel-BqDWyOa9.js → EntityTimelinePanel--E6hLMCM.js} +2 -2
  74. package/dashboard/dist/assets/{EntityTimelinePanel-BqDWyOa9.js.map → EntityTimelinePanel--E6hLMCM.js.map} +1 -1
  75. package/dashboard/dist/assets/{EscalationListSchemaPage-DyyTyghx.js → EscalationListSchemaPage-CdFtqEEX.js} +2 -2
  76. package/dashboard/dist/assets/{EscalationListSchemaPage-DyyTyghx.js.map → EscalationListSchemaPage-CdFtqEEX.js.map} +1 -1
  77. package/dashboard/dist/assets/{EscalationSchemaPage-DLQG6EXQ.js → EscalationSchemaPage-BsjS2axz.js} +2 -2
  78. package/dashboard/dist/assets/{EscalationSchemaPage-DLQG6EXQ.js.map → EscalationSchemaPage-BsjS2axz.js.map} +1 -1
  79. package/dashboard/dist/assets/{EscalationsOverview-RrbkkEU0.js → EscalationsOverview-FL-xteVc.js} +2 -2
  80. package/dashboard/dist/assets/{EscalationsOverview-RrbkkEU0.js.map → EscalationsOverview-FL-xteVc.js.map} +1 -1
  81. package/dashboard/dist/assets/{EventTable-DOxubt7O.js → EventTable-BOcgZ78i.js} +2 -2
  82. package/dashboard/dist/assets/{EventTable-DOxubt7O.js.map → EventTable-BOcgZ78i.js.map} +1 -1
  83. package/dashboard/dist/assets/{FilterBar-y659Gc3X.js → FilterBar-DfCiCmm-.js} +2 -2
  84. package/dashboard/dist/assets/{FilterBar-y659Gc3X.js.map → FilterBar-DfCiCmm-.js.map} +1 -1
  85. package/dashboard/dist/assets/{GraphInvokePage-oHLgSAl6.js → GraphInvokePage-DfVeiN-8.js} +2 -2
  86. package/dashboard/dist/assets/{GraphInvokePage-oHLgSAl6.js.map → GraphInvokePage-DfVeiN-8.js.map} +1 -1
  87. package/dashboard/dist/assets/{HomePage-C9FUpD7x.js → HomePage-C2IhF9WB.js} +2 -2
  88. package/dashboard/dist/assets/{HomePage-C9FUpD7x.js.map → HomePage-C2IhF9WB.js.map} +1 -1
  89. package/dashboard/dist/assets/{ListToolbar-DfpSgWYU.js → ListToolbar-DA0PTOl5.js} +2 -2
  90. package/dashboard/dist/assets/{ListToolbar-DfpSgWYU.js.map → ListToolbar-DA0PTOl5.js.map} +1 -1
  91. package/dashboard/dist/assets/{McpOverview-6Ubpr9QS.js → McpOverview-DstPch5M.js} +2 -2
  92. package/dashboard/dist/assets/{McpOverview-6Ubpr9QS.js.map → McpOverview-DstPch5M.js.map} +1 -1
  93. package/dashboard/dist/assets/{McpQueryDetailPage-DFt-vQEp.js → McpQueryDetailPage-Csv0PKE0.js} +2 -2
  94. package/dashboard/dist/assets/{McpQueryDetailPage-DFt-vQEp.js.map → McpQueryDetailPage-Csv0PKE0.js.map} +1 -1
  95. package/dashboard/dist/assets/{McpQueryPage-DQiG0AE3.js → McpQueryPage-DxmqCkly.js} +2 -2
  96. package/dashboard/dist/assets/{McpQueryPage-DQiG0AE3.js.map → McpQueryPage-DxmqCkly.js.map} +1 -1
  97. package/dashboard/dist/assets/{McpRunDetailPage-BgsSegyP.js → McpRunDetailPage-CcJOlp_B.js} +2 -2
  98. package/dashboard/dist/assets/{McpRunDetailPage-BgsSegyP.js.map → McpRunDetailPage-CcJOlp_B.js.map} +1 -1
  99. package/dashboard/dist/assets/{McpRunsPage-tCMxspqS.js → McpRunsPage-BZCR043j.js} +2 -2
  100. package/dashboard/dist/assets/{McpRunsPage-tCMxspqS.js.map → McpRunsPage-BZCR043j.js.map} +1 -1
  101. package/dashboard/dist/assets/{OperationsPage-DUaRmEPa.js → OperationsPage-DMsPXITh.js} +2 -2
  102. package/dashboard/dist/assets/{OperationsPage-DUaRmEPa.js.map → OperationsPage-DMsPXITh.js.map} +1 -1
  103. package/dashboard/dist/assets/{OperatorDashboard-CayyjMcf.js → OperatorDashboard-DSloftQ5.js} +2 -2
  104. package/dashboard/dist/assets/{OperatorDashboard-CayyjMcf.js.map → OperatorDashboard-DSloftQ5.js.map} +1 -1
  105. package/dashboard/dist/assets/{PersonaDetailPage-DBcxfdbN.js → PersonaDetailPage-jDVRCLbU.js} +2 -2
  106. package/dashboard/dist/assets/{PersonaDetailPage-DBcxfdbN.js.map → PersonaDetailPage-jDVRCLbU.js.map} +1 -1
  107. package/dashboard/dist/assets/{PersonasPage-DPq0HQAB.js → PersonasPage-DnDDwXoy.js} +2 -2
  108. package/dashboard/dist/assets/{PersonasPage-DPq0HQAB.js.map → PersonasPage-DnDDwXoy.js.map} +1 -1
  109. package/dashboard/dist/assets/{ProcessDetailPage-QQZNNNMw.js → ProcessDetailPage-CfAUU6q2.js} +2 -2
  110. package/dashboard/dist/assets/{ProcessDetailPage-QQZNNNMw.js.map → ProcessDetailPage-CfAUU6q2.js.map} +1 -1
  111. package/dashboard/dist/assets/{ProcessesListPage-UKQMJ4Te.js → ProcessesListPage-CnAXzaVv.js} +2 -2
  112. package/dashboard/dist/assets/{ProcessesListPage-UKQMJ4Te.js.map → ProcessesListPage-CnAXzaVv.js.map} +1 -1
  113. package/dashboard/dist/assets/{RoleDetailPage-DT-3sSRD.js → RoleDetailPage-Dg1p6Qz_.js} +2 -2
  114. package/dashboard/dist/assets/{RoleDetailPage-DT-3sSRD.js.map → RoleDetailPage-Dg1p6Qz_.js.map} +1 -1
  115. package/dashboard/dist/assets/{RolesPage-DZg4niqL.js → RolesPage-DeRVQux8.js} +2 -2
  116. package/dashboard/dist/assets/{RolesPage-DZg4niqL.js.map → RolesPage-DeRVQux8.js.map} +1 -1
  117. package/dashboard/dist/assets/{RunAsSelector-DkcNR7L6.js → RunAsSelector-BFNqQGuG.js} +2 -2
  118. package/dashboard/dist/assets/{RunAsSelector-DkcNR7L6.js.map → RunAsSelector-BFNqQGuG.js.map} +1 -1
  119. package/dashboard/dist/assets/{ScanCodesPage-U-alpwWF.js → ScanCodesPage-D0GOdk5m.js} +2 -2
  120. package/dashboard/dist/assets/{ScanCodesPage-U-alpwWF.js.map → ScanCodesPage-D0GOdk5m.js.map} +1 -1
  121. package/dashboard/dist/assets/{ScanSchemeDetailPage-lXwlcraS.js → ScanSchemeDetailPage-vFqoe_P4.js} +2 -2
  122. package/dashboard/dist/assets/{ScanSchemeDetailPage-lXwlcraS.js.map → ScanSchemeDetailPage-vFqoe_P4.js.map} +1 -1
  123. package/dashboard/dist/assets/{ScanStationPage-DYMiTp-v.js → ScanStationPage-DH1ynTX9.js} +2 -2
  124. package/dashboard/dist/assets/{ScanStationPage-DYMiTp-v.js.map → ScanStationPage-DH1ynTX9.js.map} +1 -1
  125. package/dashboard/dist/assets/{StickyPagination-D896Wquq.js → StickyPagination-B99hVu95.js} +2 -2
  126. package/dashboard/dist/assets/{StickyPagination-D896Wquq.js.map → StickyPagination-B99hVu95.js.map} +1 -1
  127. package/dashboard/dist/assets/{StreamMessageDetail-DIh5qEGJ.js → StreamMessageDetail-DcDGISrv.js} +2 -2
  128. package/dashboard/dist/assets/{StreamMessageDetail-DIh5qEGJ.js.map → StreamMessageDetail-DcDGISrv.js.map} +1 -1
  129. package/dashboard/dist/assets/{SwimlaneTimeline-B8SucVj5.js → SwimlaneTimeline-BP3mSQAg.js} +2 -2
  130. package/dashboard/dist/assets/{SwimlaneTimeline-B8SucVj5.js.map → SwimlaneTimeline-BP3mSQAg.js.map} +1 -1
  131. package/dashboard/dist/assets/{TaskDetailPage-Di-z_ZE2.js → TaskDetailPage-_XWLJzt-.js} +2 -2
  132. package/dashboard/dist/assets/{TaskDetailPage-Di-z_ZE2.js.map → TaskDetailPage-_XWLJzt-.js.map} +1 -1
  133. package/dashboard/dist/assets/{TasksListPage-ClHGEdin.js → TasksListPage-iGriKiO2.js} +2 -2
  134. package/dashboard/dist/assets/{TasksListPage-ClHGEdin.js.map → TasksListPage-iGriKiO2.js.map} +1 -1
  135. package/dashboard/dist/assets/{TimeAgo-BSDHd9Xo.js → TimeAgo-BO33VeFl.js} +2 -2
  136. package/dashboard/dist/assets/{TimeAgo-BSDHd9Xo.js.map → TimeAgo-BO33VeFl.js.map} +1 -1
  137. package/dashboard/dist/assets/{TimestampCell-WQL3FxWl.js → TimestampCell-KAjX7w35.js} +2 -2
  138. package/dashboard/dist/assets/{TimestampCell-WQL3FxWl.js.map → TimestampCell-KAjX7w35.js.map} +1 -1
  139. package/dashboard/dist/assets/{ToolTestPanel-IVIkqZTi.js → ToolTestPanel-BchG2yC6.js} +2 -2
  140. package/dashboard/dist/assets/{ToolTestPanel-IVIkqZTi.js.map → ToolTestPanel-BchG2yC6.js.map} +1 -1
  141. package/dashboard/dist/assets/{TopicDetailPage-BOasQo68.js → TopicDetailPage-BaK8H0o1.js} +2 -2
  142. package/dashboard/dist/assets/{TopicDetailPage-BOasQo68.js.map → TopicDetailPage-BaK8H0o1.js.map} +1 -1
  143. package/dashboard/dist/assets/{TopicsPage-DV_orf_V.js → TopicsPage-DEyvm669.js} +2 -2
  144. package/dashboard/dist/assets/{TopicsPage-DV_orf_V.js.map → TopicsPage-DEyvm669.js.map} +1 -1
  145. package/dashboard/dist/assets/{UserName-rshjKBtm.js → UserName-BV6SKI9P.js} +2 -2
  146. package/dashboard/dist/assets/{UserName-rshjKBtm.js.map → UserName-BV6SKI9P.js.map} +1 -1
  147. package/dashboard/dist/assets/{WorkflowExecutionPage-BpNGLwbK.js → WorkflowExecutionPage-1sKoEFNC.js} +2 -2
  148. package/dashboard/dist/assets/{WorkflowExecutionPage-BpNGLwbK.js.map → WorkflowExecutionPage-1sKoEFNC.js.map} +1 -1
  149. package/dashboard/dist/assets/{WorkflowsDashboard-BAXt8gv_.js → WorkflowsDashboard-YTHDZZOD.js} +2 -2
  150. package/dashboard/dist/assets/{WorkflowsDashboard-BAXt8gv_.js.map → WorkflowsDashboard-YTHDZZOD.js.map} +1 -1
  151. package/dashboard/dist/assets/{WorkflowsOverview-DvOyzL6y.js → WorkflowsOverview-ucXPLTtm.js} +2 -2
  152. package/dashboard/dist/assets/{WorkflowsOverview-DvOyzL6y.js.map → WorkflowsOverview-ucXPLTtm.js.map} +1 -1
  153. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CraijGy6.js → YamlWorkflowDetailPage-C_RTZKqZ.js} +2 -2
  154. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CraijGy6.js.map → YamlWorkflowDetailPage-C_RTZKqZ.js.map} +1 -1
  155. package/dashboard/dist/assets/{YamlWorkflowsPage-CNz3ptmj.js → YamlWorkflowsPage-Usid3w2W.js} +2 -2
  156. package/dashboard/dist/assets/{YamlWorkflowsPage-CNz3ptmj.js.map → YamlWorkflowsPage-Usid3w2W.js.map} +1 -1
  157. package/dashboard/dist/assets/{agents-BswSJR-t.js → agents-BTDsRK8e.js} +2 -2
  158. package/dashboard/dist/assets/{agents-BswSJR-t.js.map → agents-BTDsRK8e.js.map} +1 -1
  159. package/dashboard/dist/assets/{bots-VzlLx_GQ.js → bots-DxLrfdfr.js} +2 -2
  160. package/dashboard/dist/assets/{bots-VzlLx_GQ.js.map → bots-DxLrfdfr.js.map} +1 -1
  161. package/dashboard/dist/assets/{capabilities-B0bNlTTA.js → capabilities-DbTmeW-S.js} +2 -2
  162. package/dashboard/dist/assets/{capabilities-B0bNlTTA.js.map → capabilities-DbTmeW-S.js.map} +1 -1
  163. package/dashboard/dist/assets/{controlplane-DBESTVZS.js → controlplane-CEBntAL4.js} +2 -2
  164. package/dashboard/dist/assets/{controlplane-DBESTVZS.js.map → controlplane-CEBntAL4.js.map} +1 -1
  165. package/dashboard/dist/assets/{escalation-columns-CoqsCdbP.js → escalation-columns-Carqdwoh.js} +2 -2
  166. package/dashboard/dist/assets/{escalation-columns-CoqsCdbP.js.map → escalation-columns-Carqdwoh.js.map} +1 -1
  167. package/dashboard/dist/assets/{index-DUfdCp8e.js → index-B2hz0pUh.js} +2 -2
  168. package/dashboard/dist/assets/{index-DUfdCp8e.js.map → index-B2hz0pUh.js.map} +1 -1
  169. package/dashboard/dist/assets/{index-DJS-hvDt.js → index-B9m7fA3M.js} +2 -2
  170. package/dashboard/dist/assets/{index-DJS-hvDt.js.map → index-B9m7fA3M.js.map} +1 -1
  171. package/dashboard/dist/assets/{index-C_lA7ghl.js → index-BhapT-Vl.js} +2 -2
  172. package/dashboard/dist/assets/{index-C_lA7ghl.js.map → index-BhapT-Vl.js.map} +1 -1
  173. package/dashboard/dist/assets/{index-DsDFZzqr.js → index-Bqm4zu46.js} +2 -2
  174. package/dashboard/dist/assets/{index-DsDFZzqr.js.map → index-Bqm4zu46.js.map} +1 -1
  175. package/dashboard/dist/assets/{index-Cd7jZylO.js → index-C0hSttF5.js} +2 -2
  176. package/dashboard/dist/assets/{index-Cd7jZylO.js.map → index-C0hSttF5.js.map} +1 -1
  177. package/dashboard/dist/assets/{index-ByUjwu37.js → index-CDkg6iOE.js} +2 -2
  178. package/dashboard/dist/assets/{index-ByUjwu37.js.map → index-CDkg6iOE.js.map} +1 -1
  179. package/dashboard/dist/assets/{index-Ci4lxPwS.js → index-CVBBkW8V.js} +2 -2
  180. package/dashboard/dist/assets/{index-Ci4lxPwS.js.map → index-CVBBkW8V.js.map} +1 -1
  181. package/dashboard/dist/assets/{index-DYDcjn-b.js → index-CgIBjZta.js} +2 -2
  182. package/dashboard/dist/assets/{index-DYDcjn-b.js.map → index-CgIBjZta.js.map} +1 -1
  183. package/dashboard/dist/assets/{index-Cqrp5B5S.js → index-DBXm49S6.js} +25 -25
  184. package/dashboard/dist/assets/index-DBXm49S6.js.map +1 -0
  185. package/dashboard/dist/assets/{index-BBXmIWKx.js → index-De8iV1y2.js} +2 -2
  186. package/dashboard/dist/assets/{index-BBXmIWKx.js.map → index-De8iV1y2.js.map} +1 -1
  187. package/dashboard/dist/assets/{index-D8ljRGIb.js → index-DsgjFRvA.js} +2 -2
  188. package/dashboard/dist/assets/{index-D8ljRGIb.js.map → index-DsgjFRvA.js.map} +1 -1
  189. package/dashboard/dist/assets/{index-BLzwfbZV.js → index-kes8V4Xw.js} +2 -2
  190. package/dashboard/dist/assets/{index-BLzwfbZV.js.map → index-kes8V4Xw.js.map} +1 -1
  191. package/dashboard/dist/assets/{index-CALocCAr.js → index-nwLh3CK2.js} +2 -2
  192. package/dashboard/dist/assets/{index-CALocCAr.js.map → index-nwLh3CK2.js.map} +1 -1
  193. package/dashboard/dist/assets/{knowledge-DB2DgDa_.js → knowledge-oFYAanUp.js} +2 -2
  194. package/dashboard/dist/assets/{knowledge-DB2DgDa_.js.map → knowledge-oFYAanUp.js.map} +1 -1
  195. package/dashboard/dist/assets/{mcp-D72yCeuf.js → mcp-C9Kw4Ow8.js} +2 -2
  196. package/dashboard/dist/assets/{mcp-D72yCeuf.js.map → mcp-C9Kw4Ow8.js.map} +1 -1
  197. package/dashboard/dist/assets/{mcp-query-Cyyc_0E8.js → mcp-query-BwzpZ91Z.js} +2 -2
  198. package/dashboard/dist/assets/{mcp-query-Cyyc_0E8.js.map → mcp-query-BwzpZ91Z.js.map} +1 -1
  199. package/dashboard/dist/assets/{personas-xMDV7yXb.js → personas-D5ehmtRb.js} +2 -2
  200. package/dashboard/dist/assets/{personas-xMDV7yXb.js.map → personas-D5ehmtRb.js.map} +1 -1
  201. package/dashboard/dist/assets/{pipelines-mlxfmi6m.js → pipelines-xgPKGEdD.js} +2 -2
  202. package/dashboard/dist/assets/{pipelines-mlxfmi6m.js.map → pipelines-xgPKGEdD.js.map} +1 -1
  203. package/dashboard/dist/assets/{tasks-CxgOp_9H.js → tasks-CLyrl-MU.js} +2 -2
  204. package/dashboard/dist/assets/{tasks-CxgOp_9H.js.map → tasks-CLyrl-MU.js.map} +1 -1
  205. package/dashboard/dist/assets/{topics-CFb_L0Vs.js → topics-B_gO7CQ0.js} +2 -2
  206. package/dashboard/dist/assets/{topics-CFb_L0Vs.js.map → topics-B_gO7CQ0.js.map} +1 -1
  207. package/dashboard/dist/assets/{useEventHooks-nC5kH-QW.js → useEventHooks-BdWYm63U.js} +2 -2
  208. package/dashboard/dist/assets/{useEventHooks-nC5kH-QW.js.map → useEventHooks-BdWYm63U.js.map} +1 -1
  209. package/dashboard/dist/assets/{useNamespace-DQeDgRFR.js → useNamespace-C238M4Qn.js} +2 -2
  210. package/dashboard/dist/assets/{useNamespace-DQeDgRFR.js.map → useNamespace-C238M4Qn.js.map} +1 -1
  211. package/dashboard/dist/assets/{useYamlActivityEvents-BuGC3oBE.js → useYamlActivityEvents-B2ryEK4S.js} +2 -2
  212. package/dashboard/dist/assets/{useYamlActivityEvents-BuGC3oBE.js.map → useYamlActivityEvents-B2ryEK4S.js.map} +1 -1
  213. package/dashboard/dist/assets/{users-BZUTtM_6.js → users-BFaTe6Mt.js} +2 -2
  214. package/dashboard/dist/assets/{users-BZUTtM_6.js.map → users-BFaTe6Mt.js.map} +1 -1
  215. package/dashboard/dist/assets/{workflows-DWhaZWVK.js → workflows-DXz7tZxp.js} +2 -2
  216. package/dashboard/dist/assets/{workflows-DWhaZWVK.js.map → workflows-DXz7tZxp.js.map} +1 -1
  217. package/dashboard/dist/assets/{yaml-workflows-C1TeDIIk.js → yaml-workflows-u3xuRAnS.js} +2 -2
  218. package/dashboard/dist/assets/{yaml-workflows-C1TeDIIk.js.map → yaml-workflows-u3xuRAnS.js.map} +1 -1
  219. package/dashboard/dist/index.html +1 -1
  220. package/docs/code-owned-configuration.md +131 -0
  221. package/package.json +1 -1
  222. package/dashboard/dist/assets/index-Cqrp5B5S.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{c as k,u as R,b as O,j as e,a as d}from"./vendor-query-RUZdMvN6.js";import{P as F}from"./PageHeader-BpeBHqyc.js";import{g as b}from"./index-Cqrp5B5S.js";import{M}from"./Modal-BU7No9NH.js";import{R as g,C}from"./constants-BHkpVaqx.js";import{aX as E,aG as T,aD as W,J as j,T as D,ap as I}from"./vendor-icons-BPsNpK3Y.js";import"./vendor-react-CdqEC2zv.js";function $(){return R({queryKey:["maintenance"],queryFn:()=>b("/config/maintenance")})}function _(){const t=O();return k({mutationFn:r=>b("/config/maintenance",{method:"PUT",body:JSON.stringify(r)}),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenance"]})}})}function q(){return k({mutationFn:t=>b("/dba/prune",{method:"POST",body:JSON.stringify(t)})})}function v({checked:t,onToggle:r,label:a,hint:s,safety:i,value:l,onChange:c}){const n=i==="safe"?W:i==="moderate"?E:T,o=i==="safe"?"text-status-success":i==="moderate"?"text-status-warning":"text-status-error",p=i==="safe"?"Safe":i==="moderate"?"Careful":"Permanent";return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 rounded border-border accent-accent shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:a}),e.jsxs("span",{className:`flex items-center gap-0.5 text-2xs ${o}`,children:[e.jsx(n,{className:"w-3 h-3",strokeWidth:1.5}),p]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:s})]})]}),e.jsx("select",{value:l,onChange:x=>c(x.target.value),disabled:!t,className:`select text-xs w-36 transition-opacity ${t?"":"opacity-40 cursor-not-allowed"}`,children:g.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))})]})}function L(){return e.jsxs("div",{className:"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed",children:"Stripping preserves workflow results and timeline data needed for the execution detail view. Transient jobs are internal bookkeeping that accumulates over time."})]})}const f={pruneJobs:!0,expire:"30 days",engineStreams:!0,engineStreamsExpire:"1 day",workerStreams:!0,workerStreamsExpire:"90 days",stripAttributes:!1,pruneTransient:!1};function N(t){return t.pruneJobs||t.engineStreams||t.workerStreams||t.stripAttributes||t.pruneTransient}function P({fields:t,onChange:r}){const a=(s,i)=>r({...t,[s]:i});return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Stream Messages"}),e.jsx("p",{className:"text-2xs text-text-tertiary mb-4",children:"Processed routing messages. Already consumed — safe to remove after a short retention window."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{checked:t.engineStreams,onToggle:s=>a("engineStreams",s),label:"Engine messages",hint:"Internal orchestration signals",safety:"safe",value:t.engineStreamsExpire,onChange:s=>a("engineStreamsExpire",s)}),e.jsx(v,{checked:t.workerStreams,onToggle:s=>a("workerStreams",s),label:"Worker messages",hint:"Activity dispatch and response payloads",safety:"safe",value:t.workerStreamsExpire,onChange:s=>a("workerStreamsExpire",s)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Completed Workflows"}),e.jsx("p",{className:"text-2xs text-text-tertiary mb-4",children:"Choose how to handle completed workflow records. Reducing strips step-level detail but keeps the workflow and its results. Deleting removes the record entirely."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:!t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!1,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Keep as-is"}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"No changes to completed workflow records."})]})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!0,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Reduce completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-2xs text-status-warning",children:[e.jsx(E,{className:"w-3 h-3",strokeWidth:1.5}),"Careful"]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"Strips step-level execution detail (activity inputs/outputs, internal state). Workflow results and timeline are preserved."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.stripAttributes||t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${!t.stripAttributes||t.pruneJobs?"opacity-40 cursor-not-allowed":""}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.pruneJobs,onChange:()=>r({...t,pruneJobs:!0,stripAttributes:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Delete completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-2xs text-status-error",children:[e.jsx(T,{className:"w-3 h-3",strokeWidth:1.5}),"Permanent"]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"Permanently removes workflow records. Results, timeline, and all execution data are deleted and cannot be recovered."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${t.pruneJobs?"":"opacity-40 cursor-not-allowed"}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]})]}),e.jsx(L,{})]})]})}function m({label:t,value:r}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-light text-text-primary",children:r.toLocaleString()}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:t})]})}function U(){const t=q(),[r,a]=d.useState(f),[s,i]=d.useState(null),[l,c]=d.useState(!1),n=()=>{i(null),t.mutate({expire:r.expire,jobs:r.pruneJobs,engineStreams:r.engineStreams,engineStreamsExpire:r.engineStreamsExpire,workerStreams:r.workerStreams,workerStreamsExpire:r.workerStreamsExpire,attributes:r.stripAttributes,pruneTransient:r.pruneTransient},{onSuccess:o=>{i(o),c(!1)}})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(P,{fields:r,onChange:a}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsx("p",{className:"text-2xs text-text-tertiary",children:N(r)?"This action permanently deletes data and cannot be undone.":"Select at least one operation to enable pruning."}),e.jsx("button",{onClick:()=>c(!0),disabled:!N(r)||t.isPending,className:"bg-status-error text-text-inverse px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0",children:t.isPending?"Pruning...":"Prune Now"})]}),s&&e.jsxs("div",{className:"bg-surface-sunken rounded-md px-4 py-3",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Results"}),e.jsxs("div",{className:"flex flex-wrap gap-6",children:[s.jobs!=null&&s.jobs>0&&e.jsx(m,{label:"Jobs deleted",value:s.jobs}),s.engineStreams!=null&&s.engineStreams>0&&e.jsx(m,{label:"Engine streams",value:s.engineStreams}),s.workerStreams!=null&&s.workerStreams>0&&e.jsx(m,{label:"Worker streams",value:s.workerStreams}),s.streams!=null&&s.engineStreams==null&&s.streams>0&&e.jsx(m,{label:"Streams",value:s.streams}),s.attributes!=null&&s.attributes>0&&e.jsx(m,{label:"Artifacts stripped",value:s.attributes}),s.transient!=null&&s.transient>0&&e.jsx(m,{label:"Transient deleted",value:s.transient}),s.marked!=null&&s.marked>0&&e.jsx(m,{label:"Marked pruned",value:s.marked}),Object.values(s).every(o=>!o||o===0)&&e.jsx("p",{className:"text-xs text-text-tertiary",children:"Nothing to prune within the selected retention windows."})]})]}),t.error&&e.jsx("p",{className:"text-xs text-status-error",children:t.error.message}),e.jsx(M,{open:l,onClose:()=>c(!1),title:"Confirm Prune",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"This will permanently delete data. This action cannot be undone."}),e.jsxs("ul",{className:"text-xs text-text-secondary space-y-1 list-disc list-inside",children:[r.pruneJobs&&e.jsxs("li",{children:["Delete jobs older than ",r.expire]}),r.engineStreams&&e.jsxs("li",{children:["Delete engine streams older than ",r.engineStreamsExpire]}),r.workerStreams&&e.jsxs("li",{children:["Delete worker streams older than ",r.workerStreamsExpire]}),r.stripAttributes&&e.jsx("li",{children:"Strip execution artifacts from completed jobs"}),r.pruneTransient&&e.jsx("li",{children:"Delete transient (entity-less) jobs"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:()=>c(!1),className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:n,className:"bg-status-error text-text-inverse px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity",disabled:t.isPending,children:t.isPending?"Pruning...":"Confirm Prune"})]})]})})]})}function w(t){var c;if(!((c=t==null?void 0:t.rules)!=null&&c.length))return f;const r=t.rules,a=r.find(n=>n.target==="streams"&&n.action==="delete"),s=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.hasEntity===!1),i=r.find(n=>n.target==="jobs"&&n.action==="prune"&&n.hasEntity===!0),l=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.pruned===!0);return{pruneJobs:!!l,expire:(l==null?void 0:l.olderThan)??"180 days",engineStreams:!!a,engineStreamsExpire:(a==null?void 0:a.olderThan)??"1 day",workerStreams:!!a,workerStreamsExpire:(a==null?void 0:a.olderThan)??"90 days",stripAttributes:!!i,pruneTransient:!!s}}function H(t){const r=[];return t.engineStreams&&r.push({target:"streams",action:"delete",olderThan:t.engineStreamsExpire}),t.workerStreams&&t.workerStreamsExpire!==t.engineStreamsExpire&&r.push({target:"streams",action:"delete",olderThan:t.workerStreamsExpire}),t.pruneTransient&&r.push({target:"jobs",action:"delete",olderThan:t.expire,hasEntity:!1}),t.stripAttributes&&r.push({target:"jobs",action:"prune",olderThan:t.expire,hasEntity:!0}),t.pruneJobs&&r.push({target:"jobs",action:"delete",olderThan:t.expire,pruned:!0}),r}function S(t){var r;return((r=C.find(a=>a.value===t))==null?void 0:r.label)??""}function K(){const{data:t,isLoading:r}=$(),a=_(),[s,i]=d.useState(""),[l,c]=d.useState(f),[n,o]=d.useState(""),p=d.useCallback(()=>{t!=null&&t.config&&(i(t.config.schedule),c(w(t.config)),o(JSON.stringify({schedule:t.config.schedule,fields:w(t.config)})))},[t]);d.useEffect(()=>{p()},[p]);const x=JSON.stringify({schedule:s,fields:l}),y=n!==""&&x!==n,h=(t==null?void 0:t.active)??!1,J=()=>{const u=H(l);a.mutate({schedule:s,rules:u},{onSuccess:()=>{o(JSON.stringify({schedule:s,fields:l}))}})},A=()=>{p()};return r?e.jsx("div",{className:"animate-pulse h-40 bg-surface-sunken rounded"}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 @split:grid-cols-[1fr_auto] gap-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"Schedule"}),e.jsxs("div",{className:"flex items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-2xs text-text-tertiary mb-1",children:"Cron Expression"}),e.jsx("input",{type:"text",value:s,onChange:u=>i(u.target.value),placeholder:"0 2 * * *",className:"input text-xs font-mono w-48"})]}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 h-8",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full dot-ring ${h?"bg-status-success":"bg-text-tertiary"}`}),e.jsx("span",{className:`text-xs ${h?"text-status-success":"text-text-tertiary"}`,children:h?"Active":"Inactive"})]})}),S(s)&&e.jsx("p",{className:"text-xs text-text-tertiary h-8 flex items-center",children:S(s)})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:C.map(u=>e.jsx("button",{type:"button",onClick:()=>i(u.value),className:`px-2.5 py-1 text-2xs rounded-full transition-colors ${s===u.value?"bg-accent/10 text-accent font-medium":"bg-surface-sunken text-text-tertiary hover:text-text-secondary"}`,children:u.label},u.value))})]}),e.jsxs("div",{className:"lg:w-72",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"How It Works"}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed",children:"Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively since they only contain internal routing data. Worker streams should be retained longer to preserve execution playback and input enrichment."})]})]})]}),e.jsx(P,{fields:l,onChange:c}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y&&e.jsx("button",{onClick:A,className:"text-2xs text-text-tertiary hover:text-text-primary transition-colors",children:"Revert changes"}),a.error&&e.jsx("p",{className:"text-xs text-status-error",children:a.error.message})]}),e.jsx("button",{onClick:J,disabled:!y||!s.trim()||a.isPending,className:"btn-primary text-xs disabled:opacity-40 shrink-0",children:a.isPending?"Saving...":"Save Schedule"})]})]})}function Q({mode:t,onChange:r}){const a=(s,i,l)=>e.jsxs("button",{onClick:()=>r(s),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${t===s?"bg-accent/10 text-accent font-medium":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[i,l]});return e.jsxs("div",{className:"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit",children:[a("prune",e.jsx(D,{className:"w-3.5 h-3.5"}),"Prune Now"),a("schedule",e.jsx(I,{className:"w-3.5 h-3.5"}),"Schedule")]})}function ee(){const[t,r]=d.useState("schedule");return e.jsxs("div",{children:[e.jsx(F,{title:"DB Maintenance",docsHash:"#docs:dashboard.md:db-maintenance",actions:e.jsx(Q,{mode:t,onChange:r})}),e.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10",children:[e.jsx(j,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-text-secondary leading-relaxed",children:"Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are always safe to prune, workflow reduction preserves results, and deletion is permanent."})]}),t==="prune"?e.jsx(U,{}):e.jsx(K,{})]})}export{ee as MaintenancePage};
2
- //# sourceMappingURL=index-BLzwfbZV.js.map
1
+ import{c as k,u as R,b as O,j as e,a as d}from"./vendor-query-RUZdMvN6.js";import{P as F}from"./PageHeader-BpeBHqyc.js";import{g as b}from"./index-DBXm49S6.js";import{M}from"./Modal-BU7No9NH.js";import{R as g,C}from"./constants-BHkpVaqx.js";import{aX as E,aG as T,aD as W,J as j,T as D,ap as I}from"./vendor-icons-BPsNpK3Y.js";import"./vendor-react-CdqEC2zv.js";function $(){return R({queryKey:["maintenance"],queryFn:()=>b("/config/maintenance")})}function _(){const t=O();return k({mutationFn:r=>b("/config/maintenance",{method:"PUT",body:JSON.stringify(r)}),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenance"]})}})}function q(){return k({mutationFn:t=>b("/dba/prune",{method:"POST",body:JSON.stringify(t)})})}function v({checked:t,onToggle:r,label:a,hint:s,safety:i,value:l,onChange:c}){const n=i==="safe"?W:i==="moderate"?E:T,o=i==="safe"?"text-status-success":i==="moderate"?"text-status-warning":"text-status-error",p=i==="safe"?"Safe":i==="moderate"?"Careful":"Permanent";return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 rounded border-border accent-accent shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:a}),e.jsxs("span",{className:`flex items-center gap-0.5 text-2xs ${o}`,children:[e.jsx(n,{className:"w-3 h-3",strokeWidth:1.5}),p]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:s})]})]}),e.jsx("select",{value:l,onChange:x=>c(x.target.value),disabled:!t,className:`select text-xs w-36 transition-opacity ${t?"":"opacity-40 cursor-not-allowed"}`,children:g.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))})]})}function L(){return e.jsxs("div",{className:"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed",children:"Stripping preserves workflow results and timeline data needed for the execution detail view. Transient jobs are internal bookkeeping that accumulates over time."})]})}const f={pruneJobs:!0,expire:"30 days",engineStreams:!0,engineStreamsExpire:"1 day",workerStreams:!0,workerStreamsExpire:"90 days",stripAttributes:!1,pruneTransient:!1};function N(t){return t.pruneJobs||t.engineStreams||t.workerStreams||t.stripAttributes||t.pruneTransient}function P({fields:t,onChange:r}){const a=(s,i)=>r({...t,[s]:i});return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Stream Messages"}),e.jsx("p",{className:"text-2xs text-text-tertiary mb-4",children:"Processed routing messages. Already consumed — safe to remove after a short retention window."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{checked:t.engineStreams,onToggle:s=>a("engineStreams",s),label:"Engine messages",hint:"Internal orchestration signals",safety:"safe",value:t.engineStreamsExpire,onChange:s=>a("engineStreamsExpire",s)}),e.jsx(v,{checked:t.workerStreams,onToggle:s=>a("workerStreams",s),label:"Worker messages",hint:"Activity dispatch and response payloads",safety:"safe",value:t.workerStreamsExpire,onChange:s=>a("workerStreamsExpire",s)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Completed Workflows"}),e.jsx("p",{className:"text-2xs text-text-tertiary mb-4",children:"Choose how to handle completed workflow records. Reducing strips step-level detail but keeps the workflow and its results. Deleting removes the record entirely."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:!t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!1,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Keep as-is"}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"No changes to completed workflow records."})]})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!0,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Reduce completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-2xs text-status-warning",children:[e.jsx(E,{className:"w-3 h-3",strokeWidth:1.5}),"Careful"]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"Strips step-level execution detail (activity inputs/outputs, internal state). Workflow results and timeline are preserved."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.stripAttributes||t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${!t.stripAttributes||t.pruneJobs?"opacity-40 cursor-not-allowed":""}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.pruneJobs,onChange:()=>r({...t,pruneJobs:!0,stripAttributes:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Delete completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-2xs text-status-error",children:[e.jsx(T,{className:"w-3 h-3",strokeWidth:1.5}),"Permanent"]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"Permanently removes workflow records. Results, timeline, and all execution data are deleted and cannot be recovered."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${t.pruneJobs?"":"opacity-40 cursor-not-allowed"}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]})]}),e.jsx(L,{})]})]})}function m({label:t,value:r}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-light text-text-primary",children:r.toLocaleString()}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:t})]})}function U(){const t=q(),[r,a]=d.useState(f),[s,i]=d.useState(null),[l,c]=d.useState(!1),n=()=>{i(null),t.mutate({expire:r.expire,jobs:r.pruneJobs,engineStreams:r.engineStreams,engineStreamsExpire:r.engineStreamsExpire,workerStreams:r.workerStreams,workerStreamsExpire:r.workerStreamsExpire,attributes:r.stripAttributes,pruneTransient:r.pruneTransient},{onSuccess:o=>{i(o),c(!1)}})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(P,{fields:r,onChange:a}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsx("p",{className:"text-2xs text-text-tertiary",children:N(r)?"This action permanently deletes data and cannot be undone.":"Select at least one operation to enable pruning."}),e.jsx("button",{onClick:()=>c(!0),disabled:!N(r)||t.isPending,className:"bg-status-error text-text-inverse px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0",children:t.isPending?"Pruning...":"Prune Now"})]}),s&&e.jsxs("div",{className:"bg-surface-sunken rounded-md px-4 py-3",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Results"}),e.jsxs("div",{className:"flex flex-wrap gap-6",children:[s.jobs!=null&&s.jobs>0&&e.jsx(m,{label:"Jobs deleted",value:s.jobs}),s.engineStreams!=null&&s.engineStreams>0&&e.jsx(m,{label:"Engine streams",value:s.engineStreams}),s.workerStreams!=null&&s.workerStreams>0&&e.jsx(m,{label:"Worker streams",value:s.workerStreams}),s.streams!=null&&s.engineStreams==null&&s.streams>0&&e.jsx(m,{label:"Streams",value:s.streams}),s.attributes!=null&&s.attributes>0&&e.jsx(m,{label:"Artifacts stripped",value:s.attributes}),s.transient!=null&&s.transient>0&&e.jsx(m,{label:"Transient deleted",value:s.transient}),s.marked!=null&&s.marked>0&&e.jsx(m,{label:"Marked pruned",value:s.marked}),Object.values(s).every(o=>!o||o===0)&&e.jsx("p",{className:"text-xs text-text-tertiary",children:"Nothing to prune within the selected retention windows."})]})]}),t.error&&e.jsx("p",{className:"text-xs text-status-error",children:t.error.message}),e.jsx(M,{open:l,onClose:()=>c(!1),title:"Confirm Prune",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"This will permanently delete data. This action cannot be undone."}),e.jsxs("ul",{className:"text-xs text-text-secondary space-y-1 list-disc list-inside",children:[r.pruneJobs&&e.jsxs("li",{children:["Delete jobs older than ",r.expire]}),r.engineStreams&&e.jsxs("li",{children:["Delete engine streams older than ",r.engineStreamsExpire]}),r.workerStreams&&e.jsxs("li",{children:["Delete worker streams older than ",r.workerStreamsExpire]}),r.stripAttributes&&e.jsx("li",{children:"Strip execution artifacts from completed jobs"}),r.pruneTransient&&e.jsx("li",{children:"Delete transient (entity-less) jobs"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:()=>c(!1),className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:n,className:"bg-status-error text-text-inverse px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity",disabled:t.isPending,children:t.isPending?"Pruning...":"Confirm Prune"})]})]})})]})}function w(t){var c;if(!((c=t==null?void 0:t.rules)!=null&&c.length))return f;const r=t.rules,a=r.find(n=>n.target==="streams"&&n.action==="delete"),s=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.hasEntity===!1),i=r.find(n=>n.target==="jobs"&&n.action==="prune"&&n.hasEntity===!0),l=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.pruned===!0);return{pruneJobs:!!l,expire:(l==null?void 0:l.olderThan)??"180 days",engineStreams:!!a,engineStreamsExpire:(a==null?void 0:a.olderThan)??"1 day",workerStreams:!!a,workerStreamsExpire:(a==null?void 0:a.olderThan)??"90 days",stripAttributes:!!i,pruneTransient:!!s}}function H(t){const r=[];return t.engineStreams&&r.push({target:"streams",action:"delete",olderThan:t.engineStreamsExpire}),t.workerStreams&&t.workerStreamsExpire!==t.engineStreamsExpire&&r.push({target:"streams",action:"delete",olderThan:t.workerStreamsExpire}),t.pruneTransient&&r.push({target:"jobs",action:"delete",olderThan:t.expire,hasEntity:!1}),t.stripAttributes&&r.push({target:"jobs",action:"prune",olderThan:t.expire,hasEntity:!0}),t.pruneJobs&&r.push({target:"jobs",action:"delete",olderThan:t.expire,pruned:!0}),r}function S(t){var r;return((r=C.find(a=>a.value===t))==null?void 0:r.label)??""}function K(){const{data:t,isLoading:r}=$(),a=_(),[s,i]=d.useState(""),[l,c]=d.useState(f),[n,o]=d.useState(""),p=d.useCallback(()=>{t!=null&&t.config&&(i(t.config.schedule),c(w(t.config)),o(JSON.stringify({schedule:t.config.schedule,fields:w(t.config)})))},[t]);d.useEffect(()=>{p()},[p]);const x=JSON.stringify({schedule:s,fields:l}),y=n!==""&&x!==n,h=(t==null?void 0:t.active)??!1,J=()=>{const u=H(l);a.mutate({schedule:s,rules:u},{onSuccess:()=>{o(JSON.stringify({schedule:s,fields:l}))}})},A=()=>{p()};return r?e.jsx("div",{className:"animate-pulse h-40 bg-surface-sunken rounded"}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 @split:grid-cols-[1fr_auto] gap-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"Schedule"}),e.jsxs("div",{className:"flex items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-2xs text-text-tertiary mb-1",children:"Cron Expression"}),e.jsx("input",{type:"text",value:s,onChange:u=>i(u.target.value),placeholder:"0 2 * * *",className:"input text-xs font-mono w-48"})]}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 h-8",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full dot-ring ${h?"bg-status-success":"bg-text-tertiary"}`}),e.jsx("span",{className:`text-xs ${h?"text-status-success":"text-text-tertiary"}`,children:h?"Active":"Inactive"})]})}),S(s)&&e.jsx("p",{className:"text-xs text-text-tertiary h-8 flex items-center",children:S(s)})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:C.map(u=>e.jsx("button",{type:"button",onClick:()=>i(u.value),className:`px-2.5 py-1 text-2xs rounded-full transition-colors ${s===u.value?"bg-accent/10 text-accent font-medium":"bg-surface-sunken text-text-tertiary hover:text-text-secondary"}`,children:u.label},u.value))})]}),e.jsxs("div",{className:"lg:w-72",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"How It Works"}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed",children:"Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively since they only contain internal routing data. Worker streams should be retained longer to preserve execution playback and input enrichment."})]})]})]}),e.jsx(P,{fields:l,onChange:c}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y&&e.jsx("button",{onClick:A,className:"text-2xs text-text-tertiary hover:text-text-primary transition-colors",children:"Revert changes"}),a.error&&e.jsx("p",{className:"text-xs text-status-error",children:a.error.message})]}),e.jsx("button",{onClick:J,disabled:!y||!s.trim()||a.isPending,className:"btn-primary text-xs disabled:opacity-40 shrink-0",children:a.isPending?"Saving...":"Save Schedule"})]})]})}function Q({mode:t,onChange:r}){const a=(s,i,l)=>e.jsxs("button",{onClick:()=>r(s),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${t===s?"bg-accent/10 text-accent font-medium":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[i,l]});return e.jsxs("div",{className:"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit",children:[a("prune",e.jsx(D,{className:"w-3.5 h-3.5"}),"Prune Now"),a("schedule",e.jsx(I,{className:"w-3.5 h-3.5"}),"Schedule")]})}function ee(){const[t,r]=d.useState("schedule");return e.jsxs("div",{children:[e.jsx(F,{title:"DB Maintenance",docsHash:"#docs:dashboard.md:db-maintenance",actions:e.jsx(Q,{mode:t,onChange:r})}),e.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10",children:[e.jsx(j,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-text-secondary leading-relaxed",children:"Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are always safe to prune, workflow reduction preserves results, and deletion is permanent."})]}),t==="prune"?e.jsx(U,{}):e.jsx(K,{})]})}export{ee as MaintenancePage};
2
+ //# sourceMappingURL=index-kes8V4Xw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-BLzwfbZV.js","sources":["../../src/api/maintenance.ts","../../src/pages/admin/maintenance/controls.tsx","../../src/pages/admin/maintenance/PruneSection.tsx","../../src/pages/admin/maintenance/ScheduleSection.tsx","../../src/pages/admin/maintenance/MaintenancePage.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { apiFetch } from './client';\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MaintenanceRule {\n target: 'streams' | 'jobs';\n action: 'delete' | 'prune';\n olderThan: string;\n hasEntity?: boolean;\n pruned?: boolean;\n}\n\nexport interface MaintenanceConfig {\n schedule: string;\n rules: MaintenanceRule[];\n}\n\nexport interface PruneOptions {\n expire?: string;\n jobs?: boolean;\n streams?: boolean;\n engineStreams?: boolean;\n engineStreamsExpire?: string;\n workerStreams?: boolean;\n workerStreamsExpire?: string;\n attributes?: boolean;\n entities?: string[];\n pruneTransient?: boolean;\n keepHmark?: boolean;\n}\n\nexport interface PruneResult {\n jobs?: number;\n streams?: number;\n engineStreams?: number;\n workerStreams?: number;\n attributes?: number;\n transient?: number;\n marked?: number;\n}\n\n// ── Maintenance config ────────────────────────────────────────────────────────\n\nexport function useMaintenanceConfig() {\n return useQuery<{ config: MaintenanceConfig; active: boolean }>({\n queryKey: ['maintenance'],\n queryFn: () => apiFetch('/config/maintenance'),\n });\n}\n\nexport function useUpdateMaintenanceConfig() {\n const queryClient = useQueryClient();\n return useMutation<\n { config: MaintenanceConfig; restarted: boolean },\n Error,\n MaintenanceConfig\n >({\n mutationFn: (config) =>\n apiFetch('/config/maintenance', {\n method: 'PUT',\n body: JSON.stringify(config),\n }),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['maintenance'] });\n },\n });\n}\n\n// ── DBA operations ────────────────────────────────────────────────────────────\n\nexport function usePrune() {\n return useMutation<PruneResult, Error, PruneOptions>({\n mutationFn: (options) =>\n apiFetch('/dba/prune', {\n method: 'POST',\n body: JSON.stringify(options),\n }),\n });\n}\n\nexport function useDeploy() {\n return useMutation<{ ok: boolean }, Error, void>({\n mutationFn: () =>\n apiFetch('/dba/deploy', { method: 'POST' }),\n });\n}\n","import { Info, ShieldCheck, ShieldAlert, ShieldOff } from 'lucide-react';\nimport { RETENTION_PERIOD_OPTIONS } from '../../../lib/constants';\n\n// ── Retention row (checkbox + label + select) ───────────────────────────────\n\nexport function RetentionRow({ checked, onToggle, label, hint, safety, value, onChange }: {\n checked: boolean;\n onToggle: (v: boolean) => void;\n label: string;\n hint: string;\n safety: 'safe' | 'moderate' | 'destructive';\n value: string;\n onChange: (v: string) => void;\n}) {\n const SafetyIcon = safety === 'safe' ? ShieldCheck : safety === 'moderate' ? ShieldAlert : ShieldOff;\n const safetyColor = safety === 'safe' ? 'text-status-success' : safety === 'moderate' ? 'text-status-warning' : 'text-status-error';\n const safetyLabel = safety === 'safe' ? 'Safe' : safety === 'moderate' ? 'Careful' : 'Permanent';\n\n return (\n <div className=\"flex items-center gap-4\">\n <label className=\"flex items-center gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onToggle(e.target.checked)}\n className=\"w-4 h-4 rounded border-border accent-accent shrink-0\"\n />\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">{label}</span>\n <span className={`flex items-center gap-0.5 text-2xs ${safetyColor}`}>\n <SafetyIcon className=\"w-3 h-3\" strokeWidth={1.5} />\n {safetyLabel}\n </span>\n </div>\n <p className=\"text-2xs text-text-tertiary\">{hint}</p>\n </div>\n </label>\n <select\n value={value}\n onChange={(e) => onChange(e.target.value)}\n disabled={!checked}\n className={`select text-xs w-36 transition-opacity ${!checked ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n );\n}\n\n// ── Cleanup checkbox ────────────────────────────────────────────────────────\n\nexport function CleanupCheck({ checked, onChange, label, description, safety }: {\n checked: boolean;\n onChange: (v: boolean) => void;\n label: string;\n description: string;\n safety: 'safe' | 'moderate' | 'destructive';\n}) {\n const SafetyIcon = safety === 'safe' ? ShieldCheck : safety === 'moderate' ? ShieldAlert : ShieldOff;\n const safetyColor = safety === 'safe' ? 'text-status-success' : safety === 'moderate' ? 'text-status-warning' : 'text-status-error';\n const safetyLabel = safety === 'safe' ? 'Safe' : safety === 'moderate' ? 'Careful' : 'Permanent';\n\n return (\n <label className=\"flex items-start gap-2.5 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onChange(e.target.checked)}\n className=\"w-4 h-4 mt-0.5 rounded border-border accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">{label}</span>\n <span className={`flex items-center gap-0.5 text-2xs ${safetyColor}`}>\n <SafetyIcon className=\"w-3 h-3\" strokeWidth={1.5} />\n {safetyLabel}\n </span>\n </div>\n <p className=\"text-2xs text-text-tertiary\">{description}</p>\n </div>\n </label>\n );\n}\n\n// ── Cleanup callout ─────────────────────────────────────────────────────────\n\nexport function CleanupCallout() {\n return (\n <div className=\"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken\">\n <Info className=\"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5\" />\n <p className=\"text-2xs text-text-tertiary leading-relaxed\">\n Stripping preserves workflow results and timeline data needed for the execution detail view.\n Transient jobs are internal bookkeeping that accumulates over time.\n </p>\n </div>\n );\n}\n\n// ── Prune fields state shape (shared between both panels) ───────────────────\n\nexport interface PruneFields {\n pruneJobs: boolean;\n expire: string;\n engineStreams: boolean;\n engineStreamsExpire: string;\n workerStreams: boolean;\n workerStreamsExpire: string;\n stripAttributes: boolean;\n pruneTransient: boolean;\n}\n\nexport const DEFAULT_PRUNE_FIELDS: PruneFields = {\n pruneJobs: true,\n expire: '30 days',\n engineStreams: true,\n engineStreamsExpire: '1 day',\n workerStreams: true,\n workerStreamsExpire: '90 days',\n stripAttributes: false,\n pruneTransient: false,\n};\n\nexport function hasSelection(f: PruneFields): boolean {\n return f.pruneJobs || f.engineStreams || f.workerStreams || f.stripAttributes || f.pruneTransient;\n}\n\n// ── Prune fields editor (reused by both Prune Now and Schedule) ─────────────\n\nexport function PruneFieldsEditor({ fields, onChange }: {\n fields: PruneFields;\n onChange: (f: PruneFields) => void;\n}) {\n const set = <K extends keyof PruneFields>(key: K, value: PruneFields[K]) =>\n onChange({ ...fields, [key]: value });\n\n return (\n <div className=\"space-y-8\">\n {/* Stream messages — always safe to prune */}\n <div>\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1\">\n Stream Messages\n </p>\n <p className=\"text-2xs text-text-tertiary mb-4\">\n Processed routing messages. Already consumed — safe to remove after a short retention window.\n </p>\n <div className=\"space-y-3\">\n <RetentionRow\n checked={fields.engineStreams} onToggle={(v) => set('engineStreams', v)}\n label=\"Engine messages\" hint=\"Internal orchestration signals\"\n safety=\"safe\"\n value={fields.engineStreamsExpire} onChange={(v) => set('engineStreamsExpire', v)}\n />\n <RetentionRow\n checked={fields.workerStreams} onToggle={(v) => set('workerStreams', v)}\n label=\"Worker messages\" hint=\"Activity dispatch and response payloads\"\n safety=\"safe\"\n value={fields.workerStreamsExpire} onChange={(v) => set('workerStreamsExpire', v)}\n />\n </div>\n </div>\n\n {/* Workflow data — mutually exclusive: reduce OR delete */}\n <div>\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1\">\n Completed Workflows\n </p>\n <p className=\"text-2xs text-text-tertiary mb-4\">\n Choose how to handle completed workflow records. Reducing strips step-level detail\n but keeps the workflow and its results. Deleting removes the record entirely.\n </p>\n <div className=\"space-y-3\">\n <label className=\"flex items-start gap-2.5 cursor-pointer\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={!fields.stripAttributes && !fields.pruneJobs}\n onChange={() => onChange({ ...fields, stripAttributes: false, pruneJobs: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <span className=\"text-xs text-text-primary\">Keep as-is</span>\n <p className=\"text-2xs text-text-tertiary\">No changes to completed workflow records.</p>\n </div>\n </label>\n\n <div className=\"flex items-start gap-2.5\">\n <label className=\"flex items-start gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={fields.stripAttributes && !fields.pruneJobs}\n onChange={() => onChange({ ...fields, stripAttributes: true, pruneJobs: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">Reduce completed workflows</span>\n <span className=\"flex items-center gap-0.5 text-2xs text-status-warning\">\n <ShieldAlert className=\"w-3 h-3\" strokeWidth={1.5} />\n Careful\n </span>\n </div>\n <p className=\"text-2xs text-text-tertiary\">\n Strips step-level execution detail (activity inputs/outputs, internal state).\n Workflow results and timeline are preserved.\n </p>\n </div>\n </label>\n <select\n value={fields.expire}\n onChange={(e) => set('expire', e.target.value)}\n disabled={!fields.stripAttributes || fields.pruneJobs}\n className={`select text-xs w-36 transition-opacity mt-0.5 ${!fields.stripAttributes || fields.pruneJobs ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n\n <div className=\"flex items-start gap-2.5\">\n <label className=\"flex items-start gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={fields.pruneJobs}\n onChange={() => onChange({ ...fields, pruneJobs: true, stripAttributes: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">Delete completed workflows</span>\n <span className=\"flex items-center gap-0.5 text-2xs text-status-error\">\n <ShieldOff className=\"w-3 h-3\" strokeWidth={1.5} />\n Permanent\n </span>\n </div>\n <p className=\"text-2xs text-text-tertiary\">\n Permanently removes workflow records. Results, timeline, and all\n execution data are deleted and cannot be recovered.\n </p>\n </div>\n </label>\n <select\n value={fields.expire}\n onChange={(e) => set('expire', e.target.value)}\n disabled={!fields.pruneJobs}\n className={`select text-xs w-36 transition-opacity mt-0.5 ${!fields.pruneJobs ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n </div>\n <CleanupCallout />\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport { usePrune, type PruneResult } from '../../../api/maintenance';\nimport { Modal } from '../../../components/common/modal/Modal';\nimport { PruneFieldsEditor, DEFAULT_PRUNE_FIELDS, hasSelection, type PruneFields } from './controls';\n\nfunction ResultCard({ label, value }: { label: string; value: number }) {\n return (\n <div>\n <p className=\"text-lg font-light text-text-primary\">{value.toLocaleString()}</p>\n <p className=\"text-2xs text-text-tertiary\">{label}</p>\n </div>\n );\n}\n\nexport function PruneSection() {\n const prune = usePrune();\n const [fields, setFields] = useState<PruneFields>(DEFAULT_PRUNE_FIELDS);\n const [result, setResult] = useState<PruneResult | null>(null);\n const [showConfirm, setShowConfirm] = useState(false);\n\n const handlePrune = () => {\n setResult(null);\n prune.mutate(\n {\n expire: fields.expire,\n jobs: fields.pruneJobs,\n engineStreams: fields.engineStreams,\n engineStreamsExpire: fields.engineStreamsExpire,\n workerStreams: fields.workerStreams,\n workerStreamsExpire: fields.workerStreamsExpire,\n attributes: fields.stripAttributes,\n pruneTransient: fields.pruneTransient,\n },\n {\n onSuccess: (data) => {\n setResult(data);\n setShowConfirm(false);\n },\n },\n );\n };\n\n return (\n <div className=\"space-y-8\">\n <PruneFieldsEditor fields={fields} onChange={setFields} />\n\n {/* Action bar */}\n <div className=\"flex items-center justify-between pt-2 border-t border-surface-border\">\n <p className=\"text-2xs text-text-tertiary\">\n {!hasSelection(fields)\n ? 'Select at least one operation to enable pruning.'\n : 'This action permanently deletes data and cannot be undone.'}\n </p>\n <button\n onClick={() => setShowConfirm(true)}\n disabled={!hasSelection(fields) || prune.isPending}\n className=\"bg-status-error text-text-inverse px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0\"\n >\n {prune.isPending ? 'Pruning...' : 'Prune Now'}\n </button>\n </div>\n\n {/* Results */}\n {result && (\n <div className=\"bg-surface-sunken rounded-md px-4 py-3\">\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2\">\n Results\n </p>\n <div className=\"flex flex-wrap gap-6\">\n {result.jobs != null && result.jobs > 0 && <ResultCard label=\"Jobs deleted\" value={result.jobs} />}\n {result.engineStreams != null && result.engineStreams > 0 && <ResultCard label=\"Engine streams\" value={result.engineStreams} />}\n {result.workerStreams != null && result.workerStreams > 0 && <ResultCard label=\"Worker streams\" value={result.workerStreams} />}\n {result.streams != null && result.engineStreams == null && result.streams > 0 && <ResultCard label=\"Streams\" value={result.streams} />}\n {result.attributes != null && result.attributes > 0 && <ResultCard label=\"Artifacts stripped\" value={result.attributes} />}\n {result.transient != null && result.transient > 0 && <ResultCard label=\"Transient deleted\" value={result.transient} />}\n {result.marked != null && result.marked > 0 && <ResultCard label=\"Marked pruned\" value={result.marked} />}\n {Object.values(result).every((v) => !v || v === 0) && (\n <p className=\"text-xs text-text-tertiary\">Nothing to prune within the selected retention windows.</p>\n )}\n </div>\n </div>\n )}\n\n {prune.error && (\n <p className=\"text-xs text-status-error\">{(prune.error as Error).message}</p>\n )}\n\n {/* Confirm modal */}\n <Modal open={showConfirm} onClose={() => setShowConfirm(false)} title=\"Confirm Prune\">\n <div className=\"space-y-4\">\n <p className=\"text-sm text-text-secondary\">\n This will permanently delete data. This action cannot be undone.\n </p>\n <ul className=\"text-xs text-text-secondary space-y-1 list-disc list-inside\">\n {fields.pruneJobs && <li>Delete jobs older than {fields.expire}</li>}\n {fields.engineStreams && <li>Delete engine streams older than {fields.engineStreamsExpire}</li>}\n {fields.workerStreams && <li>Delete worker streams older than {fields.workerStreamsExpire}</li>}\n {fields.stripAttributes && <li>Strip execution artifacts from completed jobs</li>}\n {fields.pruneTransient && <li>Delete transient (entity-less) jobs</li>}\n </ul>\n <div className=\"flex justify-end gap-3 pt-2\">\n <button onClick={() => setShowConfirm(false)} className=\"btn-secondary text-xs\">Cancel</button>\n <button\n onClick={handlePrune}\n className=\"bg-status-error text-text-inverse px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity\"\n disabled={prune.isPending}\n >\n {prune.isPending ? 'Pruning...' : 'Confirm Prune'}\n </button>\n </div>\n </div>\n </Modal>\n </div>\n );\n}\n","import { useState, useEffect, useCallback } from 'react';\nimport { Info } from 'lucide-react';\nimport {\n useMaintenanceConfig,\n useUpdateMaintenanceConfig,\n type MaintenanceConfig,\n} from '../../../api/maintenance';\nimport { CRON_PRESETS } from '../../../lib/constants';\nimport { PruneFieldsEditor, DEFAULT_PRUNE_FIELDS, type PruneFields } from './controls';\n\n// ── Helpers ─────────────────────────────────────────────────────────────────\n\n/** Convert a MaintenanceConfig (rules array) into PruneFields for the editor. */\nfunction configToFields(config: MaintenanceConfig | undefined): PruneFields {\n if (!config?.rules?.length) return DEFAULT_PRUNE_FIELDS;\n const r = config.rules;\n const streamDelete = r.find((x) => x.target === 'streams' && x.action === 'delete');\n const jobDeleteTransient = r.find((x) => x.target === 'jobs' && x.action === 'delete' && x.hasEntity === false);\n const jobPrune = r.find((x) => x.target === 'jobs' && x.action === 'prune' && x.hasEntity === true);\n const jobDeletePruned = r.find((x) => x.target === 'jobs' && x.action === 'delete' && x.pruned === true);\n return {\n pruneJobs: !!jobDeletePruned,\n expire: jobDeletePruned?.olderThan ?? '180 days',\n engineStreams: !!streamDelete,\n engineStreamsExpire: streamDelete?.olderThan ?? '1 day',\n workerStreams: !!streamDelete,\n workerStreamsExpire: streamDelete?.olderThan ?? '90 days',\n stripAttributes: !!jobPrune,\n pruneTransient: !!jobDeleteTransient,\n };\n}\n\n/** Convert PruneFields back to a MaintenanceConfig rules array. */\nfunction fieldsToRules(f: PruneFields): MaintenanceConfig['rules'] {\n const rules: MaintenanceConfig['rules'] = [];\n if (f.engineStreams) {\n rules.push({ target: 'streams', action: 'delete', olderThan: f.engineStreamsExpire });\n }\n if (f.workerStreams && f.workerStreamsExpire !== f.engineStreamsExpire) {\n rules.push({ target: 'streams', action: 'delete', olderThan: f.workerStreamsExpire });\n }\n if (f.pruneTransient) {\n rules.push({ target: 'jobs', action: 'delete', olderThan: f.expire, hasEntity: false });\n }\n if (f.stripAttributes) {\n rules.push({ target: 'jobs', action: 'prune', olderThan: f.expire, hasEntity: true });\n }\n if (f.pruneJobs) {\n rules.push({ target: 'jobs', action: 'delete', olderThan: f.expire, pruned: true });\n }\n return rules;\n}\n\nfunction describeCron(expr: string): string {\n return CRON_PRESETS.find((p) => p.value === expr)?.label ?? '';\n}\n\n// ── Main ────────────────────────────────────────────────────────────────────\n\nexport function ScheduleSection() {\n const { data, isLoading } = useMaintenanceConfig();\n const updateConfig = useUpdateMaintenanceConfig();\n\n const [schedule, setSchedule] = useState('');\n const [fields, setFields] = useState<PruneFields>(DEFAULT_PRUNE_FIELDS);\n const [savedSnapshot, setSavedSnapshot] = useState('');\n\n // Sync from server config when loaded\n const syncFromServer = useCallback(() => {\n if (!data?.config) return;\n setSchedule(data.config.schedule);\n setFields(configToFields(data.config));\n setSavedSnapshot(JSON.stringify({ schedule: data.config.schedule, fields: configToFields(data.config) }));\n }, [data]);\n\n useEffect(() => { syncFromServer(); }, [syncFromServer]);\n\n const currentSnapshot = JSON.stringify({ schedule, fields });\n const isDirty = savedSnapshot !== '' && currentSnapshot !== savedSnapshot;\n const active = data?.active ?? false;\n\n const handleSave = () => {\n const rules = fieldsToRules(fields);\n updateConfig.mutate(\n { schedule, rules },\n {\n onSuccess: () => {\n setSavedSnapshot(JSON.stringify({ schedule, fields }));\n },\n },\n );\n };\n\n const handleRevert = () => {\n syncFromServer();\n };\n\n if (isLoading) {\n return <div className=\"animate-pulse h-40 bg-surface-sunken rounded\" />;\n }\n\n return (\n <div className=\"space-y-8\">\n {/* Cron schedule + status */}\n <div className=\"grid grid-cols-1 @split:grid-cols-[1fr_auto] gap-10\">\n <div>\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4\">\n Schedule\n </p>\n <div className=\"flex items-end gap-4\">\n <div>\n <label className=\"block text-2xs text-text-tertiary mb-1\">Cron Expression</label>\n <input\n type=\"text\"\n value={schedule}\n onChange={(e) => setSchedule(e.target.value)}\n placeholder=\"0 2 * * *\"\n className=\"input text-xs font-mono w-48\"\n />\n </div>\n <div>\n <div className=\"flex items-center gap-1.5 h-8\">\n <span className={`w-2.5 h-2.5 rounded-full dot-ring ${active ? 'bg-status-success' : 'bg-text-tertiary'}`} />\n <span className={`text-xs ${active ? 'text-status-success' : 'text-text-tertiary'}`}>\n {active ? 'Active' : 'Inactive'}\n </span>\n </div>\n </div>\n {describeCron(schedule) && (\n <p className=\"text-xs text-text-tertiary h-8 flex items-center\">{describeCron(schedule)}</p>\n )}\n </div>\n\n {/* Preset pills */}\n <div className=\"flex flex-wrap gap-1.5 mt-3\">\n {CRON_PRESETS.map((preset) => (\n <button\n key={preset.value}\n type=\"button\"\n onClick={() => setSchedule(preset.value)}\n className={`px-2.5 py-1 text-2xs rounded-full transition-colors ${\n schedule === preset.value\n ? 'bg-accent/10 text-accent font-medium'\n : 'bg-surface-sunken text-text-tertiary hover:text-text-secondary'\n }`}\n >\n {preset.label}\n </button>\n ))}\n </div>\n </div>\n\n <div className=\"lg:w-72\">\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4\">\n How It Works\n </p>\n <div className=\"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken\">\n <Info className=\"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5\" />\n <p className=\"text-2xs text-text-tertiary leading-relaxed\">\n Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively\n since they only contain internal routing data. Worker streams should be retained longer\n to preserve execution playback and input enrichment.\n </p>\n </div>\n </div>\n </div>\n\n {/* Same prune fields as Prune Now */}\n <PruneFieldsEditor fields={fields} onChange={setFields} />\n\n {/* Action bar */}\n <div className=\"flex items-center justify-between pt-2 border-t border-surface-border\">\n <div className=\"flex items-center gap-3\">\n {isDirty && (\n <button\n onClick={handleRevert}\n className=\"text-2xs text-text-tertiary hover:text-text-primary transition-colors\"\n >\n Revert changes\n </button>\n )}\n {updateConfig.error && (\n <p className=\"text-xs text-status-error\">{(updateConfig.error as Error).message}</p>\n )}\n </div>\n <button\n onClick={handleSave}\n disabled={!isDirty || !schedule.trim() || updateConfig.isPending}\n className=\"btn-primary text-xs disabled:opacity-40 shrink-0\"\n >\n {updateConfig.isPending ? 'Saving...' : 'Save Schedule'}\n </button>\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport { Trash2, Clock, Info } from 'lucide-react';\nimport { PageHeader } from '../../../components/common/layout/PageHeader';\nimport { PruneSection } from './PruneSection';\nimport { ScheduleSection } from './ScheduleSection';\n\ntype Mode = 'prune' | 'schedule';\n\nfunction ModeToggle({ mode, onChange }: { mode: Mode; onChange: (m: Mode) => void }) {\n const btn = (m: Mode, icon: React.ReactNode, label: string) => (\n <button\n onClick={() => onChange(m)}\n className={`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${\n mode === m\n ? 'bg-accent/10 text-accent font-medium'\n : 'text-text-tertiary hover:text-text-secondary hover:bg-surface-hover'\n }`}\n >\n {icon}\n {label}\n </button>\n );\n\n return (\n <div className=\"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit\">\n {btn('prune', <Trash2 className=\"w-3.5 h-3.5\" />, 'Prune Now')}\n {btn('schedule', <Clock className=\"w-3.5 h-3.5\" />, 'Schedule')}\n </div>\n );\n}\n\nexport function MaintenancePage() {\n const [mode, setMode] = useState<Mode>('schedule');\n\n return (\n <div>\n <PageHeader\n title=\"DB Maintenance\"\n docsHash=\"#docs:dashboard.md:db-maintenance\"\n actions={<ModeToggle mode={mode} onChange={setMode} />}\n />\n\n <div className=\"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10\">\n <Info className=\"w-4 h-4 text-accent shrink-0 mt-0.5\" />\n <p className=\"text-xs text-text-secondary leading-relaxed\">\n Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are\n always safe to prune, workflow reduction preserves results, and deletion is permanent.\n </p>\n </div>\n\n {mode === 'prune' ? <PruneSection /> : <ScheduleSection />}\n </div>\n );\n}\n"],"names":["useMaintenanceConfig","useQuery","apiFetch","useUpdateMaintenanceConfig","queryClient","useQueryClient","useMutation","config","usePrune","options","RetentionRow","checked","onToggle","label","hint","safety","value","onChange","SafetyIcon","ShieldCheck","ShieldAlert","ShieldOff","safetyColor","safetyLabel","jsxs","jsx","e","RETENTION_PERIOD_OPTIONS","opt","CleanupCallout","Info","DEFAULT_PRUNE_FIELDS","hasSelection","f","PruneFieldsEditor","fields","set","key","v","ResultCard","PruneSection","prune","setFields","useState","result","setResult","showConfirm","setShowConfirm","handlePrune","data","Modal","configToFields","_a","streamDelete","x","jobDeleteTransient","jobPrune","jobDeletePruned","fieldsToRules","rules","describeCron","expr","CRON_PRESETS","p","ScheduleSection","isLoading","updateConfig","schedule","setSchedule","savedSnapshot","setSavedSnapshot","syncFromServer","useCallback","useEffect","currentSnapshot","isDirty","active","handleSave","handleRevert","preset","ModeToggle","mode","btn","m","icon","Trash2","Clock","MaintenancePage","setMode","PageHeader"],"mappings":"0WA4CO,SAASA,GAAuB,CACrC,OAAOC,EAAyD,CAC9D,SAAU,CAAC,aAAa,EACxB,QAAS,IAAMC,EAAS,qBAAqB,CAAA,CAC9C,CACH,CAEO,SAASC,GAA6B,CAC3C,MAAMC,EAAcC,EAAA,EACpB,OAAOC,EAIL,CACA,WAAaC,GACXL,EAAS,sBAAuB,CAC9B,OAAQ,MACR,KAAM,KAAK,UAAUK,CAAM,CAAA,CAC5B,EACH,UAAW,IAAM,CACfH,EAAY,kBAAkB,CAAE,SAAU,CAAC,aAAa,EAAG,CAC7D,CAAA,CACD,CACH,CAIO,SAASI,GAAW,CACzB,OAAOF,EAA8C,CACnD,WAAaG,GACXP,EAAS,aAAc,CACrB,OAAQ,OACR,KAAM,KAAK,UAAUO,CAAO,CAAA,CAC7B,CAAA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,WAAYzD,MAAC6D,GAAM,UAAU,aAAA,CAAc,EAAI,UAAU,CAAA,EAChE,CAEJ,CAEO,SAASC,IAAkB,CAChC,KAAM,CAACN,EAAMO,CAAO,EAAI7C,EAAAA,SAAe,UAAU,EAEjD,cACG,MAAA,CACC,SAAA,CAAAlB,EAAAA,IAACgE,EAAA,CACC,MAAM,iBACN,SAAS,oCACT,QAAShE,EAAAA,IAACuD,EAAA,CAAW,KAAAC,EAAY,SAAUO,CAAA,CAAS,CAAA,CAAA,EAGtDhE,EAAAA,KAAC,MAAA,CAAI,UAAU,uFACb,SAAA,CAAAC,EAAAA,IAACK,EAAA,CAAK,UAAU,qCAAA,CAAsC,EACtDL,EAAAA,IAAC,IAAA,CAAE,UAAU,8CAA8C,SAAA,uLAAA,CAG3D,CAAA,EACF,EAECwD,IAAS,QAAUxD,MAACe,EAAA,CAAA,CAAa,QAAMwB,EAAA,CAAA,CAAgB,CAAA,EAC1D,CAEJ"}
1
+ {"version":3,"file":"index-kes8V4Xw.js","sources":["../../src/api/maintenance.ts","../../src/pages/admin/maintenance/controls.tsx","../../src/pages/admin/maintenance/PruneSection.tsx","../../src/pages/admin/maintenance/ScheduleSection.tsx","../../src/pages/admin/maintenance/MaintenancePage.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { apiFetch } from './client';\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MaintenanceRule {\n target: 'streams' | 'jobs';\n action: 'delete' | 'prune';\n olderThan: string;\n hasEntity?: boolean;\n pruned?: boolean;\n}\n\nexport interface MaintenanceConfig {\n schedule: string;\n rules: MaintenanceRule[];\n}\n\nexport interface PruneOptions {\n expire?: string;\n jobs?: boolean;\n streams?: boolean;\n engineStreams?: boolean;\n engineStreamsExpire?: string;\n workerStreams?: boolean;\n workerStreamsExpire?: string;\n attributes?: boolean;\n entities?: string[];\n pruneTransient?: boolean;\n keepHmark?: boolean;\n}\n\nexport interface PruneResult {\n jobs?: number;\n streams?: number;\n engineStreams?: number;\n workerStreams?: number;\n attributes?: number;\n transient?: number;\n marked?: number;\n}\n\n// ── Maintenance config ────────────────────────────────────────────────────────\n\nexport function useMaintenanceConfig() {\n return useQuery<{ config: MaintenanceConfig; active: boolean }>({\n queryKey: ['maintenance'],\n queryFn: () => apiFetch('/config/maintenance'),\n });\n}\n\nexport function useUpdateMaintenanceConfig() {\n const queryClient = useQueryClient();\n return useMutation<\n { config: MaintenanceConfig; restarted: boolean },\n Error,\n MaintenanceConfig\n >({\n mutationFn: (config) =>\n apiFetch('/config/maintenance', {\n method: 'PUT',\n body: JSON.stringify(config),\n }),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['maintenance'] });\n },\n });\n}\n\n// ── DBA operations ────────────────────────────────────────────────────────────\n\nexport function usePrune() {\n return useMutation<PruneResult, Error, PruneOptions>({\n mutationFn: (options) =>\n apiFetch('/dba/prune', {\n method: 'POST',\n body: JSON.stringify(options),\n }),\n });\n}\n\nexport function useDeploy() {\n return useMutation<{ ok: boolean }, Error, void>({\n mutationFn: () =>\n apiFetch('/dba/deploy', { method: 'POST' }),\n });\n}\n","import { Info, ShieldCheck, ShieldAlert, ShieldOff } from 'lucide-react';\nimport { RETENTION_PERIOD_OPTIONS } from '../../../lib/constants';\n\n// ── Retention row (checkbox + label + select) ───────────────────────────────\n\nexport function RetentionRow({ checked, onToggle, label, hint, safety, value, onChange }: {\n checked: boolean;\n onToggle: (v: boolean) => void;\n label: string;\n hint: string;\n safety: 'safe' | 'moderate' | 'destructive';\n value: string;\n onChange: (v: string) => void;\n}) {\n const SafetyIcon = safety === 'safe' ? ShieldCheck : safety === 'moderate' ? ShieldAlert : ShieldOff;\n const safetyColor = safety === 'safe' ? 'text-status-success' : safety === 'moderate' ? 'text-status-warning' : 'text-status-error';\n const safetyLabel = safety === 'safe' ? 'Safe' : safety === 'moderate' ? 'Careful' : 'Permanent';\n\n return (\n <div className=\"flex items-center gap-4\">\n <label className=\"flex items-center gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onToggle(e.target.checked)}\n className=\"w-4 h-4 rounded border-border accent-accent shrink-0\"\n />\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">{label}</span>\n <span className={`flex items-center gap-0.5 text-2xs ${safetyColor}`}>\n <SafetyIcon className=\"w-3 h-3\" strokeWidth={1.5} />\n {safetyLabel}\n </span>\n </div>\n <p className=\"text-2xs text-text-tertiary\">{hint}</p>\n </div>\n </label>\n <select\n value={value}\n onChange={(e) => onChange(e.target.value)}\n disabled={!checked}\n className={`select text-xs w-36 transition-opacity ${!checked ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n );\n}\n\n// ── Cleanup checkbox ────────────────────────────────────────────────────────\n\nexport function CleanupCheck({ checked, onChange, label, description, safety }: {\n checked: boolean;\n onChange: (v: boolean) => void;\n label: string;\n description: string;\n safety: 'safe' | 'moderate' | 'destructive';\n}) {\n const SafetyIcon = safety === 'safe' ? ShieldCheck : safety === 'moderate' ? ShieldAlert : ShieldOff;\n const safetyColor = safety === 'safe' ? 'text-status-success' : safety === 'moderate' ? 'text-status-warning' : 'text-status-error';\n const safetyLabel = safety === 'safe' ? 'Safe' : safety === 'moderate' ? 'Careful' : 'Permanent';\n\n return (\n <label className=\"flex items-start gap-2.5 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onChange(e.target.checked)}\n className=\"w-4 h-4 mt-0.5 rounded border-border accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">{label}</span>\n <span className={`flex items-center gap-0.5 text-2xs ${safetyColor}`}>\n <SafetyIcon className=\"w-3 h-3\" strokeWidth={1.5} />\n {safetyLabel}\n </span>\n </div>\n <p className=\"text-2xs text-text-tertiary\">{description}</p>\n </div>\n </label>\n );\n}\n\n// ── Cleanup callout ─────────────────────────────────────────────────────────\n\nexport function CleanupCallout() {\n return (\n <div className=\"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken\">\n <Info className=\"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5\" />\n <p className=\"text-2xs text-text-tertiary leading-relaxed\">\n Stripping preserves workflow results and timeline data needed for the execution detail view.\n Transient jobs are internal bookkeeping that accumulates over time.\n </p>\n </div>\n );\n}\n\n// ── Prune fields state shape (shared between both panels) ───────────────────\n\nexport interface PruneFields {\n pruneJobs: boolean;\n expire: string;\n engineStreams: boolean;\n engineStreamsExpire: string;\n workerStreams: boolean;\n workerStreamsExpire: string;\n stripAttributes: boolean;\n pruneTransient: boolean;\n}\n\nexport const DEFAULT_PRUNE_FIELDS: PruneFields = {\n pruneJobs: true,\n expire: '30 days',\n engineStreams: true,\n engineStreamsExpire: '1 day',\n workerStreams: true,\n workerStreamsExpire: '90 days',\n stripAttributes: false,\n pruneTransient: false,\n};\n\nexport function hasSelection(f: PruneFields): boolean {\n return f.pruneJobs || f.engineStreams || f.workerStreams || f.stripAttributes || f.pruneTransient;\n}\n\n// ── Prune fields editor (reused by both Prune Now and Schedule) ─────────────\n\nexport function PruneFieldsEditor({ fields, onChange }: {\n fields: PruneFields;\n onChange: (f: PruneFields) => void;\n}) {\n const set = <K extends keyof PruneFields>(key: K, value: PruneFields[K]) =>\n onChange({ ...fields, [key]: value });\n\n return (\n <div className=\"space-y-8\">\n {/* Stream messages — always safe to prune */}\n <div>\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1\">\n Stream Messages\n </p>\n <p className=\"text-2xs text-text-tertiary mb-4\">\n Processed routing messages. Already consumed — safe to remove after a short retention window.\n </p>\n <div className=\"space-y-3\">\n <RetentionRow\n checked={fields.engineStreams} onToggle={(v) => set('engineStreams', v)}\n label=\"Engine messages\" hint=\"Internal orchestration signals\"\n safety=\"safe\"\n value={fields.engineStreamsExpire} onChange={(v) => set('engineStreamsExpire', v)}\n />\n <RetentionRow\n checked={fields.workerStreams} onToggle={(v) => set('workerStreams', v)}\n label=\"Worker messages\" hint=\"Activity dispatch and response payloads\"\n safety=\"safe\"\n value={fields.workerStreamsExpire} onChange={(v) => set('workerStreamsExpire', v)}\n />\n </div>\n </div>\n\n {/* Workflow data — mutually exclusive: reduce OR delete */}\n <div>\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1\">\n Completed Workflows\n </p>\n <p className=\"text-2xs text-text-tertiary mb-4\">\n Choose how to handle completed workflow records. Reducing strips step-level detail\n but keeps the workflow and its results. Deleting removes the record entirely.\n </p>\n <div className=\"space-y-3\">\n <label className=\"flex items-start gap-2.5 cursor-pointer\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={!fields.stripAttributes && !fields.pruneJobs}\n onChange={() => onChange({ ...fields, stripAttributes: false, pruneJobs: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <span className=\"text-xs text-text-primary\">Keep as-is</span>\n <p className=\"text-2xs text-text-tertiary\">No changes to completed workflow records.</p>\n </div>\n </label>\n\n <div className=\"flex items-start gap-2.5\">\n <label className=\"flex items-start gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={fields.stripAttributes && !fields.pruneJobs}\n onChange={() => onChange({ ...fields, stripAttributes: true, pruneJobs: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">Reduce completed workflows</span>\n <span className=\"flex items-center gap-0.5 text-2xs text-status-warning\">\n <ShieldAlert className=\"w-3 h-3\" strokeWidth={1.5} />\n Careful\n </span>\n </div>\n <p className=\"text-2xs text-text-tertiary\">\n Strips step-level execution detail (activity inputs/outputs, internal state).\n Workflow results and timeline are preserved.\n </p>\n </div>\n </label>\n <select\n value={fields.expire}\n onChange={(e) => set('expire', e.target.value)}\n disabled={!fields.stripAttributes || fields.pruneJobs}\n className={`select text-xs w-36 transition-opacity mt-0.5 ${!fields.stripAttributes || fields.pruneJobs ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n\n <div className=\"flex items-start gap-2.5\">\n <label className=\"flex items-start gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={fields.pruneJobs}\n onChange={() => onChange({ ...fields, pruneJobs: true, stripAttributes: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">Delete completed workflows</span>\n <span className=\"flex items-center gap-0.5 text-2xs text-status-error\">\n <ShieldOff className=\"w-3 h-3\" strokeWidth={1.5} />\n Permanent\n </span>\n </div>\n <p className=\"text-2xs text-text-tertiary\">\n Permanently removes workflow records. Results, timeline, and all\n execution data are deleted and cannot be recovered.\n </p>\n </div>\n </label>\n <select\n value={fields.expire}\n onChange={(e) => set('expire', e.target.value)}\n disabled={!fields.pruneJobs}\n className={`select text-xs w-36 transition-opacity mt-0.5 ${!fields.pruneJobs ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n </div>\n <CleanupCallout />\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport { usePrune, type PruneResult } from '../../../api/maintenance';\nimport { Modal } from '../../../components/common/modal/Modal';\nimport { PruneFieldsEditor, DEFAULT_PRUNE_FIELDS, hasSelection, type PruneFields } from './controls';\n\nfunction ResultCard({ label, value }: { label: string; value: number }) {\n return (\n <div>\n <p className=\"text-lg font-light text-text-primary\">{value.toLocaleString()}</p>\n <p className=\"text-2xs text-text-tertiary\">{label}</p>\n </div>\n );\n}\n\nexport function PruneSection() {\n const prune = usePrune();\n const [fields, setFields] = useState<PruneFields>(DEFAULT_PRUNE_FIELDS);\n const [result, setResult] = useState<PruneResult | null>(null);\n const [showConfirm, setShowConfirm] = useState(false);\n\n const handlePrune = () => {\n setResult(null);\n prune.mutate(\n {\n expire: fields.expire,\n jobs: fields.pruneJobs,\n engineStreams: fields.engineStreams,\n engineStreamsExpire: fields.engineStreamsExpire,\n workerStreams: fields.workerStreams,\n workerStreamsExpire: fields.workerStreamsExpire,\n attributes: fields.stripAttributes,\n pruneTransient: fields.pruneTransient,\n },\n {\n onSuccess: (data) => {\n setResult(data);\n setShowConfirm(false);\n },\n },\n );\n };\n\n return (\n <div className=\"space-y-8\">\n <PruneFieldsEditor fields={fields} onChange={setFields} />\n\n {/* Action bar */}\n <div className=\"flex items-center justify-between pt-2 border-t border-surface-border\">\n <p className=\"text-2xs text-text-tertiary\">\n {!hasSelection(fields)\n ? 'Select at least one operation to enable pruning.'\n : 'This action permanently deletes data and cannot be undone.'}\n </p>\n <button\n onClick={() => setShowConfirm(true)}\n disabled={!hasSelection(fields) || prune.isPending}\n className=\"bg-status-error text-text-inverse px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0\"\n >\n {prune.isPending ? 'Pruning...' : 'Prune Now'}\n </button>\n </div>\n\n {/* Results */}\n {result && (\n <div className=\"bg-surface-sunken rounded-md px-4 py-3\">\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2\">\n Results\n </p>\n <div className=\"flex flex-wrap gap-6\">\n {result.jobs != null && result.jobs > 0 && <ResultCard label=\"Jobs deleted\" value={result.jobs} />}\n {result.engineStreams != null && result.engineStreams > 0 && <ResultCard label=\"Engine streams\" value={result.engineStreams} />}\n {result.workerStreams != null && result.workerStreams > 0 && <ResultCard label=\"Worker streams\" value={result.workerStreams} />}\n {result.streams != null && result.engineStreams == null && result.streams > 0 && <ResultCard label=\"Streams\" value={result.streams} />}\n {result.attributes != null && result.attributes > 0 && <ResultCard label=\"Artifacts stripped\" value={result.attributes} />}\n {result.transient != null && result.transient > 0 && <ResultCard label=\"Transient deleted\" value={result.transient} />}\n {result.marked != null && result.marked > 0 && <ResultCard label=\"Marked pruned\" value={result.marked} />}\n {Object.values(result).every((v) => !v || v === 0) && (\n <p className=\"text-xs text-text-tertiary\">Nothing to prune within the selected retention windows.</p>\n )}\n </div>\n </div>\n )}\n\n {prune.error && (\n <p className=\"text-xs text-status-error\">{(prune.error as Error).message}</p>\n )}\n\n {/* Confirm modal */}\n <Modal open={showConfirm} onClose={() => setShowConfirm(false)} title=\"Confirm Prune\">\n <div className=\"space-y-4\">\n <p className=\"text-sm text-text-secondary\">\n This will permanently delete data. This action cannot be undone.\n </p>\n <ul className=\"text-xs text-text-secondary space-y-1 list-disc list-inside\">\n {fields.pruneJobs && <li>Delete jobs older than {fields.expire}</li>}\n {fields.engineStreams && <li>Delete engine streams older than {fields.engineStreamsExpire}</li>}\n {fields.workerStreams && <li>Delete worker streams older than {fields.workerStreamsExpire}</li>}\n {fields.stripAttributes && <li>Strip execution artifacts from completed jobs</li>}\n {fields.pruneTransient && <li>Delete transient (entity-less) jobs</li>}\n </ul>\n <div className=\"flex justify-end gap-3 pt-2\">\n <button onClick={() => setShowConfirm(false)} className=\"btn-secondary text-xs\">Cancel</button>\n <button\n onClick={handlePrune}\n className=\"bg-status-error text-text-inverse px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity\"\n disabled={prune.isPending}\n >\n {prune.isPending ? 'Pruning...' : 'Confirm Prune'}\n </button>\n </div>\n </div>\n </Modal>\n </div>\n );\n}\n","import { useState, useEffect, useCallback } from 'react';\nimport { Info } from 'lucide-react';\nimport {\n useMaintenanceConfig,\n useUpdateMaintenanceConfig,\n type MaintenanceConfig,\n} from '../../../api/maintenance';\nimport { CRON_PRESETS } from '../../../lib/constants';\nimport { PruneFieldsEditor, DEFAULT_PRUNE_FIELDS, type PruneFields } from './controls';\n\n// ── Helpers ─────────────────────────────────────────────────────────────────\n\n/** Convert a MaintenanceConfig (rules array) into PruneFields for the editor. */\nfunction configToFields(config: MaintenanceConfig | undefined): PruneFields {\n if (!config?.rules?.length) return DEFAULT_PRUNE_FIELDS;\n const r = config.rules;\n const streamDelete = r.find((x) => x.target === 'streams' && x.action === 'delete');\n const jobDeleteTransient = r.find((x) => x.target === 'jobs' && x.action === 'delete' && x.hasEntity === false);\n const jobPrune = r.find((x) => x.target === 'jobs' && x.action === 'prune' && x.hasEntity === true);\n const jobDeletePruned = r.find((x) => x.target === 'jobs' && x.action === 'delete' && x.pruned === true);\n return {\n pruneJobs: !!jobDeletePruned,\n expire: jobDeletePruned?.olderThan ?? '180 days',\n engineStreams: !!streamDelete,\n engineStreamsExpire: streamDelete?.olderThan ?? '1 day',\n workerStreams: !!streamDelete,\n workerStreamsExpire: streamDelete?.olderThan ?? '90 days',\n stripAttributes: !!jobPrune,\n pruneTransient: !!jobDeleteTransient,\n };\n}\n\n/** Convert PruneFields back to a MaintenanceConfig rules array. */\nfunction fieldsToRules(f: PruneFields): MaintenanceConfig['rules'] {\n const rules: MaintenanceConfig['rules'] = [];\n if (f.engineStreams) {\n rules.push({ target: 'streams', action: 'delete', olderThan: f.engineStreamsExpire });\n }\n if (f.workerStreams && f.workerStreamsExpire !== f.engineStreamsExpire) {\n rules.push({ target: 'streams', action: 'delete', olderThan: f.workerStreamsExpire });\n }\n if (f.pruneTransient) {\n rules.push({ target: 'jobs', action: 'delete', olderThan: f.expire, hasEntity: false });\n }\n if (f.stripAttributes) {\n rules.push({ target: 'jobs', action: 'prune', olderThan: f.expire, hasEntity: true });\n }\n if (f.pruneJobs) {\n rules.push({ target: 'jobs', action: 'delete', olderThan: f.expire, pruned: true });\n }\n return rules;\n}\n\nfunction describeCron(expr: string): string {\n return CRON_PRESETS.find((p) => p.value === expr)?.label ?? '';\n}\n\n// ── Main ────────────────────────────────────────────────────────────────────\n\nexport function ScheduleSection() {\n const { data, isLoading } = useMaintenanceConfig();\n const updateConfig = useUpdateMaintenanceConfig();\n\n const [schedule, setSchedule] = useState('');\n const [fields, setFields] = useState<PruneFields>(DEFAULT_PRUNE_FIELDS);\n const [savedSnapshot, setSavedSnapshot] = useState('');\n\n // Sync from server config when loaded\n const syncFromServer = useCallback(() => {\n if (!data?.config) return;\n setSchedule(data.config.schedule);\n setFields(configToFields(data.config));\n setSavedSnapshot(JSON.stringify({ schedule: data.config.schedule, fields: configToFields(data.config) }));\n }, [data]);\n\n useEffect(() => { syncFromServer(); }, [syncFromServer]);\n\n const currentSnapshot = JSON.stringify({ schedule, fields });\n const isDirty = savedSnapshot !== '' && currentSnapshot !== savedSnapshot;\n const active = data?.active ?? false;\n\n const handleSave = () => {\n const rules = fieldsToRules(fields);\n updateConfig.mutate(\n { schedule, rules },\n {\n onSuccess: () => {\n setSavedSnapshot(JSON.stringify({ schedule, fields }));\n },\n },\n );\n };\n\n const handleRevert = () => {\n syncFromServer();\n };\n\n if (isLoading) {\n return <div className=\"animate-pulse h-40 bg-surface-sunken rounded\" />;\n }\n\n return (\n <div className=\"space-y-8\">\n {/* Cron schedule + status */}\n <div className=\"grid grid-cols-1 @split:grid-cols-[1fr_auto] gap-10\">\n <div>\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4\">\n Schedule\n </p>\n <div className=\"flex items-end gap-4\">\n <div>\n <label className=\"block text-2xs text-text-tertiary mb-1\">Cron Expression</label>\n <input\n type=\"text\"\n value={schedule}\n onChange={(e) => setSchedule(e.target.value)}\n placeholder=\"0 2 * * *\"\n className=\"input text-xs font-mono w-48\"\n />\n </div>\n <div>\n <div className=\"flex items-center gap-1.5 h-8\">\n <span className={`w-2.5 h-2.5 rounded-full dot-ring ${active ? 'bg-status-success' : 'bg-text-tertiary'}`} />\n <span className={`text-xs ${active ? 'text-status-success' : 'text-text-tertiary'}`}>\n {active ? 'Active' : 'Inactive'}\n </span>\n </div>\n </div>\n {describeCron(schedule) && (\n <p className=\"text-xs text-text-tertiary h-8 flex items-center\">{describeCron(schedule)}</p>\n )}\n </div>\n\n {/* Preset pills */}\n <div className=\"flex flex-wrap gap-1.5 mt-3\">\n {CRON_PRESETS.map((preset) => (\n <button\n key={preset.value}\n type=\"button\"\n onClick={() => setSchedule(preset.value)}\n className={`px-2.5 py-1 text-2xs rounded-full transition-colors ${\n schedule === preset.value\n ? 'bg-accent/10 text-accent font-medium'\n : 'bg-surface-sunken text-text-tertiary hover:text-text-secondary'\n }`}\n >\n {preset.label}\n </button>\n ))}\n </div>\n </div>\n\n <div className=\"lg:w-72\">\n <p className=\"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4\">\n How It Works\n </p>\n <div className=\"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken\">\n <Info className=\"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5\" />\n <p className=\"text-2xs text-text-tertiary leading-relaxed\">\n Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively\n since they only contain internal routing data. Worker streams should be retained longer\n to preserve execution playback and input enrichment.\n </p>\n </div>\n </div>\n </div>\n\n {/* Same prune fields as Prune Now */}\n <PruneFieldsEditor fields={fields} onChange={setFields} />\n\n {/* Action bar */}\n <div className=\"flex items-center justify-between pt-2 border-t border-surface-border\">\n <div className=\"flex items-center gap-3\">\n {isDirty && (\n <button\n onClick={handleRevert}\n className=\"text-2xs text-text-tertiary hover:text-text-primary transition-colors\"\n >\n Revert changes\n </button>\n )}\n {updateConfig.error && (\n <p className=\"text-xs text-status-error\">{(updateConfig.error as Error).message}</p>\n )}\n </div>\n <button\n onClick={handleSave}\n disabled={!isDirty || !schedule.trim() || updateConfig.isPending}\n className=\"btn-primary text-xs disabled:opacity-40 shrink-0\"\n >\n {updateConfig.isPending ? 'Saving...' : 'Save Schedule'}\n </button>\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport { Trash2, Clock, Info } from 'lucide-react';\nimport { PageHeader } from '../../../components/common/layout/PageHeader';\nimport { PruneSection } from './PruneSection';\nimport { ScheduleSection } from './ScheduleSection';\n\ntype Mode = 'prune' | 'schedule';\n\nfunction ModeToggle({ mode, onChange }: { mode: Mode; onChange: (m: Mode) => void }) {\n const btn = (m: Mode, icon: React.ReactNode, label: string) => (\n <button\n onClick={() => onChange(m)}\n className={`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${\n mode === m\n ? 'bg-accent/10 text-accent font-medium'\n : 'text-text-tertiary hover:text-text-secondary hover:bg-surface-hover'\n }`}\n >\n {icon}\n {label}\n </button>\n );\n\n return (\n <div className=\"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit\">\n {btn('prune', <Trash2 className=\"w-3.5 h-3.5\" />, 'Prune Now')}\n {btn('schedule', <Clock className=\"w-3.5 h-3.5\" />, 'Schedule')}\n </div>\n );\n}\n\nexport function MaintenancePage() {\n const [mode, setMode] = useState<Mode>('schedule');\n\n return (\n <div>\n <PageHeader\n title=\"DB Maintenance\"\n docsHash=\"#docs:dashboard.md:db-maintenance\"\n actions={<ModeToggle mode={mode} onChange={setMode} />}\n />\n\n <div className=\"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10\">\n <Info className=\"w-4 h-4 text-accent shrink-0 mt-0.5\" />\n <p className=\"text-xs text-text-secondary leading-relaxed\">\n Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are\n always safe to prune, workflow reduction preserves results, and deletion is permanent.\n </p>\n </div>\n\n {mode === 'prune' ? <PruneSection /> : <ScheduleSection />}\n </div>\n );\n}\n"],"names":["useMaintenanceConfig","useQuery","apiFetch","useUpdateMaintenanceConfig","queryClient","useQueryClient","useMutation","config","usePrune","options","RetentionRow","checked","onToggle","label","hint","safety","value","onChange","SafetyIcon","ShieldCheck","ShieldAlert","ShieldOff","safetyColor","safetyLabel","jsxs","jsx","e","RETENTION_PERIOD_OPTIONS","opt","CleanupCallout","Info","DEFAULT_PRUNE_FIELDS","hasSelection","f","PruneFieldsEditor","fields","set","key","v","ResultCard","PruneSection","prune","setFields","useState","result","setResult","showConfirm","setShowConfirm","handlePrune","data","Modal","configToFields","_a","streamDelete","x","jobDeleteTransient","jobPrune","jobDeletePruned","fieldsToRules","rules","describeCron","expr","CRON_PRESETS","p","ScheduleSection","isLoading","updateConfig","schedule","setSchedule","savedSnapshot","setSavedSnapshot","syncFromServer","useCallback","useEffect","currentSnapshot","isDirty","active","handleSave","handleRevert","preset","ModeToggle","mode","btn","m","icon","Trash2","Clock","MaintenancePage","setMode","PageHeader"],"mappings":"0WA4CO,SAASA,GAAuB,CACrC,OAAOC,EAAyD,CAC9D,SAAU,CAAC,aAAa,EACxB,QAAS,IAAMC,EAAS,qBAAqB,CAAA,CAC9C,CACH,CAEO,SAASC,GAA6B,CAC3C,MAAMC,EAAcC,EAAA,EACpB,OAAOC,EAIL,CACA,WAAaC,GACXL,EAAS,sBAAuB,CAC9B,OAAQ,MACR,KAAM,KAAK,UAAUK,CAAM,CAAA,CAC5B,EACH,UAAW,IAAM,CACfH,EAAY,kBAAkB,CAAE,SAAU,CAAC,aAAa,EAAG,CAC7D,CAAA,CACD,CACH,CAIO,SAASI,GAAW,CACzB,OAAOF,EAA8C,CACnD,WAAaG,GACXP,EAAS,aAAc,CACrB,OAAQ,OACR,KAAM,KAAK,UAAUO,CAAO,CAAA,CAC7B,CAAA,CACJ,CACH,CC1EO,SAASC,EAAa,CAAE,QAAAC,EAAS,SAAAC,EAAU,MAAAC,EAAO,KAAAC,EAAM,OAAAC,EAAQ,MAAAC,EAAO,SAAAC,GAQ3E,CACD,MAAMC,EAAaH,IAAW,OAASI,EAAcJ,IAAW,WAAaK,EAAcC,EACrFC,EAAcP,IAAW,OAAS,sBAAwBA,IAAW,WAAa,sBAAwB,oBAC1GQ,EAAcR,IAAW,OAAS,OAASA,IAAW,WAAa,UAAY,YAErF,OACES,EAAAA,KAAC,MA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A,KAAC,MAAA,CAAI,UAAU,uFACb,SAAA,CAAAC,EAAAA,IAACK,EAAA,CAAK,UAAU,qCAAA,CAAsC,EACtDL,EAAAA,IAAC,IAAA,CAAE,UAAU,8CAA8C,SAAA,uLAAA,CAG3D,CAAA,EACF,EAECwD,IAAS,QAAUxD,MAACe,EAAA,CAAA,CAAa,QAAMwB,EAAA,CAAA,CAAgB,CAAA,EAC1D,CAEJ"}
@@ -1,2 +1,2 @@
1
- import{u as I,c as M,j as e,a as l,b as ae}from"./vendor-query-RUZdMvN6.js";import{f as ne,b as ie}from"./vendor-react-CdqEC2zv.js";import{P as le}from"./PageHeader-BpeBHqyc.js";import{F as oe,a as ce}from"./FilterBar-y659Gc3X.js";import{L as xe}from"./ListToolbar-DfpSgWYU.js";import{b as de}from"./api-path-u2Jf9QXS.js";import{E as ue}from"./EmptyState-lpUFYfun.js";import{D as pe}from"./DropZone-DovkhN2p.js";import{g as N}from"./index-Cqrp5B5S.js";import{F as me,b as X,a8 as Q,a9 as he,w as fe,b1 as ge,b2 as be,b3 as je,b4 as ye,b5 as Ne,X as ve,av as we,aw as ke,aU as Se,T as Ce,b6 as H,b7 as Fe,C as Te}from"./vendor-icons-BPsNpK3Y.js";import{T as J}from"./TimeAgo-BSDHd9Xo.js";function Pe(t,a=100,n){const s=new URLSearchParams;t&&s.set("prefix",t),s.set("pageSize",String(a)),n&&s.set("continuationToken",n);const o=s.toString();return I({queryKey:["fileBrowse",t,a,n],queryFn:()=>N(`/file-browser/browse?${o}`)})}function Ue(t){return I({queryKey:["fileMetadata",t],queryFn:()=>N(`/file-browser/metadata/${t}`),enabled:!!t})}function $e(){return M({mutationFn:t=>N("/file-browser/signed-url",{method:"POST",body:JSON.stringify(t)})})}function Ee(){return M({mutationFn:t=>N(`/file-browser/delete/${t}`,{method:"DELETE"})})}function De(){return M({mutationFn:async({path:t,file:a})=>{const n=await a.arrayBuffer();return N(`/file-browser/upload?path=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:n})}})}function Le(t){return I({queryKey:["filePreviewUrl",t],queryFn:async()=>(await N("/file-browser/signed-url",{method:"POST",body:JSON.stringify({path:t,expiresIn:3600})})).url,enabled:!!t,staleTime:3e3*1e3})}function Be({prefix:t,onNavigate:a}){const n=t?t.replace(/\/+$/,"").split("/").filter(Boolean):[];return e.jsxs("nav",{className:"flex items-center gap-1 text-sm mb-6 min-h-[28px]",children:[e.jsxs("button",{onClick:()=>a(""),className:`flex items-center gap-1.5 px-1.5 py-0.5 rounded transition-colors ${n.length===0?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsx(me,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),e.jsx("span",{children:"Root"})]}),n.map((s,o)=>{const i=o===n.length-1,d=n.slice(0,o+1).join("/")+"/";return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"w-3.5 h-3.5 text-text-tertiary"}),e.jsx("button",{onClick:()=>a(d),className:`px-1.5 py-0.5 rounded transition-colors ${i?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:s})]},d)})]})}function Re(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function S(t){return t.split("/").pop()||t}function _({label:t,value:a,mono:n,children:s}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5",children:t}),e.jsx("dd",{className:`text-sm text-text-secondary ${n?"font-mono text-xs break-all":""}`,children:s||a})]})}function _e({url:t}){const[a,n]=l.useState(null),[s,o]=l.useState(!1);return a===null&&!s&&fetch(t).then(i=>{if(!i.ok)throw new Error;return i.text()}).then(i=>n(i.slice(0,1e5))).catch(()=>o(!0)),s?e.jsx("p",{className:"text-xs text-text-tertiary",children:"Could not load preview"}):a===null?e.jsx("div",{className:"animate-pulse h-32 bg-surface-sunken rounded"}):e.jsx("pre",{className:"font-mono text-xs text-text-secondary bg-surface-sunken rounded-md p-3 overflow-x-auto max-h-[400px] overflow-y-auto whitespace-pre-wrap break-words",children:a})}function Ie({metadata:t}){const[a,n]=l.useState(null);async function s(o,i){await navigator.clipboard.writeText(o),n(i),setTimeout(()=>n(null),2e3)}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5",children:"Path"}),e.jsxs("dd",{onClick:()=>s(t.path,"path"),className:"group flex items-center gap-1.5 text-xs font-mono text-text-secondary break-all cursor-pointer hover:text-text-primary transition-colors",title:"Click to copy",children:[e.jsx("span",{className:"flex-1",children:t.path}),a==="path"?e.jsx(Q,{className:"w-3.5 h-3.5 text-status-success shrink-0"}):e.jsx(he,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-100 text-text-tertiary shrink-0 transition-opacity"})]})]}),e.jsx(_,{label:"Type",value:t.content_type}),e.jsx(_,{label:"Size",value:Re(t.size)}),e.jsx(_,{label:"Modified",children:e.jsx(J,{date:t.modified_at})})]})}async function Me(t,a){const s=await(await fetch(t)).blob(),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=a,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function Oe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function ze(t){var n;const a=((n=t.split(".").pop())==null?void 0:n.toLowerCase())||"";return["png","jpg","jpeg","gif","svg","webp"].includes(a)?e.jsx(ge,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["json"].includes(a)?e.jsx(be,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["csv","xlsx","xls"].includes(a)?e.jsx(je,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["txt","md","html","xml","yaml","yml","css","js","ts"].includes(a)?e.jsx(ye,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):e.jsx(Ne,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5})}function qe(t){var n;const a=((n=t.split(".").pop())==null?void 0:n.toLowerCase())||"";return["png","jpg","jpeg","gif","svg","webp"].includes(a)}function We(t){const a=t.replace(/\/+$/,"");return a.split("/").pop()||a}function Ae(t){return t.split("/").pop()||t}function Ke({directories:t,files:a,onNavigate:n,onSelect:s,selectedFile:o}){return e.jsxs("table",{className:"w-full mt-2",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-2xs uppercase tracking-wider text-text-tertiary",children:[e.jsx("th",{className:"pb-2 pl-2 font-medium",children:"Name"}),e.jsx("th",{className:"pb-2 font-medium w-24 text-right",children:"Size"}),e.jsx("th",{className:"pb-2 pr-2 font-medium w-40 text-right",children:"Modified"})]})}),e.jsxs("tbody",{children:[t.map(i=>e.jsxs("tr",{onClick:()=>n(i),className:"row-hover cursor-pointer group",children:[e.jsx("td",{className:"py-2 pl-2",children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[e.jsx(fe,{className:"w-4 h-4 text-accent/75 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"text-sm text-text-primary group-hover:text-accent transition-colors",children:We(i)})]})}),e.jsx("td",{className:"py-2 text-right text-xs text-text-tertiary",children:"—"}),e.jsx("td",{className:"py-2 pr-2 text-right text-xs text-text-tertiary",children:"—"})]},i)),a.map(i=>e.jsxs("tr",{onClick:()=>s(i.path),className:`row-hover cursor-pointer group ${o===i.path?"bg-surface-hover":""}`,children:[e.jsx("td",{className:"py-2 pl-2",children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[ze(i.path),e.jsx("span",{className:"text-sm text-text-primary truncate",children:Ae(i.path)})]})}),e.jsx("td",{className:"py-2 text-right text-xs text-text-secondary tabular-nums",children:Oe(i.size)}),e.jsx("td",{className:"py-2 pr-2 text-right text-xs text-text-secondary",children:e.jsx(J,{date:i.modified_at})})]},i.path))]})]})}const Ge=[{label:"1 hour",value:3600},{label:"6 hours",value:21600},{label:"24 hours",value:86400},{label:"7 days",value:604800},{label:"30 days",value:2592e3}];function He({filePath:t,onClose:a,onDeleted:n}){var b,k;const{data:s,isLoading:o}=Ue(t),i=$e(),d=Ee(),[v,f]=l.useState(!1),[w,C]=l.useState(!1),[j,h]=l.useState(!1),{data:u}=Le(t),g=((b=s==null?void 0:s.content_type)==null?void 0:b.startsWith("image/"))||qe(t),F=/\.(ts|tsx|js|jsx|json|md|yaml|yml|toml|xml|csv|sql|sh|py|rb|go|rs|java|c|cpp|h|css|scss|html|txt|log|env|ini|cfg|conf)$/i,p=((k=s==null?void 0:s.content_type)==null?void 0:k.startsWith("text/"))||(s==null?void 0:s.content_type)==="application/json"||(s==null?void 0:s.content_type)==="application/xml"||(s==null?void 0:s.content_type)==="application/octet-stream"&&F.test(t),$=(s==null?void 0:s.content_type)==="application/pdf";async function E(){try{const c=await i.mutateAsync({path:t,expiresIn:3600}),x=c.url.startsWith("http")?c.url:`${window.location.origin}${c.url}`;Me(x,S(t))}catch{}}async function T(c){f(!1);try{const x=await i.mutateAsync({path:t,expiresIn:c}),y=x.url.startsWith("http")?x.url:`${window.location.origin}${x.url}`;await navigator.clipboard.writeText(y),C(!0),setTimeout(()=>C(!1),2e3)}catch{}}return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"w-[380px] shrink-0 border-l border-surface-border bg-surface overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 bg-surface z-10 px-5 pt-5 pb-3 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary truncate pr-2",title:S(t),children:S(t)}),e.jsx("button",{onClick:a,className:"text-text-tertiary hover:text-text-primary shrink-0",children:e.jsx(ve,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsxs("button",{onClick:E,className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Download",children:[e.jsx(we,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Download"})]}),e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Open in new tab",children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Open"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>f(c=>!c),className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Share with signed URL",children:[w?e.jsx(Q,{className:"w-3.5 h-3.5 text-status-success"}):e.jsx(Se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Share"})]}),v&&e.jsx("div",{className:"absolute top-full left-0 mt-1 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100] min-w-[120px]",children:Ge.map(c=>e.jsx("button",{onClick:()=>T(c.value),className:"w-full text-left px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover hover:text-text-primary transition-colors",children:c.label},c.value))})]}),e.jsxs("button",{onClick:()=>h(!0),className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs text-status-error/70 hover:text-status-error",title:"Delete file",children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Delete"})]})]}),j&&e.jsxs("div",{className:"mt-3 p-3 bg-status-error/5 border border-status-error/20 rounded-md",children:[e.jsxs("p",{className:"text-xs text-text-primary mb-2",children:["Permanently delete ",e.jsx("span",{className:"font-medium",children:S(t)}),"? This cannot be undone."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>h(!1),className:"btn-secondary text-xs",disabled:d.isPending,children:"Cancel"}),e.jsx("button",{onClick:async()=>{try{await d.mutateAsync(t),h(!1),n==null||n()}catch{}},className:"btn-primary text-xs !bg-status-error hover:!bg-status-error/90",disabled:d.isPending,children:d.isPending?"Deleting...":"Delete"})]}),d.isError&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:d.error.message})]}),i.isError&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:i.error.message})]}),e.jsx("div",{className:"p-5",children:o?e.jsxs("div",{className:"animate-pulse space-y-3",children:[e.jsx("div",{className:"h-48 bg-surface-sunken rounded"}),e.jsx("div",{className:"h-4 bg-surface-sunken rounded w-2/3"})]}):e.jsxs(e.Fragment,{children:[g&&u&&e.jsx("div",{className:"mb-5 rounded-md border border-surface-border bg-surface-sunken overflow-hidden",style:{maxHeight:"400px"},children:e.jsx("img",{src:u,alt:S(t),className:"w-full object-cover object-top",style:{maxHeight:"400px"}})}),p&&u&&e.jsx("div",{className:"mb-5",children:e.jsx(_e,{url:u})}),$&&u&&e.jsx("div",{className:"mb-5 p-4 bg-surface-sunken rounded-md text-center",children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:text-accent-hover text-sm font-medium",children:"Open PDF in new tab"})}),s&&e.jsx(Ie,{metadata:s})]})})]})})}const Xe=[25,50,100,200];function it(){const[t,a]=ne(),n=t.get("prefix")||"",[s,o]=l.useState(""),[i,d]=l.useState(""),[v,f]=l.useState(null),[w,C]=l.useState(100),[j,h]=l.useState([]),[u,g]=l.useState();l.useEffect(()=>{const r=setTimeout(()=>{d(s),g(void 0),h([])},300);return()=>clearTimeout(r)},[s]);const F=i?`${n}${i}`:n,{data:p,isLoading:$,isFetching:E,refetch:T}=Pe(F,w,u),b=De(),k=ae(),c=l.useRef(null),[x,y]=l.useState(null),[P,O]=l.useState(""),z=l.useCallback(r=>{y(r),O(n)},[n]),[q,W]=l.useState(""),Z=l.useCallback(()=>{if(!x)return;W("");let r=x.length;for(const m of x){const K=`${P}${m.name}`;b.mutate({path:K,file:m},{onSuccess:()=>{r--,k.invalidateQueries({queryKey:["fileBrowse"]}),r<=0&&y(null)},onError:G=>{r--,W(G.message),console.error("[Upload] failed:",K,G)}})}},[x,P,b,k]),D=(p==null?void 0:p.directories)??[],U=(p==null?void 0:p.files)??[],L=p==null?void 0:p.nextToken,A=l.useCallback(r=>{o(""),d(""),f(null),g(void 0),h([]),a(r?{prefix:r}:{})},[a]);function V(){L&&(h(r=>[...r,u||""]),g(L))}function Y(){if(j.length===0)return;const r=[...j],m=r.pop();h(r),g(m||void 0)}function ee(r){C(r),g(void 0),h([])}const te=D.length===0&&U.length===0,se=j.length+1,B=!!L,R=j.length>0,re=de("/file-browser/browse",{prefix:F,pageSize:w,continuationToken:u||void 0});return e.jsxs(pe,{onDrop:z,label:"Drop files to upload",children:[e.jsxs("div",{className:"flex gap-0",children:[e.jsx("input",{ref:c,type:"file",multiple:!0,className:"hidden",onChange:r=>{const m=Array.from(r.target.files||[]);m.length&&z(m),r.target.value=""}}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden pr-6",children:[e.jsx(le,{title:"Files",docsHash:"#docs:dashboard.md:files",actions:e.jsxs("button",{onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},disabled:b.isPending,className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(H,{className:"w-3.5 h-3.5"}),b.isPending?"Uploading...":"Upload"]})}),e.jsx(Be,{prefix:n,onNavigate:A}),e.jsx(oe,{actions:e.jsx(xe,{onRefresh:()=>T(),isFetching:E,apiPath:re}),children:e.jsx(ce,{label:"Search",value:s,onChange:o,placeholder:"Filter by prefix..."})}),$?e.jsx("div",{className:"animate-pulse space-y-2 mt-4",children:Array.from({length:6}).map((r,m)=>e.jsx("div",{className:"h-10 bg-surface-sunken rounded"},m))}):te?e.jsx("div",{className:"cursor-pointer",onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},children:e.jsx(ue,{icon:Fe,title:s?"No matching files":"No files yet",description:s?void 0:"Drop files here or click to upload"})}):e.jsx(Ke,{directories:D,files:U,onNavigate:A,onSelect:f,selectedFile:v}),(R||B||U.length>0)&&e.jsxs("div",{className:"flex items-center justify-between pt-4 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("p",{className:"text-xs text-text-tertiary",children:["Page ",se," · ",U.length+D.length," items"]}),e.jsx("select",{value:w,onChange:r=>ee(parseInt(r.target.value)),className:"select text-xs py-1",children:Xe.map(r=>e.jsxs("option",{value:r,children:[r," / page"]},r))})]}),(R||B)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:Y,disabled:!R,className:"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1",children:[e.jsx(Te,{className:"w-3.5 h-3.5"}),"Previous"]}),e.jsxs("button",{onClick:V,disabled:!B,className:"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1",children:["Next",e.jsx(X,{className:"w-3.5 h-3.5"})]})]})]})]}),v&&e.jsx(He,{filePath:v,onClose:()=>f(null),onDeleted:()=>{f(null),T()}})]}),x&&ie.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>y(null)}),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-surface-raised border border-surface-border rounded-lg shadow-lg w-full max-w-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-surface-border",children:e.jsxs("h3",{className:"text-sm font-medium text-text-primary",children:["Upload ",x.length," file",x.length>1?"s":""]})}),e.jsxs("div",{className:"px-5 py-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Destination folder"}),e.jsx("input",{type:"text",value:P,onChange:r=>O(r.target.value),placeholder:"e.g., images/ or leave empty for root",className:"input text-xs w-full font-mono"})]}),e.jsx("div",{className:"text-2xs text-text-quaternary space-y-0.5",children:x.map((r,m)=>e.jsxs("p",{className:"truncate",children:[P,r.name," ",e.jsxs("span",{className:"text-text-tertiary",children:["(",(r.size/1024).toFixed(1)," KB)"]})]},m))}),q&&e.jsx("p",{className:"text-xs text-status-error",children:q})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-surface-border",children:[e.jsx("button",{onClick:()=>y(null),className:"btn-ghost text-xs",children:"Cancel"}),e.jsxs("button",{onClick:Z,className:"btn-primary text-xs",children:[e.jsx(H,{className:"w-3.5 h-3.5 mr-1.5 inline"}),"Upload"]})]})]})})]}),document.body)]})}export{it as FilesPage};
2
- //# sourceMappingURL=index-CALocCAr.js.map
1
+ import{u as I,c as M,j as e,a as l,b as ae}from"./vendor-query-RUZdMvN6.js";import{f as ne,b as ie}from"./vendor-react-CdqEC2zv.js";import{P as le}from"./PageHeader-BpeBHqyc.js";import{F as oe,a as ce}from"./FilterBar-DfCiCmm-.js";import{L as xe}from"./ListToolbar-DA0PTOl5.js";import{b as de}from"./api-path-u2Jf9QXS.js";import{E as ue}from"./EmptyState-lpUFYfun.js";import{D as pe}from"./DropZone-DovkhN2p.js";import{g as N}from"./index-DBXm49S6.js";import{F as me,b as X,a8 as Q,a9 as he,w as fe,b1 as ge,b2 as be,b3 as je,b4 as ye,b5 as Ne,X as ve,av as we,aw as ke,aU as Se,T as Ce,b6 as H,b7 as Fe,C as Te}from"./vendor-icons-BPsNpK3Y.js";import{T as J}from"./TimeAgo-BO33VeFl.js";function Pe(t,a=100,n){const s=new URLSearchParams;t&&s.set("prefix",t),s.set("pageSize",String(a)),n&&s.set("continuationToken",n);const o=s.toString();return I({queryKey:["fileBrowse",t,a,n],queryFn:()=>N(`/file-browser/browse?${o}`)})}function Ue(t){return I({queryKey:["fileMetadata",t],queryFn:()=>N(`/file-browser/metadata/${t}`),enabled:!!t})}function $e(){return M({mutationFn:t=>N("/file-browser/signed-url",{method:"POST",body:JSON.stringify(t)})})}function Ee(){return M({mutationFn:t=>N(`/file-browser/delete/${t}`,{method:"DELETE"})})}function De(){return M({mutationFn:async({path:t,file:a})=>{const n=await a.arrayBuffer();return N(`/file-browser/upload?path=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:n})}})}function Le(t){return I({queryKey:["filePreviewUrl",t],queryFn:async()=>(await N("/file-browser/signed-url",{method:"POST",body:JSON.stringify({path:t,expiresIn:3600})})).url,enabled:!!t,staleTime:3e3*1e3})}function Be({prefix:t,onNavigate:a}){const n=t?t.replace(/\/+$/,"").split("/").filter(Boolean):[];return e.jsxs("nav",{className:"flex items-center gap-1 text-sm mb-6 min-h-[28px]",children:[e.jsxs("button",{onClick:()=>a(""),className:`flex items-center gap-1.5 px-1.5 py-0.5 rounded transition-colors ${n.length===0?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsx(me,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),e.jsx("span",{children:"Root"})]}),n.map((s,o)=>{const i=o===n.length-1,d=n.slice(0,o+1).join("/")+"/";return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"w-3.5 h-3.5 text-text-tertiary"}),e.jsx("button",{onClick:()=>a(d),className:`px-1.5 py-0.5 rounded transition-colors ${i?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:s})]},d)})]})}function Re(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function S(t){return t.split("/").pop()||t}function _({label:t,value:a,mono:n,children:s}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5",children:t}),e.jsx("dd",{className:`text-sm text-text-secondary ${n?"font-mono text-xs break-all":""}`,children:s||a})]})}function _e({url:t}){const[a,n]=l.useState(null),[s,o]=l.useState(!1);return a===null&&!s&&fetch(t).then(i=>{if(!i.ok)throw new Error;return i.text()}).then(i=>n(i.slice(0,1e5))).catch(()=>o(!0)),s?e.jsx("p",{className:"text-xs text-text-tertiary",children:"Could not load preview"}):a===null?e.jsx("div",{className:"animate-pulse h-32 bg-surface-sunken rounded"}):e.jsx("pre",{className:"font-mono text-xs text-text-secondary bg-surface-sunken rounded-md p-3 overflow-x-auto max-h-[400px] overflow-y-auto whitespace-pre-wrap break-words",children:a})}function Ie({metadata:t}){const[a,n]=l.useState(null);async function s(o,i){await navigator.clipboard.writeText(o),n(i),setTimeout(()=>n(null),2e3)}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-2xs uppercase tracking-wider text-text-tertiary mb-0.5",children:"Path"}),e.jsxs("dd",{onClick:()=>s(t.path,"path"),className:"group flex items-center gap-1.5 text-xs font-mono text-text-secondary break-all cursor-pointer hover:text-text-primary transition-colors",title:"Click to copy",children:[e.jsx("span",{className:"flex-1",children:t.path}),a==="path"?e.jsx(Q,{className:"w-3.5 h-3.5 text-status-success shrink-0"}):e.jsx(he,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-100 text-text-tertiary shrink-0 transition-opacity"})]})]}),e.jsx(_,{label:"Type",value:t.content_type}),e.jsx(_,{label:"Size",value:Re(t.size)}),e.jsx(_,{label:"Modified",children:e.jsx(J,{date:t.modified_at})})]})}async function Me(t,a){const s=await(await fetch(t)).blob(),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=a,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function Oe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function ze(t){var n;const a=((n=t.split(".").pop())==null?void 0:n.toLowerCase())||"";return["png","jpg","jpeg","gif","svg","webp"].includes(a)?e.jsx(ge,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["json"].includes(a)?e.jsx(be,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["csv","xlsx","xls"].includes(a)?e.jsx(je,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):["txt","md","html","xml","yaml","yml","css","js","ts"].includes(a)?e.jsx(ye,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5}):e.jsx(Ne,{className:"w-4 h-4 text-accent/60",strokeWidth:1.5})}function qe(t){var n;const a=((n=t.split(".").pop())==null?void 0:n.toLowerCase())||"";return["png","jpg","jpeg","gif","svg","webp"].includes(a)}function We(t){const a=t.replace(/\/+$/,"");return a.split("/").pop()||a}function Ae(t){return t.split("/").pop()||t}function Ke({directories:t,files:a,onNavigate:n,onSelect:s,selectedFile:o}){return e.jsxs("table",{className:"w-full mt-2",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-2xs uppercase tracking-wider text-text-tertiary",children:[e.jsx("th",{className:"pb-2 pl-2 font-medium",children:"Name"}),e.jsx("th",{className:"pb-2 font-medium w-24 text-right",children:"Size"}),e.jsx("th",{className:"pb-2 pr-2 font-medium w-40 text-right",children:"Modified"})]})}),e.jsxs("tbody",{children:[t.map(i=>e.jsxs("tr",{onClick:()=>n(i),className:"row-hover cursor-pointer group",children:[e.jsx("td",{className:"py-2 pl-2",children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[e.jsx(fe,{className:"w-4 h-4 text-accent/75 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"text-sm text-text-primary group-hover:text-accent transition-colors",children:We(i)})]})}),e.jsx("td",{className:"py-2 text-right text-xs text-text-tertiary",children:"—"}),e.jsx("td",{className:"py-2 pr-2 text-right text-xs text-text-tertiary",children:"—"})]},i)),a.map(i=>e.jsxs("tr",{onClick:()=>s(i.path),className:`row-hover cursor-pointer group ${o===i.path?"bg-surface-hover":""}`,children:[e.jsx("td",{className:"py-2 pl-2",children:e.jsxs("span",{className:"flex items-center gap-2.5",children:[ze(i.path),e.jsx("span",{className:"text-sm text-text-primary truncate",children:Ae(i.path)})]})}),e.jsx("td",{className:"py-2 text-right text-xs text-text-secondary tabular-nums",children:Oe(i.size)}),e.jsx("td",{className:"py-2 pr-2 text-right text-xs text-text-secondary",children:e.jsx(J,{date:i.modified_at})})]},i.path))]})]})}const Ge=[{label:"1 hour",value:3600},{label:"6 hours",value:21600},{label:"24 hours",value:86400},{label:"7 days",value:604800},{label:"30 days",value:2592e3}];function He({filePath:t,onClose:a,onDeleted:n}){var b,k;const{data:s,isLoading:o}=Ue(t),i=$e(),d=Ee(),[v,f]=l.useState(!1),[w,C]=l.useState(!1),[j,h]=l.useState(!1),{data:u}=Le(t),g=((b=s==null?void 0:s.content_type)==null?void 0:b.startsWith("image/"))||qe(t),F=/\.(ts|tsx|js|jsx|json|md|yaml|yml|toml|xml|csv|sql|sh|py|rb|go|rs|java|c|cpp|h|css|scss|html|txt|log|env|ini|cfg|conf)$/i,p=((k=s==null?void 0:s.content_type)==null?void 0:k.startsWith("text/"))||(s==null?void 0:s.content_type)==="application/json"||(s==null?void 0:s.content_type)==="application/xml"||(s==null?void 0:s.content_type)==="application/octet-stream"&&F.test(t),$=(s==null?void 0:s.content_type)==="application/pdf";async function E(){try{const c=await i.mutateAsync({path:t,expiresIn:3600}),x=c.url.startsWith("http")?c.url:`${window.location.origin}${c.url}`;Me(x,S(t))}catch{}}async function T(c){f(!1);try{const x=await i.mutateAsync({path:t,expiresIn:c}),y=x.url.startsWith("http")?x.url:`${window.location.origin}${x.url}`;await navigator.clipboard.writeText(y),C(!0),setTimeout(()=>C(!1),2e3)}catch{}}return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"w-[380px] shrink-0 border-l border-surface-border bg-surface overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 bg-surface z-10 px-5 pt-5 pb-3 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary truncate pr-2",title:S(t),children:S(t)}),e.jsx("button",{onClick:a,className:"text-text-tertiary hover:text-text-primary shrink-0",children:e.jsx(ve,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsxs("button",{onClick:E,className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Download",children:[e.jsx(we,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Download"})]}),e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Open in new tab",children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Open"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>f(c=>!c),className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs",title:"Share with signed URL",children:[w?e.jsx(Q,{className:"w-3.5 h-3.5 text-status-success"}):e.jsx(Se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Share"})]}),v&&e.jsx("div",{className:"absolute top-full left-0 mt-1 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100] min-w-[120px]",children:Ge.map(c=>e.jsx("button",{onClick:()=>T(c.value),className:"w-full text-left px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover hover:text-text-primary transition-colors",children:c.label},c.value))})]}),e.jsxs("button",{onClick:()=>h(!0),className:"btn-ghost flex items-center gap-1.5 !px-2.5 !py-1.5 text-xs text-status-error/70 hover:text-status-error",title:"Delete file",children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Delete"})]})]}),j&&e.jsxs("div",{className:"mt-3 p-3 bg-status-error/5 border border-status-error/20 rounded-md",children:[e.jsxs("p",{className:"text-xs text-text-primary mb-2",children:["Permanently delete ",e.jsx("span",{className:"font-medium",children:S(t)}),"? This cannot be undone."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>h(!1),className:"btn-secondary text-xs",disabled:d.isPending,children:"Cancel"}),e.jsx("button",{onClick:async()=>{try{await d.mutateAsync(t),h(!1),n==null||n()}catch{}},className:"btn-primary text-xs !bg-status-error hover:!bg-status-error/90",disabled:d.isPending,children:d.isPending?"Deleting...":"Delete"})]}),d.isError&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:d.error.message})]}),i.isError&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:i.error.message})]}),e.jsx("div",{className:"p-5",children:o?e.jsxs("div",{className:"animate-pulse space-y-3",children:[e.jsx("div",{className:"h-48 bg-surface-sunken rounded"}),e.jsx("div",{className:"h-4 bg-surface-sunken rounded w-2/3"})]}):e.jsxs(e.Fragment,{children:[g&&u&&e.jsx("div",{className:"mb-5 rounded-md border border-surface-border bg-surface-sunken overflow-hidden",style:{maxHeight:"400px"},children:e.jsx("img",{src:u,alt:S(t),className:"w-full object-cover object-top",style:{maxHeight:"400px"}})}),p&&u&&e.jsx("div",{className:"mb-5",children:e.jsx(_e,{url:u})}),$&&u&&e.jsx("div",{className:"mb-5 p-4 bg-surface-sunken rounded-md text-center",children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:text-accent-hover text-sm font-medium",children:"Open PDF in new tab"})}),s&&e.jsx(Ie,{metadata:s})]})})]})})}const Xe=[25,50,100,200];function it(){const[t,a]=ne(),n=t.get("prefix")||"",[s,o]=l.useState(""),[i,d]=l.useState(""),[v,f]=l.useState(null),[w,C]=l.useState(100),[j,h]=l.useState([]),[u,g]=l.useState();l.useEffect(()=>{const r=setTimeout(()=>{d(s),g(void 0),h([])},300);return()=>clearTimeout(r)},[s]);const F=i?`${n}${i}`:n,{data:p,isLoading:$,isFetching:E,refetch:T}=Pe(F,w,u),b=De(),k=ae(),c=l.useRef(null),[x,y]=l.useState(null),[P,O]=l.useState(""),z=l.useCallback(r=>{y(r),O(n)},[n]),[q,W]=l.useState(""),Z=l.useCallback(()=>{if(!x)return;W("");let r=x.length;for(const m of x){const K=`${P}${m.name}`;b.mutate({path:K,file:m},{onSuccess:()=>{r--,k.invalidateQueries({queryKey:["fileBrowse"]}),r<=0&&y(null)},onError:G=>{r--,W(G.message),console.error("[Upload] failed:",K,G)}})}},[x,P,b,k]),D=(p==null?void 0:p.directories)??[],U=(p==null?void 0:p.files)??[],L=p==null?void 0:p.nextToken,A=l.useCallback(r=>{o(""),d(""),f(null),g(void 0),h([]),a(r?{prefix:r}:{})},[a]);function V(){L&&(h(r=>[...r,u||""]),g(L))}function Y(){if(j.length===0)return;const r=[...j],m=r.pop();h(r),g(m||void 0)}function ee(r){C(r),g(void 0),h([])}const te=D.length===0&&U.length===0,se=j.length+1,B=!!L,R=j.length>0,re=de("/file-browser/browse",{prefix:F,pageSize:w,continuationToken:u||void 0});return e.jsxs(pe,{onDrop:z,label:"Drop files to upload",children:[e.jsxs("div",{className:"flex gap-0",children:[e.jsx("input",{ref:c,type:"file",multiple:!0,className:"hidden",onChange:r=>{const m=Array.from(r.target.files||[]);m.length&&z(m),r.target.value=""}}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden pr-6",children:[e.jsx(le,{title:"Files",docsHash:"#docs:dashboard.md:files",actions:e.jsxs("button",{onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},disabled:b.isPending,className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(H,{className:"w-3.5 h-3.5"}),b.isPending?"Uploading...":"Upload"]})}),e.jsx(Be,{prefix:n,onNavigate:A}),e.jsx(oe,{actions:e.jsx(xe,{onRefresh:()=>T(),isFetching:E,apiPath:re}),children:e.jsx(ce,{label:"Search",value:s,onChange:o,placeholder:"Filter by prefix..."})}),$?e.jsx("div",{className:"animate-pulse space-y-2 mt-4",children:Array.from({length:6}).map((r,m)=>e.jsx("div",{className:"h-10 bg-surface-sunken rounded"},m))}):te?e.jsx("div",{className:"cursor-pointer",onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},children:e.jsx(ue,{icon:Fe,title:s?"No matching files":"No files yet",description:s?void 0:"Drop files here or click to upload"})}):e.jsx(Ke,{directories:D,files:U,onNavigate:A,onSelect:f,selectedFile:v}),(R||B||U.length>0)&&e.jsxs("div",{className:"flex items-center justify-between pt-4 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("p",{className:"text-xs text-text-tertiary",children:["Page ",se," · ",U.length+D.length," items"]}),e.jsx("select",{value:w,onChange:r=>ee(parseInt(r.target.value)),className:"select text-xs py-1",children:Xe.map(r=>e.jsxs("option",{value:r,children:[r," / page"]},r))})]}),(R||B)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:Y,disabled:!R,className:"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1",children:[e.jsx(Te,{className:"w-3.5 h-3.5"}),"Previous"]}),e.jsxs("button",{onClick:V,disabled:!B,className:"btn-ghost text-xs disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1",children:["Next",e.jsx(X,{className:"w-3.5 h-3.5"})]})]})]})]}),v&&e.jsx(He,{filePath:v,onClose:()=>f(null),onDeleted:()=>{f(null),T()}})]}),x&&ie.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>y(null)}),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-surface-raised border border-surface-border rounded-lg shadow-lg w-full max-w-sm",children:[e.jsx("div",{className:"px-5 py-4 border-b border-surface-border",children:e.jsxs("h3",{className:"text-sm font-medium text-text-primary",children:["Upload ",x.length," file",x.length>1?"s":""]})}),e.jsxs("div",{className:"px-5 py-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Destination folder"}),e.jsx("input",{type:"text",value:P,onChange:r=>O(r.target.value),placeholder:"e.g., images/ or leave empty for root",className:"input text-xs w-full font-mono"})]}),e.jsx("div",{className:"text-2xs text-text-quaternary space-y-0.5",children:x.map((r,m)=>e.jsxs("p",{className:"truncate",children:[P,r.name," ",e.jsxs("span",{className:"text-text-tertiary",children:["(",(r.size/1024).toFixed(1)," KB)"]})]},m))}),q&&e.jsx("p",{className:"text-xs text-status-error",children:q})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-surface-border",children:[e.jsx("button",{onClick:()=>y(null),className:"btn-ghost text-xs",children:"Cancel"}),e.jsxs("button",{onClick:Z,className:"btn-primary text-xs",children:[e.jsx(H,{className:"w-3.5 h-3.5 mr-1.5 inline"}),"Upload"]})]})]})})]}),document.body)]})}export{it as FilesPage};
2
+ //# sourceMappingURL=index-nwLh3CK2.js.map