@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.
- package/CHANGELOG.md +28 -0
- package/LICENSE +661 -0
- package/README.md +490 -2
- package/dist/api-key-DJeN1-7G.d.ts +46 -0
- package/dist/auth/credential.d.ts +2 -0
- package/dist/auth/credential.js +61 -0
- package/dist/auth/oauth-login.d.ts +2 -0
- package/dist/auth/oauth-login.js +2 -0
- package/dist/auth/oauth-session.d.ts +2 -0
- package/dist/auth/oauth-session.js +31 -0
- package/dist/card-BxBzr5Uj.d.ts +1392 -0
- package/dist/card-DN0sLkCG.d.ts +33 -0
- package/dist/client-DdXLlH1B.d.ts +3380 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +99 -0
- package/dist/collection-DGnTvD6R.d.ts +294 -0
- package/dist/collection-fFahL-ub.d.ts +53 -0
- package/dist/content-translation-zfUkE_OG.d.ts +8 -0
- package/dist/credential-6aOEGqMH.d.ts +30 -0
- package/dist/cron-DThzerR6.d.ts +9 -0
- package/dist/csv-upload--K35QedP.d.ts +8 -0
- package/dist/dashboard-CM7RmNeE.d.ts +38 -0
- package/dist/dashboard-DtLXVgtf.d.ts +978 -0
- package/dist/data-action-CkXVrOUH.d.ts +97 -0
- package/dist/data-app-CqP5_fpB.d.ts +76 -0
- package/dist/database-B0JNZjDN.d.ts +27 -0
- package/dist/database-BxqDmfcj.d.ts +997 -0
- package/dist/dataset-BBNGPVec.d.ts +4144 -0
- package/dist/dataset-BUirJ1rO.d.ts +23 -0
- package/dist/dependency-CzpXmeu7.d.ts +299 -0
- package/dist/dependency-arB8Cr2H.d.ts +879 -0
- package/dist/document-tLd6pYWe.d.ts +115 -0
- package/dist/domain/api-key.d.ts +2 -0
- package/dist/domain/api-key.js +31 -0
- package/dist/domain/card.d.ts +2 -0
- package/dist/domain/card.js +140 -0
- package/dist/domain/collection.d.ts +2 -0
- package/dist/domain/collection.js +137 -0
- package/dist/domain/content-translation.d.ts +2 -0
- package/dist/domain/content-translation.js +5 -0
- package/dist/domain/cron.d.ts +2 -0
- package/dist/domain/cron.js +5 -0
- package/dist/domain/dashboard.d.ts +2 -0
- package/dist/domain/dashboard.js +211 -0
- package/dist/domain/data-action.d.ts +2 -0
- package/dist/domain/data-action.js +91 -0
- package/dist/domain/data-app.d.ts +2 -0
- package/dist/domain/data-app.js +52 -0
- package/dist/domain/database.d.ts +2 -0
- package/dist/domain/database.js +56 -0
- package/dist/domain/dataset.d.ts +2 -0
- package/dist/domain/dataset.js +56 -0
- package/dist/domain/dependency.d.ts +2 -0
- package/dist/domain/dependency.js +168 -0
- package/dist/domain/document.d.ts +2 -0
- package/dist/domain/document.js +94 -0
- package/dist/domain/eid-translation.d.ts +2 -0
- package/dist/domain/eid-translation.js +36 -0
- package/dist/domain/embedding.d.ts +2 -0
- package/dist/domain/embedding.js +9 -0
- package/dist/domain/erd.d.ts +2 -0
- package/dist/domain/erd.js +45 -0
- package/dist/domain/field.d.ts +2 -0
- package/dist/domain/field.js +274 -0
- package/dist/domain/git-sync.d.ts +2 -0
- package/dist/domain/git-sync.js +147 -0
- package/dist/domain/glossary.d.ts +2 -0
- package/dist/domain/glossary.js +30 -0
- package/dist/domain/library.d.ts +2 -0
- package/dist/domain/library.js +89 -0
- package/dist/domain/measure.d.ts +2 -0
- package/dist/domain/measure.js +43 -0
- package/dist/domain/metric.d.ts +2 -0
- package/dist/domain/metric.js +139 -0
- package/dist/domain/moderation-review.d.ts +2 -0
- package/dist/domain/moderation-review.js +31 -0
- package/dist/domain/notification.d.ts +2 -0
- package/dist/domain/notification.js +143 -0
- package/dist/domain/parameter.d.ts +2 -0
- package/dist/domain/parameter.js +109 -0
- package/dist/domain/permission.d.ts +2 -0
- package/dist/domain/permission.js +36 -0
- package/dist/domain/pulse.d.ts +2 -0
- package/dist/domain/pulse.js +140 -0
- package/dist/domain/query.d.ts +2 -0
- package/dist/domain/query.js +13 -0
- package/dist/domain/replacement.d.ts +2 -0
- package/dist/domain/replacement.js +93 -0
- package/dist/domain/revision.d.ts +2 -0
- package/dist/domain/revision.js +90 -0
- package/dist/domain/search.d.ts +2 -0
- package/dist/domain/search.js +63 -0
- package/dist/domain/segment.d.ts +2 -0
- package/dist/domain/segment.js +46 -0
- package/dist/domain/session-properties.d.ts +2 -0
- package/dist/domain/session-properties.js +14 -0
- package/dist/domain/setting.d.ts +2 -0
- package/dist/domain/setting.js +22 -0
- package/dist/domain/setup.d.ts +2 -0
- package/dist/domain/setup.js +21 -0
- package/dist/domain/snippet.d.ts +2 -0
- package/dist/domain/snippet.js +38 -0
- package/dist/domain/table.d.ts +2 -0
- package/dist/domain/table.js +187 -0
- package/dist/domain/text.d.ts +5 -0
- package/dist/domain/text.js +6 -0
- package/dist/domain/timeline.d.ts +2 -0
- package/dist/domain/timeline.js +97 -0
- package/dist/domain/transform-dag-run.d.ts +2 -0
- package/dist/domain/transform-dag-run.js +19 -0
- package/dist/domain/transform-inspector.d.ts +2 -0
- package/dist/domain/transform-inspector.js +142 -0
- package/dist/domain/transform-job.d.ts +2 -0
- package/dist/domain/transform-job.js +115 -0
- package/dist/domain/transform-python.d.ts +2 -0
- package/dist/domain/transform-python.js +51 -0
- package/dist/domain/transform-tag.d.ts +2 -0
- package/dist/domain/transform-tag.js +17 -0
- package/dist/domain/transform-test.d.ts +2 -0
- package/dist/domain/transform-test.js +176 -0
- package/dist/domain/transform.d.ts +2 -0
- package/dist/domain/transform.js +304 -0
- package/dist/domain/upload.d.ts +2 -0
- package/dist/domain/upload.js +13 -0
- package/dist/domain/user.d.ts +2 -0
- package/dist/domain/user.js +16 -0
- package/dist/eid-translation-CH6NPWd-.d.ts +143 -0
- package/dist/embedding-oU3gqfgX.d.ts +10 -0
- package/dist/erd-BdeFEeSy.d.ts +842 -0
- package/dist/erd-CbV7xvAc.d.ts +51 -0
- package/dist/errors-DdMlaXqq.js +330 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +189 -0
- package/dist/features-SMSfJhB6.d.ts +295 -0
- package/dist/field-D1Pfk-0S.d.ts +50 -0
- package/dist/field-p9Rme2zB.d.ts +2549 -0
- package/dist/git-sync-BTf1aYHr.d.ts +205 -0
- package/dist/git-sync-C99SVdJ9.d.ts +258 -0
- package/dist/glossary-CHK3elPj.d.ts +35 -0
- package/dist/glossary-DFvnz-E5.d.ts +15 -0
- package/dist/http/errors.d.ts +2 -0
- package/dist/http/errors.js +2 -0
- package/dist/http/oauth.d.ts +2 -0
- package/dist/http/oauth.js +201 -0
- package/dist/http/retry.d.ts +19 -0
- package/dist/http/retry.js +33 -0
- package/dist/http/transport.d.ts +2 -0
- package/dist/http/transport.js +2 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +64 -0
- package/dist/input-gate-registry-Dai7SfXb.js +14 -0
- package/dist/input-gates-DwKoTJVQ.d.ts +28 -0
- package/dist/json-BksZpXDC.d.ts +19 -0
- package/dist/json-pointer.d.ts +5 -0
- package/dist/json-pointer.js +10 -0
- package/dist/json.d.ts +2 -0
- package/dist/json.js +44 -0
- package/dist/known-range-DTOBgTEC.d.ts +7 -0
- package/dist/library-B9pEq7qP.d.ts +230 -0
- package/dist/list-BT_bBm9Z.d.ts +7 -0
- package/dist/list.d.ts +2 -0
- package/dist/list.js +1 -0
- package/dist/measure-CgH14YQZ.d.ts +44 -0
- package/dist/measure-lPz8qnwz.d.ts +108 -0
- package/dist/metric-DcYloqOQ.d.ts +2655 -0
- package/dist/moderation-review-B4RUTZ6_.d.ts +56 -0
- package/dist/network-error-5g4U1iul.js +62 -0
- package/dist/notification-Cp5GJErS.d.ts +22 -0
- package/dist/notification-D1MThyKE.d.ts +443 -0
- package/dist/oauth-C4ordeoJ.d.ts +59 -0
- package/dist/oauth-login-CJsT_3EE.d.ts +19 -0
- package/dist/oauth-login-D734Jvbq.js +179 -0
- package/dist/oauth-session-BlIlcd8Q.d.ts +6 -0
- package/dist/paginate-COuL0Gzl.d.ts +24 -0
- package/dist/paginate.d.ts +2 -0
- package/dist/paginate.js +49 -0
- package/dist/parameter-ak-J-IOj.d.ts +190 -0
- package/dist/permission-BnCQw5Kp.d.ts +149 -0
- package/dist/poll-CIwnee7h.d.ts +15 -0
- package/dist/poll.d.ts +2 -0
- package/dist/poll.js +47 -0
- package/dist/predicates.d.ts +10 -0
- package/dist/predicates.js +18 -0
- package/dist/pulse-0LG3K6qO.d.ts +598 -0
- package/dist/pulse-BzKmz3Yn.d.ts +18 -0
- package/dist/query-Xsin530u.d.ts +23 -0
- package/dist/refusal-B9aeHMc9.js +130 -0
- package/dist/replacement-BGyggp-G.d.ts +2467 -0
- package/dist/replacement-CVebCuNp.d.ts +128 -0
- package/dist/requirement-check-glU7wqhQ.d.ts +17 -0
- package/dist/requirements-Dx_ZVzl7.d.ts +227 -0
- package/dist/resources/api-key.d.ts +11 -0
- package/dist/resources/api-key.js +35 -0
- package/dist/resources/card.d.ts +2 -0
- package/dist/resources/card.js +103 -0
- package/dist/resources/collection.d.ts +2 -0
- package/dist/resources/collection.js +134 -0
- package/dist/resources/content-translation.d.ts +11 -0
- package/dist/resources/content-translation.js +27 -0
- package/dist/resources/csv-upload.d.ts +2 -0
- package/dist/resources/csv-upload.js +9 -0
- package/dist/resources/dashboard.d.ts +2 -0
- package/dist/resources/dashboard.js +221 -0
- package/dist/resources/data-action.d.ts +60 -0
- package/dist/resources/data-action.js +79 -0
- package/dist/resources/data-app.d.ts +112 -0
- package/dist/resources/data-app.js +75 -0
- package/dist/resources/database.d.ts +2 -0
- package/dist/resources/database.js +103 -0
- package/dist/resources/dataset.d.ts +2 -0
- package/dist/resources/dataset.js +81 -0
- package/dist/resources/dependency.d.ts +2 -0
- package/dist/resources/dependency.js +156 -0
- package/dist/resources/document.d.ts +55 -0
- package/dist/resources/document.js +60 -0
- package/dist/resources/eid-translation.d.ts +8 -0
- package/dist/resources/eid-translation.js +19 -0
- package/dist/resources/erd.d.ts +2 -0
- package/dist/resources/erd.js +26 -0
- package/dist/resources/field.d.ts +2 -0
- package/dist/resources/field.js +99 -0
- package/dist/resources/git-sync.d.ts +2 -0
- package/dist/resources/git-sync.js +362 -0
- package/dist/resources/glossary.d.ts +2 -0
- package/dist/resources/glossary.js +51 -0
- package/dist/resources/library.d.ts +85 -0
- package/dist/resources/library.js +90 -0
- package/dist/resources/measure.d.ts +2 -0
- package/dist/resources/measure.js +57 -0
- package/dist/resources/metric.d.ts +2 -0
- package/dist/resources/metric.js +50 -0
- package/dist/resources/moderation-review.d.ts +23 -0
- package/dist/resources/moderation-review.js +24 -0
- package/dist/resources/notification.d.ts +2 -0
- package/dist/resources/notification.js +93 -0
- package/dist/resources/optional-parsed.d.ts +7 -0
- package/dist/resources/optional-parsed.js +14 -0
- package/dist/resources/permission.d.ts +10 -0
- package/dist/resources/permission.js +31 -0
- package/dist/resources/pivot-export.d.ts +10 -0
- package/dist/resources/pivot-export.js +16 -0
- package/dist/resources/pulse.d.ts +2 -0
- package/dist/resources/pulse.js +76 -0
- package/dist/resources/replacement.d.ts +2 -0
- package/dist/resources/replacement.js +82 -0
- package/dist/resources/request-body.d.ts +9 -0
- package/dist/resources/request-body.js +13 -0
- package/dist/resources/revision.d.ts +70 -0
- package/dist/resources/revision.js +46 -0
- package/dist/resources/search.d.ts +2 -0
- package/dist/resources/search.js +78 -0
- package/dist/resources/segment.d.ts +2 -0
- package/dist/resources/segment.js +55 -0
- package/dist/resources/setting.d.ts +11 -0
- package/dist/resources/setting.js +43 -0
- package/dist/resources/setup.d.ts +8 -0
- package/dist/resources/setup.js +18 -0
- package/dist/resources/snippet.d.ts +2 -0
- package/dist/resources/snippet.js +52 -0
- package/dist/resources/table.d.ts +2 -0
- package/dist/resources/table.js +274 -0
- package/dist/resources/timeline-event.d.ts +12 -0
- package/dist/resources/timeline-event.js +51 -0
- package/dist/resources/timeline.d.ts +2 -0
- package/dist/resources/timeline.js +82 -0
- package/dist/resources/transform-dag-run.d.ts +22 -0
- package/dist/resources/transform-dag-run.js +32 -0
- package/dist/resources/transform-inspector.d.ts +214 -0
- package/dist/resources/transform-inspector.js +47 -0
- package/dist/resources/transform-job.d.ts +2 -0
- package/dist/resources/transform-job.js +90 -0
- package/dist/resources/transform-python.d.ts +59 -0
- package/dist/resources/transform-python.js +57 -0
- package/dist/resources/transform-tag.d.ts +35 -0
- package/dist/resources/transform-tag.js +47 -0
- package/dist/resources/transform-test.d.ts +2 -0
- package/dist/resources/transform-test.js +75 -0
- package/dist/resources/transform.d.ts +2 -0
- package/dist/resources/transform.js +227 -0
- package/dist/resources/upload.d.ts +2 -0
- package/dist/resources/upload.js +48 -0
- package/dist/resources/user.d.ts +8 -0
- package/dist/resources/user.js +11 -0
- package/dist/revision-Dyl-8p7d.d.ts +106 -0
- package/dist/search-Cm5IxKss.d.ts +92 -0
- package/dist/search-Cten2h0I.d.ts +26 -0
- package/dist/segment-CbAgVO-5.d.ts +47 -0
- package/dist/segment-DQLX6r1E.d.ts +16 -0
- package/dist/session-properties-COtlxAcK.d.ts +15 -0
- package/dist/setting-DXuQGXGF.d.ts +25 -0
- package/dist/setup-JqcJ2unJ.d.ts +26 -0
- package/dist/signal.d.ts +8 -0
- package/dist/signal.js +25 -0
- package/dist/snippet-C_Ilx7tR.d.ts +41 -0
- package/dist/snippet-Djn0rL21.d.ts +16 -0
- package/dist/table-CDZbLNow.d.ts +176 -0
- package/dist/table-Od6uvDVW.d.ts +3234 -0
- package/dist/tag-qzjGGci8.d.ts +48 -0
- package/dist/timeline-BK45hy-h.d.ts +218 -0
- package/dist/timeline-BTs6fuRp.d.ts +21 -0
- package/dist/transform-C5thnJwW.d.ts +559 -0
- package/dist/transform-WASQAXeA.d.ts +652 -0
- package/dist/transform-dag-run-BgZwv1yx.d.ts +49 -0
- package/dist/transform-inspector-CMCh8WKV.d.ts +374 -0
- package/dist/transform-job-D8jTQtdX.d.ts +98 -0
- package/dist/transform-job-DmTwKxhc.d.ts +237 -0
- package/dist/transform-python-DtL3xxMj.d.ts +101 -0
- package/dist/transform-tag-C6j5EUkX.d.ts +25 -0
- package/dist/transform-test-CR_i54IV.d.ts +412 -0
- package/dist/transform-test-CeMzDpUC.d.ts +346 -0
- package/dist/transport-BsXqRujn.d.ts +476 -0
- package/dist/transport-HP7cyo9N.js +397 -0
- package/dist/upload-B5YjVkSW.d.ts +12 -0
- package/dist/upload-UPfZFdbH.d.ts +22 -0
- package/dist/url-CI0pxHOc.d.ts +7 -0
- package/dist/url.d.ts +2 -0
- package/dist/url.js +34 -0
- package/dist/user-Sqqv7rqh.d.ts +18 -0
- package/dist/version/capability-error.d.ts +2 -0
- package/dist/version/capability-error.js +42 -0
- package/dist/version/features.d.ts +2 -0
- package/dist/version/features.js +171 -0
- package/dist/version/input-gates.d.ts +2 -0
- package/dist/version/input-gates.js +13 -0
- package/dist/version/known-range.d.ts +2 -0
- package/dist/version/known-range.js +7 -0
- package/dist/version/probe.d.ts +2 -0
- package/dist/version/probe.js +30 -0
- package/dist/version/profile.d.ts +2 -0
- package/dist/version/profile.js +64 -0
- package/dist/version/requirement-check.d.ts +2 -0
- package/dist/version/requirement-check.js +62 -0
- package/dist/version/requirements.d.ts +2 -0
- package/dist/version/requirements.js +229 -0
- package/dist/version/tag.d.ts +2 -0
- package/dist/version/tag.js +52 -0
- package/package.json +66 -4
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { SessionProperties } from "./domain/session-properties.js";
|
|
2
|
+
import { NetworkError, ResponseShapeError, TimeoutError, ValidationError, errorMessage, isNonInterruptFailure } from "./errors.js";
|
|
3
|
+
import { JSON_CONTENT_TYPE, parseJson } from "./json.js";
|
|
4
|
+
import { combineAborts, throwIfAborted, untilAborted } from "./signal.js";
|
|
5
|
+
import { normalizeUrl } from "./url.js";
|
|
6
|
+
import { a as HttpError, p as isRetryableStatus } from "./errors-DdMlaXqq.js";
|
|
7
|
+
import { CapabilityError } from "./version/capability-error.js";
|
|
8
|
+
import { createServerProfile } from "./version/profile.js";
|
|
9
|
+
import { PROBE_PATH, probeBudget, serverInfoFromProperties } from "./version/probe.js";
|
|
10
|
+
import { featureFailures } from "./version/requirement-check.js";
|
|
11
|
+
import { assertCredentialHeaderSafe, credentialAuthHeader, credentialSecrets } from "./auth/credential.js";
|
|
12
|
+
import { n as isConnectionClosed, t as buildNetworkError } from "./network-error-5g4U1iul.js";
|
|
13
|
+
import { backoffDelay, runWithRetries } from "./http/retry.js";
|
|
14
|
+
//#region src/http/response-shape.ts
|
|
15
|
+
async function parseJsonResponse(text, schema, context) {
|
|
16
|
+
try {
|
|
17
|
+
return parseJson(text, schema, { source: context.url });
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (error instanceof ValidationError) throw ResponseShapeError.fromZodIssues({
|
|
20
|
+
kind: "zod",
|
|
21
|
+
method: context.method,
|
|
22
|
+
url: context.url,
|
|
23
|
+
status: context.status,
|
|
24
|
+
zodIssues: error.developerDetail.zodIssues,
|
|
25
|
+
serverTag: await context.getServerTag(),
|
|
26
|
+
serverSkew: context.serverSkew
|
|
27
|
+
});
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/http/transport.ts
|
|
33
|
+
const DEFAULT_METHOD = "GET";
|
|
34
|
+
const DEFAULT_TIMEOUT_MS = 3e4;
|
|
35
|
+
const OCTET_STREAM_CONTENT_TYPE = "application/octet-stream";
|
|
36
|
+
const TEXT_CONTENT_TYPE_PREFIX = "text/";
|
|
37
|
+
const ERROR_BODY_BYTE_CAP = 64 * 1024;
|
|
38
|
+
const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
|
|
39
|
+
"GET",
|
|
40
|
+
"HEAD",
|
|
41
|
+
"OPTIONS"
|
|
42
|
+
]);
|
|
43
|
+
function createTransport(config, options) {
|
|
44
|
+
const baseUrl = normalizeUrl(config.url);
|
|
45
|
+
assertCredentialHeaderSafe(config.credential);
|
|
46
|
+
const fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
47
|
+
let inForce = options.server ?? null;
|
|
48
|
+
let newest = null;
|
|
49
|
+
let probesStarted = 0;
|
|
50
|
+
let applied = null;
|
|
51
|
+
const inFlight = /* @__PURE__ */ new Set();
|
|
52
|
+
const getServerTag = options.getServerTag ?? (async () => tagOf(inForce));
|
|
53
|
+
const refreshCredential = options.refreshCredential;
|
|
54
|
+
let credential = config.credential;
|
|
55
|
+
const knownSecrets = new Set(credentialSecrets(credential));
|
|
56
|
+
const redactionContext = { knownSecrets };
|
|
57
|
+
let refreshInFlight = null;
|
|
58
|
+
function tryRefreshCredential() {
|
|
59
|
+
const refresh = refreshCredential;
|
|
60
|
+
if (credential.kind !== "oauth" || refresh === void 0) return Promise.resolve(false);
|
|
61
|
+
refreshInFlight ??= refreshOnce(refresh).finally(() => {
|
|
62
|
+
refreshInFlight = null;
|
|
63
|
+
});
|
|
64
|
+
return refreshInFlight;
|
|
65
|
+
}
|
|
66
|
+
async function refreshOnce(refresh) {
|
|
67
|
+
const next = await refresh();
|
|
68
|
+
if (next === null) return false;
|
|
69
|
+
credential = next;
|
|
70
|
+
for (const secret of credentialSecrets(next)) knownSecrets.add(secret);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
async function attemptOnce(prepared, attempt) {
|
|
74
|
+
const hasRetriesLeft = attempt < prepared.retries;
|
|
75
|
+
const timeoutSignal = AbortSignal.timeout(prepared.timeoutMs);
|
|
76
|
+
const combined = combineAborts(timeoutSignal, prepared.cancelSignal);
|
|
77
|
+
let response;
|
|
78
|
+
try {
|
|
79
|
+
response = await fetchImpl(prepared.url, {
|
|
80
|
+
method: prepared.method,
|
|
81
|
+
headers: prepared.headers,
|
|
82
|
+
body: prepared.body,
|
|
83
|
+
signal: combined
|
|
84
|
+
});
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throwIfAborted(prepared.cancelSignal);
|
|
87
|
+
const isStaleSocketFirstTry = attempt === 0 && isConnectionClosed(error);
|
|
88
|
+
if (prepared.idempotent && (hasRetriesLeft || isStaleSocketFirstTry)) return {
|
|
89
|
+
kind: "retry",
|
|
90
|
+
delayMs: backoffDelay({ attempt })
|
|
91
|
+
};
|
|
92
|
+
if (timeoutSignal.aborted) throw new TimeoutError(`Request timed out after ${prepared.timeoutMs}ms`, {
|
|
93
|
+
kind: "http",
|
|
94
|
+
method: prepared.method,
|
|
95
|
+
url: prepared.url,
|
|
96
|
+
timeoutMs: prepared.timeoutMs
|
|
97
|
+
});
|
|
98
|
+
throw buildNetworkError(error, prepared.method, prepared.url);
|
|
99
|
+
}
|
|
100
|
+
const canRetryStatus = hasRetriesLeft && prepared.idempotent;
|
|
101
|
+
if (!response.ok && isRetryableStatus(response.status) && canRetryStatus) {
|
|
102
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
103
|
+
response.body?.cancel().catch(() => void 0);
|
|
104
|
+
return {
|
|
105
|
+
kind: "retry",
|
|
106
|
+
delayMs: backoffDelay({
|
|
107
|
+
attempt,
|
|
108
|
+
retryAfterHeader: retryAfter
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
const rawBody = await readBodyForError(response);
|
|
114
|
+
const serverTag = await getServerTag();
|
|
115
|
+
throw new HttpError({
|
|
116
|
+
status: response.status,
|
|
117
|
+
statusText: response.statusText,
|
|
118
|
+
method: prepared.method,
|
|
119
|
+
url: prepared.url,
|
|
120
|
+
responseHeaders: response.headers,
|
|
121
|
+
rawBody,
|
|
122
|
+
serverTag,
|
|
123
|
+
redactionContext
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
assertContentType(response, prepared);
|
|
127
|
+
return {
|
|
128
|
+
kind: "success",
|
|
129
|
+
response
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
async function executeRaw(prepared) {
|
|
133
|
+
try {
|
|
134
|
+
return await runWithRetries((attempt) => attemptOnce(prepared, attempt), prepared.cancelSignal);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
throwIfAborted(prepared.cancelSignal);
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function executeWithAuthRefresh(path, opts) {
|
|
141
|
+
const prepared = prepare(path, opts);
|
|
142
|
+
try {
|
|
143
|
+
return {
|
|
144
|
+
response: await executeRaw(prepared),
|
|
145
|
+
prepared
|
|
146
|
+
};
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (error instanceof HttpError && error.status === 401) {
|
|
149
|
+
if (await tryRefreshCredential()) {
|
|
150
|
+
const retried = prepare(path, opts);
|
|
151
|
+
return {
|
|
152
|
+
response: await executeRaw(retried),
|
|
153
|
+
prepared: retried
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function prepare(path, opts = {}) {
|
|
161
|
+
const method = opts.method ?? "GET";
|
|
162
|
+
const expectContentType = opts.expectContentType ?? "json";
|
|
163
|
+
const url = buildUrl(baseUrl, path, opts.query);
|
|
164
|
+
const headers = new Headers();
|
|
165
|
+
const auth = credentialAuthHeader(credential);
|
|
166
|
+
headers.set(auth.name, auth.value);
|
|
167
|
+
headers.set("accept", acceptHeader(expectContentType));
|
|
168
|
+
headers.set("user-agent", options.userAgent);
|
|
169
|
+
let body = null;
|
|
170
|
+
if (opts.body !== void 0 && opts.body !== null) if (typeof opts.body === "string" || opts.body instanceof URLSearchParams) body = opts.body;
|
|
171
|
+
else if (opts.body instanceof FormData || opts.body instanceof ReadableStream) body = opts.body;
|
|
172
|
+
else if (opts.body instanceof Uint8Array) {
|
|
173
|
+
body = opts.body;
|
|
174
|
+
headers.set("content-type", OCTET_STREAM_CONTENT_TYPE);
|
|
175
|
+
} else {
|
|
176
|
+
body = JSON.stringify(opts.body);
|
|
177
|
+
headers.set("content-type", JSON_CONTENT_TYPE);
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
url,
|
|
181
|
+
method,
|
|
182
|
+
headers,
|
|
183
|
+
body,
|
|
184
|
+
expectContentType,
|
|
185
|
+
retries: opts.retries ?? 3,
|
|
186
|
+
idempotent: opts.idempotent ?? IDEMPOTENT_METHODS.has(method),
|
|
187
|
+
timeoutMs: opts.timeoutMs ?? 3e4,
|
|
188
|
+
cancelSignal: combineAborts(opts.signal, options.signal)
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async function readJson(path, opts = {}) {
|
|
192
|
+
const chosenFor = inForce;
|
|
193
|
+
const { response, prepared } = await executeWithAuthRefresh(path, {
|
|
194
|
+
...opts,
|
|
195
|
+
expectContentType: "json"
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
text: await response.text(),
|
|
199
|
+
context: {
|
|
200
|
+
method: prepared.method,
|
|
201
|
+
url: prepared.url,
|
|
202
|
+
status: response.status,
|
|
203
|
+
...namingOf(chosenFor)
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function namingOf(profile) {
|
|
208
|
+
if (profile === null) return {
|
|
209
|
+
getServerTag,
|
|
210
|
+
serverSkew: null
|
|
211
|
+
};
|
|
212
|
+
return {
|
|
213
|
+
getServerTag: async () => profile.version.tag,
|
|
214
|
+
serverSkew: profile.skew
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
async function runProbe(order, budget) {
|
|
218
|
+
const read = await readJson(PROBE_PATH, probeBudget(budget));
|
|
219
|
+
const properties = await parseJsonResponse(read.text, SessionProperties, read.context);
|
|
220
|
+
const info = serverInfoFromProperties(properties);
|
|
221
|
+
const profile = createServerProfile(info);
|
|
222
|
+
if (applied === null || applied.order < order) {
|
|
223
|
+
options.onServerProbed?.(info, profile);
|
|
224
|
+
applied = {
|
|
225
|
+
order,
|
|
226
|
+
profile
|
|
227
|
+
};
|
|
228
|
+
inForce = profile;
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
properties,
|
|
232
|
+
profile,
|
|
233
|
+
read
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function startProbe(budget) {
|
|
237
|
+
probesStarted += 1;
|
|
238
|
+
const probed = runProbe(probesStarted, budget);
|
|
239
|
+
newest = probed;
|
|
240
|
+
inFlight.add(probed);
|
|
241
|
+
probed.then(() => {
|
|
242
|
+
inFlight.delete(probed);
|
|
243
|
+
}, () => {
|
|
244
|
+
inFlight.delete(probed);
|
|
245
|
+
if (newest === probed) newest = null;
|
|
246
|
+
});
|
|
247
|
+
return probed;
|
|
248
|
+
}
|
|
249
|
+
function appliedProfile() {
|
|
250
|
+
return applied === null ? null : applied.profile;
|
|
251
|
+
}
|
|
252
|
+
function verifying() {
|
|
253
|
+
const settled = appliedProfile();
|
|
254
|
+
if (newest === null && settled !== null) return Promise.resolve(settled);
|
|
255
|
+
return (newest ?? startProbe({})).then((probed) => probed.profile, fallBackTo(appliedProfile));
|
|
256
|
+
}
|
|
257
|
+
function profileInForce() {
|
|
258
|
+
const current = inForce;
|
|
259
|
+
if (current === null) return verifying();
|
|
260
|
+
if (newest === null) return Promise.resolve(current);
|
|
261
|
+
return newest.then((probed) => probed.profile, fallBackTo(() => inForce));
|
|
262
|
+
}
|
|
263
|
+
async function server(wait = {}) {
|
|
264
|
+
throwIfAborted(wait.signal);
|
|
265
|
+
return untilAborted(profileInForce(), wait.signal);
|
|
266
|
+
}
|
|
267
|
+
async function verifiedServer(wait = {}) {
|
|
268
|
+
throwIfAborted(wait.signal);
|
|
269
|
+
return untilAborted(verifying(), wait.signal);
|
|
270
|
+
}
|
|
271
|
+
async function probe(reader, read = {}) {
|
|
272
|
+
const { signal, ...budget } = read;
|
|
273
|
+
throwIfAborted(signal);
|
|
274
|
+
const probed = await untilAborted(startProbe(budget), signal);
|
|
275
|
+
const context = {
|
|
276
|
+
...probed.read.context,
|
|
277
|
+
...namingOf(probed.profile)
|
|
278
|
+
};
|
|
279
|
+
return parseJsonResponse(probed.read.text, reader, context);
|
|
280
|
+
}
|
|
281
|
+
async function probesSettled() {
|
|
282
|
+
while (inFlight.size > 0) await Promise.allSettled(inFlight);
|
|
283
|
+
}
|
|
284
|
+
async function requireFeatures(features, wait = {}) {
|
|
285
|
+
if (features.length === 0) return;
|
|
286
|
+
const profile = await preflightServer(wait);
|
|
287
|
+
if (profile === null) return;
|
|
288
|
+
for (const failure of featureFailures(features, profile)) refuseBeforeSending(new CapabilityError(failure));
|
|
289
|
+
}
|
|
290
|
+
async function preflightServer(wait = {}) {
|
|
291
|
+
try {
|
|
292
|
+
return await verifiedServer(wait);
|
|
293
|
+
} catch (error) {
|
|
294
|
+
if (!isNonInterruptFailure(error)) throw error;
|
|
295
|
+
skipOrThrow({
|
|
296
|
+
kind: "unverified",
|
|
297
|
+
failure: error
|
|
298
|
+
});
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function refuseBeforeSending(refusal) {
|
|
303
|
+
skipOrThrow({
|
|
304
|
+
kind: "refused",
|
|
305
|
+
refusal
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
function skipOrThrow(skipped) {
|
|
309
|
+
const hook = options.onPreflightSkipped;
|
|
310
|
+
if (hook === void 0) throw skippedError(skipped);
|
|
311
|
+
hook(skipped);
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
server,
|
|
315
|
+
verifiedServer,
|
|
316
|
+
probe,
|
|
317
|
+
requireFeatures,
|
|
318
|
+
preflightServer,
|
|
319
|
+
refuseBeforeSending,
|
|
320
|
+
probesSettled,
|
|
321
|
+
async requestRaw(path, opts) {
|
|
322
|
+
return (await executeWithAuthRefresh(path, opts ?? {})).response;
|
|
323
|
+
},
|
|
324
|
+
async requestParsed(schema, path, opts) {
|
|
325
|
+
const read = await readJson(path, opts);
|
|
326
|
+
return parseJsonResponse(read.text, schema, read.context);
|
|
327
|
+
},
|
|
328
|
+
async requestStream(path, opts) {
|
|
329
|
+
const { response, prepared } = await executeWithAuthRefresh(path, {
|
|
330
|
+
...opts,
|
|
331
|
+
expectContentType: opts?.expectContentType ?? "binary"
|
|
332
|
+
});
|
|
333
|
+
if (!response.body) throw new NetworkError("Response had no body to stream", {
|
|
334
|
+
method: prepared.method,
|
|
335
|
+
url: prepared.url,
|
|
336
|
+
cause: "missing body"
|
|
337
|
+
});
|
|
338
|
+
return response.body;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function skippedError(skipped) {
|
|
343
|
+
return skipped.kind === "refused" ? skipped.refusal : skipped.failure;
|
|
344
|
+
}
|
|
345
|
+
function fallBackTo(fallback) {
|
|
346
|
+
return (error) => {
|
|
347
|
+
const profile = fallback();
|
|
348
|
+
if (profile !== null && isNonInterruptFailure(error)) return profile;
|
|
349
|
+
throw error;
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function tagOf(profile) {
|
|
353
|
+
return profile === null ? null : profile.version.tag;
|
|
354
|
+
}
|
|
355
|
+
function buildUrl(baseUrl, path, query) {
|
|
356
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
357
|
+
const target = new URL(baseUrl + normalizedPath);
|
|
358
|
+
if (query) for (const [key, value] of Object.entries(query)) {
|
|
359
|
+
if (value === void 0) continue;
|
|
360
|
+
if (Array.isArray(value)) for (const entry of value) target.searchParams.append(key, String(entry));
|
|
361
|
+
else target.searchParams.append(key, String(value));
|
|
362
|
+
}
|
|
363
|
+
return target.toString();
|
|
364
|
+
}
|
|
365
|
+
function acceptHeader(expected) {
|
|
366
|
+
if (expected === "json") return JSON_CONTENT_TYPE;
|
|
367
|
+
if (expected === "text") return "text/*";
|
|
368
|
+
return "*/*";
|
|
369
|
+
}
|
|
370
|
+
function assertContentType(response, prepared) {
|
|
371
|
+
if (prepared.expectContentType === "binary") return;
|
|
372
|
+
const contentType = response.headers.get("content-type");
|
|
373
|
+
if (contentType === null) throwContentTypeMismatch(response, prepared, prepared.expectContentType);
|
|
374
|
+
if (prepared.expectContentType === "json" && !contentType.includes("application/json")) throwContentTypeMismatch(response, prepared, "json");
|
|
375
|
+
if (prepared.expectContentType === "text" && !contentType.startsWith(TEXT_CONTENT_TYPE_PREFIX)) throwContentTypeMismatch(response, prepared, "text");
|
|
376
|
+
}
|
|
377
|
+
function throwContentTypeMismatch(response, prepared, expected) {
|
|
378
|
+
const actual = response.headers.get("content-type") ?? "no content-type";
|
|
379
|
+
throw new HttpError({
|
|
380
|
+
status: response.status,
|
|
381
|
+
statusText: response.statusText,
|
|
382
|
+
method: prepared.method,
|
|
383
|
+
url: prepared.url,
|
|
384
|
+
responseHeaders: response.headers,
|
|
385
|
+
rawBody: null,
|
|
386
|
+
overrideUserMessage: `Expected ${expected} response but got ${actual}`
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
async function readBodyForError(response) {
|
|
390
|
+
try {
|
|
391
|
+
return Buffer.from(await response.arrayBuffer()).subarray(0, ERROR_BODY_BYTE_CAP).toString("utf8");
|
|
392
|
+
} catch (error) {
|
|
393
|
+
return `[body read failed: ${errorMessage(error)}]`;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
//#endregion
|
|
397
|
+
export { DEFAULT_TIMEOUT_MS as n, createTransport as r, DEFAULT_METHOD as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { f as RequestOptions, h as Transport } from "./transport-BsXqRujn.js";
|
|
2
|
+
import { t as UploadResult } from "./upload-UPfZFdbH.js";
|
|
3
|
+
import { t as CsvFile } from "./csv-upload--K35QedP.js";
|
|
4
|
+
//#region src/resources/upload.d.ts
|
|
5
|
+
interface UploadCsvParams {
|
|
6
|
+
collection_id: string;
|
|
7
|
+
}
|
|
8
|
+
declare function uploadResource(transport: Transport): {
|
|
9
|
+
createFromCsv: (file: CsvFile, params: UploadCsvParams, options?: RequestOptions) => Promise<UploadResult>;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { uploadResource as n, UploadCsvParams as t };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/domain/upload.d.ts
|
|
3
|
+
declare const UploadResult: z.ZodObject<{
|
|
4
|
+
model_id: z.ZodNumber;
|
|
5
|
+
table_id: z.ZodNumber;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
type UploadResult = z.infer<typeof UploadResult>;
|
|
8
|
+
declare const UploadUpdateAction: z.ZodEnum<{
|
|
9
|
+
replace: "replace";
|
|
10
|
+
append: "append";
|
|
11
|
+
}>;
|
|
12
|
+
type UploadUpdateAction = z.infer<typeof UploadUpdateAction>;
|
|
13
|
+
declare const UploadUpdateResult: z.ZodObject<{
|
|
14
|
+
table_id: z.ZodNumber;
|
|
15
|
+
action: z.ZodEnum<{
|
|
16
|
+
replace: "replace";
|
|
17
|
+
append: "append";
|
|
18
|
+
}>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
type UploadUpdateResult = z.infer<typeof UploadUpdateResult>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { UploadUpdateAction as n, UploadUpdateResult as r, UploadResult as t };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/url.d.ts
|
|
2
|
+
declare function normalizeUrl(input: string): string;
|
|
3
|
+
declare function displayUrl(input: string): string;
|
|
4
|
+
declare function isLoopbackHost(hostname: string): boolean;
|
|
5
|
+
declare function assertEndpointOrigin(endpoint: string, baseUrl: string, label: string): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { normalizeUrl as i, displayUrl as n, isLoopbackHost as r, assertEndpointOrigin as t };
|
package/dist/url.d.ts
ADDED
package/dist/url.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ConfigError } from "./errors.js";
|
|
2
|
+
//#region src/url.ts
|
|
3
|
+
function normalizeUrl(input) {
|
|
4
|
+
const trimmed = input.trim().replace(/\/+$/, "");
|
|
5
|
+
if (!/^https?:\/\//i.test(trimmed)) throw new ConfigError("URL must start with http:// or https://");
|
|
6
|
+
return trimmed;
|
|
7
|
+
}
|
|
8
|
+
function displayUrl(input) {
|
|
9
|
+
const parsed = new URL(input);
|
|
10
|
+
const path = parsed.pathname.replace(/\/+$/, "");
|
|
11
|
+
return `${parsed.origin}${path}`;
|
|
12
|
+
}
|
|
13
|
+
const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
|
|
14
|
+
"localhost",
|
|
15
|
+
"127.0.0.1",
|
|
16
|
+
"::1",
|
|
17
|
+
"[::1]"
|
|
18
|
+
]);
|
|
19
|
+
function isLoopbackHost(hostname) {
|
|
20
|
+
return LOOPBACK_HOSTS.has(hostname.toLowerCase());
|
|
21
|
+
}
|
|
22
|
+
function assertEndpointOrigin(endpoint, baseUrl, label) {
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = new URL(endpoint);
|
|
26
|
+
} catch {
|
|
27
|
+
throw new ConfigError(`OAuth ${label} is not a valid URL: ${endpoint}`);
|
|
28
|
+
}
|
|
29
|
+
const base = new URL(baseUrl);
|
|
30
|
+
if (parsed.protocol !== "https:" && !isLoopbackHost(parsed.hostname)) throw new ConfigError(`OAuth ${label} must use https: ${endpoint}`);
|
|
31
|
+
if (parsed.origin !== base.origin) throw new ConfigError(`OAuth ${label} origin (${parsed.origin}) does not match the Metabase URL (${base.origin})`);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { assertEndpointOrigin, displayUrl, isLoopbackHost, normalizeUrl };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/domain/user.d.ts
|
|
3
|
+
declare const CurrentUser: z.ZodObject<{
|
|
4
|
+
id: z.ZodNumber;
|
|
5
|
+
email: z.ZodString;
|
|
6
|
+
common_name: z.ZodString;
|
|
7
|
+
is_superuser: z.ZodBoolean;
|
|
8
|
+
}, z.core.$loose>;
|
|
9
|
+
type CurrentUser = z.infer<typeof CurrentUser>;
|
|
10
|
+
declare const CurrentUserCompact: z.ZodObject<{
|
|
11
|
+
id: z.ZodNumber;
|
|
12
|
+
email: z.ZodString;
|
|
13
|
+
common_name: z.ZodString;
|
|
14
|
+
is_superuser: z.ZodBoolean;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
type CurrentUserCompact = z.infer<typeof CurrentUserCompact>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CurrentUserCompact as n, CurrentUser as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as versionTooOldMessage, S as missingTokenFeatureMessage, b as RequirementFailure, x as RequirementReason, y as CapabilityError } from "../transport-BsXqRujn.js";
|
|
2
|
+
export { CapabilityError, RequirementFailure, RequirementReason, missingTokenFeatureMessage, versionTooOldMessage };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MetabaseError } from "../errors.js";
|
|
2
|
+
import "../errors-DdMlaXqq.js";
|
|
3
|
+
import { FEATURE_NAMES } from "./features.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/version/capability-error.ts
|
|
6
|
+
const RequirementReason = z.enum([
|
|
7
|
+
"version-too-old",
|
|
8
|
+
"missing-token-feature",
|
|
9
|
+
"superseded-by-feature"
|
|
10
|
+
]);
|
|
11
|
+
const RequirementFailure = z.object({
|
|
12
|
+
reason: RequirementReason,
|
|
13
|
+
detail: z.string(),
|
|
14
|
+
feature: z.enum(FEATURE_NAMES),
|
|
15
|
+
since: z.number().int(),
|
|
16
|
+
tokenFeature: z.string().nullable(),
|
|
17
|
+
serverVersion: z.string()
|
|
18
|
+
});
|
|
19
|
+
function versionTooOldMessage(since, serverVersion) {
|
|
20
|
+
return `This operation requires Metabase v${since}+ (this server is ${serverVersion}). Upgrade Metabase to use it.`;
|
|
21
|
+
}
|
|
22
|
+
function missingTokenFeatureMessage(tokenFeature) {
|
|
23
|
+
return `This operation requires the '${tokenFeature}' premium feature (not enabled on this server).`;
|
|
24
|
+
}
|
|
25
|
+
var CapabilityError = class extends MetabaseError {
|
|
26
|
+
category = "capability";
|
|
27
|
+
isRetryable = false;
|
|
28
|
+
developerDetail;
|
|
29
|
+
constructor(failure, refusal = null) {
|
|
30
|
+
super(capabilityMessage(failure, refusal), refusal === null ? void 0 : { cause: refusal });
|
|
31
|
+
this.name = "CapabilityError";
|
|
32
|
+
this.developerDetail = failure;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function capabilityMessage(failure, refusal) {
|
|
36
|
+
if (refusal === null || refusal.status !== 400) return failure.detail;
|
|
37
|
+
const said = refusal.serverMessage;
|
|
38
|
+
if (said === null) return failure.detail;
|
|
39
|
+
return `${failure.detail}\nMetabase answered ${refusal.status}: ${said}`;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { CapabilityError, RequirementFailure, RequirementReason, missingTokenFeatureMessage, versionTooOldMessage };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as FeatureRule, c as TokenGap, d as featureAvailability, f as isFeatureName, i as FeatureName, l as VersionGap, n as FEATURE_RULES, o as Features, p as ruleGap, r as FeatureGap, s as RuleMajor, t as FEATURE_NAMES, u as evaluateFeatures } from "../features-SMSfJhB6.js";
|
|
2
|
+
export { FEATURE_NAMES, FEATURE_RULES, FeatureGap, FeatureName, FeatureRule, Features, RuleMajor, TokenGap, VersionGap, evaluateFeatures, featureAvailability, isFeatureName, ruleGap };
|