@fabricorg/experiments 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/fx.js CHANGED
@@ -7,7 +7,7 @@ import { parse, stringify } from 'yaml';
7
7
  import { randomUUID, webcrypto, createHash } from 'crypto';
8
8
  import { createServer } from 'http';
9
9
  import { createRequire } from 'module';
10
- import { createWorkspaceContext, deleteEphemeralLakebaseBranch, createEphemeralLakebaseBranch, toLakebaseBranchId } from '@fabricorg/databricks-testkit';
10
+ import { createTargetPackRegistry, builtinTargetPacks, doctorTargetPack, runTargetPack, createWorkspaceContext, deleteEphemeralLakebaseBranch, createEphemeralLakebaseBranch, toLakebaseBranchId } from '@fabricorg/databricks-testkit';
11
11
  import { XMLParser } from 'fast-xml-parser';
12
12
  import { execFile } from 'child_process';
13
13
  import { homedir } from 'os';
@@ -7577,6 +7577,7 @@ var TestRunListInput = external_exports.object({
7577
7577
  status: TestRunStatus.optional(),
7578
7578
  source: CreateTestRunInput.shape.source.optional(),
7579
7579
  suite: external_exports.string().min(1).max(240).optional(),
7580
+ targetPack: external_exports.string().min(1).max(120).regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/).optional(),
7580
7581
  limit: external_exports.coerce.number().int().min(1).max(200).optional(),
7581
7582
  offset: external_exports.coerce.number().int().min(0).max(1e5).optional()
7582
7583
  });
@@ -8267,7 +8268,7 @@ var FILES = {
8267
8268
  devDependencies: {
8268
8269
  "@cucumber/cucumber": "^13.0.0",
8269
8270
  "@duckdb/node-api": "^1.5.0",
8270
- "@fabricorg/databricks-bdd": "^0.4.0",
8271
+ "@fabricorg/databricks-bdd": "^0.6.0",
8271
8272
  tsx: "^4.19.2",
8272
8273
  typescript: "^5.8.3"
8273
8274
  }
@@ -8803,6 +8804,8 @@ function normalizeTestEvidence(value, options = {}) {
8803
8804
  };
8804
8805
  }
8805
8806
  if (kind === "databricks-live-suite") {
8807
+ const targetPack = objectOf(evidence.targetPack);
8808
+ const target = objectOf(targetPack.target);
8806
8809
  const cases = arrayOfRecords(evidence.results).map((result) => ({
8807
8810
  id: String(result.id ?? ""),
8808
8811
  name: String(result.description ?? result.id ?? "Live check"),
@@ -8824,11 +8827,19 @@ function normalizeTestEvidence(value, options = {}) {
8824
8827
  summary,
8825
8828
  environment: compact({
8826
8829
  profile: "live",
8827
- cloud: env.DBX_TEST_CLOUD ?? "azure",
8828
- workspace: env.DATABRICKS_HOST,
8830
+ cloud: target.cloud ?? env.DBX_TEST_CLOUD ?? "azure",
8831
+ region: target.region ?? env.DBX_TEST_REGION,
8832
+ workspace: target.workspace ?? env.DATABRICKS_HOST,
8829
8833
  warehouseId: env.DATABRICKS_WAREHOUSE_ID,
8830
- runtime: env.DBX_TEST_RUNTIME_VERSION,
8831
- compute: env.DBX_TEST_COMPUTE
8834
+ runtime: target.runtime ?? env.DBX_TEST_RUNTIME_VERSION,
8835
+ compute: target.compute ?? env.DBX_TEST_COMPUTE,
8836
+ targetPackId: targetPack.id,
8837
+ targetPackName: targetPack.name,
8838
+ targetPackVersion: targetPack.version,
8839
+ targetPackMaturity: targetPack.maturity,
8840
+ targetPackCapabilities: targetPack.capabilities,
8841
+ targetPackCertificationScopes: targetPack.certificationScopes,
8842
+ targetPackDocsUrl: targetPack.docsUrl
8832
8843
  }),
8833
8844
  revision,
8834
8845
  cases,
@@ -9166,6 +9177,147 @@ async function readSecretApiKey() {
9166
9177
  stdin.on("data", onData);
9167
9178
  });
9168
9179
  }
9180
+ var registry = createTargetPackRegistry(builtinTargetPacks);
9181
+ async function cmdTargets(action, packId, options = {}) {
9182
+ const stdout = options.stdout ?? process.stdout;
9183
+ const stderr2 = options.stderr ?? process.stderr;
9184
+ const env = { ...options.env ?? process.env };
9185
+ if (action === "list") {
9186
+ const packs = [...registry.values()].map(describePack);
9187
+ if (options.json) {
9188
+ stdout.write(`${JSON.stringify({ packs }, null, 2)}
9189
+ `);
9190
+ } else {
9191
+ stdout.write("ID MATURITY VERSION CAPABILITIES NAME\n");
9192
+ for (const pack2 of packs) {
9193
+ stdout.write(
9194
+ `${pack2.id.padEnd(19)} ${pack2.maturity.padEnd(12)} ${pack2.version.padEnd(8)} ${String(pack2.capabilityCount).padEnd(13)} ${pack2.name}
9195
+ `
9196
+ );
9197
+ }
9198
+ }
9199
+ return 0;
9200
+ }
9201
+ if (!packId) {
9202
+ stderr2.write(`Usage: fx targets ${action || "<list|doctor|run>"} <pack> [flags]
9203
+ `);
9204
+ return 1;
9205
+ }
9206
+ const pack = registry.get(packId);
9207
+ if (!pack) {
9208
+ stderr2.write(
9209
+ `Unknown target pack '${packId}'. Available: ${[...registry.keys()].join(", ")}
9210
+ `
9211
+ );
9212
+ return 1;
9213
+ }
9214
+ const requiredChecks = options.requiredChecks ?? pack.requiredChecks;
9215
+ const doctor = doctorTargetPack(pack, env, requiredChecks);
9216
+ if (action === "doctor") {
9217
+ writeDoctor(doctor, options.json === true, stdout);
9218
+ return doctor.ready ? 0 : 1;
9219
+ }
9220
+ if (action !== "run") {
9221
+ stderr2.write(`Unknown targets action '${action}'. Use list, doctor, run, or publish.
9222
+ `);
9223
+ return 1;
9224
+ }
9225
+ if (options.live) env.DBX_TEST_LIVE = "1";
9226
+ if (env.DBX_TEST_LIVE !== "1") {
9227
+ stderr2.write(
9228
+ "Target packs can create or mutate Databricks resources. Pass --live or set DBX_TEST_LIVE=1.\n"
9229
+ );
9230
+ return 1;
9231
+ }
9232
+ if (!doctor.ready) {
9233
+ writeDoctor(doctor, options.json === true, stderr2);
9234
+ return 1;
9235
+ }
9236
+ const evidencePath = options.evidencePath ?? `reports/target-packs/${pack.id}/evidence.json`;
9237
+ const junitPath = options.junitPath ?? `reports/target-packs/${pack.id}/junit.xml`;
9238
+ const evidence = await runTargetPack(pack, {
9239
+ env,
9240
+ requiredChecks,
9241
+ evidencePath,
9242
+ junitPath
9243
+ });
9244
+ if (!evidence) {
9245
+ stderr2.write("Target pack did not run because DBX_TEST_LIVE is disabled.\n");
9246
+ return 1;
9247
+ }
9248
+ if (options.json) {
9249
+ stdout.write(`${JSON.stringify(evidence, null, 2)}
9250
+ `);
9251
+ } else {
9252
+ for (const result of evidence.results) {
9253
+ stdout.write(`${symbol(result.status)} ${result.id} (${result.durationMs}ms)
9254
+ `);
9255
+ }
9256
+ stdout.write(
9257
+ `${evidence.success ? "PASS" : "FAIL"} ${pack.name}; evidence=${evidencePath}; junit=${junitPath}
9258
+ `
9259
+ );
9260
+ }
9261
+ return evidence.success ? 0 : 1;
9262
+ }
9263
+ async function cmdTargetPublish(evidencePath, options = {}) {
9264
+ const raw = JSON.parse(await readFile(evidencePath, "utf8"));
9265
+ const metadata = objectOf2(raw.targetPack);
9266
+ const packName = typeof metadata.name === "string" ? metadata.name : void 0;
9267
+ const packId = typeof metadata.id === "string" ? metadata.id : void 0;
9268
+ if (!packName && !packId) {
9269
+ throw new Error("Target evidence is missing targetPack metadata");
9270
+ }
9271
+ return cmdTestPublish(evidencePath, {
9272
+ ...options,
9273
+ suite: options.suite ?? `Databricks target: ${packName ?? packId}`
9274
+ });
9275
+ }
9276
+ function describePack(pack) {
9277
+ return {
9278
+ id: pack.id,
9279
+ name: pack.name,
9280
+ description: pack.description,
9281
+ version: pack.version,
9282
+ maturity: pack.maturity,
9283
+ capabilityCount: pack.capabilities.length,
9284
+ capabilities: [...pack.capabilities],
9285
+ requiredChecks: [...pack.requiredChecks ?? []],
9286
+ docsUrl: pack.docsUrl,
9287
+ certificationScopes: [...pack.certificationScopes ?? []]
9288
+ };
9289
+ }
9290
+ function writeDoctor(doctor, json, stream) {
9291
+ if (json) {
9292
+ stream.write(`${JSON.stringify(doctor, null, 2)}
9293
+ `);
9294
+ return;
9295
+ }
9296
+ stream.write(
9297
+ `${doctor.ready ? "READY" : "NOT READY"} ${doctor.pack.name} ${doctor.pack.version} (${doctor.pack.maturity})
9298
+ `
9299
+ );
9300
+ for (const requirement of doctor.requirements) {
9301
+ stream.write(
9302
+ `${requirement.satisfied ? "\u2713" : requirement.required ? "\u2717" : "-"} requirement ${requirement.id}: ${requirement.description} [${requirement.variables.join(" | ")}]
9303
+ `
9304
+ );
9305
+ }
9306
+ for (const check of doctor.checks) {
9307
+ stream.write(
9308
+ `${check.configured ? "\u2713" : check.required ? "\u2717" : "-"} check ${check.id}${check.required ? " [required]" : ""}: ${check.description}
9309
+ `
9310
+ );
9311
+ }
9312
+ }
9313
+ function symbol(status) {
9314
+ if (status === "pass") return "\u2713";
9315
+ if (status === "fail") return "\u2717";
9316
+ return "-";
9317
+ }
9318
+ function objectOf2(value) {
9319
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
9320
+ }
9169
9321
 
9170
9322
  // src/bin/fx.ts
9171
9323
  var HELP = `fx \u2014 Fabric Experiments CLI
@@ -9191,6 +9343,10 @@ COMMANDS
9191
9343
  logout [profile] Remove a stored hosted profile.
9192
9344
  profile [list|show|use] Inspect or switch hosted profiles.
9193
9345
  doctor Verify API, tenant, gateway, role, and config security.
9346
+ targets list List built-in Databricks target packs.
9347
+ targets doctor <pack> Validate target configuration without creating resources.
9348
+ targets run <pack> Run a pack and write JSON/JUnit evidence. Requires --live.
9349
+ targets publish <file> Publish target-pack evidence to Studio Quality.
9194
9350
 
9195
9351
  GLOBAL FLAGS
9196
9352
  --tenant <id> Tenant scope (default: default)
@@ -9221,6 +9377,10 @@ GLOBAL FLAGS
9221
9377
  --suite <name> test publish: display name for the suite
9222
9378
  --external-id <id> test publish: idempotent CI run identifier
9223
9379
  --run-url <url> test publish: CI artifact/run link
9380
+ --live targets run: explicitly allow live Databricks operations
9381
+ --required <ids> targets run: comma-separated required check IDs
9382
+ --evidence <file> targets run: evidence JSON output path
9383
+ --junit <file> targets run: JUnit XML output path
9224
9384
  --key-id <id> publish: keyId to sign with (default: dev-default)
9225
9385
  --out <dir> import-mojito: output directory
9226
9386
  --report <file> import-mojito: compatibility report path
@@ -9228,7 +9388,7 @@ GLOBAL FLAGS
9228
9388
  -h, --help print this help
9229
9389
  -v, --version print version
9230
9390
  `;
9231
- var VERSION2 = "0.7.0";
9391
+ var VERSION2 = "0.9.0";
9232
9392
  function parse2(argv) {
9233
9393
  const positional = [];
9234
9394
  const flags = {};
@@ -9299,6 +9459,38 @@ async function main() {
9299
9459
  );
9300
9460
  case "doctor":
9301
9461
  return cmdDoctor({ profileName: args.flags.profile });
9462
+ case "targets": {
9463
+ const action = args.positional[0] ?? "list";
9464
+ if (action === "publish") {
9465
+ const evidencePath = args.positional[1];
9466
+ if (!evidencePath) {
9467
+ process.stderr.write("Usage: fx targets publish <evidence.json> [flags]\n");
9468
+ return 1;
9469
+ }
9470
+ const hosted = await resolveHostedContext({
9471
+ profileName: args.flags.profile,
9472
+ apiUrl: args.flags["api-url"],
9473
+ apiKey: args.flags["api-key"],
9474
+ tenantId: explicitTenantId
9475
+ });
9476
+ return cmdTargetPublish(evidencePath, {
9477
+ tenantId: hosted.tenantId,
9478
+ apiUrl: hosted.apiUrl,
9479
+ apiKey: hosted.apiKey,
9480
+ bearerToken: hosted.bearerToken,
9481
+ suite: args.flags.suite,
9482
+ externalId: args.flags["external-id"],
9483
+ runUrl: args.flags["run-url"]
9484
+ });
9485
+ }
9486
+ return cmdTargets(action, args.positional[1], {
9487
+ json: args.flags.json === true,
9488
+ live: args.flags.live === true,
9489
+ requiredChecks: typeof args.flags.required === "string" ? args.flags.required.split(",").map((value) => value.trim()).filter(Boolean) : void 0,
9490
+ evidencePath: args.flags.evidence,
9491
+ junitPath: args.flags.junit
9492
+ });
9493
+ }
9302
9494
  case "validate":
9303
9495
  return cmdValidate(args.positional[0] ?? ".");
9304
9496
  case "plan":