@metabase/cli 0.3.1 → 0.3.2-alpha.fix-transform-test-ee-path.8ac2a7a

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