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