@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,50 @@
1
+ import { CardQueryResult } from "../domain/card.js";
2
+ import { t as explainer } from "../refusal-B9aeHMc9.js";
3
+ import { MetricBreakoutValues, MetricDimensionListing } from "../domain/metric.js";
4
+ //#region src/resources/metric.ts
5
+ function metricResource(transport) {
6
+ const { explain } = explainer(transport, "metric");
7
+ /**
8
+ * Run a metric definition and return the query result envelope: one metric or measure, or an
9
+ * arithmetic expression over several, each leaf filtered and projected on its own `lib/uuid`.
10
+ */
11
+ async function query(definition, options = {}) {
12
+ return transport.requestParsed(CardQueryResult, "/api/metric/dataset", {
13
+ ...options,
14
+ method: "POST",
15
+ body: { definition }
16
+ });
17
+ }
18
+ /**
19
+ * Fetch the distinct values of a definition's breakout dimension, with that column's metadata.
20
+ * Takes the same definition `query` does.
21
+ */
22
+ async function breakoutValues(definition, options = {}) {
23
+ return transport.requestParsed(MetricBreakoutValues, "/api/metric/breakout-values", {
24
+ ...options,
25
+ method: "POST",
26
+ body: { definition }
27
+ });
28
+ }
29
+ /**
30
+ * List a metric's curated dimensions and, under `with-addable`, the columns still available to
31
+ * add, grouped by source table. `query` filters both by a name substring.
32
+ */
33
+ async function dimensions(id, params = {}, options = {}) {
34
+ return transport.requestParsed(MetricDimensionListing, `/api/metric/${id}/dimension`, {
35
+ ...options,
36
+ query: {
37
+ query: params.query,
38
+ "with-addable": params["with-addable"],
39
+ "include-orphaned": params["include-orphaned"]
40
+ }
41
+ });
42
+ }
43
+ return {
44
+ query: explain("query", query),
45
+ breakoutValues: explain("breakoutValues", breakoutValues),
46
+ dimensions: explain("dimensions", dimensions)
47
+ };
48
+ }
49
+ //#endregion
50
+ export { metricResource };
@@ -0,0 +1,23 @@
1
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ //#region src/resources/moderation-review.d.ts
3
+ declare function moderationReviewResource(transport: Transport): {
4
+ create: (params: {
5
+ moderated_item_id: number;
6
+ moderated_item_type: "card" | "dashboard";
7
+ status?: "verified" | null | undefined;
8
+ text?: string | null | undefined;
9
+ }, options?: RequestOptions | undefined) => Promise<{
10
+ [x: string]: unknown;
11
+ id: number;
12
+ moderated_item_id: number;
13
+ moderated_item_type: "card" | "dashboard";
14
+ moderator_id: number;
15
+ status: "verified" | null;
16
+ text: string | null;
17
+ most_recent: boolean;
18
+ created_at: string;
19
+ updated_at: string;
20
+ }>;
21
+ };
22
+ //#endregion
23
+ export { moderationReviewResource };
@@ -0,0 +1,24 @@
1
+ import { ModerationReview, ModerationReviewCreateInput } from "../domain/moderation-review.js";
2
+ import { t as explainer } from "../refusal-B9aeHMc9.js";
3
+ import { parseRequestBody } from "./request-body.js";
4
+ //#region src/resources/moderation-review.ts
5
+ function moderationReviewResource(transport) {
6
+ const { explain } = explainer(transport, "moderationReview");
7
+ /**
8
+ * Create a moderation review on a card or dashboard. `status: "verified"` marks the item
9
+ * verified, `null` or an absent status records a note that leaves it unverified. The new review
10
+ * becomes the item's most recent one; the server keeps the ten newest per item. Admins only.
11
+ * A body that does not match `ModerationReviewCreateInput` is refused before any request.
12
+ */
13
+ async function create(params, options = {}) {
14
+ const body = parseRequestBody(ModerationReviewCreateInput, params, "moderation review");
15
+ return transport.requestParsed(ModerationReview, "/api/moderation-review", {
16
+ ...options,
17
+ method: "POST",
18
+ body
19
+ });
20
+ }
21
+ return { create: explain("create", create) };
22
+ }
23
+ //#endregion
24
+ export { moderationReviewResource };
@@ -0,0 +1,2 @@
1
+ import { i as notificationResource, n as assertCardAlert, r as mergeAlertUpdate, t as NotificationListParams } from "../notification-BiegPoSD.js";
2
+ export { NotificationListParams, assertCardAlert, mergeAlertUpdate, notificationResource };
@@ -0,0 +1,93 @@
1
+ import { ConfigError } from "../errors.js";
2
+ import { CARD_PAYLOAD_TYPE, Notification, NotificationCardPayload } from "../domain/notification.js";
3
+ import { z } from "zod";
4
+ //#region src/resources/notification.ts
5
+ const NotificationApiList = z.array(Notification);
6
+ function assertCardAlert(notification) {
7
+ 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`);
8
+ return notification;
9
+ }
10
+ function mergeAlertUpdate(current, patch) {
11
+ return Notification.parse({
12
+ ...current,
13
+ ...patch,
14
+ id: current.id,
15
+ payload: patch.payload === void 0 ? current.payload : mergePayload(current, patch.payload)
16
+ });
17
+ }
18
+ function mergePayload(current, patch) {
19
+ if (current.payload === null) throw new ConfigError(`alert ${current.id} has lost its card payload — it can be archived, but not patched`);
20
+ return NotificationCardPayload.parse({
21
+ ...current.payload,
22
+ ...patch
23
+ });
24
+ }
25
+ function notificationResource(transport) {
26
+ /**
27
+ * List question alerts, optionally narrowed by the card they watch, their creator, or a
28
+ * recipient. `/api/notification` also serves Metabase's internal system-event notifications, so
29
+ * the request pins the card payload type.
30
+ */
31
+ async function list(params = {}, options = {}) {
32
+ return {
33
+ data: await transport.requestParsed(NotificationApiList, "/api/notification", {
34
+ ...options,
35
+ query: {
36
+ payload_type: CARD_PAYLOAD_TYPE,
37
+ card_id: params.card_id,
38
+ creator_id: params.creator_id,
39
+ recipient_id: params.recipient_id,
40
+ include_inactive: params.include_inactive
41
+ }
42
+ }),
43
+ total: null
44
+ };
45
+ }
46
+ /** Get one question alert by id, refusing an id that names a system-event notification. */
47
+ async function get(id, options = {}) {
48
+ return assertCardAlert(await transport.requestParsed(Notification, `/api/notification/${id}`, { ...options }));
49
+ }
50
+ /** Create a question alert — its card payload, schedules and handlers — from a full body. */
51
+ async function create(params, options = {}) {
52
+ return transport.requestParsed(Notification, "/api/notification", {
53
+ ...options,
54
+ method: "POST",
55
+ body: params
56
+ });
57
+ }
58
+ /** Update a question alert by id, merging the patch over the stored notification. */
59
+ async function update(id, params, options = {}) {
60
+ const current = await get(id, options);
61
+ return transport.requestParsed(Notification, `/api/notification/${id}`, {
62
+ ...options,
63
+ method: "PUT",
64
+ body: mergeAlertUpdate(current, params)
65
+ });
66
+ }
67
+ /** Archive a question alert by id, stopping every delivery. Metabase models this as an update. */
68
+ async function archive(id, options = {}) {
69
+ return update(id, { active: false }, options);
70
+ }
71
+ /**
72
+ * Send a question alert now, off-schedule, to every handler on it. The server answers with no
73
+ * body.
74
+ */
75
+ async function send(id, options = {}) {
76
+ await get(id, options);
77
+ await transport.requestRaw(`/api/notification/${id}/send`, {
78
+ ...options,
79
+ method: "POST",
80
+ expectContentType: "binary"
81
+ });
82
+ }
83
+ return {
84
+ list,
85
+ get,
86
+ create,
87
+ update,
88
+ archive,
89
+ send
90
+ };
91
+ }
92
+ //#endregion
93
+ export { assertCardAlert, mergeAlertUpdate, notificationResource };
@@ -0,0 +1,7 @@
1
+ import { f as RequestOptions, g as TransportRequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ import { ZodType } from "zod";
3
+ //#region src/resources/optional-parsed.d.ts
4
+ type OptionalParsedOptions = RequestOptions & Pick<TransportRequestOptions, "query">;
5
+ declare function fetchOptionalParsed<T>(client: Transport, path: string, schema: ZodType<T>, options?: OptionalParsedOptions): Promise<T | null>;
6
+ //#endregion
7
+ export { OptionalParsedOptions, fetchOptionalParsed };
@@ -0,0 +1,14 @@
1
+ import { parseJsonOrPlain } from "../json.js";
2
+ //#region src/resources/optional-parsed.ts
3
+ const NO_CONTENT_STATUS = 204;
4
+ async function fetchOptionalParsed(client, path, schema, options = {}) {
5
+ const response = await client.requestRaw(path, {
6
+ ...options,
7
+ method: "GET",
8
+ expectContentType: "binary"
9
+ });
10
+ if (response.status === NO_CONTENT_STATUS) return null;
11
+ return parseJsonOrPlain(await response.text(), response.headers.get("content-type"), schema, { source: response.url });
12
+ }
13
+ //#endregion
14
+ export { fetchOptionalParsed };
@@ -0,0 +1,10 @@
1
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ import { a as PermissionsGraph } from "../permission-BnCQw5Kp.js";
3
+ //#region src/resources/permission.d.ts
4
+ declare function permissionResource(transport: Transport): {
5
+ graph: (options?: RequestOptions) => Promise<PermissionsGraph>;
6
+ databaseGraph: (id: number, options?: RequestOptions) => Promise<PermissionsGraph>;
7
+ groupGraph: (id: number, options?: RequestOptions) => Promise<PermissionsGraph>;
8
+ };
9
+ //#endregion
10
+ export { permissionResource };
@@ -0,0 +1,31 @@
1
+ import { PermissionsGraph } from "../domain/permission.js";
2
+ //#region src/resources/permission.ts
3
+ function permissionResource(transport) {
4
+ /**
5
+ * Get the data permissions of every group on every database, keyed by group id then database
6
+ * id. Admin only. One read of the whole `data_permissions` table, so prefer `databaseGraph` when
7
+ * one database is the question.
8
+ */
9
+ async function graph(options = {}) {
10
+ return transport.requestParsed(PermissionsGraph, "/api/permissions/graph", { ...options });
11
+ }
12
+ /**
13
+ * Get the data permissions of every group on one database. Admin only. The read is filtered to
14
+ * that database, so this is the cheapest way to learn which groups can query a table: look the
15
+ * group up under the database and read `view-data` and `create-queries` down to the table id.
16
+ */
17
+ async function databaseGraph(id, options = {}) {
18
+ return transport.requestParsed(PermissionsGraph, `/api/permissions/graph/db/${id}`, { ...options });
19
+ }
20
+ /** Get the data permissions of one group on every database. Admin only. */
21
+ async function groupGraph(id, options = {}) {
22
+ return transport.requestParsed(PermissionsGraph, `/api/permissions/graph/group/${id}`, { ...options });
23
+ }
24
+ return {
25
+ graph,
26
+ databaseGraph,
27
+ groupGraph
28
+ };
29
+ }
30
+ //#endregion
31
+ export { permissionResource };
@@ -0,0 +1,10 @@
1
+ import { n as ExportFormat } from "../query-Xsin530u.js";
2
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
3
+ //#region src/resources/pivot-export.d.ts
4
+ /**
5
+ * Refuse a pivoted export the server would answer with plain rows: a JSON export keeps only the
6
+ * ungrouped rows, and an admin can turn pivoted CSV and XLSX exports off.
7
+ */
8
+ declare function assertPivotedExport(transport: Transport, format: ExportFormat, options: RequestOptions): Promise<void>;
9
+ //#endregion
10
+ export { assertPivotedExport };
@@ -0,0 +1,16 @@
1
+ import { SessionProperties } from "../domain/session-properties.js";
2
+ import { ConfigError } from "../errors.js";
3
+ import { PivotExportFormat } from "../domain/query.js";
4
+ import { z } from "zod";
5
+ //#region src/resources/pivot-export.ts
6
+ const PivotedExportsProperty = SessionProperties.extend({ "enable-pivoted-exports": z.boolean() });
7
+ /**
8
+ * Refuse a pivoted export the server would answer with plain rows: a JSON export keeps only the
9
+ * ungrouped rows, and an admin can turn pivoted CSV and XLSX exports off.
10
+ */
11
+ async function assertPivotedExport(transport, format, options) {
12
+ if (!PivotExportFormat.safeParse(format).success) throw new ConfigError(`a ${format} export cannot be pivoted; only ${PivotExportFormat.options.join(" and ")} can`);
13
+ if (!(await transport.probe(PivotedExportsProperty, options))["enable-pivoted-exports"]) throw new ConfigError("the server has pivoted exports turned off (the enable-pivoted-exports setting), so it would export the plain rows");
14
+ }
15
+ //#endregion
16
+ export { assertPivotedExport };
@@ -0,0 +1,2 @@
1
+ import { n as mergePulseUpdate, r as pulseResource, t as PulseListParams } from "../pulse-dylocLd9.js";
2
+ export { PulseListParams, mergePulseUpdate, pulseResource };
@@ -0,0 +1,75 @@
1
+ import { Pulse } from "../domain/pulse.js";
2
+ import { z } from "zod";
3
+ //#region src/resources/pulse.ts
4
+ const PulseApiList = z.array(Pulse);
5
+ function mergePulseUpdate(current, patch) {
6
+ return {
7
+ ...patch,
8
+ archived: patch.archived ?? current.archived,
9
+ skip_if_empty: patch.skip_if_empty ?? current.skip_if_empty
10
+ };
11
+ }
12
+ function pulseResource(transport) {
13
+ /** List dashboard subscriptions, optionally narrowed to one dashboard or to the archived ones. */
14
+ async function list(params = {}, options = {}) {
15
+ return {
16
+ data: await transport.requestParsed(PulseApiList, "/api/pulse", {
17
+ ...options,
18
+ query: {
19
+ dashboard_id: params.dashboard_id,
20
+ archived: params.archived
21
+ }
22
+ }),
23
+ total: null
24
+ };
25
+ }
26
+ /** Get one dashboard subscription by id. */
27
+ async function get(id, options = {}) {
28
+ return transport.requestParsed(Pulse, `/api/pulse/${id}`, { ...options });
29
+ }
30
+ /**
31
+ * Create a dashboard subscription — its cards and its delivery channels — from a full body.
32
+ * Non-empty `parameters` need the `dashboard_subscription_filters` premium feature, and are
33
+ * refused before the wire without it.
34
+ */
35
+ async function create(params, options = {}) {
36
+ await requireSubscriptionFilters(params.parameters, options);
37
+ return transport.requestParsed(Pulse, "/api/pulse", {
38
+ ...options,
39
+ method: "POST",
40
+ body: params
41
+ });
42
+ }
43
+ /**
44
+ * Update a dashboard subscription by id, carrying the server-defaulted flags forward. Non-empty
45
+ * `parameters` are refused as on `create`.
46
+ */
47
+ async function update(id, params, options = {}) {
48
+ await requireSubscriptionFilters(params.parameters, options);
49
+ const current = await get(id, options);
50
+ return transport.requestParsed(Pulse, `/api/pulse/${id}`, {
51
+ ...options,
52
+ method: "PUT",
53
+ body: mergePulseUpdate(current, params)
54
+ });
55
+ }
56
+ /**
57
+ * Archive a dashboard subscription by id, stopping every delivery. Metabase models this as an
58
+ * update, and disables each of the subscription's channels as a side effect.
59
+ */
60
+ async function archive(id, options = {}) {
61
+ return update(id, { archived: true }, options);
62
+ }
63
+ async function requireSubscriptionFilters(parameters, options) {
64
+ if (parameters !== void 0 && parameters.length > 0) await transport.requireFeatures(["dashboardSubscriptionFilters"], options);
65
+ }
66
+ return {
67
+ list,
68
+ get,
69
+ create,
70
+ update,
71
+ archive
72
+ };
73
+ }
74
+ //#endregion
75
+ export { mergePulseUpdate, pulseResource };
@@ -0,0 +1,2 @@
1
+ import { n as replacementResource, t as ReplacementRunListParams } from "../replacement-S9U3gApY.js";
2
+ export { ReplacementRunListParams, replacementResource };
@@ -0,0 +1,82 @@
1
+ import { t as explainer } from "../refusal-B9aeHMc9.js";
2
+ import { ReplacementCheck, ReplacementRun, ReplacementRunStarted } from "../domain/replacement.js";
3
+ import { z } from "zod";
4
+ //#region src/resources/replacement.ts
5
+ const ReplacementApiRunList = z.array(ReplacementRun);
6
+ const CancelRunResponse = z.object({ success: z.literal(true) });
7
+ function replacementResource(transport) {
8
+ const { explain } = explainer(transport, "replacement");
9
+ /**
10
+ * Check whether every usage of a source entity could be rewritten to read a target entity
11
+ * instead: the two must share a database, the target must not depend on the source, every source
12
+ * column must exist on the target with a compatible type, and a table source must not be joined
13
+ * implicitly or sandboxed. Admins only.
14
+ */
15
+ async function checkReplaceSource(params, options = {}) {
16
+ return transport.requestParsed(ReplacementCheck, "/api/ee/replacement/check-replace-source", {
17
+ ...options,
18
+ method: "POST",
19
+ body: params
20
+ });
21
+ }
22
+ /**
23
+ * Rewrite every usage of a source entity to read a target entity, in the background. Runs the
24
+ * same check as `checkReplaceSource` first and refuses with a 400 when it fails, and with a 409
25
+ * while another replacement is running. Admins only.
26
+ */
27
+ async function replaceSource(params, options = {}) {
28
+ return transport.requestParsed(ReplacementRunStarted, "/api/ee/replacement/replace-source", {
29
+ ...options,
30
+ method: "POST",
31
+ body: params
32
+ });
33
+ }
34
+ /**
35
+ * Create a transform from a model's query, run it, and rewrite every usage of the model to read
36
+ * the transform's output table, in the background; the model becomes a saved question. A failed
37
+ * transform run leaves the model as it was; a failed rewrite keeps the transform and its table
38
+ * as well, since other queries may already read them. Refuses with a 409 while another
39
+ * replacement is running. Admins only.
40
+ */
41
+ async function replaceModelWithTransform(params, options = {}) {
42
+ return transport.requestParsed(ReplacementRunStarted, "/api/ee/replacement/replace-model-with-transform", {
43
+ ...options,
44
+ method: "POST",
45
+ body: params
46
+ });
47
+ }
48
+ /**
49
+ * List replacement runs, newest first. `is-active: true` keeps only the run in progress,
50
+ * `false` only the ended ones. Admins only.
51
+ */
52
+ async function listRuns(params = {}, options = {}) {
53
+ return {
54
+ data: await transport.requestParsed(ReplacementApiRunList, "/api/ee/replacement/runs", {
55
+ ...options,
56
+ query: { "is-active": params["is-active"] }
57
+ }),
58
+ total: null
59
+ };
60
+ }
61
+ /** Get one replacement run by id, with its status and progress. Admins only. */
62
+ async function getRun(id, options = {}) {
63
+ return transport.requestParsed(ReplacementRun, `/api/ee/replacement/runs/${id}`, { ...options });
64
+ }
65
+ /** Cancel the replacement in progress. Refuses with a 409 once the run has ended. Admins only. */
66
+ async function cancelRun(id, options = {}) {
67
+ await transport.requestParsed(CancelRunResponse, `/api/ee/replacement/runs/${id}/cancel`, {
68
+ ...options,
69
+ method: "POST"
70
+ });
71
+ }
72
+ return {
73
+ checkReplaceSource: explain("checkReplaceSource", checkReplaceSource),
74
+ replaceSource: explain("replaceSource", replaceSource),
75
+ replaceModelWithTransform: explain("replaceModelWithTransform", replaceModelWithTransform),
76
+ listRuns: explain("listRuns", listRuns),
77
+ getRun: explain("getRun", getRun),
78
+ cancelRun: explain("cancelRun", cancelRun)
79
+ };
80
+ }
81
+ //#endregion
82
+ export { replacementResource };
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ //#region src/resources/request-body.d.ts
3
+ /**
4
+ * Parse the body a caller hands a method, refusing one that does not match `schema` before any
5
+ * request. `what` names the body in the refusal.
6
+ */
7
+ declare function parseRequestBody<T>(schema: z.ZodType<T>, value: unknown, what: string): T;
8
+ //#endregion
9
+ export { parseRequestBody };
@@ -0,0 +1,13 @@
1
+ import { ConfigError, formatZodIssue } from "../errors.js";
2
+ //#region src/resources/request-body.ts
3
+ /**
4
+ * Parse the body a caller hands a method, refusing one that does not match `schema` before any
5
+ * request. `what` names the body in the refusal.
6
+ */
7
+ function parseRequestBody(schema, value, what) {
8
+ const parsed = schema.safeParse(value);
9
+ if (!parsed.success) throw new ConfigError(`invalid ${what}: ${parsed.error.issues.map(formatZodIssue).join("; ")}`);
10
+ return parsed.data;
11
+ }
12
+ //#endregion
13
+ export { parseRequestBody };
@@ -0,0 +1,70 @@
1
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ import { t as ListResult } from "../list-BT_bBm9Z.js";
3
+ //#region src/resources/revision.d.ts
4
+ declare function revisionResource(transport: Transport): {
5
+ list: (entity: "card" | "dashboard" | "document" | "measure" | "segment" | "transform" | "transform-test", id: number, options?: RequestOptions | undefined) => Promise<ListResult<{
6
+ [x: string]: unknown;
7
+ id: number;
8
+ timestamp: string;
9
+ is_creation: boolean;
10
+ is_reversion: boolean;
11
+ most_recent: boolean;
12
+ diff: {
13
+ [x: string]: unknown;
14
+ } | null;
15
+ description: string;
16
+ has_multiple_changes: boolean;
17
+ user: {
18
+ [x: string]: unknown;
19
+ id: number;
20
+ first_name: string | null;
21
+ last_name: string | null;
22
+ common_name: string;
23
+ };
24
+ }>>;
25
+ revert: (params: {
26
+ entity: "card" | "dashboard" | "document" | "measure" | "segment" | "transform" | "transform-test";
27
+ id: number;
28
+ revision_id: number;
29
+ }, options?: RequestOptions | undefined) => Promise<{
30
+ outcome: "reverted";
31
+ revision: {
32
+ [x: string]: unknown;
33
+ id: number;
34
+ timestamp: string;
35
+ is_creation: boolean;
36
+ is_reversion: boolean;
37
+ most_recent: boolean;
38
+ diff: {
39
+ [x: string]: unknown;
40
+ } | null;
41
+ description: string;
42
+ has_multiple_changes: boolean;
43
+ user: {
44
+ [x: string]: unknown;
45
+ id: number;
46
+ first_name: string | null;
47
+ last_name: string | null;
48
+ common_name: string;
49
+ };
50
+ };
51
+ } | {
52
+ outcome: "unchanged";
53
+ revision: {
54
+ [x: string]: unknown;
55
+ id: number;
56
+ model: string;
57
+ model_id: number;
58
+ user_id: number;
59
+ object: {
60
+ [x: string]: unknown;
61
+ };
62
+ timestamp: string;
63
+ is_creation: boolean;
64
+ is_reversion: boolean;
65
+ most_recent: boolean;
66
+ };
67
+ }>;
68
+ };
69
+ //#endregion
70
+ export { revisionResource };
@@ -0,0 +1,51 @@
1
+ import { t as explainer } from "../refusal-B9aeHMc9.js";
2
+ import { Revision, RevisionRow } from "../domain/revision.js";
3
+ import { z } from "zod";
4
+ //#region src/resources/revision.ts
5
+ const RevisionApiList = z.array(Revision);
6
+ const RevisionApiRevert = z.union([Revision.transform((revision) => ({
7
+ outcome: "reverted",
8
+ revision
9
+ })), RevisionRow.transform((revision) => ({
10
+ outcome: "unchanged",
11
+ revision
12
+ }))]);
13
+ const ENTITY_FEATURES = {
14
+ measure: "measures",
15
+ transform: "transforms",
16
+ "transform-test": "transformTests"
17
+ };
18
+ function entityFeatures(entity) {
19
+ const feature = ENTITY_FEATURES[entity];
20
+ return feature === void 0 ? [] : [{
21
+ feature,
22
+ fields: ["entity"]
23
+ }];
24
+ }
25
+ function revisionResource(transport) {
26
+ const { explain } = explainer(transport, "revision");
27
+ /** List the revisions of an entity the caller may read, newest first, each with its diff. */
28
+ async function list(entity, id, options = {}) {
29
+ return {
30
+ data: await transport.requestParsed(RevisionApiList, `/api/revision/${entity}/${id}`, { ...options }),
31
+ total: null
32
+ };
33
+ }
34
+ /**
35
+ * Revert an entity to one of its prior revisions. Needs write access to the entity, and for a
36
+ * card the permission to run the query being restored.
37
+ */
38
+ async function revert(params, options = {}) {
39
+ return transport.requestParsed(RevisionApiRevert, "/api/revision/revert", {
40
+ ...options,
41
+ method: "POST",
42
+ body: params
43
+ });
44
+ }
45
+ return {
46
+ list: explain("list", list, entityFeatures),
47
+ revert: explain("revert", revert, (params) => entityFeatures(params.entity))
48
+ };
49
+ }
50
+ //#endregion
51
+ export { revisionResource };
@@ -0,0 +1,2 @@
1
+ import { n as SearchParams, r as searchResource, t as SearchPage } from "../search-BxJipLN6.js";
2
+ export { SearchPage, SearchParams, searchResource };
@@ -0,0 +1,57 @@
1
+ import { t as explainer } from "../refusal-B9aeHMc9.js";
2
+ import { SearchResult } from "../domain/search.js";
3
+ import { z } from "zod";
4
+ //#region src/resources/search.ts
5
+ const SearchApiResponse = z.object({
6
+ data: z.array(SearchResult),
7
+ total: z.number().int().nonnegative()
8
+ }).loose();
9
+ function verifiedFeatures(params = {}) {
10
+ return params.verified === true ? [{
11
+ feature: "contentVerification",
12
+ fields: ["verified"]
13
+ }] : [];
14
+ }
15
+ function searchResource(transport) {
16
+ const { explain } = explainer(transport, "search");
17
+ /**
18
+ * Search over the instance's content, ranked against `q`. `models` narrows which kinds of entity
19
+ * may match, `archived` swaps the active set for the archived one, `table_db_id` restricts to
20
+ * items on one database, `verified` to verified content, `collection` to one collection and its
21
+ * descendants, `created_by` to items created by any of those users, `search_native_query` also
22
+ * matches native query text but narrows to the models that carry one (cards, models, metrics,
23
+ * actions, transforms), `include_metadata` attaches each card's `result_metadata`,
24
+ * `include_dashboard_questions` also matches questions saved into a dashboard (excluded by
25
+ * default), and `limit`/`offset` are the window the server applies before ranking hydration.
26
+ * `verified` needs the `content_verification` premium feature, and is refused before the wire
27
+ * without it: a server granting neither it nor `official_collections` refuses the filter, and one
28
+ * granting `official_collections` alone takes it without applying it.
29
+ */
30
+ async function query(params = {}, options = {}) {
31
+ await transport.requireFeatures(verifiedFeatures(params).map((requirement) => requirement.feature), options);
32
+ const response = await transport.requestParsed(SearchApiResponse, "/api/search", {
33
+ ...options,
34
+ query: {
35
+ q: params.q,
36
+ models: params.models,
37
+ archived: params.archived,
38
+ limit: params.limit,
39
+ offset: params.offset,
40
+ table_db_id: params.table_db_id,
41
+ verified: params.verified,
42
+ collection: params.collection,
43
+ created_by: params.created_by,
44
+ search_native_query: params.search_native_query,
45
+ include_metadata: params.include_metadata,
46
+ include_dashboard_questions: params.include_dashboard_questions
47
+ }
48
+ });
49
+ return {
50
+ data: response.data,
51
+ total: response.total
52
+ };
53
+ }
54
+ return { query: explain("query", query, verifiedFeatures) };
55
+ }
56
+ //#endregion
57
+ export { searchResource };