@databricks-solutions/lakebase-scm-utils 0.2.45 → 0.2.47

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 (71) hide show
  1. package/README.md +13 -4
  2. package/dist/{pr-D3CteJaf.d.cts → pr-e-E4aP4j.d.cts} +6 -0
  3. package/dist/{pr-D3CteJaf.d.ts → pr-e-E4aP4j.d.ts} +6 -0
  4. package/dist/scripts/github/index.cjs +2 -0
  5. package/dist/scripts/github/index.d.cts +1 -1
  6. package/dist/scripts/github/index.d.ts +1 -1
  7. package/dist/scripts/github/index.js +2 -0
  8. package/dist/scripts/github/pr.cli.cjs +2 -0
  9. package/dist/scripts/github/pr.cli.js +2 -0
  10. package/dist/scripts/index.cjs +38 -5
  11. package/dist/scripts/index.d.cts +2 -2
  12. package/dist/scripts/index.d.ts +2 -2
  13. package/dist/scripts/index.js +36 -5
  14. package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +12 -3
  15. package/dist/scripts/lakebase/ci-resolve-branch.cli.js +12 -3
  16. package/dist/scripts/lakebase/collapse-heads.cli.cjs +12 -3
  17. package/dist/scripts/lakebase/collapse-heads.cli.js +12 -3
  18. package/dist/scripts/lakebase/detect-language.cli.cjs +12 -3
  19. package/dist/scripts/lakebase/detect-language.cli.js +12 -3
  20. package/dist/scripts/lakebase/doctor.cli.cjs +12 -3
  21. package/dist/scripts/lakebase/doctor.cli.js +12 -3
  22. package/dist/scripts/lakebase/get-connection.cli.cjs +12 -3
  23. package/dist/scripts/lakebase/get-connection.cli.js +12 -3
  24. package/dist/scripts/lakebase/index.cjs +44 -5
  25. package/dist/scripts/lakebase/index.d.cts +3 -14
  26. package/dist/scripts/lakebase/index.d.ts +3 -14
  27. package/dist/scripts/lakebase/index.js +44 -5
  28. package/dist/scripts/lakebase/infra-runner.cli.cjs +12 -3
  29. package/dist/scripts/lakebase/infra-runner.cli.js +12 -3
  30. package/dist/scripts/lakebase/new-migration.cli.cjs +12 -3
  31. package/dist/scripts/lakebase/new-migration.cli.js +12 -3
  32. package/dist/scripts/lakebase/schema-diff.cli.cjs +12 -3
  33. package/dist/scripts/lakebase/schema-diff.cli.js +12 -3
  34. package/dist/scripts/lakebase/schema-migrate.cli.cjs +12 -3
  35. package/dist/scripts/lakebase/schema-migrate.cli.js +12 -3
  36. package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +12 -3
  37. package/dist/scripts/lakebase/scm-claim-feature.cli.js +12 -3
  38. package/dist/scripts/lakebase/scm-doctor.cli.cjs +12 -3
  39. package/dist/scripts/lakebase/scm-doctor.cli.js +12 -3
  40. package/dist/scripts/lakebase/scm-merge.cli.cjs +12 -3
  41. package/dist/scripts/lakebase/scm-merge.cli.js +12 -3
  42. package/dist/scripts/lakebase/scm-prepare-pr.cli.cjs +2 -0
  43. package/dist/scripts/lakebase/scm-prepare-pr.cli.js +2 -0
  44. package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +12 -3
  45. package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +12 -3
  46. package/dist/scripts/lakebase/scm-wait-ci.cli.cjs +8 -0
  47. package/dist/scripts/lakebase/scm-wait-ci.cli.js +8 -0
  48. package/dist/scripts/lakebase/sync-ci-secrets.cli.cjs +8610 -0
  49. package/dist/scripts/lakebase/sync-ci-secrets.cli.d.cts +4 -0
  50. package/dist/scripts/lakebase/sync-ci-secrets.cli.d.ts +4 -0
  51. package/dist/scripts/lakebase/sync-ci-secrets.cli.js +8597 -0
  52. package/dist/scripts/util/index.cjs +21 -2
  53. package/dist/scripts/util/index.d.cts +9 -1
  54. package/dist/scripts/util/index.d.ts +9 -1
  55. package/dist/scripts/util/index.js +19 -2
  56. package/package.json +3 -2
  57. package/scripts/github/pr.ts +8 -0
  58. package/scripts/lakebase/constants.ts +23 -5
  59. package/scripts/lakebase/create-project.ts +14 -3
  60. package/scripts/lakebase/get-connection.ts +17 -3
  61. package/scripts/lakebase/scm-wait-ci.ts +13 -0
  62. package/scripts/lakebase/sync-ci-secrets.cli.ts +122 -0
  63. package/scripts/util/ci-secrets.ts +14 -1
  64. package/skills/lakebase-scm-workflows/README.md +2 -1
  65. package/templates/project/common/.gitignore.base +6 -0
  66. package/templates/project/common/scripts/lk +22 -4
  67. package/templates/project/nodejs/package.json +3 -1
  68. package/templates/project/nodejs/src/index.js +8 -0
  69. package/templates/project/nodejs/src/openapi.js +20 -0
  70. package/templates/project/nodejs/src/routes/health.js +18 -0
  71. package/templates/project/nodejs/tests/app.test.js +16 -0
@@ -382,6 +382,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
382
382
  var DEFAULT_ENDPOINT = "primary";
383
383
  var CONSORT_APPLICATION_NAME = "consort";
384
384
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
385
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
385
386
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
386
387
 
387
388
  // scripts/lakebase/self-version.ts
@@ -392,8 +393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
392
393
  var cached;
393
394
  function substrateSelfVersion() {
394
395
  if (cached !== void 0) return cached;
395
- if ("0.2.45".length > 0) {
396
- cached = "0.2.45";
396
+ if ("0.2.47".length > 0) {
397
+ cached = "0.2.47";
397
398
  return cached;
398
399
  }
399
400
  cached = "unknown";
@@ -421,9 +422,17 @@ function substrateSelfVersion() {
421
422
  }
422
423
 
423
424
  // scripts/lakebase/get-connection.ts
425
+ function sanitizeApplicationName(raw) {
426
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
427
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
428
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
429
+ }
424
430
  function connectionApplicationName() {
431
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
432
+ if (client) return sanitizeApplicationName(client);
425
433
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
426
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
434
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
435
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
427
436
  }
428
437
  async function getConnection(args) {
429
438
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -79370,6 +79370,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
79370
79370
  var DEFAULT_ENDPOINT = "primary";
79371
79371
  var CONSORT_APPLICATION_NAME = "consort";
79372
79372
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
79373
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
79373
79374
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
79374
79375
 
79375
79376
  // scripts/lakebase/self-version.ts
@@ -79381,8 +79382,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79381
79382
  var cached;
79382
79383
  function substrateSelfVersion() {
79383
79384
  if (cached !== void 0) return cached;
79384
- if ("0.2.45".length > 0) {
79385
- cached = "0.2.45";
79385
+ if ("0.2.47".length > 0) {
79386
+ cached = "0.2.47";
79386
79387
  return cached;
79387
79388
  }
79388
79389
  cached = "unknown";
@@ -79410,9 +79411,17 @@ function substrateSelfVersion() {
79410
79411
  }
79411
79412
 
79412
79413
  // scripts/lakebase/get-connection.ts
79414
+ function sanitizeApplicationName(raw) {
79415
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
79416
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79417
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
79418
+ }
79413
79419
  function connectionApplicationName() {
79420
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
79421
+ if (client) return sanitizeApplicationName(client);
79414
79422
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
79415
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79423
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
79424
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79416
79425
  }
79417
79426
  async function getConnection(args) {
79418
79427
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -473,6 +473,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
473
473
  var DEFAULT_ENDPOINT = "primary";
474
474
  var CONSORT_APPLICATION_NAME = "consort";
475
475
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
476
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
476
477
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
477
478
 
478
479
  // scripts/lakebase/self-version.ts
@@ -483,8 +484,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
483
484
  var cached;
484
485
  function substrateSelfVersion() {
485
486
  if (cached !== void 0) return cached;
486
- if ("0.2.45".length > 0) {
487
- cached = "0.2.45";
487
+ if ("0.2.47".length > 0) {
488
+ cached = "0.2.47";
488
489
  return cached;
489
490
  }
490
491
  cached = "unknown";
@@ -512,9 +513,17 @@ function substrateSelfVersion() {
512
513
  }
513
514
 
514
515
  // scripts/lakebase/get-connection.ts
516
+ function sanitizeApplicationName(raw) {
517
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
518
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
519
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
520
+ }
515
521
  function connectionApplicationName() {
522
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
523
+ if (client) return sanitizeApplicationName(client);
516
524
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
517
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
525
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
526
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
518
527
  }
519
528
  async function getConnection(args) {
520
529
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -79273,6 +79273,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
79273
79273
  var DEFAULT_ENDPOINT = "primary";
79274
79274
  var CONSORT_APPLICATION_NAME = "consort";
79275
79275
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
79276
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
79276
79277
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
79277
79278
 
79278
79279
  // scripts/lakebase/self-version.ts
@@ -79284,8 +79285,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79284
79285
  var cached;
79285
79286
  function substrateSelfVersion() {
79286
79287
  if (cached !== void 0) return cached;
79287
- if ("0.2.45".length > 0) {
79288
- cached = "0.2.45";
79288
+ if ("0.2.47".length > 0) {
79289
+ cached = "0.2.47";
79289
79290
  return cached;
79290
79291
  }
79291
79292
  cached = "unknown";
@@ -79313,9 +79314,17 @@ function substrateSelfVersion() {
79313
79314
  }
79314
79315
 
79315
79316
  // scripts/lakebase/get-connection.ts
79317
+ function sanitizeApplicationName(raw) {
79318
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
79319
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79320
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
79321
+ }
79316
79322
  function connectionApplicationName() {
79323
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
79324
+ if (client) return sanitizeApplicationName(client);
79317
79325
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
79318
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79326
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
79327
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79319
79328
  }
79320
79329
  async function getConnection(args) {
79321
79330
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -378,6 +378,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
378
378
  var DEFAULT_ENDPOINT = "primary";
379
379
  var CONSORT_APPLICATION_NAME = "consort";
380
380
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
381
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
381
382
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
382
383
 
383
384
  // scripts/lakebase/self-version.ts
@@ -388,8 +389,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
388
389
  var cached;
389
390
  function substrateSelfVersion() {
390
391
  if (cached !== void 0) return cached;
391
- if ("0.2.45".length > 0) {
392
- cached = "0.2.45";
392
+ if ("0.2.47".length > 0) {
393
+ cached = "0.2.47";
393
394
  return cached;
394
395
  }
395
396
  cached = "unknown";
@@ -417,9 +418,17 @@ function substrateSelfVersion() {
417
418
  }
418
419
 
419
420
  // scripts/lakebase/get-connection.ts
421
+ function sanitizeApplicationName(raw) {
422
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
423
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
424
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
425
+ }
420
426
  function connectionApplicationName() {
427
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
428
+ if (client) return sanitizeApplicationName(client);
421
429
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
422
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
430
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
431
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
423
432
  }
424
433
  async function getConnection(args) {
425
434
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -81577,6 +81577,7 @@ var RUNTIME_ARTIFACT_IGNORE = [
81577
81577
  var DEFAULT_ENDPOINT = "primary";
81578
81578
  var CONSORT_APPLICATION_NAME = "consort";
81579
81579
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
81580
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
81580
81581
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
81581
81582
 
81582
81583
  // scripts/lakebase/self-version.ts
@@ -81588,8 +81589,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
81588
81589
  var cached;
81589
81590
  function substrateSelfVersion() {
81590
81591
  if (cached !== void 0) return cached;
81591
- if ("0.2.45".length > 0) {
81592
- cached = "0.2.45";
81592
+ if ("0.2.47".length > 0) {
81593
+ cached = "0.2.47";
81593
81594
  return cached;
81594
81595
  }
81595
81596
  cached = "unknown";
@@ -81617,9 +81618,17 @@ function substrateSelfVersion() {
81617
81618
  }
81618
81619
 
81619
81620
  // scripts/lakebase/get-connection.ts
81621
+ function sanitizeApplicationName(raw) {
81622
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
81623
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
81624
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
81625
+ }
81620
81626
  function connectionApplicationName() {
81627
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
81628
+ if (client) return sanitizeApplicationName(client);
81621
81629
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
81622
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
81630
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
81631
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
81623
81632
  }
81624
81633
  async function getConnection(args) {
81625
81634
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -89736,6 +89745,8 @@ async function getPullRequest(ownerRepo, headBranch) {
89736
89745
  isDraft: pr.draft || false,
89737
89746
  ciStatus,
89738
89747
  checks,
89748
+ mergeable: pr.mergeable,
89749
+ mergeableState: pr.mergeable_state,
89739
89750
  headBranch: pr.head?.ref || headBranch,
89740
89751
  baseBranch: pr.base?.ref || "",
89741
89752
  body: pr.body || void 0,
@@ -91984,6 +91995,16 @@ async function setRepoSecrets(ownerRepo, secrets) {
91984
91995
  await setRepoSecret(ownerRepo, name, value);
91985
91996
  }
91986
91997
  }
91998
+ async function listSecretNames(ownerRepo) {
91999
+ try {
92000
+ const { owner, repo } = parseOwnerRepo(ownerRepo);
92001
+ const octokit2 = await getOctokit2();
92002
+ const { data } = await octokit2.rest.actions.listRepoSecrets({ owner, repo });
92003
+ return data.secrets.map((s2) => s2.name);
92004
+ } catch {
92005
+ return [];
92006
+ }
92007
+ }
91987
92008
 
91988
92009
  // scripts/git/remote.ts
91989
92010
  init_cjs_shims();
@@ -92023,6 +92044,11 @@ async function getOwnerRepo(cwd) {
92023
92044
  }
92024
92045
 
92025
92046
  // scripts/util/ci-secrets.ts
92047
+ var REQUIRED_CI_SECRETS = ["DATABRICKS_HOST", "LAKEBASE_PROJECT_ID", "DATABRICKS_TOKEN"];
92048
+ async function missingCiSecrets(ownerRepo) {
92049
+ const present = new Set(await listSecretNames(ownerRepo));
92050
+ return REQUIRED_CI_SECRETS.filter((n) => !present.has(n));
92051
+ }
92026
92052
  async function syncCiSecrets(args) {
92027
92053
  const lifetime = args.lifetimeSeconds ?? 86400;
92028
92054
  const comment = args.comment ?? "GitHub Actions CI";
@@ -92539,10 +92565,17 @@ Last probe error:
92539
92565
  lifetimeSeconds: 86400,
92540
92566
  ownerRepo: fullRepoName
92541
92567
  });
92568
+ const missing = await missingCiSecrets(fullRepoName);
92569
+ if (missing.length > 0) {
92570
+ const m2 = `CI auth incomplete \u2014 repo secret(s) MISSING: ${missing.join(", ")}. CI cannot provision a per-PR Lakebase branch until fixed. Repair with: lakebase-sync-ci-secrets (run in the project).`;
92571
+ warnings.push(m2);
92572
+ report(`WARNING: ${m2}`);
92573
+ }
92542
92574
  } catch (err) {
92543
92575
  const msg = err instanceof Error ? err.message : String(err);
92544
- warnings.push(`CI auth setup failed: ${msg}`);
92545
- report(`Warning: CI auth setup failed (${msg})`);
92576
+ const m2 = `CI auth setup failed: ${msg}. CI will fail (no DATABASE_URL) until repaired \u2014 run: lakebase-sync-ci-secrets (in the project).`;
92577
+ warnings.push(m2);
92578
+ report(`WARNING: ${m2}`);
92546
92579
  }
92547
92580
  }
92548
92581
  if (useGithub && runnerType === "self-hosted") {
@@ -94894,6 +94927,12 @@ async function waitForCi(args) {
94894
94927
  if (lastPr.ciStatus === "success") {
94895
94928
  return { done: true, value: lastPr };
94896
94929
  }
94930
+ if (lastPr.mergeableState === "dirty" && lastPr.checks.length === 0) {
94931
+ throw new ScmWaitCiError(
94932
+ `PR ${lastPr.url} is CONFLICTING with ${lastPr.baseBranch} \u2014 GitHub will not dispatch CI (0 runs) until the conflict is resolved. Reconcile the branch and re-push; the synchronize event will trigger CI.`,
94933
+ "pr-conflicting"
94934
+ );
94935
+ }
94897
94936
  if (lastPr.ciStatus === "failure") {
94898
94937
  const failed = lastPr.checks.filter((c) => /(FAILURE|TIMED_OUT|CANCELLED|ACTION_REQUIRED)/i.test(c.conclusion)).map((c) => `${c.name} (${c.conclusion})`);
94899
94938
  throw new ScmWaitCiError(
@@ -1,4 +1,4 @@
1
- import { W as WorkflowRunSummary, e as PullRequestInfo, o as mergePairedPullRequest } from '../../pr-D3CteJaf.cjs';
1
+ import { W as WorkflowRunSummary, e as PullRequestInfo, o as mergePairedPullRequest } from '../../pr-e-E4aP4j.cjs';
2
2
  import { Pool } from 'pg';
3
3
 
4
4
  declare const BRAND: unique symbol;
@@ -2510,17 +2510,6 @@ interface EnableInfraForProjectResult {
2510
2510
  */
2511
2511
  declare function enableInfraForProject(args: EnableInfraForProjectArgs): EnableInfraForProjectResult;
2512
2512
 
2513
- /**
2514
- * The `application_name` stamped on the substrate's Postgres connections , `<brand>/<version>`,
2515
- * reflecting WHO opened the connection:
2516
- * - `consort/<consort-version>` when the work comes FROM Consort (Consort exports its version
2517
- * in CONSORT_VERSION_ENV; we read it here);
2518
- * - `scm-utils/<scm-utils-version>` when scm-utils is invoked DIRECTLY (the VS Code extension,
2519
- * a bare `lakebase-*` CLI) , no env, so it falls back to this package's own brand + SemVer.
2520
- * Each carries its OWN version. A TRANSPARENT label visible to the database owner in their own
2521
- * `pg_stat_activity`. Never throws (an unreadable scm-utils version -> `scm-utils/unknown`; a
2522
- * blank env is ignored), so labelling can never break a connection.
2523
- */
2524
2513
  declare function connectionApplicationName(): string;
2525
2514
  interface GetConnectionArgs {
2526
2515
  /**
@@ -3133,8 +3122,8 @@ declare function preparePr(args: PreparePrArgs): Promise<PreparePrResult>;
3133
3122
  declare function pushFailureHint(rawMessage: string): string;
3134
3123
 
3135
3124
  declare class ScmWaitCiError extends Error {
3136
- readonly code: "no-state-file" | "bad-precondition" | "no-github-remote" | "ci-failed" | "timeout" | "pr-not-found";
3137
- constructor(message: string, code: "no-state-file" | "bad-precondition" | "no-github-remote" | "ci-failed" | "timeout" | "pr-not-found");
3125
+ readonly code: "no-state-file" | "bad-precondition" | "no-github-remote" | "ci-failed" | "pr-conflicting" | "timeout" | "pr-not-found";
3126
+ constructor(message: string, code: "no-state-file" | "bad-precondition" | "no-github-remote" | "ci-failed" | "pr-conflicting" | "timeout" | "pr-not-found");
3138
3127
  }
3139
3128
  interface WaitCiArgs {
3140
3129
  projectDir: string;
@@ -1,4 +1,4 @@
1
- import { W as WorkflowRunSummary, e as PullRequestInfo, o as mergePairedPullRequest } from '../../pr-D3CteJaf.js';
1
+ import { W as WorkflowRunSummary, e as PullRequestInfo, o as mergePairedPullRequest } from '../../pr-e-E4aP4j.js';
2
2
  import { Pool } from 'pg';
3
3
 
4
4
  declare const BRAND: unique symbol;
@@ -2510,17 +2510,6 @@ interface EnableInfraForProjectResult {
2510
2510
  */
2511
2511
  declare function enableInfraForProject(args: EnableInfraForProjectArgs): EnableInfraForProjectResult;
2512
2512
 
2513
- /**
2514
- * The `application_name` stamped on the substrate's Postgres connections , `<brand>/<version>`,
2515
- * reflecting WHO opened the connection:
2516
- * - `consort/<consort-version>` when the work comes FROM Consort (Consort exports its version
2517
- * in CONSORT_VERSION_ENV; we read it here);
2518
- * - `scm-utils/<scm-utils-version>` when scm-utils is invoked DIRECTLY (the VS Code extension,
2519
- * a bare `lakebase-*` CLI) , no env, so it falls back to this package's own brand + SemVer.
2520
- * Each carries its OWN version. A TRANSPARENT label visible to the database owner in their own
2521
- * `pg_stat_activity`. Never throws (an unreadable scm-utils version -> `scm-utils/unknown`; a
2522
- * blank env is ignored), so labelling can never break a connection.
2523
- */
2524
2513
  declare function connectionApplicationName(): string;
2525
2514
  interface GetConnectionArgs {
2526
2515
  /**
@@ -3133,8 +3122,8 @@ declare function preparePr(args: PreparePrArgs): Promise<PreparePrResult>;
3133
3122
  declare function pushFailureHint(rawMessage: string): string;
3134
3123
 
3135
3124
  declare class ScmWaitCiError extends Error {
3136
- readonly code: "no-state-file" | "bad-precondition" | "no-github-remote" | "ci-failed" | "timeout" | "pr-not-found";
3137
- constructor(message: string, code: "no-state-file" | "bad-precondition" | "no-github-remote" | "ci-failed" | "timeout" | "pr-not-found");
3125
+ readonly code: "no-state-file" | "bad-precondition" | "no-github-remote" | "ci-failed" | "pr-conflicting" | "timeout" | "pr-not-found";
3126
+ constructor(message: string, code: "no-state-file" | "bad-precondition" | "no-github-remote" | "ci-failed" | "pr-conflicting" | "timeout" | "pr-not-found");
3138
3127
  }
3139
3128
  interface WaitCiArgs {
3140
3129
  projectDir: string;
@@ -2506,6 +2506,7 @@ var RUNTIME_ARTIFACT_IGNORE = [
2506
2506
  var DEFAULT_ENDPOINT = "primary";
2507
2507
  var CONSORT_APPLICATION_NAME = "consort";
2508
2508
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
2509
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
2509
2510
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
2510
2511
 
2511
2512
  // scripts/lakebase/self-version.ts
@@ -2517,8 +2518,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
2517
2518
  var cached;
2518
2519
  function substrateSelfVersion() {
2519
2520
  if (cached !== void 0) return cached;
2520
- if ("0.2.45".length > 0) {
2521
- cached = "0.2.45";
2521
+ if ("0.2.47".length > 0) {
2522
+ cached = "0.2.47";
2522
2523
  return cached;
2523
2524
  }
2524
2525
  cached = "unknown";
@@ -2546,9 +2547,17 @@ function substrateSelfVersion() {
2546
2547
  }
2547
2548
 
2548
2549
  // scripts/lakebase/get-connection.ts
2550
+ function sanitizeApplicationName(raw) {
2551
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
2552
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
2553
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
2554
+ }
2549
2555
  function connectionApplicationName() {
2556
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
2557
+ if (client) return sanitizeApplicationName(client);
2550
2558
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
2551
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
2559
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
2560
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
2552
2561
  }
2553
2562
  async function getConnection(args) {
2554
2563
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -10665,6 +10674,8 @@ async function getPullRequest(ownerRepo, headBranch) {
10665
10674
  isDraft: pr.draft || false,
10666
10675
  ciStatus,
10667
10676
  checks,
10677
+ mergeable: pr.mergeable,
10678
+ mergeableState: pr.mergeable_state,
10668
10679
  headBranch: pr.head?.ref || headBranch,
10669
10680
  baseBranch: pr.base?.ref || "",
10670
10681
  body: pr.body || void 0,
@@ -12913,6 +12924,16 @@ async function setRepoSecrets(ownerRepo, secrets) {
12913
12924
  await setRepoSecret(ownerRepo, name, value);
12914
12925
  }
12915
12926
  }
12927
+ async function listSecretNames(ownerRepo) {
12928
+ try {
12929
+ const { owner, repo } = parseOwnerRepo(ownerRepo);
12930
+ const octokit2 = await getOctokit2();
12931
+ const { data } = await octokit2.rest.actions.listRepoSecrets({ owner, repo });
12932
+ return data.secrets.map((s) => s.name);
12933
+ } catch {
12934
+ return [];
12935
+ }
12936
+ }
12916
12937
 
12917
12938
  // scripts/git/remote.ts
12918
12939
  init_esm_shims();
@@ -12952,6 +12973,11 @@ async function getOwnerRepo(cwd) {
12952
12973
  }
12953
12974
 
12954
12975
  // scripts/util/ci-secrets.ts
12976
+ var REQUIRED_CI_SECRETS = ["DATABRICKS_HOST", "LAKEBASE_PROJECT_ID", "DATABRICKS_TOKEN"];
12977
+ async function missingCiSecrets(ownerRepo) {
12978
+ const present = new Set(await listSecretNames(ownerRepo));
12979
+ return REQUIRED_CI_SECRETS.filter((n) => !present.has(n));
12980
+ }
12955
12981
  async function syncCiSecrets(args) {
12956
12982
  const lifetime = args.lifetimeSeconds ?? 86400;
12957
12983
  const comment = args.comment ?? "GitHub Actions CI";
@@ -13468,10 +13494,17 @@ Last probe error:
13468
13494
  lifetimeSeconds: 86400,
13469
13495
  ownerRepo: fullRepoName
13470
13496
  });
13497
+ const missing = await missingCiSecrets(fullRepoName);
13498
+ if (missing.length > 0) {
13499
+ const m = `CI auth incomplete \u2014 repo secret(s) MISSING: ${missing.join(", ")}. CI cannot provision a per-PR Lakebase branch until fixed. Repair with: lakebase-sync-ci-secrets (run in the project).`;
13500
+ warnings.push(m);
13501
+ report(`WARNING: ${m}`);
13502
+ }
13471
13503
  } catch (err) {
13472
13504
  const msg = err instanceof Error ? err.message : String(err);
13473
- warnings.push(`CI auth setup failed: ${msg}`);
13474
- report(`Warning: CI auth setup failed (${msg})`);
13505
+ const m = `CI auth setup failed: ${msg}. CI will fail (no DATABASE_URL) until repaired \u2014 run: lakebase-sync-ci-secrets (in the project).`;
13506
+ warnings.push(m);
13507
+ report(`WARNING: ${m}`);
13475
13508
  }
13476
13509
  }
13477
13510
  if (useGithub && runnerType === "self-hosted") {
@@ -15823,6 +15856,12 @@ async function waitForCi(args) {
15823
15856
  if (lastPr.ciStatus === "success") {
15824
15857
  return { done: true, value: lastPr };
15825
15858
  }
15859
+ if (lastPr.mergeableState === "dirty" && lastPr.checks.length === 0) {
15860
+ throw new ScmWaitCiError(
15861
+ `PR ${lastPr.url} is CONFLICTING with ${lastPr.baseBranch} \u2014 GitHub will not dispatch CI (0 runs) until the conflict is resolved. Reconcile the branch and re-push; the synchronize event will trigger CI.`,
15862
+ "pr-conflicting"
15863
+ );
15864
+ }
15826
15865
  if (lastPr.ciStatus === "failure") {
15827
15866
  const failed = lastPr.checks.filter((c) => /(FAILURE|TIMED_OUT|CANCELLED|ACTION_REQUIRED)/i.test(c.conclusion)).map((c) => `${c.name} (${c.conclusion})`);
15828
15867
  throw new ScmWaitCiError(
@@ -79278,6 +79278,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
79278
79278
  var DEFAULT_ENDPOINT = "primary";
79279
79279
  var CONSORT_APPLICATION_NAME = "consort";
79280
79280
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
79281
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
79281
79282
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
79282
79283
 
79283
79284
  // scripts/lakebase/self-version.ts
@@ -79289,8 +79290,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79289
79290
  var cached;
79290
79291
  function substrateSelfVersion() {
79291
79292
  if (cached !== void 0) return cached;
79292
- if ("0.2.45".length > 0) {
79293
- cached = "0.2.45";
79293
+ if ("0.2.47".length > 0) {
79294
+ cached = "0.2.47";
79294
79295
  return cached;
79295
79296
  }
79296
79297
  cached = "unknown";
@@ -79318,9 +79319,17 @@ function substrateSelfVersion() {
79318
79319
  }
79319
79320
 
79320
79321
  // scripts/lakebase/get-connection.ts
79322
+ function sanitizeApplicationName(raw) {
79323
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
79324
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79325
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
79326
+ }
79321
79327
  function connectionApplicationName() {
79328
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
79329
+ if (client) return sanitizeApplicationName(client);
79322
79330
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
79323
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79331
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
79332
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79324
79333
  }
79325
79334
  async function getConnection(args) {
79326
79335
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -382,6 +382,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
382
382
  var DEFAULT_ENDPOINT = "primary";
383
383
  var CONSORT_APPLICATION_NAME = "consort";
384
384
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
385
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
385
386
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
386
387
 
387
388
  // scripts/lakebase/self-version.ts
@@ -392,8 +393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
392
393
  var cached;
393
394
  function substrateSelfVersion() {
394
395
  if (cached !== void 0) return cached;
395
- if ("0.2.45".length > 0) {
396
- cached = "0.2.45";
396
+ if ("0.2.47".length > 0) {
397
+ cached = "0.2.47";
397
398
  return cached;
398
399
  }
399
400
  cached = "unknown";
@@ -421,9 +422,17 @@ function substrateSelfVersion() {
421
422
  }
422
423
 
423
424
  // scripts/lakebase/get-connection.ts
425
+ function sanitizeApplicationName(raw) {
426
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
427
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
428
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
429
+ }
424
430
  function connectionApplicationName() {
431
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
432
+ if (client) return sanitizeApplicationName(client);
425
433
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
426
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
434
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
435
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
427
436
  }
428
437
  async function getConnection(args) {
429
438
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -79278,6 +79278,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
79278
79278
  var DEFAULT_ENDPOINT = "primary";
79279
79279
  var CONSORT_APPLICATION_NAME = "consort";
79280
79280
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
79281
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
79281
79282
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
79282
79283
 
79283
79284
  // scripts/lakebase/self-version.ts
@@ -79289,8 +79290,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79289
79290
  var cached;
79290
79291
  function substrateSelfVersion() {
79291
79292
  if (cached !== void 0) return cached;
79292
- if ("0.2.45".length > 0) {
79293
- cached = "0.2.45";
79293
+ if ("0.2.47".length > 0) {
79294
+ cached = "0.2.47";
79294
79295
  return cached;
79295
79296
  }
79296
79297
  cached = "unknown";
@@ -79318,9 +79319,17 @@ function substrateSelfVersion() {
79318
79319
  }
79319
79320
 
79320
79321
  // scripts/lakebase/get-connection.ts
79322
+ function sanitizeApplicationName(raw) {
79323
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
79324
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79325
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
79326
+ }
79321
79327
  function connectionApplicationName() {
79328
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
79329
+ if (client) return sanitizeApplicationName(client);
79322
79330
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
79323
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79331
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
79332
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
79324
79333
  }
79325
79334
  async function getConnection(args) {
79326
79335
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;
@@ -382,6 +382,7 @@ var DEFAULT_DATABASE = "databricks_postgres";
382
382
  var DEFAULT_ENDPOINT = "primary";
383
383
  var CONSORT_APPLICATION_NAME = "consort";
384
384
  var SCM_UTILS_APPLICATION_NAME = "scm-utils";
385
+ var SCM_CLIENT_ENV = "LAKEBASE_SCM_CLIENT";
385
386
  var CONSORT_VERSION_ENV = "CONSORT_VERSION";
386
387
 
387
388
  // scripts/lakebase/self-version.ts
@@ -392,8 +393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
392
393
  var cached;
393
394
  function substrateSelfVersion() {
394
395
  if (cached !== void 0) return cached;
395
- if ("0.2.45".length > 0) {
396
- cached = "0.2.45";
396
+ if ("0.2.47".length > 0) {
397
+ cached = "0.2.47";
397
398
  return cached;
398
399
  }
399
400
  cached = "unknown";
@@ -421,9 +422,17 @@ function substrateSelfVersion() {
421
422
  }
422
423
 
423
424
  // scripts/lakebase/get-connection.ts
425
+ function sanitizeApplicationName(raw) {
426
+ const cleaned = raw.replace(/[^\x21-\x7e]+/g, "-").replace(/^-+|-+$/g, "");
427
+ if (!cleaned) return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
428
+ return cleaned.length > 63 ? cleaned.slice(0, 63) : cleaned;
429
+ }
424
430
  function connectionApplicationName() {
431
+ const client = process.env[SCM_CLIENT_ENV]?.trim();
432
+ if (client) return sanitizeApplicationName(client);
425
433
  const consortVersion = process.env[CONSORT_VERSION_ENV]?.trim();
426
- return consortVersion ? `${CONSORT_APPLICATION_NAME}/${consortVersion}` : `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
434
+ if (consortVersion) return `${CONSORT_APPLICATION_NAME}/${consortVersion}`;
435
+ return `${SCM_UTILS_APPLICATION_NAME}/${substrateSelfVersion()}`;
427
436
  }
428
437
  async function getConnection(args) {
429
438
  const endpointName = args.endpointName ?? DEFAULT_ENDPOINT;