@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,2 @@
1
+ import { n as segmentResource, t as SegmentArchiveParams } from "../segment-D2i34X9l.js";
2
+ export { SegmentArchiveParams, segmentResource };
@@ -0,0 +1,55 @@
1
+ import { Segment } from "../domain/segment.js";
2
+ import { z } from "zod";
3
+ //#region src/resources/segment.ts
4
+ const SegmentApiList = z.array(Segment);
5
+ function segmentResource(transport) {
6
+ /** List every segment the caller can see. */
7
+ async function list(options = {}) {
8
+ return {
9
+ data: await transport.requestParsed(SegmentApiList, "/api/segment", { ...options }),
10
+ total: null
11
+ };
12
+ }
13
+ /** Get one segment by id. */
14
+ async function get(id, options = {}) {
15
+ return transport.requestParsed(Segment, `/api/segment/${id}`, { ...options });
16
+ }
17
+ /** Create a segment — a reusable row filter over one table — from a full segment body. */
18
+ async function create(params, options = {}) {
19
+ return transport.requestParsed(Segment, "/api/segment", {
20
+ ...options,
21
+ method: "POST",
22
+ body: params
23
+ });
24
+ }
25
+ /**
26
+ * Update a segment by id, patching only the fields the body carries. `revision_message` is
27
+ * required: Metabase records every segment change in its revision history.
28
+ */
29
+ async function update(id, params, options = {}) {
30
+ return transport.requestParsed(Segment, `/api/segment/${id}`, {
31
+ ...options,
32
+ method: "PUT",
33
+ body: params
34
+ });
35
+ }
36
+ /**
37
+ * Archive (soft-delete) a segment by id. Metabase models this as an update, so it carries the
38
+ * same required `revision_message`.
39
+ */
40
+ async function archive(id, params, options = {}) {
41
+ return update(id, {
42
+ archived: true,
43
+ revision_message: params.revision_message
44
+ }, options);
45
+ }
46
+ return {
47
+ list,
48
+ get,
49
+ create,
50
+ update,
51
+ archive
52
+ };
53
+ }
54
+ //#endregion
55
+ export { segmentResource };
@@ -0,0 +1,11 @@
1
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ import { t as ListResult } from "../list-BT_bBm9Z.js";
3
+ import { t as Setting } from "../setting-DXuQGXGF.js";
4
+ //#region src/resources/setting.d.ts
5
+ declare function settingResource(transport: Transport): {
6
+ list: (options?: RequestOptions) => Promise<ListResult<Setting>>;
7
+ get: (key: string, options?: RequestOptions) => Promise<unknown>;
8
+ set: (key: string, value: unknown, options?: RequestOptions) => Promise<void>;
9
+ };
10
+ //#endregion
11
+ export { settingResource };
@@ -0,0 +1,43 @@
1
+ import { ConfigError, errorMessage } from "../errors.js";
2
+ import { fetchOptionalParsed } from "./optional-parsed.js";
3
+ import { Setting } from "../domain/setting.js";
4
+ import { z } from "zod";
5
+ //#region src/resources/setting.ts
6
+ const SettingApiList = z.array(Setting);
7
+ const UNKNOWN_SETTING_PREFIX = "Unknown setting:";
8
+ function rethrowSettingError(error, key) {
9
+ if (errorMessage(error).startsWith(UNKNOWN_SETTING_PREFIX)) throw new ConfigError(`unknown setting: ${key}`);
10
+ throw error;
11
+ }
12
+ function settingResource(transport) {
13
+ /** Get all settings and their values, with descriptions and environment-variable names. */
14
+ async function list(options = {}) {
15
+ return {
16
+ data: await transport.requestParsed(SettingApiList, "/api/setting", { ...options }),
17
+ total: null
18
+ };
19
+ }
20
+ /**
21
+ * Fetch a single setting's value by key. An unset setting answers 204 rather than 404, which
22
+ * reaches the caller as `null`; a string-typed setting answers bare text rather than JSON.
23
+ */
24
+ async function get(key, options = {}) {
25
+ return fetchOptionalParsed(transport, `/api/setting/${encodeURIComponent(key)}`, z.unknown(), options).catch((error) => rethrowSettingError(error, key));
26
+ }
27
+ /** Set a single setting's value by key. The endpoint answers 204 with no body. */
28
+ async function set(key, value, options = {}) {
29
+ await transport.requestRaw(`/api/setting/${encodeURIComponent(key)}`, {
30
+ ...options,
31
+ method: "PUT",
32
+ body: { value },
33
+ expectContentType: "binary"
34
+ }).catch((error) => rethrowSettingError(error, key));
35
+ }
36
+ return {
37
+ list,
38
+ get,
39
+ set
40
+ };
41
+ }
42
+ //#endregion
43
+ export { settingResource };
@@ -0,0 +1,8 @@
1
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ import { n as SetupResult, t as SetupInput } from "../setup-Ez_U7GmM.js";
3
+ //#region src/resources/setup.d.ts
4
+ declare function setupResource(transport: Transport): {
5
+ create: (params: SetupInput, options?: RequestOptions) => Promise<SetupResult>;
6
+ };
7
+ //#endregion
8
+ export { setupResource };
@@ -0,0 +1,18 @@
1
+ import { SetupResult } from "../domain/setup.js";
2
+ //#region src/resources/setup.ts
3
+ function setupResource(transport) {
4
+ /**
5
+ * Complete the initial setup wizard on a fresh instance, creating its first admin user and
6
+ * applying the instance preferences. The setup token is single-use.
7
+ */
8
+ async function create(params, options = {}) {
9
+ return transport.requestParsed(SetupResult, "/api/setup", {
10
+ ...options,
11
+ method: "POST",
12
+ body: params
13
+ });
14
+ }
15
+ return { create };
16
+ }
17
+ //#endregion
18
+ export { setupResource };
@@ -0,0 +1,2 @@
1
+ import { n as snippetResource, t as SnippetListParams } from "../snippet-RnnWa4TL.js";
2
+ export { SnippetListParams, snippetResource };
@@ -0,0 +1,52 @@
1
+ import { Snippet } from "../domain/snippet.js";
2
+ import { z } from "zod";
3
+ //#region src/resources/snippet.ts
4
+ const SnippetApiList = z.array(Snippet);
5
+ function snippetResource(transport) {
6
+ /** List native query snippets. `archived` swaps the listing to archived snippets. */
7
+ async function list(params = {}, options = {}) {
8
+ return {
9
+ data: await transport.requestParsed(SnippetApiList, "/api/native-query-snippet", {
10
+ ...options,
11
+ query: { archived: params.archived }
12
+ }),
13
+ total: null
14
+ };
15
+ }
16
+ /** Get one native query snippet by id. */
17
+ async function get(id, options = {}) {
18
+ return transport.requestParsed(Snippet, `/api/native-query-snippet/${id}`, { ...options });
19
+ }
20
+ /** Create a native query snippet from a name, its SQL fragment, and an optional collection. */
21
+ async function create(params, options = {}) {
22
+ return transport.requestParsed(Snippet, "/api/native-query-snippet", {
23
+ ...options,
24
+ method: "POST",
25
+ body: params
26
+ });
27
+ }
28
+ /** Update a native query snippet by id, patching only the fields the body carries. */
29
+ async function update(id, params, options = {}) {
30
+ return transport.requestParsed(Snippet, `/api/native-query-snippet/${id}`, {
31
+ ...options,
32
+ method: "PUT",
33
+ body: params
34
+ });
35
+ }
36
+ /**
37
+ * Archive (soft-delete) a native query snippet by id. Metabase models this as an update, not its
38
+ * own endpoint.
39
+ */
40
+ async function archive(id, options = {}) {
41
+ return update(id, { archived: true }, options);
42
+ }
43
+ return {
44
+ list,
45
+ get,
46
+ create,
47
+ update,
48
+ archive
49
+ };
50
+ }
51
+ //#endregion
52
+ export { snippetResource };
@@ -0,0 +1,2 @@
1
+ import { n as tableResource, t as TableListParams } from "../table-B_lfuaHc.js";
2
+ export { TableListParams, tableResource };
@@ -0,0 +1,275 @@
1
+ import { PartialWriteError } from "../errors.js";
2
+ import { CapabilityError } from "../version/capability-error.js";
3
+ import { supersedingFeature } from "../version/requirement-check.js";
4
+ import { Table, TableDataLayerTier, TableForeignKey, TableQueryMetadata, TableSelectors } from "../domain/table.js";
5
+ import { t as explainer } from "../refusal-B9aeHMc9.js";
6
+ import { buildCsvFormData } from "./csv-upload.js";
7
+ import { fetchOptionalParsed } from "./optional-parsed.js";
8
+ import { parseRequestBody } from "./request-body.js";
9
+ import { z } from "zod";
10
+ //#region src/resources/table.ts
11
+ const TableApiList = z.array(Table);
12
+ const TableApiFks = z.array(TableForeignKey);
13
+ const SyncSchemaResponse = z.object({ status: z.literal("ok") });
14
+ const FieldValuesResponse = z.object({ status: z.literal("success") });
15
+ const BulkEditResponse = z.object({});
16
+ const BULK_EDIT_PATH = "/api/data-studio/table/edit";
17
+ const BULK_SYNC_SCHEMA_PATH = "/api/data-studio/table/sync-schema";
18
+ const BULK_RESCAN_VALUES_PATH = "/api/data-studio/table/rescan-values";
19
+ const BULK_DISCARD_VALUES_PATH = "/api/data-studio/table/discard-values";
20
+ const LIST_PARAM_FEATURES = [
21
+ ["can-query", "tableListAccessFilters"],
22
+ ["can-write", "tableListAccessFilters"],
23
+ ["include-transform-targets", "tableListTransformTargets"],
24
+ ["unused-only", "tableUnusedFilter"],
25
+ ["published-only", "tableListPublishedFilter"]
26
+ ];
27
+ function listParamFeatures(params) {
28
+ return LIST_PARAM_FEATURES.filter(([param]) => params[param] === true).map(([, feature]) => feature);
29
+ }
30
+ function dataLayerFeatures(value, field) {
31
+ return isTierName(value) ? [{
32
+ feature: "tableDataLayerTiers",
33
+ fields: [field]
34
+ }] : [];
35
+ }
36
+ function isTierName(value) {
37
+ return value !== null && value !== void 0 && TableDataLayerTier.safeParse(value).success;
38
+ }
39
+ const UPLOAD_UPDATE_PATHS = {
40
+ append: "append-csv",
41
+ replace: "replace-csv"
42
+ };
43
+ function tableResource(transport) {
44
+ const { explain } = explainer(transport, "table");
45
+ /**
46
+ * List every table the caller can see, across all databases. `term` matches names and display
47
+ * names; `can-query` and `can-write` keep only the tables the caller may query or edit the
48
+ * metadata of; `include-transform-targets` adds tables a transform writes to; `unused-only` keeps
49
+ * tables nothing depends on; `published-only` keeps tables published to the library.
50
+ */
51
+ async function list(params = {}, options = {}) {
52
+ await transport.requireFeatures(listParamFeatures(params), options);
53
+ return {
54
+ data: await transport.requestParsed(TableApiList, "/api/table", {
55
+ ...options,
56
+ query: {
57
+ term: params.term,
58
+ "visibility-type": params["visibility-type"],
59
+ "data-layer": params["data-layer"],
60
+ "data-source": params["data-source"],
61
+ "owner-user-id": params["owner-user-id"],
62
+ "owner-email": params["owner-email"],
63
+ "orphan-only": params["orphan-only"],
64
+ "unused-only": params["unused-only"],
65
+ "published-only": params["published-only"],
66
+ "can-query": params["can-query"],
67
+ "can-write": params["can-write"],
68
+ "include-transform-targets": params["include-transform-targets"]
69
+ }
70
+ }),
71
+ total: null
72
+ };
73
+ }
74
+ /** Get one table by id, without its fields. */
75
+ async function get(id, options = {}) {
76
+ return transport.requestParsed(Table, `/api/table/${id}`, { ...options });
77
+ }
78
+ /** Update a table by id, patching only the fields the body carries. */
79
+ async function update(id, params, options = {}) {
80
+ await refuseRewrittenDataLayer(params.data_layer, options);
81
+ await requireDataAuthorityNull(params.data_authority, options);
82
+ const path = `/api/table/${id}`;
83
+ const updated = await transport.requestParsed(Table, path, {
84
+ ...options,
85
+ method: "PUT",
86
+ body: params
87
+ });
88
+ assertCollectionWritten(path, params.collection_id, updated);
89
+ return updated;
90
+ }
91
+ async function refuseRewrittenDataLayer(value, options) {
92
+ if (value === null || value === void 0 || isTierName(value)) return;
93
+ const profile = await transport.preflightServer(options);
94
+ if (profile === null) return;
95
+ const failure = supersedingFeature("tableDataLayerTiers", profile, `data_layer "${value}" is a medallion name; this server names a table's layer ${TableDataLayerTier.options.join(", ")} and would map it onto one of those without a word`);
96
+ if (failure !== null) transport.refuseBeforeSending(new CapabilityError(failure));
97
+ }
98
+ /** Get a table by id with its fields hydrated — the metadata the query builder runs on. */
99
+ async function queryMetadata(id, options = {}) {
100
+ return transport.requestParsed(TableQueryMetadata, `/api/table/${id}/query_metadata`, { ...options });
101
+ }
102
+ /**
103
+ * Get every foreign key whose destination is a field of this table. A table with no active
104
+ * fields answers no content, which is the same empty list.
105
+ */
106
+ async function fks(id, options = {}) {
107
+ return {
108
+ data: await fetchOptionalParsed(transport, `/api/table/${id}/fks`, TableApiFks, { ...options }) ?? [],
109
+ total: null
110
+ };
111
+ }
112
+ /**
113
+ * Trigger a sync of this table: its columns, their fingerprints and its cached field values. It
114
+ * never discovers new tables. The sync runs after the call returns; a warehouse the server cannot
115
+ * connect to is a 422.
116
+ */
117
+ async function syncSchema(id, options = {}) {
118
+ return {
119
+ id,
120
+ status: (await transport.requestParsed(SyncSchemaResponse, `/api/table/${id}/sync_schema`, {
121
+ ...options,
122
+ method: "POST"
123
+ })).status
124
+ };
125
+ }
126
+ /**
127
+ * Trigger an update of the field values of every eligible field of this table that already has a
128
+ * cached set. The scan runs after the call returns.
129
+ */
130
+ async function rescanValues(id, options = {}) {
131
+ return {
132
+ id,
133
+ status: (await transport.requestParsed(FieldValuesResponse, `/api/table/${id}/rescan_values`, {
134
+ ...options,
135
+ method: "POST"
136
+ })).status
137
+ };
138
+ }
139
+ /**
140
+ * Discard the cached field values of every field of this table, custom display values included.
141
+ * No scan recreates a discarded set; the server rebuilds it, without the display values, the next
142
+ * time the field's values are read.
143
+ */
144
+ async function discardValues(id, options = {}) {
145
+ return {
146
+ id,
147
+ status: (await transport.requestParsed(FieldValuesResponse, `/api/table/${id}/discard_values`, {
148
+ ...options,
149
+ method: "POST"
150
+ })).status
151
+ };
152
+ }
153
+ /**
154
+ * Set the same metadata on every table the selectors pick out. A table leaving the `hidden` data
155
+ * layer is re-synced after the call returns. The server answers the same whether or not the
156
+ * selectors matched a table.
157
+ */
158
+ async function bulkEdit(params, options = {}) {
159
+ await requireDataAuthorityNull(params.data_authority, options);
160
+ await transport.requestParsed(BulkEditResponse, BULK_EDIT_PATH, {
161
+ ...options,
162
+ method: "POST",
163
+ body: params
164
+ });
165
+ return {
166
+ accepted: true,
167
+ ...params
168
+ };
169
+ }
170
+ async function requireDataAuthorityNull(value, options) {
171
+ if (value === null) await transport.requireFeatures(["tableUserValueWithdrawal"], options);
172
+ }
173
+ async function postSelection(path, selectors, options) {
174
+ const body = parseRequestBody(TableSelectors, selectors, "table selectors");
175
+ await transport.requestRaw(path, {
176
+ ...options,
177
+ method: "POST",
178
+ body,
179
+ expectContentType: "binary"
180
+ });
181
+ return {
182
+ accepted: true,
183
+ ...body
184
+ };
185
+ }
186
+ /**
187
+ * Trigger a sync of every table the selectors pick out: its columns, their fingerprints and its
188
+ * cached field values. Every database behind them must answer a connection test first, or the
189
+ * call is a 422; the syncs run after it returns.
190
+ */
191
+ async function bulkSyncSchema(selectors, options = {}) {
192
+ return postSelection(BULK_SYNC_SCHEMA_PATH, selectors, options);
193
+ }
194
+ /**
195
+ * Trigger a field-values rescan of every table the selectors pick out, refreshing the sets that
196
+ * are already cached. The scans run after the call returns.
197
+ */
198
+ async function bulkRescanValues(selectors, options = {}) {
199
+ return postSelection(BULK_RESCAN_VALUES_PATH, selectors, options);
200
+ }
201
+ /**
202
+ * Discard the cached field values of every table the selectors pick out, custom display values
203
+ * included. No scan recreates a discarded set.
204
+ */
205
+ async function bulkDiscardValues(selectors, options = {}) {
206
+ return postSelection(BULK_DISCARD_VALUES_PATH, selectors, options);
207
+ }
208
+ async function updateFromCsv(id, action, file, options) {
209
+ await transport.requestRaw(`/api/table/${id}/${UPLOAD_UPDATE_PATHS[action]}`, {
210
+ ...options,
211
+ method: "POST",
212
+ body: buildCsvFormData(file),
213
+ expectContentType: "binary"
214
+ });
215
+ return {
216
+ table_id: id,
217
+ action
218
+ };
219
+ }
220
+ /**
221
+ * Inserts the rows of an uploaded CSV file into the table identified by `id`. The table must have
222
+ * been created by uploading a CSV file.
223
+ *
224
+ * The file may be at most 50 MB; larger uploads are rejected with a 413 response.
225
+ */
226
+ async function appendCsv(id, file, options = {}) {
227
+ return updateFromCsv(id, "append", file, options);
228
+ }
229
+ /**
230
+ * Replaces the contents of the table identified by `id` with the rows of an uploaded CSV file.
231
+ * The table must have been created by uploading a CSV file.
232
+ *
233
+ * The file may be at most 50 MB; larger uploads are rejected with a 413 response.
234
+ */
235
+ async function replaceCsv(id, file, options = {}) {
236
+ return updateFromCsv(id, "replace", file, options);
237
+ }
238
+ return {
239
+ list: explain("list", list, (params) => dataLayerFeatures(params?.["data-layer"], "data-layer")),
240
+ get,
241
+ update: explain("update", update, (_id, params) => dataLayerFeatures(params.data_layer, "data_layer")),
242
+ queryMetadata,
243
+ fks,
244
+ syncSchema,
245
+ rescanValues,
246
+ discardValues,
247
+ bulkEdit: explain("bulkEdit", bulkEdit),
248
+ bulkSyncSchema: explain("bulkSyncSchema", bulkSyncSchema),
249
+ bulkRescanValues: explain("bulkRescanValues", bulkRescanValues),
250
+ bulkDiscardValues: explain("bulkDiscardValues", bulkDiscardValues),
251
+ appendCsv,
252
+ replaceCsv
253
+ };
254
+ }
255
+ function assertCollectionWritten(path, requested, table) {
256
+ if (requested === void 0 || table.collection_id === requested) return;
257
+ const answered = table.collection_id === void 0 ? { kind: "unreported" } : {
258
+ kind: "reported",
259
+ value: table.collection_id
260
+ };
261
+ throw new PartialWriteError(`the server applied the rest of the update to table ${table.id} but not collection_id: ${describeCollectionAnswer(answered)}, because this server does not move a table to a collection through an update`, {
262
+ method: "PUT",
263
+ path,
264
+ field: "collection_id",
265
+ requested,
266
+ answered
267
+ });
268
+ }
269
+ function describeCollectionAnswer(answered) {
270
+ if (answered.kind === "unreported") return "it answered the table without reporting a collection";
271
+ if (answered.value === null) return "the table stays in no collection";
272
+ return `the table stays in collection ${answered.value}`;
273
+ }
274
+ //#endregion
275
+ export { tableResource };
@@ -0,0 +1,12 @@
1
+ import { f as RequestOptions, h as Transport } from "../transport-E0ZaPNWJ.js";
2
+ import { i as TimelineEvent, o as TimelineEventCreateInput, s as TimelineEventUpdateInput } from "../timeline-folD3mQ_.js";
3
+ //#region src/resources/timeline-event.d.ts
4
+ declare function timelineEventResource(transport: Transport): {
5
+ get: (id: number, options?: RequestOptions) => Promise<TimelineEvent>;
6
+ create: (params: TimelineEventCreateInput, options?: RequestOptions) => Promise<TimelineEvent>;
7
+ update: (id: number, params: TimelineEventUpdateInput, options?: RequestOptions) => Promise<TimelineEvent>;
8
+ archive: (id: number, options?: RequestOptions) => Promise<TimelineEvent>;
9
+ delete: (id: number, options?: RequestOptions) => Promise<void>;
10
+ };
11
+ //#endregion
12
+ export { timelineEventResource };
@@ -0,0 +1,51 @@
1
+ import { TimelineEvent } from "../domain/timeline.js";
2
+ //#region src/resources/timeline-event.ts
3
+ function timelineEventResource(transport) {
4
+ /** Get one timeline event by id. */
5
+ async function get(id, options = {}) {
6
+ return transport.requestParsed(TimelineEvent, `/api/timeline-event/${id}`, { ...options });
7
+ }
8
+ /** Create a timeline event on an existing timeline. */
9
+ async function create(params, options = {}) {
10
+ return transport.requestParsed(TimelineEvent, "/api/timeline-event", {
11
+ ...options,
12
+ method: "POST",
13
+ body: params
14
+ });
15
+ }
16
+ /**
17
+ * Update a timeline event by id, patching only the fields the body carries. `timeline_id` moves
18
+ * the event to another timeline.
19
+ */
20
+ async function update(id, params, options = {}) {
21
+ return transport.requestParsed(TimelineEvent, `/api/timeline-event/${id}`, {
22
+ ...options,
23
+ method: "PUT",
24
+ body: params
25
+ });
26
+ }
27
+ /**
28
+ * Archive (soft-delete) a timeline event by id. Metabase models this as an update, not its own
29
+ * endpoint.
30
+ */
31
+ async function archive(id, options = {}) {
32
+ return update(id, { archived: true }, options);
33
+ }
34
+ /** Permanently delete a timeline event by id. The server answers with no body. */
35
+ async function remove(id, options = {}) {
36
+ await transport.requestRaw(`/api/timeline-event/${id}`, {
37
+ ...options,
38
+ method: "DELETE",
39
+ expectContentType: "binary"
40
+ });
41
+ }
42
+ return {
43
+ get,
44
+ create,
45
+ update,
46
+ archive,
47
+ delete: remove
48
+ };
49
+ }
50
+ //#endregion
51
+ export { timelineEventResource };
@@ -0,0 +1,2 @@
1
+ import { n as TimelineListParams, r as timelineResource, t as TimelineEventsParams } from "../timeline-C2IEcRlP.js";
2
+ export { TimelineEventsParams, TimelineListParams, timelineResource };
@@ -0,0 +1,82 @@
1
+ import { Timeline } from "../domain/timeline.js";
2
+ import { z } from "zod";
3
+ //#region src/resources/timeline.ts
4
+ const TimelineApiList = z.array(Timeline);
5
+ const TimelineWithEvents = Timeline.required({ events: true });
6
+ function timelineResource(transport) {
7
+ /** List timelines. `archived` swaps the active listing for the archived one. */
8
+ async function list(params = {}, options = {}) {
9
+ return {
10
+ data: await transport.requestParsed(TimelineApiList, "/api/timeline", {
11
+ ...options,
12
+ query: { archived: params.archived }
13
+ }),
14
+ total: null
15
+ };
16
+ }
17
+ /** Get one timeline by id, without its events. */
18
+ async function get(id, options = {}) {
19
+ return transport.requestParsed(Timeline, `/api/timeline/${id}`, { ...options });
20
+ }
21
+ /**
22
+ * List the events on one timeline. Metabase has no endpoint of its own for these: the same
23
+ * timeline read hydrates them on request, and `archived` chooses which of them come back.
24
+ */
25
+ async function events(id, params = {}, options = {}) {
26
+ return {
27
+ data: (await transport.requestParsed(TimelineWithEvents, `/api/timeline/${id}`, {
28
+ ...options,
29
+ query: {
30
+ include: "events",
31
+ archived: params.archived
32
+ }
33
+ })).events,
34
+ total: null
35
+ };
36
+ }
37
+ /** Create a timeline from a full timeline body. */
38
+ async function create(params, options = {}) {
39
+ return transport.requestParsed(Timeline, "/api/timeline", {
40
+ ...options,
41
+ method: "POST",
42
+ body: params
43
+ });
44
+ }
45
+ /**
46
+ * Update a timeline by id, patching only the fields the body carries. Changing `archived`
47
+ * cascades to every event on the timeline.
48
+ */
49
+ async function update(id, params, options = {}) {
50
+ return transport.requestParsed(Timeline, `/api/timeline/${id}`, {
51
+ ...options,
52
+ method: "PUT",
53
+ body: params
54
+ });
55
+ }
56
+ /**
57
+ * Archive (soft-delete) a timeline and all its events by id. Metabase models this as an update,
58
+ * not its own endpoint.
59
+ */
60
+ async function archive(id, options = {}) {
61
+ return update(id, { archived: true }, options);
62
+ }
63
+ /** Permanently delete a timeline and all its events by id. The server answers with no body. */
64
+ async function remove(id, options = {}) {
65
+ await transport.requestRaw(`/api/timeline/${id}`, {
66
+ ...options,
67
+ method: "DELETE",
68
+ expectContentType: "binary"
69
+ });
70
+ }
71
+ return {
72
+ list,
73
+ get,
74
+ events,
75
+ create,
76
+ update,
77
+ archive,
78
+ delete: remove
79
+ };
80
+ }
81
+ //#endregion
82
+ export { timelineResource };
@@ -0,0 +1,22 @@
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/transform-dag-run.d.ts
4
+ declare function transformDagRunResource(transport: Transport): {
5
+ transformRuns: (runId: number, options?: RequestOptions | undefined) => Promise<ListResult<{
6
+ [x: string]: unknown;
7
+ id: number;
8
+ transform_id: number | null;
9
+ run_method: "manual" | "cron";
10
+ status: "timeout" | "failed" | "started" | "succeeded" | "canceled" | "canceling";
11
+ is_active: boolean | null;
12
+ start_time: string;
13
+ message: string | null;
14
+ user_id: number | null;
15
+ job_run_id: number | null;
16
+ dag_run_id: number | null;
17
+ end_time?: string | null | undefined;
18
+ }>>;
19
+ cancel: (runId: number, options?: RequestOptions | undefined) => Promise<void>;
20
+ };
21
+ //#endregion
22
+ export { transformDagRunResource };