@metabase/client 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +661 -0
  3. package/README.md +488 -2
  4. package/dist/auth/credential.d.ts +2 -0
  5. package/dist/auth/credential.js +61 -0
  6. package/dist/auth/oauth-login.d.ts +2 -0
  7. package/dist/auth/oauth-login.js +2 -0
  8. package/dist/auth/oauth-session.d.ts +2 -0
  9. package/dist/auth/oauth-session.js +31 -0
  10. package/dist/card-B6merEUN.d.ts +1392 -0
  11. package/dist/card-BZx4NSr-.d.ts +33 -0
  12. package/dist/client-DNRvXFRm.d.ts +3276 -0
  13. package/dist/client.d.ts +2 -0
  14. package/dist/client.js +95 -0
  15. package/dist/collection-Bib61WiV.d.ts +294 -0
  16. package/dist/collection-CqtGPi4W.d.ts +39 -0
  17. package/dist/content-translation-zfUkE_OG.d.ts +8 -0
  18. package/dist/credential-6aOEGqMH.d.ts +30 -0
  19. package/dist/cron-DThzerR6.d.ts +9 -0
  20. package/dist/csv-upload--K35QedP.d.ts +8 -0
  21. package/dist/dashboard-XTe46250.d.ts +38 -0
  22. package/dist/dashboard-z9i1VUZC.d.ts +970 -0
  23. package/dist/data-action-rS27f2Ji.d.ts +95 -0
  24. package/dist/database-BLUMlywE.d.ts +997 -0
  25. package/dist/database-DqTespfa.d.ts +27 -0
  26. package/dist/dataset-C6lX1-cr.d.ts +4144 -0
  27. package/dist/dataset-Cj3XuKLe.d.ts +23 -0
  28. package/dist/dependency-D8Qs5Xdx.d.ts +827 -0
  29. package/dist/dependency-fN5_7a22.d.ts +299 -0
  30. package/dist/document-oZNDbDfx.d.ts +115 -0
  31. package/dist/domain/card.d.ts +2 -0
  32. package/dist/domain/card.js +140 -0
  33. package/dist/domain/collection.d.ts +2 -0
  34. package/dist/domain/collection.js +137 -0
  35. package/dist/domain/content-translation.d.ts +2 -0
  36. package/dist/domain/content-translation.js +5 -0
  37. package/dist/domain/cron.d.ts +2 -0
  38. package/dist/domain/cron.js +5 -0
  39. package/dist/domain/dashboard.d.ts +2 -0
  40. package/dist/domain/dashboard.js +194 -0
  41. package/dist/domain/data-action.d.ts +2 -0
  42. package/dist/domain/data-action.js +85 -0
  43. package/dist/domain/database.d.ts +2 -0
  44. package/dist/domain/database.js +56 -0
  45. package/dist/domain/dataset.d.ts +2 -0
  46. package/dist/domain/dataset.js +56 -0
  47. package/dist/domain/dependency.d.ts +2 -0
  48. package/dist/domain/dependency.js +165 -0
  49. package/dist/domain/document.d.ts +2 -0
  50. package/dist/domain/document.js +94 -0
  51. package/dist/domain/eid-translation.d.ts +2 -0
  52. package/dist/domain/eid-translation.js +36 -0
  53. package/dist/domain/embedding.d.ts +2 -0
  54. package/dist/domain/embedding.js +9 -0
  55. package/dist/domain/erd.d.ts +2 -0
  56. package/dist/domain/erd.js +45 -0
  57. package/dist/domain/field.d.ts +2 -0
  58. package/dist/domain/field.js +268 -0
  59. package/dist/domain/git-sync.d.ts +2 -0
  60. package/dist/domain/git-sync.js +147 -0
  61. package/dist/domain/glossary.d.ts +2 -0
  62. package/dist/domain/glossary.js +30 -0
  63. package/dist/domain/library.d.ts +2 -0
  64. package/dist/domain/library.js +83 -0
  65. package/dist/domain/measure.d.ts +2 -0
  66. package/dist/domain/measure.js +41 -0
  67. package/dist/domain/metric.d.ts +2 -0
  68. package/dist/domain/metric.js +139 -0
  69. package/dist/domain/moderation-review.d.ts +2 -0
  70. package/dist/domain/moderation-review.js +31 -0
  71. package/dist/domain/notification.d.ts +2 -0
  72. package/dist/domain/notification.js +138 -0
  73. package/dist/domain/parameter.d.ts +2 -0
  74. package/dist/domain/parameter.js +109 -0
  75. package/dist/domain/permission.d.ts +2 -0
  76. package/dist/domain/permission.js +36 -0
  77. package/dist/domain/pulse.d.ts +2 -0
  78. package/dist/domain/pulse.js +133 -0
  79. package/dist/domain/query.d.ts +2 -0
  80. package/dist/domain/query.js +13 -0
  81. package/dist/domain/replacement.d.ts +2 -0
  82. package/dist/domain/replacement.js +93 -0
  83. package/dist/domain/revision.d.ts +2 -0
  84. package/dist/domain/revision.js +63 -0
  85. package/dist/domain/search.d.ts +2 -0
  86. package/dist/domain/search.js +63 -0
  87. package/dist/domain/segment.d.ts +2 -0
  88. package/dist/domain/segment.js +44 -0
  89. package/dist/domain/session-properties.d.ts +2 -0
  90. package/dist/domain/session-properties.js +14 -0
  91. package/dist/domain/setting.d.ts +2 -0
  92. package/dist/domain/setting.js +22 -0
  93. package/dist/domain/setup.d.ts +2 -0
  94. package/dist/domain/setup.js +21 -0
  95. package/dist/domain/snippet.d.ts +2 -0
  96. package/dist/domain/snippet.js +38 -0
  97. package/dist/domain/table.d.ts +2 -0
  98. package/dist/domain/table.js +156 -0
  99. package/dist/domain/text.d.ts +5 -0
  100. package/dist/domain/text.js +6 -0
  101. package/dist/domain/timeline.d.ts +2 -0
  102. package/dist/domain/timeline.js +97 -0
  103. package/dist/domain/transform-dag-run.d.ts +2 -0
  104. package/dist/domain/transform-dag-run.js +19 -0
  105. package/dist/domain/transform-inspector.d.ts +2 -0
  106. package/dist/domain/transform-inspector.js +142 -0
  107. package/dist/domain/transform-job.d.ts +2 -0
  108. package/dist/domain/transform-job.js +109 -0
  109. package/dist/domain/transform-python.d.ts +2 -0
  110. package/dist/domain/transform-python.js +39 -0
  111. package/dist/domain/transform-tag.d.ts +2 -0
  112. package/dist/domain/transform-tag.js +17 -0
  113. package/dist/domain/transform-test.d.ts +2 -0
  114. package/dist/domain/transform-test.js +176 -0
  115. package/dist/domain/transform.d.ts +2 -0
  116. package/dist/domain/transform.js +235 -0
  117. package/dist/domain/upload.d.ts +2 -0
  118. package/dist/domain/upload.js +13 -0
  119. package/dist/domain/user.d.ts +2 -0
  120. package/dist/domain/user.js +16 -0
  121. package/dist/eid-translation-nuhr8St2.d.ts +143 -0
  122. package/dist/embedding-Cz3RUJYf.d.ts +10 -0
  123. package/dist/erd-BdeFEeSy.d.ts +842 -0
  124. package/dist/erd-BujD227Y.d.ts +51 -0
  125. package/dist/errors-DdMlaXqq.js +330 -0
  126. package/dist/errors.d.ts +2 -0
  127. package/dist/errors.js +189 -0
  128. package/dist/features-CnFkUCj2.d.ts +261 -0
  129. package/dist/field-BCRO19mk.d.ts +2547 -0
  130. package/dist/field-Bqn10Fq_.d.ts +50 -0
  131. package/dist/git-sync-DNXrNVCW.d.ts +258 -0
  132. package/dist/git-sync-gAMKsZgN.d.ts +205 -0
  133. package/dist/glossary-CHK3elPj.d.ts +35 -0
  134. package/dist/glossary-CqFlzW33.d.ts +15 -0
  135. package/dist/http/errors.d.ts +2 -0
  136. package/dist/http/errors.js +2 -0
  137. package/dist/http/oauth.d.ts +2 -0
  138. package/dist/http/oauth.js +201 -0
  139. package/dist/http/retry.d.ts +19 -0
  140. package/dist/http/retry.js +33 -0
  141. package/dist/http/transport.d.ts +2 -0
  142. package/dist/http/transport.js +2 -0
  143. package/dist/index.d.ts +60 -0
  144. package/dist/index.js +62 -0
  145. package/dist/json-CZvjc3--.d.ts +19 -0
  146. package/dist/json-pointer.d.ts +4 -0
  147. package/dist/json-pointer.js +7 -0
  148. package/dist/json.d.ts +2 -0
  149. package/dist/json.js +44 -0
  150. package/dist/known-range-DTOBgTEC.d.ts +7 -0
  151. package/dist/library-Cx9h_RkU.d.ts +228 -0
  152. package/dist/list-BT_bBm9Z.d.ts +7 -0
  153. package/dist/list.d.ts +2 -0
  154. package/dist/list.js +1 -0
  155. package/dist/measure-CuMqPbQX.d.ts +108 -0
  156. package/dist/measure-KuXdjZYJ.d.ts +44 -0
  157. package/dist/metric-yvehaVCS.d.ts +2655 -0
  158. package/dist/moderation-review-B4RUTZ6_.d.ts +56 -0
  159. package/dist/network-error-5g4U1iul.js +62 -0
  160. package/dist/notification-BT2TDAd_.d.ts +379 -0
  161. package/dist/notification-BiegPoSD.d.ts +22 -0
  162. package/dist/oauth-C4ordeoJ.d.ts +59 -0
  163. package/dist/oauth-login-CJsT_3EE.d.ts +19 -0
  164. package/dist/oauth-login-D734Jvbq.js +179 -0
  165. package/dist/oauth-session-BlIlcd8Q.d.ts +6 -0
  166. package/dist/paginate-DZWvWvbm.d.ts +24 -0
  167. package/dist/paginate.d.ts +2 -0
  168. package/dist/paginate.js +49 -0
  169. package/dist/parameter-ak-J-IOj.d.ts +190 -0
  170. package/dist/permission-BnCQw5Kp.d.ts +149 -0
  171. package/dist/poll-CIwnee7h.d.ts +15 -0
  172. package/dist/poll.d.ts +2 -0
  173. package/dist/poll.js +47 -0
  174. package/dist/predicates.d.ts +10 -0
  175. package/dist/predicates.js +18 -0
  176. package/dist/pulse-CMc1Rwdj.d.ts +596 -0
  177. package/dist/pulse-dylocLd9.d.ts +18 -0
  178. package/dist/query-Xsin530u.d.ts +23 -0
  179. package/dist/refusal-B9aeHMc9.js +130 -0
  180. package/dist/replacement-CyvtbxGg.d.ts +2467 -0
  181. package/dist/replacement-S9U3gApY.d.ts +128 -0
  182. package/dist/requirement-check-CIA5IHC1.d.ts +17 -0
  183. package/dist/requirements-C0txASN8.d.ts +217 -0
  184. package/dist/resources/card.d.ts +2 -0
  185. package/dist/resources/card.js +103 -0
  186. package/dist/resources/collection.d.ts +2 -0
  187. package/dist/resources/collection.js +110 -0
  188. package/dist/resources/content-translation.d.ts +11 -0
  189. package/dist/resources/content-translation.js +27 -0
  190. package/dist/resources/csv-upload.d.ts +2 -0
  191. package/dist/resources/csv-upload.js +9 -0
  192. package/dist/resources/dashboard.d.ts +2 -0
  193. package/dist/resources/dashboard.js +218 -0
  194. package/dist/resources/data-action.d.ts +105 -0
  195. package/dist/resources/data-action.js +79 -0
  196. package/dist/resources/database.d.ts +2 -0
  197. package/dist/resources/database.js +103 -0
  198. package/dist/resources/dataset.d.ts +2 -0
  199. package/dist/resources/dataset.js +81 -0
  200. package/dist/resources/dependency.d.ts +2 -0
  201. package/dist/resources/dependency.js +150 -0
  202. package/dist/resources/document.d.ts +55 -0
  203. package/dist/resources/document.js +60 -0
  204. package/dist/resources/eid-translation.d.ts +8 -0
  205. package/dist/resources/eid-translation.js +19 -0
  206. package/dist/resources/erd.d.ts +2 -0
  207. package/dist/resources/erd.js +26 -0
  208. package/dist/resources/field.d.ts +2 -0
  209. package/dist/resources/field.js +98 -0
  210. package/dist/resources/git-sync.d.ts +2 -0
  211. package/dist/resources/git-sync.js +362 -0
  212. package/dist/resources/glossary.d.ts +2 -0
  213. package/dist/resources/glossary.js +51 -0
  214. package/dist/resources/library.d.ts +85 -0
  215. package/dist/resources/library.js +90 -0
  216. package/dist/resources/measure.d.ts +2 -0
  217. package/dist/resources/measure.js +57 -0
  218. package/dist/resources/metric.d.ts +2 -0
  219. package/dist/resources/metric.js +50 -0
  220. package/dist/resources/moderation-review.d.ts +23 -0
  221. package/dist/resources/moderation-review.js +24 -0
  222. package/dist/resources/notification.d.ts +2 -0
  223. package/dist/resources/notification.js +93 -0
  224. package/dist/resources/optional-parsed.d.ts +7 -0
  225. package/dist/resources/optional-parsed.js +14 -0
  226. package/dist/resources/permission.d.ts +10 -0
  227. package/dist/resources/permission.js +31 -0
  228. package/dist/resources/pivot-export.d.ts +10 -0
  229. package/dist/resources/pivot-export.js +16 -0
  230. package/dist/resources/pulse.d.ts +2 -0
  231. package/dist/resources/pulse.js +75 -0
  232. package/dist/resources/replacement.d.ts +2 -0
  233. package/dist/resources/replacement.js +82 -0
  234. package/dist/resources/request-body.d.ts +9 -0
  235. package/dist/resources/request-body.js +13 -0
  236. package/dist/resources/revision.d.ts +70 -0
  237. package/dist/resources/revision.js +51 -0
  238. package/dist/resources/search.d.ts +2 -0
  239. package/dist/resources/search.js +57 -0
  240. package/dist/resources/segment.d.ts +2 -0
  241. package/dist/resources/segment.js +55 -0
  242. package/dist/resources/setting.d.ts +11 -0
  243. package/dist/resources/setting.js +43 -0
  244. package/dist/resources/setup.d.ts +8 -0
  245. package/dist/resources/setup.js +18 -0
  246. package/dist/resources/snippet.d.ts +2 -0
  247. package/dist/resources/snippet.js +52 -0
  248. package/dist/resources/table.d.ts +2 -0
  249. package/dist/resources/table.js +275 -0
  250. package/dist/resources/timeline-event.d.ts +12 -0
  251. package/dist/resources/timeline-event.js +51 -0
  252. package/dist/resources/timeline.d.ts +2 -0
  253. package/dist/resources/timeline.js +82 -0
  254. package/dist/resources/transform-dag-run.d.ts +22 -0
  255. package/dist/resources/transform-dag-run.js +32 -0
  256. package/dist/resources/transform-inspector.d.ts +214 -0
  257. package/dist/resources/transform-inspector.js +47 -0
  258. package/dist/resources/transform-job.d.ts +2 -0
  259. package/dist/resources/transform-job.js +90 -0
  260. package/dist/resources/transform-python.d.ts +52 -0
  261. package/dist/resources/transform-python.js +56 -0
  262. package/dist/resources/transform-tag.d.ts +35 -0
  263. package/dist/resources/transform-tag.js +47 -0
  264. package/dist/resources/transform-test.d.ts +2 -0
  265. package/dist/resources/transform-test.js +75 -0
  266. package/dist/resources/transform.d.ts +2 -0
  267. package/dist/resources/transform.js +217 -0
  268. package/dist/resources/upload.d.ts +2 -0
  269. package/dist/resources/upload.js +48 -0
  270. package/dist/resources/user.d.ts +8 -0
  271. package/dist/resources/user.js +11 -0
  272. package/dist/revision-CQBPhohA.d.ts +104 -0
  273. package/dist/search-BxJipLN6.d.ts +26 -0
  274. package/dist/search-NZR6iRBs.d.ts +92 -0
  275. package/dist/segment-D2i34X9l.d.ts +16 -0
  276. package/dist/segment-pj3wklGe.d.ts +47 -0
  277. package/dist/session-properties-COtlxAcK.d.ts +15 -0
  278. package/dist/setting-DXuQGXGF.d.ts +25 -0
  279. package/dist/setup-Ez_U7GmM.d.ts +26 -0
  280. package/dist/signal.d.ts +8 -0
  281. package/dist/signal.js +25 -0
  282. package/dist/snippet-RnnWa4TL.d.ts +16 -0
  283. package/dist/snippet-hEV429Pv.d.ts +41 -0
  284. package/dist/table-B3-UaPHa.d.ts +3229 -0
  285. package/dist/table-B_lfuaHc.d.ts +176 -0
  286. package/dist/tag-qzjGGci8.d.ts +48 -0
  287. package/dist/timeline-C2IEcRlP.d.ts +21 -0
  288. package/dist/timeline-folD3mQ_.d.ts +218 -0
  289. package/dist/transform-CDurgE1D.d.ts +443 -0
  290. package/dist/transform-CXOT5kFe.d.ts +638 -0
  291. package/dist/transform-dag-run-BgZwv1yx.d.ts +49 -0
  292. package/dist/transform-inspector-BUYBt6--.d.ts +374 -0
  293. package/dist/transform-job-29P6BULe.d.ts +237 -0
  294. package/dist/transform-job-CTJImaOd.d.ts +96 -0
  295. package/dist/transform-python-DdDnW6yK.d.ts +56 -0
  296. package/dist/transform-tag-DVUIZTEM.d.ts +25 -0
  297. package/dist/transform-test-A-CJYT6B.d.ts +412 -0
  298. package/dist/transform-test-BwuyrHpT.d.ts +346 -0
  299. package/dist/transport-E0ZaPNWJ.d.ts +462 -0
  300. package/dist/transport-HP7cyo9N.js +397 -0
  301. package/dist/upload-B7PG3ePk.d.ts +12 -0
  302. package/dist/upload-UPfZFdbH.d.ts +22 -0
  303. package/dist/url-CI0pxHOc.d.ts +7 -0
  304. package/dist/url.d.ts +2 -0
  305. package/dist/url.js +34 -0
  306. package/dist/user-2r0OBoO6.d.ts +18 -0
  307. package/dist/version/capability-error.d.ts +2 -0
  308. package/dist/version/capability-error.js +42 -0
  309. package/dist/version/features.d.ts +2 -0
  310. package/dist/version/features.js +143 -0
  311. package/dist/version/known-range.d.ts +2 -0
  312. package/dist/version/known-range.js +7 -0
  313. package/dist/version/probe.d.ts +2 -0
  314. package/dist/version/probe.js +30 -0
  315. package/dist/version/profile.d.ts +2 -0
  316. package/dist/version/profile.js +64 -0
  317. package/dist/version/requirement-check.d.ts +2 -0
  318. package/dist/version/requirement-check.js +62 -0
  319. package/dist/version/requirements.d.ts +2 -0
  320. package/dist/version/requirements.js +219 -0
  321. package/dist/version/tag.d.ts +2 -0
  322. package/dist/version/tag.js +52 -0
  323. package/package.json +65 -4
@@ -0,0 +1,11 @@
1
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ import { t as CsvFile } from "../csv-upload--K35QedP.js";
3
+ //#region src/resources/content-translation.d.ts
4
+ declare function contentTranslationResource(transport: Transport): {
5
+ download: (options?: RequestOptions | undefined) => Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
6
+ upload: (file: CsvFile, options?: RequestOptions | undefined) => Promise<{
7
+ success: true;
8
+ }>;
9
+ };
10
+ //#endregion
11
+ export { contentTranslationResource };
@@ -0,0 +1,27 @@
1
+ import { ContentTranslationUploadResult } from "../domain/content-translation.js";
2
+ import { t as explainer } from "../refusal-B9aeHMc9.js";
3
+ import { buildCsvFormData } from "./csv-upload.js";
4
+ //#region src/resources/content-translation.ts
5
+ const CONTENT_TRANSLATION_PATH = "/api/ee/content-translation";
6
+ function contentTranslationResource(transport) {
7
+ const { explain } = explainer(transport, "contentTranslation");
8
+ /** Download the complete content translation dictionary as CSV. */
9
+ async function download(options = {}) {
10
+ return transport.requestStream(`${CONTENT_TRANSLATION_PATH}/csv`, options);
11
+ }
12
+ /** Replace the complete content translation dictionary with the attached CSV. */
13
+ async function upload(file, options = {}) {
14
+ const form = buildCsvFormData(file);
15
+ return transport.requestParsed(ContentTranslationUploadResult, `${CONTENT_TRANSLATION_PATH}/upload-dictionary`, {
16
+ ...options,
17
+ method: "POST",
18
+ body: form
19
+ });
20
+ }
21
+ return {
22
+ download: explain("download", download),
23
+ upload: explain("upload", upload)
24
+ };
25
+ }
26
+ //#endregion
27
+ export { contentTranslationResource };
@@ -0,0 +1,2 @@
1
+ import { n as buildCsvFormData, t as CsvFile } from "../csv-upload--K35QedP.js";
2
+ export { CsvFile, buildCsvFormData };
@@ -0,0 +1,9 @@
1
+ //#region src/resources/csv-upload.ts
2
+ const CSV_CONTENT_TYPE = "text/csv";
3
+ function buildCsvFormData(file) {
4
+ const form = new FormData();
5
+ form.append("file", new Blob([file.bytes], { type: CSV_CONTENT_TYPE }), file.filename);
6
+ return form;
7
+ }
8
+ //#endregion
9
+ export { buildCsvFormData };
@@ -0,0 +1,2 @@
1
+ import { a as DashcardCardProblem, i as DashcardCardMissing, n as DashcardCardArchived, o as DashcardCardUnreadable, r as DashcardCardIssue, s as dashboardResource, t as DashboardListParams } from "../dashboard-XTe46250.js";
2
+ export { DashboardListParams, DashcardCardArchived, DashcardCardIssue, DashcardCardMissing, DashcardCardProblem, DashcardCardUnreadable, dashboardResource };
@@ -0,0 +1,218 @@
1
+ import { ConfigError } from "../errors.js";
2
+ import { a as HttpError } from "../errors-DdMlaXqq.js";
3
+ import { ParameterValues } from "../domain/parameter.js";
4
+ import { cardResource } from "./card.js";
5
+ import { Dashboard, DashboardCopy, DashboardDetail, Dashcard } from "../domain/dashboard.js";
6
+ import { z } from "zod";
7
+ //#region src/resources/dashboard.ts
8
+ const DashboardApiList = z.array(Dashboard);
9
+ const PreflightDashcard = z.looseObject({ card_id: z.number().int().nullable().optional() });
10
+ function dashboardResource(transport) {
11
+ const card = cardResource(transport);
12
+ /** List dashboards. `f` picks a server-side preset. */
13
+ async function list(params = {}, options = {}) {
14
+ return {
15
+ data: await transport.requestParsed(DashboardApiList, "/api/dashboard", {
16
+ ...options,
17
+ query: { f: params.f }
18
+ }),
19
+ total: null
20
+ };
21
+ }
22
+ /** Get one dashboard by id, with its dashcards, tabs and parameters. */
23
+ async function get(id, options = {}) {
24
+ return transport.requestParsed(DashboardDetail, `/api/dashboard/${id}`, { ...options });
25
+ }
26
+ /**
27
+ * Create a dashboard. The endpoint accepts no dashcards or tabs — a follow-up `update` is what
28
+ * puts content on a fresh dashboard.
29
+ */
30
+ async function create(params, options = {}) {
31
+ return transport.requestParsed(Dashboard, "/api/dashboard", {
32
+ ...options,
33
+ method: "POST",
34
+ body: params
35
+ });
36
+ }
37
+ /**
38
+ * Update a dashboard by id, patching only the fields the body carries. `dashcards` and `tabs` are
39
+ * full replacements: whatever the arrays omit is deleted from the dashboard. A body with
40
+ * `dashcards` and no `tabs` key keeps the current tabs, read first: the server takes the missing
41
+ * key for an empty list and deletes every tab, or fails on a dashcard that still names one.
42
+ */
43
+ async function update(id, params, options = {}) {
44
+ const body = await withCurrentTabs(id, params, options);
45
+ return transport.requestParsed(DashboardDetail, `/api/dashboard/${id}`, {
46
+ ...options,
47
+ method: "PUT",
48
+ body
49
+ });
50
+ }
51
+ async function withCurrentTabs(id, params, options) {
52
+ if (params.dashcards === void 0 || params.tabs !== void 0) return params;
53
+ const current = await get(id, options);
54
+ return {
55
+ ...params,
56
+ tabs: tabWrites(current.tabs)
57
+ };
58
+ }
59
+ /**
60
+ * Copy a dashboard, with its tabs and dashcards, into `collection_id` (root when absent). A deep
61
+ * copy duplicates its questions and metrics and references its models. With `is_deep_copy`
62
+ * false or absent the copy references every card, and a dashboard holding unarchived dashboard
63
+ * questions is refused. Archived cards, cards the caller cannot read, and every card on a
64
+ * dashcard whose main card the caller cannot read are left out and reported as `uncopied`, once
65
+ * per dashcard they sat on. A left-out main card takes its dashcard with it; a left-out series
66
+ * card stays on a dashcard whose main card is referenced and is dropped from one whose main card
67
+ * is duplicated. Action, link and placeholder dashcards are not copied.
68
+ */
69
+ async function copy(id, params = {}, options = {}) {
70
+ return transport.requestParsed(DashboardCopy, `/api/dashboard/${id}/copy`, {
71
+ ...options,
72
+ method: "POST",
73
+ body: params
74
+ });
75
+ }
76
+ /**
77
+ * Archive (soft-delete) a dashboard by id. Metabase models this as an update, not its own
78
+ * endpoint. The answer is read as `Dashboard` rather than the `DashboardDetail` `update` returns:
79
+ * an archive is a state change on the dashboard itself, and its dashcards are not part of it.
80
+ */
81
+ async function archive(id, options = {}) {
82
+ return transport.requestParsed(Dashboard, `/api/dashboard/${id}`, {
83
+ ...options,
84
+ method: "PUT",
85
+ body: { archived: true }
86
+ });
87
+ }
88
+ /**
89
+ * Patch one dashcard on a dashboard. Metabase exposes no dashcard endpoint and its dashboard PUT
90
+ * is a full replace of `dashcards`, so the patch is read-modify-written over the dashboard as it
91
+ * currently stands, its tabs sent back unchanged.
92
+ */
93
+ async function updateDashcard(dashboardId, dashcardId, params, options = {}) {
94
+ const dashboard = await get(dashboardId, options);
95
+ const target = dashboard.dashcards.find((dashcard) => dashcard.id === dashcardId);
96
+ if (target === void 0) throw new ConfigError(`dashcard ${dashcardId} not found on dashboard ${dashboardId}`);
97
+ const patched = Dashcard.parse({
98
+ ...target,
99
+ ...params
100
+ });
101
+ const refreshed = (await update(dashboardId, {
102
+ dashcards: dashboard.dashcards.map((dashcard) => stripEntityId(dashcard.id === dashcardId ? patched : dashcard)),
103
+ tabs: tabWrites(dashboard.tabs)
104
+ }, options)).dashcards.find((dashcard) => dashcard.id === dashcardId);
105
+ if (refreshed === void 0) throw new Error(`PUT /api/dashboard/${dashboardId}: dashcard ${dashcardId} missing from response`);
106
+ return refreshed;
107
+ }
108
+ /**
109
+ * Check every card a `dashcards` body references before writing it, through `GET /api/card/{id}`
110
+ * once per distinct id. Reports one issue per reference whose card is missing, archived, or
111
+ * unreadable, so an empty result means the body is safe to send; an id the server answers for in
112
+ * any other way propagates as the failure it was.
113
+ */
114
+ async function checkCardReferences(dashcards, options = {}) {
115
+ const grouped = groupByCardId(collectCardReferences(dashcards));
116
+ return (await Promise.all(Array.from(grouped.entries()).map(async ([cardId, references]) => ({
117
+ references,
118
+ problem: await inspectCard(cardId, options)
119
+ })))).flatMap((check) => {
120
+ const problem = check.problem;
121
+ if (problem === null) return [];
122
+ return check.references.map((reference) => ({
123
+ ...reference,
124
+ problem
125
+ }));
126
+ });
127
+ }
128
+ async function inspectCard(cardId, options) {
129
+ try {
130
+ return (await card.get(cardId, options)).archived ? { reason: "archived" } : null;
131
+ } catch (error) {
132
+ if (!(error instanceof HttpError)) throw error;
133
+ if (error.kind === "resource-missing") return { reason: "missing" };
134
+ if (error.kind === "auth" || error.kind === "forbidden") return {
135
+ reason: "unreadable",
136
+ detail: error.userMessage
137
+ };
138
+ throw error;
139
+ }
140
+ }
141
+ /**
142
+ * Fetch the selectable values for a dashboard parameter, through the chain-filter value endpoint.
143
+ * `constraints` sets other parameters' values, which narrow the values of a parameter linked to
144
+ * them.
145
+ */
146
+ async function parameterValues(dashboardId, parameterId, constraints = {}, options = {}) {
147
+ return transport.requestParsed(ParameterValues, `/api/dashboard/${dashboardId}/params/${encodeURIComponent(parameterId)}/values`, {
148
+ ...options,
149
+ query: constraints
150
+ });
151
+ }
152
+ /**
153
+ * Search a dashboard parameter's selectable values: the server returns only values containing the
154
+ * substring, capped at the first 1000 matches. `constraints` narrows them as `parameterValues`
155
+ * does.
156
+ */
157
+ async function searchParameterValues(dashboardId, parameterId, query, constraints = {}, options = {}) {
158
+ const parameter = encodeURIComponent(parameterId);
159
+ return transport.requestParsed(ParameterValues, `/api/dashboard/${dashboardId}/params/${parameter}/search/${encodeURIComponent(query)}`, {
160
+ ...options,
161
+ query: constraints
162
+ });
163
+ }
164
+ return {
165
+ list,
166
+ get,
167
+ create,
168
+ update,
169
+ archive,
170
+ copy,
171
+ updateDashcard,
172
+ checkCardReferences,
173
+ parameterValues,
174
+ searchParameterValues
175
+ };
176
+ }
177
+ function collectCardReferences(dashcards) {
178
+ if (dashcards === void 0 || dashcards === null) return [];
179
+ const references = [];
180
+ dashcards.forEach((dashcard, index) => {
181
+ const parsed = PreflightDashcard.safeParse(dashcard);
182
+ if (!parsed.success) return;
183
+ const cardId = parsed.data.card_id;
184
+ if (typeof cardId === "number" && cardId > 0) references.push({
185
+ cardId,
186
+ path: `/dashcards/${index}/card_id`
187
+ });
188
+ });
189
+ return references;
190
+ }
191
+ function groupByCardId(references) {
192
+ const grouped = /* @__PURE__ */ new Map();
193
+ for (const reference of references) {
194
+ const existing = grouped.get(reference.cardId);
195
+ if (existing === void 0) grouped.set(reference.cardId, [reference]);
196
+ else existing.push(reference);
197
+ }
198
+ return grouped;
199
+ }
200
+ function tabWrites(tabs) {
201
+ return tabs.map(({ id, name }) => ({
202
+ id,
203
+ name
204
+ }));
205
+ }
206
+ function stripEntityId(dashcard) {
207
+ const { entity_id: _entity_id, id, size_x, size_y, row, col, ...rest } = dashcard;
208
+ return {
209
+ ...rest,
210
+ id,
211
+ size_x,
212
+ size_y,
213
+ row,
214
+ col
215
+ };
216
+ }
217
+ //#endregion
218
+ export { dashboardResource };
@@ -0,0 +1,105 @@
1
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ import { t as ListResult } from "../list-BT_bBm9Z.js";
3
+ import { a as DataActionExecuteResult, i as DataActionExecuteInput, t as DataAction } from "../data-action-rS27f2Ji.js";
4
+ //#region src/resources/data-action.d.ts
5
+ declare function dataActionResource(transport: Transport): {
6
+ list: (options?: RequestOptions) => Promise<ListResult<DataAction>>;
7
+ get: (id: number, options?: RequestOptions) => Promise<DataAction>;
8
+ create: (params: {
9
+ name: string;
10
+ type: "query";
11
+ database_id: number;
12
+ dataset_query: {
13
+ [x: string]: unknown;
14
+ };
15
+ parameters?: {
16
+ [x: string]: unknown;
17
+ id: string;
18
+ type: string;
19
+ target: unknown;
20
+ name?: string | undefined;
21
+ slug?: string | undefined;
22
+ required?: boolean | undefined;
23
+ }[] | undefined;
24
+ collection_id?: number | null | undefined;
25
+ description?: string | null | undefined;
26
+ visualization_settings?: unknown;
27
+ }, options?: RequestOptions | undefined) => Promise<{
28
+ [x: string]: unknown;
29
+ id: number;
30
+ name: string;
31
+ description: string | null;
32
+ type: string;
33
+ model_id: number | null;
34
+ parameters: {
35
+ [x: string]: unknown;
36
+ id: string;
37
+ type: string;
38
+ name?: string | undefined;
39
+ slug?: string | undefined;
40
+ target?: unknown;
41
+ required?: boolean | undefined;
42
+ }[] | null;
43
+ visualization_settings: unknown;
44
+ archived: boolean;
45
+ public_uuid: string | null;
46
+ entity_id: string | null;
47
+ creator_id: number;
48
+ created_at: string;
49
+ updated_at: string;
50
+ collection_id: number | null;
51
+ database_id?: number | null | undefined;
52
+ dataset_query?: unknown;
53
+ }>;
54
+ update: (id: number, params: {
55
+ name?: string | undefined;
56
+ database_id?: number | undefined;
57
+ dataset_query?: {
58
+ [x: string]: unknown;
59
+ } | undefined;
60
+ parameters?: {
61
+ [x: string]: unknown;
62
+ id: string;
63
+ type: string;
64
+ target: unknown;
65
+ name?: string | undefined;
66
+ slug?: string | undefined;
67
+ required?: boolean | undefined;
68
+ }[] | undefined;
69
+ collection_id?: number | null | undefined;
70
+ description?: string | null | undefined;
71
+ visualization_settings?: unknown;
72
+ archived?: boolean | undefined;
73
+ }, options?: RequestOptions | undefined) => Promise<{
74
+ [x: string]: unknown;
75
+ id: number;
76
+ name: string;
77
+ description: string | null;
78
+ type: string;
79
+ model_id: number | null;
80
+ parameters: {
81
+ [x: string]: unknown;
82
+ id: string;
83
+ type: string;
84
+ name?: string | undefined;
85
+ slug?: string | undefined;
86
+ target?: unknown;
87
+ required?: boolean | undefined;
88
+ }[] | null;
89
+ visualization_settings: unknown;
90
+ archived: boolean;
91
+ public_uuid: string | null;
92
+ entity_id: string | null;
93
+ creator_id: number;
94
+ created_at: string;
95
+ updated_at: string;
96
+ collection_id: number | null;
97
+ database_id?: number | null | undefined;
98
+ dataset_query?: unknown;
99
+ }>;
100
+ archive: (id: number, options?: RequestOptions) => Promise<DataAction>;
101
+ delete: (id: number, options?: RequestOptions) => Promise<void>;
102
+ execute: (id: number, params: DataActionExecuteInput, options?: RequestOptions) => Promise<DataActionExecuteResult>;
103
+ };
104
+ //#endregion
105
+ export { dataActionResource };
@@ -0,0 +1,79 @@
1
+ import { t as explainer } from "../refusal-B9aeHMc9.js";
2
+ import { DataActionExecuteResult, dataActionSchema } from "../domain/data-action.js";
3
+ import { z } from "zod";
4
+ //#region src/resources/data-action.ts
5
+ function collectionFeatures(params) {
6
+ return params.collection_id === void 0 ? [] : [{
7
+ feature: "dataActionCollections",
8
+ fields: ["collection_id"]
9
+ }];
10
+ }
11
+ function dataActionResource(transport) {
12
+ const { explain } = explainer(transport, "dataAction");
13
+ async function readSchema(options) {
14
+ const { features } = await transport.server(options);
15
+ return dataActionSchema(features);
16
+ }
17
+ /** List the unarchived data actions the caller can see. `GET /api/action` answers a bare array. */
18
+ async function list(options = {}) {
19
+ const schema = await readSchema(options);
20
+ return {
21
+ data: await transport.requestParsed(z.array(schema), "/api/action", { ...options }),
22
+ total: null
23
+ };
24
+ }
25
+ /** Get one unarchived data action by id. */
26
+ async function get(id, options = {}) {
27
+ const schema = await readSchema(options);
28
+ return transport.requestParsed(schema, `/api/action/${id}`, { ...options });
29
+ }
30
+ /** Create a data action — a parameterized native query that writes to a database — in a collection. */
31
+ async function create(params, options = {}) {
32
+ const schema = await readSchema(options);
33
+ return transport.requestParsed(schema, "/api/action", {
34
+ ...options,
35
+ method: "POST",
36
+ body: params
37
+ });
38
+ }
39
+ /** Update a data action by id, patching only the fields the body carries. */
40
+ async function update(id, params, options = {}) {
41
+ const schema = await readSchema(options);
42
+ return transport.requestParsed(schema, `/api/action/${id}`, {
43
+ ...options,
44
+ method: "PUT",
45
+ body: params
46
+ });
47
+ }
48
+ /** Archive (soft-delete) a data action by id. Metabase models this as an update, not its own endpoint. */
49
+ async function archive(id, options = {}) {
50
+ return update(id, { archived: true }, options);
51
+ }
52
+ /** Delete a data action by id, removing it and the dashboard buttons that run it. */
53
+ async function remove(id, options = {}) {
54
+ await transport.requestRaw(`/api/action/${id}`, {
55
+ ...options,
56
+ method: "DELETE",
57
+ expectContentType: "binary"
58
+ });
59
+ }
60
+ /** Execute a data action by id with parameter values keyed by parameter id. */
61
+ async function execute(id, params, options = {}) {
62
+ return transport.requestParsed(DataActionExecuteResult, `/api/action/${id}/execute`, {
63
+ ...options,
64
+ method: "POST",
65
+ body: params
66
+ });
67
+ }
68
+ return {
69
+ list,
70
+ get,
71
+ create: explain("create", create),
72
+ update: explain("update", update, (_id, params) => collectionFeatures(params)),
73
+ archive,
74
+ delete: remove,
75
+ execute
76
+ };
77
+ }
78
+ //#endregion
79
+ export { dataActionResource };
@@ -0,0 +1,2 @@
1
+ import { i as databaseResource, n as DatabaseListParams, r as DatabaseSyncSchemaParams, t as DatabaseGetParams } from "../database-DqTespfa.js";
2
+ export { DatabaseGetParams, DatabaseListParams, DatabaseSyncSchemaParams, databaseResource };
@@ -0,0 +1,103 @@
1
+ import { Table } from "../domain/table.js";
2
+ import { Database, DatabaseWithSettings } from "../domain/database.js";
3
+ import { pollUntil } from "../poll.js";
4
+ import { z } from "zod";
5
+ //#region src/resources/database.ts
6
+ const DatabaseApiList = z.object({
7
+ data: z.array(Database),
8
+ total: z.number().int().nonnegative()
9
+ }).loose();
10
+ const DatabaseTaskAck = z.object({ status: z.literal("ok") });
11
+ const DatabaseApiSchemaList = z.array(z.string());
12
+ const DatabaseApiSchemaTableList = z.array(Table);
13
+ const SYNC_COMPLETE = "complete";
14
+ function databaseResource(transport) {
15
+ /** List databases. `include` hydrates each database's tables; `saved` adds the Saved Questions virtual database. */
16
+ async function list(params = {}, options = {}) {
17
+ const response = await transport.requestParsed(DatabaseApiList, "/api/database", {
18
+ ...options,
19
+ query: {
20
+ include: params.include,
21
+ saved: params.saved
22
+ }
23
+ });
24
+ return {
25
+ data: response.data,
26
+ total: response.total
27
+ };
28
+ }
29
+ /** Get one database by id. `include` hydrates its tables, and `tables.fields` their fields too. */
30
+ async function get(id, params = {}, options = {}) {
31
+ return transport.requestParsed(Database, `/api/database/${id}`, {
32
+ ...options,
33
+ query: { include: params.include }
34
+ });
35
+ }
36
+ /** Update a database's settings by id; the server merges them into the ones it holds. */
37
+ async function update(id, params, options = {}) {
38
+ return transport.requestParsed(DatabaseWithSettings, `/api/database/${id}`, {
39
+ ...options,
40
+ method: "PUT",
41
+ body: params
42
+ });
43
+ }
44
+ /** List the schema names in a database. */
45
+ async function schemas(id, options = {}) {
46
+ return {
47
+ data: await transport.requestParsed(DatabaseApiSchemaList, `/api/database/${id}/schemas`, { ...options }),
48
+ total: null
49
+ };
50
+ }
51
+ /** List the tables one schema of a database holds. */
52
+ async function schemaTables(id, schema, options = {}) {
53
+ return {
54
+ data: await transport.requestParsed(DatabaseApiSchemaTableList, `/api/database/${id}/schema/${encodeURIComponent(schema)}`, { ...options }),
55
+ total: null
56
+ };
57
+ }
58
+ /**
59
+ * Trigger a manual schema sync for a database. The endpoint queues the sync and returns at once;
60
+ * pass `wait` to poll the database until it reports its initial sync complete.
61
+ */
62
+ async function syncSchema(id, params = {}, options = {}) {
63
+ const ack = await transport.requestParsed(DatabaseTaskAck, `/api/database/${id}/sync_schema`, {
64
+ ...options,
65
+ method: "POST"
66
+ });
67
+ const wait = params.wait;
68
+ if (wait === void 0) return {
69
+ id,
70
+ status: ack.status
71
+ };
72
+ const database = await pollUntil(async (signal) => transport.requestParsed(Database, `/api/database/${id}`, {
73
+ ...options,
74
+ signal
75
+ }), (candidate) => candidate.initial_sync_status === SYNC_COMPLETE, wait);
76
+ return {
77
+ id,
78
+ status: ack.status,
79
+ initial_sync_status: database.initial_sync_status ?? null
80
+ };
81
+ }
82
+ /** Trigger a rescan of the cached field values across a database. */
83
+ async function rescanValues(id, options = {}) {
84
+ return {
85
+ id,
86
+ status: (await transport.requestParsed(DatabaseTaskAck, `/api/database/${id}/rescan_values`, {
87
+ ...options,
88
+ method: "POST"
89
+ })).status
90
+ };
91
+ }
92
+ return {
93
+ list,
94
+ get,
95
+ update,
96
+ schemas,
97
+ schemaTables,
98
+ syncSchema,
99
+ rescanValues
100
+ };
101
+ }
102
+ //#endregion
103
+ export { databaseResource };
@@ -0,0 +1,2 @@
1
+ import { n as DatasetNativeParams, r as datasetResource, t as DatasetExportParams } from "../dataset-Cj3XuKLe.js";
2
+ export { DatasetExportParams, DatasetNativeParams, datasetResource };
@@ -0,0 +1,81 @@
1
+ import { CardQueryResult } from "../domain/card.js";
2
+ import { CompiledQuery, QueryMetadata } from "../domain/dataset.js";
3
+ import { assertPivotedExport } from "./pivot-export.js";
4
+ //#region src/resources/dataset.ts
5
+ function datasetResource(transport) {
6
+ /**
7
+ * Run an ad-hoc query and return its result envelope. The body is a whole query — MBQL 5, legacy
8
+ * MBQL, or native — rather than a reference to a saved one, so nothing here is a card.
9
+ */
10
+ async function query(body, options = {}) {
11
+ return transport.requestParsed(CardQueryResult, "/api/dataset", {
12
+ ...options,
13
+ method: "POST",
14
+ body
15
+ });
16
+ }
17
+ /**
18
+ * Fetch a native version of an MBQL query. `pretty` rides in the same body as the query and
19
+ * defaults server-side to true.
20
+ */
21
+ async function native(datasetQuery, params = {}, options = {}) {
22
+ return transport.requestParsed(CompiledQuery, "/api/dataset/native", {
23
+ ...options,
24
+ method: "POST",
25
+ body: {
26
+ ...datasetQuery,
27
+ pretty: params.pretty
28
+ }
29
+ });
30
+ }
31
+ /**
32
+ * Get all of the required query metadata for an ad-hoc query: the databases, tables, fields and
33
+ * snippets it references. `{ settings: { "include-sensitive-fields": true } }` inside the query
34
+ * widens the field filter.
35
+ */
36
+ async function queryMetadata(datasetQuery, options = {}) {
37
+ return transport.requestParsed(QueryMetadata, "/api/dataset/query_metadata", {
38
+ ...options,
39
+ method: "POST",
40
+ body: datasetQuery
41
+ });
42
+ }
43
+ /**
44
+ * Execute a query and download the result data as a file in the specified format. Unlike
45
+ * `query`, this endpoint answers bytes, so a caller consumes the stream rather than a value.
46
+ * `visualization_settings` drive `format_rows` column formatting and, through
47
+ * `pivot_table.column_split`, the layout `pivot_results` lays the rows out in. The server only
48
+ * computes that layout for a query it runs as a pivot, which it reads from the query's own
49
+ * `was-pivot`, so `pivot_results` sets it. A pivot the server would answer with plain rows (a
50
+ * JSON export, or pivoted exports turned off) is refused. `csv_include_bom` opens a CSV with a
51
+ * UTF-8 byte order mark; a server without it drops the key silently, so asking for one is refused
52
+ * there before the wire.
53
+ */
54
+ async function exportQuery(format, params, options = {}) {
55
+ if (params.pivot_results) await assertPivotedExport(transport, format, options);
56
+ await transport.requireFeatures(params.csv_include_bom ? ["exportCsvByteOrderMark"] : [], options);
57
+ const exported = params.pivot_results ? {
58
+ ...params.query,
59
+ "was-pivot": true
60
+ } : params.query;
61
+ return transport.requestStream(`/api/dataset/${format}`, {
62
+ ...options,
63
+ method: "POST",
64
+ body: {
65
+ query: exported,
66
+ visualization_settings: params.visualization_settings,
67
+ format_rows: params.format_rows,
68
+ pivot_results: params.pivot_results,
69
+ csv_include_bom: params.csv_include_bom
70
+ }
71
+ });
72
+ }
73
+ return {
74
+ query,
75
+ native,
76
+ queryMetadata,
77
+ exportQuery
78
+ };
79
+ }
80
+ //#endregion
81
+ export { datasetResource };
@@ -0,0 +1,2 @@
1
+ import { a as dependencyResource, i as DependencyItemPageOptions, n as DependencyDependentsParams, r as DependencyItemListParams, t as DependencyBrokenParams } from "../dependency-fN5_7a22.js";
2
+ export { DependencyBrokenParams, DependencyDependentsParams, DependencyItemListParams, DependencyItemPageOptions, dependencyResource };