@lunora/studio 1.0.0-alpha.217 → 1.0.0-alpha.219

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 (193) hide show
  1. package/dist/index.d.mts +2 -2
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  6. package/dist/packem_chunks/ApiTab.mjs +1 -1
  7. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  8. package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
  9. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  10. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  11. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  12. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  13. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  14. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  15. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  16. package/dist/packem_chunks/MailPanel.mjs +2 -2
  17. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  18. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  19. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  20. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  21. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  22. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  23. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  24. package/dist/packem_chunks/TableEditor.mjs +1 -1
  25. package/dist/packem_chunks/agents-panel.mjs +1 -1
  26. package/dist/packem_chunks/analytics-panel.mjs +1 -1
  27. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  28. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  29. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  30. package/dist/packem_chunks/containers-panel.mjs +1 -1
  31. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  32. package/dist/packem_chunks/evals-panel.mjs +1 -1
  33. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  34. package/dist/packem_chunks/flags-panel.mjs +1 -1
  35. package/dist/packem_chunks/issues-panel.mjs +1 -1
  36. package/dist/packem_chunks/kv-browser.mjs +1 -1
  37. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  38. package/dist/packem_chunks/migrations-route.mjs +1 -1
  39. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  40. package/dist/packem_chunks/payments-panel.mjs +1 -1
  41. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  42. package/dist/packem_chunks/queues-panel.mjs +1 -1
  43. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  44. package/dist/packem_chunks/rls-panel.mjs +1 -1
  45. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  46. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  47. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  48. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  49. package/dist/packem_chunks/traces-panel.mjs +1 -1
  50. package/dist/packem_chunks/users-panel.mjs +1 -1
  51. package/dist/packem_chunks/vector-browser.mjs +1 -1
  52. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  53. package/dist/packem_shared/{ApiDocsPanel-BImfQhyJ.mjs → ApiDocsPanel-DzvVLAev.mjs} +1 -1
  54. package/dist/packem_shared/{ApiReferencePanel-CigvHhCa.mjs → ApiReferencePanel--1Y4o_-l.mjs} +1 -1
  55. package/dist/packem_shared/{CommandPalette-CSdz9zax.mjs → CommandPalette-D7GxhPrH.mjs} +1 -1
  56. package/dist/packem_shared/DataBrowser-CKbaOtDh.mjs +4 -0
  57. package/dist/packem_shared/GlobalDataBrowser-DSexMt80.mjs +1 -0
  58. package/dist/packem_shared/{HomePanel-_BwLI4TQ.mjs → HomePanel-BkCmY0Hl.mjs} +1 -1
  59. package/dist/packem_shared/{MigrationsPanel-BPWzFdxC.mjs → MigrationsPanel-DLQRarWw.mjs} +1 -1
  60. package/dist/packem_shared/{OpenRpcReferencePanel-C6CM791D.mjs → OpenRpcReferencePanel-a_mbqw67.mjs} +1 -1
  61. package/dist/packem_shared/{ScheduledJobs-B4DPADwk.mjs → ScheduledJobs-DSqsMB51.mjs} +1 -1
  62. package/dist/packem_shared/Studio-BE_SzY44.mjs +1 -0
  63. package/dist/packem_shared/{StudioApp-fYFz6zZQ.mjs → StudioApp-kVjMop0V.mjs} +1 -1
  64. package/dist/packem_shared/{advisor-view-CPgOok_h.mjs → advisor-view-DtkbHW2O.mjs} +1 -1
  65. package/dist/packem_shared/aggregateMetrics-5zEJC6Ju.mjs +1 -0
  66. package/dist/packem_shared/auth-pager-DiDnXsfe.mjs +1 -0
  67. package/dist/packem_shared/{data-grid-DTBAKZlm.mjs → data-grid-BPu1a997.mjs} +1 -1
  68. package/dist/packem_shared/data-view-params-DhYmAkcj.mjs +1 -0
  69. package/dist/packem_shared/{error-alert-tf5zvSLV.mjs → error-alert-dQk3g8WI.mjs} +1 -1
  70. package/dist/packem_shared/{grid-features-Dm80ngyR.mjs → grid-features-ByxOklon.mjs} +1 -1
  71. package/dist/packem_shared/grid-pagination-DgzyzfBh.mjs +1 -0
  72. package/dist/packem_shared/home-panel-B_HN6YMA.mjs +3 -0
  73. package/dist/packem_shared/internal-CyDwqA67.mjs +2 -0
  74. package/dist/packem_shared/{log-line-BoObzuue.mjs → log-line-BHZD2Aj4.mjs} +1 -1
  75. package/dist/packem_shared/{recording-client-BXUIyBL4.mjs → recording-client-CjRFjhya.mjs} +1 -1
  76. package/dist/packem_shared/reference-view-vNXUVPlA.mjs +13 -0
  77. package/dist/packem_shared/{schema-diagram-CDj_69jF.mjs → schema-diagram-DADlbs2X.mjs} +1 -1
  78. package/dist/packem_shared/{sql-result-table-C5y0jwaK.mjs → sql-result-table-DS4o0GoC.mjs} +1 -1
  79. package/dist/packem_shared/{studio-OqNyRY1N.mjs → studio-BVQq3QLR.mjs} +1 -1
  80. package/dist/packem_shared/table-list-sidebar-D30qERKx.mjs +1 -0
  81. package/dist/packem_shared/{use-admin-query-BKXiqLci.mjs → use-admin-query-CR9mHt0P.mjs} +1 -1
  82. package/dist/packem_shared/{use-async-submit-BTr3w2-K.mjs → use-async-submit-LWIKsZ8r.mjs} +1 -1
  83. package/dist/packem_shared/{use-auth-config-CuM3eJZz.mjs → use-auth-config-HmTOvrWd.mjs} +1 -1
  84. package/dist/packem_shared/{use-open-trace-BCW0c9qq.mjs → use-open-trace-DdGxsEB9.mjs} +1 -1
  85. package/dist/packem_shared/{use-sql-assistant-BhIMDQHV.mjs → use-sql-assistant-D4XQ0v0R.mjs} +1 -1
  86. package/dist/standalone/{chunk-VPL4UEUQ.js → chunk-2ABVDLD3.js} +1 -1
  87. package/dist/standalone/{chunk-GNT6XGND.js → chunk-2HAWCLCS.js} +1 -1
  88. package/dist/standalone/chunk-2HF37UQN.js +1 -0
  89. package/dist/standalone/chunk-2JLOP2EL.js +1 -0
  90. package/dist/standalone/{chunk-DUKQRASV.js → chunk-2R6ZRXPJ.js} +1 -1
  91. package/dist/standalone/{chunk-NKPDRRNQ.js → chunk-2RMFAASK.js} +1 -1
  92. package/dist/standalone/{chunk-ZBCR4Y7H.js → chunk-3C25RFTP.js} +1 -1
  93. package/dist/standalone/chunk-3GFF4BA4.js +3 -0
  94. package/dist/standalone/{chunk-PA2VU4KN.js → chunk-3TE3V2QL.js} +1 -1
  95. package/dist/standalone/{chunk-SO2DWPC4.js → chunk-3ZMF2GJ5.js} +1 -1
  96. package/dist/standalone/chunk-4AZDQAT2.js +1 -0
  97. package/dist/standalone/chunk-4P2KFEUN.js +1 -0
  98. package/dist/standalone/chunk-5ICUJ4IA.js +15 -0
  99. package/dist/standalone/{chunk-FODLDLE2.js → chunk-6B7FVPW3.js} +5 -5
  100. package/dist/standalone/{chunk-QHRQX4KT.js → chunk-6CGJCPHC.js} +1 -1
  101. package/dist/standalone/chunk-6DAD3RFX.js +1 -0
  102. package/dist/standalone/chunk-6HDT763N.js +1 -0
  103. package/dist/standalone/{chunk-EDGO46IR.js → chunk-6P7CYZPR.js} +1 -1
  104. package/dist/standalone/{chunk-3S77QF26.js → chunk-6RNWWWLS.js} +1 -1
  105. package/dist/standalone/chunk-6WPU62WQ.js +2 -0
  106. package/dist/standalone/{chunk-JYKNN7XE.js → chunk-A2XTI2C3.js} +1 -1
  107. package/dist/standalone/{chunk-WMCC4HKS.js → chunk-AM7VTTNL.js} +1 -1
  108. package/dist/standalone/chunk-BJEJVHCO.js +9 -0
  109. package/dist/standalone/{chunk-TIUMFAN2.js → chunk-DKLSANZA.js} +1 -1
  110. package/dist/standalone/{chunk-NX2EQSOE.js → chunk-DX6246CW.js} +1 -1
  111. package/dist/standalone/{chunk-DX6FAHR2.js → chunk-DXT2DY4I.js} +1 -1
  112. package/dist/standalone/{chunk-RLVFEWIN.js → chunk-EDEQELIO.js} +1 -1
  113. package/dist/standalone/chunk-EQVY6WGK.js +1 -0
  114. package/dist/standalone/{chunk-YIK4XEVX.js → chunk-FCEQTBLC.js} +1 -1
  115. package/dist/standalone/{chunk-WD3PESCG.js → chunk-FCPY75TQ.js} +1 -1
  116. package/dist/standalone/{chunk-E7TOMONS.js → chunk-FS4GMDIW.js} +1 -1
  117. package/dist/standalone/{chunk-YDIJI7T6.js → chunk-GGAUC5ZI.js} +1 -1
  118. package/dist/standalone/{chunk-N3R2NFDS.js → chunk-GL7PC32W.js} +1 -1
  119. package/dist/standalone/{chunk-R3J3OY24.js → chunk-GYKK64E7.js} +1 -1
  120. package/dist/standalone/{chunk-JYQA5LES.js → chunk-H4OORJHB.js} +1 -1
  121. package/dist/standalone/chunk-HR7W3Z5I.js +1 -0
  122. package/dist/standalone/chunk-I3TUOZM3.js +1 -0
  123. package/dist/standalone/{chunk-OK2Q64WC.js → chunk-I4VOJYXE.js} +1 -1
  124. package/dist/standalone/{chunk-BOTGXX4H.js → chunk-IJPXZZZ5.js} +1 -1
  125. package/dist/standalone/{chunk-Y5D7BKI4.js → chunk-J345HOFQ.js} +1 -1
  126. package/dist/standalone/chunk-JNDBJAO6.js +1 -0
  127. package/dist/standalone/{chunk-LAOVV6GJ.js → chunk-JQ63BDVF.js} +1 -1
  128. package/dist/standalone/{chunk-IDVSCQJU.js → chunk-K4HVLN3Z.js} +1 -1
  129. package/dist/standalone/chunk-KFEWMJQS.js +1 -0
  130. package/dist/standalone/chunk-KGCUFNFC.js +5 -0
  131. package/dist/standalone/{chunk-4Q6ZHR7P.js → chunk-LJVH6HRQ.js} +1 -1
  132. package/dist/standalone/{chunk-GGPSI4ZR.js → chunk-MDUTVBJZ.js} +1 -1
  133. package/dist/standalone/{chunk-U745VG7H.js → chunk-MMMRSTCL.js} +1 -1
  134. package/dist/standalone/{chunk-3F35BVE4.js → chunk-PAE3ULFR.js} +1 -1
  135. package/dist/standalone/{chunk-2J44JAMR.js → chunk-PIKO7SSB.js} +1 -1
  136. package/dist/standalone/chunk-PSBP27ZK.js +1 -0
  137. package/dist/standalone/chunk-PSPSEIFN.js +1 -0
  138. package/dist/standalone/{chunk-SYJQ3QYJ.js → chunk-PUBYZCHW.js} +1 -1
  139. package/dist/standalone/{chunk-7PKIWAFQ.js → chunk-PVNT7VXC.js} +1 -1
  140. package/dist/standalone/{chunk-BDO4YYBB.js → chunk-PY5P53RV.js} +3 -3
  141. package/dist/standalone/{chunk-LBMSRD6N.js → chunk-Q2F2DRGB.js} +1 -1
  142. package/dist/standalone/chunk-QKZ2JCH3.js +1 -0
  143. package/dist/standalone/{chunk-F2FPKLFM.js → chunk-RBJMRBC3.js} +1 -1
  144. package/dist/standalone/{chunk-SGBJAOTU.js → chunk-RE4RWXYW.js} +1 -1
  145. package/dist/standalone/{chunk-XUNTO4S2.js → chunk-RVBRSHYE.js} +1 -1
  146. package/dist/standalone/{chunk-3OI7B7W6.js → chunk-SEBIGECV.js} +1 -1
  147. package/dist/standalone/{chunk-6EJUU2ZR.js → chunk-TZHEXHD4.js} +1 -1
  148. package/dist/standalone/{chunk-4FNAK556.js → chunk-UTPXXTQ6.js} +1 -1
  149. package/dist/standalone/chunk-UYKO4I36.js +1 -0
  150. package/dist/standalone/chunk-V2JKX5UU.js +14 -0
  151. package/dist/standalone/{chunk-EHTUWA7S.js → chunk-V2LIXSFE.js} +1 -1
  152. package/dist/standalone/{chunk-YHCB77HW.js → chunk-VQM2MKYO.js} +1 -1
  153. package/dist/standalone/chunk-VQTSESFP.js +1 -0
  154. package/dist/standalone/{chunk-HRHJB4QO.js → chunk-WINPNKYC.js} +1 -1
  155. package/dist/standalone/{chunk-BMDPZOBN.js → chunk-Y5PCZUGU.js} +1 -1
  156. package/dist/standalone/{chunk-A2TVIAEC.js → chunk-YBCFAAQJ.js} +1 -1
  157. package/dist/standalone/chunk-YV6JXZJO.js +1 -0
  158. package/dist/standalone/{chunk-2DX5MROH.js → chunk-ZHM5ZHPC.js} +1 -1
  159. package/dist/standalone/{chunk-PD6WIDY6.js → chunk-ZJZNCJHY.js} +1 -1
  160. package/dist/standalone/{chunk-OVBIGTEL.js → chunk-ZUGCPRKB.js} +1 -1
  161. package/dist/standalone/studio.js +1 -1
  162. package/dist/styles.css +1 -1
  163. package/package.json +6 -6
  164. package/dist/packem_shared/DataBrowser-DLRa1EYq.mjs +0 -4
  165. package/dist/packem_shared/GlobalDataBrowser-BTbqR6Wc.mjs +0 -1
  166. package/dist/packem_shared/Studio-CcWQdYrV.mjs +0 -1
  167. package/dist/packem_shared/aggregateMetrics-CY05xrYU.mjs +0 -1
  168. package/dist/packem_shared/data-view-params-qoSTqjAj.mjs +0 -1
  169. package/dist/packem_shared/home-panel-DCUKd8Uk.mjs +0 -3
  170. package/dist/packem_shared/internal-B6haJbiP.mjs +0 -2
  171. package/dist/packem_shared/reference-view-DiikOols.mjs +0 -13
  172. package/dist/packem_shared/table-list-sidebar-DHG1UJC4.mjs +0 -1
  173. package/dist/standalone/chunk-4BSUMM2O.js +0 -1
  174. package/dist/standalone/chunk-4IE4RCU2.js +0 -14
  175. package/dist/standalone/chunk-6IGGJN74.js +0 -1
  176. package/dist/standalone/chunk-75TJGBCF.js +0 -1
  177. package/dist/standalone/chunk-AFUPTCKG.js +0 -1
  178. package/dist/standalone/chunk-C3RVT4ZV.js +0 -1
  179. package/dist/standalone/chunk-EC4MB5HF.js +0 -5
  180. package/dist/standalone/chunk-ETRF5USL.js +0 -1
  181. package/dist/standalone/chunk-FR7VMBTI.js +0 -1
  182. package/dist/standalone/chunk-J54ZPBT7.js +0 -1
  183. package/dist/standalone/chunk-ORJ7WS3N.js +0 -1
  184. package/dist/standalone/chunk-RLLKECZT.js +0 -1
  185. package/dist/standalone/chunk-SI6H2NVN.js +0 -1
  186. package/dist/standalone/chunk-SUDJTC4S.js +0 -1
  187. package/dist/standalone/chunk-SYDJEFWA.js +0 -1
  188. package/dist/standalone/chunk-TFDBSYX4.js +0 -15
  189. package/dist/standalone/chunk-UEVR3CED.js +0 -2
  190. package/dist/standalone/chunk-UEZQP5EU.js +0 -9
  191. package/dist/standalone/chunk-XGJNOLY6.js +0 -1
  192. package/dist/standalone/chunk-XNHCCZZZ.js +0 -3
  193. package/dist/standalone/chunk-ZGMLIJ7Y.js +0 -1
@@ -1 +1 @@
1
- import{useState as x,useRef as he,useEffect as se}from"react";import{b as xe,d as ye,c as be,a as de,C as ce}from"../packem_shared/card--2hKx4L2.mjs";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as me}from"react/compiler-runtime";import{E as ge}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{L as ve}from"../packem_shared/live-status-BuJdUZFU.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as D}from"../packem_shared/button-q0UYSmrn.mjs";import{E as fe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Ne,a as ke,b as oe,c as te,d as Se,e as ae}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{ADMIN_FUNCTIONS as X}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as i,jsx as a}from"react/jsx-runtime";import{useLunora as pe}from"@lunora/react";import{ShardInput as Ce}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{I as K}from"../packem_shared/input-CXhxesPC.mjs";import{L as $}from"../packem_shared/label-DKFzyHq6.mjs";import{T as we}from"../packem_shared/textarea--40GKAyz.mjs";import{d as Pe,c as Ae,b as Ee,f as le}from"../packem_shared/internal-B6haJbiP.mjs";const ie=["read","insert","update","delete"],Te=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],_e=e=>e.file===""?e.procedure:`${e.file}:${e.procedure}`,Ie=e=>{const t=new Set;for(const s of e?.advisories??[])if(s.name==="rls_uncovered_table"){const{table:d}=s.metadata;typeof d=="string"&&d!==""&&t.add(d)}return t},Re=(e,t,s)=>{const d=new Map,r=n=>{const o=d.get(n);if(o!==void 0)return o;const f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:s.has(n)};return d.set(n,f),f};for(const n of e)r(n.table).cells[n.on]={path:_e(n),procedure:n.procedure};for(const n of t)r(n.table).maskedColumns.add(n.column);for(const n of s)r(n);return[...d.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},Fe=e=>{const t=me(17);let s;t[0]!==e?(s=e===void 0?{}:e,t[0]=e,t[1]=s):s=t[1];const{onProbe:d}=s,r=ee();let n,o;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},t[2]=n,t[3]=o):(n=t[2],o=t[3]);const f=re(X.rlsPolicies,n,o);let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l={},t[4]=l):l=t[4];const b=re(X.maskPolicies,l);let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h={},t[5]=h):h=t[5];const g=re(X.getAdvisories,h);let v;if(t[6]!==g.data||t[7]!==b.data||t[8]!==d||t[9]!==f||t[10]!==r){let N=null;f.data!==void 0&&(N=Array.isArray(f.data.policies)?f.data.policies:[]);const _=Array.isArray(b.data?.columns)?b.data.columns:[],U=g.data??null,{error:w,errorSource:k,liveError:P}=f,E=N===null?[]:Re(N,_,Ie(U));let S;t[12]!==P?(S=a("div",{className:"flex items-center justify-end",children:a(ve,{message:P,prefix:"pm"})}),t[12]=P,t[13]=S):S=t[13];let p;t[14]!==w||t[15]!==k?(p=w!==null&&a(ge,{error:k,testId:"pm-error"}),t[14]=w,t[15]=k,t[16]=p):p=t[16],v=i("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[S,p,N!==null&&E.length===0?a(fe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):i(Ne,{"data-testid":"pm-table",children:[a(ke,{children:i(oe,{children:[a(te,{children:r("Table")}),ie.map(c=>a(te,{children:Te(r,c)},c)),a(te,{children:r("Masked columns")})]})}),a(Se,{children:E.map(c=>i(oe,{"data-testid":`pm-row-${c.table}`,children:[a(ae,{className:"font-mono text-xs",children:i("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&a(L,{"data-testid":`pm-uncovered-${c.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),ie.map(A=>{const y=c.cells[A];return a(ae,{"data-testid":`pm-cell-${c.table}-${A}`,children:y.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):i("span",{className:"flex flex-col gap-1",children:[a(L,{variant:"secondary",children:r("Covered by {procedure}",{procedure:y.procedure})}),d!==void 0&&a(D,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${A}`,onClick:()=>{d(c.table,A,y.path??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},A)}),a(ae,{children:c.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Oe)})})]},c.table))})]})]}),t[6]=g.data,t[7]=b.data,t[8]=d,t[9]=f,t[10]=r,t[11]=v}else v=t[11];return v};function Oe(e){return a(L,{variant:"outline",children:e},e)}const De=Ae(X.runAs),Le=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),$e=e=>{const t=e?.code;return typeof t=="string"?t:void 0},Ue=()=>{const e=pe();return async({args:t,functionPath:s,shardKey:d="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};const n=De;try{return{kind:"allowed",value:await e.query(n,{args:t,functionPath:s,userId:r},Pe(d))}}catch(o){const f=o instanceof Error?o.message:String(o),l=$e(o);return l!==void 0&&Le.has(l)?{kind:"denied",message:f}:{kind:"errored",message:f}}}},Me=e=>e===void 0?"undefined":JSON.stringify(e,null,2),ze=({functions:e,prefill:t,runAsIdentity:s=!1}={})=>{const d=pe(),r=ee(),n=Ue(),[o,f]=x(null),[l,b]=x(null),h=e??o??[],[g,v]=x(""),[N,_]=x("{}"),[U,w]=x(""),[k,P]=x(""),[E,S]=x(!1),[p,c]=x(null),[A,y]=x(null),T=he(-1);se(()=>{if(e!==void 0)return;let m=!1;return d.listFunctions().then(u=>(m||f(u),u)).catch(u=>{m||b(Ee(u))}),()=>{m=!0}},[d,e]),se(()=>{if(t===void 0||T.current===t.nonce)return;T.current=t.nonce;const m=t.functionPath;queueMicrotask(()=>{v(m),c(null)})},[t]);const C=g===""?h[0]?.path??"":g,I=async()=>{if(C==="")return;let m;try{m=N.trim()===""?{}:JSON.parse(N)}catch(u){y(r("Invalid JSON args: {message}",{message:u.message})),c(null);return}y(null),S(!0);try{const u=await n({args:m,functionPath:C,shardKey:U.trim(),userId:k.trim()});c(u)}finally{S(!1)}},R=()=>{le(I())},Y=m=>{v(m.target.value)},F=m=>{_(m.target.value)},O=m=>{P(m.target.value)};return i("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[l!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:l}),!s&&a(fe,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),i("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[i("div",{className:"flex flex-col gap-1.5",children:[a($,{htmlFor:"pp-function",children:r("Function")}),a("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:Y,value:C,children:h.map(m=>i("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),i("div",{className:"flex flex-col gap-1.5",children:[a($,{htmlFor:"pp-args",children:r("Arguments")}),a(we,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:F,value:N})]}),a(Ce,{onChange:w,testId:"pp-shard",value:U}),i("div",{className:"flex flex-col gap-1.5",children:[a($,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(K,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:O,placeholder:r("Required — the identity to probe as"),value:k})]}),i("div",{className:"flex items-center gap-2",children:[a(D,{"data-testid":"pp-run",disabled:!s||E||C==="",onClick:R,type:"button",children:r(E?"Probing…":"Run probe")}),k.trim()!==""&&a(L,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:k.trim()})})]})]}),A!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:A}),p!==null&&p.kind==="allowed"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a(L,{variant:"secondary",children:r("Allowed")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Me(p.value)})]}),p!==null&&p.kind==="invalid"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[a(L,{variant:"outline",children:r("Not run")}),a("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:p.message})]}),p!==null&&p.kind==="errored"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[a(L,{variant:"outline",children:r("Errored")}),a("p",{className:"text-sm text-muted-foreground",children:r("The call failed for a reason that is not an access verdict, so it says nothing about the policy.")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:p.message})]}),p!==null&&p.kind==="denied"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a(L,{variant:"destructive",children:r("Denied")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:p.message})]})]})},Be="/__lunora/policy-scaffold",je={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists — pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."},We=async e=>{const t=await fetch(Be,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),s=await t.json();if(s.needsManualEdit===!0)return{kind:"needs-manual-edit",message:s.message??"This change must be made by hand."};if(t.ok)return{diagnostics:s.diagnostics??[],kind:"ok",label:s.fileName??s.exportName??""};const d=s.error;return{kind:"error",message:d===void 0?`policy scaffold failed (${String(t.status)})`:je[d]??d}},ne={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},qe=()=>{const e=me(69),t=ee(),[s,d]=x(null),[r,n]=x(!1),[o,f]=x(null),[l,b]=x(ne);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=Z=>{const J=Z.target.name,{value:G}=Z.target;b(ue=>({...ue,[J]:G}))},e[0]=h):h=e[0];const g=h;let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{d(null),b(ne)},e[1]=v):v=e[1];const N=v;let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=async Z=>{n(!0),f(null);try{const J=await We(Z);f(J),J.kind==="ok"&&N()}catch(J){const G=J;f({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},e[2]=_):_=e[2];const U=_;let w;e[3]!==l.policyName||e[4]!==l.tableName?(w=()=>{le(U({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},e[3]=l.policyName,e[4]=l.tableName,e[5]=w):w=e[5];const k=w;let P;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(P=()=>{le(U({exportName:l.exportName.trim(),filePath:l.filePath.trim(),kind:"wireRls",policies:l.policies.trim()}))},e[6]=l.exportName,e[7]=l.filePath,e[8]=l.policies,e[9]=P):P=e[9];const E=P;let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{f(null),d("scaffold")},e[10]=S):S=e[10];const p=S;let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{f(null),d("wire")},e[11]=c):c=e[11];const A=c;let y;e[12]!==t?(y=t("Scaffold access rules"),e[12]=t,e[13]=y):y=e[13];let T;e[14]!==y?(T=a(xe,{children:y}),e[14]=y,e[15]=T):T=e[15];let C;e[16]!==t?(C=t("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=t,e[17]=C):C=e[17];let I;e[18]!==C?(I=a(ye,{children:C}),e[18]=C,e[19]=I):I=e[19];let R;e[20]!==I||e[21]!==T?(R=i(be,{children:[T,I]}),e[20]=I,e[21]=T,e[22]=R):R=e[22];const Y=s==="scaffold"?"default":"outline";let F;e[23]!==t?(F=t("New policy file"),e[23]=t,e[24]=F):F=e[24];let O;e[25]!==Y||e[26]!==F?(O=a(D,{"data-testid":"policy-scaffolder-new",onClick:p,size:"xs",type:"button",variant:Y,children:F}),e[25]=Y,e[26]=F,e[27]=O):O=e[27];const m=s==="wire"?"default":"outline";let u;e[28]!==t?(u=t("Wire into a procedure"),e[28]=t,e[29]=u):u=e[29];let M;e[30]!==m||e[31]!==u?(M=a(D,{"data-testid":"policy-scaffolder-wire",onClick:A,size:"xs",type:"button",variant:m,children:u}),e[30]=m,e[31]=u,e[32]=M):M=e[32];let z;e[33]!==O||e[34]!==M?(z=i("div",{className:"flex flex-wrap gap-2",children:[O,M]}),e[33]=O,e[34]=M,e[35]=z):z=e[35];let B;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==s||e[40]!==k||e[41]!==t?(B=s==="scaffold"&&i("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(K,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:l.policyName})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(K,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:l.tableName})]}),a(D,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:k,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(D,{onClick:N,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=s,e[40]=k,e[41]=t,e[42]=B):B=e[42];let j;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==s||e[48]!==E||e[49]!==t?(j=s==="wire"&&i("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(K,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:l.filePath})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(K,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:l.exportName})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(K,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:l.policies})]}),a(D,{"data-testid":"policy-scaffolder-apply",disabled:r||l.filePath.trim()===""||l.exportName.trim()===""||l.policies.trim()==="",onClick:E,size:"xs",type:"button",children:t(r?"Wiring…":"Wire RLS")}),a(D,{onClick:N,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[43]=r,e[44]=l.exportName,e[45]=l.filePath,e[46]=l.policies,e[47]=s,e[48]=E,e[49]=t,e[50]=j):j=e[50];let W;e[51]!==o?(W=o?.kind==="error"&&a("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=W):W=e[52];let q;e[53]!==o?.kind||e[54]!==t?(q=o?.kind==="needs-manual-edit"&&a("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:t("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=t,e[55]=q):q=e[55];let Q;e[56]!==o||e[57]!==t?(Q=o?.kind==="ok"&&i("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[a("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:t("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&a("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Qe)})]}),e[56]=o,e[57]=t,e[58]=Q):Q=e[58];let H;e[59]!==z||e[60]!==B||e[61]!==j||e[62]!==W||e[63]!==q||e[64]!==Q?(H=i(de,{children:[z,B,j,W,q,Q]}),e[59]=z,e[60]=B,e[61]=j,e[62]=W,e[63]=q,e[64]=Q,e[65]=H):H=e[65];let V;return e[66]!==R||e[67]!==H?(V=i(ce,{"data-testid":"policy-scaffolder",size:"sm",children:[R,H]}),e[66]=R,e[67]=H,e[68]=V):V=e[68],V};function Qe(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const mt=({functions:e,runAsIdentity:t=!1,schemaEditable:s=!1}={})=>{const d=ee(),[r,n]=x(void 0),o=(f,l,b)=>{b!==""&&n(h=>({functionPath:b,nonce:(h?.nonce??0)+1}))};return i("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[i("section",{className:"flex flex-col gap-3",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Permissions")})}),a(Fe,{onProbe:o})]}),a("section",{className:"flex flex-col gap-3",children:i(ce,{className:"gap-0 py-0",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Probe")})}),i(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:d("Pick a function and an identity, then run it to see the access outcome.")}),a(ze,{functions:e,prefill:r,runAsIdentity:t})]})]})}),s&&a("section",{className:"flex flex-col gap-2",children:a(qe,{})})]})};export{mt as PermissionsPanel};
1
+ import{useState as x,useRef as he,useEffect as se}from"react";import{b as xe,d as ye,c as be,a as de,C as ce}from"../packem_shared/card--2hKx4L2.mjs";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as me}from"react/compiler-runtime";import{E as ge}from"../packem_shared/error-alert-dQk3g8WI.mjs";import{L as ve}from"../packem_shared/live-status-BuJdUZFU.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as D}from"../packem_shared/button-q0UYSmrn.mjs";import{E as fe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Ne,a as ke,b as oe,c as te,d as Se,e as ae}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{ADMIN_FUNCTIONS as X}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as i,jsx as a}from"react/jsx-runtime";import{useLunora as pe}from"@lunora/react";import{d as Ce}from"../packem_shared/wire-codec-Bk4XZGE4.mjs";import{ShardInput as we}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{I as K}from"../packem_shared/input-CXhxesPC.mjs";import{L as $}from"../packem_shared/label-DKFzyHq6.mjs";import{T as Pe}from"../packem_shared/textarea--40GKAyz.mjs";import{d as Ae,c as Ee,b as Te,f as le,j as _e}from"../packem_shared/internal-CyDwqA67.mjs";const ie=["read","insert","update","delete"],Ie=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],Re=e=>e.file===""?e.procedure:`${e.file}:${e.procedure}`,Fe=e=>{const t=new Set;for(const s of e?.advisories??[])if(s.name==="rls_uncovered_table"){const{table:d}=s.metadata;typeof d=="string"&&d!==""&&t.add(d)}return t},Oe=(e,t,s)=>{const d=new Map,r=n=>{const o=d.get(n);if(o!==void 0)return o;const f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:s.has(n)};return d.set(n,f),f};for(const n of e)r(n.table).cells[n.on]={path:Re(n),procedure:n.procedure};for(const n of t)r(n.table).maskedColumns.add(n.column);for(const n of s)r(n);return[...d.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},De=e=>{const t=me(17);let s;t[0]!==e?(s=e===void 0?{}:e,t[0]=e,t[1]=s):s=t[1];const{onProbe:d}=s,r=ee();let n,o;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},t[2]=n,t[3]=o):(n=t[2],o=t[3]);const f=re(X.rlsPolicies,n,o);let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l={},t[4]=l):l=t[4];const b=re(X.maskPolicies,l);let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h={},t[5]=h):h=t[5];const g=re(X.getAdvisories,h);let v;if(t[6]!==g.data||t[7]!==b.data||t[8]!==d||t[9]!==f||t[10]!==r){let N=null;f.data!==void 0&&(N=Array.isArray(f.data.policies)?f.data.policies:[]);const _=Array.isArray(b.data?.columns)?b.data.columns:[],U=g.data??null,{error:w,errorSource:k,liveError:P}=f,E=N===null?[]:Oe(N,_,Fe(U));let S;t[12]!==P?(S=a("div",{className:"flex items-center justify-end",children:a(ve,{message:P,prefix:"pm"})}),t[12]=P,t[13]=S):S=t[13];let p;t[14]!==w||t[15]!==k?(p=w!==null&&a(ge,{error:k,testId:"pm-error"}),t[14]=w,t[15]=k,t[16]=p):p=t[16],v=i("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[S,p,N!==null&&E.length===0?a(fe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):i(Ne,{"data-testid":"pm-table",children:[a(ke,{children:i(oe,{children:[a(te,{children:r("Table")}),ie.map(c=>a(te,{children:Ie(r,c)},c)),a(te,{children:r("Masked columns")})]})}),a(Se,{children:E.map(c=>i(oe,{"data-testid":`pm-row-${c.table}`,children:[a(ae,{className:"font-mono text-xs",children:i("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&a(L,{"data-testid":`pm-uncovered-${c.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),ie.map(A=>{const y=c.cells[A];return a(ae,{"data-testid":`pm-cell-${c.table}-${A}`,children:y.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):i("span",{className:"flex flex-col gap-1",children:[a(L,{variant:"secondary",children:r("Covered by {procedure}",{procedure:y.procedure})}),d!==void 0&&a(D,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${A}`,onClick:()=>{d(c.table,A,y.path??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},A)}),a(ae,{children:c.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Le)})})]},c.table))})]})]}),t[6]=g.data,t[7]=b.data,t[8]=d,t[9]=f,t[10]=r,t[11]=v}else v=t[11];return v};function Le(e){return a(L,{variant:"outline",children:e},e)}const $e=Ee(X.runAs),Ue=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),Me=e=>{const t=e?.code;return typeof t=="string"?t:void 0},ze=()=>{const e=pe();return async({args:t,functionPath:s,shardKey:d="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};const n=$e;try{return{kind:"allowed",value:await e.query(n,{args:t,functionPath:s,userId:r},Ae(d))}}catch(o){const f=o instanceof Error?o.message:String(o),l=Me(o);return l!==void 0&&Ue.has(l)?{kind:"denied",message:f}:{kind:"errored",message:f}}}},je=e=>e===void 0?"undefined":JSON.stringify(e,_e,2),Be=({functions:e,prefill:t,runAsIdentity:s=!1}={})=>{const d=pe(),r=ee(),n=ze(),[o,f]=x(null),[l,b]=x(null),h=e??o??[],[g,v]=x(""),[N,_]=x("{}"),[U,w]=x(""),[k,P]=x(""),[E,S]=x(!1),[p,c]=x(null),[A,y]=x(null),T=he(-1);se(()=>{if(e!==void 0)return;let m=!1;return d.listFunctions().then(u=>(m||f(u),u)).catch(u=>{m||b(Te(u))}),()=>{m=!0}},[d,e]),se(()=>{if(t===void 0||T.current===t.nonce)return;T.current=t.nonce;const m=t.functionPath;queueMicrotask(()=>{v(m),c(null)})},[t]);const C=g===""?h[0]?.path??"":g,I=async()=>{if(C==="")return;let m;try{m=N.trim()===""?{}:Ce(JSON.parse(N))}catch(u){y(r("Invalid JSON args: {message}",{message:u.message})),c(null);return}y(null),S(!0);try{const u=await n({args:m,functionPath:C,shardKey:U.trim(),userId:k.trim()});c(u)}finally{S(!1)}},R=()=>{le(I())},Y=m=>{v(m.target.value)},F=m=>{_(m.target.value)},O=m=>{P(m.target.value)};return i("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[l!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:l}),!s&&a(fe,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),i("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[i("div",{className:"flex flex-col gap-1.5",children:[a($,{htmlFor:"pp-function",children:r("Function")}),a("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:Y,value:C,children:h.map(m=>i("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),i("div",{className:"flex flex-col gap-1.5",children:[a($,{htmlFor:"pp-args",children:r("Arguments")}),a(Pe,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:F,value:N})]}),a(we,{onChange:w,testId:"pp-shard",value:U}),i("div",{className:"flex flex-col gap-1.5",children:[a($,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(K,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:O,placeholder:r("Required — the identity to probe as"),value:k})]}),i("div",{className:"flex items-center gap-2",children:[a(D,{"data-testid":"pp-run",disabled:!s||E||C==="",onClick:R,type:"button",children:r(E?"Probing…":"Run probe")}),k.trim()!==""&&a(L,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:k.trim()})})]})]}),A!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:A}),p!==null&&p.kind==="allowed"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a(L,{variant:"secondary",children:r("Allowed")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(p.value)})]}),p!==null&&p.kind==="invalid"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[a(L,{variant:"outline",children:r("Not run")}),a("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:p.message})]}),p!==null&&p.kind==="errored"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[a(L,{variant:"outline",children:r("Errored")}),a("p",{className:"text-sm text-muted-foreground",children:r("The call failed for a reason that is not an access verdict, so it says nothing about the policy.")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:p.message})]}),p!==null&&p.kind==="denied"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a(L,{variant:"destructive",children:r("Denied")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:p.message})]})]})},We="/__lunora/policy-scaffold",qe={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists — pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."},Qe=async e=>{const t=await fetch(We,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),s=await t.json();if(s.needsManualEdit===!0)return{kind:"needs-manual-edit",message:s.message??"This change must be made by hand."};if(t.ok)return{diagnostics:s.diagnostics??[],kind:"ok",label:s.fileName??s.exportName??""};const d=s.error;return{kind:"error",message:d===void 0?`policy scaffold failed (${String(t.status)})`:qe[d]??d}},ne={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},He=()=>{const e=me(69),t=ee(),[s,d]=x(null),[r,n]=x(!1),[o,f]=x(null),[l,b]=x(ne);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=Z=>{const J=Z.target.name,{value:G}=Z.target;b(ue=>({...ue,[J]:G}))},e[0]=h):h=e[0];const g=h;let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{d(null),b(ne)},e[1]=v):v=e[1];const N=v;let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=async Z=>{n(!0),f(null);try{const J=await Qe(Z);f(J),J.kind==="ok"&&N()}catch(J){const G=J;f({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},e[2]=_):_=e[2];const U=_;let w;e[3]!==l.policyName||e[4]!==l.tableName?(w=()=>{le(U({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},e[3]=l.policyName,e[4]=l.tableName,e[5]=w):w=e[5];const k=w;let P;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(P=()=>{le(U({exportName:l.exportName.trim(),filePath:l.filePath.trim(),kind:"wireRls",policies:l.policies.trim()}))},e[6]=l.exportName,e[7]=l.filePath,e[8]=l.policies,e[9]=P):P=e[9];const E=P;let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{f(null),d("scaffold")},e[10]=S):S=e[10];const p=S;let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{f(null),d("wire")},e[11]=c):c=e[11];const A=c;let y;e[12]!==t?(y=t("Scaffold access rules"),e[12]=t,e[13]=y):y=e[13];let T;e[14]!==y?(T=a(xe,{children:y}),e[14]=y,e[15]=T):T=e[15];let C;e[16]!==t?(C=t("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=t,e[17]=C):C=e[17];let I;e[18]!==C?(I=a(ye,{children:C}),e[18]=C,e[19]=I):I=e[19];let R;e[20]!==I||e[21]!==T?(R=i(be,{children:[T,I]}),e[20]=I,e[21]=T,e[22]=R):R=e[22];const Y=s==="scaffold"?"default":"outline";let F;e[23]!==t?(F=t("New policy file"),e[23]=t,e[24]=F):F=e[24];let O;e[25]!==Y||e[26]!==F?(O=a(D,{"data-testid":"policy-scaffolder-new",onClick:p,size:"xs",type:"button",variant:Y,children:F}),e[25]=Y,e[26]=F,e[27]=O):O=e[27];const m=s==="wire"?"default":"outline";let u;e[28]!==t?(u=t("Wire into a procedure"),e[28]=t,e[29]=u):u=e[29];let M;e[30]!==m||e[31]!==u?(M=a(D,{"data-testid":"policy-scaffolder-wire",onClick:A,size:"xs",type:"button",variant:m,children:u}),e[30]=m,e[31]=u,e[32]=M):M=e[32];let z;e[33]!==O||e[34]!==M?(z=i("div",{className:"flex flex-wrap gap-2",children:[O,M]}),e[33]=O,e[34]=M,e[35]=z):z=e[35];let j;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==s||e[40]!==k||e[41]!==t?(j=s==="scaffold"&&i("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(K,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:l.policyName})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(K,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:l.tableName})]}),a(D,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:k,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(D,{onClick:N,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=s,e[40]=k,e[41]=t,e[42]=j):j=e[42];let B;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==s||e[48]!==E||e[49]!==t?(B=s==="wire"&&i("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(K,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:l.filePath})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(K,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:l.exportName})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a($,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(K,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:l.policies})]}),a(D,{"data-testid":"policy-scaffolder-apply",disabled:r||l.filePath.trim()===""||l.exportName.trim()===""||l.policies.trim()==="",onClick:E,size:"xs",type:"button",children:t(r?"Wiring…":"Wire RLS")}),a(D,{onClick:N,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[43]=r,e[44]=l.exportName,e[45]=l.filePath,e[46]=l.policies,e[47]=s,e[48]=E,e[49]=t,e[50]=B):B=e[50];let W;e[51]!==o?(W=o?.kind==="error"&&a("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=W):W=e[52];let q;e[53]!==o?.kind||e[54]!==t?(q=o?.kind==="needs-manual-edit"&&a("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:t("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=t,e[55]=q):q=e[55];let Q;e[56]!==o||e[57]!==t?(Q=o?.kind==="ok"&&i("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[a("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:t("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&a("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Je)})]}),e[56]=o,e[57]=t,e[58]=Q):Q=e[58];let H;e[59]!==z||e[60]!==j||e[61]!==B||e[62]!==W||e[63]!==q||e[64]!==Q?(H=i(de,{children:[z,j,B,W,q,Q]}),e[59]=z,e[60]=j,e[61]=B,e[62]=W,e[63]=q,e[64]=Q,e[65]=H):H=e[65];let V;return e[66]!==R||e[67]!==H?(V=i(ce,{"data-testid":"policy-scaffolder",size:"sm",children:[R,H]}),e[66]=R,e[67]=H,e[68]=V):V=e[68],V};function Je(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const ut=({functions:e,runAsIdentity:t=!1,schemaEditable:s=!1}={})=>{const d=ee(),[r,n]=x(void 0),o=(f,l,b)=>{b!==""&&n(h=>({functionPath:b,nonce:(h?.nonce??0)+1}))};return i("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[i("section",{className:"flex flex-col gap-3",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Permissions")})}),a(De,{onProbe:o})]}),a("section",{className:"flex flex-col gap-3",children:i(ce,{className:"gap-0 py-0",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Probe")})}),i(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:d("Pick a function and an identity, then run it to see the access outcome.")}),a(Be,{functions:e,prefill:r,runAsIdentity:t})]})]})}),s&&a("section",{className:"flex flex-col gap-2",children:a(He,{})})]})};export{ut as PermissionsPanel};
@@ -1 +1 @@
1
- import{c as P}from"react/compiler-runtime";import{useLunora as Ve}from"@lunora/react";import{useState as M}from"react";import{ConfirmButton as Ye}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{E as Xe}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{A as Ke}from"../packem_shared/alert-PB5W11MM.mjs";import{B as ve}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as we}from"../packem_shared/button-q0UYSmrn.mjs";import{C as $e,a as Oe}from"../packem_shared/card--2hKx4L2.mjs";import{E as Qe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as Ze}from"../packem_shared/input-CXhxesPC.mjs";import{S as et}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as ke,a as Ue,b as oe,c as _,d as Je,e as T}from"../packem_shared/table-D0SBiDu-.mjs";import{T as tt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Be}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{useAutoRefresh as st}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{useT as j}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as G}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{d as _e,b as Te,c as Ae,f as Ce,h as at}from"../packem_shared/internal-B6haJbiP.mjs";import{jsx as s,jsxs as q,Fragment as Fe}from"react/jsx-runtime";const rt=(n,e)=>{const t=new Set(n.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=n.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!t.has(a.name)),l=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:l,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||l>0}},nt=200,ot=Ae(G.sendQueueMessage),lt=Ae(G.replayQueueMessage),dt=Ae(G.clearQueueMessages),Re=96,it=n=>{if(n===void 0)return"—";try{return JSON.stringify(n)}catch{return"[unserializable]"}},ct=n=>n.length>Re?`${n.slice(0,Re)}…`:n,ut=n=>n==="error"?"destructive":n==="retry"?"outline":"secondary",mt=(n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),ft=n=>{const e=P(11),{loaded:t,queues:i}=n,l=j();let a;e[0]!==l?(a=l("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=l,e[1]=a):a=e[1];let o;e[2]!==a?(o=s("p",{className:"text-sm text-muted-foreground",children:a}),e[2]=a,e[3]=o):o=e[3];let r;e[4]!==t||e[5]!==i||e[6]!==l?(r=t&&i.length===0?s(Qe,{description:l("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:l("No queues defined")}):s($e,{className:"overflow-hidden py-0",children:s(Oe,{className:"px-0",children:q(ke,{"data-testid":"queues-table",children:[s(Ue,{children:q(oe,{children:[s(_,{children:l("Export")}),s(_,{children:l("Queue")}),s(_,{children:l("Mode")}),s(_,{children:l("Binding")}),s(_,{children:l("Dead-letter")})]})}),s(Je,{children:i.map(xt)})]})})}),e[4]=t,e[5]=i,e[6]=l,e[7]=r):r=e[7];let f;return e[8]!==o||e[9]!==r?(f=q("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=f):f=e[10],f},ht=n=>{const e=P(67),{message:t,onReplay:i,replayingId:l}=n,a=j();let o,r,f,u,g,y,x,d,m,p;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==a){const U=it(t.body);r=oe,y=`queues-message-${t.id}`;const J=t.exportName??t.queue;e[19]!==J?(x=s(T,{className:"font-mono text-xs",children:J}),e[19]=J,e[20]=x):x=e[20],e[21]!==t.messageId?(d=s(T,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=d):d=e[22],e[23]!==t.attempts?(m=s(T,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const A=`queues-outcome-${t.id}`;let I;e[25]!==t.outcome?(I=ut(t.outcome),e[25]=t.outcome,e[26]=I):I=e[26];let C;e[27]!==t.outcome||e[28]!==A||e[29]!==I?(C=s(ve,{"data-testid":A,variant:I,children:t.outcome}),e[27]=t.outcome,e[28]=A,e[29]=I,e[30]=C):C=e[30];let L;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==a?(L=t.deadLettered&&s(ve,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:a("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=a,e[34]=L):L=e[34],e[35]!==C||e[36]!==L?(p=s(T,{children:q("span",{className:"inline-flex items-center gap-1",children:[C,L]})}),e[35]=C,e[36]=L,e[37]=p):p=e[37],o=T,f="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=U,g=ct(U),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=a,e[9]=o,e[10]=r,e[11]=f,e[12]=u,e[13]=g,e[14]=y,e[15]=x,e[16]=d,e[17]=m,e[18]=p}else o=e[9],r=e[10],f=e[11],u=e[12],g=e[13],y=e[14],x=e[15],d=e[16],m=e[17],p=e[18];let h;e[38]!==o||e[39]!==f||e[40]!==u||e[41]!==g?(h=s(o,{className:f,title:u,children:g}),e[38]=o,e[39]=f,e[40]=u,e[41]=g,e[42]=h):h=e[42];let N;e[43]!==t.capturedAt?(N=at(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=s(T,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=b):b=e[46];const E=`queues-replay-${t.id}`,Q=l!==null;let v;e[47]!==t.id||e[48]!==l||e[49]!==a?(v=l===t.id?a("Replaying…"):a("Replay"),e[47]=t.id,e[48]=l,e[49]=a,e[50]=v):v=e[50];let w;e[51]!==t.id||e[52]!==i||e[53]!==E||e[54]!==Q||e[55]!==v?(w=s(T,{children:s(we,{"data-id":t.id,"data-testid":E,disabled:Q,onClick:i,size:"xs",type:"button",variant:"outline",children:v})}),e[51]=t.id,e[52]=i,e[53]=E,e[54]=Q,e[55]=v,e[56]=w):w=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==w||e[60]!==y||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==p||e[65]!==h?(D=q(r,{"data-testid":y,children:[x,d,m,p,h,b,w]}),e[57]=r,e[58]=b,e[59]=w,e[60]=y,e[61]=x,e[62]=d,e[63]=m,e[64]=p,e[65]=h,e[66]=D):D=e[66],D},pt=n=>{const e=P(29),{hasError:t,messages:i,onClear:l,onReplay:a,replayingId:o}=n,r=j();let f;e[0]!==r?(f=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=r,e[1]=f):f=e[1];let u;e[2]!==f?(u=s("p",{className:"text-sm text-muted-foreground",children:f}),e[2]=f,e[3]=u):u=e[3];let g;e[4]!==r?(g=r("Clear the whole message log?"),e[4]=r,e[5]=g):g=e[5];const y=i.length===0;let x;e[6]!==r?(x=r("Clear log"),e[6]=r,e[7]=x):x=e[7];let d;e[8]!==l||e[9]!==g||e[10]!==y||e[11]!==x?(d=s("div",{className:"ml-auto",children:s(Ye,{confirmLabel:g,disabled:y,onConfirm:l,testId:"queues-clear",children:x})}),e[8]=l,e[9]=g,e[10]=y,e[11]=x,e[12]=d):d=e[12];let m;e[13]!==i.length||e[14]!==r?(m=i.length>0&&s(ve,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=r,e[15]=m):m=e[15];let p;e[16]!==u||e[17]!==d||e[18]!==m?(p=q("div",{className:"flex flex-wrap items-center gap-2",children:[u,d,m]}),e[16]=u,e[17]=d,e[18]=m,e[19]=p):p=e[19];let h;e[20]!==t||e[21]!==i||e[22]!==a||e[23]!==o||e[24]!==r?(h=!t&&i.length===0?s(Qe,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")}):s($e,{className:"overflow-hidden py-0",children:s(Oe,{className:"px-0",children:s(et,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:q(ke,{"data-testid":"queues-messages-table",children:[s(Ue,{children:q(oe,{children:[s(_,{children:r("Export")}),s(_,{children:r("Message")}),s(_,{children:r("Attempts")}),s(_,{children:r("Outcome")}),s(_,{children:r("Body")}),s(_,{children:r("Captured")}),s(_,{})]})}),s(Je,{children:i.map(b=>s(ht,{message:b,onReplay:a,replayingId:o},b.id))})]})})})}),e[20]=t,e[21]=i,e[22]=a,e[23]=o,e[24]=r,e[25]=h):h=e[25];let N;return e[26]!==p||e[27]!==h?(N=q("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[p,h]}),e[26]=p,e[27]=h,e[28]=N):N=e[28],N},gt=n=>{const e=P(20),{batchMode:t,bodyText:i,delayText:l,onBatchModeChange:a,onBodyChange:o,onDelayChange:r,onSelectExport:f,onSend:u,queues:g,selectedExportName:y,sending:x}=n,d=j();let m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let p;e[2]!==m?(p=s("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=p):p=e[3];let h;e[4]!==t||e[5]!==i||e[6]!==l||e[7]!==a||e[8]!==o||e[9]!==r||e[10]!==f||e[11]!==u||e[12]!==g||e[13]!==y||e[14]!==x||e[15]!==d?(h=g.length===0?s(Qe,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")}):q(Fe,{children:[q("div",{className:"flex flex-wrap items-center gap-2",children:[s("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:f,value:y,children:g.map(yt)}),s(Ze,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:l}),q("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"}),d("Send as batch (JSON array)")]}),s(we,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||y==="",onClick:u,type:"button",children:d(x?"Sending…":"Send message")})]}),s(tt,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=l,e[7]=a,e[8]=o,e[9]=r,e[10]=f,e[11]=u,e[12]=g,e[13]=y,e[14]=x,e[15]=d,e[16]=h):h=e[16];let N;return e[17]!==p||e[18]!==h?(N=q("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[p,h]}),e[17]=p,e[18]=h,e[19]=N):N=e[19],N},Ft=n=>{const e=P(59),{limit:t}=n,i=t??nt,l=Ve(),a=j(),[o,r]=M("declared"),[f,u]=M(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];const{data:y,error:x,errorSource:d}=Be(G.listQueues,g);let m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];const{data:p,error:h,errorSource:N,refetch:b}=Be(G.getQueueMessages,m),E=Array.isArray(y?.queues)?[...y.queues].toSorted(bt):[],Q=p?.entries??[],{deadLetteredCount:v,queuesWithoutDlq:w,showReliabilityWarning:D}=rt(E,Q),[U,J]=M(""),[A,I]=M(""),[C,L]=M(""),[F,We]=M(!1),[le,Ie]=M(!1),[de,Le]=M(null),z=E.some(c=>c.exportName===U)?U:E[0]?.exportName??"",Me=o==="messages"?h:x,Ge=o==="messages"?N:d,ie=Me??f,ce=Me===null?f:Ge;let H;e[3]!==b?(H=()=>{b()},e[3]=b,e[4]=H):H=e[4],st(H,o==="messages");const ue=async()=>{u(null);const c=z;if(c==="")return;let S=null;const Se=A.trim();if(Se!=="")try{S=JSON.parse(Se)}catch{u(a("Body must be valid JSON."));return}let Ee;const De=C.trim();if(De!==""){const W=Number(De);if(!Number.isFinite(W)||W<0){u(a("Delay must be a non-negative number of seconds."));return}Ee=W}if(F&&!Array.isArray(S)){u(a("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ie(!0);const He=F?{batch:S,delaySeconds:Ee,exportName:c}:{body:S,delaySeconds:Ee,exportName:c};try{await l.query(ot,He,_e("")),b()}catch(W){u(Te(W))}Ie(!1)};let V;e[5]!==l||e[6]!==b?(V=async c=>{u(null),Le(c);try{await l.query(lt,{id:c},_e("")),b()}catch(S){u(Te(S))}Le(null)},e[5]=l,e[6]=b,e[7]=V):V=e[7];const me=V;let Y;e[8]!==l||e[9]!==b?(Y=async()=>{u(null);try{await l.query(dt,{},_e("")),b()}catch(c){u(Te(c))}},e[8]=l,e[9]=b,e[10]=Y):Y=e[10];const fe=Y;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=c=>{const S=c.currentTarget.dataset.tab;(S==="declared"||S==="messages"||S==="send")&&r(S)},e[11]=X):X=e[11];const Pe=X;let K;e[12]===Symbol.for("react.memo_cache_sentinel")?(K=c=>{J(c.currentTarget.value)},e[12]=K):K=e[12];const he=K;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=c=>{I(c.currentTarget.value)},e[13]=Z):Z=e[13];const pe=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=c=>{L(c.currentTarget.value)},e[14]=ee):ee=e[14];const ge=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=c=>{We(c.currentTarget.checked)},e[15]=te):te=e[15];const xe=te;let se;e[16]!==ue?(se=()=>{Ce(ue())},e[16]=ue,e[17]=se):se=e[17];const ye=se;let ae;e[18]!==me?(ae=c=>{const{id:S}=c.currentTarget.dataset;S!==void 0&&Ce(me(S))},e[18]=me,e[19]=ae):ae=e[19];const be=ae;let re;e[20]!==fe?(re=()=>{Ce(fe())},e[20]=fe,e[21]=re):re=e[21];const Ne=re,je="flex flex-col gap-6",ze="lunora-queues-panel";let B;e[22]!==a||e[23]!==o?(B=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>s(we,{"aria-selected":o===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===c?"secondary":"ghost",children:mt(c,a)},c))}),e[22]=a,e[23]=o,e[24]=B):B=e[24];let R;e[25]!==ie||e[26]!==ce?(R=ie!==null&&s(Xe,{error:ce,testId:"queues-error"}),e[25]=ie,e[26]=ce,e[27]=R):R=e[27];const qe=D&&s(Ke,{icon:s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:q("div",{className:"flex flex-col gap-1",children:[w.length>0&&q(Fe,{children:[s("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:w.map(Nt).join(", ")})}),s("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),v>0&&s("p",{className:w.length>0?"text-muted-foreground":"font-medium",children:v===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:v})})]})});let $;e[28]!==E||e[29]!==y||e[30]!==o?($=o==="declared"&&s(ft,{loaded:y!==void 0,queues:E}),e[28]=E,e[29]=y,e[30]=o,e[31]=$):$=e[31];let O;e[32]!==Q||e[33]!==h||e[34]!==Ne||e[35]!==be||e[36]!==de||e[37]!==o?(O=o==="messages"&&s(pt,{hasError:h!==null,messages:Q,onClear:Ne,onReplay:be,replayingId:de}),e[32]=Q,e[33]=h,e[34]=Ne,e[35]=be,e[36]=de,e[37]=o,e[38]=O):O=e[38];let k;e[39]!==F||e[40]!==A||e[41]!==C||e[42]!==xe||e[43]!==pe||e[44]!==ge||e[45]!==he||e[46]!==ye||e[47]!==E||e[48]!==z||e[49]!==le||e[50]!==o?(k=o==="send"&&s(gt,{batchMode:F,bodyText:A,delayText:C,onBatchModeChange:xe,onBodyChange:pe,onDelayChange:ge,onSelectExport:he,onSend:ye,queues:E,selectedExportName:z,sending:le}),e[39]=F,e[40]=A,e[41]=C,e[42]=xe,e[43]=pe,e[44]=ge,e[45]=he,e[46]=ye,e[47]=E,e[48]=z,e[49]=le,e[50]=o,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=q("div",{className:je,"data-testid":ze,children:[B,R,qe,$,O,k]}),e[52]=B,e[53]=R,e[54]=qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne};function xt(n){return q(oe,{"data-testid":`queues-row-${n.exportName}`,children:[s(T,{className:"font-mono text-xs",children:n.exportName}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.name}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"—"})]},n.exportName)}function yt(n){return s("option",{value:n.exportName,children:n.exportName},n.exportName)}function bt(n,e){return n.exportName.localeCompare(e.exportName)}function Nt(n){return n.name}export{Ft as default};
1
+ import{c as G}from"react/compiler-runtime";import{useLunora as Ve}from"@lunora/react";import{useState as M}from"react";import{ConfirmButton as Ye}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{E as Xe}from"../packem_shared/error-alert-dQk3g8WI.mjs";import{A as Ke}from"../packem_shared/alert-PB5W11MM.mjs";import{B as ve}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as we}from"../packem_shared/button-q0UYSmrn.mjs";import{C as $e,a as Oe}from"../packem_shared/card--2hKx4L2.mjs";import{E as Qe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as Ze}from"../packem_shared/input-CXhxesPC.mjs";import{S as et}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as ke,a as Ue,b as oe,c as _,d as Je,e as T}from"../packem_shared/table-D0SBiDu-.mjs";import{T as tt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Be}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{useAutoRefresh as st}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{useT as P}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{d as _e,b as Te,c as Ae,f as Ce,h as at,j as rt}from"../packem_shared/internal-CyDwqA67.mjs";import{jsx as s,jsxs as q,Fragment as Fe}from"react/jsx-runtime";const nt=(n,e)=>{const t=new Set(n.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=n.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!t.has(a.name)),l=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:l,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||l>0}},ot=200,lt=Ae(W.sendQueueMessage),dt=Ae(W.replayQueueMessage),it=Ae(W.clearQueueMessages),Re=96,ct=n=>{if(n===void 0)return"—";try{return JSON.stringify(n,rt)}catch{return"[unserializable]"}},ut=n=>n.length>Re?`${n.slice(0,Re)}…`:n,mt=n=>n==="error"?"destructive":n==="retry"?"outline":"secondary",ft=(n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),ht=n=>{const e=G(11),{loaded:t,queues:i}=n,l=P();let a;e[0]!==l?(a=l("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=l,e[1]=a):a=e[1];let o;e[2]!==a?(o=s("p",{className:"text-sm text-muted-foreground",children:a}),e[2]=a,e[3]=o):o=e[3];let r;e[4]!==t||e[5]!==i||e[6]!==l?(r=t&&i.length===0?s(Qe,{description:l("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:l("No queues defined")}):s($e,{className:"overflow-hidden py-0",children:s(Oe,{className:"px-0",children:q(ke,{"data-testid":"queues-table",children:[s(Ue,{children:q(oe,{children:[s(_,{children:l("Export")}),s(_,{children:l("Queue")}),s(_,{children:l("Mode")}),s(_,{children:l("Binding")}),s(_,{children:l("Dead-letter")})]})}),s(Je,{children:i.map(yt)})]})})}),e[4]=t,e[5]=i,e[6]=l,e[7]=r):r=e[7];let f;return e[8]!==o||e[9]!==r?(f=q("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=f):f=e[10],f},pt=n=>{const e=G(67),{message:t,onReplay:i,replayingId:l}=n,a=P();let o,r,f,u,g,y,x,d,m,p;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==a){const U=ct(t.body);r=oe,y=`queues-message-${t.id}`;const J=t.exportName??t.queue;e[19]!==J?(x=s(T,{className:"font-mono text-xs",children:J}),e[19]=J,e[20]=x):x=e[20],e[21]!==t.messageId?(d=s(T,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=d):d=e[22],e[23]!==t.attempts?(m=s(T,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const A=`queues-outcome-${t.id}`;let I;e[25]!==t.outcome?(I=mt(t.outcome),e[25]=t.outcome,e[26]=I):I=e[26];let C;e[27]!==t.outcome||e[28]!==A||e[29]!==I?(C=s(ve,{"data-testid":A,variant:I,children:t.outcome}),e[27]=t.outcome,e[28]=A,e[29]=I,e[30]=C):C=e[30];let L;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==a?(L=t.deadLettered&&s(ve,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:a("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=a,e[34]=L):L=e[34],e[35]!==C||e[36]!==L?(p=s(T,{children:q("span",{className:"inline-flex items-center gap-1",children:[C,L]})}),e[35]=C,e[36]=L,e[37]=p):p=e[37],o=T,f="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=U,g=ut(U),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=a,e[9]=o,e[10]=r,e[11]=f,e[12]=u,e[13]=g,e[14]=y,e[15]=x,e[16]=d,e[17]=m,e[18]=p}else o=e[9],r=e[10],f=e[11],u=e[12],g=e[13],y=e[14],x=e[15],d=e[16],m=e[17],p=e[18];let h;e[38]!==o||e[39]!==f||e[40]!==u||e[41]!==g?(h=s(o,{className:f,title:u,children:g}),e[38]=o,e[39]=f,e[40]=u,e[41]=g,e[42]=h):h=e[42];let N;e[43]!==t.capturedAt?(N=at(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=s(T,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=b):b=e[46];const E=`queues-replay-${t.id}`,Q=l!==null;let v;e[47]!==t.id||e[48]!==l||e[49]!==a?(v=l===t.id?a("Replaying…"):a("Replay"),e[47]=t.id,e[48]=l,e[49]=a,e[50]=v):v=e[50];let w;e[51]!==t.id||e[52]!==i||e[53]!==E||e[54]!==Q||e[55]!==v?(w=s(T,{children:s(we,{"data-id":t.id,"data-testid":E,disabled:Q,onClick:i,size:"xs",type:"button",variant:"outline",children:v})}),e[51]=t.id,e[52]=i,e[53]=E,e[54]=Q,e[55]=v,e[56]=w):w=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==w||e[60]!==y||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==p||e[65]!==h?(D=q(r,{"data-testid":y,children:[x,d,m,p,h,b,w]}),e[57]=r,e[58]=b,e[59]=w,e[60]=y,e[61]=x,e[62]=d,e[63]=m,e[64]=p,e[65]=h,e[66]=D):D=e[66],D},gt=n=>{const e=G(29),{hasError:t,messages:i,onClear:l,onReplay:a,replayingId:o}=n,r=P();let f;e[0]!==r?(f=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=r,e[1]=f):f=e[1];let u;e[2]!==f?(u=s("p",{className:"text-sm text-muted-foreground",children:f}),e[2]=f,e[3]=u):u=e[3];let g;e[4]!==r?(g=r("Clear the whole message log?"),e[4]=r,e[5]=g):g=e[5];const y=i.length===0;let x;e[6]!==r?(x=r("Clear log"),e[6]=r,e[7]=x):x=e[7];let d;e[8]!==l||e[9]!==g||e[10]!==y||e[11]!==x?(d=s("div",{className:"ml-auto",children:s(Ye,{confirmLabel:g,disabled:y,onConfirm:l,testId:"queues-clear",children:x})}),e[8]=l,e[9]=g,e[10]=y,e[11]=x,e[12]=d):d=e[12];let m;e[13]!==i.length||e[14]!==r?(m=i.length>0&&s(ve,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=r,e[15]=m):m=e[15];let p;e[16]!==u||e[17]!==d||e[18]!==m?(p=q("div",{className:"flex flex-wrap items-center gap-2",children:[u,d,m]}),e[16]=u,e[17]=d,e[18]=m,e[19]=p):p=e[19];let h;e[20]!==t||e[21]!==i||e[22]!==a||e[23]!==o||e[24]!==r?(h=!t&&i.length===0?s(Qe,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")}):s($e,{className:"overflow-hidden py-0",children:s(Oe,{className:"px-0",children:s(et,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:q(ke,{"data-testid":"queues-messages-table",children:[s(Ue,{children:q(oe,{children:[s(_,{children:r("Export")}),s(_,{children:r("Message")}),s(_,{children:r("Attempts")}),s(_,{children:r("Outcome")}),s(_,{children:r("Body")}),s(_,{children:r("Captured")}),s(_,{})]})}),s(Je,{children:i.map(b=>s(pt,{message:b,onReplay:a,replayingId:o},b.id))})]})})})}),e[20]=t,e[21]=i,e[22]=a,e[23]=o,e[24]=r,e[25]=h):h=e[25];let N;return e[26]!==p||e[27]!==h?(N=q("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[p,h]}),e[26]=p,e[27]=h,e[28]=N):N=e[28],N},xt=n=>{const e=G(20),{batchMode:t,bodyText:i,delayText:l,onBatchModeChange:a,onBodyChange:o,onDelayChange:r,onSelectExport:f,onSend:u,queues:g,selectedExportName:y,sending:x}=n,d=P();let m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let p;e[2]!==m?(p=s("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=p):p=e[3];let h;e[4]!==t||e[5]!==i||e[6]!==l||e[7]!==a||e[8]!==o||e[9]!==r||e[10]!==f||e[11]!==u||e[12]!==g||e[13]!==y||e[14]!==x||e[15]!==d?(h=g.length===0?s(Qe,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")}):q(Fe,{children:[q("div",{className:"flex flex-wrap items-center gap-2",children:[s("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:f,value:y,children:g.map(bt)}),s(Ze,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:l}),q("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"}),d("Send as batch (JSON array)")]}),s(we,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||y==="",onClick:u,type:"button",children:d(x?"Sending…":"Send message")})]}),s(tt,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=l,e[7]=a,e[8]=o,e[9]=r,e[10]=f,e[11]=u,e[12]=g,e[13]=y,e[14]=x,e[15]=d,e[16]=h):h=e[16];let N;return e[17]!==p||e[18]!==h?(N=q("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[p,h]}),e[17]=p,e[18]=h,e[19]=N):N=e[19],N},jt=n=>{const e=G(59),{limit:t}=n,i=t??ot,l=Ve(),a=P(),[o,r]=M("declared"),[f,u]=M(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];const{data:y,error:x,errorSource:d}=Be(W.listQueues,g);let m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];const{data:p,error:h,errorSource:N,refetch:b}=Be(W.getQueueMessages,m),E=Array.isArray(y?.queues)?[...y.queues].toSorted(Nt):[],Q=p?.entries??[],{deadLetteredCount:v,queuesWithoutDlq:w,showReliabilityWarning:D}=nt(E,Q),[U,J]=M(""),[A,I]=M(""),[C,L]=M(""),[F,je]=M(!1),[le,Ie]=M(!1),[de,Le]=M(null),z=E.some(c=>c.exportName===U)?U:E[0]?.exportName??"",Me=o==="messages"?h:x,We=o==="messages"?N:d,ie=Me??f,ce=Me===null?f:We;let H;e[3]!==b?(H=()=>{b()},e[3]=b,e[4]=H):H=e[4],st(H,o==="messages");const ue=async()=>{u(null);const c=z;if(c==="")return;let S=null;const Se=A.trim();if(Se!=="")try{S=JSON.parse(Se)}catch{u(a("Body must be valid JSON."));return}let Ee;const De=C.trim();if(De!==""){const j=Number(De);if(!Number.isFinite(j)||j<0){u(a("Delay must be a non-negative number of seconds."));return}Ee=j}if(F&&!Array.isArray(S)){u(a("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ie(!0);const He=F?{batch:S,delaySeconds:Ee,exportName:c}:{body:S,delaySeconds:Ee,exportName:c};try{await l.query(lt,He,_e("")),b()}catch(j){u(Te(j))}Ie(!1)};let V;e[5]!==l||e[6]!==b?(V=async c=>{u(null),Le(c);try{await l.query(dt,{id:c},_e("")),b()}catch(S){u(Te(S))}Le(null)},e[5]=l,e[6]=b,e[7]=V):V=e[7];const me=V;let Y;e[8]!==l||e[9]!==b?(Y=async()=>{u(null);try{await l.query(it,{},_e("")),b()}catch(c){u(Te(c))}},e[8]=l,e[9]=b,e[10]=Y):Y=e[10];const fe=Y;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=c=>{const S=c.currentTarget.dataset.tab;(S==="declared"||S==="messages"||S==="send")&&r(S)},e[11]=X):X=e[11];const Ge=X;let K;e[12]===Symbol.for("react.memo_cache_sentinel")?(K=c=>{J(c.currentTarget.value)},e[12]=K):K=e[12];const he=K;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=c=>{I(c.currentTarget.value)},e[13]=Z):Z=e[13];const pe=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=c=>{L(c.currentTarget.value)},e[14]=ee):ee=e[14];const ge=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=c=>{je(c.currentTarget.checked)},e[15]=te):te=e[15];const xe=te;let se;e[16]!==ue?(se=()=>{Ce(ue())},e[16]=ue,e[17]=se):se=e[17];const ye=se;let ae;e[18]!==me?(ae=c=>{const{id:S}=c.currentTarget.dataset;S!==void 0&&Ce(me(S))},e[18]=me,e[19]=ae):ae=e[19];const be=ae;let re;e[20]!==fe?(re=()=>{Ce(fe())},e[20]=fe,e[21]=re):re=e[21];const Ne=re,Pe="flex flex-col gap-6",ze="lunora-queues-panel";let B;e[22]!==a||e[23]!==o?(B=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>s(we,{"aria-selected":o===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Ge,role:"tab",size:"sm",type:"button",variant:o===c?"secondary":"ghost",children:ft(c,a)},c))}),e[22]=a,e[23]=o,e[24]=B):B=e[24];let R;e[25]!==ie||e[26]!==ce?(R=ie!==null&&s(Xe,{error:ce,testId:"queues-error"}),e[25]=ie,e[26]=ce,e[27]=R):R=e[27];const qe=D&&s(Ke,{icon:s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:q("div",{className:"flex flex-col gap-1",children:[w.length>0&&q(Fe,{children:[s("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:w.map(qt).join(", ")})}),s("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),v>0&&s("p",{className:w.length>0?"text-muted-foreground":"font-medium",children:v===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:v})})]})});let $;e[28]!==E||e[29]!==y||e[30]!==o?($=o==="declared"&&s(ht,{loaded:y!==void 0,queues:E}),e[28]=E,e[29]=y,e[30]=o,e[31]=$):$=e[31];let O;e[32]!==Q||e[33]!==h||e[34]!==Ne||e[35]!==be||e[36]!==de||e[37]!==o?(O=o==="messages"&&s(gt,{hasError:h!==null,messages:Q,onClear:Ne,onReplay:be,replayingId:de}),e[32]=Q,e[33]=h,e[34]=Ne,e[35]=be,e[36]=de,e[37]=o,e[38]=O):O=e[38];let k;e[39]!==F||e[40]!==A||e[41]!==C||e[42]!==xe||e[43]!==pe||e[44]!==ge||e[45]!==he||e[46]!==ye||e[47]!==E||e[48]!==z||e[49]!==le||e[50]!==o?(k=o==="send"&&s(xt,{batchMode:F,bodyText:A,delayText:C,onBatchModeChange:xe,onBodyChange:pe,onDelayChange:ge,onSelectExport:he,onSend:ye,queues:E,selectedExportName:z,sending:le}),e[39]=F,e[40]=A,e[41]=C,e[42]=xe,e[43]=pe,e[44]=ge,e[45]=he,e[46]=ye,e[47]=E,e[48]=z,e[49]=le,e[50]=o,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=q("div",{className:Pe,"data-testid":ze,children:[B,R,qe,$,O,k]}),e[52]=B,e[53]=R,e[54]=qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne};function yt(n){return q(oe,{"data-testid":`queues-row-${n.exportName}`,children:[s(T,{className:"font-mono text-xs",children:n.exportName}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.name}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),s(T,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"—"})]},n.exportName)}function bt(n){return s("option",{value:n.exportName,children:n.exportName},n.exportName)}function Nt(n,e){return n.exportName.localeCompare(e.exportName)}function qt(n){return n.name}export{jt as default};
@@ -1 +1 @@
1
- import{E as g}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card--2hKx4L2.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as S,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=E(),{data:l,error:p,errorSource:u,liveError:f}=A(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(S,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
1
+ import{E as g}from"../packem_shared/error-alert-dQk3g8WI.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card--2hKx4L2.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as S,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=E(),{data:l,error:p,errorSource:u,liveError:f}=A(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(S,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as _,C as j}from"../packem_shared/card--2hKx4L2.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as O,a as $,b as E,c as R,d as G,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as L}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as t,jsxs as a}from"react/jsx-runtime";const H=["read","insert","update","delete"],z=(e,r)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[r],J=e=>{const r=new Map;for(const s of e){const l=r.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),r.set(s.table,l)}return[...r.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},oe=()=>{const e=U(49),r=Q();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:C,errorSource:I}=L(q.rlsPolicies,s),c=l!==void 0;let p,n,m,o,f,h,u,b,i;if(e[1]!==l||e[2]!==C||e[3]!==I||e[4]!==c||e[5]!==r){const k=J(Array.isArray(l?.policies)?l.policies:[]);let v;e[15]!==l?(v=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=v):v=e[16],n=v,u="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(i=C!==null&&t(F,{error:I,testId:"rls-error"}),e[17]=C,e[18]=I,e[19]=i):i=e[19],h="flex flex-col gap-2",p=j,m="overflow-hidden py-0";let A;e[20]!==r?(A=r("Policies"),e[20]=r,e[21]=A):A=e[21],e[22]!==A?(o=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[22]=A,e[23]=o):o=e[23],f=c&&k.length===0?t(D,{description:r("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:r("No policies defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-policies-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Table")}),H.map(d=>t(R,{children:z(r,d)},d)),t(R,{children:r("Guarded by")})]})}),t(G,{children:k.map(d=>a(E,{"data-testid":`rls-table-${d.table}`,children:[t(S,{className:"font-mono text-xs",children:d.table}),H.map(B=>t(S,{children:d.operations.has(B)?t(M,{variant:"secondary",children:r("Guarded")}):t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},B)),t(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=C,e[3]=I,e[4]=c,e[5]=r,e[6]=p,e[7]=n,e[8]=m,e[9]=o,e[10]=f,e[11]=h,e[12]=u,e[13]=b,e[14]=i}else p=e[6],n=e[7],m=e[8],o=e[9],f=e[10],h=e[11],u=e[12],b=e[13],i=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==o||e[27]!==f?(x=a(p,{className:m,children:[o,f]}),e[24]=p,e[25]=m,e[26]=o,e[27]=f,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=t("section",{className:h,children:x}),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==r?(y=r("Roles"),e[32]=r,e[33]=y):y=e[33];let g;e[34]!==y?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==c||e[37]!==n||e[38]!==r?(T=c&&n.length===0?t(D,{description:r("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:r("No roles defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-roles-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Role")}),t(R,{children:r("Description")}),t(R,{children:r("Permissions")})]})}),t(G,{children:n.map(V)})]})}),e[36]=c,e[37]=n,e[38]=r,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=t("section",{className:"flex flex-col gap-2",children:a(j,{className:"overflow-hidden py-0",children:[g,T]})}),e[40]=g,e[41]=T,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==b||e[46]!==i||e[47]!==N?(P=a("div",{className:u,"data-testid":b,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=b,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function K(e){return t(M,{variant:"outline",children:e},e)}function V(e){return a(E,{"data-testid":`rls-role-${e.name}`,children:[t(S,{className:"font-mono text-xs",children:e.name}),t(S,{className:"text-muted-foreground",children:e.description??""}),t(S,{children:e.permissions.length===0?t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):t("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)})})]},e.name)}export{oe as default};
1
+ import{c as U}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-dQk3g8WI.mjs";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as _,C as j}from"../packem_shared/card--2hKx4L2.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as O,a as $,b as E,c as R,d as G,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as L}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as t,jsxs as a}from"react/jsx-runtime";const H=["read","insert","update","delete"],z=(e,r)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[r],J=e=>{const r=new Map;for(const s of e){const l=r.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),r.set(s.table,l)}return[...r.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},oe=()=>{const e=U(49),r=Q();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:C,errorSource:I}=L(q.rlsPolicies,s),c=l!==void 0;let p,n,m,o,f,h,u,b,i;if(e[1]!==l||e[2]!==C||e[3]!==I||e[4]!==c||e[5]!==r){const k=J(Array.isArray(l?.policies)?l.policies:[]);let v;e[15]!==l?(v=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=v):v=e[16],n=v,u="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(i=C!==null&&t(F,{error:I,testId:"rls-error"}),e[17]=C,e[18]=I,e[19]=i):i=e[19],h="flex flex-col gap-2",p=j,m="overflow-hidden py-0";let A;e[20]!==r?(A=r("Policies"),e[20]=r,e[21]=A):A=e[21],e[22]!==A?(o=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[22]=A,e[23]=o):o=e[23],f=c&&k.length===0?t(D,{description:r("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:r("No policies defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-policies-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Table")}),H.map(d=>t(R,{children:z(r,d)},d)),t(R,{children:r("Guarded by")})]})}),t(G,{children:k.map(d=>a(E,{"data-testid":`rls-table-${d.table}`,children:[t(S,{className:"font-mono text-xs",children:d.table}),H.map(B=>t(S,{children:d.operations.has(B)?t(M,{variant:"secondary",children:r("Guarded")}):t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},B)),t(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=C,e[3]=I,e[4]=c,e[5]=r,e[6]=p,e[7]=n,e[8]=m,e[9]=o,e[10]=f,e[11]=h,e[12]=u,e[13]=b,e[14]=i}else p=e[6],n=e[7],m=e[8],o=e[9],f=e[10],h=e[11],u=e[12],b=e[13],i=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==o||e[27]!==f?(x=a(p,{className:m,children:[o,f]}),e[24]=p,e[25]=m,e[26]=o,e[27]=f,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=t("section",{className:h,children:x}),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==r?(y=r("Roles"),e[32]=r,e[33]=y):y=e[33];let g;e[34]!==y?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==c||e[37]!==n||e[38]!==r?(T=c&&n.length===0?t(D,{description:r("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:r("No roles defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-roles-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Role")}),t(R,{children:r("Description")}),t(R,{children:r("Permissions")})]})}),t(G,{children:n.map(V)})]})}),e[36]=c,e[37]=n,e[38]=r,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=t("section",{className:"flex flex-col gap-2",children:a(j,{className:"overflow-hidden py-0",children:[g,T]})}),e[40]=g,e[41]=T,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==b||e[46]!==i||e[47]!==N?(P=a("div",{className:u,"data-testid":b,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=b,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function K(e){return t(M,{variant:"outline",children:e},e)}function V(e){return a(E,{"data-testid":`rls-role-${e.name}`,children:[t(S,{className:"font-mono text-xs",children:e.name}),t(S,{className:"text-muted-foreground",children:e.description??""}),t(S,{children:e.permissions.length===0?t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):t("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)})})]},e.name)}export{oe as default};
@@ -1 +1 @@
1
- import{c as D}from"react/compiler-runtime";import{useState as F}from"react";import{B as Y}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{useLunora as V}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as O}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as P,a as R}from"../packem_shared/card--2hKx4L2.mjs";import{E as W}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Q,a as K,b as q,c as x,d as z,e as b}from"../packem_shared/table-D0SBiDu-.mjs";import{b as H}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{f as A,b as U,h as j}from"../packem_shared/internal-B6haJbiP.mjs";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-B4DPADwk.mjs";const te={kind:"idle"},re=(n,e,c)=>c!==void 0?c:e===void 0?a=>n.runCronJob(a):void 0,le=({loadCronJobs:n,runCronJob:e}={})=>{const c=V(),a=M(),[p,o]=F({}),s=H(["lunora-cron-jobs",n?"custom":"default"],()=>(n??(()=>c.getCronJobs()))()),{data:r,error:y}=s,h=re(c,n,e),i=async l=>{if(h!==void 0){o(d=>({...d,[l]:{kind:"running"}}));try{await h(l),o(d=>({...d,[l]:{kind:"ok"}})),s.refetch()}catch(d){o(g=>({...g,[l]:{kind:"error",message:U(d)}}))}}};return m("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:y}),r?.length===0&&t(W,{description:a("Triggers declared with the cronJobs() builder appear here."),icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:a("No cron triggers.")}),r!==void 0&&r.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"cron-table",children:[t(K,{children:m(q,{children:[t(x,{children:a("name")}),t(x,{children:a("schedule")}),t(x,{children:a("target")}),t(x,{children:a("shard")}),h!==void 0&&t(x,{"aria-label":a("Actions")})]})}),t(z,{children:r.map(l=>{const d=p[l.name]??te;return m(q,{"data-testid":`cron-row-${l.name}`,children:[t(b,{children:l.name}),t(b,{className:"font-mono text-xs tabular-nums",children:l.cron}),t(b,{children:m("span",{className:"flex items-center gap-2",children:[l.workflow===void 0?t(O,{variant:"outline",children:a("function")}):t(O,{variant:"secondary",children:a("workflow")}),t("span",{className:"font-mono text-xs",children:l.workflow??l.functionPath})]})}),t(b,{children:l.shardKey??""}),h!==void 0&&t(b,{className:"text-right",children:m("span",{className:"flex items-center justify-end gap-2",children:[d.kind==="ok"&&t("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${l.name}`,children:a("ran")}),d.kind==="error"&&t("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${l.name}`,role:"alert",children:d.message}),t(G,{confirmLabel:a("Run now?"),disabled:d.kind==="running",onConfirm:()=>{A(i(l.name))},testId:`cron-run-${l.name}`,children:d.kind==="running"?a("Running…"):a("Run now")})]})})]},`${l.cron}:${l.name}`)})})]})})})]})},se=n=>Number.isFinite(n)?j(n,"—"):"—",ne=n=>{const e=D(34);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadJobs:a,removeJob:p,retryJob:o}=c,s=V(),r=M();let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-dead-jobs"],e[2]=y):y=e[2];let h;e[3]!==s||e[4]!==a?(h=async()=>(await(a??(()=>s.listDeadJobs()))()).toSorted(oe),e[3]=s,e[4]=a,e[5]=h):h=e[5];const i=H(y,h),l=i.data,[d,g]=F(void 0),N=i.error??d,f=a===void 0;let C;e[6]!==s||e[7]!==f||e[8]!==o?(C=o??(f?u=>s.retryDeadJob(u):void 0),e[6]=s,e[7]=f,e[8]=o,e[9]=C):C=e[9];const v=C;let k;e[10]!==s||e[11]!==f||e[12]!==p?(k=p??(f?u=>s.removeDeadJob(u):void 0),e[10]=s,e[11]=f,e[12]=p,e[13]=k):k=e[13];const S=k;let $;e[14]!==i?($=()=>{i.refetch()},e[14]=i,e[15]=$):$=e[15],X($,!0);let I;e[16]!==i?(I=async u=>{g(void 0);try{await u,i.refetch()}catch(Z){g(U(Z))}},e[16]=i,e[17]=I):I=e[17];const L=I,T=v!==void 0||S!==void 0;let J;e[18]!==N?(J=N!==void 0&&t("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:N}),e[18]=N,e[19]=J):J=e[19];let w;e[20]!==l?.length||e[21]!==r?(w=l?.length===0&&t(W,{description:r("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:r("No dead-letter jobs.")}),e[20]=l?.length,e[21]=r,e[22]=w):w=e[22];let _;e[23]!==L||e[24]!==T||e[25]!==l||e[26]!==S||e[27]!==v||e[28]!==r?(_=l!==void 0&&l.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"dlq-table",children:[t(K,{children:m(q,{children:[t(x,{children:r("function")}),t(x,{children:r("attempts")}),t(x,{children:r("last tried")}),t(x,{children:r("pool")}),t(x,{children:r("shard")}),t(x,{children:r("id")}),T&&t(x,{"aria-label":r("Actions")})]})}),t(z,{children:l.map(u=>m(q,{"data-testid":`dlq-row-${u.id}`,children:[t(b,{className:"font-mono text-xs",children:u.workflow??u.functionPath}),t(b,{className:"tabular-nums",children:u.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:se(u.scheduledFor)}),t(b,{className:"font-mono text-xs",children:u.pool??""}),t(b,{children:u.shardKey??""}),t(b,{className:"font-mono text-xs",children:u.id}),T&&t(b,{className:"text-right",children:m("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&t(Y,{"data-testid":`dlq-retry-${u.id}`,onClick:()=>{A(L(v(u.id)))},size:"sm",type:"button",variant:"outline",children:r("Retry")}),S!==void 0&&t(G,{confirmLabel:r("Drop job?"),onConfirm:()=>{A(L(S(u.id)))},testId:`dlq-remove-${u.id}`,children:r("Drop")})]})})]},u.id))})]})})}),e[23]=L,e[24]=T,e[25]=l,e[26]=S,e[27]=v,e[28]=r,e[29]=_):_=e[29];let B;return e[30]!==_||e[31]!==J||e[32]!==w?(B=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[J,w,_]}),e[30]=_,e[31]=J,e[32]=w,e[33]=B):B=e[33],B};function oe(n,e){return(e.attempts??0)-(n.attempts??0)}const E=n=>{const e=D(8),{label:c,testId:a,value:p}=n;let o;e[0]!==c?(o=t("span",{className:"text-xs text-muted-foreground",children:c}),e[0]=c,e[1]=o):o=e[1];let s;e[2]!==a||e[3]!==p?(s=t("span",{className:"text-2xl font-semibold tabular-nums","data-testid":a,children:p}),e[2]=a,e[3]=p,e[4]=s):s=e[4];let r;return e[5]!==o||e[6]!==s?(r=t(P,{className:"flex-1 py-0",children:m(R,{className:"flex flex-col gap-1 p-4",children:[o,s]})}),e[5]=o,e[6]=s,e[7]=r):r=e[7],r},ae=n=>{const e=D(25);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadStatus:a}=c,p=V(),o=M(),s=a===void 0;let r;e[2]!==s?(r=["lunora-scheduler-status",s],e[2]=s,e[3]=r):r=e[3];let y;e[4]!==p||e[5]!==a?(y=async()=>{const k=await(a??(()=>p.schedulerStatus()))();return{...k,pools:k.pools.toSorted(ie)}},e[4]=p,e[5]=a,e[6]=y):y=e[6];const h=H(r,y),{data:i,error:l}=h;let d;e[7]!==h?(d=()=>{h.refetch()},e[7]=h,e[8]=d):d=e[8],X(d,!0);let g;e[9]!==l?(g=l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:l}),e[9]=l,e[10]=g):g=e[10];let N;e[11]!==i||e[12]!==o?(N=i!==void 0&&m("div",{className:"flex gap-3","data-testid":"pools-totals",children:[t(E,{label:o("backlog"),testId:"pools-backlog",value:i.backlog}),t(E,{label:o("in flight"),testId:"pools-inflight",value:i.inFlight}),t(E,{label:o("pools"),testId:"pools-count",value:i.pools.length})]}),e[11]=i,e[12]=o,e[13]=N):N=e[13];let f;e[14]!==i?.pools.length||e[15]!==o?(f=i?.pools.length===0&&t(W,{description:o("Pools created with createWorkpool appear here once they have activity."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:o("No workpools.")}),e[14]=i?.pools.length,e[15]=o,e[16]=f):f=e[16];let C;e[17]!==i||e[18]!==o?(C=i!==void 0&&i.pools.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"pools-table",children:[t(K,{children:m(q,{children:[t(x,{children:o("pool")}),t(x,{children:o("queued")}),t(x,{children:o("in flight")}),t(x,{children:o("max concurrency")})]})}),t(z,{children:i.pools.map(de)})]})})}),e[17]=i,e[18]=o,e[19]=C):C=e[19];let v;return e[20]!==g||e[21]!==N||e[22]!==f||e[23]!==C?(v=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[g,N,f,C]}),e[20]=g,e[21]=N,e[22]=f,e[23]=C,e[24]=v):v=e[24],v};function ie(n,e){return e.queued-n.queued}function de(n){return m(q,{"data-testid":`pools-row-${n.name}`,children:[t(b,{className:"font-mono text-xs",children:n.name}),t(b,{className:"tabular-nums",children:n.queued}),m(b,{className:"tabular-nums",children:[n.inFlight," / ",n.maxConcurrency]}),t(b,{className:"tabular-nums",children:n.maxConcurrency})]},n.name)}const ce=["jobs","dead","pools","cron"],Ie=n=>{const e=D(41);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadCronJobs:a,scheduledCancel:p,scheduledLoad:o}=c,s=M(),[r,y]=F("jobs");let h;e[2]!==s?(h=s("Cron triggers"),e[2]=s,e[3]=h):h=e[3];let i;e[4]!==s?(i=s("Dead letter"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("Scheduled jobs"),e[6]=s,e[7]=l):l=e[7];let d;e[8]!==s?(d=s("Pools"),e[8]=s,e[9]=d):d=e[9];let g;e[10]!==h||e[11]!==i||e[12]!==l||e[13]!==d?(g={cron:h,dead:i,jobs:l,pools:d},e[10]=h,e[11]=i,e[12]=l,e[13]=d,e[14]=g):g=e[14];const N=g;let f;e[15]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{y(w.currentTarget.dataset.view)},e[15]=f):f=e[15];const C=f;let v;e[16]!==s?(v=s("Schedule view"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==r||e[19]!==N?(k=ce.map(w=>t(Y,{"aria-selected":r===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:C,role:"tab",size:"sm",type:"button",variant:r===w?"default":"outline",children:N[w]},w)),e[18]=r,e[19]=N,e[20]=k):k=e[20];let S;e[21]!==v||e[22]!==k?(S=t("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:k}),e[21]=v,e[22]=k,e[23]=S):S=e[23];let $;e[24]!==p||e[25]!==o||e[26]!==r?($=r==="jobs"&&t(ee,{cancelJob:p,loadJobs:o}),e[24]=p,e[25]=o,e[26]=r,e[27]=$):$=e[27];let I;e[28]!==r?(I=r==="dead"&&t(ne,{}),e[28]=r,e[29]=I):I=e[29];let L;e[30]!==r?(L=r==="pools"&&t(ae,{}),e[30]=r,e[31]=L):L=e[31];let T;e[32]!==a||e[33]!==r?(T=r==="cron"&&t(le,{loadCronJobs:a}),e[32]=a,e[33]=r,e[34]=T):T=e[34];let J;return e[35]!==S||e[36]!==$||e[37]!==I||e[38]!==L||e[39]!==T?(J=m("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,$,I,L,T]}),e[35]=S,e[36]=$,e[37]=I,e[38]=L,e[39]=T,e[40]=J):J=e[40],J};export{Ie as SchedulePanel};
1
+ import{c as D}from"react/compiler-runtime";import{useState as F}from"react";import{B as Y}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{useLunora as V}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as O}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as P,a as R}from"../packem_shared/card--2hKx4L2.mjs";import{E as W}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Q,a as K,b as q,c as x,d as z,e as b}from"../packem_shared/table-D0SBiDu-.mjs";import{b as H}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{f as A,b as U,h as j}from"../packem_shared/internal-CyDwqA67.mjs";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-DSqsMB51.mjs";const te={kind:"idle"},re=(n,e,c)=>c!==void 0?c:e===void 0?a=>n.runCronJob(a):void 0,le=({loadCronJobs:n,runCronJob:e}={})=>{const c=V(),a=M(),[p,o]=F({}),s=H(["lunora-cron-jobs",n?"custom":"default"],()=>(n??(()=>c.getCronJobs()))()),{data:r,error:y}=s,h=re(c,n,e),i=async l=>{if(h!==void 0){o(d=>({...d,[l]:{kind:"running"}}));try{await h(l),o(d=>({...d,[l]:{kind:"ok"}})),s.refetch()}catch(d){o(g=>({...g,[l]:{kind:"error",message:U(d)}}))}}};return m("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:y}),r?.length===0&&t(W,{description:a("Triggers declared with the cronJobs() builder appear here."),icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:a("No cron triggers.")}),r!==void 0&&r.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"cron-table",children:[t(K,{children:m(q,{children:[t(x,{children:a("name")}),t(x,{children:a("schedule")}),t(x,{children:a("target")}),t(x,{children:a("shard")}),h!==void 0&&t(x,{"aria-label":a("Actions")})]})}),t(z,{children:r.map(l=>{const d=p[l.name]??te;return m(q,{"data-testid":`cron-row-${l.name}`,children:[t(b,{children:l.name}),t(b,{className:"font-mono text-xs tabular-nums",children:l.cron}),t(b,{children:m("span",{className:"flex items-center gap-2",children:[l.workflow===void 0?t(O,{variant:"outline",children:a("function")}):t(O,{variant:"secondary",children:a("workflow")}),t("span",{className:"font-mono text-xs",children:l.workflow??l.functionPath})]})}),t(b,{children:l.shardKey??""}),h!==void 0&&t(b,{className:"text-right",children:m("span",{className:"flex items-center justify-end gap-2",children:[d.kind==="ok"&&t("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${l.name}`,children:a("ran")}),d.kind==="error"&&t("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${l.name}`,role:"alert",children:d.message}),t(G,{confirmLabel:a("Run now?"),disabled:d.kind==="running",onConfirm:()=>{A(i(l.name))},testId:`cron-run-${l.name}`,children:d.kind==="running"?a("Running…"):a("Run now")})]})})]},`${l.cron}:${l.name}`)})})]})})})]})},se=n=>Number.isFinite(n)?j(n,"—"):"—",ne=n=>{const e=D(34);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadJobs:a,removeJob:p,retryJob:o}=c,s=V(),r=M();let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-dead-jobs"],e[2]=y):y=e[2];let h;e[3]!==s||e[4]!==a?(h=async()=>(await(a??(()=>s.listDeadJobs()))()).toSorted(oe),e[3]=s,e[4]=a,e[5]=h):h=e[5];const i=H(y,h),l=i.data,[d,g]=F(void 0),N=i.error??d,f=a===void 0;let C;e[6]!==s||e[7]!==f||e[8]!==o?(C=o??(f?u=>s.retryDeadJob(u):void 0),e[6]=s,e[7]=f,e[8]=o,e[9]=C):C=e[9];const v=C;let k;e[10]!==s||e[11]!==f||e[12]!==p?(k=p??(f?u=>s.removeDeadJob(u):void 0),e[10]=s,e[11]=f,e[12]=p,e[13]=k):k=e[13];const S=k;let $;e[14]!==i?($=()=>{i.refetch()},e[14]=i,e[15]=$):$=e[15],X($,!0);let I;e[16]!==i?(I=async u=>{g(void 0);try{await u,i.refetch()}catch(Z){g(U(Z))}},e[16]=i,e[17]=I):I=e[17];const L=I,T=v!==void 0||S!==void 0;let J;e[18]!==N?(J=N!==void 0&&t("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:N}),e[18]=N,e[19]=J):J=e[19];let w;e[20]!==l?.length||e[21]!==r?(w=l?.length===0&&t(W,{description:r("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:r("No dead-letter jobs.")}),e[20]=l?.length,e[21]=r,e[22]=w):w=e[22];let _;e[23]!==L||e[24]!==T||e[25]!==l||e[26]!==S||e[27]!==v||e[28]!==r?(_=l!==void 0&&l.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"dlq-table",children:[t(K,{children:m(q,{children:[t(x,{children:r("function")}),t(x,{children:r("attempts")}),t(x,{children:r("last tried")}),t(x,{children:r("pool")}),t(x,{children:r("shard")}),t(x,{children:r("id")}),T&&t(x,{"aria-label":r("Actions")})]})}),t(z,{children:l.map(u=>m(q,{"data-testid":`dlq-row-${u.id}`,children:[t(b,{className:"font-mono text-xs",children:u.workflow??u.functionPath}),t(b,{className:"tabular-nums",children:u.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:se(u.scheduledFor)}),t(b,{className:"font-mono text-xs",children:u.pool??""}),t(b,{children:u.shardKey??""}),t(b,{className:"font-mono text-xs",children:u.id}),T&&t(b,{className:"text-right",children:m("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&t(Y,{"data-testid":`dlq-retry-${u.id}`,onClick:()=>{A(L(v(u.id)))},size:"sm",type:"button",variant:"outline",children:r("Retry")}),S!==void 0&&t(G,{confirmLabel:r("Drop job?"),onConfirm:()=>{A(L(S(u.id)))},testId:`dlq-remove-${u.id}`,children:r("Drop")})]})})]},u.id))})]})})}),e[23]=L,e[24]=T,e[25]=l,e[26]=S,e[27]=v,e[28]=r,e[29]=_):_=e[29];let B;return e[30]!==_||e[31]!==J||e[32]!==w?(B=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[J,w,_]}),e[30]=_,e[31]=J,e[32]=w,e[33]=B):B=e[33],B};function oe(n,e){return(e.attempts??0)-(n.attempts??0)}const E=n=>{const e=D(8),{label:c,testId:a,value:p}=n;let o;e[0]!==c?(o=t("span",{className:"text-xs text-muted-foreground",children:c}),e[0]=c,e[1]=o):o=e[1];let s;e[2]!==a||e[3]!==p?(s=t("span",{className:"text-2xl font-semibold tabular-nums","data-testid":a,children:p}),e[2]=a,e[3]=p,e[4]=s):s=e[4];let r;return e[5]!==o||e[6]!==s?(r=t(P,{className:"flex-1 py-0",children:m(R,{className:"flex flex-col gap-1 p-4",children:[o,s]})}),e[5]=o,e[6]=s,e[7]=r):r=e[7],r},ae=n=>{const e=D(25);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadStatus:a}=c,p=V(),o=M(),s=a===void 0;let r;e[2]!==s?(r=["lunora-scheduler-status",s],e[2]=s,e[3]=r):r=e[3];let y;e[4]!==p||e[5]!==a?(y=async()=>{const k=await(a??(()=>p.schedulerStatus()))();return{...k,pools:k.pools.toSorted(ie)}},e[4]=p,e[5]=a,e[6]=y):y=e[6];const h=H(r,y),{data:i,error:l}=h;let d;e[7]!==h?(d=()=>{h.refetch()},e[7]=h,e[8]=d):d=e[8],X(d,!0);let g;e[9]!==l?(g=l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:l}),e[9]=l,e[10]=g):g=e[10];let N;e[11]!==i||e[12]!==o?(N=i!==void 0&&m("div",{className:"flex gap-3","data-testid":"pools-totals",children:[t(E,{label:o("backlog"),testId:"pools-backlog",value:i.backlog}),t(E,{label:o("in flight"),testId:"pools-inflight",value:i.inFlight}),t(E,{label:o("pools"),testId:"pools-count",value:i.pools.length})]}),e[11]=i,e[12]=o,e[13]=N):N=e[13];let f;e[14]!==i?.pools.length||e[15]!==o?(f=i?.pools.length===0&&t(W,{description:o("Pools created with createWorkpool appear here once they have activity."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:o("No workpools.")}),e[14]=i?.pools.length,e[15]=o,e[16]=f):f=e[16];let C;e[17]!==i||e[18]!==o?(C=i!==void 0&&i.pools.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"pools-table",children:[t(K,{children:m(q,{children:[t(x,{children:o("pool")}),t(x,{children:o("queued")}),t(x,{children:o("in flight")}),t(x,{children:o("max concurrency")})]})}),t(z,{children:i.pools.map(de)})]})})}),e[17]=i,e[18]=o,e[19]=C):C=e[19];let v;return e[20]!==g||e[21]!==N||e[22]!==f||e[23]!==C?(v=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[g,N,f,C]}),e[20]=g,e[21]=N,e[22]=f,e[23]=C,e[24]=v):v=e[24],v};function ie(n,e){return e.queued-n.queued}function de(n){return m(q,{"data-testid":`pools-row-${n.name}`,children:[t(b,{className:"font-mono text-xs",children:n.name}),t(b,{className:"tabular-nums",children:n.queued}),m(b,{className:"tabular-nums",children:[n.inFlight," / ",n.maxConcurrency]}),t(b,{className:"tabular-nums",children:n.maxConcurrency})]},n.name)}const ce=["jobs","dead","pools","cron"],Ie=n=>{const e=D(41);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadCronJobs:a,scheduledCancel:p,scheduledLoad:o}=c,s=M(),[r,y]=F("jobs");let h;e[2]!==s?(h=s("Cron triggers"),e[2]=s,e[3]=h):h=e[3];let i;e[4]!==s?(i=s("Dead letter"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("Scheduled jobs"),e[6]=s,e[7]=l):l=e[7];let d;e[8]!==s?(d=s("Pools"),e[8]=s,e[9]=d):d=e[9];let g;e[10]!==h||e[11]!==i||e[12]!==l||e[13]!==d?(g={cron:h,dead:i,jobs:l,pools:d},e[10]=h,e[11]=i,e[12]=l,e[13]=d,e[14]=g):g=e[14];const N=g;let f;e[15]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{y(w.currentTarget.dataset.view)},e[15]=f):f=e[15];const C=f;let v;e[16]!==s?(v=s("Schedule view"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==r||e[19]!==N?(k=ce.map(w=>t(Y,{"aria-selected":r===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:C,role:"tab",size:"sm",type:"button",variant:r===w?"default":"outline",children:N[w]},w)),e[18]=r,e[19]=N,e[20]=k):k=e[20];let S;e[21]!==v||e[22]!==k?(S=t("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:k}),e[21]=v,e[22]=k,e[23]=S):S=e[23];let $;e[24]!==p||e[25]!==o||e[26]!==r?($=r==="jobs"&&t(ee,{cancelJob:p,loadJobs:o}),e[24]=p,e[25]=o,e[26]=r,e[27]=$):$=e[27];let I;e[28]!==r?(I=r==="dead"&&t(ne,{}),e[28]=r,e[29]=I):I=e[29];let L;e[30]!==r?(L=r==="pools"&&t(ae,{}),e[30]=r,e[31]=L):L=e[31];let T;e[32]!==a||e[33]!==r?(T=r==="cron"&&t(le,{loadCronJobs:a}),e[32]=a,e[33]=r,e[34]=T):T=e[34];let J;return e[35]!==S||e[36]!==$||e[37]!==I||e[38]!==L||e[39]!==T?(J=m("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,$,I,L,T]}),e[35]=S,e[36]=$,e[37]=I,e[38]=L,e[39]=T,e[40]=J):J=e[40],J};export{Ie as SchedulePanel};
@@ -1 +1 @@
1
- import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card--2hKx4L2.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
1
+ import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-dQk3g8WI.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card--2hKx4L2.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
@@ -1 +1 @@
1
- import{c as K}from"react/compiler-runtime";import{E as R}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as C}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card--2hKx4L2.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as k,c as y,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{j as q}from"../packem_shared/internal-B6haJbiP.mjs";import{jsxs as a,jsx as t}from"react/jsx-runtime";const w=80,G=c=>{if(c===void 0)return"";const e=JSON.stringify(c,q);return e.length>w?`${e.slice(0,w)}…`:e},J=c=>{const e=[];for(const r of c){const n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((u,o)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${o.toString()}`,subscription:u})})}return e},I=t("span",{className:"text-muted-foreground",children:"—"}),ae=c=>{const e=K(22),{initialShardKey:r}=c,n=O(),{queryShardKey:u,setShardKey:o,shardKey:m}=L(r);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==u?(f={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=f):f=e[2];const{data:s,error:i,errorSource:h,refetch:j}=P(W.listSubscriptions,p,f);F(j,!0);let b;if(e[3]!==i||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==m||e[8]!==n){const N=s===void 0?[]:J(s.connections);let l;e[10]!==o||e[11]!==m?(l=t(E,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,e[11]=m,e[12]=l):l=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&a("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(C,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),t(C,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==l||e[17]!==d?(g=a("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),e[16]=l,e[17]=d,e[18]=g):g=e[18];let x;e[19]!==i||e[20]!==h?(x=i!==null&&t(R,{error:h,testId:"subs-error"}),e[19]=i,e[20]=h,e[21]=x):x=e[21],b=a("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,i===null&&s!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:a(_,{"data-testid":"subs-table",children:[t(D,{children:a(k,{children:[t(y,{children:n("Connection")}),t(y,{children:n("Function path")}),t(y,{children:n("Table")}),t(y,{children:n("Arguments")})]})}),t(H,{children:N.map(v=>{const{subscription:A}=v,T=G(A?.args);return a(k,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:a("span",{className:"inline-flex items-center gap-1.5",children:["#",v.connectionId,v.admin&&t(C,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:A?.functionPath??I}),t(S,{children:A?.table??I}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:T||void 0,children:T||I})]},v.key)})})]})})})]}),e[3]=i,e[4]=h,e[5]=s,e[6]=o,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{ae as default};
1
+ import{c as K}from"react/compiler-runtime";import{E as R}from"../packem_shared/error-alert-dQk3g8WI.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as C}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card--2hKx4L2.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as k,c as y,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{j as q}from"../packem_shared/internal-CyDwqA67.mjs";import{jsxs as a,jsx as t}from"react/jsx-runtime";const w=80,G=c=>{if(c===void 0)return"";const e=JSON.stringify(c,q);return e.length>w?`${e.slice(0,w)}…`:e},J=c=>{const e=[];for(const r of c){const n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((u,o)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${o.toString()}`,subscription:u})})}return e},I=t("span",{className:"text-muted-foreground",children:"—"}),ae=c=>{const e=K(22),{initialShardKey:r}=c,n=O(),{queryShardKey:u,setShardKey:o,shardKey:m}=L(r);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==u?(f={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=f):f=e[2];const{data:s,error:i,errorSource:h,refetch:j}=P(W.listSubscriptions,p,f);F(j,!0);let b;if(e[3]!==i||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==m||e[8]!==n){const N=s===void 0?[]:J(s.connections);let l;e[10]!==o||e[11]!==m?(l=t(E,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,e[11]=m,e[12]=l):l=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&a("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(C,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),t(C,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==l||e[17]!==d?(g=a("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),e[16]=l,e[17]=d,e[18]=g):g=e[18];let x;e[19]!==i||e[20]!==h?(x=i!==null&&t(R,{error:h,testId:"subs-error"}),e[19]=i,e[20]=h,e[21]=x):x=e[21],b=a("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,i===null&&s!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:a(_,{"data-testid":"subs-table",children:[t(D,{children:a(k,{children:[t(y,{children:n("Connection")}),t(y,{children:n("Function path")}),t(y,{children:n("Table")}),t(y,{children:n("Arguments")})]})}),t(H,{children:N.map(v=>{const{subscription:A}=v,T=G(A?.args);return a(k,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:a("span",{className:"inline-flex items-center gap-1.5",children:["#",v.connectionId,v.admin&&t(C,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:A?.functionPath??I}),t(S,{children:A?.table??I}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:T||void 0,children:T||I})]},v.key)})})]})})})]}),e[3]=i,e[4]=h,e[5]=s,e[6]=o,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{ae as default};
@@ -1 +1 @@
1
- import{c as q}from"react/compiler-runtime";import{useLunora as I}from"@lunora/react";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card--2hKx4L2.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as r}from"../packem_shared/table-D0SBiDu-.mjs";import{b as Q}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as n,jsxs as s}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:S}=W,t=Y(),L=I();let T;e[0]!==L||e[1]!==S?(T=()=>Promise.resolve(S?S():L.debug()),e[0]=L,e[1]=S,e[2]=T):T=e[2];const M=T,A=S?"injected":"live";let x;e[3]!==A?(x=["lunora-studio","sync-client-debug",A],e[3]=A,e[4]=x):x=e[4];const{data:c,refetch:O}=Q(x,M);if(V(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let k;return e[9]!==i||e[10]!==g?(k=n(R,{children:n(H,{children:n(P,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=k):k=e[11],k}const{pendingWrites:v,shards:C,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const E=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==E?(d=n(_,{variant:E,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=E,e[18]=d):d=e[18];let h;e[19]!==v||e[20]!==t?(h=v>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:v})}):null,e[19]=v,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=s("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==C||e[31]!==t?(p=C.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:C.map(i=>s(w,{children:[n(r,{children:i.shardKey??t("(default)")}),n(r,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(r,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=C,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>s(w,{children:[n(r,{className:"font-mono text-xs",children:i.functionPath}),n(r,{children:i.kind}),n(r,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(r,{children:i.serverCursor??"—"}),n(r,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:s(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};
1
+ import{c as q}from"react/compiler-runtime";import{useLunora as I}from"@lunora/react";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card--2hKx4L2.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as r}from"../packem_shared/table-D0SBiDu-.mjs";import{b as Q}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as n,jsxs as s}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:S}=W,t=Y(),L=I();let T;e[0]!==L||e[1]!==S?(T=()=>Promise.resolve(S?S():L.debug()),e[0]=L,e[1]=S,e[2]=T):T=e[2];const M=T,A=S?"injected":"live";let x;e[3]!==A?(x=["lunora-studio","sync-client-debug",A],e[3]=A,e[4]=x):x=e[4];const{data:c,refetch:O}=Q(x,M);if(V(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let k;return e[9]!==i||e[10]!==g?(k=n(R,{children:n(H,{children:n(P,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=k):k=e[11],k}const{pendingWrites:v,shards:C,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const E=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==E?(d=n(_,{variant:E,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=E,e[18]=d):d=e[18];let h;e[19]!==v||e[20]!==t?(h=v>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:v})}):null,e[19]=v,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=s("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==C||e[31]!==t?(p=C.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:C.map(i=>s(w,{children:[n(r,{children:i.shardKey??t("(default)")}),n(r,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(r,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=C,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>s(w,{children:[n(r,{className:"font-mono text-xs",children:i.functionPath}),n(r,{children:i.kind}),n(r,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(r,{children:i.serverCursor??"—"}),n(r,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:s(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{useState as ee,useEffect as le}from"react";import{E as ge}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{L as be}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as xe}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as ye}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{E as Ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ve}from"../packem_shared/input-CXhxesPC.mjs";import{u as oe}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{u as Se}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as me}from"../packem_shared/internal-B6haJbiP.mjs";import{r as we}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{p as _e,c as Ie}from"../packem_shared/trace-handoff-BV3EWqy_.mjs";import{L as ke}from"../packem_shared/log-line-BoObzuue.mjs";import{f as Me}from"../packem_shared/log-fields-SBxKyBug.mjs";import{c as ne}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as n,jsxs as k,Fragment as $e}from"react/jsx-runtime";const Te=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Le=(a,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ce(a.offsetMs/e*100),s=a.durationMs/e*100,l=Math.max(Te,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ce=(a,e,t=!1)=>{const s=e.trim().toLowerCase(),l=t?a.filter(r=>!r.ok):a;return s===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(s)||r.functionPath.toLowerCase().includes(s)||r.traceId.toLowerCase().includes(s)||r.spans.some(o=>o.name.toLowerCase().includes(s)||o.spanId.toLowerCase().includes(s)))},q=a=>Number.isFinite(a)?a>0&&a<1?`${a.toFixed(2)}ms`:`${String(Math.round(a))}ms`:"—",Ee=a=>!Number.isFinite(a)||a<=0?[]:Array.from({length:de},(e,t)=>{const s=(t+1)/de;return{label:q(a*s),percent:s*100}}),ue=a=>{if(typeof a=="string")return a;try{return JSON.stringify(a)}catch{return String(a)}},Y=a=>{const e=U(7),{label:t,value:s}=a;let l;e[0]!==t?(l=n("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==s?(r=n("dd",{className:"min-w-0 break-all",children:s}),e[2]=s,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Pe=a=>{const e=U(68),{span:t}=a,s=Z();let l,r,o,i,d,f;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==s){const $=Object.entries(t.attributes??{});let M;e[15]!==t.events?(M=t.events??[],e[15]=t.events,e[16]=M):M=e[16],l=M,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let N;e[17]!==s?(N=s("Span ID"),e[17]=s,e[18]=N):N=e[18];let v;e[19]!==t.spanId||e[20]!==N?(v=n(Y,{label:N,value:t.spanId}),e[19]=t.spanId,e[20]=N,e[21]=v):v=e[21];let S;e[22]!==s?(S=s("Parent span ID"),e[22]=s,e[23]=S):S=e[23];let m;e[24]!==t.parentSpanId||e[25]!==s?(m=t.parentSpanId===""?s("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=s,e[26]=m):m=e[26];let u;e[27]!==m||e[28]!==S?(u=n(Y,{label:S,value:m}),e[27]=m,e[28]=S,e[29]=u):u=e[29];let h;e[30]!==s?(h=s("Kind"),e[30]=s,e[31]=h):h=e[31];const T=t.kind??"internal";let _;e[32]!==h||e[33]!==T?(_=n(Y,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=_):_=e[34];let w;e[35]!==s?(w=s("Started at"),e[35]=s,e[36]=w):w=e[36];let g;e[37]!==t.offsetMs||e[38]!==s?(g=s("+{offset}",{offset:q(t.offsetMs)}),e[37]=t.offsetMs,e[38]=s,e[39]=g):g=e[39];let b;e[40]!==w||e[41]!==g?(b=n(Y,{label:w,value:g}),e[40]=w,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==s?(I=s("Duration"),e[43]=s,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=q(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=n(Y,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==u||e[51]!==_||e[52]!==b||e[53]!==x||e[54]!==v?(i=k("dl",{className:"flex flex-col gap-1",children:[v,u,_,b,x]}),e[50]=u,e[51]=_,e[52]=b,e[53]=x,e[54]=v,e[55]=i):i=e[55],e[56]!==t.error?(d=t.error!==void 0&&k("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[n("span",{className:"font-semibold text-destructive",children:t.error.type}),n("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=d):d=e[57],f=$.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Attributes")}),n("dl",{className:"flex flex-col gap-1",children:$.map(Fe)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=s,e[9]=l,e[10]=r,e[11]=o,e[12]=i,e[13]=d,e[14]=f}else l=e[9],r=e[10],o=e[11],i=e[12],d=e[13],f=e[14];let c;e[58]!==l||e[59]!==s?(c=l.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-events",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Events")}),n("ul",{className:"flex flex-col gap-1",children:l.map(Ae)})]}),e[58]=l,e[59]=s,e[60]=c):c=e[60];let y;return e[61]!==r||e[62]!==o||e[63]!==i||e[64]!==d||e[65]!==f||e[66]!==c?(y=k("div",{className:r,"data-testid":o,children:[i,d,f,c]}),e[61]=r,e[62]=o,e[63]=i,e[64]=d,e[65]=f,e[66]=c,e[67]=y):y=e[67],y};function Fe(a){const[e,t]=a;return n(Y,{label:e,value:ue(t)},e)}function Ke(a){const[e,t]=a;return`${e}=${ue(t)}`}function Ae(a){return k("li",{className:"flex gap-2",children:[n("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(a.ts)}),n(fe,{variant:"secondary",children:a.name}),n("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(a.attributes??{}).map(Ke).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",Re=a=>{const e=U(17),{traceDurationMs:t}=a;let s,l,r,o,i,d;if(e[0]!==t){d=Symbol.for("react.early_return_sentinel");e:{const y=Ee(t);if(y.length===0){d=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=ne(pe,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(i=n("span",{}),e[8]=i):i=e[8],s="relative h-3",l=y.map(je)}e[0]=t,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=i,e[6]=d}else s=e[1],l=e[2],r=e[3],o=e[4],i=e[5],d=e[6];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[9]!==s||e[10]!==l?(f=n("span",{className:s,children:l}),e[9]=s,e[10]=l,e[11]=f):f=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==i||e[15]!==f?(c=k("div",{className:r,"data-testid":o,children:[i,f]}),e[12]=r,e[13]=o,e[14]=i,e[15]=f,e[16]=c):c=e[16],c},Be=a=>{const e=U(60),{span:t,traceDurationMs:s}=a,l=Z(),[r,o]=ee(!1);let i;e[0]!==t||e[1]!==s?(i=Le(t,s),e[0]=t,e[1]=s,e[2]=i):i=e[2];const{leftPercent:d,widthPercent:f}=i;let c;e[3]!==t.attributes?(c=Me(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const y=c,$=t.depth*De;let M;e[5]!==$?(M={paddingLeft:$},e[5]=$,e[6]=M):M=e[6];const N=M,v=`${String(d)}%`,S=`${String(f)}%`;let m;e[7]!==v||e[8]!==S?(m={left:v,width:S},e[7]=v,e[8]=S,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(We)},e[10]=h):h=e[10];const T=h,_=t.depth,w=`tr-span-detail-${t.spanId}`;let g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:q(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:q(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=ne(pe,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=b):b=e[17];const I=`tr-span-toggle-${t.spanId}`;let p;e[18]!==t.ok?(p=t.ok?null:n("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"●"}),e[18]=t.ok,e[19]=p):p=e[19];let x;e[20]!==N||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:N,title:t.name,children:[p,t.name]}),e[20]=N,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const R=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==R?(L=ne("absolute inset-y-0 rounded-sm",R),e[24]=R,e[25]=L):L=e[25];let D;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(D=n("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:n("span",{className:L,"data-left":d,"data-testid":"tr-span-bar","data-width":f,style:u})}),e[26]=u,e[27]=d,e[28]=L,e[29]=f,e[30]=D):D=e[30];let B;e[31]!==t.durationMs?(B=q(t.durationMs),e[31]=t.durationMs,e[32]=B):B=e[32];let F;e[33]!==B?(F=n("span",{className:"text-right tabular-nums text-muted-foreground",children:B}),e[33]=B,e[34]=F):F=e[34];let O;e[35]!==t.error?(O=t.error===void 0?null:n("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=O):O=e[36];let C;e[37]!==O?(C=n("span",{className:"truncate text-muted-foreground",children:O}),e[37]=O,e[38]=C):C=e[38];let j;e[39]!==y?(j=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=j):j=e[40];let E;e[41]!==j?(E=n("span",{className:"truncate text-muted-foreground",children:j}),e[41]=j,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==w||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==D||e[49]!==F||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":w,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,D,F,C,E]}),e[43]=r,e[44]=w,e[45]=g,e[46]=I,e[47]=x,e[48]=D,e[49]=F,e[50]=C,e[51]=E,e[52]=W):W=e[52];let K;e[53]!==r||e[54]!==t?(K=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Pe,{span:t})}),e[53]=r,e[54]=t,e[55]=K):K=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==K?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,K]}),e[56]=t.depth,e[57]=W,e[58]=K,e[59]=P):P=e[59],P},Oe=a=>{const e=U(15),{durationMs:t,spans:s}=a,l=Z();let r;e[0]!==t?(r=n(Re,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let i;if(e[4]!==t||e[5]!==s){let c;e[7]!==t?(c=y=>n(Be,{span:y,traceDurationMs:t},y.spanId),e[7]=t,e[8]=c):c=e[8],i=s.map(c),e[4]=t,e[5]=s,e[6]=i}else i=e[6];let d;e[9]!==o||e[10]!==i?(d=n("ul",{"aria-label":o,children:i}),e[9]=o,e[10]=i,e[11]=d):d=e[11];let f;return e[12]!==r||e[13]!==d?(f=k($e,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function je(a){return n("span",{className:ne("absolute inset-y-0 border-l border-border/70",a.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(a.percent)}%`},children:a.label},a.percent)}function We(a){return!a}const Ue=a=>Array.isArray(a?.traces)?a.traces:[],qe=a=>{const e=U(12),{entries:t}=a,s=Z();let l;e[0]!==t.length||e[1]!==s?(l=s("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=s,e[2]=l):l=e[2];let r;e[3]!==l?(r=n("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(Ge),e[5]=t,e[6]=o):o=e[6];let i;e[7]!==o?(i=n("div",{role:"grid",children:o}),e[7]=o,e[8]=i):i=e[8];let d;return e[9]!==r||e[10]!==i?(d=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,i]}),e[9]=r,e[10]=i,e[11]=d):d=e[11],d},ze=a=>{const e=U(50),{expanded:t,logs:s,onToggle:l,trace:r}=a,o=Z();let i;e[0]!==l||e[1]!==r.traceId?(i=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=i):i=e[2];const d=i,f=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,y=`tr-toggle-${r.traceId}`,$=t?"▾":"▸";let M;e[3]!==$?(M=n("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=M):M=e[4];let N;e[5]!==r.rootName?(N=n("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=N):N=e[6];let v;e[7]!==r.functionPath?(v=n("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=v):v=e[8];let S;e[9]!==r.durationMs?(S=q(r.durationMs),e[9]=r.durationMs,e[10]=S):S=e[10];let m;e[11]!==S?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:S}),e[11]=S,e[12]=m):m=e[12];let u;e[13]!==o||e[14]!==r.spans.length?(u=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=u):u=e[15];let h;e[16]!==u?(h=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:u}),e[16]=u,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let _;e[18]!==o||e[19]!==r.ok?(_=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=_):_=e[20];let w;e[21]!==T||e[22]!==_?(w=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=w):w=e[23];let g;e[24]!==r.startTs?(g=me(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let b;e[26]!==g?(b=n("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=b):b=e[27];let I;e[28]!==t||e[29]!==d||e[30]!==m||e[31]!==h||e[32]!==w||e[33]!==b||e[34]!==c||e[35]!==y||e[36]!==M||e[37]!==N||e[38]!==v?(I=k("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":y,onClick:d,type:"button",children:[M,N,v,m,h,w,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=w,e[33]=b,e[34]=c,e[35]=y,e[36]=M,e[37]=N,e[38]=v,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==s||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(p=t&&k("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[n(Oe,{durationMs:r.durationMs,spans:r.spans}),s.length>0&&n(qe,{entries:s})]}),e[40]=t,e[41]=s,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=p):p=e[45];let x;return e[46]!==I||e[47]!==p||e[48]!==f?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":f,children:[I,p]}),e[46]=I,e[47]=p,e[48]=f,e[49]=x):x=e[49],x},gt=a=>{const e=U(58),{initialShardKey:t}=a,s=Z(),[l]=ee(_e),{queryShardKey:r,setShardKey:o,shardKey:i}=Se(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(He);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Je,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let S;e[2]!==r?(S={live:!0,shardKey:r},e[2]=r,e[3]=S):S=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,S);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w={},e[4]=w):w=e[4];const g=$.size>0;let b;e[5]!==r||e[6]!==g?(b={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=b):b=e[7];const{data:I}=oe(ie.getLogs,w,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&we(r)},x=[m,r],e[8]=m,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let R;if(e[12]!==m||e[13]!==u||e[14]!==h||e[15]!==$||e[16]!==T||e[17]!==_||e[18]!==I?.entries||e[19]!==c||e[20]!==d||e[21]!==o||e[22]!==i||e[23]!==s){const L=Ue(m),D=m?.total??L.length,B=D>L.length,F=Ce(L,d,c),O=Map.groupBy((I?.entries??[]).toReversed(),Qe);let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=A=>{f(A.target.value)},e[25]=C):C=e[25];const j=C;let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=A=>{M(he=>{const ae=new Set(he);return ae.has(A)?ae.delete(A):ae.add(A),ae})},e[26]=E):E=e[26];const W=E,K=u===null&&F.length===0&&!T;let P;e[27]!==o||e[28]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[27]=o,e[28]=i,e[29]=P):P=e[29];let z;e[30]!==s?(z=s("Search traces"),e[30]=s,e[31]=z):z=e[31];let G;e[32]!==s?(G=s("search trace, span, or function"),e[32]=s,e[33]=G):G=e[33];let H;e[34]!==d||e[35]!==z||e[36]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:j,placeholder:G,value:d}),e[34]=d,e[35]=z,e[36]=G,e[37]=H):H=e[37];let J;e[38]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[38]=c,e[39]=J):J=e[39];let Q;e[40]!==s?(Q=s("Errors only"),e[40]=s,e[41]=Q):Q=e[41];let V;e[42]!==J||e[43]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[42]=J,e[43]=Q,e[44]=V):V=e[44];let X;e[45]!==_?(X=n(be,{message:_,prefix:"tr"}),e[45]=_,e[46]=X):X=e[46];let te;e[47]!==P||e[48]!==H||e[49]!==V||e[50]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[47]=P,e[48]=H,e[49]=V,e[50]=X,e[51]=te):te=e[51];let re;e[52]!==u||e[53]!==h?(re=u!==null&&n(ge,{error:h,testId:"tr-error"}),e[52]=u,e[53]=h,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==s?(se=K&&n(Ne,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:n("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[55]=K,e[56]=s,e[57]=se):se=e[57],R=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&B&&n("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:D})}),u===null&&F.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:F.map(A=>n(ze,{expanded:$.has(A.traceId),logs:O.get(A.traceId)??[],onToggle:W,trace:A},A.traceId))})]}),e[12]=m,e[13]=u,e[14]=h,e[15]=$,e[16]=T,e[17]=_,e[18]=I?.entries,e[19]=c,e[20]=d,e[21]=o,e[22]=i,e[23]=s,e[24]=R}else R=e[24];return R};function Ge(a,e){return n("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:n(ke,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function He(){return new Set}function Je(){Ie()}function Qe(a){return a.traceId}export{gt as default};
1
+ import{c as U}from"react/compiler-runtime";import{useState as ee,useEffect as le}from"react";import{E as ge}from"../packem_shared/error-alert-dQk3g8WI.mjs";import{L as be}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as xe}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as ye}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{E as Ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ve}from"../packem_shared/input-CXhxesPC.mjs";import{u as oe}from"../packem_shared/use-admin-query-CR9mHt0P.mjs";import{u as we}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as me,j as Se}from"../packem_shared/internal-CyDwqA67.mjs";import{r as _e}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{p as Ie,c as ke}from"../packem_shared/trace-handoff-BV3EWqy_.mjs";import{L as Me}from"../packem_shared/log-line-BHZD2Aj4.mjs";import{f as $e}from"../packem_shared/log-fields-SBxKyBug.mjs";import{c as ne}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as n,jsxs as k,Fragment as Te}from"react/jsx-runtime";const Le=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Ce=(a,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ce(a.offsetMs/e*100),s=a.durationMs/e*100,l=Math.max(Le,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ee=(a,e,t=!1)=>{const s=e.trim().toLowerCase(),l=t?a.filter(r=>!r.ok):a;return s===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(s)||r.functionPath.toLowerCase().includes(s)||r.traceId.toLowerCase().includes(s)||r.spans.some(o=>o.name.toLowerCase().includes(s)||o.spanId.toLowerCase().includes(s)))},q=a=>Number.isFinite(a)?a>0&&a<1?`${a.toFixed(2)}ms`:`${String(Math.round(a))}ms`:"—",Pe=a=>!Number.isFinite(a)||a<=0?[]:Array.from({length:de},(e,t)=>{const s=(t+1)/de;return{label:q(a*s),percent:s*100}}),ue=a=>{if(typeof a=="string")return a;try{return JSON.stringify(a,Se)}catch{return String(a)}},Y=a=>{const e=U(7),{label:t,value:s}=a;let l;e[0]!==t?(l=n("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==s?(r=n("dd",{className:"min-w-0 break-all",children:s}),e[2]=s,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Fe=a=>{const e=U(68),{span:t}=a,s=Z();let l,r,o,i,d,f;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==s){const $=Object.entries(t.attributes??{});let M;e[15]!==t.events?(M=t.events??[],e[15]=t.events,e[16]=M):M=e[16],l=M,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let N;e[17]!==s?(N=s("Span ID"),e[17]=s,e[18]=N):N=e[18];let v;e[19]!==t.spanId||e[20]!==N?(v=n(Y,{label:N,value:t.spanId}),e[19]=t.spanId,e[20]=N,e[21]=v):v=e[21];let w;e[22]!==s?(w=s("Parent span ID"),e[22]=s,e[23]=w):w=e[23];let m;e[24]!==t.parentSpanId||e[25]!==s?(m=t.parentSpanId===""?s("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=s,e[26]=m):m=e[26];let u;e[27]!==m||e[28]!==w?(u=n(Y,{label:w,value:m}),e[27]=m,e[28]=w,e[29]=u):u=e[29];let h;e[30]!==s?(h=s("Kind"),e[30]=s,e[31]=h):h=e[31];const T=t.kind??"internal";let _;e[32]!==h||e[33]!==T?(_=n(Y,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=_):_=e[34];let S;e[35]!==s?(S=s("Started at"),e[35]=s,e[36]=S):S=e[36];let g;e[37]!==t.offsetMs||e[38]!==s?(g=s("+{offset}",{offset:q(t.offsetMs)}),e[37]=t.offsetMs,e[38]=s,e[39]=g):g=e[39];let b;e[40]!==S||e[41]!==g?(b=n(Y,{label:S,value:g}),e[40]=S,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==s?(I=s("Duration"),e[43]=s,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=q(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=n(Y,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==u||e[51]!==_||e[52]!==b||e[53]!==x||e[54]!==v?(i=k("dl",{className:"flex flex-col gap-1",children:[v,u,_,b,x]}),e[50]=u,e[51]=_,e[52]=b,e[53]=x,e[54]=v,e[55]=i):i=e[55],e[56]!==t.error?(d=t.error!==void 0&&k("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[n("span",{className:"font-semibold text-destructive",children:t.error.type}),n("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=d):d=e[57],f=$.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Attributes")}),n("dl",{className:"flex flex-col gap-1",children:$.map(Ke)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=s,e[9]=l,e[10]=r,e[11]=o,e[12]=i,e[13]=d,e[14]=f}else l=e[9],r=e[10],o=e[11],i=e[12],d=e[13],f=e[14];let c;e[58]!==l||e[59]!==s?(c=l.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-events",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Events")}),n("ul",{className:"flex flex-col gap-1",children:l.map(Ae)})]}),e[58]=l,e[59]=s,e[60]=c):c=e[60];let y;return e[61]!==r||e[62]!==o||e[63]!==i||e[64]!==d||e[65]!==f||e[66]!==c?(y=k("div",{className:r,"data-testid":o,children:[i,d,f,c]}),e[61]=r,e[62]=o,e[63]=i,e[64]=d,e[65]=f,e[66]=c,e[67]=y):y=e[67],y};function Ke(a){const[e,t]=a;return n(Y,{label:e,value:ue(t)},e)}function Re(a){const[e,t]=a;return`${e}=${ue(t)}`}function Ae(a){return k("li",{className:"flex gap-2",children:[n("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(a.ts)}),n(fe,{variant:"secondary",children:a.name}),n("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(a.attributes??{}).map(Re).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",je=a=>{const e=U(17),{traceDurationMs:t}=a;let s,l,r,o,i,d;if(e[0]!==t){d=Symbol.for("react.early_return_sentinel");e:{const y=Pe(t);if(y.length===0){d=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=ne(pe,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(i=n("span",{}),e[8]=i):i=e[8],s="relative h-3",l=y.map(We)}e[0]=t,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=i,e[6]=d}else s=e[1],l=e[2],r=e[3],o=e[4],i=e[5],d=e[6];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[9]!==s||e[10]!==l?(f=n("span",{className:s,children:l}),e[9]=s,e[10]=l,e[11]=f):f=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==i||e[15]!==f?(c=k("div",{className:r,"data-testid":o,children:[i,f]}),e[12]=r,e[13]=o,e[14]=i,e[15]=f,e[16]=c):c=e[16],c},Be=a=>{const e=U(60),{span:t,traceDurationMs:s}=a,l=Z(),[r,o]=ee(!1);let i;e[0]!==t||e[1]!==s?(i=Ce(t,s),e[0]=t,e[1]=s,e[2]=i):i=e[2];const{leftPercent:d,widthPercent:f}=i;let c;e[3]!==t.attributes?(c=$e(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const y=c,$=t.depth*De;let M;e[5]!==$?(M={paddingLeft:$},e[5]=$,e[6]=M):M=e[6];const N=M,v=`${String(d)}%`,w=`${String(f)}%`;let m;e[7]!==v||e[8]!==w?(m={left:v,width:w},e[7]=v,e[8]=w,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(Ue)},e[10]=h):h=e[10];const T=h,_=t.depth,S=`tr-span-detail-${t.spanId}`;let g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:q(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:q(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=ne(pe,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=b):b=e[17];const I=`tr-span-toggle-${t.spanId}`;let p;e[18]!==t.ok?(p=t.ok?null:n("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"●"}),e[18]=t.ok,e[19]=p):p=e[19];let x;e[20]!==N||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:N,title:t.name,children:[p,t.name]}),e[20]=N,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const D=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==D?(L=ne("absolute inset-y-0 rounded-sm",D),e[24]=D,e[25]=L):L=e[25];let A;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(A=n("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:n("span",{className:L,"data-left":d,"data-testid":"tr-span-bar","data-width":f,style:u})}),e[26]=u,e[27]=d,e[28]=L,e[29]=f,e[30]=A):A=e[30];let j;e[31]!==t.durationMs?(j=q(t.durationMs),e[31]=t.durationMs,e[32]=j):j=e[32];let F;e[33]!==j?(F=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=F):F=e[34];let B;e[35]!==t.error?(B=t.error===void 0?null:n("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=B):B=e[36];let C;e[37]!==B?(C=n("span",{className:"truncate text-muted-foreground",children:B}),e[37]=B,e[38]=C):C=e[38];let O;e[39]!==y?(O=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=O):O=e[40];let E;e[41]!==O?(E=n("span",{className:"truncate text-muted-foreground",children:O}),e[41]=O,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==S||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==A||e[49]!==F||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":S,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,A,F,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=F,e[50]=C,e[51]=E,e[52]=W):W=e[52];let K;e[53]!==r||e[54]!==t?(K=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=K):K=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==K?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,K]}),e[56]=t.depth,e[57]=W,e[58]=K,e[59]=P):P=e[59],P},Oe=a=>{const e=U(15),{durationMs:t,spans:s}=a,l=Z();let r;e[0]!==t?(r=n(je,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let i;if(e[4]!==t||e[5]!==s){let c;e[7]!==t?(c=y=>n(Be,{span:y,traceDurationMs:t},y.spanId),e[7]=t,e[8]=c):c=e[8],i=s.map(c),e[4]=t,e[5]=s,e[6]=i}else i=e[6];let d;e[9]!==o||e[10]!==i?(d=n("ul",{"aria-label":o,children:i}),e[9]=o,e[10]=i,e[11]=d):d=e[11];let f;return e[12]!==r||e[13]!==d?(f=k(Te,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function We(a){return n("span",{className:ne("absolute inset-y-0 border-l border-border/70",a.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(a.percent)}%`},children:a.label},a.percent)}function Ue(a){return!a}const qe=a=>Array.isArray(a?.traces)?a.traces:[],ze=a=>{const e=U(12),{entries:t}=a,s=Z();let l;e[0]!==t.length||e[1]!==s?(l=s("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=s,e[2]=l):l=e[2];let r;e[3]!==l?(r=n("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(He),e[5]=t,e[6]=o):o=e[6];let i;e[7]!==o?(i=n("div",{role:"grid",children:o}),e[7]=o,e[8]=i):i=e[8];let d;return e[9]!==r||e[10]!==i?(d=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,i]}),e[9]=r,e[10]=i,e[11]=d):d=e[11],d},Ge=a=>{const e=U(50),{expanded:t,logs:s,onToggle:l,trace:r}=a,o=Z();let i;e[0]!==l||e[1]!==r.traceId?(i=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=i):i=e[2];const d=i,f=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,y=`tr-toggle-${r.traceId}`,$=t?"▾":"▸";let M;e[3]!==$?(M=n("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=M):M=e[4];let N;e[5]!==r.rootName?(N=n("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=N):N=e[6];let v;e[7]!==r.functionPath?(v=n("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=v):v=e[8];let w;e[9]!==r.durationMs?(w=q(r.durationMs),e[9]=r.durationMs,e[10]=w):w=e[10];let m;e[11]!==w?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:w}),e[11]=w,e[12]=m):m=e[12];let u;e[13]!==o||e[14]!==r.spans.length?(u=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=u):u=e[15];let h;e[16]!==u?(h=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:u}),e[16]=u,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let _;e[18]!==o||e[19]!==r.ok?(_=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=_):_=e[20];let S;e[21]!==T||e[22]!==_?(S=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=S):S=e[23];let g;e[24]!==r.startTs?(g=me(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let b;e[26]!==g?(b=n("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=b):b=e[27];let I;e[28]!==t||e[29]!==d||e[30]!==m||e[31]!==h||e[32]!==S||e[33]!==b||e[34]!==c||e[35]!==y||e[36]!==M||e[37]!==N||e[38]!==v?(I=k("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":y,onClick:d,type:"button",children:[M,N,v,m,h,S,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=S,e[33]=b,e[34]=c,e[35]=y,e[36]=M,e[37]=N,e[38]=v,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==s||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(p=t&&k("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[n(Oe,{durationMs:r.durationMs,spans:r.spans}),s.length>0&&n(ze,{entries:s})]}),e[40]=t,e[41]=s,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=p):p=e[45];let x;return e[46]!==I||e[47]!==p||e[48]!==f?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":f,children:[I,p]}),e[46]=I,e[47]=p,e[48]=f,e[49]=x):x=e[49],x},bt=a=>{const e=U(58),{initialShardKey:t}=a,s=Z(),[l]=ee(Ie),{queryShardKey:r,setShardKey:o,shardKey:i}=we(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(Je);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Qe,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let w;e[2]!==r?(w={live:!0,shardKey:r},e[2]=r,e[3]=w):w=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,w);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={},e[4]=S):S=e[4];const g=$.size>0;let b;e[5]!==r||e[6]!==g?(b={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=b):b=e[7];const{data:I}=oe(ie.getLogs,S,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&_e(r)},x=[m,r],e[8]=m,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let D;if(e[12]!==m||e[13]!==u||e[14]!==h||e[15]!==$||e[16]!==T||e[17]!==_||e[18]!==I?.entries||e[19]!==c||e[20]!==d||e[21]!==o||e[22]!==i||e[23]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,F=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[25]=C):C=e[25];const O=C;let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=R=>{M(he=>{const ae=new Set(he);return ae.has(R)?ae.delete(R):ae.add(R),ae})},e[26]=E):E=e[26];const W=E,K=u===null&&F.length===0&&!T;let P;e[27]!==o||e[28]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[27]=o,e[28]=i,e[29]=P):P=e[29];let z;e[30]!==s?(z=s("Search traces"),e[30]=s,e[31]=z):z=e[31];let G;e[32]!==s?(G=s("search trace, span, or function"),e[32]=s,e[33]=G):G=e[33];let H;e[34]!==d||e[35]!==z||e[36]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[34]=d,e[35]=z,e[36]=G,e[37]=H):H=e[37];let J;e[38]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[38]=c,e[39]=J):J=e[39];let Q;e[40]!==s?(Q=s("Errors only"),e[40]=s,e[41]=Q):Q=e[41];let V;e[42]!==J||e[43]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[42]=J,e[43]=Q,e[44]=V):V=e[44];let X;e[45]!==_?(X=n(be,{message:_,prefix:"tr"}),e[45]=_,e[46]=X):X=e[46];let te;e[47]!==P||e[48]!==H||e[49]!==V||e[50]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[47]=P,e[48]=H,e[49]=V,e[50]=X,e[51]=te):te=e[51];let re;e[52]!==u||e[53]!==h?(re=u!==null&&n(ge,{error:h,testId:"tr-error"}),e[52]=u,e[53]=h,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==s?(se=K&&n(Ne,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:n("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[55]=K,e[56]=s,e[57]=se):se=e[57],D=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&j&&n("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:A})}),u===null&&F.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:F.map(R=>n(Ge,{expanded:$.has(R.traceId),logs:B.get(R.traceId)??[],onToggle:W,trace:R},R.traceId))})]}),e[12]=m,e[13]=u,e[14]=h,e[15]=$,e[16]=T,e[17]=_,e[18]=I?.entries,e[19]=c,e[20]=d,e[21]=o,e[22]=i,e[23]=s,e[24]=D}else D=e[24];return D};function He(a,e){return n("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:n(Me,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function Je(){return new Set}function Qe(){ke()}function Ve(a){return a.traceId}export{bt as default};