@fabricorg/experiments 0.6.1 → 0.6.2
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/dist/bin/fx.cjs +39 -4
- package/dist/bin/fx.cjs.map +1 -1
- package/dist/bin/fx.js +39 -4
- package/dist/bin/fx.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/fx.cjs
CHANGED
|
@@ -7827,14 +7827,17 @@ var ApiClient = class {
|
|
|
7827
7827
|
orgId: this.opts.defaultOrgId,
|
|
7828
7828
|
...pathParams ?? {}
|
|
7829
7829
|
};
|
|
7830
|
-
const
|
|
7830
|
+
const baseUrl = this.opts.baseUrl.endsWith("/") ? this.opts.baseUrl : `${this.opts.baseUrl}/`;
|
|
7831
|
+
const endpointPath = buildPath(def.path, merged).replace(/^\//, "");
|
|
7832
|
+
const url = new URL(endpointPath, baseUrl);
|
|
7831
7833
|
const init = {
|
|
7832
7834
|
method: def.method,
|
|
7833
7835
|
headers: {
|
|
7834
7836
|
accept: "application/json",
|
|
7835
7837
|
// Hosted Fabric API keys use their own header so upstream auth
|
|
7836
7838
|
// middleware cannot mistake them for OAuth bearer credentials.
|
|
7837
|
-
...this.opts.apiKey ? { "x-api-key": this.opts.apiKey } : {}
|
|
7839
|
+
...this.opts.apiKey ? { "x-api-key": this.opts.apiKey } : {},
|
|
7840
|
+
...this.opts.bearerToken ? { authorization: `Bearer ${this.opts.bearerToken}` } : {}
|
|
7838
7841
|
},
|
|
7839
7842
|
credentials: "include"
|
|
7840
7843
|
};
|
|
@@ -8469,7 +8472,13 @@ async function cmdTestPublish(evidencePath, options = {}) {
|
|
|
8469
8472
|
}
|
|
8470
8473
|
const evidence = parseEvidenceText(await promises.readFile(path.resolve(evidencePath), "utf8"));
|
|
8471
8474
|
const input = normalizeTestEvidence(evidence, { ...options, env });
|
|
8472
|
-
const
|
|
8475
|
+
const bearerToken = options.bearerToken ?? await resolveGatewayToken(apiUrl, env);
|
|
8476
|
+
const api = new ApiClient({
|
|
8477
|
+
baseUrl: apiUrl,
|
|
8478
|
+
apiKey,
|
|
8479
|
+
...bearerToken ? { bearerToken } : {},
|
|
8480
|
+
defaultOrgId: tenantId
|
|
8481
|
+
});
|
|
8473
8482
|
const created = await api.testRuns.create(input);
|
|
8474
8483
|
process.stdout.write(
|
|
8475
8484
|
`Published ${created.source} run ${created.id}: ${created.status} (${created.summary.passed}/${created.summary.total} passed)
|
|
@@ -8477,6 +8486,32 @@ async function cmdTestPublish(evidencePath, options = {}) {
|
|
|
8477
8486
|
);
|
|
8478
8487
|
return 0;
|
|
8479
8488
|
}
|
|
8489
|
+
async function resolveGatewayToken(apiUrl, env) {
|
|
8490
|
+
if (env.FX_GATEWAY_BEARER_TOKEN) return env.FX_GATEWAY_BEARER_TOKEN;
|
|
8491
|
+
if (!new URL(apiUrl).hostname.endsWith(".databricksapps.com")) return void 0;
|
|
8492
|
+
const host = env.DATABRICKS_HOST?.replace(/\/$/, "");
|
|
8493
|
+
const clientId = env.FX_QUALITY_DATABRICKS_CLIENT_ID ?? env.DATABRICKS_CLIENT_ID;
|
|
8494
|
+
const clientSecret = env.FX_QUALITY_DATABRICKS_CLIENT_SECRET ?? env.DATABRICKS_CLIENT_SECRET;
|
|
8495
|
+
if (!host || !clientId || !clientSecret) {
|
|
8496
|
+
throw new Error("Databricks Apps publication requires DATABRICKS_HOST and client credentials");
|
|
8497
|
+
}
|
|
8498
|
+
const response = await fetch(`${host}/oidc/v1/token`, {
|
|
8499
|
+
method: "POST",
|
|
8500
|
+
headers: {
|
|
8501
|
+
authorization: `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString("base64")}`,
|
|
8502
|
+
"content-type": "application/x-www-form-urlencoded"
|
|
8503
|
+
},
|
|
8504
|
+
body: new URLSearchParams({ grant_type: "client_credentials", scope: "all-apis" })
|
|
8505
|
+
});
|
|
8506
|
+
if (!response.ok) {
|
|
8507
|
+
throw new Error(`Databricks OAuth failed (${response.status} ${response.statusText})`);
|
|
8508
|
+
}
|
|
8509
|
+
const body = await response.json();
|
|
8510
|
+
if (typeof body.access_token !== "string" || !body.access_token) {
|
|
8511
|
+
throw new Error("Databricks OAuth response did not include an access token");
|
|
8512
|
+
}
|
|
8513
|
+
return body.access_token;
|
|
8514
|
+
}
|
|
8480
8515
|
function normalizeTestEvidence(value, options = {}) {
|
|
8481
8516
|
if (!value || typeof value !== "object") throw new Error("Evidence must be a JSON object");
|
|
8482
8517
|
const evidence = value;
|
|
@@ -8722,7 +8757,7 @@ GLOBAL FLAGS
|
|
|
8722
8757
|
-h, --help print this help
|
|
8723
8758
|
-v, --version print version
|
|
8724
8759
|
`;
|
|
8725
|
-
var VERSION2 = "0.6.
|
|
8760
|
+
var VERSION2 = "0.6.2";
|
|
8726
8761
|
function parse2(argv) {
|
|
8727
8762
|
const positional = [];
|
|
8728
8763
|
const flags = {};
|