@databricks-solutions/lakebase-scm-utils 0.3.9 → 0.3.11

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 (69) hide show
  1. package/dist/{pr-e-E4aP4j.d.cts → pr-D-eayWyJ.d.cts} +59 -1
  2. package/dist/{pr-e-E4aP4j.d.ts → pr-D-eayWyJ.d.ts} +59 -1
  3. package/dist/scripts/git/index.cjs +30 -14
  4. package/dist/scripts/git/index.d.cts +32 -1
  5. package/dist/scripts/git/index.d.ts +32 -1
  6. package/dist/scripts/git/index.js +28 -14
  7. package/dist/scripts/github/index.d.cts +2 -60
  8. package/dist/scripts/github/index.d.ts +2 -60
  9. package/dist/scripts/index.cjs +301 -98
  10. package/dist/scripts/index.d.cts +4 -4
  11. package/dist/scripts/index.d.ts +4 -4
  12. package/dist/scripts/index.js +296 -98
  13. package/dist/scripts/lakebase/branch.cli.cjs +55 -10
  14. package/dist/scripts/lakebase/branch.cli.js +55 -10
  15. package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +59 -24
  16. package/dist/scripts/lakebase/ci-resolve-branch.cli.js +59 -24
  17. package/dist/scripts/lakebase/collapse-heads.cli.cjs +16 -14
  18. package/dist/scripts/lakebase/collapse-heads.cli.js +16 -14
  19. package/dist/scripts/lakebase/cut-backup.cli.cjs +43 -10
  20. package/dist/scripts/lakebase/cut-backup.cli.js +43 -10
  21. package/dist/scripts/lakebase/cut-tier.cli.cjs +43 -10
  22. package/dist/scripts/lakebase/cut-tier.cli.js +43 -10
  23. package/dist/scripts/lakebase/detect-language.cli.cjs +16 -14
  24. package/dist/scripts/lakebase/detect-language.cli.js +16 -14
  25. package/dist/scripts/lakebase/doctor.cli.cjs +16 -14
  26. package/dist/scripts/lakebase/doctor.cli.js +16 -14
  27. package/dist/scripts/lakebase/get-connection.cli.cjs +16 -14
  28. package/dist/scripts/lakebase/get-connection.cli.js +16 -14
  29. package/dist/scripts/lakebase/index.cjs +313 -99
  30. package/dist/scripts/lakebase/index.d.cts +97 -2
  31. package/dist/scripts/lakebase/index.d.ts +97 -2
  32. package/dist/scripts/lakebase/index.js +310 -99
  33. package/dist/scripts/lakebase/infra-runner.cli.cjs +16 -14
  34. package/dist/scripts/lakebase/infra-runner.cli.js +16 -14
  35. package/dist/scripts/lakebase/new-migration.cli.cjs +16 -14
  36. package/dist/scripts/lakebase/new-migration.cli.js +16 -14
  37. package/dist/scripts/lakebase/schema-diff.cli.cjs +16 -14
  38. package/dist/scripts/lakebase/schema-diff.cli.js +16 -14
  39. package/dist/scripts/lakebase/schema-migrate.cli.cjs +16 -14
  40. package/dist/scripts/lakebase/schema-migrate.cli.js +16 -14
  41. package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +59 -24
  42. package/dist/scripts/lakebase/scm-claim-feature.cli.js +59 -24
  43. package/dist/scripts/lakebase/scm-doctor.cli.cjs +59 -24
  44. package/dist/scripts/lakebase/scm-doctor.cli.js +59 -24
  45. package/dist/scripts/lakebase/scm-merge.cli.cjs +16 -14
  46. package/dist/scripts/lakebase/scm-merge.cli.js +16 -14
  47. package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +16 -14
  48. package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +16 -14
  49. package/dist/scripts/lakebase/scm-recover-orphans.cli.cjs +43 -10
  50. package/dist/scripts/lakebase/scm-recover-orphans.cli.js +43 -10
  51. package/dist/scripts/lakebase/snapshot.cli.cjs +418 -0
  52. package/dist/scripts/lakebase/snapshot.cli.d.cts +1 -0
  53. package/dist/scripts/lakebase/snapshot.cli.d.ts +1 -0
  54. package/dist/scripts/lakebase/snapshot.cli.js +395 -0
  55. package/dist/scripts/util/index.cjs +2 -2
  56. package/dist/scripts/util/index.js +2 -2
  57. package/package.json +2 -1
  58. package/scripts/git/commit-push.ts +60 -14
  59. package/scripts/lakebase/branch-create.ts +93 -14
  60. package/scripts/lakebase/branch.cli.ts +15 -0
  61. package/scripts/lakebase/create-preflight.ts +213 -1
  62. package/scripts/lakebase/create-project.ts +98 -30
  63. package/scripts/lakebase/get-connection.ts +29 -12
  64. package/scripts/lakebase/snapshot.cli.ts +117 -0
  65. package/scripts/lakebase/snapshot.ts +85 -0
  66. package/templates/project/common/scripts/run-tests.sh +43 -2
  67. package/templates/project/python/tests/conftest.py +22 -0
  68. package/templates/project/common/tests/e2e/__pycache__/conftest.cpython-314.pyc +0 -0
  69. package/templates/project/python/tests/__pycache__/conftest.cpython-314.pyc +0 -0
@@ -464,9 +464,46 @@ function dbcli2(args, host, timeout = KIT_TIMEOUTS.cliDefault) {
464
464
  }
465
465
 
466
466
  // scripts/lakebase/branch-create.ts
467
+ function snapshotPath(instance, snapshot) {
468
+ return snapshot.includes("/") ? snapshot : `${projectPath(instance)}/snapshots/${snapshot}`;
469
+ }
470
+ function applyExpiration(spec, ttl, noExpiry) {
471
+ if (ttl && noExpiry === true) {
472
+ throw new LakebaseBranchError(
473
+ `Cannot set both ttl ("${ttl}") and noExpiry: true on the same branch \u2013 they are mutually exclusive. Pass one or the other.`
474
+ );
475
+ }
476
+ if (ttl) spec.ttl = ttl;
477
+ else if (noExpiry ?? true) spec.no_expiry = true;
478
+ }
467
479
  async function createBranch(args) {
468
480
  const sanitized = sanitizeBranchName(args.branch);
469
481
  const lookup = { instance: args.instance, host: args.host };
482
+ if (args.fromSnapshot) {
483
+ if (args.parentBranch || args.sourceBranchTime || args.sourceBranchLsn) {
484
+ throw new LakebaseBranchError(
485
+ `fromSnapshot is mutually exclusive with parentBranch / sourceBranchTime / sourceBranchLsn (the Lakebase API rejects source_snapshot combined with any source_branch field).`
486
+ );
487
+ }
488
+ const existing2 = await getBranchByName(sanitized, lookup);
489
+ if (existing2) return existing2;
490
+ const spec = { source_snapshot: snapshotPath(args.instance, args.fromSnapshot) };
491
+ applyExpiration(spec, args.ttl, args.noExpiry);
492
+ try {
493
+ await createWithTtlRecovery(args.instance, sanitized, spec, args.host);
494
+ } catch (err) {
495
+ if (err instanceof LakebaseBranchTtlTooLongError) throw err;
496
+ const landed = await getBranchByName(sanitized, lookup);
497
+ if (!landed) throw err;
498
+ }
499
+ return waitForBranchReady({
500
+ instance: args.instance,
501
+ host: args.host,
502
+ branch: sanitized,
503
+ timeoutMs: args.readyTimeoutMs ?? KIT_TIMEOUTS.readyWait,
504
+ pollIntervalMs: args.pollIntervalMs ?? KIT_TIMEOUTS.readyPoll
505
+ });
506
+ }
470
507
  let sourceBranchPath;
471
508
  if (args.parentBranch) {
472
509
  if (looksLikeBranchUid(args.parentBranch)) {
@@ -514,19 +551,15 @@ async function createBranch(args) {
514
551
  assertSourceMatches(existing, sourceBranchPath, sanitized);
515
552
  return existing;
516
553
  }
517
- if (args.ttl && args.noExpiry === true) {
554
+ if (args.sourceBranchTime && args.sourceBranchLsn) {
518
555
  throw new LakebaseBranchError(
519
- `Cannot set both ttl ("${args.ttl}") and noExpiry: true on the same branch \u2013 they are mutually exclusive. Pass one or the other.`
556
+ `sourceBranchTime and sourceBranchLsn are mutually exclusive \u2013 pass at most one point-in-time.`
520
557
  );
521
558
  }
522
- const specObj = {
523
- source_branch: sourceBranchPath
524
- };
525
- if (args.ttl) {
526
- specObj.ttl = args.ttl;
527
- } else if (args.noExpiry ?? true) {
528
- specObj.no_expiry = true;
529
- }
559
+ const specObj = { source_branch: sourceBranchPath };
560
+ if (args.sourceBranchTime) specObj.source_branch_time = args.sourceBranchTime;
561
+ else if (args.sourceBranchLsn) specObj.source_branch_lsn = args.sourceBranchLsn;
562
+ applyExpiration(specObj, args.ttl, args.noExpiry);
530
563
  try {
531
564
  await createWithTtlRecovery(args.instance, sanitized, specObj, args.host);
532
565
  } catch (err) {
@@ -531,9 +531,46 @@ function dbcli2(args, host, timeout = KIT_TIMEOUTS.cliDefault) {
531
531
  }
532
532
 
533
533
  // scripts/lakebase/branch-create.ts
534
+ function snapshotPath(instance, snapshot) {
535
+ return snapshot.includes("/") ? snapshot : `${projectPath(instance)}/snapshots/${snapshot}`;
536
+ }
537
+ function applyExpiration(spec, ttl, noExpiry) {
538
+ if (ttl && noExpiry === true) {
539
+ throw new LakebaseBranchError(
540
+ `Cannot set both ttl ("${ttl}") and noExpiry: true on the same branch \u2013 they are mutually exclusive. Pass one or the other.`
541
+ );
542
+ }
543
+ if (ttl) spec.ttl = ttl;
544
+ else if (noExpiry ?? true) spec.no_expiry = true;
545
+ }
534
546
  async function createBranch(args) {
535
547
  const sanitized = sanitizeBranchName(args.branch);
536
548
  const lookup = { instance: args.instance, host: args.host };
549
+ if (args.fromSnapshot) {
550
+ if (args.parentBranch || args.sourceBranchTime || args.sourceBranchLsn) {
551
+ throw new LakebaseBranchError(
552
+ `fromSnapshot is mutually exclusive with parentBranch / sourceBranchTime / sourceBranchLsn (the Lakebase API rejects source_snapshot combined with any source_branch field).`
553
+ );
554
+ }
555
+ const existing2 = await getBranchByName(sanitized, lookup);
556
+ if (existing2) return existing2;
557
+ const spec = { source_snapshot: snapshotPath(args.instance, args.fromSnapshot) };
558
+ applyExpiration(spec, args.ttl, args.noExpiry);
559
+ try {
560
+ await createWithTtlRecovery(args.instance, sanitized, spec, args.host);
561
+ } catch (err) {
562
+ if (err instanceof LakebaseBranchTtlTooLongError) throw err;
563
+ const landed = await getBranchByName(sanitized, lookup);
564
+ if (!landed) throw err;
565
+ }
566
+ return waitForBranchReady({
567
+ instance: args.instance,
568
+ host: args.host,
569
+ branch: sanitized,
570
+ timeoutMs: args.readyTimeoutMs ?? KIT_TIMEOUTS.readyWait,
571
+ pollIntervalMs: args.pollIntervalMs ?? KIT_TIMEOUTS.readyPoll
572
+ });
573
+ }
537
574
  let sourceBranchPath;
538
575
  if (args.parentBranch) {
539
576
  if (looksLikeBranchUid(args.parentBranch)) {
@@ -581,19 +618,15 @@ async function createBranch(args) {
581
618
  assertSourceMatches(existing, sourceBranchPath, sanitized);
582
619
  return existing;
583
620
  }
584
- if (args.ttl && args.noExpiry === true) {
621
+ if (args.sourceBranchTime && args.sourceBranchLsn) {
585
622
  throw new LakebaseBranchError(
586
- `Cannot set both ttl ("${args.ttl}") and noExpiry: true on the same branch \u2013 they are mutually exclusive. Pass one or the other.`
623
+ `sourceBranchTime and sourceBranchLsn are mutually exclusive \u2013 pass at most one point-in-time.`
587
624
  );
588
625
  }
589
- const specObj = {
590
- source_branch: sourceBranchPath
591
- };
592
- if (args.ttl) {
593
- specObj.ttl = args.ttl;
594
- } else if (args.noExpiry ?? true) {
595
- specObj.no_expiry = true;
596
- }
626
+ const specObj = { source_branch: sourceBranchPath };
627
+ if (args.sourceBranchTime) specObj.source_branch_time = args.sourceBranchTime;
628
+ else if (args.sourceBranchLsn) specObj.source_branch_lsn = args.sourceBranchLsn;
629
+ applyExpiration(specObj, args.ttl, args.noExpiry);
597
630
  try {
598
631
  await createWithTtlRecovery(args.instance, sanitized, specObj, args.host);
599
632
  } catch (err) {
@@ -491,9 +491,46 @@ function dbcli2(args, host, timeout = KIT_TIMEOUTS.cliDefault) {
491
491
  }
492
492
 
493
493
  // scripts/lakebase/branch-create.ts
494
+ function snapshotPath(instance, snapshot) {
495
+ return snapshot.includes("/") ? snapshot : `${projectPath(instance)}/snapshots/${snapshot}`;
496
+ }
497
+ function applyExpiration(spec, ttl, noExpiry) {
498
+ if (ttl && noExpiry === true) {
499
+ throw new LakebaseBranchError(
500
+ `Cannot set both ttl ("${ttl}") and noExpiry: true on the same branch \u2013 they are mutually exclusive. Pass one or the other.`
501
+ );
502
+ }
503
+ if (ttl) spec.ttl = ttl;
504
+ else if (noExpiry ?? true) spec.no_expiry = true;
505
+ }
494
506
  async function createBranch(args) {
495
507
  const sanitized = sanitizeBranchName(args.branch);
496
508
  const lookup = { instance: args.instance, host: args.host };
509
+ if (args.fromSnapshot) {
510
+ if (args.parentBranch || args.sourceBranchTime || args.sourceBranchLsn) {
511
+ throw new LakebaseBranchError(
512
+ `fromSnapshot is mutually exclusive with parentBranch / sourceBranchTime / sourceBranchLsn (the Lakebase API rejects source_snapshot combined with any source_branch field).`
513
+ );
514
+ }
515
+ const existing2 = await getBranchByName(sanitized, lookup);
516
+ if (existing2) return existing2;
517
+ const spec = { source_snapshot: snapshotPath(args.instance, args.fromSnapshot) };
518
+ applyExpiration(spec, args.ttl, args.noExpiry);
519
+ try {
520
+ await createWithTtlRecovery(args.instance, sanitized, spec, args.host);
521
+ } catch (err) {
522
+ if (err instanceof LakebaseBranchTtlTooLongError) throw err;
523
+ const landed = await getBranchByName(sanitized, lookup);
524
+ if (!landed) throw err;
525
+ }
526
+ return waitForBranchReady({
527
+ instance: args.instance,
528
+ host: args.host,
529
+ branch: sanitized,
530
+ timeoutMs: args.readyTimeoutMs ?? KIT_TIMEOUTS.readyWait,
531
+ pollIntervalMs: args.pollIntervalMs ?? KIT_TIMEOUTS.readyPoll
532
+ });
533
+ }
497
534
  let sourceBranchPath;
498
535
  if (args.parentBranch) {
499
536
  if (looksLikeBranchUid(args.parentBranch)) {
@@ -541,19 +578,15 @@ async function createBranch(args) {
541
578
  assertSourceMatches(existing, sourceBranchPath, sanitized);
542
579
  return existing;
543
580
  }
544
- if (args.ttl && args.noExpiry === true) {
581
+ if (args.sourceBranchTime && args.sourceBranchLsn) {
545
582
  throw new LakebaseBranchError(
546
- `Cannot set both ttl ("${args.ttl}") and noExpiry: true on the same branch \u2013 they are mutually exclusive. Pass one or the other.`
583
+ `sourceBranchTime and sourceBranchLsn are mutually exclusive \u2013 pass at most one point-in-time.`
547
584
  );
548
585
  }
549
- const specObj = {
550
- source_branch: sourceBranchPath
551
- };
552
- if (args.ttl) {
553
- specObj.ttl = args.ttl;
554
- } else if (args.noExpiry ?? true) {
555
- specObj.no_expiry = true;
556
- }
586
+ const specObj = { source_branch: sourceBranchPath };
587
+ if (args.sourceBranchTime) specObj.source_branch_time = args.sourceBranchTime;
588
+ else if (args.sourceBranchLsn) specObj.source_branch_lsn = args.sourceBranchLsn;
589
+ applyExpiration(specObj, args.ttl, args.noExpiry);
557
590
  try {
558
591
  await createWithTtlRecovery(args.instance, sanitized, specObj, args.host);
559
592
  } catch (err) {
@@ -79290,8 +79290,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79290
79290
  var cached;
79291
79291
  function substrateSelfVersion() {
79292
79292
  if (cached !== void 0) return cached;
79293
- if ("0.3.9".length > 0) {
79294
- cached = "0.3.9";
79293
+ if ("0.3.11".length > 0) {
79294
+ cached = "0.3.11";
79295
79295
  return cached;
79296
79296
  }
79297
79297
  cached = "unknown";
@@ -79338,22 +79338,24 @@ async function getConnection(args) {
79338
79338
  const endpointPath = `projects/${args.instance}/branches/${branchId}/endpoints/${endpointName}`;
79339
79339
  if (args.output === "dsn") {
79340
79340
  const host2 = await resolveEndpointHost(args.instance, branchId);
79341
- const { token, email: email2 } = await mintCredential(endpointPath);
79342
- const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token });
79341
+ const { token: token2, email: email2 } = await mintCredential(endpointPath);
79342
+ const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token2 });
79343
79343
  return { url, host: host2, port: POSTGRES_PORT, database, user: email2, endpointPath };
79344
79344
  }
79345
79345
  const host = await resolveEndpointHost(args.instance, branchId);
79346
- const email = await resolveCurrentUser();
79347
79346
  process.env.PGAPPNAME = connectionApplicationName();
79348
- return createLakebasePool({
79349
- endpoint: endpointPath,
79350
- host,
79351
- database,
79352
- user: email,
79353
- // workspaceClient is passed through verbatim. createLakebasePool falls
79354
- // back to environment / ServiceContext when omitted.
79355
- ...args.workspaceClient !== void 0 ? { workspaceClient: args.workspaceClient } : {}
79356
- });
79347
+ if (args.workspaceClient !== void 0) {
79348
+ const email2 = await resolveCurrentUser();
79349
+ return createLakebasePool({
79350
+ endpoint: endpointPath,
79351
+ host,
79352
+ database,
79353
+ user: email2,
79354
+ workspaceClient: args.workspaceClient
79355
+ });
79356
+ }
79357
+ const { token, email } = await mintCredential(endpointPath);
79358
+ return createLakebasePool({ host, database, user: email, password: token });
79357
79359
  }
79358
79360
  async function resolveEndpointHost(instance, branch) {
79359
79361
  const branchId = await resolveBranchId({ instance, branch });
@@ -393,8 +393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
393
393
  var cached;
394
394
  function substrateSelfVersion() {
395
395
  if (cached !== void 0) return cached;
396
- if ("0.3.9".length > 0) {
397
- cached = "0.3.9";
396
+ if ("0.3.11".length > 0) {
397
+ cached = "0.3.11";
398
398
  return cached;
399
399
  }
400
400
  cached = "unknown";
@@ -441,22 +441,24 @@ async function getConnection(args) {
441
441
  const endpointPath = `projects/${args.instance}/branches/${branchId}/endpoints/${endpointName}`;
442
442
  if (args.output === "dsn") {
443
443
  const host2 = await resolveEndpointHost(args.instance, branchId);
444
- const { token, email: email2 } = await mintCredential(endpointPath);
445
- const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token });
444
+ const { token: token2, email: email2 } = await mintCredential(endpointPath);
445
+ const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token2 });
446
446
  return { url, host: host2, port: POSTGRES_PORT, database, user: email2, endpointPath };
447
447
  }
448
448
  const host = await resolveEndpointHost(args.instance, branchId);
449
- const email = await resolveCurrentUser();
450
449
  process.env.PGAPPNAME = connectionApplicationName();
451
- return createLakebasePool({
452
- endpoint: endpointPath,
453
- host,
454
- database,
455
- user: email,
456
- // workspaceClient is passed through verbatim. createLakebasePool falls
457
- // back to environment / ServiceContext when omitted.
458
- ...args.workspaceClient !== void 0 ? { workspaceClient: args.workspaceClient } : {}
459
- });
450
+ if (args.workspaceClient !== void 0) {
451
+ const email2 = await resolveCurrentUser();
452
+ return createLakebasePool({
453
+ endpoint: endpointPath,
454
+ host,
455
+ database,
456
+ user: email2,
457
+ workspaceClient: args.workspaceClient
458
+ });
459
+ }
460
+ const { token, email } = await mintCredential(endpointPath);
461
+ return createLakebasePool({ host, database, user: email, password: token });
460
462
  }
461
463
  async function resolveEndpointHost(instance, branch) {
462
464
  const branchId = await resolveBranchId({ instance, branch });
@@ -80800,8 +80800,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
80800
80800
  var cached;
80801
80801
  function substrateSelfVersion() {
80802
80802
  if (cached !== void 0) return cached;
80803
- if ("0.3.9".length > 0) {
80804
- cached = "0.3.9";
80803
+ if ("0.3.11".length > 0) {
80804
+ cached = "0.3.11";
80805
80805
  return cached;
80806
80806
  }
80807
80807
  cached = "unknown";
@@ -80848,22 +80848,24 @@ async function getConnection(args) {
80848
80848
  const endpointPath = `projects/${args.instance}/branches/${branchId}/endpoints/${endpointName}`;
80849
80849
  if (args.output === "dsn") {
80850
80850
  const host2 = await resolveEndpointHost(args.instance, branchId);
80851
- const { token, email: email2 } = await mintCredential(endpointPath);
80852
- const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token });
80851
+ const { token: token2, email: email2 } = await mintCredential(endpointPath);
80852
+ const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token2 });
80853
80853
  return { url, host: host2, port: POSTGRES_PORT, database, user: email2, endpointPath };
80854
80854
  }
80855
80855
  const host = await resolveEndpointHost(args.instance, branchId);
80856
- const email = await resolveCurrentUser();
80857
80856
  process.env.PGAPPNAME = connectionApplicationName();
80858
- return createLakebasePool({
80859
- endpoint: endpointPath,
80860
- host,
80861
- database,
80862
- user: email,
80863
- // workspaceClient is passed through verbatim. createLakebasePool falls
80864
- // back to environment / ServiceContext when omitted.
80865
- ...args.workspaceClient !== void 0 ? { workspaceClient: args.workspaceClient } : {}
80866
- });
80857
+ if (args.workspaceClient !== void 0) {
80858
+ const email2 = await resolveCurrentUser();
80859
+ return createLakebasePool({
80860
+ endpoint: endpointPath,
80861
+ host,
80862
+ database,
80863
+ user: email2,
80864
+ workspaceClient: args.workspaceClient
80865
+ });
80866
+ }
80867
+ const { token, email } = await mintCredential(endpointPath);
80868
+ return createLakebasePool({ host, database, user: email, password: token });
80867
80869
  }
80868
80870
  async function resolveEndpointHost(instance, branch) {
80869
80871
  const branchId = await resolveBranchId({ instance, branch });
@@ -1959,8 +1959,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
1959
1959
  var cached;
1960
1960
  function substrateSelfVersion() {
1961
1961
  if (cached !== void 0) return cached;
1962
- if ("0.3.9".length > 0) {
1963
- cached = "0.3.9";
1962
+ if ("0.3.11".length > 0) {
1963
+ cached = "0.3.11";
1964
1964
  return cached;
1965
1965
  }
1966
1966
  cached = "unknown";
@@ -2007,22 +2007,24 @@ async function getConnection(args) {
2007
2007
  const endpointPath = `projects/${args.instance}/branches/${branchId}/endpoints/${endpointName}`;
2008
2008
  if (args.output === "dsn") {
2009
2009
  const host2 = await resolveEndpointHost(args.instance, branchId);
2010
- const { token, email: email2 } = await mintCredential(endpointPath);
2011
- const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token });
2010
+ const { token: token2, email: email2 } = await mintCredential(endpointPath);
2011
+ const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token2 });
2012
2012
  return { url, host: host2, port: POSTGRES_PORT, database, user: email2, endpointPath };
2013
2013
  }
2014
2014
  const host = await resolveEndpointHost(args.instance, branchId);
2015
- const email = await resolveCurrentUser();
2016
2015
  process.env.PGAPPNAME = connectionApplicationName();
2017
- return createLakebasePool({
2018
- endpoint: endpointPath,
2019
- host,
2020
- database,
2021
- user: email,
2022
- // workspaceClient is passed through verbatim. createLakebasePool falls
2023
- // back to environment / ServiceContext when omitted.
2024
- ...args.workspaceClient !== void 0 ? { workspaceClient: args.workspaceClient } : {}
2025
- });
2016
+ if (args.workspaceClient !== void 0) {
2017
+ const email2 = await resolveCurrentUser();
2018
+ return createLakebasePool({
2019
+ endpoint: endpointPath,
2020
+ host,
2021
+ database,
2022
+ user: email2,
2023
+ workspaceClient: args.workspaceClient
2024
+ });
2025
+ }
2026
+ const { token, email } = await mintCredential(endpointPath);
2027
+ return createLakebasePool({ host, database, user: email, password: token });
2026
2028
  }
2027
2029
  async function resolveEndpointHost(instance, branch) {
2028
2030
  const branchId = await resolveBranchId({ instance, branch });
@@ -79285,8 +79285,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79285
79285
  var cached;
79286
79286
  function substrateSelfVersion() {
79287
79287
  if (cached !== void 0) return cached;
79288
- if ("0.3.9".length > 0) {
79289
- cached = "0.3.9";
79288
+ if ("0.3.11".length > 0) {
79289
+ cached = "0.3.11";
79290
79290
  return cached;
79291
79291
  }
79292
79292
  cached = "unknown";
@@ -79333,22 +79333,24 @@ async function getConnection(args) {
79333
79333
  const endpointPath = `projects/${args.instance}/branches/${branchId}/endpoints/${endpointName}`;
79334
79334
  if (args.output === "dsn") {
79335
79335
  const host2 = await resolveEndpointHost(args.instance, branchId);
79336
- const { token, email: email2 } = await mintCredential(endpointPath);
79337
- const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token });
79336
+ const { token: token2, email: email2 } = await mintCredential(endpointPath);
79337
+ const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token2 });
79338
79338
  return { url, host: host2, port: POSTGRES_PORT, database, user: email2, endpointPath };
79339
79339
  }
79340
79340
  const host = await resolveEndpointHost(args.instance, branchId);
79341
- const email = await resolveCurrentUser();
79342
79341
  process.env.PGAPPNAME = connectionApplicationName();
79343
- return createLakebasePool({
79344
- endpoint: endpointPath,
79345
- host,
79346
- database,
79347
- user: email,
79348
- // workspaceClient is passed through verbatim. createLakebasePool falls
79349
- // back to environment / ServiceContext when omitted.
79350
- ...args.workspaceClient !== void 0 ? { workspaceClient: args.workspaceClient } : {}
79351
- });
79342
+ if (args.workspaceClient !== void 0) {
79343
+ const email2 = await resolveCurrentUser();
79344
+ return createLakebasePool({
79345
+ endpoint: endpointPath,
79346
+ host,
79347
+ database,
79348
+ user: email2,
79349
+ workspaceClient: args.workspaceClient
79350
+ });
79351
+ }
79352
+ const { token, email } = await mintCredential(endpointPath);
79353
+ return createLakebasePool({ host, database, user: email, password: token });
79352
79354
  }
79353
79355
  async function resolveEndpointHost(instance, branch) {
79354
79356
  const branchId = await resolveBranchId({ instance, branch });
@@ -389,8 +389,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
389
389
  var cached;
390
390
  function substrateSelfVersion() {
391
391
  if (cached !== void 0) return cached;
392
- if ("0.3.9".length > 0) {
393
- cached = "0.3.9";
392
+ if ("0.3.11".length > 0) {
393
+ cached = "0.3.11";
394
394
  return cached;
395
395
  }
396
396
  cached = "unknown";
@@ -437,22 +437,24 @@ async function getConnection(args) {
437
437
  const endpointPath = `projects/${args.instance}/branches/${branchId}/endpoints/${endpointName}`;
438
438
  if (args.output === "dsn") {
439
439
  const host2 = await resolveEndpointHost(args.instance, branchId);
440
- const { token, email: email2 } = await mintCredential(endpointPath);
441
- const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token });
440
+ const { token: token2, email: email2 } = await mintCredential(endpointPath);
441
+ const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token2 });
442
442
  return { url, host: host2, port: POSTGRES_PORT, database, user: email2, endpointPath };
443
443
  }
444
444
  const host = await resolveEndpointHost(args.instance, branchId);
445
- const email = await resolveCurrentUser();
446
445
  process.env.PGAPPNAME = connectionApplicationName();
447
- return createLakebasePool({
448
- endpoint: endpointPath,
449
- host,
450
- database,
451
- user: email,
452
- // workspaceClient is passed through verbatim. createLakebasePool falls
453
- // back to environment / ServiceContext when omitted.
454
- ...args.workspaceClient !== void 0 ? { workspaceClient: args.workspaceClient } : {}
455
- });
446
+ if (args.workspaceClient !== void 0) {
447
+ const email2 = await resolveCurrentUser();
448
+ return createLakebasePool({
449
+ endpoint: endpointPath,
450
+ host,
451
+ database,
452
+ user: email2,
453
+ workspaceClient: args.workspaceClient
454
+ });
455
+ }
456
+ const { token, email } = await mintCredential(endpointPath);
457
+ return createLakebasePool({ host, database, user: email, password: token });
456
458
  }
457
459
  async function resolveEndpointHost(instance, branch) {
458
460
  const branchId = await resolveBranchId({ instance, branch });