@metabase/cli 0.3.1 → 0.3.2-alpha.fix-transform-test-ee-path.041c793

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 (267) hide show
  1. package/dist/{add-collection-CYDUm_XO.mjs → add-collection-73X1DmCM.mjs} +6 -9
  2. package/dist/{alert-ClyhtxIz.mjs → alert-BB38lWSL.mjs} +7 -7
  3. package/dist/{alerts-Dt3D1gcz.mjs → alerts-DxyzqLSU.mjs} +7 -7
  4. package/dist/{append-Bl_Ensmr.mjs → append-CHme1Enm.mjs} +5 -5
  5. package/dist/{archive-DSMqHRr1.mjs → archive-BGiDxu8O.mjs} +4 -4
  6. package/dist/{archive-D3a3Wgz0.mjs → archive-BMyvyf62.mjs} +4 -4
  7. package/dist/{archive-BdHXQg4I.mjs → archive-C4Y2B58q.mjs} +4 -4
  8. package/dist/{archive-CWceyy8x.mjs → archive-CP5Hlqjw.mjs} +5 -5
  9. package/dist/{archive-BOyKhNOz.mjs → archive-Cq3fnc0v2.mjs} +6 -6
  10. package/dist/{archive-DVGDg8mP.mjs → archive-CqKqNdUh.mjs} +6 -6
  11. package/dist/{archive-DDru3vdy.mjs → archive-Czo5T0Lp.mjs} +4 -4
  12. package/dist/{archive-nKD3mOB8.mjs → archive-DBcxZwLd.mjs} +6 -6
  13. package/dist/{archive-CNblz55j.mjs → archive-DKFPJ9j3.mjs} +6 -6
  14. package/dist/{archive-BJZ7Dace.mjs → archive-DPL1qOuL.mjs} +6 -6
  15. package/dist/{archive-DiGxCojL.mjs → archive-eS-XA74p.mjs} +4 -4
  16. package/dist/{auth-aCksg8q2.mjs → auth-6YyB0HNB.mjs} +5 -5
  17. package/dist/{body-DxRSAMNC.mjs → body-OjAWKVaU.mjs} +3 -3
  18. package/dist/{branches-_0VWR2Zm.mjs → branches-D5YLVFDK.mjs} +4 -7
  19. package/dist/{cancel-ctpVE8uC.mjs → cancel-DeRIq1YJ.mjs} +4 -4
  20. package/dist/{cancel-task-FtxBka-M.mjs → cancel-task-CqExODVm.mjs} +5 -8
  21. package/dist/card-BMSqofd7.mjs +24 -0
  22. package/dist/{card-zyUkr2nS.mjs → card-CEkp1mcI.mjs} +1 -1
  23. package/dist/{card-DZxRmver.mjs → card-voh1k4hl.mjs} +14 -11
  24. package/dist/{cards-DHOWAvfv.mjs → cards-B813G9I5.mjs} +7 -7
  25. package/dist/cli.mjs +572 -69
  26. package/dist/client-cJ7aw0Gt.mjs +4092 -0
  27. package/dist/collection-BfNg7tEg.mjs +20 -0
  28. package/dist/{collection-CfulNRBG.mjs → collection-BxdPxD38.mjs} +1 -1
  29. package/dist/{collection-CGoVLvcD.mjs → collection-DYM0p3Xl.mjs} +1 -1
  30. package/dist/{collection-namespace-CEoQ7G08.mjs → collection-namespace-CVzDgJV0.mjs} +2 -2
  31. package/dist/{content-translation-DNKerjS3.mjs → content-translation-QKWt9l76.mjs} +3 -3
  32. package/dist/{create-e650zxzX.mjs → create-4UnoQvsy.mjs} +5 -5
  33. package/dist/{create-DaYRnK5P.mjs → create-BJad6MR82.mjs} +8 -8
  34. package/dist/{create-CcLchJAN.mjs → create-BLiB2xqo.mjs} +7 -7
  35. package/dist/{create-C9vy4ZG6.mjs → create-BWp6L_dW.mjs} +5 -5
  36. package/dist/{create-C78g8Crb.mjs → create-Bef5eBCA.mjs} +5 -5
  37. package/dist/{create-F4Lf09xq.mjs → create-CMV3qlzJ.mjs} +4 -4
  38. package/dist/{create-DmvoibX8.mjs → create-CWGsiFvU.mjs} +4 -4
  39. package/dist/{create-C3IaXXty.mjs → create-CoFg1p6m.mjs} +4 -4
  40. package/dist/{create-CEydRMWS.mjs → create-CvIeb1NU.mjs} +7 -7
  41. package/dist/{create-vlrlY-2E.mjs → create-CvpeAcFc.mjs} +4 -4
  42. package/dist/{create-wJR4CxHA.mjs → create-D50TxVTk.mjs} +5 -8
  43. package/dist/{create-CLG2-bso.mjs → create-DEBgYRlM.mjs} +6 -6
  44. package/dist/{create-7ddYK4TA.mjs → create-DJm0YuLW.mjs} +6 -6
  45. package/dist/{create-BdPVWYSi.mjs → create-DmKwDQCY2.mjs} +6 -6
  46. package/dist/{create-branch-B8C7jl-J.mjs → create-branch-BN5iH-GM.mjs} +5 -9
  47. package/dist/{create-DIVhBIyE.mjs → create-bvpl6Fn5.mjs} +11 -7
  48. package/dist/create-uanpKsPo.mjs +34 -0
  49. package/dist/{csv-BLPJtlSC.mjs → csv-BhuX9fwh.mjs} +5 -5
  50. package/dist/{current-task-C-ldJbWE.mjs → current-task-BMt2NeqV.mjs} +5 -8
  51. package/dist/{dashboard-CtO_3EfC.mjs → dashboard-Ct_ajSYI.mjs} +10 -10
  52. package/dist/{dashboard-CKUR8ZpQ.mjs → dashboard-D0hwTC-f.mjs} +11 -2
  53. package/dist/{dashboard-BlbNszi8.mjs → dashboard-DgK81azj.mjs} +1 -1
  54. package/dist/{database-B19qlLKZ.mjs → database-C3E9PZSx.mjs} +1 -1
  55. package/dist/{database-C8G6ZKG0.mjs → database-JtHTqSpq.mjs} +1 -1
  56. package/dist/{db-xXselnBq.mjs → db-B_LW2VE-.mjs} +7 -7
  57. package/dist/{delete-ZJJyqsRh.mjs → delete-BOcPK_H9.mjs} +5 -5
  58. package/dist/{delete-BZZHw6pm.mjs → delete-CowGO4rh.mjs} +5 -5
  59. package/dist/{delete-D6WxgWRp.mjs → delete-D0f7VatX.mjs} +5 -5
  60. package/dist/{delete-BwSPQy7m.mjs → delete-D2bUV6uo.mjs} +5 -5
  61. package/dist/delete-DZ_ICQug.mjs +44 -0
  62. package/dist/{delete-BZwAOQxG.mjs → delete-Ur7b11no.mjs} +5 -5
  63. package/dist/{delete-runtime-D74s6vhu.mjs → delete-runtime-BKEzJn22.mjs} +1 -2
  64. package/dist/{delete-table-CJktZE3w.mjs → delete-table-Dd8X573t.mjs} +5 -5
  65. package/dist/{dependencies-BdqIqEIy.mjs → dependencies-XDVLBwko.mjs} +7 -7
  66. package/dist/{dirty-BW2As2wS.mjs → dirty-k-JmGLsS.mjs} +6 -9
  67. package/dist/{document-Cd2mmqCp.mjs → document-BHpLJbKU.mjs} +5 -0
  68. package/dist/document-BW9iow8R.mjs +19 -0
  69. package/dist/{document-D6OybtP2.mjs → document-CA0Q6lqu.mjs} +1 -1
  70. package/dist/{download-mfFJ9oRS.mjs → download-CQjPIYDO.mjs} +3 -6
  71. package/dist/{eid-DZ-4t2xe.mjs → eid-CNTKDgwj.mjs} +4 -5
  72. package/dist/{events-D6yFmXP1.mjs → events-BshWlkDp.mjs} +5 -5
  73. package/dist/{export-DYZjz1WP.mjs → export-Dq6ecU8h.mjs} +7 -10
  74. package/dist/{field-BJ54wmIX.mjs → field-Bo2ISMO4.mjs} +5 -5
  75. package/dist/{field-Cr2DPUG9.mjs → field-CcN4oZy6.mjs} +16 -1
  76. package/dist/{field-BPsNa-TO.mjs → field-fDtIrY6D.mjs} +1 -1
  77. package/dist/{fields-FUWCgPOa.mjs → fields-CVctqn5G.mjs} +7 -7
  78. package/dist/{get-BraVQ1FJ.mjs → get-7xTeNGAo.mjs} +6 -6
  79. package/dist/{get-LAew34ID.mjs → get-8b5Sh50q.mjs} +6 -6
  80. package/dist/{get-CWnriw33.mjs → get-B4RgW-VT.mjs} +6 -6
  81. package/dist/{get-C_5AbfpO.mjs → get-BD81MHl_.mjs} +4 -4
  82. package/dist/{get-ByZJf9nO.mjs → get-Bl3OmlBP.mjs} +5 -5
  83. package/dist/get-BtTetWzm.mjs +32 -0
  84. package/dist/{get-_ggLr1tY.mjs → get-BvSA_mmf.mjs} +6 -6
  85. package/dist/{get-DhkltKIV.mjs → get-BvgEF--n.mjs} +4 -4
  86. package/dist/{get-DYaQpixt.mjs → get-C5sWciaE.mjs} +6 -6
  87. package/dist/get-CO6X4nZH.mjs +93 -0
  88. package/dist/{get-DVyesErX.mjs → get-CTPvdcud.mjs} +6 -6
  89. package/dist/{get-DMECsioX.mjs → get-CrpwxWOV.mjs} +4 -4
  90. package/dist/{get-Ba2HRdrx.mjs → get-D4oGhZWX.mjs} +6 -6
  91. package/dist/{get-CsN7NBI0.mjs → get-Df6cGHCM.mjs} +4 -4
  92. package/dist/{get-BWl3vzsf.mjs → get-DfMVlz64.mjs} +6 -6
  93. package/dist/{get-C5q49Dgx.mjs → get-Dr-U321T2.mjs} +6 -6
  94. package/dist/{get-DAOSGt5Z.mjs → get-Dw7jAno3.mjs} +6 -6
  95. package/dist/{get-DRJtsS1_.mjs → get-PWhOdz1z.mjs} +4 -4
  96. package/dist/{get-CQ0-fFWP.mjs → get-RslzBaXx.mjs} +5 -8
  97. package/dist/{get-run-oH4dRCBx.mjs → get-run-CZdDqfUj.mjs} +6 -6
  98. package/dist/{get-DCutQeiV.mjs → get-wjIgUlNl.mjs} +4 -4
  99. package/dist/git-sync-BmoRk0UV.mjs +28 -0
  100. package/dist/{git-sync-BDnxPrqU.mjs → git-sync-BwBRmEhE.mjs} +18 -1
  101. package/dist/{git-sync-DxD_ng48.mjs → git-sync-TjX1r_wF.mjs} +1 -1
  102. package/dist/{group-DBM87IgC.mjs → group-YQQ5GIcP.mjs} +2 -2
  103. package/dist/{has-remote-changes-CnmyIw_7.mjs → has-remote-changes-i-3MVxat.mjs} +5 -8
  104. package/dist/{import-B7Si-bSI.mjs → import-DWEKejya.mjs} +7 -10
  105. package/dist/{input-DH9i67x_.mjs → input-DEvkIjGr.mjs} +1 -1
  106. package/dist/{is-dirty-BOH_VEA8.mjs → is-dirty-C5ipqd4v.mjs} +3 -6
  107. package/dist/{items-DouHkWev.mjs → items-hKJ2ZDwy.mjs} +7 -7
  108. package/dist/{key-BEhqIzIQ.mjs → key-PYetuQ13.mjs} +1 -1
  109. package/dist/{library-1J_4Dicw.mjs → library-B7_04UVK.mjs} +5 -5
  110. package/dist/library-BPIzb3K_.mjs +81 -0
  111. package/dist/{library-DfYAT2Ep.mjs → library-PGCfm0UA.mjs} +1 -1
  112. package/dist/{list-BK_6VNm_.mjs → list-1vdClKSE.mjs} +4 -4
  113. package/dist/{list-DWLGpMvr.mjs → list-6myofqMv.mjs} +7 -7
  114. package/dist/{list-DhViDVx_.mjs → list-B-9QOX9Y.mjs} +6 -6
  115. package/dist/{list-aKUk-a1Y.mjs → list-Bs7_Rysg.mjs} +7 -7
  116. package/dist/list-CHuhMXet.mjs +35 -0
  117. package/dist/{list-DptEWB5Y.mjs → list-CLZU_EOf.mjs} +4 -4
  118. package/dist/{list-B2Ddf4W0.mjs → list-Cen-7uTo.mjs} +5 -5
  119. package/dist/{list-D2IYZ6lk.mjs → list-CgH-H-O6.mjs} +6 -6
  120. package/dist/{list-BeMYIeiI.mjs → list-CjNXskB4.mjs} +7 -7
  121. package/dist/{list-C1bAtgO1.mjs → list-CmFh1GQ_.mjs} +4 -4
  122. package/dist/{list-Cy0w4Fap.mjs → list-D6tTvYUP.mjs} +4 -4
  123. package/dist/{list-C7UvO3Uw.mjs → list-DI820W6w.mjs} +6 -6
  124. package/dist/{list-D25ofn4v.mjs → list-DKZnQ4Ts.mjs} +7 -7
  125. package/dist/{list-C0zJ2ehz.mjs → list-DKcC4cm0.mjs} +6 -6
  126. package/dist/{list-qs9wAtC3.mjs → list-DfRqNH1N.mjs} +4 -4
  127. package/dist/list-DjwnsyXM.mjs +60 -0
  128. package/dist/{list-sDpy4nDU.mjs → list-VNC-_E59.mjs} +6 -6
  129. package/dist/{list-DJK9_BEF.mjs → list-eKDT1XXk.mjs} +14 -13
  130. package/dist/{list-BXlTYsYA.mjs → list-oX2SMzxZ.mjs} +4 -4
  131. package/dist/{login-BmyCAfRV.mjs → login-DumZaWXK.mjs} +18 -15
  132. package/dist/{logout-DUR32q0V.mjs → logout-BsXPRc-3.mjs} +3 -4
  133. package/dist/{measure-DdVp-8jw.mjs → measure-BFxkbAoa.mjs} +6 -6
  134. package/dist/{notification-Fcq1fIPw.mjs → notification-DVrLkjFT.mjs} +1 -1
  135. package/dist/{parameter-DUKR8NXo.mjs → parameter-Celg0wZa.mjs} +1 -1
  136. package/dist/{parameter-values-CBR-cBev.mjs → parameter-values-CoF9Hx1p.mjs} +5 -6
  137. package/dist/{parse-enum-D0Jfm_Bz.mjs → parse-enum-Dc0dMZ3P.mjs} +1 -1
  138. package/dist/{parse-id-B3YwNojT.mjs → parse-id-DmFJgpY6.mjs} +1 -1
  139. package/dist/{parse-ref-ibKVB0J4.mjs → parse-ref-DTDld_LJ.mjs} +1 -1
  140. package/dist/{path-D8BQmEhL.mjs → path-BQ4lRDyN.mjs} +5 -5
  141. package/dist/{poll-75SvT7Zv.mjs → poll-CZeXepUQ.mjs} +2 -2
  142. package/dist/{preflight-CoF1Em99.mjs → preflight-BTQe4swo.mjs} +3 -4
  143. package/dist/{process-DBOOrmET.mjs → process-CTrfxxaC.mjs} +1 -1
  144. package/dist/{publish-Cb7XrQ3X.mjs → publish-CFB2Cc5A.mjs} +9 -9
  145. package/dist/{pulse-BmsDenXm.mjs → pulse-Dz0ocv0l.mjs} +1 -1
  146. package/dist/{pulse-DhG6I9mI.mjs → pulse-x0gFxWfG.mjs} +2 -2
  147. package/dist/{query-D35B588l.mjs → query-BJbUnAHf.mjs} +10 -12
  148. package/dist/query-CV2KCS5O.mjs +114 -0
  149. package/dist/{query-result-DBDwk8TS.mjs → query-result-E4Q-Gra6.mjs} +1 -1
  150. package/dist/{remove-collection-DJem6V26.mjs → remove-collection-D3yvKH3e.mjs} +6 -9
  151. package/dist/{render-CI93iP0I.mjs → render-BJRCs7rA.mjs} +13 -2
  152. package/dist/{replace-CtsWICrD.mjs → replace-uj4WTqx_.mjs} +5 -5
  153. package/dist/{rescan-values-CaXUL6z5.mjs → rescan-values-CzxQU318.mjs} +6 -6
  154. package/dist/{run-CM-Amtbf.mjs → run-B2f_omHu.mjs} +26 -14
  155. package/dist/run-DlO1J1Sx.mjs +50 -0
  156. package/dist/{run-BeLm17F4.mjs → run-yX2dtmE5.mjs} +6 -6
  157. package/dist/{runs-DFG63zgr.mjs → runs-DzUO45wU.mjs} +7 -7
  158. package/dist/{runtime-z8rra6-I.mjs → runtime-arKqJqIT.mjs} +994 -252
  159. package/dist/{schema-tables-COAHkIcy.mjs → schema-tables-DZCNzuQ6.mjs} +7 -7
  160. package/dist/{schemas-BX5BATiV.mjs → schemas-2ejqaVsG.mjs} +5 -5
  161. package/dist/{search-DFBwUc6d.mjs → search-BAXg-EJw.mjs} +2 -1
  162. package/dist/{search-CPvvmhdt.mjs → search-DcihauDZ.mjs} +6 -6
  163. package/dist/{segment-C62L6BI3.mjs → segment-BQT2poPG.mjs} +6 -6
  164. package/dist/{selectors-P4QnrORk.mjs → selectors-BzestDld.mjs} +3 -3
  165. package/dist/{send-PZh5IKF8.mjs → send-DMxoLFo7.mjs} +4 -4
  166. package/dist/{set-DbCtUoFd.mjs → set-CDmiD0vv.mjs} +5 -5
  167. package/dist/{set-active-DL4QzWDO.mjs → set-active-RrvWR9NY.mjs} +5 -5
  168. package/dist/{setting-BlRcZbhC.mjs → setting-BiBLCcxz.mjs} +4 -4
  169. package/dist/{setup-D_SLaC-3.mjs → setup-DYsTzkWO.mjs} +4 -4
  170. package/dist/{signal-CMd0EFUa.mjs → signal-k7cm5N6h.mjs} +11 -2
  171. package/dist/skill-list-D9_1Pmt7.mjs +76 -0
  172. package/dist/skills-BPHXUfeL.mjs +351 -0
  173. package/dist/{skills-D991LB1M.mjs → skills-C3bxxC6a.mjs} +3 -3
  174. package/dist/snippet-BtfxE60H.mjs +19 -0
  175. package/dist/{stash-DyBxFoP6.mjs → stash-DdheS0Ad.mjs} +7 -11
  176. package/dist/{status-cfDHqK2Q.mjs → status-BuIzXRX1.mjs} +12 -11
  177. package/dist/{status-DUsiogz5.mjs → status-CXouQJ31.mjs} +11 -9
  178. package/dist/{subscription-Bn0AU7GN.mjs → subscription-CJ8Igs1U.mjs} +6 -6
  179. package/dist/{subscriptions-DwqjCVlc.mjs → subscriptions-D0NpGvCQ.mjs} +7 -7
  180. package/dist/{summary-BGwSNzf4.mjs → summary-D04S8gGj.mjs} +6 -6
  181. package/dist/{sync-schema-dtkDOAKe.mjs → sync-schema-DrA5zkdl.mjs} +7 -7
  182. package/dist/{sync-task-BACcrs0i.mjs → sync-task-BXeWuARG.mjs} +1 -1
  183. package/dist/{table-CsIJNPFf.mjs → table-C6h4tIRw.mjs} +1 -1
  184. package/dist/{table-CeeTJgQb.mjs → table-DfuY0N8e.mjs} +51 -4
  185. package/dist/{table-BJoEAoCU.mjs → table-Dntbz7Q2.mjs} +5 -5
  186. package/dist/timeline-8jwsldo3.mjs +21 -0
  187. package/dist/{timeline-event-BsF7YqzZ.mjs → timeline-event-BbB1xEdI.mjs} +6 -6
  188. package/dist/{transform-DoTyyXAu.mjs → transform-CtqB1WYo.mjs} +2 -2
  189. package/dist/{transform-D3QX0jxA.mjs → transform-DiW7bREn.mjs} +68 -5
  190. package/dist/{transform-job-50GZHhKH.mjs → transform-job-AaMZRxAq.mjs} +1 -1
  191. package/dist/transform-job-B-1YAbvy.mjs +22 -0
  192. package/dist/{transform-job-DRrK28IH.mjs → transform-job-CCguL6LP.mjs} +41 -4
  193. package/dist/transform-m6s4kkWU.mjs +28 -0
  194. package/dist/{transform-tag-VM9R7Q_M.mjs → transform-tag-PjryheLF.mjs} +5 -5
  195. package/dist/transform-test-BjjCQ2xm.mjs +169 -0
  196. package/dist/transform-test-DSTkKKNC.mjs +16 -0
  197. package/dist/transform-test-gzDcbypy.mjs +25 -0
  198. package/dist/{transforms-BjACGbBp.mjs → transforms-CijX3VE7.mjs} +7 -7
  199. package/dist/{tree-BwS6JAmk.mjs → tree-Cmb3O6rH.mjs} +4 -5
  200. package/dist/{unpublish-DWdPnENY.mjs → unpublish-DkP_AcK5.mjs} +4 -7
  201. package/dist/{update-DKEHY-gt.mjs → update-8UmD1prT.mjs} +7 -7
  202. package/dist/{update-C1FBVLfC.mjs → update-BFyRBc-H.mjs} +8 -8
  203. package/dist/{update-tLIhVIPp.mjs → update-BrXGg3QO.mjs} +8 -8
  204. package/dist/{update-DCjAjihm.mjs → update-C91m9YAR.mjs} +6 -6
  205. package/dist/{update-BpPaacCF.mjs → update-COcx61Ur.mjs} +6 -6
  206. package/dist/update-Ci8YL4_2.mjs +41 -0
  207. package/dist/{update-BR_vkkd1.mjs → update-CtLbFCd_.mjs} +5 -5
  208. package/dist/{update-DTmRHBik.mjs → update-D6Zzvc7F.mjs} +7 -7
  209. package/dist/{update-cqR1U6DU.mjs → update-D8htjzNJ.mjs} +5 -5
  210. package/dist/{update-B2CF2DK4.mjs → update-D9kOTr0n.mjs} +6 -6
  211. package/dist/{update-C4y3iQsv.mjs → update-DPTio6i1.mjs} +7 -7
  212. package/dist/{update-DsZttiSC.mjs → update-DlWB9s0v.mjs} +5 -5
  213. package/dist/{update-BCT9qpVr.mjs → update-DubrpPbz.mjs} +5 -5
  214. package/dist/{update-3idz42uD.mjs → update-Dz47cKBk.mjs} +7 -7
  215. package/dist/{update-DkviXwSg.mjs → update-FCP5Lop2.mjs} +7 -7
  216. package/dist/{update-DlTaD1x3.mjs → update-KSHnb6vB.mjs} +9 -9
  217. package/dist/{update-dashcard-DlE_bb2F.mjs → update-dashcard-BlibHa5o.mjs} +7 -7
  218. package/dist/{upgrade-mNV7XuJG.mjs → upgrade-EwL6wPSY.mjs} +6 -8
  219. package/dist/upload-BZshRJIM.mjs +13 -0
  220. package/dist/{upload-CEGVxmYB.mjs → upload-D0KaTqUE.mjs} +4 -7
  221. package/dist/{upload-CD555ui1.mjs → upload-Do2PBSeH.mjs} +2 -2
  222. package/dist/{uuid-C4hqn3kA.mjs → uuid-DjKLDIVE.mjs} +10 -7
  223. package/dist/{validate-query-DaGYSmpQ.mjs → validate-query-D6_ad-Gi.mjs} +3 -4
  224. package/dist/{validate-BWchyW0V.mjs → validate-xR_MHBNR.mjs} +69 -23
  225. package/dist/{values-C0O3eNaW.mjs → values-Dc9612_L.mjs} +6 -6
  226. package/dist/{verify-DfTjYF7s.mjs → verify-DVN1eqXZ.mjs} +3 -18
  227. package/dist/{wait-WZmFenN_.mjs → wait-C-ovOTAZ.mjs} +7 -10
  228. package/dist/{wait-flags-BbfDSP8R.mjs → wait-flags-BQNmuvIj.mjs} +2 -2
  229. package/dist/{window-BkvrP0gB.mjs → window-DSb1tqSe.mjs} +1 -1
  230. package/package.json +1 -1
  231. package/skill-data/core/SKILL.md +31 -15
  232. package/skill-data/dashboard/SKILL.md +1 -1
  233. package/skill-data/data-workflow/references/building-clean-tables.md +6 -2
  234. package/skill-data/data-workflow/references/reusable-definitions.md +11 -3
  235. package/skill-data/document/SKILL.md +4 -1
  236. package/skill-data/git-sync/SKILL.md +5 -0
  237. package/skill-data/mbql/SKILL.md +84 -115
  238. package/skill-data/mbql/references/operators.md +77 -231
  239. package/skill-data/metadata/SKILL.md +1 -1
  240. package/skill-data/metadata/references/semantic-types.md +7 -1
  241. package/skill-data/native-sql/SKILL.md +8 -9
  242. package/skill-data/native-sql/references/template-tags.md +27 -27
  243. package/skill-data/notification/SKILL.md +7 -1
  244. package/skill-data/transform/SKILL.md +76 -4
  245. package/skill-data/transform-test-plan/SKILL.md +171 -0
  246. package/skill-data/transform-test-plan/references/checklist.md +81 -0
  247. package/skill-data/transform-test-plan/references/checks.md +260 -0
  248. package/skill-data/visualization/SKILL.md +13 -6
  249. package/skill-data/visualization/references/settings.md +13 -11
  250. package/skills/metabase-cli/SKILL.md +1 -1
  251. package/dist/card-CGCXbdmD.mjs +0 -24
  252. package/dist/client-mKuHg_sc.mjs +0 -2218
  253. package/dist/collection-D8Tk8i3a.mjs +0 -20
  254. package/dist/document-KbcHhzFz.mjs +0 -19
  255. package/dist/get-BC8J8BXB.mjs +0 -80
  256. package/dist/git-sync-Dik8nKfw.mjs +0 -28
  257. package/dist/library-ClLgrAXy.mjs +0 -19
  258. package/dist/list-CW5PdYCX.mjs +0 -98
  259. package/dist/network-error-D6CiOEBw.mjs +0 -431
  260. package/dist/predicates-Bkm2IoeX.mjs +0 -170
  261. package/dist/query-C256WBYG.mjs +0 -87
  262. package/dist/skills-DTCrMcix.mjs +0 -216
  263. package/dist/snippet-DTDO55Cg.mjs +0 -19
  264. package/dist/timeline-DcXPshcT.mjs +0 -21
  265. package/dist/transform-Dsf_wHAj.mjs +0 -28
  266. package/dist/transform-job-B1yLv5l-.mjs +0 -22
  267. package/dist/upload-DsYCf5kB.mjs +0 -13
@@ -0,0 +1,4092 @@
1
+ import { $ as InternalError, Q as ConfigError, at as ValidationError, n as methodRequirements, nt as ResponseShapeError, ot as errorMessage, rt as TimeoutError, tt as NetworkError } from "./cli.mjs";
2
+ import { n as Notification, r as NotificationCardPayload, t as CARD_PAYLOAD_TYPE } from "./notification-DaA4bBHW.mjs";
3
+ import { $ as createServerProfile, B as JSON_CONTENT_TYPE, F as buildNetworkError, G as credentialSecrets, H as parseJsonOrPlain, I as isConnectionClosed, J as normalizeUrl, L as HttpError, U as assertCredentialHeaderSafe, V as parseJson, W as credentialAuthHeader, Z as checkFeatures, et as probeServer, tt as CapabilityError, z as isRetryableStatus } from "./runtime-arKqJqIT.mjs";
4
+ import { n as throwIfAborted, r as untilAborted, t as combineAborts } from "./signal-k7cm5N6h.mjs";
5
+ import { a as FieldSearchMatches, i as FieldRemappedValue, l as FieldValues, n as FieldBaseType, o as FieldSemanticType, t as Field } from "./field-CcN4oZy6.mjs";
6
+ import { a as TemporalUnit, r as ParameterValues } from "./parameter-Celg0wZa.mjs";
7
+ import { a as CardQueryResult, l as DatasetQuery, s as CardType, t as Card } from "./card-voh1k4hl.mjs";
8
+ import { c as TableVisibilityType, i as TableForeignKey, o as TableQueryMetadata, r as TableDataLayerTier, t as Table } from "./table-DfuY0N8e.mjs";
9
+ import { t as Database } from "./database-JtHTqSpq.mjs";
10
+ import { t as Snippet } from "./snippet-CyKAgIZl.mjs";
11
+ import { c as CollectionItem, i as CollectionAuthorityLevel, m as CollectionTreeNode, r as Collection, s as CollectionId } from "./collection-BxdPxD38.mjs";
12
+ import { t as ContentTranslationUploadResult } from "./content-translation-BrHOrmj9.mjs";
13
+ import { a as DashboardDetail, c as Dashcard, r as DashboardCopy, t as Dashboard } from "./dashboard-D0hwTC-f.mjs";
14
+ import { r as pollUntil } from "./poll-CZeXepUQ.mjs";
15
+ import { t as Document } from "./document-BHpLJbKU.mjs";
16
+ import { i as EidTranslateResult } from "./eid-translation-zEHtr5Oc.mjs";
17
+ import { c as SyncSettingsUpdateResult, i as SyncExportPreflight, n as SyncDirtyItem, p as isSyncTaskTerminal, s as SyncRemoteChanges, t as SyncBranchCreated, u as SyncTask } from "./git-sync-BwBRmEhE.mjs";
18
+ import { a as toLibrary, i as libraryWireSchema, n as LibraryCollectionInfo } from "./library-BPIzb3K_.mjs";
19
+ import { t as Measure } from "./measure-CtfjqJFP.mjs";
20
+ import { t as Pulse } from "./pulse-Dz0ocv0l.mjs";
21
+ import { a as TransformDagTransform, d as TransformTarget, g as transformRowSchema, h as transformDetailSchema, i as TransformDagRunResult, l as TransformRunSummary, m as isTransformRunTerminal, o as TransformRun, p as isTransformRunFailed, u as TransformSourceTableEntry } from "./transform-DiW7bREn.mjs";
22
+ import { r as SearchResult } from "./search-BAXg-EJw.mjs";
23
+ import { t as Segment } from "./segment-OsrbUDzw.mjs";
24
+ import { t as Setting } from "./setting-DTiLCW8g.mjs";
25
+ import { n as SetupResult } from "./setup-CO7QV-ao.mjs";
26
+ import { i as TimelineEvent, t as Timeline } from "./timeline-CCSU2qOS.mjs";
27
+ import { c as transformJobSchema, n as TransformJobActiveResult, s as transformJobRunResultSchema } from "./transform-job-CCguL6LP.mjs";
28
+ import { t as TransformTag } from "./transform-tag-CcElGp3C.mjs";
29
+ import { i as TransformTestRunResult, t as TransformTest } from "./transform-test-BjjCQ2xm.mjs";
30
+ import { t as UploadResult } from "./upload-DAtxBBms.mjs";
31
+ import { z } from "zod";
32
+ import { setTimeout } from "node:timers/promises";
33
+ //#region \0rolldown/runtime.js
34
+ var __defProp = Object.defineProperty;
35
+ var __exportAll = (all, no_symbols) => {
36
+ let target = {};
37
+ for (var name in all) __defProp(target, name, {
38
+ get: all[name],
39
+ enumerable: true
40
+ });
41
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
42
+ return target;
43
+ };
44
+ //#endregion
45
+ //#region ../client/src/http/response-shape.ts
46
+ async function parseJsonResponse(text, schema, context) {
47
+ try {
48
+ return parseJson(text, schema, { source: context.url });
49
+ } catch (error) {
50
+ if (error instanceof ValidationError) throw ResponseShapeError.fromZodIssues({
51
+ kind: "zod",
52
+ method: context.method,
53
+ url: context.url,
54
+ status: context.status,
55
+ zodIssues: error.developerDetail.zodIssues,
56
+ serverTag: await context.getServerTag(),
57
+ serverSkew: context.serverSkew
58
+ });
59
+ throw error;
60
+ }
61
+ }
62
+ //#endregion
63
+ //#region ../client/src/http/retry.ts
64
+ const BASE_DELAY_MS = 250;
65
+ const MAX_DELAY_MS = 8e3;
66
+ const MS_PER_SECOND = 1e3;
67
+ function backoffDelay({ attempt, retryAfterHeader }) {
68
+ const fromHeader = parseRetryAfter(retryAfterHeader);
69
+ if (fromHeader !== null) return fromHeader;
70
+ return Math.min(MAX_DELAY_MS, BASE_DELAY_MS * 2 ** attempt);
71
+ }
72
+ function parseRetryAfter(header) {
73
+ if (!header) return null;
74
+ const numeric = Number(header);
75
+ if (Number.isFinite(numeric) && numeric >= 0) return Math.round(numeric * MS_PER_SECOND);
76
+ const dateMs = Date.parse(header);
77
+ if (Number.isFinite(dateMs)) return Math.max(0, dateMs - Date.now());
78
+ return null;
79
+ }
80
+ function sleep(ms, signal) {
81
+ return setTimeout(ms, void 0, { signal });
82
+ }
83
+ async function runWithRetries(attempt, signal) {
84
+ let attemptIndex = 0;
85
+ while (true) {
86
+ const outcome = await attempt(attemptIndex);
87
+ if (outcome.kind === "success") return outcome.response;
88
+ await sleep(outcome.delayMs, signal);
89
+ attemptIndex += 1;
90
+ }
91
+ }
92
+ //#endregion
93
+ //#region ../client/src/http/transport.ts
94
+ const UNAUTHORIZED_STATUS = 401;
95
+ const DEFAULT_TIMEOUT_MS = 3e4;
96
+ const OCTET_STREAM_CONTENT_TYPE = "application/octet-stream";
97
+ const TEXT_CONTENT_TYPE_PREFIX = "text/";
98
+ const ERROR_BODY_BYTE_CAP = 64 * 1024;
99
+ const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
100
+ "GET",
101
+ "HEAD",
102
+ "OPTIONS"
103
+ ]);
104
+ function createTransport(config, options) {
105
+ const baseUrl = normalizeUrl(config.url);
106
+ assertCredentialHeaderSafe(config.credential);
107
+ const fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
108
+ let settledProfile = options.server ?? null;
109
+ const getServerTag = options.getServerTag ?? (async () => tagOf(settledProfile));
110
+ const serverSkew = () => settledProfile === null ? null : settledProfile.skew;
111
+ const refreshCredential = options.refreshCredential;
112
+ let credential = config.credential;
113
+ const knownSecrets = new Set(credentialSecrets(credential));
114
+ const redactionContext = { knownSecrets };
115
+ let refreshInFlight = null;
116
+ function tryRefreshCredential() {
117
+ const refresh = refreshCredential;
118
+ if (credential.kind !== "oauth" || refresh === void 0) return Promise.resolve(false);
119
+ refreshInFlight ??= refreshOnce(refresh).finally(() => {
120
+ refreshInFlight = null;
121
+ });
122
+ return refreshInFlight;
123
+ }
124
+ async function refreshOnce(refresh) {
125
+ const next = await refresh();
126
+ if (next === null) return false;
127
+ credential = next;
128
+ for (const secret of credentialSecrets(next)) knownSecrets.add(secret);
129
+ return true;
130
+ }
131
+ async function attemptOnce(prepared, attempt) {
132
+ const hasRetriesLeft = attempt < prepared.retries;
133
+ const timeoutSignal = AbortSignal.timeout(prepared.timeoutMs);
134
+ const combined = combineAborts(timeoutSignal, prepared.cancelSignal);
135
+ let response;
136
+ try {
137
+ response = await fetchImpl(prepared.url, {
138
+ method: prepared.method,
139
+ headers: prepared.headers,
140
+ body: prepared.body,
141
+ signal: combined
142
+ });
143
+ } catch (error) {
144
+ throwIfAborted(prepared.cancelSignal);
145
+ const isStaleSocketFirstTry = attempt === 0 && isConnectionClosed(error);
146
+ if (prepared.idempotent && (hasRetriesLeft || isStaleSocketFirstTry)) return {
147
+ kind: "retry",
148
+ delayMs: backoffDelay({ attempt })
149
+ };
150
+ if (timeoutSignal.aborted) throw new TimeoutError(`Request timed out after ${prepared.timeoutMs}ms`, {
151
+ kind: "http",
152
+ method: prepared.method,
153
+ url: prepared.url,
154
+ timeoutMs: prepared.timeoutMs
155
+ });
156
+ throw buildNetworkError(error, prepared.method, prepared.url);
157
+ }
158
+ const canRetryStatus = hasRetriesLeft && prepared.idempotent;
159
+ if (!response.ok && isRetryableStatus(response.status) && canRetryStatus) {
160
+ const retryAfter = response.headers.get("Retry-After");
161
+ response.body?.cancel().catch(() => void 0);
162
+ return {
163
+ kind: "retry",
164
+ delayMs: backoffDelay({
165
+ attempt,
166
+ retryAfterHeader: retryAfter
167
+ })
168
+ };
169
+ }
170
+ if (!response.ok) {
171
+ const rawBody = await readBodyForError(response);
172
+ const serverTag = await getServerTag();
173
+ throw new HttpError({
174
+ status: response.status,
175
+ statusText: response.statusText,
176
+ method: prepared.method,
177
+ url: prepared.url,
178
+ responseHeaders: response.headers,
179
+ rawBody,
180
+ serverTag,
181
+ redactionContext
182
+ });
183
+ }
184
+ assertContentType(response, prepared);
185
+ return {
186
+ kind: "success",
187
+ response
188
+ };
189
+ }
190
+ async function executeRaw(prepared) {
191
+ try {
192
+ return await runWithRetries((attempt) => attemptOnce(prepared, attempt), prepared.cancelSignal);
193
+ } catch (error) {
194
+ throwIfAborted(prepared.cancelSignal);
195
+ throw error;
196
+ }
197
+ }
198
+ async function executeWithAuthRefresh(path, opts) {
199
+ const prepared = prepare(path, opts);
200
+ try {
201
+ return {
202
+ response: await executeRaw(prepared),
203
+ prepared
204
+ };
205
+ } catch (error) {
206
+ if (error instanceof HttpError && error.status === UNAUTHORIZED_STATUS) {
207
+ if (await tryRefreshCredential()) {
208
+ const retried = prepare(path, opts);
209
+ return {
210
+ response: await executeRaw(retried),
211
+ prepared: retried
212
+ };
213
+ }
214
+ }
215
+ throw error;
216
+ }
217
+ }
218
+ function prepare(path, opts = {}) {
219
+ const method = opts.method ?? "GET";
220
+ const expectContentType = opts.expectContentType ?? "json";
221
+ const url = buildUrl(baseUrl, path, opts.query);
222
+ const headers = new Headers();
223
+ const auth = credentialAuthHeader(credential);
224
+ headers.set(auth.name, auth.value);
225
+ headers.set("accept", acceptHeader(expectContentType));
226
+ headers.set("user-agent", options.userAgent);
227
+ let body = null;
228
+ if (opts.body !== void 0 && opts.body !== null) if (typeof opts.body === "string" || opts.body instanceof URLSearchParams) body = opts.body;
229
+ else if (opts.body instanceof FormData || opts.body instanceof ReadableStream) body = opts.body;
230
+ else if (opts.body instanceof Uint8Array) {
231
+ body = opts.body;
232
+ headers.set("content-type", OCTET_STREAM_CONTENT_TYPE);
233
+ } else {
234
+ body = JSON.stringify(opts.body);
235
+ headers.set("content-type", JSON_CONTENT_TYPE);
236
+ }
237
+ return {
238
+ url,
239
+ method,
240
+ headers,
241
+ body,
242
+ expectContentType,
243
+ retries: opts.retries ?? 3,
244
+ idempotent: opts.idempotent ?? IDEMPOTENT_METHODS.has(method),
245
+ timeoutMs: opts.timeoutMs ?? DEFAULT_TIMEOUT_MS,
246
+ cancelSignal: combineAborts(opts.signal, options.signal)
247
+ };
248
+ }
249
+ let serverProfile = options.server === void 0 ? null : Promise.resolve(options.server);
250
+ async function server(wait = {}) {
251
+ throwIfAborted(wait.signal);
252
+ if (serverProfile === null) {
253
+ const probe = probeServer(transport).then((info) => {
254
+ settledProfile = createServerProfile(info);
255
+ return settledProfile;
256
+ });
257
+ probe.catch(() => {
258
+ serverProfile = null;
259
+ });
260
+ serverProfile = probe;
261
+ }
262
+ return untilAborted(serverProfile, wait.signal);
263
+ }
264
+ const enforceRequirements = options.enforceRequirements ?? true;
265
+ async function requireFeatures(features, wait = {}) {
266
+ if (!enforceRequirements || features.length === 0) return;
267
+ const failure = checkFeatures(features, await server(wait));
268
+ if (failure !== null) throw new CapabilityError(failure);
269
+ }
270
+ async function requireMethod(key, wait = {}) {
271
+ return requireFeatures(methodRequirements(key), wait);
272
+ }
273
+ const transport = {
274
+ server,
275
+ require: requireMethod,
276
+ requireFeatures,
277
+ async requestRaw(path, opts) {
278
+ return (await executeWithAuthRefresh(path, opts ?? {})).response;
279
+ },
280
+ async requestParsed(schema, path, opts) {
281
+ const { response, prepared } = await executeWithAuthRefresh(path, {
282
+ ...opts,
283
+ expectContentType: "json"
284
+ });
285
+ return parseJsonResponse(await response.text(), schema, {
286
+ method: prepared.method,
287
+ url: prepared.url,
288
+ status: response.status,
289
+ getServerTag,
290
+ serverSkew: serverSkew()
291
+ });
292
+ },
293
+ async requestStream(path, opts) {
294
+ const { response, prepared } = await executeWithAuthRefresh(path, {
295
+ ...opts,
296
+ expectContentType: opts?.expectContentType ?? "binary"
297
+ });
298
+ if (!response.body) throw new NetworkError("Response had no body to stream", {
299
+ method: prepared.method,
300
+ url: prepared.url,
301
+ cause: "missing body"
302
+ });
303
+ return response.body;
304
+ }
305
+ };
306
+ return transport;
307
+ }
308
+ function tagOf(profile) {
309
+ return profile === null ? null : profile.version.tag;
310
+ }
311
+ function buildUrl(baseUrl, path, query) {
312
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
313
+ const target = new URL(baseUrl + normalizedPath);
314
+ if (query) for (const [key, value] of Object.entries(query)) {
315
+ if (value === void 0) continue;
316
+ if (Array.isArray(value)) for (const entry of value) target.searchParams.append(key, String(entry));
317
+ else target.searchParams.append(key, String(value));
318
+ }
319
+ return target.toString();
320
+ }
321
+ function acceptHeader(expected) {
322
+ if (expected === "json") return JSON_CONTENT_TYPE;
323
+ if (expected === "text") return "text/*";
324
+ return "*/*";
325
+ }
326
+ function assertContentType(response, prepared) {
327
+ if (prepared.expectContentType === "binary") return;
328
+ const contentType = response.headers.get("content-type");
329
+ if (contentType === null) throwContentTypeMismatch(response, prepared, prepared.expectContentType);
330
+ if (prepared.expectContentType === "json" && !contentType.includes("application/json")) throwContentTypeMismatch(response, prepared, "json");
331
+ if (prepared.expectContentType === "text" && !contentType.startsWith(TEXT_CONTENT_TYPE_PREFIX)) throwContentTypeMismatch(response, prepared, "text");
332
+ }
333
+ function throwContentTypeMismatch(response, prepared, expected) {
334
+ const actual = response.headers.get("content-type") ?? "no content-type";
335
+ throw new HttpError({
336
+ status: response.status,
337
+ statusText: response.statusText,
338
+ method: prepared.method,
339
+ url: prepared.url,
340
+ responseHeaders: response.headers,
341
+ rawBody: null,
342
+ overrideUserMessage: `Expected ${expected} response but got ${actual}`
343
+ });
344
+ }
345
+ async function readBodyForError(response) {
346
+ try {
347
+ return Buffer.from(await response.arrayBuffer()).subarray(0, ERROR_BODY_BYTE_CAP).toString("utf8");
348
+ } catch (error) {
349
+ return `[body read failed: ${errorMessage(error)}]`;
350
+ }
351
+ }
352
+ //#endregion
353
+ //#region ../client/src/domain/dataset.ts
354
+ const CompiledQuery = z.object({
355
+ query: z.union([z.string(), z.array(z.unknown())]),
356
+ params: z.array(z.unknown()).nullable().optional(),
357
+ collection: z.string().optional()
358
+ }).loose();
359
+ const FieldRef = z.tuple([
360
+ z.literal("field"),
361
+ z.string(),
362
+ z.object({ "base-type": FieldBaseType }).loose()
363
+ ]);
364
+ const VirtualField = z.object({
365
+ id: z.union([z.number().int(), FieldRef]),
366
+ table_id: z.string(),
367
+ name: z.string(),
368
+ display_name: z.string(),
369
+ base_type: FieldBaseType,
370
+ semantic_type: FieldSemanticType.nullable(),
371
+ fk_target_field_id: z.number().int().nullable().optional()
372
+ }).loose();
373
+ const VirtualTable = z.object({
374
+ id: z.string(),
375
+ db_id: z.number().int(),
376
+ display_name: z.string(),
377
+ schema: z.string(),
378
+ description: z.string().nullable(),
379
+ type: CardType,
380
+ moderated_status: z.string().nullable(),
381
+ entity_id: z.string().nullable(),
382
+ fields: z.array(VirtualField)
383
+ }).loose();
384
+ const QueryMetadata = z.object({
385
+ databases: z.array(Database),
386
+ tables: z.array(z.union([TableQueryMetadata, VirtualTable])),
387
+ fields: z.array(Field),
388
+ snippets: z.array(Snippet)
389
+ }).loose();
390
+ //#endregion
391
+ //#region ../client/src/resources/card.ts
392
+ const CardApiList = z.array(Card);
393
+ function cardResource(transport) {
394
+ /** List cards. `f` picks a server-side preset; `model_id` scopes the presets that need an id. */
395
+ async function list(params = {}, options = {}) {
396
+ await transport.require("card.list", options);
397
+ return {
398
+ data: await transport.requestParsed(CardApiList, "/api/card", {
399
+ ...options,
400
+ query: {
401
+ f: params.f,
402
+ model_id: params.model_id
403
+ }
404
+ }),
405
+ total: null
406
+ };
407
+ }
408
+ /** Get one card by id. */
409
+ async function get(id, options = {}) {
410
+ await transport.require("card.get", options);
411
+ return transport.requestParsed(Card, `/api/card/${id}`, { ...options });
412
+ }
413
+ /** Create a card — a question, a model, or a metric — from a full card body. */
414
+ async function create(params, options = {}) {
415
+ await transport.require("card.create", options);
416
+ return transport.requestParsed(Card, "/api/card", {
417
+ ...options,
418
+ method: "POST",
419
+ body: params
420
+ });
421
+ }
422
+ /** Update a card by id, patching only the fields the body carries. */
423
+ async function update(id, params, options = {}) {
424
+ await transport.require("card.update", options);
425
+ return transport.requestParsed(Card, `/api/card/${id}`, {
426
+ ...options,
427
+ method: "PUT",
428
+ body: params
429
+ });
430
+ }
431
+ /** Archive (soft-delete) a card by id. Metabase models this as an update, not its own endpoint. */
432
+ async function archive(id, options = {}) {
433
+ await transport.require("card.archive", options);
434
+ return update(id, { archived: true }, options);
435
+ }
436
+ /** Run a saved card and return the query result envelope. */
437
+ async function query(id, params, options = {}) {
438
+ await transport.require("card.query", options);
439
+ return transport.requestParsed(CardQueryResult, `/api/card/${id}/query`, {
440
+ ...options,
441
+ method: "POST",
442
+ body: { parameters: params.parameters }
443
+ });
444
+ }
445
+ /**
446
+ * Run a saved card and stream its result as a download. Unlike `query`, this endpoint takes a
447
+ * form-encoded body and answers bytes, so a caller consumes the stream rather than a value.
448
+ */
449
+ async function exportQuery(id, format, params, options = {}) {
450
+ await transport.require("card.exportQuery", options);
451
+ const body = new URLSearchParams({
452
+ parameters: JSON.stringify(params.parameters),
453
+ format_rows: String(params.format_rows),
454
+ pivot_results: String(params.pivot_results)
455
+ });
456
+ return transport.requestStream(`/api/card/${id}/query/${format}`, {
457
+ ...options,
458
+ method: "POST",
459
+ body
460
+ });
461
+ }
462
+ /**
463
+ * Get all of the required query metadata for a saved card: the databases, tables, fields and
464
+ * snippets its query references, plus the card's own metadata for a model or a native query.
465
+ */
466
+ async function queryMetadata(id, options = {}) {
467
+ await transport.require("card.queryMetadata", options);
468
+ return transport.requestParsed(QueryMetadata, `/api/card/${id}/query_metadata`, { ...options });
469
+ }
470
+ return {
471
+ list,
472
+ get,
473
+ create,
474
+ update,
475
+ archive,
476
+ query,
477
+ exportQuery,
478
+ queryMetadata
479
+ };
480
+ }
481
+ async function* paginatePages(client, path, itemSchema, opts = {}) {
482
+ const envelopeSchema = paginatedEnvelopeSchema(itemSchema);
483
+ const pageSize = opts.pageSize ?? 50;
484
+ if (!Number.isInteger(pageSize) || pageSize < 1) throw new InternalError(`pageSize must be an integer of at least 1, got ${pageSize}`);
485
+ const start = opts.offset ?? 0;
486
+ const max = opts.max ?? Number.POSITIVE_INFINITY;
487
+ let taken = 0;
488
+ let previousHead = null;
489
+ while (taken < max) {
490
+ const remaining = max - taken;
491
+ const limit = Math.min(pageSize, remaining);
492
+ const offset = start + taken;
493
+ const envelope = await client.requestParsed(envelopeSchema, path, {
494
+ query: {
495
+ ...opts.query,
496
+ limit,
497
+ offset
498
+ },
499
+ ...opts.signal !== void 0 && { signal: opts.signal }
500
+ });
501
+ const items = envelope.data.length > remaining ? envelope.data.slice(0, remaining) : envelope.data;
502
+ const total = envelope.total ?? null;
503
+ const head = items.length === 0 ? null : JSON.stringify(items[0]);
504
+ if (head !== null && head === previousHead) throw new ConfigError(`the endpoint returned the same first row at offset ${offset} as at the previous offset; it is ignoring the offset parameter, so paging cannot advance`);
505
+ previousHead = head;
506
+ yield {
507
+ items,
508
+ total
509
+ };
510
+ if (items.length === 0) return;
511
+ const consumed = taken + items.length;
512
+ if (total !== null && start + consumed === total) return;
513
+ taken = consumed;
514
+ }
515
+ }
516
+ function paginatedEnvelopeSchema(itemSchema) {
517
+ return z.object({
518
+ data: z.array(itemSchema),
519
+ total: z.number().int().nonnegative().nullable().optional(),
520
+ limit: z.number().int().nonnegative().optional(),
521
+ offset: z.number().int().nonnegative().optional()
522
+ }).loose();
523
+ }
524
+ //#endregion
525
+ //#region ../client/src/resources/collection.ts
526
+ const CollectionApiList = z.array(Collection);
527
+ const CollectionTreeApiList = z.array(CollectionTreeNode);
528
+ const COLLECTION_LIST_QUERY = {
529
+ all: {},
530
+ archived: { archived: true },
531
+ personal: { "personal-only": true }
532
+ };
533
+ const DEFAULT_LIST_FILTER = "all";
534
+ function refPath(ref) {
535
+ return encodeURIComponent(ref);
536
+ }
537
+ /**
538
+ * List collections including the Library and its children, parsing each through the caller's own
539
+ * projection. `Collection` pins `type`, `namespace` and `authority_level` to closed enums, so a
540
+ * consumer reading a few fields off every collection on the instance narrows here: one collection
541
+ * carrying a server value outside those sets then costs nothing to a caller that never reads the
542
+ * field.
543
+ */
544
+ async function listCollectionsWithLibrary(transport, schema, options = {}) {
545
+ return transport.requestParsed(z.array(schema), "/api/collection", {
546
+ ...options,
547
+ query: { "include-library": true }
548
+ });
549
+ }
550
+ function collectionResource(transport) {
551
+ /** List collections. `filter` picks a server-side preset: everything, archived, or personal. */
552
+ async function list(params = {}, options = {}) {
553
+ await transport.require("collection.list", options);
554
+ return {
555
+ data: await transport.requestParsed(CollectionApiList, "/api/collection", {
556
+ ...options,
557
+ query: COLLECTION_LIST_QUERY[params.filter ?? DEFAULT_LIST_FILTER]
558
+ }),
559
+ total: null
560
+ };
561
+ }
562
+ /**
563
+ * List collections including the Library and its children, which the plain listing omits.
564
+ * The Library's own children carry neither `type` nor `is_remote_synced`, so this is where a
565
+ * caller resolves both.
566
+ */
567
+ async function listWithLibrary(options = {}) {
568
+ await transport.require("collection.listWithLibrary", options);
569
+ return {
570
+ data: await listCollectionsWithLibrary(transport, Collection, options),
571
+ total: null
572
+ };
573
+ }
574
+ /** Get one collection by id, entity id, or the `root`/`trash` alias. */
575
+ async function get(ref, options = {}) {
576
+ await transport.require("collection.get", options);
577
+ return transport.requestParsed(Collection, `/api/collection/${refPath(ref)}`, { ...options });
578
+ }
579
+ /** Create a new collection. */
580
+ async function create(params, options = {}) {
581
+ await transport.require("collection.create", options);
582
+ return transport.requestParsed(Collection, "/api/collection", {
583
+ ...options,
584
+ method: "POST",
585
+ body: params
586
+ });
587
+ }
588
+ /** Update a collection, patching only the fields the body carries. */
589
+ async function update(ref, params, options = {}) {
590
+ await transport.require("collection.update", options);
591
+ return transport.requestParsed(Collection, `/api/collection/${refPath(ref)}`, {
592
+ ...options,
593
+ method: "PUT",
594
+ body: params
595
+ });
596
+ }
597
+ /** Archive (soft-delete) a collection. Metabase models this as an update, not its own endpoint. */
598
+ async function archive(ref, options = {}) {
599
+ await transport.require("collection.archive", options);
600
+ return update(ref, { archived: true }, options);
601
+ }
602
+ /**
603
+ * Walk the items inside a collection one page at a time. This endpoint pages on the server, so
604
+ * the caller consumes pages rather than a single list and decides how far to pull.
605
+ */
606
+ async function* itemPages(ref, params = {}, options = {}) {
607
+ await transport.require("collection.itemPages", options);
608
+ yield* paginatePages(transport, `/api/collection/${refPath(ref)}/items`, CollectionItem, {
609
+ query: {
610
+ models: params.models,
611
+ archived: params.archived,
612
+ pinned_state: params.pinned_state
613
+ },
614
+ ...options.offset !== void 0 && { offset: options.offset },
615
+ ...options.max !== void 0 && { max: options.max },
616
+ ...options.pageSize !== void 0 && { pageSize: options.pageSize },
617
+ ...options.signal !== void 0 && { signal: options.signal }
618
+ });
619
+ }
620
+ /** Fetch the collection hierarchy as a forest of nested nodes. */
621
+ async function tree(options = {}) {
622
+ await transport.require("collection.tree", options);
623
+ return {
624
+ data: await transport.requestParsed(CollectionTreeApiList, "/api/collection/tree", { ...options }),
625
+ total: null
626
+ };
627
+ }
628
+ return {
629
+ list,
630
+ listWithLibrary,
631
+ get,
632
+ create,
633
+ update,
634
+ archive,
635
+ itemPages,
636
+ tree
637
+ };
638
+ }
639
+ //#endregion
640
+ //#region ../client/src/resources/csv-upload.ts
641
+ const CSV_CONTENT_TYPE = "text/csv";
642
+ function buildCsvFormData(file) {
643
+ const form = new FormData();
644
+ form.append("file", new Blob([file.bytes], { type: CSV_CONTENT_TYPE }), file.filename);
645
+ return form;
646
+ }
647
+ //#endregion
648
+ //#region ../client/src/resources/content-translation.ts
649
+ const CONTENT_TRANSLATION_PATH = "/api/ee/content-translation";
650
+ function contentTranslationResource(transport) {
651
+ /** Download the complete content translation dictionary as CSV. */
652
+ async function download(options = {}) {
653
+ await transport.require("contentTranslation.download", options);
654
+ return transport.requestStream(`${CONTENT_TRANSLATION_PATH}/csv`, options);
655
+ }
656
+ /** Replace the complete content translation dictionary with the attached CSV. */
657
+ async function upload(file, options = {}) {
658
+ await transport.require("contentTranslation.upload", options);
659
+ const form = buildCsvFormData(file);
660
+ return transport.requestParsed(ContentTranslationUploadResult, `${CONTENT_TRANSLATION_PATH}/upload-dictionary`, {
661
+ ...options,
662
+ method: "POST",
663
+ body: form
664
+ });
665
+ }
666
+ return {
667
+ download,
668
+ upload
669
+ };
670
+ }
671
+ //#endregion
672
+ //#region ../client/src/resources/dashboard.ts
673
+ const DashboardApiList = z.array(Dashboard);
674
+ const PreflightDashcard = z.looseObject({ card_id: z.number().int().nullable().optional() });
675
+ function dashboardResource(transport) {
676
+ const card = cardResource(transport);
677
+ /** List dashboards. `f` picks a server-side preset. */
678
+ async function list(params = {}, options = {}) {
679
+ await transport.require("dashboard.list", options);
680
+ return {
681
+ data: await transport.requestParsed(DashboardApiList, "/api/dashboard", {
682
+ ...options,
683
+ query: { f: params.f }
684
+ }),
685
+ total: null
686
+ };
687
+ }
688
+ /** Get one dashboard by id, with its dashcards, tabs and parameters. */
689
+ async function get(id, options = {}) {
690
+ await transport.require("dashboard.get", options);
691
+ return transport.requestParsed(DashboardDetail, `/api/dashboard/${id}`, { ...options });
692
+ }
693
+ /**
694
+ * Create a dashboard. The endpoint accepts no dashcards or tabs — a follow-up `update` is what
695
+ * puts content on a fresh dashboard.
696
+ */
697
+ async function create(params, options = {}) {
698
+ await transport.require("dashboard.create", options);
699
+ return transport.requestParsed(Dashboard, "/api/dashboard", {
700
+ ...options,
701
+ method: "POST",
702
+ body: params
703
+ });
704
+ }
705
+ /**
706
+ * Update a dashboard by id, patching only the fields the body carries. `dashcards` and `tabs` are
707
+ * full replacements: whatever the body omits is deleted from the dashboard.
708
+ */
709
+ async function update(id, params, options = {}) {
710
+ await transport.require("dashboard.update", options);
711
+ return transport.requestParsed(DashboardDetail, `/api/dashboard/${id}`, {
712
+ ...options,
713
+ method: "PUT",
714
+ body: params
715
+ });
716
+ }
717
+ /**
718
+ * Copy a dashboard, with its tabs and dashcards, into `collection_id` (root when absent). A deep
719
+ * copy duplicates the cards it can; otherwise the copy references them, except dashboard
720
+ * questions, which are always duplicated. Cards the caller cannot read are left behind and
721
+ * reported as `uncopied`.
722
+ */
723
+ async function copy(id, params = {}, options = {}) {
724
+ await transport.require("dashboard.copy", options);
725
+ return transport.requestParsed(DashboardCopy, `/api/dashboard/${id}/copy`, {
726
+ ...options,
727
+ method: "POST",
728
+ body: params
729
+ });
730
+ }
731
+ /**
732
+ * Archive (soft-delete) a dashboard by id. Metabase models this as an update, not its own
733
+ * endpoint. The answer is read as `Dashboard` rather than the `DashboardDetail` `update` returns:
734
+ * an archive is a state change on the dashboard itself, and its dashcards are not part of it.
735
+ */
736
+ async function archive(id, options = {}) {
737
+ await transport.require("dashboard.archive", options);
738
+ return transport.requestParsed(Dashboard, `/api/dashboard/${id}`, {
739
+ ...options,
740
+ method: "PUT",
741
+ body: { archived: true }
742
+ });
743
+ }
744
+ /**
745
+ * Patch one dashcard on a dashboard. Metabase exposes no dashcard endpoint and its dashboard PUT
746
+ * is a full replace of `dashcards`, so the patch is read-modify-written over the dashboard as it
747
+ * currently stands.
748
+ */
749
+ async function updateDashcard(dashboardId, dashcardId, params, options = {}) {
750
+ await transport.require("dashboard.updateDashcard", options);
751
+ const dashboard = await get(dashboardId, options);
752
+ const target = dashboard.dashcards.find((dashcard) => dashcard.id === dashcardId);
753
+ if (target === void 0) throw new ConfigError(`dashcard ${dashcardId} not found on dashboard ${dashboardId}`);
754
+ const patched = Dashcard.parse({
755
+ ...target,
756
+ ...params
757
+ });
758
+ const refreshed = (await update(dashboardId, { dashcards: dashboard.dashcards.map((dashcard) => stripEntityId(dashcard.id === dashcardId ? patched : dashcard)) }, options)).dashcards.find((dashcard) => dashcard.id === dashcardId);
759
+ if (refreshed === void 0) throw new Error(`PUT /api/dashboard/${dashboardId}: dashcard ${dashcardId} missing from response`);
760
+ return refreshed;
761
+ }
762
+ /**
763
+ * Check every card a `dashcards` body references before writing it, through `GET /api/card/{id}`
764
+ * once per distinct id. Reports one issue per reference whose card is missing, archived, or
765
+ * unreadable, so an empty result means the body is safe to send; an id the server answers for in
766
+ * any other way propagates as the failure it was.
767
+ */
768
+ async function checkCardReferences(dashcards, options = {}) {
769
+ await transport.require("dashboard.checkCardReferences", options);
770
+ const grouped = groupByCardId(collectCardReferences(dashcards));
771
+ return (await Promise.all(Array.from(grouped.entries()).map(async ([cardId, references]) => ({
772
+ references,
773
+ problem: await inspectCard(cardId, options)
774
+ })))).flatMap((check) => {
775
+ const problem = check.problem;
776
+ if (problem === null) return [];
777
+ return check.references.map((reference) => ({
778
+ ...reference,
779
+ problem
780
+ }));
781
+ });
782
+ }
783
+ async function inspectCard(cardId, options) {
784
+ try {
785
+ return (await card.get(cardId, options)).archived ? { reason: "archived" } : null;
786
+ } catch (error) {
787
+ if (!(error instanceof HttpError)) throw error;
788
+ if (error.kind === "resource-missing") return { reason: "missing" };
789
+ if (error.kind === "auth") return {
790
+ reason: "unreadable",
791
+ detail: error.userMessage
792
+ };
793
+ throw error;
794
+ }
795
+ }
796
+ /**
797
+ * Fetch the selectable values for a dashboard parameter, through the chain-filter value endpoint.
798
+ */
799
+ async function parameterValues(dashboardId, parameterId, options = {}) {
800
+ await transport.require("dashboard.parameterValues", options);
801
+ return transport.requestParsed(ParameterValues, `/api/dashboard/${dashboardId}/params/${encodeURIComponent(parameterId)}/values`, { ...options });
802
+ }
803
+ /**
804
+ * Search a dashboard parameter's selectable values: the server returns only values containing the
805
+ * substring, capped at the first 1000 matches.
806
+ */
807
+ async function searchParameterValues(dashboardId, parameterId, query, options = {}) {
808
+ await transport.require("dashboard.searchParameterValues", options);
809
+ const parameter = encodeURIComponent(parameterId);
810
+ return transport.requestParsed(ParameterValues, `/api/dashboard/${dashboardId}/params/${parameter}/search/${encodeURIComponent(query)}`, { ...options });
811
+ }
812
+ return {
813
+ list,
814
+ get,
815
+ create,
816
+ update,
817
+ archive,
818
+ copy,
819
+ updateDashcard,
820
+ checkCardReferences,
821
+ parameterValues,
822
+ searchParameterValues
823
+ };
824
+ }
825
+ function collectCardReferences(dashcards) {
826
+ if (dashcards === void 0 || dashcards === null) return [];
827
+ const references = [];
828
+ dashcards.forEach((dashcard, index) => {
829
+ const parsed = PreflightDashcard.safeParse(dashcard);
830
+ if (!parsed.success) return;
831
+ const cardId = parsed.data.card_id;
832
+ if (typeof cardId === "number" && cardId > 0) references.push({
833
+ cardId,
834
+ path: `/dashcards/${index}/card_id`
835
+ });
836
+ });
837
+ return references;
838
+ }
839
+ function groupByCardId(references) {
840
+ const grouped = /* @__PURE__ */ new Map();
841
+ for (const reference of references) {
842
+ const existing = grouped.get(reference.cardId);
843
+ if (existing === void 0) grouped.set(reference.cardId, [reference]);
844
+ else existing.push(reference);
845
+ }
846
+ return grouped;
847
+ }
848
+ function stripEntityId(dashcard) {
849
+ const { entity_id: _entity_id, id, size_x, size_y, row, col, ...rest } = dashcard;
850
+ return {
851
+ ...rest,
852
+ id,
853
+ size_x,
854
+ size_y,
855
+ row,
856
+ col
857
+ };
858
+ }
859
+ //#endregion
860
+ //#region ../client/src/resources/database.ts
861
+ const DatabaseApiList = z.object({
862
+ data: z.array(Database),
863
+ total: z.number().int().nonnegative()
864
+ }).loose();
865
+ const DatabaseTaskAck = z.object({ status: z.literal("ok") });
866
+ const DatabaseApiSchemaList = z.array(z.string());
867
+ const DatabaseApiSchemaTableList = z.array(Table);
868
+ const SYNC_COMPLETE = "complete";
869
+ function databaseResource(transport) {
870
+ /** List databases. `include` hydrates each database's tables; `saved` adds the Saved Questions virtual database. */
871
+ async function list(params = {}, options = {}) {
872
+ await transport.require("database.list", options);
873
+ const response = await transport.requestParsed(DatabaseApiList, "/api/database", {
874
+ ...options,
875
+ query: {
876
+ include: params.include,
877
+ saved: params.saved
878
+ }
879
+ });
880
+ return {
881
+ data: response.data,
882
+ total: response.total
883
+ };
884
+ }
885
+ /** Get one database by id. `include` hydrates its tables, and `tables.fields` their fields too. */
886
+ async function get(id, params = {}, options = {}) {
887
+ await transport.require("database.get", options);
888
+ return transport.requestParsed(Database, `/api/database/${id}`, {
889
+ ...options,
890
+ query: { include: params.include }
891
+ });
892
+ }
893
+ /** List the schema names in a database. */
894
+ async function schemas(id, options = {}) {
895
+ await transport.require("database.schemas", options);
896
+ return {
897
+ data: await transport.requestParsed(DatabaseApiSchemaList, `/api/database/${id}/schemas`, { ...options }),
898
+ total: null
899
+ };
900
+ }
901
+ /** List the tables one schema of a database holds. */
902
+ async function schemaTables(id, schema, options = {}) {
903
+ await transport.require("database.schemaTables", options);
904
+ return {
905
+ data: await transport.requestParsed(DatabaseApiSchemaTableList, `/api/database/${id}/schema/${encodeURIComponent(schema)}`, { ...options }),
906
+ total: null
907
+ };
908
+ }
909
+ /**
910
+ * Trigger a manual schema sync for a database. The endpoint queues the sync and returns at once;
911
+ * pass `wait` to poll the database until it reports its initial sync complete.
912
+ */
913
+ async function syncSchema(id, params = {}, options = {}) {
914
+ await transport.require("database.syncSchema", options);
915
+ const ack = await transport.requestParsed(DatabaseTaskAck, `/api/database/${id}/sync_schema`, {
916
+ ...options,
917
+ method: "POST"
918
+ });
919
+ const wait = params.wait;
920
+ if (wait === void 0) return {
921
+ id,
922
+ status: ack.status
923
+ };
924
+ const database = await pollUntil(async (signal) => transport.requestParsed(Database, `/api/database/${id}`, {
925
+ ...options,
926
+ signal
927
+ }), (candidate) => candidate.initial_sync_status === SYNC_COMPLETE, wait);
928
+ return {
929
+ id,
930
+ status: ack.status,
931
+ initial_sync_status: database.initial_sync_status ?? null
932
+ };
933
+ }
934
+ /** Trigger a rescan of the cached field values across a database. */
935
+ async function rescanValues(id, options = {}) {
936
+ await transport.require("database.rescanValues", options);
937
+ return {
938
+ id,
939
+ status: (await transport.requestParsed(DatabaseTaskAck, `/api/database/${id}/rescan_values`, {
940
+ ...options,
941
+ method: "POST"
942
+ })).status
943
+ };
944
+ }
945
+ return {
946
+ list,
947
+ get,
948
+ schemas,
949
+ schemaTables,
950
+ syncSchema,
951
+ rescanValues
952
+ };
953
+ }
954
+ //#endregion
955
+ //#region ../client/src/resources/dataset.ts
956
+ function datasetResource(transport) {
957
+ /**
958
+ * Run an ad-hoc query and return its result envelope. The body is a whole query — MBQL 5, legacy
959
+ * MBQL, or native — rather than a reference to a saved one, so nothing here is a card.
960
+ */
961
+ async function query(body, options = {}) {
962
+ await transport.require("dataset.query", options);
963
+ return transport.requestParsed(CardQueryResult, "/api/dataset", {
964
+ ...options,
965
+ method: "POST",
966
+ body
967
+ });
968
+ }
969
+ /**
970
+ * Fetch a native version of an MBQL query. `pretty` rides in the same body as the query and
971
+ * defaults server-side to true.
972
+ */
973
+ async function native(datasetQuery, params = {}, options = {}) {
974
+ await transport.require("dataset.native", options);
975
+ return transport.requestParsed(CompiledQuery, "/api/dataset/native", {
976
+ ...options,
977
+ method: "POST",
978
+ body: {
979
+ ...datasetQuery,
980
+ pretty: params.pretty
981
+ }
982
+ });
983
+ }
984
+ /**
985
+ * Get all of the required query metadata for an ad-hoc query: the databases, tables, fields and
986
+ * snippets it references. `{ settings: { "include-sensitive-fields": true } }` inside the query
987
+ * widens the field filter.
988
+ */
989
+ async function queryMetadata(datasetQuery, options = {}) {
990
+ await transport.require("dataset.queryMetadata", options);
991
+ return transport.requestParsed(QueryMetadata, "/api/dataset/query_metadata", {
992
+ ...options,
993
+ method: "POST",
994
+ body: datasetQuery
995
+ });
996
+ }
997
+ /**
998
+ * Run an ad-hoc query and stream its result as a download. Unlike `query`, this endpoint answers
999
+ * bytes, so a caller consumes the stream rather than a value.
1000
+ */
1001
+ async function exportQuery(format, params, options = {}) {
1002
+ await transport.require("dataset.exportQuery", options);
1003
+ return transport.requestStream(`/api/dataset/${format}`, {
1004
+ ...options,
1005
+ method: "POST",
1006
+ body: {
1007
+ query: params.query,
1008
+ format_rows: params.format_rows,
1009
+ pivot_results: params.pivot_results
1010
+ }
1011
+ });
1012
+ }
1013
+ return {
1014
+ query,
1015
+ native,
1016
+ queryMetadata,
1017
+ exportQuery
1018
+ };
1019
+ }
1020
+ //#endregion
1021
+ //#region ../client/src/domain/dependency.ts
1022
+ const DependencyType = z.enum([
1023
+ "table",
1024
+ "card",
1025
+ "snippet",
1026
+ "transform",
1027
+ "dashboard",
1028
+ "document",
1029
+ "sandbox",
1030
+ "segment",
1031
+ "measure"
1032
+ ]);
1033
+ const DependencyUsageType = z.enum([
1034
+ "table",
1035
+ "snippet",
1036
+ "transform",
1037
+ "dashboard",
1038
+ "document",
1039
+ "sandbox",
1040
+ "segment",
1041
+ "question",
1042
+ "model",
1043
+ "metric",
1044
+ "measure"
1045
+ ]);
1046
+ const DependencyFindingErrorType = z.enum([
1047
+ "missing-column",
1048
+ "missing-table-alias",
1049
+ "missing-table",
1050
+ "missing-card",
1051
+ "duplicate-column",
1052
+ "syntax-error",
1053
+ "validation-exception-error"
1054
+ ]);
1055
+ const DependencyErrorSourceType = z.enum([
1056
+ "table",
1057
+ "card",
1058
+ "transform"
1059
+ ]);
1060
+ z.enum([
1061
+ "name",
1062
+ "location",
1063
+ "view-count"
1064
+ ]);
1065
+ z.enum([
1066
+ "name",
1067
+ "location",
1068
+ "dependents-with-errors",
1069
+ "dependents-errors"
1070
+ ]);
1071
+ const DependencyCollectionRef = z.object({
1072
+ id: CollectionId,
1073
+ name: z.string(),
1074
+ authority_level: CollectionAuthorityLevel.nullable(),
1075
+ is_personal: z.boolean().optional()
1076
+ }).loose();
1077
+ const DependencyContainerRef = z.object({
1078
+ id: z.number().int(),
1079
+ name: z.string()
1080
+ }).loose();
1081
+ const DependencyEntityData = z.object({
1082
+ name: z.string().nullable().optional(),
1083
+ display_name: z.string().nullable().optional(),
1084
+ description: z.string().nullable().optional(),
1085
+ type: CardType.nullable().optional(),
1086
+ display: z.string().nullable().optional(),
1087
+ database_id: z.number().int().nullable().optional(),
1088
+ db_id: z.number().int().nullable().optional(),
1089
+ schema: z.string().nullable().optional(),
1090
+ collection_id: CollectionId.nullable().optional(),
1091
+ collection: DependencyCollectionRef.nullable().optional(),
1092
+ dashboard_id: z.number().int().nullable().optional(),
1093
+ dashboard: DependencyContainerRef.nullable().optional(),
1094
+ document_id: z.number().int().nullable().optional(),
1095
+ document: DependencyContainerRef.nullable().optional(),
1096
+ table_id: z.number().int().nullable().optional(),
1097
+ view_count: z.number().int().nullable().optional()
1098
+ }).loose();
1099
+ const DependencyEntity = z.object({
1100
+ id: z.number().int(),
1101
+ type: DependencyType,
1102
+ data: DependencyEntityData
1103
+ }).loose();
1104
+ const DependencyNode = DependencyEntity.extend({ dependents_count: z.partialRecord(DependencyUsageType, z.number().int()).nullable() });
1105
+ const DependencyFindingError = z.object({
1106
+ id: z.number().int(),
1107
+ analyzed_entity_type: DependencyType,
1108
+ analyzed_entity_id: z.number().int(),
1109
+ error_type: DependencyFindingErrorType,
1110
+ error_detail: z.string().nullable().optional(),
1111
+ source_entity_type: DependencyErrorSourceType.nullable().optional(),
1112
+ source_entity_id: z.number().int().nullable().optional()
1113
+ }).loose();
1114
+ const BreakingSource = DependencyNode.extend({ dependents_errors: z.array(DependencyFindingError).nullable().optional() });
1115
+ const DependencyEdge = z.object({
1116
+ from_entity_type: DependencyType,
1117
+ from_entity_id: z.number().int(),
1118
+ to_entity_type: DependencyType,
1119
+ to_entity_id: z.number().int()
1120
+ }).loose();
1121
+ const DependencyGraph = z.object({
1122
+ nodes: z.array(DependencyNode),
1123
+ edges: z.array(DependencyEdge)
1124
+ }).loose();
1125
+ //#endregion
1126
+ //#region ../client/src/resources/dependency.ts
1127
+ const DependencyNodeApiList = z.array(DependencyNode);
1128
+ const DependencyEntityApiList = z.array(DependencyEntity);
1129
+ const RENAMED_FILTERS = [
1130
+ "dependent-types",
1131
+ "dependent-card-types",
1132
+ "card-types",
1133
+ "include-personal-collections",
1134
+ "sort-column",
1135
+ "sort-direction"
1136
+ ];
1137
+ function filterFeatures(params) {
1138
+ return RENAMED_FILTERS.some((key) => params[key] !== void 0) ? ["dependencyKebabCaseFilters"] : [];
1139
+ }
1140
+ function dependencyResource(transport) {
1141
+ /**
1142
+ * The upstream dependency graph of one entity. `nodes` holds the starting entity plus every
1143
+ * entity it depends on, directly or transitively; each edge runs from the dependent to what it
1144
+ * depends on.
1145
+ */
1146
+ async function graph(type, id, options = {}) {
1147
+ await transport.require("dependency.graph", options);
1148
+ return transport.requestParsed(DependencyGraph, "/api/ee/dependencies/graph", {
1149
+ ...options,
1150
+ query: {
1151
+ type,
1152
+ id
1153
+ }
1154
+ });
1155
+ }
1156
+ /**
1157
+ * The entities that depend directly on one entity. `dependent-types` and `dependent-card-types`
1158
+ * narrow which kinds are listed, `broken` keeps only those whose query the entity has broken,
1159
+ * `query` matches against names and locations, `include-personal-collections` admits content in
1160
+ * personal collections, and `sort-column` / `sort-direction` order the result.
1161
+ */
1162
+ async function dependents(type, id, params = {}, options = {}) {
1163
+ await transport.require("dependency.dependents", options);
1164
+ await transport.requireFeatures(filterFeatures(params), options);
1165
+ return {
1166
+ data: await transport.requestParsed(DependencyNodeApiList, "/api/ee/dependencies/graph/dependents", {
1167
+ ...options,
1168
+ query: {
1169
+ type,
1170
+ id,
1171
+ "dependent-types": params["dependent-types"],
1172
+ "dependent-card-types": params["dependent-card-types"],
1173
+ broken: params.broken,
1174
+ query: params.query,
1175
+ "include-personal-collections": params["include-personal-collections"],
1176
+ "sort-column": params["sort-column"],
1177
+ "sort-direction": params["sort-direction"]
1178
+ }
1179
+ }),
1180
+ total: null
1181
+ };
1182
+ }
1183
+ /**
1184
+ * The dependents of one entity whose queries it has broken, as bare entities without a
1185
+ * dependents count. `dependent-types` and `dependent-card-types` narrow which kinds are listed,
1186
+ * `include-personal-collections` admits content in personal collections, and `sort-column` /
1187
+ * `sort-direction` order the result.
1188
+ */
1189
+ async function broken(type, id, params = {}, options = {}) {
1190
+ await transport.require("dependency.broken", options);
1191
+ await transport.requireFeatures(filterFeatures(params), options);
1192
+ return {
1193
+ data: await transport.requestParsed(DependencyEntityApiList, "/api/ee/dependencies/graph/broken", {
1194
+ ...options,
1195
+ query: {
1196
+ type,
1197
+ id,
1198
+ "dependent-types": params["dependent-types"],
1199
+ "dependent-card-types": params["dependent-card-types"],
1200
+ "include-personal-collections": params["include-personal-collections"],
1201
+ "sort-column": params["sort-column"],
1202
+ "sort-direction": params["sort-direction"]
1203
+ }
1204
+ }),
1205
+ total: null
1206
+ };
1207
+ }
1208
+ /**
1209
+ * Walk the entities nothing depends on, one page at a time. `types` and `card-types` narrow
1210
+ * which kinds are listed, `query` matches against names and locations,
1211
+ * `include-personal-collections` admits content in personal collections, and `sort-column` /
1212
+ * `sort-direction` order the result. This endpoint pages on the server, so the caller consumes
1213
+ * pages and decides how far to pull.
1214
+ */
1215
+ async function* unreferencedPages(params = {}, options = {}) {
1216
+ await transport.require("dependency.unreferencedPages", options);
1217
+ await transport.requireFeatures(filterFeatures(params), options);
1218
+ yield* paginatePages(transport, "/api/ee/dependencies/graph/unreferenced", DependencyNode, {
1219
+ query: itemListQuery(params),
1220
+ ...options.offset !== void 0 && { offset: options.offset },
1221
+ ...options.max !== void 0 && { max: options.max },
1222
+ ...options.pageSize !== void 0 && { pageSize: options.pageSize },
1223
+ ...options.signal !== void 0 && { signal: options.signal }
1224
+ });
1225
+ }
1226
+ /**
1227
+ * Walk the entities whose dependents carry analysis errors, one page at a time, each with the
1228
+ * `dependents_errors` rows found downstream of it. The server lists cards and tables unless
1229
+ * `types` says otherwise; `card-types`, `query`, `include-personal-collections`, `sort-column`
1230
+ * and `sort-direction` read as on `unreferencedPages`. This endpoint pages on the server, so the
1231
+ * caller consumes pages and decides how far to pull.
1232
+ */
1233
+ async function* breakingPages(params = {}, options = {}) {
1234
+ await transport.require("dependency.breakingPages", options);
1235
+ await transport.requireFeatures(filterFeatures(params), options);
1236
+ yield* paginatePages(transport, "/api/ee/dependencies/graph/breaking", BreakingSource, {
1237
+ query: itemListQuery(params),
1238
+ ...options.offset !== void 0 && { offset: options.offset },
1239
+ ...options.max !== void 0 && { max: options.max },
1240
+ ...options.pageSize !== void 0 && { pageSize: options.pageSize },
1241
+ ...options.signal !== void 0 && { signal: options.signal }
1242
+ });
1243
+ }
1244
+ return {
1245
+ graph,
1246
+ dependents,
1247
+ broken,
1248
+ unreferencedPages,
1249
+ breakingPages
1250
+ };
1251
+ }
1252
+ function itemListQuery(params) {
1253
+ return {
1254
+ types: params.types,
1255
+ "card-types": params["card-types"],
1256
+ query: params.query,
1257
+ "include-personal-collections": params["include-personal-collections"],
1258
+ "sort-column": params["sort-column"],
1259
+ "sort-direction": params["sort-direction"]
1260
+ };
1261
+ }
1262
+ //#endregion
1263
+ //#region ../client/src/resources/document.ts
1264
+ const DocumentApiList = z.object({ items: z.array(Document) }).loose();
1265
+ function documentResource(transport) {
1266
+ /** Get existing documents. */
1267
+ async function list(options = {}) {
1268
+ await transport.require("document.list", options);
1269
+ return {
1270
+ data: (await transport.requestParsed(DocumentApiList, "/api/document", { ...options })).items,
1271
+ total: null
1272
+ };
1273
+ }
1274
+ /** Return an existing document by id. */
1275
+ async function get(id, options = {}) {
1276
+ await transport.require("document.get", options);
1277
+ return transport.requestParsed(Document, `/api/document/${id}`, { ...options });
1278
+ }
1279
+ /** Create a new document. */
1280
+ async function create(params, options = {}) {
1281
+ await transport.require("document.create", options);
1282
+ return transport.requestParsed(Document, "/api/document", {
1283
+ ...options,
1284
+ method: "POST",
1285
+ body: params
1286
+ });
1287
+ }
1288
+ /** Update an existing document by id. */
1289
+ async function update(id, params, options = {}) {
1290
+ await transport.require("document.update", options);
1291
+ return transport.requestParsed(Document, `/api/document/${id}`, {
1292
+ ...options,
1293
+ method: "PUT",
1294
+ body: params
1295
+ });
1296
+ }
1297
+ /** Archive (soft-delete) a document by id. Metabase models this as an update, not its own endpoint. */
1298
+ async function archive(id, options = {}) {
1299
+ await transport.require("document.archive", options);
1300
+ return update(id, { archived: true }, options);
1301
+ }
1302
+ /**
1303
+ * Copy a document into `collection_id` (root when absent), duplicating the cards saved inside
1304
+ * it. An archived source is not found.
1305
+ */
1306
+ async function copy(id, params = {}, options = {}) {
1307
+ await transport.require("document.copy", options);
1308
+ return transport.requestParsed(Document, `/api/document/${id}/copy`, {
1309
+ ...options,
1310
+ method: "POST",
1311
+ body: params
1312
+ });
1313
+ }
1314
+ return {
1315
+ list,
1316
+ get,
1317
+ create,
1318
+ update,
1319
+ archive,
1320
+ copy
1321
+ };
1322
+ }
1323
+ //#endregion
1324
+ //#region ../client/src/resources/eid-translation.ts
1325
+ function eidTranslationResource(transport) {
1326
+ /**
1327
+ * Translate entity ids to the numeric ids of the rows they name. The request groups the entity
1328
+ * ids by model; the response is keyed by entity id, each entry carrying its model and — when the
1329
+ * lookup succeeded — the numeric id.
1330
+ */
1331
+ async function translate(params, options = {}) {
1332
+ await transport.require("eidTranslation.translate", options);
1333
+ return transport.requestParsed(EidTranslateResult, "/api/eid-translation/translate", {
1334
+ ...options,
1335
+ method: "POST",
1336
+ body: params
1337
+ });
1338
+ }
1339
+ return { translate };
1340
+ }
1341
+ //#endregion
1342
+ //#region ../client/src/domain/erd.ts
1343
+ const ErdField = z.object({
1344
+ id: z.number().int(),
1345
+ name: z.string(),
1346
+ display_name: z.string(),
1347
+ database_type: z.string(),
1348
+ base_type: FieldBaseType.nullable(),
1349
+ effective_type: FieldBaseType.nullable(),
1350
+ semantic_type: FieldSemanticType.nullable(),
1351
+ fk_target_field_id: z.number().int().nullable(),
1352
+ fk_target_table_id: z.number().int().nullable()
1353
+ }).loose();
1354
+ const ErdOwner = z.object({
1355
+ id: z.number().int().optional(),
1356
+ email: z.string(),
1357
+ first_name: z.string().nullable().optional(),
1358
+ last_name: z.string().nullable().optional()
1359
+ }).loose().nullable();
1360
+ const ErdNode = z.object({
1361
+ table_id: z.number().int(),
1362
+ name: z.string(),
1363
+ display_name: z.string(),
1364
+ description: z.string().nullable(),
1365
+ owner: ErdOwner,
1366
+ schema: z.string().nullable(),
1367
+ visibility_type: TableVisibilityType.nullable(),
1368
+ db_id: z.number().int(),
1369
+ fields: z.array(ErdField)
1370
+ }).loose();
1371
+ const ErdEdge = z.object({
1372
+ source_table_id: z.number().int(),
1373
+ source_field_id: z.number().int(),
1374
+ target_table_id: z.number().int(),
1375
+ target_field_id: z.number().int(),
1376
+ relationship: z.enum(["one-to-one", "many-to-one"])
1377
+ }).loose();
1378
+ const Erd = z.object({
1379
+ nodes: z.array(ErdNode),
1380
+ edges: z.array(ErdEdge)
1381
+ }).loose();
1382
+ //#endregion
1383
+ //#region ../client/src/resources/erd.ts
1384
+ const ERD_PATH = "/api/ee/erd";
1385
+ function erdResource(transport) {
1386
+ /**
1387
+ * Get the entity relationship diagram of a database: the readable tables as nodes, each with its
1388
+ * fields, and the foreign keys between them as edges. `table-ids` makes those tables the focal
1389
+ * points and draws their neighbours; `schema` keeps one schema, the empty string the tables with
1390
+ * none.
1391
+ */
1392
+ async function get(params, options = {}) {
1393
+ await transport.require("erd.get", options);
1394
+ return transport.requestParsed(Erd, ERD_PATH, {
1395
+ ...options,
1396
+ query: {
1397
+ "database-id": params["database-id"],
1398
+ "table-ids": params["table-ids"],
1399
+ schema: params.schema
1400
+ }
1401
+ });
1402
+ }
1403
+ return { get };
1404
+ }
1405
+ //#endregion
1406
+ //#region ../client/src/resources/optional-parsed.ts
1407
+ const NO_CONTENT_STATUS = 204;
1408
+ async function fetchOptionalParsed(client, path, schema, options = {}) {
1409
+ const response = await client.requestRaw(path, {
1410
+ ...options,
1411
+ method: "GET",
1412
+ expectContentType: "binary"
1413
+ });
1414
+ if (response.status === NO_CONTENT_STATUS) return null;
1415
+ return parseJsonOrPlain(await response.text(), response.headers.get("content-type"), schema, { source: response.url });
1416
+ }
1417
+ //#endregion
1418
+ //#region ../client/src/resources/field.ts
1419
+ const FieldApiSummary = z.tuple([z.tuple([z.literal("count"), z.number().int()]), z.tuple([z.literal("distincts"), z.number().int()])]);
1420
+ function fieldResource(transport) {
1421
+ /** Get one field by id. */
1422
+ async function get(id, options = {}) {
1423
+ await transport.require("field.get", options);
1424
+ return transport.requestParsed(Field, `/api/field/${id}`, { ...options });
1425
+ }
1426
+ /**
1427
+ * Update a field by id, patching only the fields the body carries. A `data_sensitivity` label is
1428
+ * a person's call the server's classifier never overwrites, and `null` withdraws it so the
1429
+ * classifier's own applies again; a server without the column would drop the key silently, so
1430
+ * the label is refused there before the wire.
1431
+ */
1432
+ async function update(id, params, options = {}) {
1433
+ await transport.require("field.update", options);
1434
+ await transport.requireFeatures(params.data_sensitivity === void 0 ? [] : ["fieldDataSensitivity"], options);
1435
+ return transport.requestParsed(Field, `/api/field/${id}`, {
1436
+ ...options,
1437
+ method: "PUT",
1438
+ body: params
1439
+ });
1440
+ }
1441
+ /**
1442
+ * Search the values of `searchId` that contain `value`, case-insensitively, answering the
1443
+ * matching values of `id` paired with them. An FK on either side is followed to the PK it
1444
+ * points at. Without `value`, the first `limit` values.
1445
+ */
1446
+ async function search(id, searchId, params, options = {}) {
1447
+ await transport.require("field.search", options);
1448
+ return transport.requestParsed(FieldSearchMatches, `/api/field/${id}/search/${searchId}`, {
1449
+ ...options,
1450
+ query: {
1451
+ value: params.value,
1452
+ limit: params.limit
1453
+ }
1454
+ });
1455
+ }
1456
+ /**
1457
+ * The value of `remappedId` on the one row where `id` equals `value`, as `[value, remapped]`,
1458
+ * or `null` when no row matches. `value` is parsed as a number for a numeric field.
1459
+ */
1460
+ async function remapping(id, remappedId, params, options = {}) {
1461
+ await transport.require("field.remapping", options);
1462
+ return fetchOptionalParsed(transport, `/api/field/${id}/remapping/${remappedId}`, FieldRemappedValue, {
1463
+ ...options,
1464
+ query: { value: params.value }
1465
+ });
1466
+ }
1467
+ /** Get the row count and the distinct-value count for a field. */
1468
+ async function summary(id, options = {}) {
1469
+ await transport.require("field.summary", options);
1470
+ const [[, count], [, distincts]] = await transport.requestParsed(FieldApiSummary, `/api/field/${id}/summary`, { ...options });
1471
+ return {
1472
+ field_id: id,
1473
+ count,
1474
+ distincts
1475
+ };
1476
+ }
1477
+ /** Get the cached distinct values Metabase holds for a field. */
1478
+ async function values(id, options = {}) {
1479
+ await transport.require("field.values", options);
1480
+ return transport.requestParsed(FieldValues, `/api/field/${id}/values`, { ...options });
1481
+ }
1482
+ return {
1483
+ get,
1484
+ update,
1485
+ search,
1486
+ remapping,
1487
+ summary,
1488
+ values
1489
+ };
1490
+ }
1491
+ //#endregion
1492
+ //#region ../client/src/resources/git-sync.ts
1493
+ const SyncScopeCollection = Collection.pick({
1494
+ id: true,
1495
+ name: true,
1496
+ is_remote_synced: true
1497
+ }).strip();
1498
+ const SyncDirtyFlag = z.object({ is_dirty: z.boolean() });
1499
+ const SyncDirtyList = z.object({ dirty: z.array(SyncDirtyItem) });
1500
+ const SyncBranchList = z.object({ items: z.array(z.string()) });
1501
+ const SyncImportStarted = z.object({
1502
+ status: z.literal("success"),
1503
+ task_id: z.number().int().positive().nullable(),
1504
+ message: z.string().nullable().optional()
1505
+ });
1506
+ const SyncExportStarted = z.object({
1507
+ message: z.string(),
1508
+ task_id: z.number().int().positive()
1509
+ });
1510
+ const SyncStashStarted = z.object({
1511
+ status: z.literal("success"),
1512
+ message: z.string(),
1513
+ task_id: z.number().int().positive()
1514
+ });
1515
+ const RemoteSyncSetting = z.string().nullable();
1516
+ const FORBIDDEN_STATUS = 403;
1517
+ const UNREGISTERED_STATUS = 404;
1518
+ function isRemoteUnreadable(error) {
1519
+ if (!(error instanceof HttpError)) return false;
1520
+ return error.status === FORBIDDEN_STATUS || error.status === UNREGISTERED_STATUS;
1521
+ }
1522
+ function gitSyncResource(transport) {
1523
+ /** Get the running or most recently finished sync task, or null when the server has none. */
1524
+ async function currentTask(options = {}) {
1525
+ await transport.require("gitSync.currentTask", options);
1526
+ return fetchOptionalParsed(transport, "/api/ee/remote-sync/current-task", SyncTask, options);
1527
+ }
1528
+ /** Request cancellation of the running sync task, and answer it in the state that left it. */
1529
+ async function cancelTask(options = {}) {
1530
+ await transport.require("gitSync.cancelTask", options);
1531
+ return transport.requestParsed(SyncTask, "/api/ee/remote-sync/current-task/cancel", {
1532
+ ...options,
1533
+ method: "POST"
1534
+ });
1535
+ }
1536
+ /** Whether Metabase holds content changes the remote has not been told about. */
1537
+ async function isDirty(options = {}) {
1538
+ await transport.require("gitSync.isDirty", options);
1539
+ return (await transport.requestParsed(SyncDirtyFlag, "/api/ee/remote-sync/is-dirty", { ...options })).is_dirty;
1540
+ }
1541
+ /** List the objects whose local state differs from the remote. */
1542
+ async function dirty(options = {}) {
1543
+ await transport.require("gitSync.dirty", options);
1544
+ return {
1545
+ data: (await transport.requestParsed(SyncDirtyList, "/api/ee/remote-sync/dirty", { ...options })).dirty,
1546
+ total: null
1547
+ };
1548
+ }
1549
+ /**
1550
+ * Compare the tracked remote branch against what Metabase last imported. The server caches the
1551
+ * comparison; `force-refresh` re-reads the remote instead.
1552
+ */
1553
+ async function hasRemoteChanges(params = {}, options = {}) {
1554
+ await transport.require("gitSync.hasRemoteChanges", options);
1555
+ return transport.requestParsed(SyncRemoteChanges, "/api/ee/remote-sync/has-remote-changes", {
1556
+ ...options,
1557
+ query: { "force-refresh": params["force-refresh"] }
1558
+ });
1559
+ }
1560
+ /**
1561
+ * Import content from the remote into Metabase. The endpoint queues a task and returns at once;
1562
+ * pass `wait` to poll that task until it reaches a terminal status. A server already up to date
1563
+ * answers no task id, and there is then nothing to poll.
1564
+ */
1565
+ async function importFromRemote(params = {}, options = {}) {
1566
+ await transport.require("gitSync.import", options);
1567
+ const started = await transport.requestParsed(SyncImportStarted, "/api/ee/remote-sync/import", {
1568
+ ...options,
1569
+ method: "POST",
1570
+ body: {
1571
+ branch: params.branch,
1572
+ force: params.force
1573
+ }
1574
+ });
1575
+ const message = started.message ?? null;
1576
+ if (params.wait === void 0 || started.task_id === null) return {
1577
+ message,
1578
+ task_id: started.task_id
1579
+ };
1580
+ return {
1581
+ message,
1582
+ task_id: started.task_id,
1583
+ final: await settle(params.wait, options)
1584
+ };
1585
+ }
1586
+ /**
1587
+ * Export Metabase's content to the remote. The endpoint queues a task and returns at once; pass
1588
+ * `wait` to poll that task until it reaches a terminal status.
1589
+ */
1590
+ async function exportToRemote(params = {}, options = {}) {
1591
+ await transport.require("gitSync.export", options);
1592
+ const started = await transport.requestParsed(SyncExportStarted, "/api/ee/remote-sync/export", {
1593
+ ...options,
1594
+ method: "POST",
1595
+ body: {
1596
+ branch: params.branch,
1597
+ message: params.message,
1598
+ force: params.force
1599
+ }
1600
+ });
1601
+ if (params.wait === void 0) return {
1602
+ message: started.message,
1603
+ task_id: started.task_id
1604
+ };
1605
+ return {
1606
+ message: started.message,
1607
+ task_id: started.task_id,
1608
+ final: await settle(params.wait, options)
1609
+ };
1610
+ }
1611
+ /**
1612
+ * Preview what exporting to `branch` would do against the live remote, without writing: whether
1613
+ * the remote has moved on, whether a merge would apply cleanly, which entities conflict, and what
1614
+ * a force push would discard. `branch` must be the one git-sync tracks; the server answers 409
1615
+ * otherwise.
1616
+ */
1617
+ async function exportPreflight(params, options = {}) {
1618
+ await transport.require("gitSync.exportPreflight", options);
1619
+ return transport.requestParsed(SyncExportPreflight, "/api/ee/remote-sync/export-preflight", {
1620
+ ...options,
1621
+ query: { branch: params.branch }
1622
+ });
1623
+ }
1624
+ /**
1625
+ * Export Metabase's current content to a branch the remote does not have yet. The endpoint
1626
+ * queues a task and returns at once; pass `wait` to poll that task to a terminal status.
1627
+ */
1628
+ async function stash(params, options = {}) {
1629
+ await transport.require("gitSync.stash", options);
1630
+ const started = await transport.requestParsed(SyncStashStarted, "/api/ee/remote-sync/stash", {
1631
+ ...options,
1632
+ method: "POST",
1633
+ body: {
1634
+ new_branch: params.new_branch,
1635
+ message: params.message
1636
+ }
1637
+ });
1638
+ if (params.wait === void 0) return {
1639
+ status: started.status,
1640
+ message: started.message,
1641
+ task_id: started.task_id
1642
+ };
1643
+ return {
1644
+ status: started.status,
1645
+ message: started.message,
1646
+ task_id: started.task_id,
1647
+ final: await settle(params.wait, options)
1648
+ };
1649
+ }
1650
+ /** List the branches the configured remote carries. */
1651
+ async function branches(options = {}) {
1652
+ await transport.require("gitSync.branches", options);
1653
+ return {
1654
+ data: (await transport.requestParsed(SyncBranchList, "/api/ee/remote-sync/branches", { ...options })).items,
1655
+ total: null
1656
+ };
1657
+ }
1658
+ /** Create a branch on the remote and point git-sync at it. */
1659
+ async function createBranch(params, options = {}) {
1660
+ await transport.require("gitSync.createBranch", options);
1661
+ return transport.requestParsed(SyncBranchCreated, "/api/ee/remote-sync/create-branch", {
1662
+ ...options,
1663
+ method: "POST",
1664
+ body: { name: params.name }
1665
+ });
1666
+ }
1667
+ /**
1668
+ * Mark one collection as git-synced, or unmark it. The server cascades the flag to descendants
1669
+ * by location prefix, and may queue an export task to carry the change to the remote.
1670
+ */
1671
+ async function setCollectionSynced(collectionId, synced, options = {}) {
1672
+ await transport.require("gitSync.setCollectionSynced", options);
1673
+ return transport.requestParsed(SyncSettingsUpdateResult, "/api/ee/remote-sync/settings", {
1674
+ ...options,
1675
+ method: "PUT",
1676
+ body: { collections: { [collectionId]: synced } }
1677
+ });
1678
+ }
1679
+ /** The collections currently in git-sync's scope. */
1680
+ async function syncedCollections(options = {}) {
1681
+ await transport.require("gitSync.syncedCollections", options);
1682
+ return {
1683
+ data: (await listCollectionsWithLibrary(transport, SyncScopeCollection, options)).filter((entry) => entry.is_remote_synced === true),
1684
+ total: null
1685
+ };
1686
+ }
1687
+ /** The remote's URL, or null when none is configured or the caller may not read it. */
1688
+ async function remoteUrl(options = {}) {
1689
+ await transport.require("gitSync.remoteUrl", options);
1690
+ try {
1691
+ const url = await fetchOptionalParsed(transport, "/api/setting/remote-sync-url", RemoteSyncSetting, options);
1692
+ return url === "" ? null : url;
1693
+ } catch (error) {
1694
+ if (isRemoteUnreadable(error)) return null;
1695
+ throw error;
1696
+ }
1697
+ }
1698
+ /**
1699
+ * The branch git-sync tracks, or null when none is configured, the caller may not read it, or
1700
+ * the server has no remote-sync module.
1701
+ */
1702
+ async function branch(options = {}) {
1703
+ await transport.require("gitSync.branch", options);
1704
+ try {
1705
+ return await fetchOptionalParsed(transport, "/api/setting/remote-sync-branch", RemoteSyncSetting, options);
1706
+ } catch (error) {
1707
+ if (isRemoteUnreadable(error)) return null;
1708
+ throw error;
1709
+ }
1710
+ }
1711
+ /**
1712
+ * Poll the current task until it reaches a terminal status. A server with no task at all
1713
+ * answers null, which is terminal in the same sense: nothing further will happen.
1714
+ */
1715
+ async function waitForTask(wait, options = {}) {
1716
+ await transport.require("gitSync.waitForTask", options);
1717
+ return settle(wait, options);
1718
+ }
1719
+ async function settle(wait, options) {
1720
+ return pollUntil(async (signal) => currentTask({
1721
+ ...options,
1722
+ signal
1723
+ }), (task) => task === null || isSyncTaskTerminal(task.status), wait);
1724
+ }
1725
+ return {
1726
+ currentTask,
1727
+ cancelTask,
1728
+ isDirty,
1729
+ dirty,
1730
+ hasRemoteChanges,
1731
+ import: importFromRemote,
1732
+ export: exportToRemote,
1733
+ exportPreflight,
1734
+ stash,
1735
+ branches,
1736
+ createBranch,
1737
+ setCollectionSynced,
1738
+ syncedCollections,
1739
+ remoteUrl,
1740
+ branch,
1741
+ waitForTask
1742
+ };
1743
+ }
1744
+ //#endregion
1745
+ //#region ../client/src/domain/glossary.ts
1746
+ const GlossaryCreator = z.object({
1747
+ id: z.number().int(),
1748
+ email: z.string(),
1749
+ first_name: z.string().nullable(),
1750
+ last_name: z.string().nullable()
1751
+ }).loose();
1752
+ const Glossary = z.object({
1753
+ id: z.number().int(),
1754
+ term: z.string(),
1755
+ definition: z.string(),
1756
+ creator_id: z.number().int(),
1757
+ creator: GlossaryCreator,
1758
+ created_at: z.string(),
1759
+ updated_at: z.string()
1760
+ }).loose();
1761
+ Glossary.pick({
1762
+ id: true,
1763
+ term: true,
1764
+ definition: true
1765
+ }).strip();
1766
+ z.object({
1767
+ term: z.string().min(1),
1768
+ definition: z.string().min(1)
1769
+ }).strict();
1770
+ //#endregion
1771
+ //#region ../client/src/resources/glossary.ts
1772
+ const GlossaryApiList = z.object({ data: z.array(Glossary) }).loose();
1773
+ function glossaryResource(transport) {
1774
+ /**
1775
+ * List glossary entries in term order. `search` keeps the entries whose term or definition
1776
+ * contains it, case-insensitively.
1777
+ */
1778
+ async function list(params = {}, options = {}) {
1779
+ await transport.require("glossary.list", options);
1780
+ return {
1781
+ data: (await transport.requestParsed(GlossaryApiList, "/api/glossary", {
1782
+ ...options,
1783
+ query: { search: params.search }
1784
+ })).data,
1785
+ total: null
1786
+ };
1787
+ }
1788
+ /** Create a glossary entry, a term and its definition. Terms are unique. */
1789
+ async function create(params, options = {}) {
1790
+ await transport.require("glossary.create", options);
1791
+ return transport.requestParsed(Glossary, "/api/glossary", {
1792
+ ...options,
1793
+ method: "POST",
1794
+ body: params
1795
+ });
1796
+ }
1797
+ /** Replace the term and definition of a glossary entry by id. */
1798
+ async function update(id, params, options = {}) {
1799
+ await transport.require("glossary.update", options);
1800
+ return transport.requestParsed(Glossary, `/api/glossary/${id}`, {
1801
+ ...options,
1802
+ method: "PUT",
1803
+ body: params
1804
+ });
1805
+ }
1806
+ /** Delete a glossary entry by id. */
1807
+ async function remove(id, options = {}) {
1808
+ await transport.require("glossary.delete", options);
1809
+ await transport.requestRaw(`/api/glossary/${id}`, {
1810
+ ...options,
1811
+ method: "DELETE",
1812
+ expectContentType: "binary"
1813
+ });
1814
+ }
1815
+ return {
1816
+ list,
1817
+ create,
1818
+ update,
1819
+ delete: remove
1820
+ };
1821
+ }
1822
+ //#endregion
1823
+ //#region ../client/src/resources/library.ts
1824
+ const LIBRARY_ROOT_PATH = "/api/ee/library/";
1825
+ const PUBLISH_TABLES_PATH = "/api/ee/data-studio/table/publish-tables";
1826
+ const UNPUBLISH_TABLES_PATH = "/api/ee/data-studio/table/unpublish-tables";
1827
+ const LIBRARY_DATA_TYPE = "library-data";
1828
+ const PublishTablesResponse = z.object({ target_collection: Collection.nullable() });
1829
+ function libraryResource(transport) {
1830
+ /** Get the Library root and its child collections, or `null` on an instance that has none. */
1831
+ async function get(options = {}) {
1832
+ await transport.require("library.get", options);
1833
+ const { features } = await transport.server(options);
1834
+ const wire = await transport.requestParsed(libraryWireSchema(features), LIBRARY_ROOT_PATH, { ...options });
1835
+ if (wire === null) return null;
1836
+ return toLibrary(wire, await libraryListing(options));
1837
+ }
1838
+ async function libraryListing(options) {
1839
+ const data = await listCollectionsWithLibrary(transport, LibraryCollectionInfo, options);
1840
+ const byId = /* @__PURE__ */ new Map();
1841
+ for (const collection of data) if (typeof collection.id === "number") byId.set(collection.id, collection);
1842
+ return byId;
1843
+ }
1844
+ /**
1845
+ * Create the Library subtree (its Data and Metrics collections). Metabase takes no body, rejects
1846
+ * a second create with a 400, and answers the bare root collection without its
1847
+ * `effective_children` — so an existing Library short-circuits the call and a fresh one comes
1848
+ * back from a refetch, which together make this idempotent.
1849
+ */
1850
+ async function create(options = {}) {
1851
+ await transport.require("library.create", options);
1852
+ const existing = await get(options);
1853
+ if (existing !== null) return existing;
1854
+ await transport.requestRaw(LIBRARY_ROOT_PATH, {
1855
+ ...options,
1856
+ method: "POST"
1857
+ });
1858
+ const created = await get(options);
1859
+ if (created === null) throw new Error(`Library was not created after POST ${LIBRARY_ROOT_PATH}`);
1860
+ return created;
1861
+ }
1862
+ /** The id of the Library's Data collection, creating the Library first when it does not exist. */
1863
+ async function ensureDataCollectionId(options = {}) {
1864
+ await transport.require("library.ensureDataCollectionId", options);
1865
+ const data = (await create(options)).effective_children.find((child) => child.type === LIBRARY_DATA_TYPE);
1866
+ if (data === void 0) throw new Error("Library has no Data collection to publish into");
1867
+ if (typeof data.id !== "number") throw new Error(`Library Data collection has a non-numeric id ${String(data.id)}`);
1868
+ return data.id;
1869
+ }
1870
+ /**
1871
+ * Publish tables — and every upstream table they depend on — into a collection, so they lead the
1872
+ * data pickers and rank up in search. Answers the collection they landed in.
1873
+ */
1874
+ async function publishTables(params, options = {}) {
1875
+ await transport.require("library.publishTables", options);
1876
+ return (await transport.requestParsed(PublishTablesResponse, PUBLISH_TABLES_PATH, {
1877
+ ...options,
1878
+ method: "POST",
1879
+ body: params
1880
+ })).target_collection;
1881
+ }
1882
+ /**
1883
+ * Clear the Library collection from tables, and recursively from every downstream table that
1884
+ * depends on them. The endpoint answers no JSON body.
1885
+ */
1886
+ async function unpublishTables(params, options = {}) {
1887
+ await transport.require("library.unpublishTables", options);
1888
+ await transport.requestRaw(UNPUBLISH_TABLES_PATH, {
1889
+ ...options,
1890
+ method: "POST",
1891
+ body: params,
1892
+ expectContentType: "binary"
1893
+ });
1894
+ }
1895
+ return {
1896
+ get,
1897
+ create,
1898
+ ensureDataCollectionId,
1899
+ publishTables,
1900
+ unpublishTables
1901
+ };
1902
+ }
1903
+ //#endregion
1904
+ //#region ../client/src/resources/measure.ts
1905
+ const MeasureApiList = z.array(Measure);
1906
+ function measureResource(transport) {
1907
+ /** List measures. */
1908
+ async function list(options = {}) {
1909
+ await transport.require("measure.list", options);
1910
+ return {
1911
+ data: await transport.requestParsed(MeasureApiList, "/api/measure", { ...options }),
1912
+ total: null
1913
+ };
1914
+ }
1915
+ /** Get one measure by id. */
1916
+ async function get(id, options = {}) {
1917
+ await transport.require("measure.get", options);
1918
+ return transport.requestParsed(Measure, `/api/measure/${id}`, { ...options });
1919
+ }
1920
+ /** Create a measure — a saved aggregation tied to a table — from a full measure body. */
1921
+ async function create(params, options = {}) {
1922
+ await transport.require("measure.create", options);
1923
+ return transport.requestParsed(Measure, "/api/measure", {
1924
+ ...options,
1925
+ method: "POST",
1926
+ body: params
1927
+ });
1928
+ }
1929
+ /**
1930
+ * Update a measure by id, patching only the fields the body carries. `revision_message` is
1931
+ * required and lands in the audit log.
1932
+ */
1933
+ async function update(id, params, options = {}) {
1934
+ await transport.require("measure.update", options);
1935
+ return transport.requestParsed(Measure, `/api/measure/${id}`, {
1936
+ ...options,
1937
+ method: "PUT",
1938
+ body: params
1939
+ });
1940
+ }
1941
+ /**
1942
+ * Archive (soft-delete) a measure by id. Metabase models this as an update, not its own endpoint,
1943
+ * so it carries the same required `revision_message`.
1944
+ */
1945
+ async function archive(id, params, options = {}) {
1946
+ await transport.require("measure.archive", options);
1947
+ return update(id, {
1948
+ archived: true,
1949
+ revision_message: params.revision_message
1950
+ }, options);
1951
+ }
1952
+ return {
1953
+ list,
1954
+ get,
1955
+ create,
1956
+ update,
1957
+ archive
1958
+ };
1959
+ }
1960
+ //#endregion
1961
+ //#region ../client/src/domain/metric.ts
1962
+ const ClauseOptions = z.object({}).loose();
1963
+ const MetricLeafType = z.enum(["metric", "measure"]);
1964
+ const MetricLeafRef = z.tuple([
1965
+ MetricLeafType,
1966
+ z.object({ "lib/uuid": z.string().min(1) }).strict(),
1967
+ z.number().int().positive()
1968
+ ]);
1969
+ const MetricMathOperator = z.enum([
1970
+ "+",
1971
+ "-",
1972
+ "*",
1973
+ "/"
1974
+ ]);
1975
+ const MetricMathExpression = z.lazy(() => z.union([
1976
+ MetricLeafRef,
1977
+ z.number(),
1978
+ z.tuple([
1979
+ MetricMathOperator,
1980
+ ClauseOptions,
1981
+ MetricMathExpression,
1982
+ MetricMathExpression
1983
+ ]).rest(MetricMathExpression)
1984
+ ]));
1985
+ const MetricBinning = z.discriminatedUnion("strategy", [
1986
+ z.object({ strategy: z.literal("default") }).strict(),
1987
+ z.object({
1988
+ strategy: z.literal("bin-width"),
1989
+ "bin-width": z.number().positive()
1990
+ }).strict(),
1991
+ z.object({
1992
+ strategy: z.literal("num-bins"),
1993
+ "num-bins": z.number().int().positive()
1994
+ }).strict()
1995
+ ]);
1996
+ const MetricDimensionRefOptions = z.object({
1997
+ "lib/uuid": z.string().min(1).optional(),
1998
+ "display-name": z.string().min(1).nullable().optional(),
1999
+ "effective-type": FieldBaseType.nullable().optional(),
2000
+ "semantic-type": FieldSemanticType.nullable().optional(),
2001
+ "temporal-unit": TemporalUnit.nullable().optional(),
2002
+ binning: MetricBinning.nullable().optional()
2003
+ }).strict();
2004
+ const MetricDimensionRef = z.tuple([
2005
+ z.literal("dimension"),
2006
+ MetricDimensionRefOptions,
2007
+ z.string().min(1)
2008
+ ]);
2009
+ const MetricFilterArgument = z.lazy(() => z.union([
2010
+ MetricDimensionRef,
2011
+ MetricFilterClause,
2012
+ z.string(),
2013
+ z.number(),
2014
+ z.boolean(),
2015
+ z.null()
2016
+ ]));
2017
+ const MetricFilterClause = z.lazy(() => z.tuple([z.string().min(1), ClauseOptions]).rest(MetricFilterArgument));
2018
+ const MetricInstanceFilter = z.object({
2019
+ "lib/uuid": z.string().min(1),
2020
+ filter: MetricFilterClause
2021
+ }).strict();
2022
+ const MetricProjection = z.object({
2023
+ type: MetricLeafType,
2024
+ id: z.number().int().positive(),
2025
+ "lib/uuid": z.string().min(1),
2026
+ projection: z.array(MetricDimensionRef)
2027
+ }).strict();
2028
+ z.object({
2029
+ expression: MetricMathExpression,
2030
+ filters: z.array(MetricInstanceFilter).nullable().optional(),
2031
+ projections: z.array(MetricProjection).nullable().optional()
2032
+ }).strict();
2033
+ const MetricBreakoutColumn = z.object({
2034
+ name: z.string().optional(),
2035
+ display_name: z.string().optional(),
2036
+ base_type: FieldBaseType.optional(),
2037
+ effective_type: FieldBaseType.optional(),
2038
+ semantic_type: FieldSemanticType.nullable().optional()
2039
+ }).loose();
2040
+ const MetricBreakoutValues = z.object({
2041
+ values: z.array(z.unknown()),
2042
+ col: MetricBreakoutColumn
2043
+ }).loose();
2044
+ const MetricDimensionStatus = z.enum(["status/active", "status/orphaned"]);
2045
+ const MetricDimensionSource = z.object({
2046
+ type: z.literal("field"),
2047
+ "field-id": z.number().int().nullable()
2048
+ }).loose();
2049
+ const MetricDimensionGroup = z.object({
2050
+ id: z.string(),
2051
+ type: z.enum(["main", "connection"]),
2052
+ display_name: z.string()
2053
+ }).loose();
2054
+ const MetricDimension = z.object({
2055
+ id: z.string(),
2056
+ name: z.string().nullable(),
2057
+ display_name: z.string().nullable(),
2058
+ description: z.string().nullable().optional(),
2059
+ effective_type: FieldBaseType.nullable(),
2060
+ semantic_type: FieldSemanticType.nullable(),
2061
+ has_field_values: z.enum([
2062
+ "list",
2063
+ "search",
2064
+ "none"
2065
+ ]).optional(),
2066
+ status: MetricDimensionStatus.optional(),
2067
+ status_message: z.string().optional(),
2068
+ sources: z.array(MetricDimensionSource).optional(),
2069
+ group: MetricDimensionGroup.optional(),
2070
+ dimension_interestingness: z.number().optional(),
2071
+ default_temporal_unit: TemporalUnit.optional(),
2072
+ default: z.boolean().nullable().optional()
2073
+ }).loose();
2074
+ MetricDimension.pick({
2075
+ id: true,
2076
+ name: true,
2077
+ display_name: true,
2078
+ description: true,
2079
+ effective_type: true,
2080
+ semantic_type: true,
2081
+ status: true,
2082
+ group: true,
2083
+ default: true
2084
+ }).strip();
2085
+ const MetricMappingTarget = z.tuple([z.string(), ClauseOptions]).rest(z.unknown());
2086
+ const MetricAddableDimension = MetricDimension.extend({ mapping_target: MetricMappingTarget });
2087
+ const MetricAddableGroup = z.object({
2088
+ group: MetricDimensionGroup.nullable(),
2089
+ dimensions: z.array(MetricAddableDimension)
2090
+ }).loose();
2091
+ const MetricDimensionListing = z.object({
2092
+ added: z.array(MetricDimension),
2093
+ addable: z.array(MetricAddableGroup)
2094
+ }).loose();
2095
+ //#endregion
2096
+ //#region ../client/src/resources/metric.ts
2097
+ function metricResource(transport) {
2098
+ /**
2099
+ * Run a metric definition and return the query result envelope: one metric or measure, or an
2100
+ * arithmetic expression over several, each leaf filtered and projected on its own `lib/uuid`.
2101
+ */
2102
+ async function query(definition, options = {}) {
2103
+ await transport.require("metric.query", options);
2104
+ return transport.requestParsed(CardQueryResult, "/api/metric/dataset", {
2105
+ ...options,
2106
+ method: "POST",
2107
+ body: { definition }
2108
+ });
2109
+ }
2110
+ /**
2111
+ * Fetch the distinct values of a definition's breakout dimension, with that column's metadata.
2112
+ * Takes the same definition `query` does.
2113
+ */
2114
+ async function breakoutValues(definition, options = {}) {
2115
+ await transport.require("metric.breakoutValues", options);
2116
+ return transport.requestParsed(MetricBreakoutValues, "/api/metric/breakout-values", {
2117
+ ...options,
2118
+ method: "POST",
2119
+ body: { definition }
2120
+ });
2121
+ }
2122
+ /**
2123
+ * List a metric's curated dimensions and, under `with-addable`, the columns still available to
2124
+ * add, grouped by source table. `query` filters both by a name substring.
2125
+ */
2126
+ async function dimensions(id, params = {}, options = {}) {
2127
+ await transport.require("metric.dimensions", options);
2128
+ return transport.requestParsed(MetricDimensionListing, `/api/metric/${id}/dimension`, {
2129
+ ...options,
2130
+ query: {
2131
+ query: params.query,
2132
+ "with-addable": params["with-addable"],
2133
+ "include-orphaned": params["include-orphaned"]
2134
+ }
2135
+ });
2136
+ }
2137
+ return {
2138
+ query,
2139
+ breakoutValues,
2140
+ dimensions
2141
+ };
2142
+ }
2143
+ //#endregion
2144
+ //#region ../client/src/domain/moderation-review.ts
2145
+ const ModeratedItemType = z.enum(["card", "dashboard"]);
2146
+ const ModerationStatus = z.enum(["verified"]);
2147
+ const ModerationReview = z.object({
2148
+ id: z.number().int(),
2149
+ moderated_item_id: z.number().int(),
2150
+ moderated_item_type: ModeratedItemType,
2151
+ moderator_id: z.number().int(),
2152
+ status: ModerationStatus.nullable(),
2153
+ text: z.string().nullable(),
2154
+ most_recent: z.boolean(),
2155
+ created_at: z.string(),
2156
+ updated_at: z.string()
2157
+ }).loose();
2158
+ ModerationReview.pick({
2159
+ id: true,
2160
+ moderated_item_id: true,
2161
+ moderated_item_type: true,
2162
+ status: true,
2163
+ text: true,
2164
+ most_recent: true
2165
+ }).strip();
2166
+ z.object({
2167
+ moderated_item_id: z.number().int().positive(),
2168
+ moderated_item_type: ModeratedItemType,
2169
+ status: ModerationStatus.nullable().optional(),
2170
+ text: z.string().nullable().optional()
2171
+ }).strict();
2172
+ //#endregion
2173
+ //#region ../client/src/resources/moderation-review.ts
2174
+ function moderationReviewResource(transport) {
2175
+ /**
2176
+ * Create a moderation review on a card or dashboard. `status: "verified"` marks the item
2177
+ * verified, `null` or an absent status records a note that leaves it unverified. The new review
2178
+ * becomes the item's most recent one; the server keeps the ten newest per item. Admins only.
2179
+ */
2180
+ async function create(params, options = {}) {
2181
+ await transport.require("moderationReview.create", options);
2182
+ return transport.requestParsed(ModerationReview, "/api/moderation-review", {
2183
+ ...options,
2184
+ method: "POST",
2185
+ body: params
2186
+ });
2187
+ }
2188
+ return { create };
2189
+ }
2190
+ //#endregion
2191
+ //#region ../client/src/resources/notification.ts
2192
+ const NotificationApiList = z.array(Notification);
2193
+ function assertCardAlert(notification) {
2194
+ if (notification.payload_type !== "notification/card") throw new ConfigError(`notification ${notification.id} is a ${notification.payload_type}, not a question alert — this operation accepts card alerts only`);
2195
+ return notification;
2196
+ }
2197
+ function mergeAlertUpdate(current, patch) {
2198
+ return Notification.parse({
2199
+ ...current,
2200
+ ...patch,
2201
+ id: current.id,
2202
+ payload: patch.payload === void 0 ? current.payload : mergePayload(current, patch.payload)
2203
+ });
2204
+ }
2205
+ function mergePayload(current, patch) {
2206
+ if (current.payload === null) throw new ConfigError(`alert ${current.id} has lost its card payload — it can be archived, but not patched`);
2207
+ return NotificationCardPayload.parse({
2208
+ ...current.payload,
2209
+ ...patch
2210
+ });
2211
+ }
2212
+ function notificationResource(transport) {
2213
+ /**
2214
+ * List question alerts, optionally narrowed by the card they watch, their creator, or a
2215
+ * recipient. `/api/notification` also serves Metabase's internal system-event notifications, so
2216
+ * the request pins the card payload type.
2217
+ */
2218
+ async function list(params = {}, options = {}) {
2219
+ await transport.require("notification.list", options);
2220
+ return {
2221
+ data: await transport.requestParsed(NotificationApiList, "/api/notification", {
2222
+ ...options,
2223
+ query: {
2224
+ payload_type: CARD_PAYLOAD_TYPE,
2225
+ card_id: params.card_id,
2226
+ creator_id: params.creator_id,
2227
+ recipient_id: params.recipient_id,
2228
+ include_inactive: params.include_inactive
2229
+ }
2230
+ }),
2231
+ total: null
2232
+ };
2233
+ }
2234
+ /** Get one question alert by id, refusing an id that names a system-event notification. */
2235
+ async function get(id, options = {}) {
2236
+ await transport.require("notification.get", options);
2237
+ return assertCardAlert(await transport.requestParsed(Notification, `/api/notification/${id}`, { ...options }));
2238
+ }
2239
+ /** Create a question alert — its card payload, schedules and handlers — from a full body. */
2240
+ async function create(params, options = {}) {
2241
+ await transport.require("notification.create", options);
2242
+ return transport.requestParsed(Notification, "/api/notification", {
2243
+ ...options,
2244
+ method: "POST",
2245
+ body: params
2246
+ });
2247
+ }
2248
+ /** Update a question alert by id, merging the patch over the stored notification. */
2249
+ async function update(id, params, options = {}) {
2250
+ await transport.require("notification.update", options);
2251
+ const current = await get(id, options);
2252
+ return transport.requestParsed(Notification, `/api/notification/${id}`, {
2253
+ ...options,
2254
+ method: "PUT",
2255
+ body: mergeAlertUpdate(current, params)
2256
+ });
2257
+ }
2258
+ /** Archive a question alert by id, stopping every delivery. Metabase models this as an update. */
2259
+ async function archive(id, options = {}) {
2260
+ await transport.require("notification.archive", options);
2261
+ return update(id, { active: false }, options);
2262
+ }
2263
+ /**
2264
+ * Send a question alert now, off-schedule, to every handler on it. The server answers with no
2265
+ * body.
2266
+ */
2267
+ async function send(id, options = {}) {
2268
+ await transport.require("notification.send", options);
2269
+ await get(id, options);
2270
+ await transport.requestRaw(`/api/notification/${id}/send`, {
2271
+ ...options,
2272
+ method: "POST",
2273
+ expectContentType: "binary"
2274
+ });
2275
+ }
2276
+ return {
2277
+ list,
2278
+ get,
2279
+ create,
2280
+ update,
2281
+ archive,
2282
+ send
2283
+ };
2284
+ }
2285
+ //#endregion
2286
+ //#region ../client/src/domain/permission.ts
2287
+ const ViewDataPermission = z.enum([
2288
+ "unrestricted",
2289
+ "legacy-no-self-service",
2290
+ "blocked",
2291
+ "sandboxed",
2292
+ "impersonated"
2293
+ ]);
2294
+ const CreateQueriesPermission = z.enum([
2295
+ "query-builder-and-native",
2296
+ "query-builder",
2297
+ "no"
2298
+ ]);
2299
+ const DownloadPermission = z.enum(["full", "limited"]);
2300
+ const DataModelPermission = z.literal("all");
2301
+ const YesNoPermission = z.enum(["yes", "no"]);
2302
+ function granular(value) {
2303
+ const perTable = z.record(z.string(), value);
2304
+ const perSchema = z.record(z.string(), z.union([value, perTable]));
2305
+ return z.union([value, perSchema]);
2306
+ }
2307
+ const DatabasePermissions = z.object({
2308
+ "view-data": granular(ViewDataPermission).optional(),
2309
+ "create-queries": granular(CreateQueriesPermission).optional(),
2310
+ download: z.object({ schemas: granular(DownloadPermission) }).loose().optional(),
2311
+ "data-model": z.object({ schemas: granular(DataModelPermission) }).loose().optional(),
2312
+ details: YesNoPermission.optional(),
2313
+ transforms: YesNoPermission.optional()
2314
+ }).loose();
2315
+ const PermissionsGraph = z.object({
2316
+ revision: z.number().int().nonnegative(),
2317
+ groups: z.record(z.string(), z.record(z.string(), DatabasePermissions))
2318
+ }).loose();
2319
+ //#endregion
2320
+ //#region ../client/src/resources/permission.ts
2321
+ function permissionResource(transport) {
2322
+ /**
2323
+ * Get the data permissions of every group on every database, keyed by group id then database
2324
+ * id. Admin only. One read of the whole `data_permissions` table, so prefer `databaseGraph` when
2325
+ * one database is the question.
2326
+ */
2327
+ async function graph(options = {}) {
2328
+ await transport.require("permission.graph", options);
2329
+ return transport.requestParsed(PermissionsGraph, "/api/permissions/graph", { ...options });
2330
+ }
2331
+ /**
2332
+ * Get the data permissions of every group on one database. Admin only. The read is filtered to
2333
+ * that database, so this is the cheapest way to learn which groups can query a table: look the
2334
+ * group up under the database and read `view-data` and `create-queries` down to the table id.
2335
+ */
2336
+ async function databaseGraph(id, options = {}) {
2337
+ await transport.require("permission.databaseGraph", options);
2338
+ return transport.requestParsed(PermissionsGraph, `/api/permissions/graph/db/${id}`, { ...options });
2339
+ }
2340
+ /** Get the data permissions of one group on every database. Admin only. */
2341
+ async function groupGraph(id, options = {}) {
2342
+ await transport.require("permission.groupGraph", options);
2343
+ return transport.requestParsed(PermissionsGraph, `/api/permissions/graph/group/${id}`, { ...options });
2344
+ }
2345
+ return {
2346
+ graph,
2347
+ databaseGraph,
2348
+ groupGraph
2349
+ };
2350
+ }
2351
+ //#endregion
2352
+ //#region ../client/src/resources/pulse.ts
2353
+ const PulseApiList = z.array(Pulse);
2354
+ function mergePulseUpdate(current, patch) {
2355
+ return {
2356
+ ...patch,
2357
+ archived: patch.archived ?? current.archived,
2358
+ skip_if_empty: patch.skip_if_empty ?? current.skip_if_empty
2359
+ };
2360
+ }
2361
+ function pulseResource(transport) {
2362
+ /** List dashboard subscriptions, optionally narrowed to one dashboard or to the archived ones. */
2363
+ async function list(params = {}, options = {}) {
2364
+ await transport.require("pulse.list", options);
2365
+ return {
2366
+ data: await transport.requestParsed(PulseApiList, "/api/pulse", {
2367
+ ...options,
2368
+ query: {
2369
+ dashboard_id: params.dashboard_id,
2370
+ archived: params.archived
2371
+ }
2372
+ }),
2373
+ total: null
2374
+ };
2375
+ }
2376
+ /** Get one dashboard subscription by id. */
2377
+ async function get(id, options = {}) {
2378
+ await transport.require("pulse.get", options);
2379
+ return transport.requestParsed(Pulse, `/api/pulse/${id}`, { ...options });
2380
+ }
2381
+ /** Create a dashboard subscription — its cards and its delivery channels — from a full body. */
2382
+ async function create(params, options = {}) {
2383
+ await transport.require("pulse.create", options);
2384
+ return transport.requestParsed(Pulse, "/api/pulse", {
2385
+ ...options,
2386
+ method: "POST",
2387
+ body: params
2388
+ });
2389
+ }
2390
+ /** Update a dashboard subscription by id, carrying the server-defaulted flags forward. */
2391
+ async function update(id, params, options = {}) {
2392
+ await transport.require("pulse.update", options);
2393
+ const current = await get(id, options);
2394
+ return transport.requestParsed(Pulse, `/api/pulse/${id}`, {
2395
+ ...options,
2396
+ method: "PUT",
2397
+ body: mergePulseUpdate(current, params)
2398
+ });
2399
+ }
2400
+ /**
2401
+ * Archive a dashboard subscription by id, stopping every delivery. Metabase models this as an
2402
+ * update, and disables each of the subscription's channels as a side effect.
2403
+ */
2404
+ async function archive(id, options = {}) {
2405
+ await transport.require("pulse.archive", options);
2406
+ return update(id, { archived: true }, options);
2407
+ }
2408
+ return {
2409
+ list,
2410
+ get,
2411
+ create,
2412
+ update,
2413
+ archive
2414
+ };
2415
+ }
2416
+ //#endregion
2417
+ //#region ../client/src/domain/replacement.ts
2418
+ const ReplacementSourceType = z.enum(["card", "table"]);
2419
+ const ReplacementEntityType = z.enum([...ReplacementSourceType.options, "transform"]);
2420
+ const ReplacementRunStatus = z.enum([
2421
+ "pending",
2422
+ "started",
2423
+ "succeeded",
2424
+ "failed",
2425
+ "canceled",
2426
+ "timeout"
2427
+ ]);
2428
+ const ReplacementRun = z.object({
2429
+ id: z.number().int(),
2430
+ status: ReplacementRunStatus,
2431
+ is_active: z.literal(true).nullable(),
2432
+ source_entity_type: ReplacementEntityType,
2433
+ source_entity_id: z.number().int(),
2434
+ target_entity_type: ReplacementEntityType,
2435
+ target_entity_id: z.number().int(),
2436
+ progress: z.number().min(0).max(1).nullable(),
2437
+ message: z.string().nullable(),
2438
+ user_id: z.number().int().nullable(),
2439
+ start_time: z.string(),
2440
+ end_time: z.string().nullable()
2441
+ }).loose();
2442
+ ReplacementRun.pick({
2443
+ id: true,
2444
+ status: true,
2445
+ source_entity_type: true,
2446
+ source_entity_id: true,
2447
+ target_entity_type: true,
2448
+ target_entity_id: true,
2449
+ progress: true,
2450
+ message: true,
2451
+ start_time: true,
2452
+ end_time: true
2453
+ }).strip();
2454
+ const ReplacementColumn = z.object({
2455
+ id: z.number().int().nullable(),
2456
+ name: z.string(),
2457
+ display_name: z.string(),
2458
+ base_type: FieldBaseType.nullable(),
2459
+ effective_type: FieldBaseType.nullable(),
2460
+ semantic_type: FieldSemanticType.nullable()
2461
+ });
2462
+ const ReplacementColumnError = z.enum([
2463
+ "column-type-mismatch",
2464
+ "missing-primary-key",
2465
+ "missing-foreign-key",
2466
+ "foreign-key-mismatch"
2467
+ ]);
2468
+ const ReplacementColumnMatched = z.object({
2469
+ source: ReplacementColumn,
2470
+ target: ReplacementColumn,
2471
+ errors: z.array(ReplacementColumnError).optional()
2472
+ }).strict();
2473
+ const ReplacementColumnMissingOnTarget = z.object({ source: ReplacementColumn }).strict();
2474
+ const ReplacementColumnMissingOnSource = z.object({ target: ReplacementColumn }).strict();
2475
+ const ReplacementColumnMapping = z.union([
2476
+ ReplacementColumnMatched,
2477
+ ReplacementColumnMissingOnTarget,
2478
+ ReplacementColumnMissingOnSource
2479
+ ]);
2480
+ const ReplacementError = z.enum([
2481
+ "cycle-detected",
2482
+ "database-mismatch",
2483
+ "incompatible-implicit-joins",
2484
+ "affects-gtap-policies"
2485
+ ]);
2486
+ const ReplacementCheck = z.object({
2487
+ success: z.boolean(),
2488
+ errors: z.array(ReplacementError).optional(),
2489
+ column_mappings: z.array(ReplacementColumnMapping).optional()
2490
+ });
2491
+ z.object({
2492
+ source_entity_id: z.number().int().positive(),
2493
+ source_entity_type: ReplacementSourceType,
2494
+ target_entity_id: z.number().int().positive(),
2495
+ target_entity_type: ReplacementSourceType
2496
+ }).strict();
2497
+ z.object({
2498
+ card_id: z.number().int().positive(),
2499
+ transform_name: z.string(),
2500
+ transform_target: TransformTarget,
2501
+ target_collection_id: z.number().int().positive().nullable().optional(),
2502
+ transform_tag_ids: z.array(z.number().int().positive()).nullable().optional()
2503
+ }).strict();
2504
+ const ReplacementRunStarted = z.object({ run_id: z.number().int().positive() });
2505
+ //#endregion
2506
+ //#region ../client/src/resources/replacement.ts
2507
+ const ReplacementApiRunList = z.array(ReplacementRun);
2508
+ const CancelRunResponse = z.object({ success: z.literal(true) });
2509
+ function replacementResource(transport) {
2510
+ /**
2511
+ * Check whether every usage of a source entity could be rewritten to read a target entity
2512
+ * instead: the two must share a database, the target must not depend on the source, every source
2513
+ * column must exist on the target with a compatible type, and a table source must not be joined
2514
+ * implicitly or sandboxed. Admins only.
2515
+ */
2516
+ async function checkReplaceSource(params, options = {}) {
2517
+ await transport.require("replacement.checkReplaceSource", options);
2518
+ return transport.requestParsed(ReplacementCheck, "/api/ee/replacement/check-replace-source", {
2519
+ ...options,
2520
+ method: "POST",
2521
+ body: params
2522
+ });
2523
+ }
2524
+ /**
2525
+ * Rewrite every usage of a source entity to read a target entity, in the background. Runs the
2526
+ * same check as `checkReplaceSource` first and refuses with a 400 when it fails, and with a 409
2527
+ * while another replacement is running. Admins only.
2528
+ */
2529
+ async function replaceSource(params, options = {}) {
2530
+ await transport.require("replacement.replaceSource", options);
2531
+ return transport.requestParsed(ReplacementRunStarted, "/api/ee/replacement/replace-source", {
2532
+ ...options,
2533
+ method: "POST",
2534
+ body: params
2535
+ });
2536
+ }
2537
+ /**
2538
+ * Create a transform from a model's query, run it, and rewrite every usage of the model to read
2539
+ * the transform's output table, in the background; the model becomes a saved question. A failed
2540
+ * transform run leaves the model as it was; a failed rewrite keeps the transform and its table
2541
+ * as well, since other queries may already read them. Refuses with a 409 while another
2542
+ * replacement is running. Admins only.
2543
+ */
2544
+ async function replaceModelWithTransform(params, options = {}) {
2545
+ await transport.require("replacement.replaceModelWithTransform", options);
2546
+ return transport.requestParsed(ReplacementRunStarted, "/api/ee/replacement/replace-model-with-transform", {
2547
+ ...options,
2548
+ method: "POST",
2549
+ body: params
2550
+ });
2551
+ }
2552
+ /**
2553
+ * List replacement runs, newest first. `is-active: true` keeps only the run in progress,
2554
+ * `false` only the ended ones. Admins only.
2555
+ */
2556
+ async function listRuns(params = {}, options = {}) {
2557
+ await transport.require("replacement.listRuns", options);
2558
+ return {
2559
+ data: await transport.requestParsed(ReplacementApiRunList, "/api/ee/replacement/runs", {
2560
+ ...options,
2561
+ query: { "is-active": params["is-active"] }
2562
+ }),
2563
+ total: null
2564
+ };
2565
+ }
2566
+ /** Get one replacement run by id, with its status and progress. Admins only. */
2567
+ async function getRun(id, options = {}) {
2568
+ await transport.require("replacement.getRun", options);
2569
+ return transport.requestParsed(ReplacementRun, `/api/ee/replacement/runs/${id}`, { ...options });
2570
+ }
2571
+ /** Cancel the replacement in progress. Refuses with a 409 once the run has ended. Admins only. */
2572
+ async function cancelRun(id, options = {}) {
2573
+ await transport.require("replacement.cancelRun", options);
2574
+ await transport.requestParsed(CancelRunResponse, `/api/ee/replacement/runs/${id}/cancel`, {
2575
+ ...options,
2576
+ method: "POST"
2577
+ });
2578
+ }
2579
+ return {
2580
+ checkReplaceSource,
2581
+ replaceSource,
2582
+ replaceModelWithTransform,
2583
+ listRuns,
2584
+ getRun,
2585
+ cancelRun
2586
+ };
2587
+ }
2588
+ //#endregion
2589
+ //#region ../client/src/domain/revision.ts
2590
+ const RevisionEntity = z.enum([
2591
+ "card",
2592
+ "dashboard",
2593
+ "document",
2594
+ "measure",
2595
+ "segment",
2596
+ "transform"
2597
+ ]);
2598
+ const RevisionUser = z.object({
2599
+ id: z.number().int(),
2600
+ first_name: z.string().nullable(),
2601
+ last_name: z.string().nullable(),
2602
+ common_name: z.string()
2603
+ }).loose();
2604
+ const Revision = z.object({
2605
+ id: z.number().int(),
2606
+ timestamp: z.string(),
2607
+ is_creation: z.boolean(),
2608
+ is_reversion: z.boolean(),
2609
+ most_recent: z.boolean(),
2610
+ diff: z.object({}).loose().nullable(),
2611
+ description: z.string(),
2612
+ has_multiple_changes: z.boolean(),
2613
+ user: RevisionUser
2614
+ }).loose();
2615
+ Revision.pick({
2616
+ id: true,
2617
+ timestamp: true,
2618
+ is_creation: true,
2619
+ is_reversion: true,
2620
+ description: true,
2621
+ user: true
2622
+ }).strip();
2623
+ const RevisionRow = z.object({
2624
+ id: z.number().int(),
2625
+ model: z.string(),
2626
+ model_id: z.number().int(),
2627
+ user_id: z.number().int(),
2628
+ object: z.object({}).loose(),
2629
+ timestamp: z.string(),
2630
+ is_creation: z.boolean(),
2631
+ is_reversion: z.boolean(),
2632
+ most_recent: z.boolean()
2633
+ }).loose();
2634
+ z.object({
2635
+ entity: RevisionEntity,
2636
+ id: z.number().int().positive(),
2637
+ revision_id: z.number().int().positive()
2638
+ }).strict();
2639
+ const RevisionReverted = z.object({
2640
+ outcome: z.literal("reverted"),
2641
+ revision: Revision
2642
+ });
2643
+ const RevisionUnchanged = z.object({
2644
+ outcome: z.literal("unchanged"),
2645
+ revision: RevisionRow
2646
+ });
2647
+ z.discriminatedUnion("outcome", [RevisionReverted, RevisionUnchanged]);
2648
+ //#endregion
2649
+ //#region ../client/src/resources/revision.ts
2650
+ const RevisionApiList = z.array(Revision);
2651
+ const RevisionApiRevert = z.union([Revision.transform((revision) => ({
2652
+ outcome: "reverted",
2653
+ revision
2654
+ })), RevisionRow.transform((revision) => ({
2655
+ outcome: "unchanged",
2656
+ revision
2657
+ }))]);
2658
+ const ENTITY_FEATURES = {
2659
+ measure: "measures",
2660
+ transform: "transforms"
2661
+ };
2662
+ function entityFeatures(entity) {
2663
+ const feature = ENTITY_FEATURES[entity];
2664
+ return feature === void 0 ? [] : [feature];
2665
+ }
2666
+ function revisionResource(transport) {
2667
+ /** List the revisions of an entity the caller may read, newest first, each with its diff. */
2668
+ async function list(entity, id, options = {}) {
2669
+ await transport.require("revision.list", options);
2670
+ await transport.requireFeatures(entityFeatures(entity), options);
2671
+ return {
2672
+ data: await transport.requestParsed(RevisionApiList, `/api/revision/${entity}/${id}`, { ...options }),
2673
+ total: null
2674
+ };
2675
+ }
2676
+ /**
2677
+ * Revert an entity to one of its prior revisions. Needs write access to the entity, and for a
2678
+ * card the permission to run the query being restored.
2679
+ */
2680
+ async function revert(params, options = {}) {
2681
+ await transport.require("revision.revert", options);
2682
+ await transport.requireFeatures(entityFeatures(params.entity), options);
2683
+ return transport.requestParsed(RevisionApiRevert, "/api/revision/revert", {
2684
+ ...options,
2685
+ method: "POST",
2686
+ body: params
2687
+ });
2688
+ }
2689
+ return {
2690
+ list,
2691
+ revert
2692
+ };
2693
+ }
2694
+ //#endregion
2695
+ //#region ../client/src/resources/search.ts
2696
+ const SearchApiResponse = z.object({
2697
+ data: z.array(SearchResult),
2698
+ total: z.number().int().nonnegative()
2699
+ }).loose();
2700
+ function searchResource(transport) {
2701
+ /**
2702
+ * Search over the instance's content, ranked against `q`. `models` narrows which kinds of entity
2703
+ * may match, `archived` swaps the active set for the archived one, `table_db_id` restricts to
2704
+ * items on one database, `verified` to verified content, `collection` to one collection and its
2705
+ * descendants, `created_by` to items created by any of those users, `search_native_query` also
2706
+ * matches the text of native queries, `include_metadata` attaches each card's `result_metadata`,
2707
+ * and `limit`/`offset` are the window the server applies before ranking hydration.
2708
+ */
2709
+ async function query(params = {}, options = {}) {
2710
+ await transport.require("search.query", options);
2711
+ const response = await transport.requestParsed(SearchApiResponse, "/api/search", {
2712
+ ...options,
2713
+ query: {
2714
+ q: params.q,
2715
+ models: params.models,
2716
+ archived: params.archived,
2717
+ limit: params.limit,
2718
+ offset: params.offset,
2719
+ table_db_id: params.table_db_id,
2720
+ verified: params.verified,
2721
+ collection: params.collection,
2722
+ created_by: params.created_by,
2723
+ search_native_query: params.search_native_query,
2724
+ include_metadata: params.include_metadata
2725
+ }
2726
+ });
2727
+ return {
2728
+ data: response.data,
2729
+ total: response.total
2730
+ };
2731
+ }
2732
+ return { query };
2733
+ }
2734
+ //#endregion
2735
+ //#region ../client/src/resources/segment.ts
2736
+ const SegmentApiList = z.array(Segment);
2737
+ function segmentResource(transport) {
2738
+ /** List every segment the caller can see. */
2739
+ async function list(options = {}) {
2740
+ await transport.require("segment.list", options);
2741
+ return {
2742
+ data: await transport.requestParsed(SegmentApiList, "/api/segment", { ...options }),
2743
+ total: null
2744
+ };
2745
+ }
2746
+ /** Get one segment by id. */
2747
+ async function get(id, options = {}) {
2748
+ await transport.require("segment.get", options);
2749
+ return transport.requestParsed(Segment, `/api/segment/${id}`, { ...options });
2750
+ }
2751
+ /** Create a segment — a reusable row filter over one table — from a full segment body. */
2752
+ async function create(params, options = {}) {
2753
+ await transport.require("segment.create", options);
2754
+ return transport.requestParsed(Segment, "/api/segment", {
2755
+ ...options,
2756
+ method: "POST",
2757
+ body: params
2758
+ });
2759
+ }
2760
+ /**
2761
+ * Update a segment by id, patching only the fields the body carries. `revision_message` is
2762
+ * required: Metabase records every segment change in its revision history.
2763
+ */
2764
+ async function update(id, params, options = {}) {
2765
+ await transport.require("segment.update", options);
2766
+ return transport.requestParsed(Segment, `/api/segment/${id}`, {
2767
+ ...options,
2768
+ method: "PUT",
2769
+ body: params
2770
+ });
2771
+ }
2772
+ /**
2773
+ * Archive (soft-delete) a segment by id. Metabase models this as an update, so it carries the
2774
+ * same required `revision_message`.
2775
+ */
2776
+ async function archive(id, params, options = {}) {
2777
+ await transport.require("segment.archive", options);
2778
+ return update(id, {
2779
+ archived: true,
2780
+ revision_message: params.revision_message
2781
+ }, options);
2782
+ }
2783
+ return {
2784
+ list,
2785
+ get,
2786
+ create,
2787
+ update,
2788
+ archive
2789
+ };
2790
+ }
2791
+ //#endregion
2792
+ //#region ../client/src/resources/setting.ts
2793
+ const SettingApiList = z.array(Setting);
2794
+ const UNKNOWN_SETTING_PREFIX = "Unknown setting:";
2795
+ function rethrowSettingError(error, key) {
2796
+ if (errorMessage(error).startsWith(UNKNOWN_SETTING_PREFIX)) throw new ConfigError(`unknown setting: ${key}`);
2797
+ throw error;
2798
+ }
2799
+ function settingResource(transport) {
2800
+ /** Get all settings and their values, with descriptions and environment-variable names. */
2801
+ async function list(options = {}) {
2802
+ await transport.require("setting.list", options);
2803
+ return {
2804
+ data: await transport.requestParsed(SettingApiList, "/api/setting", { ...options }),
2805
+ total: null
2806
+ };
2807
+ }
2808
+ /**
2809
+ * Fetch a single setting's value by key. An unset setting answers 204 rather than 404, which
2810
+ * reaches the caller as `null`; a string-typed setting answers bare text rather than JSON.
2811
+ */
2812
+ async function get(key, options = {}) {
2813
+ await transport.require("setting.get", options);
2814
+ return fetchOptionalParsed(transport, `/api/setting/${encodeURIComponent(key)}`, z.unknown(), options).catch((error) => rethrowSettingError(error, key));
2815
+ }
2816
+ /** Set a single setting's value by key. The endpoint answers 204 with no body. */
2817
+ async function set(key, value, options = {}) {
2818
+ await transport.require("setting.set", options);
2819
+ await transport.requestRaw(`/api/setting/${encodeURIComponent(key)}`, {
2820
+ ...options,
2821
+ method: "PUT",
2822
+ body: { value },
2823
+ expectContentType: "binary"
2824
+ }).catch((error) => rethrowSettingError(error, key));
2825
+ }
2826
+ return {
2827
+ list,
2828
+ get,
2829
+ set
2830
+ };
2831
+ }
2832
+ //#endregion
2833
+ //#region ../client/src/resources/setup.ts
2834
+ function setupResource(transport) {
2835
+ /**
2836
+ * Complete the initial setup wizard on a fresh instance, creating its first admin user and
2837
+ * applying the instance preferences. The setup token is single-use.
2838
+ */
2839
+ async function create(params, options = {}) {
2840
+ await transport.require("setup.create", options);
2841
+ return transport.requestParsed(SetupResult, "/api/setup", {
2842
+ ...options,
2843
+ method: "POST",
2844
+ body: params
2845
+ });
2846
+ }
2847
+ return { create };
2848
+ }
2849
+ //#endregion
2850
+ //#region ../client/src/resources/snippet.ts
2851
+ const SnippetApiList = z.array(Snippet);
2852
+ function snippetResource(transport) {
2853
+ /** List native query snippets. `archived` swaps the listing to archived snippets. */
2854
+ async function list(params = {}, options = {}) {
2855
+ await transport.require("snippet.list", options);
2856
+ return {
2857
+ data: await transport.requestParsed(SnippetApiList, "/api/native-query-snippet", {
2858
+ ...options,
2859
+ query: { archived: params.archived }
2860
+ }),
2861
+ total: null
2862
+ };
2863
+ }
2864
+ /** Get one native query snippet by id. */
2865
+ async function get(id, options = {}) {
2866
+ await transport.require("snippet.get", options);
2867
+ return transport.requestParsed(Snippet, `/api/native-query-snippet/${id}`, { ...options });
2868
+ }
2869
+ /** Create a native query snippet from a name, its SQL fragment, and an optional collection. */
2870
+ async function create(params, options = {}) {
2871
+ await transport.require("snippet.create", options);
2872
+ return transport.requestParsed(Snippet, "/api/native-query-snippet", {
2873
+ ...options,
2874
+ method: "POST",
2875
+ body: params
2876
+ });
2877
+ }
2878
+ /** Update a native query snippet by id, patching only the fields the body carries. */
2879
+ async function update(id, params, options = {}) {
2880
+ await transport.require("snippet.update", options);
2881
+ return transport.requestParsed(Snippet, `/api/native-query-snippet/${id}`, {
2882
+ ...options,
2883
+ method: "PUT",
2884
+ body: params
2885
+ });
2886
+ }
2887
+ /**
2888
+ * Archive (soft-delete) a native query snippet by id. Metabase models this as an update, not its
2889
+ * own endpoint.
2890
+ */
2891
+ async function archive(id, options = {}) {
2892
+ await transport.require("snippet.archive", options);
2893
+ return update(id, { archived: true }, options);
2894
+ }
2895
+ return {
2896
+ list,
2897
+ get,
2898
+ create,
2899
+ update,
2900
+ archive
2901
+ };
2902
+ }
2903
+ //#endregion
2904
+ //#region ../client/src/resources/table.ts
2905
+ const TableApiList = z.array(Table);
2906
+ const TableApiFks = z.array(TableForeignKey);
2907
+ const SyncSchemaResponse = z.object({ status: z.literal("ok") });
2908
+ const RescanValuesResponse = z.object({ status: z.literal("success") });
2909
+ const BulkEditResponse = z.object({});
2910
+ const BULK_EDIT_PATH = "/api/data-studio/table/edit";
2911
+ const LIST_PARAM_FEATURES = [
2912
+ ["can-query", "tableListAccessFilters"],
2913
+ ["can-write", "tableListAccessFilters"],
2914
+ ["include-transform-targets", "tableListTransformTargets"],
2915
+ ["unused-only", "tableUnusedFilter"]
2916
+ ];
2917
+ function listParamFeatures(params) {
2918
+ return LIST_PARAM_FEATURES.filter(([param]) => params[param] !== void 0).map(([, feature]) => feature);
2919
+ }
2920
+ const UPLOAD_UPDATE_PATHS = {
2921
+ append: "append-csv",
2922
+ replace: "replace-csv"
2923
+ };
2924
+ function tableResource(transport) {
2925
+ /**
2926
+ * List every table the caller can see, across all databases. `term` matches names and display
2927
+ * names; `can-query` and `can-write` keep only the tables the caller may query or edit the
2928
+ * metadata of; `include-transform-targets` adds tables a transform writes to; `unused-only` keeps
2929
+ * tables nothing depends on.
2930
+ */
2931
+ async function list(params = {}, options = {}) {
2932
+ await transport.require("table.list", options);
2933
+ await transport.requireFeatures(listParamFeatures(params), options);
2934
+ await requireDataLayer(params["data-layer"], options);
2935
+ return {
2936
+ data: await transport.requestParsed(TableApiList, "/api/table", {
2937
+ ...options,
2938
+ query: {
2939
+ term: params.term,
2940
+ "visibility-type": params["visibility-type"],
2941
+ "data-layer": params["data-layer"],
2942
+ "data-source": params["data-source"],
2943
+ "owner-user-id": params["owner-user-id"],
2944
+ "owner-email": params["owner-email"],
2945
+ "orphan-only": params["orphan-only"],
2946
+ "unused-only": params["unused-only"],
2947
+ "can-query": params["can-query"],
2948
+ "can-write": params["can-write"],
2949
+ "include-transform-targets": params["include-transform-targets"]
2950
+ }
2951
+ }),
2952
+ total: null
2953
+ };
2954
+ }
2955
+ /** Get one table by id, without its fields. */
2956
+ async function get(id, options = {}) {
2957
+ await transport.require("table.get", options);
2958
+ return transport.requestParsed(Table, `/api/table/${id}`, { ...options });
2959
+ }
2960
+ /** Update a table by id, patching only the fields the body carries. */
2961
+ async function update(id, params, options = {}) {
2962
+ await transport.require("table.update", options);
2963
+ await requireDataLayer(params.data_layer, options);
2964
+ return transport.requestParsed(Table, `/api/table/${id}`, {
2965
+ ...options,
2966
+ method: "PUT",
2967
+ body: params
2968
+ });
2969
+ }
2970
+ async function requireDataLayer(value, options) {
2971
+ if (value === null || value === void 0) return;
2972
+ if (TableDataLayerTier.safeParse(value).success) {
2973
+ await transport.requireFeatures(["tableDataLayerTiers"], options);
2974
+ return;
2975
+ }
2976
+ const { features } = await transport.server(options);
2977
+ if (features.tableDataLayerTiers) throw new ConfigError(`data_layer "${value}" is a medallion name; this server names a table's layer ${TableDataLayerTier.options.join(", ")}`);
2978
+ }
2979
+ /** Get a table by id with its fields hydrated — the metadata the query builder runs on. */
2980
+ async function queryMetadata(id, options = {}) {
2981
+ await transport.require("table.queryMetadata", options);
2982
+ return transport.requestParsed(TableQueryMetadata, `/api/table/${id}/query_metadata`, { ...options });
2983
+ }
2984
+ /**
2985
+ * Get every foreign key whose destination is a field of this table. A table with no active
2986
+ * fields answers no content, which is the same empty list.
2987
+ */
2988
+ async function fks(id, options = {}) {
2989
+ await transport.require("table.fks", options);
2990
+ return {
2991
+ data: await fetchOptionalParsed(transport, `/api/table/${id}/fks`, TableApiFks, { ...options }) ?? [],
2992
+ total: null
2993
+ };
2994
+ }
2995
+ /**
2996
+ * Trigger a manual update of this table's schema metadata. The sync runs after the call returns;
2997
+ * a warehouse the server cannot connect to is a 422.
2998
+ */
2999
+ async function syncSchema(id, options = {}) {
3000
+ await transport.require("table.syncSchema", options);
3001
+ await transport.requestParsed(SyncSchemaResponse, `/api/table/${id}/sync_schema`, {
3002
+ ...options,
3003
+ method: "POST"
3004
+ });
3005
+ }
3006
+ /**
3007
+ * Trigger an update of the field values of every eligible field of this table. The scan runs
3008
+ * after the call returns.
3009
+ */
3010
+ async function rescanValues(id, options = {}) {
3011
+ await transport.require("table.rescanValues", options);
3012
+ await transport.requestParsed(RescanValuesResponse, `/api/table/${id}/rescan_values`, {
3013
+ ...options,
3014
+ method: "POST"
3015
+ });
3016
+ }
3017
+ /**
3018
+ * Set the same metadata on every table the selectors pick out. A table leaving the `hidden` data
3019
+ * layer is re-synced after the call returns.
3020
+ */
3021
+ async function bulkEdit(params, options = {}) {
3022
+ await transport.require("table.bulkEdit", options);
3023
+ await transport.requestParsed(BulkEditResponse, BULK_EDIT_PATH, {
3024
+ ...options,
3025
+ method: "POST",
3026
+ body: params
3027
+ });
3028
+ }
3029
+ async function updateFromCsv(id, action, file, options) {
3030
+ await transport.requestRaw(`/api/table/${id}/${UPLOAD_UPDATE_PATHS[action]}`, {
3031
+ ...options,
3032
+ method: "POST",
3033
+ body: buildCsvFormData(file),
3034
+ expectContentType: "binary"
3035
+ });
3036
+ return {
3037
+ table_id: id,
3038
+ action
3039
+ };
3040
+ }
3041
+ /**
3042
+ * Inserts the rows of an uploaded CSV file into the table identified by `id`. The table must have
3043
+ * been created by uploading a CSV file.
3044
+ *
3045
+ * The file may be at most 50 MB; larger uploads are rejected with a 413 response.
3046
+ */
3047
+ async function appendCsv(id, file, options = {}) {
3048
+ await transport.require("table.appendCsv", options);
3049
+ return updateFromCsv(id, "append", file, options);
3050
+ }
3051
+ /**
3052
+ * Replaces the contents of the table identified by `id` with the rows of an uploaded CSV file.
3053
+ * The table must have been created by uploading a CSV file.
3054
+ *
3055
+ * The file may be at most 50 MB; larger uploads are rejected with a 413 response.
3056
+ */
3057
+ async function replaceCsv(id, file, options = {}) {
3058
+ await transport.require("table.replaceCsv", options);
3059
+ return updateFromCsv(id, "replace", file, options);
3060
+ }
3061
+ return {
3062
+ list,
3063
+ get,
3064
+ update,
3065
+ queryMetadata,
3066
+ fks,
3067
+ syncSchema,
3068
+ rescanValues,
3069
+ bulkEdit,
3070
+ appendCsv,
3071
+ replaceCsv
3072
+ };
3073
+ }
3074
+ //#endregion
3075
+ //#region ../client/src/resources/timeline-event.ts
3076
+ function timelineEventResource(transport) {
3077
+ /** Get one timeline event by id. */
3078
+ async function get(id, options = {}) {
3079
+ await transport.require("timelineEvent.get", options);
3080
+ return transport.requestParsed(TimelineEvent, `/api/timeline-event/${id}`, { ...options });
3081
+ }
3082
+ /** Create a timeline event on an existing timeline. */
3083
+ async function create(params, options = {}) {
3084
+ await transport.require("timelineEvent.create", options);
3085
+ return transport.requestParsed(TimelineEvent, "/api/timeline-event", {
3086
+ ...options,
3087
+ method: "POST",
3088
+ body: params
3089
+ });
3090
+ }
3091
+ /**
3092
+ * Update a timeline event by id, patching only the fields the body carries. `timeline_id` moves
3093
+ * the event to another timeline.
3094
+ */
3095
+ async function update(id, params, options = {}) {
3096
+ await transport.require("timelineEvent.update", options);
3097
+ return transport.requestParsed(TimelineEvent, `/api/timeline-event/${id}`, {
3098
+ ...options,
3099
+ method: "PUT",
3100
+ body: params
3101
+ });
3102
+ }
3103
+ /**
3104
+ * Archive (soft-delete) a timeline event by id. Metabase models this as an update, not its own
3105
+ * endpoint.
3106
+ */
3107
+ async function archive(id, options = {}) {
3108
+ await transport.require("timelineEvent.archive", options);
3109
+ return update(id, { archived: true }, options);
3110
+ }
3111
+ /** Permanently delete a timeline event by id. The server answers with no body. */
3112
+ async function remove(id, options = {}) {
3113
+ await transport.require("timelineEvent.delete", options);
3114
+ await transport.requestRaw(`/api/timeline-event/${id}`, {
3115
+ ...options,
3116
+ method: "DELETE",
3117
+ expectContentType: "binary"
3118
+ });
3119
+ }
3120
+ return {
3121
+ get,
3122
+ create,
3123
+ update,
3124
+ archive,
3125
+ delete: remove
3126
+ };
3127
+ }
3128
+ //#endregion
3129
+ //#region ../client/src/resources/timeline.ts
3130
+ const TimelineApiList = z.array(Timeline);
3131
+ const TimelineWithEvents = Timeline.required({ events: true });
3132
+ function timelineResource(transport) {
3133
+ /** List timelines. `archived` swaps the active listing for the archived one. */
3134
+ async function list(params = {}, options = {}) {
3135
+ await transport.require("timeline.list", options);
3136
+ return {
3137
+ data: await transport.requestParsed(TimelineApiList, "/api/timeline", {
3138
+ ...options,
3139
+ query: { archived: params.archived }
3140
+ }),
3141
+ total: null
3142
+ };
3143
+ }
3144
+ /** Get one timeline by id, without its events. */
3145
+ async function get(id, options = {}) {
3146
+ await transport.require("timeline.get", options);
3147
+ return transport.requestParsed(Timeline, `/api/timeline/${id}`, { ...options });
3148
+ }
3149
+ /**
3150
+ * List the events on one timeline. Metabase has no endpoint of its own for these: the same
3151
+ * timeline read hydrates them on request, and `archived` chooses which of them come back.
3152
+ */
3153
+ async function events(id, params = {}, options = {}) {
3154
+ await transport.require("timeline.events", options);
3155
+ return {
3156
+ data: (await transport.requestParsed(TimelineWithEvents, `/api/timeline/${id}`, {
3157
+ ...options,
3158
+ query: {
3159
+ include: "events",
3160
+ archived: params.archived
3161
+ }
3162
+ })).events,
3163
+ total: null
3164
+ };
3165
+ }
3166
+ /** Create a timeline from a full timeline body. */
3167
+ async function create(params, options = {}) {
3168
+ await transport.require("timeline.create", options);
3169
+ return transport.requestParsed(Timeline, "/api/timeline", {
3170
+ ...options,
3171
+ method: "POST",
3172
+ body: params
3173
+ });
3174
+ }
3175
+ /**
3176
+ * Update a timeline by id, patching only the fields the body carries. Changing `archived`
3177
+ * cascades to every event on the timeline.
3178
+ */
3179
+ async function update(id, params, options = {}) {
3180
+ await transport.require("timeline.update", options);
3181
+ return transport.requestParsed(Timeline, `/api/timeline/${id}`, {
3182
+ ...options,
3183
+ method: "PUT",
3184
+ body: params
3185
+ });
3186
+ }
3187
+ /**
3188
+ * Archive (soft-delete) a timeline and all its events by id. Metabase models this as an update,
3189
+ * not its own endpoint.
3190
+ */
3191
+ async function archive(id, options = {}) {
3192
+ await transport.require("timeline.archive", options);
3193
+ return update(id, { archived: true }, options);
3194
+ }
3195
+ /** Permanently delete a timeline and all its events by id. The server answers with no body. */
3196
+ async function remove(id, options = {}) {
3197
+ await transport.require("timeline.delete", options);
3198
+ await transport.requestRaw(`/api/timeline/${id}`, {
3199
+ ...options,
3200
+ method: "DELETE",
3201
+ expectContentType: "binary"
3202
+ });
3203
+ }
3204
+ return {
3205
+ list,
3206
+ get,
3207
+ events,
3208
+ create,
3209
+ update,
3210
+ archive,
3211
+ delete: remove
3212
+ };
3213
+ }
3214
+ //#endregion
3215
+ //#region ../client/src/domain/transform-dag-run.ts
3216
+ const TransformMemberRun = TransformRun.extend({
3217
+ job_run_id: z.number().int().nullable(),
3218
+ dag_run_id: z.number().int().nullable()
3219
+ });
3220
+ TransformMemberRun.pick({
3221
+ id: true,
3222
+ transform_id: true,
3223
+ dag_run_id: true,
3224
+ status: true,
3225
+ run_method: true,
3226
+ start_time: true,
3227
+ end_time: true,
3228
+ message: true
3229
+ }).strip();
3230
+ //#endregion
3231
+ //#region ../client/src/resources/transform-dag-run.ts
3232
+ const TransformMemberRunList = z.array(TransformMemberRun);
3233
+ function transformDagRunResource(transport) {
3234
+ /**
3235
+ * List the transform runs a DAG run coordinated so far. A member run is inserted when its
3236
+ * transform starts, so the list grows while the DAG run is in progress.
3237
+ */
3238
+ async function transformRuns(runId, options = {}) {
3239
+ await transport.require("transformDagRun.transformRuns", options);
3240
+ return {
3241
+ data: await transport.requestParsed(TransformMemberRunList, `/api/transform-dag-run/${runId}/transform-runs`, { ...options }),
3242
+ total: null
3243
+ };
3244
+ }
3245
+ /** Cancel an in-progress DAG run and request cancellation of its still-running transforms. */
3246
+ async function cancel(runId, options = {}) {
3247
+ await transport.require("transformDagRun.cancel", options);
3248
+ await transport.requestRaw(`/api/transform-dag-run/${runId}/cancel`, {
3249
+ ...options,
3250
+ method: "POST",
3251
+ expectContentType: "binary"
3252
+ });
3253
+ }
3254
+ return {
3255
+ transformRuns,
3256
+ cancel
3257
+ };
3258
+ }
3259
+ //#endregion
3260
+ //#region ../client/src/domain/transform-inspector.ts
3261
+ const InspectorFieldStats = z.object({
3262
+ distinct_count: z.number().int().optional(),
3263
+ nil_percent: z.number().optional(),
3264
+ min: z.number().optional(),
3265
+ max: z.number().optional(),
3266
+ avg: z.number().optional(),
3267
+ q1: z.number().optional(),
3268
+ q3: z.number().optional(),
3269
+ earliest: z.string().optional(),
3270
+ latest: z.string().optional()
3271
+ }).loose();
3272
+ const InspectorField = z.object({
3273
+ id: z.number().int(),
3274
+ name: z.string(),
3275
+ display_name: z.string().nullable().optional(),
3276
+ base_type: z.string(),
3277
+ semantic_type: z.string().nullable().optional(),
3278
+ stats: InspectorFieldStats.nullable().optional()
3279
+ }).loose();
3280
+ const InspectorTable = z.object({
3281
+ table_id: z.number().int(),
3282
+ table_name: z.string(),
3283
+ schema: z.string().nullable().optional(),
3284
+ db_id: z.number().int(),
3285
+ column_count: z.number().int(),
3286
+ fields: z.array(InspectorField)
3287
+ }).loose();
3288
+ const LensComplexityLevel = z.enum([
3289
+ "fast",
3290
+ "slow",
3291
+ "very-slow"
3292
+ ]);
3293
+ const LensComplexity = z.object({
3294
+ level: LensComplexityLevel,
3295
+ score: z.number().int().optional()
3296
+ }).loose();
3297
+ const LensMetadata = z.object({
3298
+ id: z.string(),
3299
+ display_name: z.string(),
3300
+ description: z.string().nullable().optional(),
3301
+ complexity: LensComplexity.optional()
3302
+ }).loose();
3303
+ const TransformInspectionStatus = z.enum(["not-run", "ready"]);
3304
+ const TransformInspection = z.object({
3305
+ name: z.string(),
3306
+ description: z.string().nullable().optional(),
3307
+ status: TransformInspectionStatus,
3308
+ sources: z.array(InspectorTable),
3309
+ target: InspectorTable.nullable().optional(),
3310
+ visited_fields: z.object({ all: z.array(z.number().int()).optional() }).loose().nullable().optional(),
3311
+ available_lenses: z.array(LensMetadata)
3312
+ }).loose();
3313
+ const LensCardDisplay = z.enum([
3314
+ "bar",
3315
+ "row",
3316
+ "line",
3317
+ "area",
3318
+ "pie",
3319
+ "scalar",
3320
+ "gauge",
3321
+ "progress",
3322
+ "table",
3323
+ "hidden"
3324
+ ]);
3325
+ const LensJoinMetadata = z.object({
3326
+ join_step: z.number().int().optional(),
3327
+ join_alias: z.string().optional(),
3328
+ join_strategy: z.string().optional()
3329
+ }).loose();
3330
+ const LensCardMetadata = LensJoinMetadata.extend({
3331
+ dedup_key: z.array(z.unknown()).optional(),
3332
+ depends_on_cards: z.array(z.string()).optional(),
3333
+ group_id: z.string().optional(),
3334
+ group_role: z.enum(["input", "output"]).optional(),
3335
+ group_order: z.number().int().optional(),
3336
+ card_type: z.string().optional()
3337
+ });
3338
+ const LensCard = z.object({
3339
+ id: z.string(),
3340
+ section_id: z.string().nullable().optional(),
3341
+ title: z.string(),
3342
+ display: LensCardDisplay,
3343
+ dataset_query: DatasetQuery,
3344
+ metadata: LensCardMetadata.optional()
3345
+ }).loose();
3346
+ const LensSection = z.object({
3347
+ id: z.string(),
3348
+ title: z.string(),
3349
+ description: z.string().nullable().optional(),
3350
+ layout: z.enum(["flat", "comparison"]).optional()
3351
+ }).loose();
3352
+ const LensHighlight = z.object({
3353
+ label: z.string(),
3354
+ value: z.unknown().optional(),
3355
+ card_id: z.string().optional()
3356
+ }).loose();
3357
+ const LensSummary = z.object({
3358
+ text: z.string().nullable().optional(),
3359
+ highlights: z.array(LensHighlight).optional(),
3360
+ alerts: z.array(z.object({}).loose()).optional()
3361
+ }).loose();
3362
+ const LensTriggerCondition = z.object({ name: z.string() }).loose();
3363
+ const LensAlertTrigger = z.object({
3364
+ id: z.string(),
3365
+ condition: LensTriggerCondition,
3366
+ severity: z.enum([
3367
+ "info",
3368
+ "warning",
3369
+ "error"
3370
+ ]),
3371
+ message: z.string(),
3372
+ metadata: LensJoinMetadata.optional()
3373
+ }).loose();
3374
+ /** The parameters a drill lens takes; `join_step` scopes a join lens to one join. */
3375
+ const LensParams = z.object({ join_step: z.number().int().optional() });
3376
+ const LensDrillTrigger = z.object({
3377
+ lens_id: z.string(),
3378
+ condition: LensTriggerCondition,
3379
+ params: LensParams.loose().optional(),
3380
+ reason: z.string().optional(),
3381
+ metadata: LensJoinMetadata.optional()
3382
+ }).loose();
3383
+ const TransformLens = z.object({
3384
+ id: z.string(),
3385
+ display_name: z.string(),
3386
+ complexity: LensComplexity.optional(),
3387
+ summary: LensSummary.optional(),
3388
+ sections: z.array(LensSection),
3389
+ cards: z.array(LensCard),
3390
+ drill_lenses: z.array(LensMetadata).optional(),
3391
+ alert_triggers: z.array(LensAlertTrigger).optional(),
3392
+ drill_lens_triggers: z.array(LensDrillTrigger).optional()
3393
+ }).loose();
3394
+ z.object({
3395
+ query: DatasetQuery,
3396
+ lens_params: LensParams.nullable().optional()
3397
+ }).strict();
3398
+ //#endregion
3399
+ //#region ../client/src/resources/transform-inspector.ts
3400
+ function lensPath(id, lensId) {
3401
+ return `/api/ee/transforms/${id}/inspect/${encodeURIComponent(lensId)}`;
3402
+ }
3403
+ function transformInspectorResource(transport) {
3404
+ /**
3405
+ * Discover what the inspector can show for a transform: its source and target tables with field
3406
+ * statistics, the fields its query touches, and the lenses available on it.
3407
+ */
3408
+ async function discover(id, options = {}) {
3409
+ await transport.require("transformInspector.discover", options);
3410
+ return transport.requestParsed(TransformInspection, `/api/ee/transforms/${id}/inspect`, { ...options });
3411
+ }
3412
+ /**
3413
+ * Open one lens on a transform: its sections, the cards with the queries that fill them, and
3414
+ * the alert and drill-lens triggers to evaluate against the card results. A drill lens takes
3415
+ * the `params` its trigger emitted.
3416
+ */
3417
+ async function lens(id, lensId, params = {}, options = {}) {
3418
+ await transport.require("transformInspector.lens", options);
3419
+ return transport.requestParsed(TransformLens, lensPath(id, lensId), {
3420
+ ...options,
3421
+ query: { join_step: params.join_step }
3422
+ });
3423
+ }
3424
+ /**
3425
+ * Run a lens card's query in the context of the lens, so the execution is attributed to the
3426
+ * inspector. The body is the card's `dataset_query`, and the same `lens_params` the lens was
3427
+ * opened with.
3428
+ */
3429
+ async function query(id, lensId, params, options = {}) {
3430
+ await transport.require("transformInspector.query", options);
3431
+ return transport.requestParsed(CardQueryResult, `${lensPath(id, lensId)}/query`, {
3432
+ ...options,
3433
+ method: "POST",
3434
+ body: params
3435
+ });
3436
+ }
3437
+ return {
3438
+ discover,
3439
+ lens,
3440
+ query
3441
+ };
3442
+ }
3443
+ //#endregion
3444
+ //#region ../client/src/resources/transform-job.ts
3445
+ function transformJobResource(transport) {
3446
+ /** List every transform job the caller can see. */
3447
+ async function list(options = {}) {
3448
+ await transport.require("transformJob.list", options);
3449
+ const { features } = await transport.server(options);
3450
+ return {
3451
+ data: await transport.requestParsed(z.array(transformJobSchema(features)), "/api/transform-job", { ...options }),
3452
+ total: null
3453
+ };
3454
+ }
3455
+ /** Get one transform job by id. */
3456
+ async function get(id, options = {}) {
3457
+ await transport.require("transformJob.get", options);
3458
+ const { features } = await transport.server(options);
3459
+ return transport.requestParsed(transformJobSchema(features), `/api/transform-job/${id}`, { ...options });
3460
+ }
3461
+ /** Create a transform job — a schedule plus the tags it runs — from a full body. */
3462
+ async function create(params, options = {}) {
3463
+ await transport.require("transformJob.create", options);
3464
+ const { features } = await transport.server(options);
3465
+ return transport.requestParsed(transformJobSchema(features), "/api/transform-job", {
3466
+ ...options,
3467
+ method: "POST",
3468
+ body: params
3469
+ });
3470
+ }
3471
+ /** Update a transform job by id, patching only the fields the body carries. */
3472
+ async function update(id, params, options = {}) {
3473
+ await transport.require("transformJob.update", options);
3474
+ const { features } = await transport.server(options);
3475
+ return transport.requestParsed(transformJobSchema(features), `/api/transform-job/${id}`, {
3476
+ ...options,
3477
+ method: "PUT",
3478
+ body: params
3479
+ });
3480
+ }
3481
+ /** Delete a transform job by id, leaving the transforms it ran untouched. */
3482
+ async function remove(id, options = {}) {
3483
+ await transport.require("transformJob.delete", options);
3484
+ await transport.requestRaw(`/api/transform-job/${id}`, {
3485
+ ...options,
3486
+ method: "DELETE",
3487
+ expectContentType: "binary"
3488
+ });
3489
+ }
3490
+ /**
3491
+ * Start a run of a transform job by id. The job runs every transform carrying one of its tags,
3492
+ * plus those transforms' dependencies; `run_all` re-runs dependencies that are already fresh.
3493
+ */
3494
+ async function run(id, params = {}, options = {}) {
3495
+ await transport.require("transformJob.run", options);
3496
+ const { features } = await transport.server(options);
3497
+ return transport.requestParsed(transformJobRunResultSchema(features), `/api/transform-job/${id}/run`, {
3498
+ ...options,
3499
+ method: "POST",
3500
+ body: { run_all: params.run_all }
3501
+ });
3502
+ }
3503
+ /** List the transforms a job would execute, resolved from the job's tags. */
3504
+ async function transforms(id, options = {}) {
3505
+ await transport.require("transformJob.transforms", options);
3506
+ const { features } = await transport.server(options);
3507
+ return {
3508
+ data: await transport.requestParsed(z.array(transformRowSchema(features)), `/api/transform-job/${id}/transforms`, { ...options }),
3509
+ total: null
3510
+ };
3511
+ }
3512
+ /**
3513
+ * Flip the active flag on every transform job at once. Inactive jobs do not run on schedule;
3514
+ * manual runs ignore the flag. The path carries no id and is a different endpoint from `update`.
3515
+ */
3516
+ async function setActive(active, options = {}) {
3517
+ await transport.require("transformJob.setActive", options);
3518
+ return transport.requestParsed(TransformJobActiveResult, "/api/transform-job/active", {
3519
+ ...options,
3520
+ method: "PUT",
3521
+ body: { active }
3522
+ });
3523
+ }
3524
+ return {
3525
+ list,
3526
+ get,
3527
+ create,
3528
+ update,
3529
+ delete: remove,
3530
+ run,
3531
+ transforms,
3532
+ setActive
3533
+ };
3534
+ }
3535
+ //#endregion
3536
+ //#region ../client/src/domain/transform-python.ts
3537
+ const PythonLibrary = z.object({
3538
+ path: z.string(),
3539
+ source: z.string().nullable(),
3540
+ created_at: z.string(),
3541
+ updated_at: z.string()
3542
+ }).loose();
3543
+ z.object({ source: z.string() }).strict();
3544
+ const TEST_RUN_ROW_LIMIT = {
3545
+ min: 2,
3546
+ max: 100
3547
+ };
3548
+ const TestRunRowLimit = z.number().int().min(TEST_RUN_ROW_LIMIT.min).max(TEST_RUN_ROW_LIMIT.max);
3549
+ z.object({
3550
+ code: z.string(),
3551
+ source_tables: z.array(TransformSourceTableEntry).min(1),
3552
+ output_row_limit: TestRunRowLimit.optional(),
3553
+ per_input_row_limit: TestRunRowLimit.optional()
3554
+ }).strict();
3555
+ const PythonTestRunOutput = z.object({
3556
+ cols: z.array(z.object({ name: z.string() }).loose()),
3557
+ rows: z.array(z.unknown())
3558
+ });
3559
+ const PythonTestRunError = z.object({ message: z.string() }).loose();
3560
+ const PythonTestRunSucceeded = z.object({
3561
+ outcome: z.literal("succeeded"),
3562
+ logs: z.string(),
3563
+ output: PythonTestRunOutput
3564
+ });
3565
+ const PythonTestRunFailed = z.object({
3566
+ outcome: z.literal("failed"),
3567
+ logs: z.string(),
3568
+ error: PythonTestRunError
3569
+ });
3570
+ z.discriminatedUnion("outcome", [PythonTestRunSucceeded, PythonTestRunFailed]);
3571
+ //#endregion
3572
+ //#region ../client/src/resources/transform-python.ts
3573
+ const PythonApiTestRun = z.union([z.object({
3574
+ logs: z.string(),
3575
+ output: PythonTestRunOutput
3576
+ }).transform(({ logs, output }) => ({
3577
+ outcome: "succeeded",
3578
+ logs,
3579
+ output
3580
+ })), z.object({
3581
+ logs: z.string(),
3582
+ error: PythonTestRunError
3583
+ }).transform(({ logs, error }) => ({
3584
+ outcome: "failed",
3585
+ logs,
3586
+ error
3587
+ }))]);
3588
+ function libraryPath(path) {
3589
+ return `/api/ee/transforms-python/library/${encodeURIComponent(path)}`;
3590
+ }
3591
+ function transformPythonResource(transport) {
3592
+ /** Get the Python library at a path, the user module every Python transform can import. */
3593
+ async function getLibrary(path, options = {}) {
3594
+ await transport.require("transformPython.getLibrary", options);
3595
+ return transport.requestParsed(PythonLibrary, libraryPath(path), { ...options });
3596
+ }
3597
+ /** Replace the source of the Python library at a path, creating the library when none exists. */
3598
+ async function updateLibrary(path, params, options = {}) {
3599
+ await transport.require("transformPython.updateLibrary", options);
3600
+ return transport.requestParsed(PythonLibrary, libraryPath(path), {
3601
+ ...options,
3602
+ method: "PUT",
3603
+ body: params
3604
+ });
3605
+ }
3606
+ /**
3607
+ * Evaluate an ad-hoc Python transform on a sample of its source tables, without a target table.
3608
+ * Meant for early feedback on short runs: input, output and time limits apply, and the sample
3609
+ * sizes are capped at 100 rows.
3610
+ */
3611
+ async function testRun(params, options = {}) {
3612
+ await transport.require("transformPython.testRun", options);
3613
+ return transport.requestParsed(PythonApiTestRun, "/api/ee/transforms-python/test-run", {
3614
+ ...options,
3615
+ method: "POST",
3616
+ body: params
3617
+ });
3618
+ }
3619
+ return {
3620
+ getLibrary,
3621
+ updateLibrary,
3622
+ testRun
3623
+ };
3624
+ }
3625
+ //#endregion
3626
+ //#region ../client/src/resources/transform.ts
3627
+ function transformListSchema(features) {
3628
+ return z.array(transformRowSchema(features));
3629
+ }
3630
+ const TransformRunKickoff = z.object({
3631
+ message: z.string(),
3632
+ run_id: z.number().int().positive().nullable()
3633
+ });
3634
+ const TransformDagTransformList = z.array(TransformDagTransform);
3635
+ function transformResource(transport) {
3636
+ async function requestTransformList(path, opts) {
3637
+ const { features } = await transport.server(opts);
3638
+ return {
3639
+ data: await transport.requestParsed(transformListSchema(features), path, opts),
3640
+ total: null
3641
+ };
3642
+ }
3643
+ async function requestTransform(path, opts) {
3644
+ const { features } = await transport.server(opts);
3645
+ return transport.requestParsed(transformRowSchema(features), path, opts);
3646
+ }
3647
+ /** List every transform the caller can see. */
3648
+ async function list(options = {}) {
3649
+ await transport.require("transform.list", options);
3650
+ return requestTransformList("/api/transform", { ...options });
3651
+ }
3652
+ /** Get one transform by id. */
3653
+ async function get(id, options = {}) {
3654
+ await transport.require("transform.get", options);
3655
+ const { features } = await transport.server(options);
3656
+ return transport.requestParsed(transformDetailSchema(features), `/api/transform/${id}`, { ...options });
3657
+ }
3658
+ /** Create a transform — a query plus the warehouse table it writes — from a full body. */
3659
+ async function create(params, options = {}) {
3660
+ await transport.require("transform.create", options);
3661
+ return requestTransform("/api/transform", {
3662
+ ...options,
3663
+ method: "POST",
3664
+ body: params
3665
+ });
3666
+ }
3667
+ /** Update a transform by id, patching only the fields the body carries. */
3668
+ async function update(id, params, options = {}) {
3669
+ await transport.require("transform.update", options);
3670
+ return requestTransform(`/api/transform/${id}`, {
3671
+ ...options,
3672
+ method: "PUT",
3673
+ body: params
3674
+ });
3675
+ }
3676
+ /** Delete a transform by id, leaving any table it already materialized in place. */
3677
+ async function remove(id, options = {}) {
3678
+ await transport.require("transform.delete", options);
3679
+ await transport.requestRaw(`/api/transform/${id}`, {
3680
+ ...options,
3681
+ method: "DELETE",
3682
+ expectContentType: "binary"
3683
+ });
3684
+ }
3685
+ /** Drop a transform's materialized output table, keeping the transform definition. */
3686
+ async function deleteTable(id, options = {}) {
3687
+ await transport.require("transform.deleteTable", options);
3688
+ await transport.requestRaw(`/api/transform/${id}/table`, {
3689
+ ...options,
3690
+ method: "DELETE",
3691
+ expectContentType: "binary"
3692
+ });
3693
+ }
3694
+ /** List the upstream transforms a transform depends on. */
3695
+ async function dependencies(id, options = {}) {
3696
+ await transport.require("transform.dependencies", options);
3697
+ return requestTransformList(`/api/transform/${id}/dependencies`, { ...options });
3698
+ }
3699
+ /** Request cancellation of a transform's current run. */
3700
+ async function cancel(id, options = {}) {
3701
+ await transport.require("transform.cancel", options);
3702
+ await transport.requestRaw(`/api/transform/${id}/cancel`, {
3703
+ ...options,
3704
+ method: "POST",
3705
+ expectContentType: "binary"
3706
+ });
3707
+ }
3708
+ /** Get one transform run by run id — not by the id of the transform that produced it. */
3709
+ async function getRun(runId, options = {}) {
3710
+ await transport.require("transform.getRun", options);
3711
+ return transport.requestParsed(TransformRun, `/api/transform/run/${runId}`, { ...options });
3712
+ }
3713
+ /** Walk the run history, newest first, optionally narrowed to a single transform. */
3714
+ async function* runPages(params = {}, options = {}) {
3715
+ await transport.require("transform.runPages", options);
3716
+ yield* paginatePages(transport, "/api/transform/run", TransformRun, {
3717
+ query: { "transform-ids": params["transform-ids"] },
3718
+ ...options.offset !== void 0 && { offset: options.offset },
3719
+ ...options.max !== void 0 && { max: options.max },
3720
+ ...options.pageSize !== void 0 && { pageSize: options.pageSize },
3721
+ ...options.signal !== void 0 && { signal: options.signal }
3722
+ });
3723
+ }
3724
+ /**
3725
+ * Walk the unified run history, newest first by default: every row is a root run — a job run, a
3726
+ * DAG reprocess run, or a standalone transform run — and never a member run of a job or DAG.
3727
+ */
3728
+ async function* runSummaryPages(params = {}, options = {}) {
3729
+ await transport.require("transform.runSummaryPages", options);
3730
+ yield* paginatePages(transport, "/api/transform/runs", TransformRunSummary, {
3731
+ query: {
3732
+ types: params.types,
3733
+ statuses: params.statuses,
3734
+ "run-methods": params["run-methods"],
3735
+ "start-time": params["start-time"],
3736
+ "end-time": params["end-time"],
3737
+ "transform-ids": params["transform-ids"],
3738
+ "sort-column": params["sort-column"],
3739
+ "sort-direction": params["sort-direction"]
3740
+ },
3741
+ ...options.offset !== void 0 && { offset: options.offset },
3742
+ ...options.max !== void 0 && { max: options.max },
3743
+ ...options.pageSize !== void 0 && { pageSize: options.pageSize },
3744
+ ...options.signal !== void 0 && { signal: options.signal }
3745
+ });
3746
+ }
3747
+ /**
3748
+ * Reset the stored checkpoint of an incremental transform, so its next run reprocesses the whole
3749
+ * source rather than the rows past the last checkpoint.
3750
+ */
3751
+ async function resetCheckpoint(id, options = {}) {
3752
+ await transport.require("transform.resetCheckpoint", options);
3753
+ await transport.requestRaw(`/api/transform/${id}/reset-checkpoint`, {
3754
+ ...options,
3755
+ method: "POST",
3756
+ expectContentType: "binary"
3757
+ });
3758
+ }
3759
+ /**
3760
+ * Start a DAG reprocess run seeded at a transform: the transform plus, by `direction`, every
3761
+ * transform it transitively depends on or every transform that transitively depends on it. The
3762
+ * server answers at once with the run's id, or null when it ran nothing because a DAG run for
3763
+ * this transform is already in progress or the closure is empty. Progress is read off
3764
+ * `runSummaryPages` with `types: ["dag"]`, and the member runs off `transformDagRun.transformRuns`.
3765
+ */
3766
+ async function runDag(id, params, options = {}) {
3767
+ await transport.require("transform.runDag", options);
3768
+ return transport.requestParsed(TransformDagRunResult, `/api/transform/${id}/run-dag`, {
3769
+ ...options,
3770
+ method: "POST",
3771
+ body: { direction: params.direction }
3772
+ });
3773
+ }
3774
+ /** Preview the transforms a DAG reprocess seeded at a transform would run, in execution order. */
3775
+ async function dagTransforms(id, params, options = {}) {
3776
+ await transport.require("transform.dagTransforms", options);
3777
+ return {
3778
+ data: await transport.requestParsed(TransformDagTransformList, `/api/transform/${id}/dag-transforms`, {
3779
+ ...options,
3780
+ query: { direction: params.direction }
3781
+ }),
3782
+ total: null
3783
+ };
3784
+ }
3785
+ /**
3786
+ * Start a run of a transform by id. The server queues the run and answers at once; `wait` polls
3787
+ * it to a terminal status, and `syncTarget` follows that with the output table's registration.
3788
+ * A server that answers no run id started nothing, and there is then nothing to poll.
3789
+ */
3790
+ async function run(id, params = {}, options = {}) {
3791
+ await transport.require("transform.run", options);
3792
+ const kickoff = await transport.requestParsed(TransformRunKickoff, `/api/transform/${id}/run`, {
3793
+ ...options,
3794
+ method: "POST"
3795
+ });
3796
+ const schedule = params.syncTarget === true ? params.wait ?? {} : params.wait;
3797
+ if (schedule === void 0 || kickoff.run_id === null) return {
3798
+ message: kickoff.message,
3799
+ run_id: kickoff.run_id,
3800
+ final: null
3801
+ };
3802
+ const runId = kickoff.run_id;
3803
+ const final = await pollUntil(async (signal) => getRun(runId, {
3804
+ ...options,
3805
+ signal
3806
+ }), (candidate) => isTransformRunTerminal(candidate.status), schedule);
3807
+ if (params.syncTarget !== true) return {
3808
+ message: kickoff.message,
3809
+ run_id: runId,
3810
+ final
3811
+ };
3812
+ const targetTableId = isTransformRunFailed(final.status) ? null : await awaitTargetTableId(id, schedule, options);
3813
+ return {
3814
+ message: kickoff.message,
3815
+ run_id: runId,
3816
+ final,
3817
+ target_table_id: targetTableId
3818
+ };
3819
+ }
3820
+ async function awaitTargetTableId(id, wait, options) {
3821
+ try {
3822
+ return (await pollUntil(async (signal) => get(id, {
3823
+ ...options,
3824
+ signal
3825
+ }), (transform) => transform.target_table_id !== null, wait)).target_table_id;
3826
+ } catch (error) {
3827
+ if (error instanceof TimeoutError) return null;
3828
+ throw error;
3829
+ }
3830
+ }
3831
+ return {
3832
+ list,
3833
+ get,
3834
+ create,
3835
+ update,
3836
+ delete: remove,
3837
+ deleteTable,
3838
+ dependencies,
3839
+ cancel,
3840
+ getRun,
3841
+ runPages,
3842
+ runSummaryPages,
3843
+ resetCheckpoint,
3844
+ runDag,
3845
+ dagTransforms,
3846
+ run
3847
+ };
3848
+ }
3849
+ //#endregion
3850
+ //#region ../client/src/resources/transform-tag.ts
3851
+ const TransformTagApiList = z.array(TransformTag);
3852
+ function transformTagResource(transport) {
3853
+ /** List every transform tag the caller can see, built-in tags included. */
3854
+ async function list(options = {}) {
3855
+ await transport.require("transformTag.list", options);
3856
+ return {
3857
+ data: await transport.requestParsed(TransformTagApiList, "/api/transform-tag", { ...options }),
3858
+ total: null
3859
+ };
3860
+ }
3861
+ /** Create a transform tag, the label a transform job matches transforms on. */
3862
+ async function create(params, options = {}) {
3863
+ await transport.require("transformTag.create", options);
3864
+ return transport.requestParsed(TransformTag, "/api/transform-tag", {
3865
+ ...options,
3866
+ method: "POST",
3867
+ body: params
3868
+ });
3869
+ }
3870
+ /** Rename a transform tag by id. */
3871
+ async function update(id, params, options = {}) {
3872
+ await transport.require("transformTag.update", options);
3873
+ return transport.requestParsed(TransformTag, `/api/transform-tag/${id}`, {
3874
+ ...options,
3875
+ method: "PUT",
3876
+ body: params
3877
+ });
3878
+ }
3879
+ /** Delete a transform tag by id, detaching it from every transform and job carrying it. */
3880
+ async function remove(id, options = {}) {
3881
+ await transport.require("transformTag.delete", options);
3882
+ await transport.requestRaw(`/api/transform-tag/${id}`, {
3883
+ ...options,
3884
+ method: "DELETE",
3885
+ expectContentType: "binary"
3886
+ });
3887
+ }
3888
+ return {
3889
+ list,
3890
+ create,
3891
+ update,
3892
+ delete: remove
3893
+ };
3894
+ }
3895
+ //#endregion
3896
+ //#region ../client/src/resources/transform-test.ts
3897
+ const TransformTestApiList = z.array(TransformTest);
3898
+ function transformTestResource(transport) {
3899
+ /** List the transform tests, optionally only those of one transform. */
3900
+ async function list(params = {}, options = {}) {
3901
+ await transport.require("transformTest.list", options);
3902
+ return {
3903
+ data: await transport.requestParsed(TransformTestApiList, "/api/ee/transform-test", {
3904
+ ...options,
3905
+ query: { "transform-id": params["transform-id"] }
3906
+ }),
3907
+ total: null
3908
+ };
3909
+ }
3910
+ /** Get a transform test by id. */
3911
+ async function get(id, options = {}) {
3912
+ await transport.require("transformTest.get", options);
3913
+ return transport.requestParsed(TransformTest, `/api/ee/transform-test/${id}`, { ...options });
3914
+ }
3915
+ /**
3916
+ * Create a transform test. The server validates the inputs and expectations against the
3917
+ * transform before saving, and refuses with an `HttpError` whose `errorCode` is a
3918
+ * `TransformTestRefusalCode` when they cannot run.
3919
+ */
3920
+ async function create(params, options = {}) {
3921
+ await transport.require("transformTest.create", options);
3922
+ return transport.requestParsed(TransformTest, "/api/ee/transform-test", {
3923
+ ...options,
3924
+ method: "POST",
3925
+ body: params
3926
+ });
3927
+ }
3928
+ /**
3929
+ * Update a transform test by id, leaving omitted fields unchanged. A body that touches the
3930
+ * transform, inputs or expectations is validated as on create, with the same refusal.
3931
+ */
3932
+ async function update(id, params, options = {}) {
3933
+ await transport.require("transformTest.update", options);
3934
+ return transport.requestParsed(TransformTest, `/api/ee/transform-test/${id}`, {
3935
+ ...options,
3936
+ method: "PUT",
3937
+ body: params
3938
+ });
3939
+ }
3940
+ /** Delete a transform test by id. */
3941
+ async function remove(id, options = {}) {
3942
+ await transport.require("transformTest.delete", options);
3943
+ await transport.requestRaw(`/api/ee/transform-test/${id}`, {
3944
+ ...options,
3945
+ method: "DELETE",
3946
+ expectContentType: "binary"
3947
+ });
3948
+ }
3949
+ /**
3950
+ * Run a transform test by id. A result means the run happened: `status` is `passed` or `failed`
3951
+ * and every expectation reports what it found, one that could not be evaluated as its own
3952
+ * `error`. An `HttpError` whose `errorCode` is a `TransformTestRefusalCode` means the run was
3953
+ * refused and nothing meaningful ran.
3954
+ */
3955
+ async function run(id, options = {}) {
3956
+ await transport.require("transformTest.run", options);
3957
+ return transport.requestParsed(TransformTestRunResult, `/api/ee/transform-test/${id}/run`, {
3958
+ ...options,
3959
+ method: "POST"
3960
+ });
3961
+ }
3962
+ return {
3963
+ list,
3964
+ get,
3965
+ create,
3966
+ update,
3967
+ delete: remove,
3968
+ run
3969
+ };
3970
+ }
3971
+ //#endregion
3972
+ //#region ../client/src/resources/upload.ts
3973
+ const UPLOAD_TABLE_ID_HEADER = "metabase-table-id";
3974
+ function uploadResource(transport) {
3975
+ /**
3976
+ * Create a table and model populated with the values from the attached CSV. Returns the model ID
3977
+ * if successful.
3978
+ *
3979
+ * The file may be at most 50 MB; larger uploads are rejected with a 413 response.
3980
+ */
3981
+ async function createFromCsv(file, params, options = {}) {
3982
+ await transport.require("upload.createFromCsv", options);
3983
+ const form = buildCsvFormData(file);
3984
+ form.append("collection_id", params.collection_id);
3985
+ const response = await transport.requestRaw("/api/upload/csv", {
3986
+ ...options,
3987
+ method: "POST",
3988
+ body: form,
3989
+ expectContentType: "binary"
3990
+ });
3991
+ return parseCreateUploadResult(await response.text(), response.headers);
3992
+ }
3993
+ return { createFromCsv };
3994
+ }
3995
+ function parseCreateUploadResult(bodyText, headers) {
3996
+ return UploadResult.parse({
3997
+ model_id: parseResponseInteger(bodyText, "response body"),
3998
+ table_id: parseResponseInteger(headers.get(UPLOAD_TABLE_ID_HEADER), `${UPLOAD_TABLE_ID_HEADER} header`)
3999
+ });
4000
+ }
4001
+ function parseResponseInteger(value, source) {
4002
+ const trimmed = value?.trim() ?? "";
4003
+ if (trimmed === "") throw new ResponseShapeError(`upload succeeded but the ${source} was empty`, {
4004
+ kind: "decoded",
4005
+ source,
4006
+ value
4007
+ });
4008
+ const parsed = Number(trimmed);
4009
+ if (!Number.isInteger(parsed)) throw new ResponseShapeError(`upload succeeded but the ${source} was not an integer: ${JSON.stringify(trimmed)}`, {
4010
+ kind: "decoded",
4011
+ source,
4012
+ value
4013
+ });
4014
+ return parsed;
4015
+ }
4016
+ //#endregion
4017
+ //#region ../client/src/domain/user.ts
4018
+ const CurrentUser = z.object({
4019
+ id: z.number().int(),
4020
+ email: z.email(),
4021
+ common_name: z.string(),
4022
+ is_superuser: z.boolean()
4023
+ }).loose();
4024
+ CurrentUser.pick({
4025
+ id: true,
4026
+ email: true,
4027
+ common_name: true,
4028
+ is_superuser: true
4029
+ }).strip();
4030
+ //#endregion
4031
+ //#region ../client/src/resources/user.ts
4032
+ function userResource(transport) {
4033
+ /** Get the user the request's credentials authenticate as. */
4034
+ async function current(options = {}) {
4035
+ await transport.require("user.current", options);
4036
+ return transport.requestParsed(CurrentUser, "/api/user/current", { ...options });
4037
+ }
4038
+ return { current };
4039
+ }
4040
+ //#endregion
4041
+ //#region ../client/src/client.ts
4042
+ var client_exports = /* @__PURE__ */ __exportAll({ createClient: () => createClient });
4043
+ function createClient(config, options) {
4044
+ const transport = createTransport(config, options);
4045
+ return {
4046
+ card: cardResource(transport),
4047
+ collection: collectionResource(transport),
4048
+ contentTranslation: contentTranslationResource(transport),
4049
+ dashboard: dashboardResource(transport),
4050
+ database: databaseResource(transport),
4051
+ dataset: datasetResource(transport),
4052
+ dependency: dependencyResource(transport),
4053
+ document: documentResource(transport),
4054
+ eidTranslation: eidTranslationResource(transport),
4055
+ erd: erdResource(transport),
4056
+ field: fieldResource(transport),
4057
+ gitSync: gitSyncResource(transport),
4058
+ glossary: glossaryResource(transport),
4059
+ library: libraryResource(transport),
4060
+ measure: measureResource(transport),
4061
+ metric: metricResource(transport),
4062
+ moderationReview: moderationReviewResource(transport),
4063
+ notification: notificationResource(transport),
4064
+ permission: permissionResource(transport),
4065
+ pulse: pulseResource(transport),
4066
+ replacement: replacementResource(transport),
4067
+ revision: revisionResource(transport),
4068
+ search: searchResource(transport),
4069
+ segment: segmentResource(transport),
4070
+ setting: settingResource(transport),
4071
+ setup: setupResource(transport),
4072
+ snippet: snippetResource(transport),
4073
+ table: tableResource(transport),
4074
+ timeline: timelineResource(transport),
4075
+ timelineEvent: timelineEventResource(transport),
4076
+ transform: transformResource(transport),
4077
+ transformDagRun: transformDagRunResource(transport),
4078
+ transformInspector: transformInspectorResource(transport),
4079
+ transformJob: transformJobResource(transport),
4080
+ transformPython: transformPythonResource(transport),
4081
+ transformTag: transformTagResource(transport),
4082
+ transformTest: transformTestResource(transport),
4083
+ upload: uploadResource(transport),
4084
+ user: userResource(transport),
4085
+ server: transport.server,
4086
+ requestParsed: transport.requestParsed,
4087
+ requestRaw: transport.requestRaw,
4088
+ requestStream: transport.requestStream
4089
+ };
4090
+ }
4091
+ //#endregion
4092
+ export { createClient as n, client_exports as t };