@metabase/client 0.0.0-stage → 0.1.1

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 (337) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +661 -0
  3. package/README.md +490 -2
  4. package/dist/api-key-DJeN1-7G.d.ts +46 -0
  5. package/dist/auth/credential.d.ts +2 -0
  6. package/dist/auth/credential.js +61 -0
  7. package/dist/auth/oauth-login.d.ts +2 -0
  8. package/dist/auth/oauth-login.js +2 -0
  9. package/dist/auth/oauth-session.d.ts +2 -0
  10. package/dist/auth/oauth-session.js +31 -0
  11. package/dist/card-BxBzr5Uj.d.ts +1392 -0
  12. package/dist/card-DN0sLkCG.d.ts +33 -0
  13. package/dist/client-DdXLlH1B.d.ts +3380 -0
  14. package/dist/client.d.ts +2 -0
  15. package/dist/client.js +99 -0
  16. package/dist/collection-DGnTvD6R.d.ts +294 -0
  17. package/dist/collection-fFahL-ub.d.ts +53 -0
  18. package/dist/content-translation-zfUkE_OG.d.ts +8 -0
  19. package/dist/credential-6aOEGqMH.d.ts +30 -0
  20. package/dist/cron-DThzerR6.d.ts +9 -0
  21. package/dist/csv-upload--K35QedP.d.ts +8 -0
  22. package/dist/dashboard-CM7RmNeE.d.ts +38 -0
  23. package/dist/dashboard-DtLXVgtf.d.ts +978 -0
  24. package/dist/data-action-CkXVrOUH.d.ts +97 -0
  25. package/dist/data-app-CqP5_fpB.d.ts +76 -0
  26. package/dist/database-B0JNZjDN.d.ts +27 -0
  27. package/dist/database-BxqDmfcj.d.ts +997 -0
  28. package/dist/dataset-BBNGPVec.d.ts +4144 -0
  29. package/dist/dataset-BUirJ1rO.d.ts +23 -0
  30. package/dist/dependency-CzpXmeu7.d.ts +299 -0
  31. package/dist/dependency-arB8Cr2H.d.ts +879 -0
  32. package/dist/document-tLd6pYWe.d.ts +115 -0
  33. package/dist/domain/api-key.d.ts +2 -0
  34. package/dist/domain/api-key.js +31 -0
  35. package/dist/domain/card.d.ts +2 -0
  36. package/dist/domain/card.js +140 -0
  37. package/dist/domain/collection.d.ts +2 -0
  38. package/dist/domain/collection.js +137 -0
  39. package/dist/domain/content-translation.d.ts +2 -0
  40. package/dist/domain/content-translation.js +5 -0
  41. package/dist/domain/cron.d.ts +2 -0
  42. package/dist/domain/cron.js +5 -0
  43. package/dist/domain/dashboard.d.ts +2 -0
  44. package/dist/domain/dashboard.js +211 -0
  45. package/dist/domain/data-action.d.ts +2 -0
  46. package/dist/domain/data-action.js +91 -0
  47. package/dist/domain/data-app.d.ts +2 -0
  48. package/dist/domain/data-app.js +52 -0
  49. package/dist/domain/database.d.ts +2 -0
  50. package/dist/domain/database.js +56 -0
  51. package/dist/domain/dataset.d.ts +2 -0
  52. package/dist/domain/dataset.js +56 -0
  53. package/dist/domain/dependency.d.ts +2 -0
  54. package/dist/domain/dependency.js +168 -0
  55. package/dist/domain/document.d.ts +2 -0
  56. package/dist/domain/document.js +94 -0
  57. package/dist/domain/eid-translation.d.ts +2 -0
  58. package/dist/domain/eid-translation.js +36 -0
  59. package/dist/domain/embedding.d.ts +2 -0
  60. package/dist/domain/embedding.js +9 -0
  61. package/dist/domain/erd.d.ts +2 -0
  62. package/dist/domain/erd.js +45 -0
  63. package/dist/domain/field.d.ts +2 -0
  64. package/dist/domain/field.js +274 -0
  65. package/dist/domain/git-sync.d.ts +2 -0
  66. package/dist/domain/git-sync.js +147 -0
  67. package/dist/domain/glossary.d.ts +2 -0
  68. package/dist/domain/glossary.js +30 -0
  69. package/dist/domain/library.d.ts +2 -0
  70. package/dist/domain/library.js +89 -0
  71. package/dist/domain/measure.d.ts +2 -0
  72. package/dist/domain/measure.js +43 -0
  73. package/dist/domain/metric.d.ts +2 -0
  74. package/dist/domain/metric.js +139 -0
  75. package/dist/domain/moderation-review.d.ts +2 -0
  76. package/dist/domain/moderation-review.js +31 -0
  77. package/dist/domain/notification.d.ts +2 -0
  78. package/dist/domain/notification.js +143 -0
  79. package/dist/domain/parameter.d.ts +2 -0
  80. package/dist/domain/parameter.js +109 -0
  81. package/dist/domain/permission.d.ts +2 -0
  82. package/dist/domain/permission.js +36 -0
  83. package/dist/domain/pulse.d.ts +2 -0
  84. package/dist/domain/pulse.js +140 -0
  85. package/dist/domain/query.d.ts +2 -0
  86. package/dist/domain/query.js +13 -0
  87. package/dist/domain/replacement.d.ts +2 -0
  88. package/dist/domain/replacement.js +93 -0
  89. package/dist/domain/revision.d.ts +2 -0
  90. package/dist/domain/revision.js +90 -0
  91. package/dist/domain/search.d.ts +2 -0
  92. package/dist/domain/search.js +63 -0
  93. package/dist/domain/segment.d.ts +2 -0
  94. package/dist/domain/segment.js +46 -0
  95. package/dist/domain/session-properties.d.ts +2 -0
  96. package/dist/domain/session-properties.js +14 -0
  97. package/dist/domain/setting.d.ts +2 -0
  98. package/dist/domain/setting.js +22 -0
  99. package/dist/domain/setup.d.ts +2 -0
  100. package/dist/domain/setup.js +21 -0
  101. package/dist/domain/snippet.d.ts +2 -0
  102. package/dist/domain/snippet.js +38 -0
  103. package/dist/domain/table.d.ts +2 -0
  104. package/dist/domain/table.js +187 -0
  105. package/dist/domain/text.d.ts +5 -0
  106. package/dist/domain/text.js +6 -0
  107. package/dist/domain/timeline.d.ts +2 -0
  108. package/dist/domain/timeline.js +97 -0
  109. package/dist/domain/transform-dag-run.d.ts +2 -0
  110. package/dist/domain/transform-dag-run.js +19 -0
  111. package/dist/domain/transform-inspector.d.ts +2 -0
  112. package/dist/domain/transform-inspector.js +142 -0
  113. package/dist/domain/transform-job.d.ts +2 -0
  114. package/dist/domain/transform-job.js +115 -0
  115. package/dist/domain/transform-python.d.ts +2 -0
  116. package/dist/domain/transform-python.js +51 -0
  117. package/dist/domain/transform-tag.d.ts +2 -0
  118. package/dist/domain/transform-tag.js +17 -0
  119. package/dist/domain/transform-test.d.ts +2 -0
  120. package/dist/domain/transform-test.js +176 -0
  121. package/dist/domain/transform.d.ts +2 -0
  122. package/dist/domain/transform.js +304 -0
  123. package/dist/domain/upload.d.ts +2 -0
  124. package/dist/domain/upload.js +13 -0
  125. package/dist/domain/user.d.ts +2 -0
  126. package/dist/domain/user.js +16 -0
  127. package/dist/eid-translation-CH6NPWd-.d.ts +143 -0
  128. package/dist/embedding-oU3gqfgX.d.ts +10 -0
  129. package/dist/erd-BdeFEeSy.d.ts +842 -0
  130. package/dist/erd-CbV7xvAc.d.ts +51 -0
  131. package/dist/errors-DdMlaXqq.js +330 -0
  132. package/dist/errors.d.ts +2 -0
  133. package/dist/errors.js +189 -0
  134. package/dist/features-SMSfJhB6.d.ts +295 -0
  135. package/dist/field-D1Pfk-0S.d.ts +50 -0
  136. package/dist/field-p9Rme2zB.d.ts +2549 -0
  137. package/dist/git-sync-BTf1aYHr.d.ts +205 -0
  138. package/dist/git-sync-C99SVdJ9.d.ts +258 -0
  139. package/dist/glossary-CHK3elPj.d.ts +35 -0
  140. package/dist/glossary-DFvnz-E5.d.ts +15 -0
  141. package/dist/http/errors.d.ts +2 -0
  142. package/dist/http/errors.js +2 -0
  143. package/dist/http/oauth.d.ts +2 -0
  144. package/dist/http/oauth.js +201 -0
  145. package/dist/http/retry.d.ts +19 -0
  146. package/dist/http/retry.js +33 -0
  147. package/dist/http/transport.d.ts +2 -0
  148. package/dist/http/transport.js +2 -0
  149. package/dist/index.d.ts +62 -0
  150. package/dist/index.js +64 -0
  151. package/dist/input-gate-registry-Dai7SfXb.js +14 -0
  152. package/dist/input-gates-DwKoTJVQ.d.ts +28 -0
  153. package/dist/json-BksZpXDC.d.ts +19 -0
  154. package/dist/json-pointer.d.ts +5 -0
  155. package/dist/json-pointer.js +10 -0
  156. package/dist/json.d.ts +2 -0
  157. package/dist/json.js +44 -0
  158. package/dist/known-range-DTOBgTEC.d.ts +7 -0
  159. package/dist/library-B9pEq7qP.d.ts +230 -0
  160. package/dist/list-BT_bBm9Z.d.ts +7 -0
  161. package/dist/list.d.ts +2 -0
  162. package/dist/list.js +1 -0
  163. package/dist/measure-CgH14YQZ.d.ts +44 -0
  164. package/dist/measure-lPz8qnwz.d.ts +108 -0
  165. package/dist/metric-DcYloqOQ.d.ts +2655 -0
  166. package/dist/moderation-review-B4RUTZ6_.d.ts +56 -0
  167. package/dist/network-error-5g4U1iul.js +62 -0
  168. package/dist/notification-Cp5GJErS.d.ts +22 -0
  169. package/dist/notification-D1MThyKE.d.ts +443 -0
  170. package/dist/oauth-C4ordeoJ.d.ts +59 -0
  171. package/dist/oauth-login-CJsT_3EE.d.ts +19 -0
  172. package/dist/oauth-login-D734Jvbq.js +179 -0
  173. package/dist/oauth-session-BlIlcd8Q.d.ts +6 -0
  174. package/dist/paginate-COuL0Gzl.d.ts +24 -0
  175. package/dist/paginate.d.ts +2 -0
  176. package/dist/paginate.js +49 -0
  177. package/dist/parameter-ak-J-IOj.d.ts +190 -0
  178. package/dist/permission-BnCQw5Kp.d.ts +149 -0
  179. package/dist/poll-CIwnee7h.d.ts +15 -0
  180. package/dist/poll.d.ts +2 -0
  181. package/dist/poll.js +47 -0
  182. package/dist/predicates.d.ts +10 -0
  183. package/dist/predicates.js +18 -0
  184. package/dist/pulse-0LG3K6qO.d.ts +598 -0
  185. package/dist/pulse-BzKmz3Yn.d.ts +18 -0
  186. package/dist/query-Xsin530u.d.ts +23 -0
  187. package/dist/refusal-B9aeHMc9.js +130 -0
  188. package/dist/replacement-BGyggp-G.d.ts +2467 -0
  189. package/dist/replacement-CVebCuNp.d.ts +128 -0
  190. package/dist/requirement-check-glU7wqhQ.d.ts +17 -0
  191. package/dist/requirements-Dx_ZVzl7.d.ts +227 -0
  192. package/dist/resources/api-key.d.ts +11 -0
  193. package/dist/resources/api-key.js +35 -0
  194. package/dist/resources/card.d.ts +2 -0
  195. package/dist/resources/card.js +103 -0
  196. package/dist/resources/collection.d.ts +2 -0
  197. package/dist/resources/collection.js +134 -0
  198. package/dist/resources/content-translation.d.ts +11 -0
  199. package/dist/resources/content-translation.js +27 -0
  200. package/dist/resources/csv-upload.d.ts +2 -0
  201. package/dist/resources/csv-upload.js +9 -0
  202. package/dist/resources/dashboard.d.ts +2 -0
  203. package/dist/resources/dashboard.js +221 -0
  204. package/dist/resources/data-action.d.ts +60 -0
  205. package/dist/resources/data-action.js +79 -0
  206. package/dist/resources/data-app.d.ts +112 -0
  207. package/dist/resources/data-app.js +75 -0
  208. package/dist/resources/database.d.ts +2 -0
  209. package/dist/resources/database.js +103 -0
  210. package/dist/resources/dataset.d.ts +2 -0
  211. package/dist/resources/dataset.js +81 -0
  212. package/dist/resources/dependency.d.ts +2 -0
  213. package/dist/resources/dependency.js +156 -0
  214. package/dist/resources/document.d.ts +55 -0
  215. package/dist/resources/document.js +60 -0
  216. package/dist/resources/eid-translation.d.ts +8 -0
  217. package/dist/resources/eid-translation.js +19 -0
  218. package/dist/resources/erd.d.ts +2 -0
  219. package/dist/resources/erd.js +26 -0
  220. package/dist/resources/field.d.ts +2 -0
  221. package/dist/resources/field.js +99 -0
  222. package/dist/resources/git-sync.d.ts +2 -0
  223. package/dist/resources/git-sync.js +362 -0
  224. package/dist/resources/glossary.d.ts +2 -0
  225. package/dist/resources/glossary.js +51 -0
  226. package/dist/resources/library.d.ts +85 -0
  227. package/dist/resources/library.js +90 -0
  228. package/dist/resources/measure.d.ts +2 -0
  229. package/dist/resources/measure.js +57 -0
  230. package/dist/resources/metric.d.ts +2 -0
  231. package/dist/resources/metric.js +50 -0
  232. package/dist/resources/moderation-review.d.ts +23 -0
  233. package/dist/resources/moderation-review.js +24 -0
  234. package/dist/resources/notification.d.ts +2 -0
  235. package/dist/resources/notification.js +93 -0
  236. package/dist/resources/optional-parsed.d.ts +7 -0
  237. package/dist/resources/optional-parsed.js +14 -0
  238. package/dist/resources/permission.d.ts +10 -0
  239. package/dist/resources/permission.js +31 -0
  240. package/dist/resources/pivot-export.d.ts +10 -0
  241. package/dist/resources/pivot-export.js +16 -0
  242. package/dist/resources/pulse.d.ts +2 -0
  243. package/dist/resources/pulse.js +76 -0
  244. package/dist/resources/replacement.d.ts +2 -0
  245. package/dist/resources/replacement.js +82 -0
  246. package/dist/resources/request-body.d.ts +9 -0
  247. package/dist/resources/request-body.js +13 -0
  248. package/dist/resources/revision.d.ts +70 -0
  249. package/dist/resources/revision.js +46 -0
  250. package/dist/resources/search.d.ts +2 -0
  251. package/dist/resources/search.js +78 -0
  252. package/dist/resources/segment.d.ts +2 -0
  253. package/dist/resources/segment.js +55 -0
  254. package/dist/resources/setting.d.ts +11 -0
  255. package/dist/resources/setting.js +43 -0
  256. package/dist/resources/setup.d.ts +8 -0
  257. package/dist/resources/setup.js +18 -0
  258. package/dist/resources/snippet.d.ts +2 -0
  259. package/dist/resources/snippet.js +52 -0
  260. package/dist/resources/table.d.ts +2 -0
  261. package/dist/resources/table.js +274 -0
  262. package/dist/resources/timeline-event.d.ts +12 -0
  263. package/dist/resources/timeline-event.js +51 -0
  264. package/dist/resources/timeline.d.ts +2 -0
  265. package/dist/resources/timeline.js +82 -0
  266. package/dist/resources/transform-dag-run.d.ts +22 -0
  267. package/dist/resources/transform-dag-run.js +32 -0
  268. package/dist/resources/transform-inspector.d.ts +214 -0
  269. package/dist/resources/transform-inspector.js +47 -0
  270. package/dist/resources/transform-job.d.ts +2 -0
  271. package/dist/resources/transform-job.js +90 -0
  272. package/dist/resources/transform-python.d.ts +59 -0
  273. package/dist/resources/transform-python.js +57 -0
  274. package/dist/resources/transform-tag.d.ts +35 -0
  275. package/dist/resources/transform-tag.js +47 -0
  276. package/dist/resources/transform-test.d.ts +2 -0
  277. package/dist/resources/transform-test.js +75 -0
  278. package/dist/resources/transform.d.ts +2 -0
  279. package/dist/resources/transform.js +227 -0
  280. package/dist/resources/upload.d.ts +2 -0
  281. package/dist/resources/upload.js +48 -0
  282. package/dist/resources/user.d.ts +8 -0
  283. package/dist/resources/user.js +11 -0
  284. package/dist/revision-Dyl-8p7d.d.ts +106 -0
  285. package/dist/search-Cm5IxKss.d.ts +92 -0
  286. package/dist/search-Cten2h0I.d.ts +26 -0
  287. package/dist/segment-CbAgVO-5.d.ts +47 -0
  288. package/dist/segment-DQLX6r1E.d.ts +16 -0
  289. package/dist/session-properties-COtlxAcK.d.ts +15 -0
  290. package/dist/setting-DXuQGXGF.d.ts +25 -0
  291. package/dist/setup-JqcJ2unJ.d.ts +26 -0
  292. package/dist/signal.d.ts +8 -0
  293. package/dist/signal.js +25 -0
  294. package/dist/snippet-C_Ilx7tR.d.ts +41 -0
  295. package/dist/snippet-Djn0rL21.d.ts +16 -0
  296. package/dist/table-CDZbLNow.d.ts +176 -0
  297. package/dist/table-Od6uvDVW.d.ts +3234 -0
  298. package/dist/tag-qzjGGci8.d.ts +48 -0
  299. package/dist/timeline-BK45hy-h.d.ts +218 -0
  300. package/dist/timeline-BTs6fuRp.d.ts +21 -0
  301. package/dist/transform-C5thnJwW.d.ts +559 -0
  302. package/dist/transform-WASQAXeA.d.ts +652 -0
  303. package/dist/transform-dag-run-BgZwv1yx.d.ts +49 -0
  304. package/dist/transform-inspector-CMCh8WKV.d.ts +374 -0
  305. package/dist/transform-job-D8jTQtdX.d.ts +98 -0
  306. package/dist/transform-job-DmTwKxhc.d.ts +237 -0
  307. package/dist/transform-python-DtL3xxMj.d.ts +101 -0
  308. package/dist/transform-tag-C6j5EUkX.d.ts +25 -0
  309. package/dist/transform-test-CR_i54IV.d.ts +412 -0
  310. package/dist/transform-test-CeMzDpUC.d.ts +346 -0
  311. package/dist/transport-BsXqRujn.d.ts +476 -0
  312. package/dist/transport-HP7cyo9N.js +397 -0
  313. package/dist/upload-B5YjVkSW.d.ts +12 -0
  314. package/dist/upload-UPfZFdbH.d.ts +22 -0
  315. package/dist/url-CI0pxHOc.d.ts +7 -0
  316. package/dist/url.d.ts +2 -0
  317. package/dist/url.js +34 -0
  318. package/dist/user-Sqqv7rqh.d.ts +18 -0
  319. package/dist/version/capability-error.d.ts +2 -0
  320. package/dist/version/capability-error.js +42 -0
  321. package/dist/version/features.d.ts +2 -0
  322. package/dist/version/features.js +171 -0
  323. package/dist/version/input-gates.d.ts +2 -0
  324. package/dist/version/input-gates.js +13 -0
  325. package/dist/version/known-range.d.ts +2 -0
  326. package/dist/version/known-range.js +7 -0
  327. package/dist/version/probe.d.ts +2 -0
  328. package/dist/version/probe.js +30 -0
  329. package/dist/version/profile.d.ts +2 -0
  330. package/dist/version/profile.js +64 -0
  331. package/dist/version/requirement-check.d.ts +2 -0
  332. package/dist/version/requirement-check.js +62 -0
  333. package/dist/version/requirements.d.ts +2 -0
  334. package/dist/version/requirements.js +229 -0
  335. package/dist/version/tag.d.ts +2 -0
  336. package/dist/version/tag.js +52 -0
  337. package/package.json +66 -4
@@ -0,0 +1,179 @@
1
+ import { ConfigError } from "./errors.js";
2
+ import { oauthCredentialFromTokens } from "./auth/credential.js";
3
+ import { OAUTH_SCOPE, discoverLoginMetadata, exchangeCode, registerClient } from "./http/oauth.js";
4
+ import { createServer } from "node:http";
5
+ import { createHash, randomBytes } from "node:crypto";
6
+ //#region src/auth/callback-server.ts
7
+ const LOOPBACK_HOST = "127.0.0.1";
8
+ const CALLBACK_PATH = "/callback";
9
+ const DEFAULT_TIMEOUT_MS = 3e5;
10
+ function parseCallbackQuery(rawUrl) {
11
+ const queryStart = rawUrl.indexOf("?");
12
+ const params = new URLSearchParams(queryStart === -1 ? "" : rawUrl.slice(queryStart + 1));
13
+ return {
14
+ code: params.get("code"),
15
+ state: params.get("state"),
16
+ error: params.get("error"),
17
+ errorDescription: params.get("error_description")
18
+ };
19
+ }
20
+ function isCallbackPath(rawUrl) {
21
+ const queryStart = rawUrl.indexOf("?");
22
+ return (queryStart === -1 ? rawUrl : rawUrl.slice(0, queryStart)) === CALLBACK_PATH;
23
+ }
24
+ function escapeHtml(value) {
25
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
26
+ }
27
+ function htmlPage(title, message) {
28
+ return "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>" + escapeHtml(title) + "</title></head><body style=\"font-family:system-ui;text-align:center;padding-top:4rem;color:#4c5773\"><h1>" + escapeHtml(title) + "</h1><p>" + escapeHtml(message) + "</p><p>You can close this tab and return to your terminal.</p></body></html>";
29
+ }
30
+ function respond(res, status, title, message) {
31
+ res.writeHead(status, {
32
+ "content-type": "text/html; charset=utf-8",
33
+ connection: "close"
34
+ });
35
+ res.end(htmlPage(title, message));
36
+ }
37
+ function serverPort(server) {
38
+ const address = server.address();
39
+ if (address === null || typeof address === "string") throw new ConfigError("could not determine loopback callback port");
40
+ return address.port;
41
+ }
42
+ function startCallbackServer(expectedState, timeoutMs = DEFAULT_TIMEOUT_MS) {
43
+ return new Promise((resolveServer, rejectServer) => {
44
+ let settle = null;
45
+ let fail = null;
46
+ let outcome = null;
47
+ const server = createServer((req, res) => {
48
+ const rawUrl = req.url ?? "";
49
+ if (!isCallbackPath(rawUrl)) {
50
+ respond(res, 404, "Not found", "Unexpected request.");
51
+ return;
52
+ }
53
+ const query = parseCallbackQuery(rawUrl);
54
+ if (query.state !== expectedState) {
55
+ respond(res, 400, "Login failed", "Invalid or missing state.");
56
+ return;
57
+ }
58
+ if (query.error !== null) {
59
+ const detail = query.errorDescription ?? query.error;
60
+ respond(res, 400, "Login failed", detail);
61
+ deliver(new ConfigError(`authorization denied: ${detail}`));
62
+ return;
63
+ }
64
+ if (query.code === null) {
65
+ respond(res, 400, "Login failed", "Missing authorization code.");
66
+ deliver(new ConfigError("authorization callback missing code"));
67
+ return;
68
+ }
69
+ respond(res, 200, "Login complete", "Authorization complete. You can close this window.");
70
+ deliver({
71
+ code: query.code,
72
+ state: query.state
73
+ });
74
+ });
75
+ function deliver(result) {
76
+ if (outcome !== null) return;
77
+ outcome = result;
78
+ if (result instanceof Error) fail?.(result);
79
+ else settle?.(result);
80
+ }
81
+ const timer = setTimeout(() => {
82
+ deliver(new ConfigError(`timed out waiting for browser login after ${timeoutMs}ms`));
83
+ }, timeoutMs);
84
+ timer.unref();
85
+ server.on("error", (error) => {
86
+ rejectServer(error);
87
+ deliver(error);
88
+ });
89
+ server.listen(0, LOOPBACK_HOST, () => {
90
+ const port = serverPort(server);
91
+ resolveServer({
92
+ redirectUri: `http://${LOOPBACK_HOST}:${port}${CALLBACK_PATH}`,
93
+ waitForCallback() {
94
+ return new Promise((resolve, reject) => {
95
+ if (outcome !== null) {
96
+ if (outcome instanceof Error) reject(outcome);
97
+ else resolve(outcome);
98
+ return;
99
+ }
100
+ settle = resolve;
101
+ fail = reject;
102
+ });
103
+ },
104
+ close() {
105
+ clearTimeout(timer);
106
+ server.close();
107
+ server.closeAllConnections();
108
+ }
109
+ });
110
+ });
111
+ });
112
+ }
113
+ //#endregion
114
+ //#region src/auth/pkce.ts
115
+ const VERIFIER_BYTES = 32;
116
+ const STATE_BYTES = 16;
117
+ function base64Url(buffer) {
118
+ return buffer.toString("base64url");
119
+ }
120
+ function generatePkce() {
121
+ const verifier = base64Url(randomBytes(VERIFIER_BYTES));
122
+ return {
123
+ verifier,
124
+ challenge: base64Url(createHash("sha256").update(verifier).digest())
125
+ };
126
+ }
127
+ function randomState() {
128
+ return base64Url(randomBytes(STATE_BYTES));
129
+ }
130
+ //#endregion
131
+ //#region src/auth/oauth-login.ts
132
+ function buildAuthorizeUrl(authorizationEndpoint, params) {
133
+ return `${authorizationEndpoint}${authorizationEndpoint.includes("?") ? "&" : "?"}${new URLSearchParams(params).toString()}`;
134
+ }
135
+ async function resolveClientId(input, registrationEndpoint, redirectUri) {
136
+ if (input.clientId !== void 0) return input.clientId;
137
+ if (registrationEndpoint === void 0) throw new ConfigError("this Metabase has dynamic client registration disabled; pass clientId with a pre-registered native client");
138
+ return (await registerClient({
139
+ registrationEndpoint,
140
+ redirectUri,
141
+ clientName: input.clientName,
142
+ userAgent: input.userAgent
143
+ })).client_id;
144
+ }
145
+ async function oauthLogin(input, deps) {
146
+ const metadata = input.metadata ?? await discoverLoginMetadata(input.baseUrl, input.userAgent);
147
+ const pkce = generatePkce();
148
+ const state = randomState();
149
+ const server = await startCallbackServer(state, input.timeoutMs);
150
+ try {
151
+ const clientId = await resolveClientId(input, metadata.registration_endpoint, server.redirectUri);
152
+ const authorizeUrl = buildAuthorizeUrl(metadata.authorization_endpoint, {
153
+ response_type: "code",
154
+ client_id: clientId,
155
+ redirect_uri: server.redirectUri,
156
+ code_challenge: pkce.challenge,
157
+ code_challenge_method: "S256",
158
+ state,
159
+ scope: OAUTH_SCOPE
160
+ });
161
+ const opened = await deps.openBrowser(authorizeUrl);
162
+ deps.onAuthorizeUrl(authorizeUrl, opened);
163
+ const callback = await server.waitForCallback();
164
+ const tokens = await exchangeCode({
165
+ tokenEndpoint: metadata.token_endpoint,
166
+ code: callback.code,
167
+ redirectUri: server.redirectUri,
168
+ clientId,
169
+ codeVerifier: pkce.verifier,
170
+ userAgent: input.userAgent
171
+ });
172
+ if (tokens.refresh_token === void 0) throw new ConfigError("token endpoint did not return a refresh token");
173
+ return oauthCredentialFromTokens(tokens, tokens.refresh_token, clientId, deps.now());
174
+ } finally {
175
+ server.close();
176
+ }
177
+ }
178
+ //#endregion
179
+ export { oauthLogin as t };
@@ -0,0 +1,6 @@
1
+ import { c as OAuthCredential } from "./credential-6aOEGqMH.js";
2
+ //#region src/auth/oauth-session.d.ts
3
+ declare function refreshOAuthCredential(baseUrl: string, credential: OAuthCredential, nowMs: number, userAgent: string): Promise<OAuthCredential>;
4
+ declare function revokeOAuthCredential(baseUrl: string, credential: OAuthCredential, userAgent: string): Promise<boolean>;
5
+ //#endregion
6
+ export { revokeOAuthCredential as n, refreshOAuthCredential as t };
@@ -0,0 +1,24 @@
1
+ import { d as QueryValue, h as Transport } from "./transport-BsXqRujn.js";
2
+ import { ZodType } from "zod";
3
+ //#region src/paginate.d.ts
4
+ declare const DEFAULT_PAGE_SIZE = 50;
5
+ interface PaginateOptions {
6
+ query?: Record<string, QueryValue>;
7
+ pageSize?: number;
8
+ offset?: number;
9
+ max?: number;
10
+ signal?: AbortSignal;
11
+ }
12
+ interface Page<T> {
13
+ items: T[];
14
+ total: number | null;
15
+ }
16
+ interface PaginatedEnvelope<T> {
17
+ data: T[];
18
+ total?: number | null | undefined;
19
+ limit?: number | undefined;
20
+ offset?: number | undefined;
21
+ }
22
+ declare function paginatePages<T>(client: Transport, path: string, itemSchema: ZodType<T>, opts?: PaginateOptions): AsyncIterable<Page<T>>;
23
+ //#endregion
24
+ export { paginatePages as a, PaginatedEnvelope as i, Page as n, PaginateOptions as r, DEFAULT_PAGE_SIZE as t };
@@ -0,0 +1,2 @@
1
+ import { a as paginatePages, i as PaginatedEnvelope, n as Page, r as PaginateOptions, t as DEFAULT_PAGE_SIZE } from "./paginate-COuL0Gzl.js";
2
+ export { DEFAULT_PAGE_SIZE, Page, PaginateOptions, PaginatedEnvelope, paginatePages };
@@ -0,0 +1,49 @@
1
+ import { ConfigError, InternalError } from "./errors.js";
2
+ import { z } from "zod";
3
+ //#region src/paginate.ts
4
+ const DEFAULT_PAGE_SIZE = 50;
5
+ async function* paginatePages(client, path, itemSchema, opts = {}) {
6
+ const envelopeSchema = paginatedEnvelopeSchema(itemSchema);
7
+ const pageSize = opts.pageSize ?? 50;
8
+ if (!Number.isInteger(pageSize) || pageSize < 1) throw new InternalError(`pageSize must be an integer of at least 1, got ${pageSize}`);
9
+ const start = opts.offset ?? 0;
10
+ const max = opts.max ?? Number.POSITIVE_INFINITY;
11
+ let taken = 0;
12
+ let previousHead = null;
13
+ while (taken < max) {
14
+ const remaining = max - taken;
15
+ const limit = Math.min(pageSize, remaining);
16
+ const offset = start + taken;
17
+ const envelope = await client.requestParsed(envelopeSchema, path, {
18
+ query: {
19
+ ...opts.query,
20
+ limit,
21
+ offset
22
+ },
23
+ ...opts.signal !== void 0 && { signal: opts.signal }
24
+ });
25
+ const items = envelope.data.length > remaining ? envelope.data.slice(0, remaining) : envelope.data;
26
+ const total = envelope.total ?? null;
27
+ const head = items.length === 0 ? null : JSON.stringify(items[0]);
28
+ if (head !== null && head === previousHead) throw new ConfigError(`the endpoint returned the same first row at offset ${offset} as at the previous offset; it is ignoring the offset parameter, so paging cannot advance`);
29
+ previousHead = head;
30
+ yield {
31
+ items,
32
+ total
33
+ };
34
+ if (items.length === 0) return;
35
+ const consumed = taken + items.length;
36
+ if (total !== null && start + consumed === total) return;
37
+ taken = consumed;
38
+ }
39
+ }
40
+ function paginatedEnvelopeSchema(itemSchema) {
41
+ return z.object({
42
+ data: z.array(itemSchema),
43
+ total: z.number().int().nonnegative().nullable().optional(),
44
+ limit: z.number().int().nonnegative().optional(),
45
+ offset: z.number().int().nonnegative().optional()
46
+ }).loose();
47
+ }
48
+ //#endregion
49
+ export { DEFAULT_PAGE_SIZE, paginatePages };
@@ -0,0 +1,190 @@
1
+ import { z } from "zod";
2
+ //#region src/domain/parameter.d.ts
3
+ declare const ParameterType: z.ZodEnum<{
4
+ number: "number";
5
+ boolean: "boolean";
6
+ id: "id";
7
+ date: "date";
8
+ text: "text";
9
+ "temporal-unit": "temporal-unit";
10
+ "date/single": "date/single";
11
+ category: "category";
12
+ "location/city": "location/city";
13
+ "location/state": "location/state";
14
+ "location/zip_code": "location/zip_code";
15
+ "location/country": "location/country";
16
+ "date/range": "date/range";
17
+ "date/month-year": "date/month-year";
18
+ "date/quarter-year": "date/quarter-year";
19
+ "date/relative": "date/relative";
20
+ "date/all-options": "date/all-options";
21
+ "number/!=": "number/!=";
22
+ "number/<=": "number/<=";
23
+ "number/=": "number/=";
24
+ "number/>=": "number/>=";
25
+ "number/between": "number/between";
26
+ "string/!=": "string/!=";
27
+ "string/=": "string/=";
28
+ "string/contains": "string/contains";
29
+ "string/does-not-contain": "string/does-not-contain";
30
+ "string/ends-with": "string/ends-with";
31
+ "string/starts-with": "string/starts-with";
32
+ "boolean/=": "boolean/=";
33
+ }>;
34
+ type ParameterType = z.infer<typeof ParameterType>;
35
+ declare const TemporalUnit: z.ZodEnum<{
36
+ default: "default";
37
+ millisecond: "millisecond";
38
+ second: "second";
39
+ minute: "minute";
40
+ hour: "hour";
41
+ day: "day";
42
+ week: "week";
43
+ month: "month";
44
+ quarter: "quarter";
45
+ year: "year";
46
+ "second-of-minute": "second-of-minute";
47
+ "minute-of-hour": "minute-of-hour";
48
+ "hour-of-day": "hour-of-day";
49
+ "day-of-week": "day-of-week";
50
+ "day-of-month": "day-of-month";
51
+ "day-of-year": "day-of-year";
52
+ "week-of-year": "week-of-year";
53
+ "month-of-year": "month-of-year";
54
+ "quarter-of-year": "quarter-of-year";
55
+ "year-of-era": "year-of-era";
56
+ }>;
57
+ type TemporalUnit = z.infer<typeof TemporalUnit>;
58
+ declare const ValuesSourceType: z.ZodEnum<{
59
+ card: "card";
60
+ "static-list": "static-list";
61
+ }>;
62
+ type ValuesSourceType = z.infer<typeof ValuesSourceType>;
63
+ declare const ValuesQueryType: z.ZodEnum<{
64
+ list: "list";
65
+ search: "search";
66
+ none: "none";
67
+ }>;
68
+ type ValuesQueryType = z.infer<typeof ValuesQueryType>;
69
+ declare const ParameterTemplateTagRef: z.ZodTuple<[z.ZodLiteral<"template-tag">, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
70
+ id: z.ZodString;
71
+ }, z.core.$loose>]>], null>;
72
+ declare const ParameterTextTagTarget: z.ZodTuple<[z.ZodLiteral<"text-tag">, z.ZodString], null>;
73
+ declare const ParameterTarget: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"dimension">, z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"template-tag">, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
74
+ id: z.ZodString;
75
+ }, z.core.$loose>]>], null>, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>], z.ZodUnknown>, z.ZodTuple<[z.ZodLiteral<"variable">, z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"template-tag">, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
76
+ id: z.ZodString;
77
+ }, z.core.$loose>]>], null>, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>], null>, z.ZodTuple<[z.ZodLiteral<"text-tag">, z.ZodString], null>, z.ZodNumber, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>;
78
+ type ParameterTarget = z.infer<typeof ParameterTarget>;
79
+ declare const ValuesSourceConfig: z.ZodObject<{
80
+ values: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
81
+ card_id: z.ZodOptional<z.ZodNumber>;
82
+ value_field: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodUnknown>>;
83
+ label_field: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodUnknown>>;
84
+ }, z.core.$loose>;
85
+ type ValuesSourceConfig = z.infer<typeof ValuesSourceConfig>;
86
+ declare const Parameter: z.ZodObject<{
87
+ id: z.ZodString;
88
+ type: z.ZodEnum<{
89
+ number: "number";
90
+ boolean: "boolean";
91
+ id: "id";
92
+ date: "date";
93
+ text: "text";
94
+ "temporal-unit": "temporal-unit";
95
+ "date/single": "date/single";
96
+ category: "category";
97
+ "location/city": "location/city";
98
+ "location/state": "location/state";
99
+ "location/zip_code": "location/zip_code";
100
+ "location/country": "location/country";
101
+ "date/range": "date/range";
102
+ "date/month-year": "date/month-year";
103
+ "date/quarter-year": "date/quarter-year";
104
+ "date/relative": "date/relative";
105
+ "date/all-options": "date/all-options";
106
+ "number/!=": "number/!=";
107
+ "number/<=": "number/<=";
108
+ "number/=": "number/=";
109
+ "number/>=": "number/>=";
110
+ "number/between": "number/between";
111
+ "string/!=": "string/!=";
112
+ "string/=": "string/=";
113
+ "string/contains": "string/contains";
114
+ "string/does-not-contain": "string/does-not-contain";
115
+ "string/ends-with": "string/ends-with";
116
+ "string/starts-with": "string/starts-with";
117
+ "boolean/=": "boolean/=";
118
+ }>;
119
+ name: z.ZodOptional<z.ZodString>;
120
+ slug: z.ZodOptional<z.ZodString>;
121
+ sectionId: z.ZodOptional<z.ZodString>;
122
+ default: z.ZodOptional<z.ZodUnknown>;
123
+ required: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
124
+ filteringParameters: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
125
+ target: z.ZodOptional<z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"dimension">, z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"template-tag">, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
126
+ id: z.ZodString;
127
+ }, z.core.$loose>]>], null>, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>], z.ZodUnknown>, z.ZodTuple<[z.ZodLiteral<"variable">, z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"template-tag">, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
128
+ id: z.ZodString;
129
+ }, z.core.$loose>]>], null>, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>], null>, z.ZodTuple<[z.ZodLiteral<"text-tag">, z.ZodString], null>, z.ZodNumber, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>>;
130
+ temporal_units: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
131
+ default: "default";
132
+ millisecond: "millisecond";
133
+ second: "second";
134
+ minute: "minute";
135
+ hour: "hour";
136
+ day: "day";
137
+ week: "week";
138
+ month: "month";
139
+ quarter: "quarter";
140
+ year: "year";
141
+ "second-of-minute": "second-of-minute";
142
+ "minute-of-hour": "minute-of-hour";
143
+ "hour-of-day": "hour-of-day";
144
+ "day-of-week": "day-of-week";
145
+ "day-of-month": "day-of-month";
146
+ "day-of-year": "day-of-year";
147
+ "week-of-year": "week-of-year";
148
+ "month-of-year": "month-of-year";
149
+ "quarter-of-year": "quarter-of-year";
150
+ "year-of-era": "year-of-era";
151
+ }>>>>;
152
+ values_query_type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
153
+ list: "list";
154
+ search: "search";
155
+ none: "none";
156
+ }>>>;
157
+ values_source_type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
158
+ card: "card";
159
+ "static-list": "static-list";
160
+ }>>>;
161
+ values_source_config: z.ZodOptional<z.ZodNullable<z.ZodObject<{
162
+ values: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
163
+ card_id: z.ZodOptional<z.ZodNumber>;
164
+ value_field: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodUnknown>>;
165
+ label_field: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodUnknown>>;
166
+ }, z.core.$loose>>>;
167
+ }, z.core.$loose>;
168
+ type Parameter = z.infer<typeof Parameter>;
169
+ declare const ParameterMapping: z.ZodObject<{
170
+ parameter_id: z.ZodString;
171
+ target: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"dimension">, z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"template-tag">, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
172
+ id: z.ZodString;
173
+ }, z.core.$loose>]>], null>, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>], z.ZodUnknown>, z.ZodTuple<[z.ZodLiteral<"variable">, z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"template-tag">, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
174
+ id: z.ZodString;
175
+ }, z.core.$loose>]>], null>, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>], null>, z.ZodTuple<[z.ZodLiteral<"text-tag">, z.ZodString], null>, z.ZodNumber, z.ZodTuple<[z.ZodString], z.ZodUnknown>]>;
176
+ card_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
177
+ }, z.core.$loose>;
178
+ type ParameterMapping = z.infer<typeof ParameterMapping>;
179
+ declare const ParameterValues: z.ZodObject<{
180
+ values: z.ZodArray<z.ZodArray<z.ZodUnknown>>;
181
+ has_more_values: z.ZodBoolean;
182
+ }, z.core.$loose>;
183
+ type ParameterValues = z.infer<typeof ParameterValues>;
184
+ declare const ParameterValuesCompact: z.ZodObject<{
185
+ values: z.ZodArray<z.ZodArray<z.ZodUnknown>>;
186
+ has_more_values: z.ZodBoolean;
187
+ }, z.core.$strip>;
188
+ type ParameterValuesCompact = z.infer<typeof ParameterValuesCompact>;
189
+ //#endregion
190
+ export { ParameterTextTagTarget as a, ParameterValuesCompact as c, ValuesSourceConfig as d, ValuesSourceType as f, ParameterTemplateTagRef as i, TemporalUnit as l, ParameterMapping as n, ParameterType as o, ParameterTarget as r, ParameterValues as s, Parameter as t, ValuesQueryType as u };
@@ -0,0 +1,149 @@
1
+ import { z } from "zod";
2
+ //#region src/domain/permission.d.ts
3
+ declare const ViewDataPermission: z.ZodEnum<{
4
+ unrestricted: "unrestricted";
5
+ "legacy-no-self-service": "legacy-no-self-service";
6
+ blocked: "blocked";
7
+ sandboxed: "sandboxed";
8
+ impersonated: "impersonated";
9
+ }>;
10
+ type ViewDataPermission = z.infer<typeof ViewDataPermission>;
11
+ declare const CreateQueriesPermission: z.ZodEnum<{
12
+ "query-builder-and-native": "query-builder-and-native";
13
+ "query-builder": "query-builder";
14
+ no: "no";
15
+ }>;
16
+ type CreateQueriesPermission = z.infer<typeof CreateQueriesPermission>;
17
+ declare const DownloadPermission: z.ZodEnum<{
18
+ full: "full";
19
+ limited: "limited";
20
+ }>;
21
+ type DownloadPermission = z.infer<typeof DownloadPermission>;
22
+ declare const DataModelPermission: z.ZodLiteral<"all">;
23
+ type DataModelPermission = z.infer<typeof DataModelPermission>;
24
+ declare const YesNoPermission: z.ZodEnum<{
25
+ no: "no";
26
+ yes: "yes";
27
+ }>;
28
+ type YesNoPermission = z.infer<typeof YesNoPermission>;
29
+ declare const DatabasePermissions: z.ZodObject<{
30
+ "view-data": z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
31
+ unrestricted: "unrestricted";
32
+ "legacy-no-self-service": "legacy-no-self-service";
33
+ blocked: "blocked";
34
+ sandboxed: "sandboxed";
35
+ impersonated: "impersonated";
36
+ }>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
37
+ unrestricted: "unrestricted";
38
+ "legacy-no-self-service": "legacy-no-self-service";
39
+ blocked: "blocked";
40
+ sandboxed: "sandboxed";
41
+ impersonated: "impersonated";
42
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
43
+ unrestricted: "unrestricted";
44
+ "legacy-no-self-service": "legacy-no-self-service";
45
+ blocked: "blocked";
46
+ sandboxed: "sandboxed";
47
+ impersonated: "impersonated";
48
+ }>>]>>]>>;
49
+ "create-queries": z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
50
+ "query-builder-and-native": "query-builder-and-native";
51
+ "query-builder": "query-builder";
52
+ no: "no";
53
+ }>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
54
+ "query-builder-and-native": "query-builder-and-native";
55
+ "query-builder": "query-builder";
56
+ no: "no";
57
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
58
+ "query-builder-and-native": "query-builder-and-native";
59
+ "query-builder": "query-builder";
60
+ no: "no";
61
+ }>>]>>]>>;
62
+ download: z.ZodOptional<z.ZodObject<{
63
+ schemas: z.ZodUnion<readonly [z.ZodEnum<{
64
+ full: "full";
65
+ limited: "limited";
66
+ }>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
67
+ full: "full";
68
+ limited: "limited";
69
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
70
+ full: "full";
71
+ limited: "limited";
72
+ }>>]>>]>;
73
+ }, z.core.$loose>>;
74
+ "data-model": z.ZodOptional<z.ZodObject<{
75
+ schemas: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodRecord<z.ZodString, z.ZodLiteral<"all">>]>>]>;
76
+ }, z.core.$loose>>;
77
+ details: z.ZodOptional<z.ZodEnum<{
78
+ no: "no";
79
+ yes: "yes";
80
+ }>>;
81
+ transforms: z.ZodOptional<z.ZodEnum<{
82
+ no: "no";
83
+ yes: "yes";
84
+ }>>;
85
+ }, z.core.$loose>;
86
+ type DatabasePermissions = z.infer<typeof DatabasePermissions>;
87
+ declare const PermissionsGraph: z.ZodObject<{
88
+ revision: z.ZodNumber;
89
+ groups: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
90
+ "view-data": z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
91
+ unrestricted: "unrestricted";
92
+ "legacy-no-self-service": "legacy-no-self-service";
93
+ blocked: "blocked";
94
+ sandboxed: "sandboxed";
95
+ impersonated: "impersonated";
96
+ }>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
97
+ unrestricted: "unrestricted";
98
+ "legacy-no-self-service": "legacy-no-self-service";
99
+ blocked: "blocked";
100
+ sandboxed: "sandboxed";
101
+ impersonated: "impersonated";
102
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
103
+ unrestricted: "unrestricted";
104
+ "legacy-no-self-service": "legacy-no-self-service";
105
+ blocked: "blocked";
106
+ sandboxed: "sandboxed";
107
+ impersonated: "impersonated";
108
+ }>>]>>]>>;
109
+ "create-queries": z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
110
+ "query-builder-and-native": "query-builder-and-native";
111
+ "query-builder": "query-builder";
112
+ no: "no";
113
+ }>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
114
+ "query-builder-and-native": "query-builder-and-native";
115
+ "query-builder": "query-builder";
116
+ no: "no";
117
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
118
+ "query-builder-and-native": "query-builder-and-native";
119
+ "query-builder": "query-builder";
120
+ no: "no";
121
+ }>>]>>]>>;
122
+ download: z.ZodOptional<z.ZodObject<{
123
+ schemas: z.ZodUnion<readonly [z.ZodEnum<{
124
+ full: "full";
125
+ limited: "limited";
126
+ }>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
127
+ full: "full";
128
+ limited: "limited";
129
+ }>, z.ZodRecord<z.ZodString, z.ZodEnum<{
130
+ full: "full";
131
+ limited: "limited";
132
+ }>>]>>]>;
133
+ }, z.core.$loose>>;
134
+ "data-model": z.ZodOptional<z.ZodObject<{
135
+ schemas: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodRecord<z.ZodString, z.ZodLiteral<"all">>]>>]>;
136
+ }, z.core.$loose>>;
137
+ details: z.ZodOptional<z.ZodEnum<{
138
+ no: "no";
139
+ yes: "yes";
140
+ }>>;
141
+ transforms: z.ZodOptional<z.ZodEnum<{
142
+ no: "no";
143
+ yes: "yes";
144
+ }>>;
145
+ }, z.core.$loose>>>;
146
+ }, z.core.$loose>;
147
+ type PermissionsGraph = z.infer<typeof PermissionsGraph>;
148
+ //#endregion
149
+ export { PermissionsGraph as a, DownloadPermission as i, DataModelPermission as n, ViewDataPermission as o, DatabasePermissions as r, YesNoPermission as s, CreateQueriesPermission as t };
@@ -0,0 +1,15 @@
1
+ //#region src/poll.d.ts
2
+ type Backoff = "fixed" | "exponential";
3
+ interface PollOptions {
4
+ intervalMs?: number;
5
+ maxIntervalMs?: number;
6
+ timeoutMs?: number;
7
+ backoff?: Backoff;
8
+ signal?: AbortSignal;
9
+ }
10
+ declare const DEFAULT_INTERVAL_MS = 2000;
11
+ declare const DEFAULT_MAX_INTERVAL_MS = 30000;
12
+ declare const DEFAULT_TIMEOUT_MS = 600000;
13
+ declare function pollUntil<T>(fn: (signal: AbortSignal) => Promise<T>, done: (value: T) => boolean, opts?: PollOptions): Promise<T>;
14
+ //#endregion
15
+ export { PollOptions as a, DEFAULT_TIMEOUT_MS as i, DEFAULT_INTERVAL_MS as n, pollUntil as o, DEFAULT_MAX_INTERVAL_MS as r, Backoff as t };
package/dist/poll.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { a as PollOptions, i as DEFAULT_TIMEOUT_MS, n as DEFAULT_INTERVAL_MS, o as pollUntil, r as DEFAULT_MAX_INTERVAL_MS, t as Backoff } from "./poll-CIwnee7h.js";
2
+ export { Backoff, DEFAULT_INTERVAL_MS, DEFAULT_MAX_INTERVAL_MS, DEFAULT_TIMEOUT_MS, PollOptions, pollUntil };
package/dist/poll.js ADDED
@@ -0,0 +1,47 @@
1
+ import { TimeoutError } from "./errors.js";
2
+ import { combineAborts, throwIfAborted } from "./signal.js";
3
+ import { setTimeout } from "node:timers/promises";
4
+ //#region src/poll.ts
5
+ const DEFAULT_INTERVAL_MS = 2e3;
6
+ const DEFAULT_MAX_INTERVAL_MS = 3e4;
7
+ const DEFAULT_TIMEOUT_MS = 6e5;
8
+ async function pollUntil(fn, done, opts = {}) {
9
+ const intervalMs = opts.intervalMs ?? 2e3;
10
+ const maxIntervalMs = opts.maxIntervalMs ?? 3e4;
11
+ const timeoutMs = opts.timeoutMs ?? 6e5;
12
+ const backoff = opts.backoff ?? "fixed";
13
+ const combined = combineAborts(AbortSignal.timeout(timeoutMs), opts.signal);
14
+ let interval = intervalMs;
15
+ let attempts = 0;
16
+ while (true) {
17
+ throwIfAborted(opts.signal);
18
+ if (combined.aborted) throw pollTimeout(timeoutMs, attempts);
19
+ let value;
20
+ try {
21
+ value = await fn(combined);
22
+ } catch (error) {
23
+ throwIfAborted(opts.signal);
24
+ if (combined.aborted) throw pollTimeout(timeoutMs, attempts);
25
+ throw error;
26
+ }
27
+ attempts += 1;
28
+ if (done(value)) return value;
29
+ try {
30
+ await setTimeout(interval, void 0, { signal: combined });
31
+ } catch (error) {
32
+ throwIfAborted(opts.signal);
33
+ if (combined.aborted) throw pollTimeout(timeoutMs, attempts);
34
+ throw error;
35
+ }
36
+ if (backoff === "exponential") interval = Math.min(interval * 2, maxIntervalMs);
37
+ }
38
+ }
39
+ function pollTimeout(timeoutMs, attempts) {
40
+ return new TimeoutError(`Polling timed out after ${timeoutMs}ms`, {
41
+ kind: "polling",
42
+ timeoutMs,
43
+ attempts
44
+ });
45
+ }
46
+ //#endregion
47
+ export { DEFAULT_INTERVAL_MS, DEFAULT_MAX_INTERVAL_MS, DEFAULT_TIMEOUT_MS, pollUntil };