@databricks-solutions/lakebase-scm-utils 0.3.8 → 0.3.10
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/scripts/index.cjs +59 -24
- package/dist/scripts/index.js +59 -24
- package/dist/scripts/lakebase/branch.cli.cjs +55 -10
- package/dist/scripts/lakebase/branch.cli.js +55 -10
- package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +59 -24
- package/dist/scripts/lakebase/ci-resolve-branch.cli.js +59 -24
- package/dist/scripts/lakebase/collapse-heads.cli.cjs +16 -14
- package/dist/scripts/lakebase/collapse-heads.cli.js +16 -14
- package/dist/scripts/lakebase/cut-backup.cli.cjs +43 -10
- package/dist/scripts/lakebase/cut-backup.cli.js +43 -10
- package/dist/scripts/lakebase/cut-tier.cli.cjs +43 -10
- package/dist/scripts/lakebase/cut-tier.cli.js +43 -10
- package/dist/scripts/lakebase/detect-language.cli.cjs +16 -14
- package/dist/scripts/lakebase/detect-language.cli.js +16 -14
- package/dist/scripts/lakebase/doctor.cli.cjs +16 -14
- package/dist/scripts/lakebase/doctor.cli.js +16 -14
- package/dist/scripts/lakebase/get-connection.cli.cjs +16 -14
- package/dist/scripts/lakebase/get-connection.cli.js +16 -14
- package/dist/scripts/lakebase/index.cjs +59 -24
- package/dist/scripts/lakebase/index.d.cts +23 -0
- package/dist/scripts/lakebase/index.d.ts +23 -0
- package/dist/scripts/lakebase/index.js +59 -24
- package/dist/scripts/lakebase/infra-runner.cli.cjs +16 -14
- package/dist/scripts/lakebase/infra-runner.cli.js +16 -14
- package/dist/scripts/lakebase/new-migration.cli.cjs +16 -14
- package/dist/scripts/lakebase/new-migration.cli.js +16 -14
- package/dist/scripts/lakebase/schema-diff.cli.cjs +16 -14
- package/dist/scripts/lakebase/schema-diff.cli.js +16 -14
- package/dist/scripts/lakebase/schema-migrate.cli.cjs +16 -14
- package/dist/scripts/lakebase/schema-migrate.cli.js +16 -14
- package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +59 -24
- package/dist/scripts/lakebase/scm-claim-feature.cli.js +59 -24
- package/dist/scripts/lakebase/scm-doctor.cli.cjs +59 -24
- package/dist/scripts/lakebase/scm-doctor.cli.js +59 -24
- package/dist/scripts/lakebase/scm-merge.cli.cjs +16 -14
- package/dist/scripts/lakebase/scm-merge.cli.js +16 -14
- package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +16 -14
- package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +16 -14
- package/dist/scripts/lakebase/scm-recover-orphans.cli.cjs +43 -10
- package/dist/scripts/lakebase/scm-recover-orphans.cli.js +43 -10
- package/dist/scripts/lakebase/snapshot.cli.cjs +418 -0
- package/dist/scripts/lakebase/snapshot.cli.d.cts +1 -0
- package/dist/scripts/lakebase/snapshot.cli.d.ts +1 -0
- package/dist/scripts/lakebase/snapshot.cli.js +395 -0
- package/dist/scripts/util/index.cjs +2 -2
- package/dist/scripts/util/index.js +2 -2
- package/package.json +2 -1
- package/scripts/lakebase/branch-create.ts +93 -14
- package/scripts/lakebase/branch.cli.ts +15 -0
- package/scripts/lakebase/get-connection.ts +29 -12
- package/scripts/lakebase/snapshot.cli.ts +117 -0
- package/scripts/lakebase/snapshot.ts +85 -0
- package/templates/project/common/scripts/run-tests.sh +43 -2
- package/templates/project/common/tests/e2e/conftest.py +5 -1
- package/templates/project/python/tests/conftest.py +60 -4
- package/templates/project/python/tests/__pycache__/conftest.cpython-314.pyc +0 -0
|
@@ -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.
|
|
1963
|
-
cached = "0.3.
|
|
1962
|
+
if ("0.3.10".length > 0) {
|
|
1963
|
+
cached = "0.3.10";
|
|
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:
|
|
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
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
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.
|
|
79289
|
-
cached = "0.3.
|
|
79288
|
+
if ("0.3.10".length > 0) {
|
|
79289
|
+
cached = "0.3.10";
|
|
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:
|
|
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
|
-
|
|
79344
|
-
|
|
79345
|
-
|
|
79346
|
-
|
|
79347
|
-
|
|
79348
|
-
|
|
79349
|
-
|
|
79350
|
-
|
|
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.
|
|
393
|
-
cached = "0.3.
|
|
392
|
+
if ("0.3.10".length > 0) {
|
|
393
|
+
cached = "0.3.10";
|
|
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:
|
|
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
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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 });
|
|
@@ -80008,9 +80008,46 @@ function dbcli2(args, host, timeout = KIT_TIMEOUTS.cliDefault) {
|
|
|
80008
80008
|
}
|
|
80009
80009
|
|
|
80010
80010
|
// scripts/lakebase/branch-create.ts
|
|
80011
|
+
function snapshotPath(instance, snapshot) {
|
|
80012
|
+
return snapshot.includes("/") ? snapshot : `${projectPath(instance)}/snapshots/${snapshot}`;
|
|
80013
|
+
}
|
|
80014
|
+
function applyExpiration(spec, ttl, noExpiry) {
|
|
80015
|
+
if (ttl && noExpiry === true) {
|
|
80016
|
+
throw new LakebaseBranchError(
|
|
80017
|
+
`Cannot set both ttl ("${ttl}") and noExpiry: true on the same branch \u2013 they are mutually exclusive. Pass one or the other.`
|
|
80018
|
+
);
|
|
80019
|
+
}
|
|
80020
|
+
if (ttl) spec.ttl = ttl;
|
|
80021
|
+
else if (noExpiry ?? true) spec.no_expiry = true;
|
|
80022
|
+
}
|
|
80011
80023
|
async function createBranch(args) {
|
|
80012
80024
|
const sanitized = sanitizeBranchName(args.branch);
|
|
80013
80025
|
const lookup = { instance: args.instance, host: args.host };
|
|
80026
|
+
if (args.fromSnapshot) {
|
|
80027
|
+
if (args.parentBranch || args.sourceBranchTime || args.sourceBranchLsn) {
|
|
80028
|
+
throw new LakebaseBranchError(
|
|
80029
|
+
`fromSnapshot is mutually exclusive with parentBranch / sourceBranchTime / sourceBranchLsn (the Lakebase API rejects source_snapshot combined with any source_branch field).`
|
|
80030
|
+
);
|
|
80031
|
+
}
|
|
80032
|
+
const existing2 = await getBranchByName(sanitized, lookup);
|
|
80033
|
+
if (existing2) return existing2;
|
|
80034
|
+
const spec = { source_snapshot: snapshotPath(args.instance, args.fromSnapshot) };
|
|
80035
|
+
applyExpiration(spec, args.ttl, args.noExpiry);
|
|
80036
|
+
try {
|
|
80037
|
+
await createWithTtlRecovery(args.instance, sanitized, spec, args.host);
|
|
80038
|
+
} catch (err) {
|
|
80039
|
+
if (err instanceof LakebaseBranchTtlTooLongError) throw err;
|
|
80040
|
+
const landed = await getBranchByName(sanitized, lookup);
|
|
80041
|
+
if (!landed) throw err;
|
|
80042
|
+
}
|
|
80043
|
+
return waitForBranchReady({
|
|
80044
|
+
instance: args.instance,
|
|
80045
|
+
host: args.host,
|
|
80046
|
+
branch: sanitized,
|
|
80047
|
+
timeoutMs: args.readyTimeoutMs ?? KIT_TIMEOUTS.readyWait,
|
|
80048
|
+
pollIntervalMs: args.pollIntervalMs ?? KIT_TIMEOUTS.readyPoll
|
|
80049
|
+
});
|
|
80050
|
+
}
|
|
80014
80051
|
let sourceBranchPath;
|
|
80015
80052
|
if (args.parentBranch) {
|
|
80016
80053
|
if (looksLikeBranchUid(args.parentBranch)) {
|
|
@@ -80058,19 +80095,15 @@ async function createBranch(args) {
|
|
|
80058
80095
|
assertSourceMatches(existing, sourceBranchPath, sanitized);
|
|
80059
80096
|
return existing;
|
|
80060
80097
|
}
|
|
80061
|
-
if (args.
|
|
80098
|
+
if (args.sourceBranchTime && args.sourceBranchLsn) {
|
|
80062
80099
|
throw new LakebaseBranchError(
|
|
80063
|
-
`
|
|
80100
|
+
`sourceBranchTime and sourceBranchLsn are mutually exclusive \u2013 pass at most one point-in-time.`
|
|
80064
80101
|
);
|
|
80065
80102
|
}
|
|
80066
|
-
const specObj = {
|
|
80067
|
-
|
|
80068
|
-
|
|
80069
|
-
|
|
80070
|
-
specObj.ttl = args.ttl;
|
|
80071
|
-
} else if (args.noExpiry ?? true) {
|
|
80072
|
-
specObj.no_expiry = true;
|
|
80073
|
-
}
|
|
80103
|
+
const specObj = { source_branch: sourceBranchPath };
|
|
80104
|
+
if (args.sourceBranchTime) specObj.source_branch_time = args.sourceBranchTime;
|
|
80105
|
+
else if (args.sourceBranchLsn) specObj.source_branch_lsn = args.sourceBranchLsn;
|
|
80106
|
+
applyExpiration(specObj, args.ttl, args.noExpiry);
|
|
80074
80107
|
try {
|
|
80075
80108
|
await createWithTtlRecovery(args.instance, sanitized, specObj, args.host);
|
|
80076
80109
|
} catch (err) {
|
|
@@ -81607,8 +81640,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
|
|
|
81607
81640
|
var cached;
|
|
81608
81641
|
function substrateSelfVersion() {
|
|
81609
81642
|
if (cached !== void 0) return cached;
|
|
81610
|
-
if ("0.3.
|
|
81611
|
-
cached = "0.3.
|
|
81643
|
+
if ("0.3.10".length > 0) {
|
|
81644
|
+
cached = "0.3.10";
|
|
81612
81645
|
return cached;
|
|
81613
81646
|
}
|
|
81614
81647
|
cached = "unknown";
|
|
@@ -81655,22 +81688,24 @@ async function getConnection(args) {
|
|
|
81655
81688
|
const endpointPath2 = `projects/${args.instance}/branches/${branchId}/endpoints/${endpointName}`;
|
|
81656
81689
|
if (args.output === "dsn") {
|
|
81657
81690
|
const host2 = await resolveEndpointHost(args.instance, branchId);
|
|
81658
|
-
const { token, email: email2 } = await mintCredential(endpointPath2);
|
|
81659
|
-
const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password:
|
|
81691
|
+
const { token: token2, email: email2 } = await mintCredential(endpointPath2);
|
|
81692
|
+
const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token2 });
|
|
81660
81693
|
return { url, host: host2, port: POSTGRES_PORT, database, user: email2, endpointPath: endpointPath2 };
|
|
81661
81694
|
}
|
|
81662
81695
|
const host = await resolveEndpointHost(args.instance, branchId);
|
|
81663
|
-
const email = await resolveCurrentUser();
|
|
81664
81696
|
process.env.PGAPPNAME = connectionApplicationName();
|
|
81665
|
-
|
|
81666
|
-
|
|
81667
|
-
|
|
81668
|
-
|
|
81669
|
-
|
|
81670
|
-
|
|
81671
|
-
|
|
81672
|
-
|
|
81673
|
-
|
|
81697
|
+
if (args.workspaceClient !== void 0) {
|
|
81698
|
+
const email2 = await resolveCurrentUser();
|
|
81699
|
+
return createLakebasePool({
|
|
81700
|
+
endpoint: endpointPath2,
|
|
81701
|
+
host,
|
|
81702
|
+
database,
|
|
81703
|
+
user: email2,
|
|
81704
|
+
workspaceClient: args.workspaceClient
|
|
81705
|
+
});
|
|
81706
|
+
}
|
|
81707
|
+
const { token, email } = await mintCredential(endpointPath2);
|
|
81708
|
+
return createLakebasePool({ host, database, user: email, password: token });
|
|
81674
81709
|
}
|
|
81675
81710
|
async function resolveEndpointHost(instance, branch) {
|
|
81676
81711
|
const branchId = await resolveBranchId({ instance, branch });
|
|
@@ -287,6 +287,29 @@ interface CreateBranchArgs extends BranchLookupOpts {
|
|
|
287
287
|
* caller's expectation. Default: false (fallback enabled).
|
|
288
288
|
*/
|
|
289
289
|
strictParent?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Branch from an immutable SNAPSHOT instead of a source branch (the kit's
|
|
292
|
+
* fast verify-branch provisioning: snapshot the committed schema once, then
|
|
293
|
+
* branch copy-on-write from it per cycle — no `alembic upgrade head` rebuild,
|
|
294
|
+
* and a FIXED point so the fork never goes stale). Accepts a bare snapshot id
|
|
295
|
+
* or a full `projects/<p>/snapshots/<id>` path. Maps to `spec.source_snapshot`,
|
|
296
|
+
* which the Lakebase API treats as mutually exclusive with source_branch /
|
|
297
|
+
* source_branch_time / source_branch_lsn — so when set, the parentBranch
|
|
298
|
+
* resolution below is skipped entirely.
|
|
299
|
+
*/
|
|
300
|
+
fromSnapshot?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Point-in-time for a branch-from-branch create: an ISO-8601 timestamp.
|
|
303
|
+
* Maps to `spec.source_branch_time` — branch the source branch AS OF this
|
|
304
|
+
* time (PITR). Mutually exclusive with sourceBranchLsn and with fromSnapshot.
|
|
305
|
+
*/
|
|
306
|
+
sourceBranchTime?: string;
|
|
307
|
+
/**
|
|
308
|
+
* Point-in-time for a branch-from-branch create: an LSN (e.g. "0/16B3748").
|
|
309
|
+
* Maps to `spec.source_branch_lsn`. Mutually exclusive with sourceBranchTime
|
|
310
|
+
* and with fromSnapshot.
|
|
311
|
+
*/
|
|
312
|
+
sourceBranchLsn?: string;
|
|
290
313
|
}
|
|
291
314
|
/**
|
|
292
315
|
* Create a Lakebase branch.
|
|
@@ -287,6 +287,29 @@ interface CreateBranchArgs extends BranchLookupOpts {
|
|
|
287
287
|
* caller's expectation. Default: false (fallback enabled).
|
|
288
288
|
*/
|
|
289
289
|
strictParent?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Branch from an immutable SNAPSHOT instead of a source branch (the kit's
|
|
292
|
+
* fast verify-branch provisioning: snapshot the committed schema once, then
|
|
293
|
+
* branch copy-on-write from it per cycle — no `alembic upgrade head` rebuild,
|
|
294
|
+
* and a FIXED point so the fork never goes stale). Accepts a bare snapshot id
|
|
295
|
+
* or a full `projects/<p>/snapshots/<id>` path. Maps to `spec.source_snapshot`,
|
|
296
|
+
* which the Lakebase API treats as mutually exclusive with source_branch /
|
|
297
|
+
* source_branch_time / source_branch_lsn — so when set, the parentBranch
|
|
298
|
+
* resolution below is skipped entirely.
|
|
299
|
+
*/
|
|
300
|
+
fromSnapshot?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Point-in-time for a branch-from-branch create: an ISO-8601 timestamp.
|
|
303
|
+
* Maps to `spec.source_branch_time` — branch the source branch AS OF this
|
|
304
|
+
* time (PITR). Mutually exclusive with sourceBranchLsn and with fromSnapshot.
|
|
305
|
+
*/
|
|
306
|
+
sourceBranchTime?: string;
|
|
307
|
+
/**
|
|
308
|
+
* Point-in-time for a branch-from-branch create: an LSN (e.g. "0/16B3748").
|
|
309
|
+
* Maps to `spec.source_branch_lsn`. Mutually exclusive with sourceBranchTime
|
|
310
|
+
* and with fromSnapshot.
|
|
311
|
+
*/
|
|
312
|
+
sourceBranchLsn?: string;
|
|
290
313
|
}
|
|
291
314
|
/**
|
|
292
315
|
* Create a Lakebase branch.
|
|
@@ -2291,9 +2291,46 @@ function dbcli2(args, host, timeout = KIT_TIMEOUTS.cliDefault) {
|
|
|
2291
2291
|
}
|
|
2292
2292
|
|
|
2293
2293
|
// scripts/lakebase/branch-create.ts
|
|
2294
|
+
function snapshotPath(instance, snapshot) {
|
|
2295
|
+
return snapshot.includes("/") ? snapshot : `${projectPath(instance)}/snapshots/${snapshot}`;
|
|
2296
|
+
}
|
|
2297
|
+
function applyExpiration(spec, ttl, noExpiry) {
|
|
2298
|
+
if (ttl && noExpiry === true) {
|
|
2299
|
+
throw new LakebaseBranchError(
|
|
2300
|
+
`Cannot set both ttl ("${ttl}") and noExpiry: true on the same branch \u2013 they are mutually exclusive. Pass one or the other.`
|
|
2301
|
+
);
|
|
2302
|
+
}
|
|
2303
|
+
if (ttl) spec.ttl = ttl;
|
|
2304
|
+
else if (noExpiry ?? true) spec.no_expiry = true;
|
|
2305
|
+
}
|
|
2294
2306
|
async function createBranch(args) {
|
|
2295
2307
|
const sanitized = sanitizeBranchName(args.branch);
|
|
2296
2308
|
const lookup = { instance: args.instance, host: args.host };
|
|
2309
|
+
if (args.fromSnapshot) {
|
|
2310
|
+
if (args.parentBranch || args.sourceBranchTime || args.sourceBranchLsn) {
|
|
2311
|
+
throw new LakebaseBranchError(
|
|
2312
|
+
`fromSnapshot is mutually exclusive with parentBranch / sourceBranchTime / sourceBranchLsn (the Lakebase API rejects source_snapshot combined with any source_branch field).`
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
const existing2 = await getBranchByName(sanitized, lookup);
|
|
2316
|
+
if (existing2) return existing2;
|
|
2317
|
+
const spec = { source_snapshot: snapshotPath(args.instance, args.fromSnapshot) };
|
|
2318
|
+
applyExpiration(spec, args.ttl, args.noExpiry);
|
|
2319
|
+
try {
|
|
2320
|
+
await createWithTtlRecovery(args.instance, sanitized, spec, args.host);
|
|
2321
|
+
} catch (err) {
|
|
2322
|
+
if (err instanceof LakebaseBranchTtlTooLongError) throw err;
|
|
2323
|
+
const landed = await getBranchByName(sanitized, lookup);
|
|
2324
|
+
if (!landed) throw err;
|
|
2325
|
+
}
|
|
2326
|
+
return waitForBranchReady({
|
|
2327
|
+
instance: args.instance,
|
|
2328
|
+
host: args.host,
|
|
2329
|
+
branch: sanitized,
|
|
2330
|
+
timeoutMs: args.readyTimeoutMs ?? KIT_TIMEOUTS.readyWait,
|
|
2331
|
+
pollIntervalMs: args.pollIntervalMs ?? KIT_TIMEOUTS.readyPoll
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2297
2334
|
let sourceBranchPath;
|
|
2298
2335
|
if (args.parentBranch) {
|
|
2299
2336
|
if (looksLikeBranchUid(args.parentBranch)) {
|
|
@@ -2341,19 +2378,15 @@ async function createBranch(args) {
|
|
|
2341
2378
|
assertSourceMatches(existing, sourceBranchPath, sanitized);
|
|
2342
2379
|
return existing;
|
|
2343
2380
|
}
|
|
2344
|
-
if (args.
|
|
2381
|
+
if (args.sourceBranchTime && args.sourceBranchLsn) {
|
|
2345
2382
|
throw new LakebaseBranchError(
|
|
2346
|
-
`
|
|
2383
|
+
`sourceBranchTime and sourceBranchLsn are mutually exclusive \u2013 pass at most one point-in-time.`
|
|
2347
2384
|
);
|
|
2348
2385
|
}
|
|
2349
|
-
const specObj = {
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
specObj.ttl = args.ttl;
|
|
2354
|
-
} else if (args.noExpiry ?? true) {
|
|
2355
|
-
specObj.no_expiry = true;
|
|
2356
|
-
}
|
|
2386
|
+
const specObj = { source_branch: sourceBranchPath };
|
|
2387
|
+
if (args.sourceBranchTime) specObj.source_branch_time = args.sourceBranchTime;
|
|
2388
|
+
else if (args.sourceBranchLsn) specObj.source_branch_lsn = args.sourceBranchLsn;
|
|
2389
|
+
applyExpiration(specObj, args.ttl, args.noExpiry);
|
|
2357
2390
|
try {
|
|
2358
2391
|
await createWithTtlRecovery(args.instance, sanitized, specObj, args.host);
|
|
2359
2392
|
} catch (err) {
|
|
@@ -2521,8 +2554,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
|
|
|
2521
2554
|
var cached;
|
|
2522
2555
|
function substrateSelfVersion() {
|
|
2523
2556
|
if (cached !== void 0) return cached;
|
|
2524
|
-
if ("0.3.
|
|
2525
|
-
cached = "0.3.
|
|
2557
|
+
if ("0.3.10".length > 0) {
|
|
2558
|
+
cached = "0.3.10";
|
|
2526
2559
|
return cached;
|
|
2527
2560
|
}
|
|
2528
2561
|
cached = "unknown";
|
|
@@ -2569,22 +2602,24 @@ async function getConnection(args) {
|
|
|
2569
2602
|
const endpointPath2 = `projects/${args.instance}/branches/${branchId}/endpoints/${endpointName}`;
|
|
2570
2603
|
if (args.output === "dsn") {
|
|
2571
2604
|
const host2 = await resolveEndpointHost(args.instance, branchId);
|
|
2572
|
-
const { token, email: email2 } = await mintCredential(endpointPath2);
|
|
2573
|
-
const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password:
|
|
2605
|
+
const { token: token2, email: email2 } = await mintCredential(endpointPath2);
|
|
2606
|
+
const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password: token2 });
|
|
2574
2607
|
return { url, host: host2, port: POSTGRES_PORT, database, user: email2, endpointPath: endpointPath2 };
|
|
2575
2608
|
}
|
|
2576
2609
|
const host = await resolveEndpointHost(args.instance, branchId);
|
|
2577
|
-
const email = await resolveCurrentUser();
|
|
2578
2610
|
process.env.PGAPPNAME = connectionApplicationName();
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2611
|
+
if (args.workspaceClient !== void 0) {
|
|
2612
|
+
const email2 = await resolveCurrentUser();
|
|
2613
|
+
return createLakebasePool({
|
|
2614
|
+
endpoint: endpointPath2,
|
|
2615
|
+
host,
|
|
2616
|
+
database,
|
|
2617
|
+
user: email2,
|
|
2618
|
+
workspaceClient: args.workspaceClient
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
const { token, email } = await mintCredential(endpointPath2);
|
|
2622
|
+
return createLakebasePool({ host, database, user: email, password: token });
|
|
2588
2623
|
}
|
|
2589
2624
|
async function resolveEndpointHost(instance, branch) {
|
|
2590
2625
|
const branchId = await resolveBranchId({ instance, branch });
|
|
@@ -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.
|
|
79294
|
-
cached = "0.3.
|
|
79293
|
+
if ("0.3.10".length > 0) {
|
|
79294
|
+
cached = "0.3.10";
|
|
79295
79295
|
return cached;
|
|
79296
79296
|
}
|
|
79297
79297
|
cached = "unknown";
|
|
@@ -79338,22 +79338,24 @@ async function getConnection(args) {
|
|
|
79338
79338
|
const endpointPath2 = `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(endpointPath2);
|
|
79342
|
-
const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password:
|
|
79341
|
+
const { token: token2, email: email2 } = await mintCredential(endpointPath2);
|
|
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: endpointPath2 };
|
|
79344
79344
|
}
|
|
79345
79345
|
const host = await resolveEndpointHost(args.instance, branchId);
|
|
79346
|
-
const email = await resolveCurrentUser();
|
|
79347
79346
|
process.env.PGAPPNAME = connectionApplicationName();
|
|
79348
|
-
|
|
79349
|
-
|
|
79350
|
-
|
|
79351
|
-
|
|
79352
|
-
|
|
79353
|
-
|
|
79354
|
-
|
|
79355
|
-
|
|
79356
|
-
|
|
79347
|
+
if (args.workspaceClient !== void 0) {
|
|
79348
|
+
const email2 = await resolveCurrentUser();
|
|
79349
|
+
return createLakebasePool({
|
|
79350
|
+
endpoint: endpointPath2,
|
|
79351
|
+
host,
|
|
79352
|
+
database,
|
|
79353
|
+
user: email2,
|
|
79354
|
+
workspaceClient: args.workspaceClient
|
|
79355
|
+
});
|
|
79356
|
+
}
|
|
79357
|
+
const { token, email } = await mintCredential(endpointPath2);
|
|
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.
|
|
397
|
-
cached = "0.3.
|
|
396
|
+
if ("0.3.10".length > 0) {
|
|
397
|
+
cached = "0.3.10";
|
|
398
398
|
return cached;
|
|
399
399
|
}
|
|
400
400
|
cached = "unknown";
|
|
@@ -441,22 +441,24 @@ async function getConnection(args) {
|
|
|
441
441
|
const endpointPath2 = `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(endpointPath2);
|
|
445
|
-
const url = buildPostgresUrl({ host: host2, port: POSTGRES_PORT, database, user: email2, password:
|
|
444
|
+
const { token: token2, email: email2 } = await mintCredential(endpointPath2);
|
|
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: endpointPath2 };
|
|
447
447
|
}
|
|
448
448
|
const host = await resolveEndpointHost(args.instance, branchId);
|
|
449
|
-
const email = await resolveCurrentUser();
|
|
450
449
|
process.env.PGAPPNAME = connectionApplicationName();
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
450
|
+
if (args.workspaceClient !== void 0) {
|
|
451
|
+
const email2 = await resolveCurrentUser();
|
|
452
|
+
return createLakebasePool({
|
|
453
|
+
endpoint: endpointPath2,
|
|
454
|
+
host,
|
|
455
|
+
database,
|
|
456
|
+
user: email2,
|
|
457
|
+
workspaceClient: args.workspaceClient
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
const { token, email } = await mintCredential(endpointPath2);
|
|
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 });
|
|
@@ -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.
|
|
79294
|
-
cached = "0.3.
|
|
79293
|
+
if ("0.3.10".length > 0) {
|
|
79294
|
+
cached = "0.3.10";
|
|
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:
|
|
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
|
-
|
|
79349
|
-
|
|
79350
|
-
|
|
79351
|
-
|
|
79352
|
-
|
|
79353
|
-
|
|
79354
|
-
|
|
79355
|
-
|
|
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.
|
|
397
|
-
cached = "0.3.
|
|
396
|
+
if ("0.3.10".length > 0) {
|
|
397
|
+
cached = "0.3.10";
|
|
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:
|
|
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
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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 });
|