prisma 8.0.0-rc.28 → 8.0.0-rc.28-dev.173
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/prisma.js +558 -177
- package/package.json +6 -6
- package/skills/prisma-platform-core-concepts/SKILL.md +1 -1
package/dist/prisma.js
CHANGED
|
@@ -3957,46 +3957,34 @@ async function promptForSession(stored, select) {
|
|
|
3957
3957
|
return requireSession(stored.sessions, workspaceId);
|
|
3958
3958
|
}
|
|
3959
3959
|
//#endregion
|
|
3960
|
-
//#region ../cli/src/
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
const rightRank = branchOrder(right);
|
|
3965
|
-
if (leftRank !== rightRank) return leftRank - rightRank;
|
|
3966
|
-
return left.name.localeCompare(right.name);
|
|
3967
|
-
});
|
|
3968
|
-
}
|
|
3969
|
-
function branchOrder(branch) {
|
|
3970
|
-
return branch.role === "production" ? 0 : 1;
|
|
3971
|
-
}
|
|
3972
|
-
async function listBranches$1(client, projectId, signal) {
|
|
3960
|
+
//#region ../cli/src/lib/branch/list.ts
|
|
3961
|
+
/** Every live Branch of a Project, following the cursor through each
|
|
3962
|
+
* page. `gitName` asks the API for the one Branch with that git name. */
|
|
3963
|
+
async function listProjectBranches(client, options) {
|
|
3973
3964
|
const collected = [];
|
|
3974
3965
|
let cursor;
|
|
3975
|
-
|
|
3976
|
-
const query = {};
|
|
3977
|
-
if (cursor !== void 0) query.cursor = cursor;
|
|
3966
|
+
do {
|
|
3978
3967
|
const { data, error, response } = await client.GET("/v1/projects/{projectId}/branches", {
|
|
3979
3968
|
params: {
|
|
3980
|
-
path: { projectId },
|
|
3981
|
-
query
|
|
3969
|
+
path: { projectId: options.projectId },
|
|
3970
|
+
query: {
|
|
3971
|
+
...options.gitName !== void 0 ? { gitName: options.gitName } : {},
|
|
3972
|
+
...cursor !== void 0 ? { cursor } : {}
|
|
3973
|
+
}
|
|
3982
3974
|
},
|
|
3983
|
-
signal
|
|
3975
|
+
signal: options.signal
|
|
3984
3976
|
});
|
|
3985
3977
|
if (error || !data) throw branchApiError("Failed to list branches", response, error);
|
|
3986
|
-
collected.push(...data.data)
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3978
|
+
collected.push(...data.data.map((branch) => ({
|
|
3979
|
+
id: branch.id,
|
|
3980
|
+
gitName: branch.gitName,
|
|
3981
|
+
isDefault: branch.isDefault,
|
|
3982
|
+
role: branch.role
|
|
3983
|
+
})));
|
|
3984
|
+
cursor = data.pagination.hasMore ? data.pagination.nextCursor ?? void 0 : void 0;
|
|
3985
|
+
} while (cursor);
|
|
3990
3986
|
return collected;
|
|
3991
3987
|
}
|
|
3992
|
-
function toBranchSummary(branch) {
|
|
3993
|
-
return {
|
|
3994
|
-
id: branch.id,
|
|
3995
|
-
name: branch.gitName,
|
|
3996
|
-
role: branch.role,
|
|
3997
|
-
envMap: branch.role
|
|
3998
|
-
};
|
|
3999
|
-
}
|
|
4000
3988
|
function branchApiError(summary, response, error) {
|
|
4001
3989
|
const status = response?.status ?? 0;
|
|
4002
3990
|
const apiCode = error?.error?.code;
|
|
@@ -4013,6 +4001,33 @@ function branchApiError(summary, response, error) {
|
|
|
4013
4001
|
});
|
|
4014
4002
|
}
|
|
4015
4003
|
//#endregion
|
|
4004
|
+
//#region ../cli/src/controllers/branch.ts
|
|
4005
|
+
function sortBranches(branches) {
|
|
4006
|
+
return branches.slice().sort((left, right) => {
|
|
4007
|
+
const leftRank = branchOrder(left);
|
|
4008
|
+
const rightRank = branchOrder(right);
|
|
4009
|
+
if (leftRank !== rightRank) return leftRank - rightRank;
|
|
4010
|
+
return left.name.localeCompare(right.name);
|
|
4011
|
+
});
|
|
4012
|
+
}
|
|
4013
|
+
function branchOrder(branch) {
|
|
4014
|
+
return branch.role === "production" ? 0 : 1;
|
|
4015
|
+
}
|
|
4016
|
+
async function listBranches$1(client, projectId, signal) {
|
|
4017
|
+
return await listProjectBranches(client, {
|
|
4018
|
+
projectId,
|
|
4019
|
+
signal
|
|
4020
|
+
});
|
|
4021
|
+
}
|
|
4022
|
+
function toBranchSummary(branch) {
|
|
4023
|
+
return {
|
|
4024
|
+
id: branch.id,
|
|
4025
|
+
name: branch.gitName,
|
|
4026
|
+
role: branch.role,
|
|
4027
|
+
envMap: branch.role
|
|
4028
|
+
};
|
|
4029
|
+
}
|
|
4030
|
+
//#endregion
|
|
4016
4031
|
//#region ../cli/src/lib/project/prisma-dir.ts
|
|
4017
4032
|
/**
|
|
4018
4033
|
* Walks up from cwd to the nearest directory containing a `.prisma/`
|
|
@@ -4277,7 +4292,7 @@ function createManagementProjectProvider(client) {
|
|
|
4277
4292
|
}
|
|
4278
4293
|
};
|
|
4279
4294
|
}
|
|
4280
|
-
function userChoice$
|
|
4295
|
+
function userChoice$7(label) {
|
|
4281
4296
|
return {
|
|
4282
4297
|
kind: "user-choice",
|
|
4283
4298
|
label
|
|
@@ -4286,7 +4301,7 @@ function userChoice$6(label) {
|
|
|
4286
4301
|
function projectRenameFailedError(name, error) {
|
|
4287
4302
|
return new CliStructuredError("PROJECT.RENAME_FAILED", "Project rename failed", {
|
|
4288
4303
|
why: error?.error?.message ?? `The platform rejected the name "${name}".`,
|
|
4289
|
-
nextActions: [userChoice$
|
|
4304
|
+
nextActions: [userChoice$7(error?.error?.hint ?? "Pass a different project name and retry the rename.")]
|
|
4290
4305
|
});
|
|
4291
4306
|
}
|
|
4292
4307
|
function projectDeleteBlockedError(projectId, error) {
|
|
@@ -4298,7 +4313,7 @@ function projectDeleteBlockedError(projectId, error) {
|
|
|
4298
4313
|
]);
|
|
4299
4314
|
return new CliStructuredError("PROJECT.DELETE_BLOCKED", "Project cannot be deleted yet", {
|
|
4300
4315
|
why: error?.error?.message ?? `Project "${projectId}" still has active deployments.`,
|
|
4301
|
-
nextActions: [userChoice$
|
|
4316
|
+
nextActions: [userChoice$7("Delete the project's services first, then retry the deletion."), {
|
|
4302
4317
|
kind: "run-command",
|
|
4303
4318
|
label: deleteServicesCommand,
|
|
4304
4319
|
command: deleteServicesCommand
|
|
@@ -4308,7 +4323,7 @@ function projectDeleteBlockedError(projectId, error) {
|
|
|
4308
4323
|
function projectTransferRejectedError(projectId, error) {
|
|
4309
4324
|
return new CliStructuredError("PROJECT.TRANSFER_REJECTED", "Project transfer was rejected", {
|
|
4310
4325
|
why: error?.error?.message ?? `The platform rejected the transfer of project "${projectId}", for example because the recipient token is invalid or expired.`,
|
|
4311
|
-
nextActions: [userChoice$
|
|
4326
|
+
nextActions: [userChoice$7("Check the recipient workspace session or token and retry the transfer.")]
|
|
4312
4327
|
});
|
|
4313
4328
|
}
|
|
4314
4329
|
function projectApiError(summary, response, error) {
|
|
@@ -4320,7 +4335,7 @@ function projectApiError(summary, response, error) {
|
|
|
4320
4335
|
...status ? { status } : {},
|
|
4321
4336
|
...apiCode !== void 0 ? { apiCode } : {}
|
|
4322
4337
|
} } : {},
|
|
4323
|
-
nextActions: [userChoice$
|
|
4338
|
+
nextActions: [userChoice$7(error?.error?.hint ?? "Re-run with --log-level verbose for the underlying API response details.")]
|
|
4324
4339
|
});
|
|
4325
4340
|
}
|
|
4326
4341
|
//#endregion
|
|
@@ -4410,7 +4425,7 @@ async function inspectProjectBinding(options) {
|
|
|
4410
4425
|
});
|
|
4411
4426
|
});
|
|
4412
4427
|
}
|
|
4413
|
-
function runCommand$
|
|
4428
|
+
function runCommand$6(command, reason) {
|
|
4414
4429
|
return {
|
|
4415
4430
|
kind: "run-command",
|
|
4416
4431
|
label: command,
|
|
@@ -4418,7 +4433,7 @@ function runCommand$5(command, reason) {
|
|
|
4418
4433
|
...reason === void 0 ? {} : { reason }
|
|
4419
4434
|
};
|
|
4420
4435
|
}
|
|
4421
|
-
function userChoice$
|
|
4436
|
+
function userChoice$6(label) {
|
|
4422
4437
|
return {
|
|
4423
4438
|
kind: "user-choice",
|
|
4424
4439
|
label
|
|
@@ -4430,7 +4445,7 @@ function projectNotFoundError$1(projectRef, workspace) {
|
|
|
4430
4445
|
function projectNotFoundStructuredError(projectRef, workspace) {
|
|
4431
4446
|
return new CliStructuredError("PROJECT.NOT_FOUND", "Project not found", {
|
|
4432
4447
|
why: `The project "${projectRef}" does not exist in workspace "${workspace.name}" or is not accessible.`,
|
|
4433
|
-
nextActions: [userChoice$
|
|
4448
|
+
nextActions: [userChoice$6("Pass a project id or name from prisma project list."), runCommand$6("prisma project list")]
|
|
4434
4449
|
});
|
|
4435
4450
|
}
|
|
4436
4451
|
function projectAmbiguousError(projectRef, matches) {
|
|
@@ -4438,8 +4453,8 @@ function projectAmbiguousError(projectRef, matches) {
|
|
|
4438
4453
|
}
|
|
4439
4454
|
function projectAmbiguousStructuredError(projectRef, matches) {
|
|
4440
4455
|
const firstMatch = matches[0];
|
|
4441
|
-
const nextActions = [userChoice$
|
|
4442
|
-
if (firstMatch) nextActions.push(runCommand$
|
|
4456
|
+
const nextActions = [userChoice$6("Pass --project <id-or-name> to choose the project explicitly."), runCommand$6("prisma project list")];
|
|
4457
|
+
if (firstMatch) nextActions.push(runCommand$6(`prisma project link ${firstMatch.id}`));
|
|
4443
4458
|
return new CliStructuredError("PROJECT.AMBIGUOUS", "Project resolution is ambiguous", {
|
|
4444
4459
|
why: projectRef ? `Multiple projects matched "${projectRef}".` : "Multiple projects matched the current directory context.",
|
|
4445
4460
|
meta: { matches: matches.map((project) => ({
|
|
@@ -4454,9 +4469,9 @@ function localStateStaleStructuredError() {
|
|
|
4454
4469
|
why: `The target recorded in ${LOCAL_RESOLUTION_PIN_RELATIVE_PATH} is no longer available in the selected workspace.`,
|
|
4455
4470
|
meta: { pinPath: LOCAL_RESOLUTION_PIN_RELATIVE_PATH },
|
|
4456
4471
|
nextActions: [
|
|
4457
|
-
userChoice$
|
|
4458
|
-
runCommand$
|
|
4459
|
-
runCommand$
|
|
4472
|
+
userChoice$6(`Delete ${LOCAL_RESOLUTION_PIN_RELATIVE_PATH}, then choose a Project explicitly.`),
|
|
4473
|
+
runCommand$6("prisma project list"),
|
|
4474
|
+
runCommand$6("prisma project link <id-or-name>")
|
|
4460
4475
|
]
|
|
4461
4476
|
});
|
|
4462
4477
|
}
|
|
@@ -4471,10 +4486,10 @@ function localProjectWorkspaceMismatchStructuredError(options) {
|
|
|
4471
4486
|
activeWorkspaceName: options.activeWorkspace.name
|
|
4472
4487
|
},
|
|
4473
4488
|
nextActions: [
|
|
4474
|
-
userChoice$
|
|
4475
|
-
runCommand$
|
|
4476
|
-
runCommand$
|
|
4477
|
-
runCommand$
|
|
4489
|
+
userChoice$6("Switch to the linked workspace, or relink this directory to a project in the current workspace."),
|
|
4490
|
+
runCommand$6(`prisma auth workspace use ${options.pinnedWorkspaceId}`),
|
|
4491
|
+
runCommand$6("prisma project list"),
|
|
4492
|
+
runCommand$6("prisma project link <id-or-name>")
|
|
4478
4493
|
]
|
|
4479
4494
|
});
|
|
4480
4495
|
}
|
|
@@ -4692,14 +4707,14 @@ function toProjectSummary$1(project) {
|
|
|
4692
4707
|
//#region ../cli/src/controllers/project.ts
|
|
4693
4708
|
const GITHUB_INSTALL_POLL_INTERVAL_MS = 2e3;
|
|
4694
4709
|
const GITHUB_INSTALL_POLL_TIMEOUT_MS = 12e4;
|
|
4695
|
-
function runCommand$
|
|
4710
|
+
function runCommand$5(command) {
|
|
4696
4711
|
return {
|
|
4697
4712
|
kind: "run-command",
|
|
4698
4713
|
label: command,
|
|
4699
4714
|
command
|
|
4700
4715
|
};
|
|
4701
4716
|
}
|
|
4702
|
-
function userChoice$
|
|
4717
|
+
function userChoice$5(label) {
|
|
4703
4718
|
return {
|
|
4704
4719
|
kind: "user-choice",
|
|
4705
4720
|
label
|
|
@@ -4737,13 +4752,13 @@ function transferRecipientRequiredError(formatCommand) {
|
|
|
4737
4752
|
return new CliStructuredError("PROJECT.TRANSFER_RECIPIENT_REQUIRED", "Transfer recipient required", {
|
|
4738
4753
|
why: "Project transfer needs the receiving workspace.",
|
|
4739
4754
|
nextActions: [
|
|
4740
|
-
userChoice$
|
|
4741
|
-
runCommand$
|
|
4755
|
+
userChoice$5("Pass --to-workspace <id-or-name> for a locally authenticated workspace, or --recipient-token <token> for a cross-account transfer."),
|
|
4756
|
+
runCommand$5(formatCommand([
|
|
4742
4757
|
"auth",
|
|
4743
4758
|
"workspace",
|
|
4744
4759
|
"list"
|
|
4745
4760
|
])),
|
|
4746
|
-
runCommand$
|
|
4761
|
+
runCommand$5(formatCommand([
|
|
4747
4762
|
"project",
|
|
4748
4763
|
"transfer",
|
|
4749
4764
|
"<project>",
|
|
@@ -4758,7 +4773,7 @@ function transferRecipientRequiredError(formatCommand) {
|
|
|
4758
4773
|
function transferRecipientUnavailableError(formatCommand) {
|
|
4759
4774
|
return new CliStructuredError("PROJECT.TRANSFER_RECIPIENT_UNAVAILABLE", "Local workspace sessions are unavailable", {
|
|
4760
4775
|
why: `--to-workspace resolves locally stored OAuth sessions, but ${SERVICE_TOKEN_ENV_VAR} is set and service-token mode does not read them.`,
|
|
4761
|
-
nextActions: [userChoice$
|
|
4776
|
+
nextActions: [userChoice$5("Pass --recipient-token <token> with an access token for the receiving workspace, or unset the service token."), runCommand$5(formatCommand([
|
|
4762
4777
|
"project",
|
|
4763
4778
|
"transfer",
|
|
4764
4779
|
"<project>",
|
|
@@ -4960,13 +4975,13 @@ function toRepositoryConnection(record) {
|
|
|
4960
4975
|
function unsupportedRepositoryProviderError() {
|
|
4961
4976
|
return new CliStructuredError("GIT.REPO_PROVIDER_UNSUPPORTED", "Repository provider is not supported", {
|
|
4962
4977
|
why: "Repository connection supports GitHub repository URLs only.",
|
|
4963
|
-
nextActions: [userChoice$
|
|
4978
|
+
nextActions: [userChoice$5("Pass a GitHub repository URL such as git@github.com:prisma/prisma-cli.git."), runCommand$5("prisma git connect git@github.com:owner/repo.git")]
|
|
4964
4979
|
});
|
|
4965
4980
|
}
|
|
4966
4981
|
function repoNotConnectedError() {
|
|
4967
4982
|
return new CliStructuredError("GIT.REPO_NOT_CONNECTED", "No GitHub repository connected", {
|
|
4968
4983
|
why: "The resolved project does not have an active GitHub repository connection.",
|
|
4969
|
-
nextActions: [userChoice$
|
|
4984
|
+
nextActions: [userChoice$5("Run prisma git connect before disconnecting."), runCommand$5("prisma git connect")]
|
|
4970
4985
|
});
|
|
4971
4986
|
}
|
|
4972
4987
|
function repoInstallationRequiredError(repository, installUrl) {
|
|
@@ -4977,9 +4992,9 @@ function repoInstallationRequiredError(repository, installUrl) {
|
|
|
4977
4992
|
installUrl
|
|
4978
4993
|
},
|
|
4979
4994
|
nextActions: [
|
|
4980
|
-
userChoice$
|
|
4995
|
+
userChoice$5("Finish installing the GitHub App in the browser, then rerun prisma git connect."),
|
|
4981
4996
|
openUrl(installUrl),
|
|
4982
|
-
runCommand$
|
|
4997
|
+
runCommand$5(`prisma git connect ${repository.url}`)
|
|
4983
4998
|
]
|
|
4984
4999
|
});
|
|
4985
5000
|
}
|
|
@@ -4991,9 +5006,9 @@ function repoNotAccessibleError(repository, installUrl) {
|
|
|
4991
5006
|
installUrl
|
|
4992
5007
|
},
|
|
4993
5008
|
nextActions: [
|
|
4994
|
-
userChoice$
|
|
5009
|
+
userChoice$5("Open the GitHub App installation URL, grant access to this repository, then rerun prisma git connect."),
|
|
4995
5010
|
openUrl(installUrl),
|
|
4996
|
-
runCommand$
|
|
5011
|
+
runCommand$5(`prisma git connect ${repository.url}`)
|
|
4997
5012
|
]
|
|
4998
5013
|
});
|
|
4999
5014
|
}
|
|
@@ -5001,7 +5016,7 @@ function repoAlreadyConnectedError(repositoryFullName) {
|
|
|
5001
5016
|
return new CliStructuredError("GIT.REPO_ALREADY_CONNECTED", "Project already has a GitHub repository connected", {
|
|
5002
5017
|
why: `The resolved project is already connected to ${repositoryFullName}.`,
|
|
5003
5018
|
meta: { repository: repositoryFullName },
|
|
5004
|
-
nextActions: [userChoice$
|
|
5019
|
+
nextActions: [userChoice$5("Disconnect the existing repository before connecting a different one."), runCommand$5("prisma git disconnect")]
|
|
5005
5020
|
});
|
|
5006
5021
|
}
|
|
5007
5022
|
function repositoryFullNamesMatch(left, right) {
|
|
@@ -5019,7 +5034,7 @@ function repoConnectionApiError(summary, response, error) {
|
|
|
5019
5034
|
status,
|
|
5020
5035
|
...apiCode ? { apiCode } : {}
|
|
5021
5036
|
},
|
|
5022
|
-
nextActions: [userChoice$
|
|
5037
|
+
nextActions: [userChoice$5(apiHint ?? repoConnectionFixForStatus(status)), runCommand$5(unauthorized ? "prisma auth login" : "prisma project show")]
|
|
5023
5038
|
});
|
|
5024
5039
|
}
|
|
5025
5040
|
function repoConnectionFixForStatus(status) {
|
|
@@ -5030,6 +5045,317 @@ function repoConnectionFixForStatus(status) {
|
|
|
5030
5045
|
return "Re-run with --log-level verbose for the underlying API response details.";
|
|
5031
5046
|
}
|
|
5032
5047
|
//#endregion
|
|
5048
|
+
//#region ../cli/src/lib/address/address.ts
|
|
5049
|
+
/**
|
|
5050
|
+
* Addresses as command subjects. Prisma Composer names everything it
|
|
5051
|
+
* deploys with an address such as `shop.api`, whose first `.`-separated
|
|
5052
|
+
* part is the app. A subject names one by `@`, an optional environment
|
|
5053
|
+
* and `:`, then the address: `@pr-42:shop.api`, `@shop.catalog`,
|
|
5054
|
+
* `@shop`. The app is the Project's `logicalId`; the full address is the
|
|
5055
|
+
* service, database or bucket row's `logicalId`.
|
|
5056
|
+
*/
|
|
5057
|
+
const PRODUCTION_ENVIRONMENT = "production";
|
|
5058
|
+
const WHITESPACE = /\s/;
|
|
5059
|
+
const DEPLOY_LIST_COMMAND = `${CLI_NAME} deploy list`;
|
|
5060
|
+
const BRANCH_LIST_COMMAND = `${CLI_NAME} branch list`;
|
|
5061
|
+
const BRANCH_SCOPED_KINDS = [
|
|
5062
|
+
"service",
|
|
5063
|
+
"database",
|
|
5064
|
+
"bucket"
|
|
5065
|
+
];
|
|
5066
|
+
const KIND_GROUP = {
|
|
5067
|
+
service: "service",
|
|
5068
|
+
database: "postgres",
|
|
5069
|
+
bucket: "bucket"
|
|
5070
|
+
};
|
|
5071
|
+
function isAddress(subject) {
|
|
5072
|
+
return subject.startsWith("@");
|
|
5073
|
+
}
|
|
5074
|
+
function parseAddress(subject) {
|
|
5075
|
+
if (!isAddress(subject)) throw malformedAddressError(subject, "It does not start with '@'.");
|
|
5076
|
+
if (WHITESPACE.test(subject)) throw malformedAddressError(subject, "It contains a space.");
|
|
5077
|
+
const body = subject.slice(1);
|
|
5078
|
+
const colon = body.indexOf(":");
|
|
5079
|
+
const environment = colon === -1 ? void 0 : body.slice(0, colon);
|
|
5080
|
+
const address = colon === -1 ? body : body.slice(colon + 1);
|
|
5081
|
+
if (environment === "") throw malformedAddressError(subject, "The environment before ':' is empty. Leave out the ':' to name production.");
|
|
5082
|
+
if (address === "") throw malformedAddressError(subject, "The address is empty.");
|
|
5083
|
+
const segments = address.split(".");
|
|
5084
|
+
if (segments.some((segment) => segment === "")) throw malformedAddressError(subject, `The address "${address}" has an empty part between dots.`);
|
|
5085
|
+
return {
|
|
5086
|
+
text: subject,
|
|
5087
|
+
environment,
|
|
5088
|
+
address,
|
|
5089
|
+
appName: segments[0] ?? ""
|
|
5090
|
+
};
|
|
5091
|
+
}
|
|
5092
|
+
/** Where a match lives, for a consent question: `in production (branch
|
|
5093
|
+
* main)` or `in environment pr-42 (branch pr-42)`. */
|
|
5094
|
+
function describeEnvironment(match) {
|
|
5095
|
+
const branch = `(branch ${match.branch.gitName})`;
|
|
5096
|
+
if (match.environment === PRODUCTION_ENVIRONMENT) return `in production ${branch}`;
|
|
5097
|
+
if (match.branch.isDefault) return `in environment ${match.environment}, which is production ${branch}`;
|
|
5098
|
+
return `in environment ${match.environment} ${branch}`;
|
|
5099
|
+
}
|
|
5100
|
+
/** The Project an address subject names. It must be the app name alone,
|
|
5101
|
+
* with no environment: a Project spans every environment, so
|
|
5102
|
+
* `@pr-42:shop` must never reach a command that acts on all of them. */
|
|
5103
|
+
async function resolveProjectAddress(api, subject, signal) {
|
|
5104
|
+
const parsed = parseAddress(subject);
|
|
5105
|
+
if (parsed.environment !== void 0) throw projectEnvironmentError(parsed);
|
|
5106
|
+
if (parsed.address !== parsed.appName) throw projectGivenRowAddressError(parsed);
|
|
5107
|
+
return findProject(api, parsed, signal);
|
|
5108
|
+
}
|
|
5109
|
+
/** The service, database or bucket row an address subject names. */
|
|
5110
|
+
async function resolveBranchScopedAddress(api, kind, subject, signal) {
|
|
5111
|
+
const parsed = parseAddress(subject);
|
|
5112
|
+
if (parsed.address === parsed.appName) throw addressNamesProjectError(parsed, kind);
|
|
5113
|
+
const project = await findProject(api, parsed, signal);
|
|
5114
|
+
const branch = await findBranch(api, parsed, project, signal);
|
|
5115
|
+
const rows = await listRows(api, kind, parsed, project.id, branch.id, signal);
|
|
5116
|
+
if (rows.length > 1) throw rowsAmbiguousError(parsed, kind, rows);
|
|
5117
|
+
const [row] = rows;
|
|
5118
|
+
if (row !== void 0) return {
|
|
5119
|
+
id: row.id,
|
|
5120
|
+
text: parsed.text,
|
|
5121
|
+
environment: parsed.environment ?? PRODUCTION_ENVIRONMENT,
|
|
5122
|
+
project,
|
|
5123
|
+
branch
|
|
5124
|
+
};
|
|
5125
|
+
for (const otherKind of BRANCH_SCOPED_KINDS.filter((other) => other !== kind)) if ((await listRows(api, otherKind, parsed, project.id, branch.id, signal)).length > 0) throw wrongKindError(parsed, kind, otherKind);
|
|
5126
|
+
throw rowNotFoundError(parsed, kind, project, branch);
|
|
5127
|
+
}
|
|
5128
|
+
/** The hand-over: a subject that is an address becomes the row id, the
|
|
5129
|
+
* Project id and the Branch git name it names, exactly what the user
|
|
5130
|
+
* could have typed instead. Any other subject passes through with the
|
|
5131
|
+
* flags it came with. */
|
|
5132
|
+
async function resolveBranchScopedSubject(api, kind, subject, signal, flags = {}) {
|
|
5133
|
+
if (!isAddress(subject)) return {
|
|
5134
|
+
ref: subject,
|
|
5135
|
+
project: flags.project,
|
|
5136
|
+
branch: flags.branch,
|
|
5137
|
+
match: void 0
|
|
5138
|
+
};
|
|
5139
|
+
rejectScopeFlags(subject, flags);
|
|
5140
|
+
const match = await resolveBranchScopedAddress(api, kind, subject, signal);
|
|
5141
|
+
return {
|
|
5142
|
+
ref: match.id,
|
|
5143
|
+
project: match.project.id,
|
|
5144
|
+
branch: match.branch.gitName,
|
|
5145
|
+
match
|
|
5146
|
+
};
|
|
5147
|
+
}
|
|
5148
|
+
/** The Project id an address subject names, or the subject unchanged. */
|
|
5149
|
+
async function resolveProjectSubject(api, subject, signal) {
|
|
5150
|
+
if (!isAddress(subject)) return subject;
|
|
5151
|
+
return (await resolveProjectAddress(api, subject, signal)).id;
|
|
5152
|
+
}
|
|
5153
|
+
function rejectScopeFlags(subject, flags) {
|
|
5154
|
+
const given = [...flags.project !== void 0 ? ["--project"] : [], ...flags.branch !== void 0 ? ["--branch"] : []];
|
|
5155
|
+
if (given.length === 0) return;
|
|
5156
|
+
throw new CliStructuredError("ADDRESS.USAGE_ERROR", `${given.join(" and ")} cannot be combined with an address`, {
|
|
5157
|
+
why: `"${subject}" already names its Project and Branch, so ${given.join(" and ")} would name them a second time.`,
|
|
5158
|
+
meta: {
|
|
5159
|
+
address: subject,
|
|
5160
|
+
flags: given
|
|
5161
|
+
},
|
|
5162
|
+
nextActions: [userChoice$4(`Drop ${given.join(" and ")}, or pass an id or name instead of the address.`)]
|
|
5163
|
+
});
|
|
5164
|
+
}
|
|
5165
|
+
async function listAllPages(summary, fetchPage) {
|
|
5166
|
+
const rows = [];
|
|
5167
|
+
let cursor;
|
|
5168
|
+
do {
|
|
5169
|
+
const { data, error, response } = await fetchPage(cursor);
|
|
5170
|
+
if (error || !data) throw addressApiError(summary, response, error);
|
|
5171
|
+
rows.push(...data.data);
|
|
5172
|
+
cursor = data.pagination.hasMore ? data.pagination.nextCursor ?? void 0 : void 0;
|
|
5173
|
+
} while (cursor);
|
|
5174
|
+
return rows;
|
|
5175
|
+
}
|
|
5176
|
+
async function findProject(api, subject, signal) {
|
|
5177
|
+
const matches = (await listAllPages("Failed to look up the app's Project", (cursor) => api.GET("/v1/projects", {
|
|
5178
|
+
params: { query: {
|
|
5179
|
+
logicalId: subject.appName,
|
|
5180
|
+
cursor
|
|
5181
|
+
} },
|
|
5182
|
+
signal
|
|
5183
|
+
}))).filter((project) => project.logicalId === subject.appName);
|
|
5184
|
+
if (matches.length > 1) throw new CliStructuredError("ADDRESS.AMBIGUOUS", `Several Projects are named "${subject.appName}"`, {
|
|
5185
|
+
why: `"${subject.text}" names app "${subject.appName}", and more than one Project in this workspace has it.`,
|
|
5186
|
+
meta: {
|
|
5187
|
+
address: subject.text,
|
|
5188
|
+
matches: idsAndNames(matches)
|
|
5189
|
+
},
|
|
5190
|
+
nextActions: [userChoice$4(`Pass a Project id instead of the address: ${matches.map((project) => project.id).join(", ")}.`)]
|
|
5191
|
+
});
|
|
5192
|
+
const [project] = matches;
|
|
5193
|
+
if (project === void 0) throw new CliStructuredError("ADDRESS.NOT_FOUND", `No Project for app "${subject.appName}"`, {
|
|
5194
|
+
why: `"${subject.text}" names app "${subject.appName}", and no Project in this workspace was deployed for it.`,
|
|
5195
|
+
meta: {
|
|
5196
|
+
address: subject.text,
|
|
5197
|
+
app: subject.appName
|
|
5198
|
+
},
|
|
5199
|
+
nextActions: [userChoice$4("Check the app name, or that you are signed in to the workspace the app was deployed to."), runCommand$4(`${CLI_NAME} project list`)]
|
|
5200
|
+
});
|
|
5201
|
+
return {
|
|
5202
|
+
id: project.id,
|
|
5203
|
+
name: project.name
|
|
5204
|
+
};
|
|
5205
|
+
}
|
|
5206
|
+
/** No environment, or `production`, is the Project's default Branch;
|
|
5207
|
+
* any other environment is the Branch with that git name. */
|
|
5208
|
+
async function findBranch(api, subject, project, signal) {
|
|
5209
|
+
const environment = subject.environment ?? PRODUCTION_ENVIRONMENT;
|
|
5210
|
+
const production = environment === PRODUCTION_ENVIRONMENT;
|
|
5211
|
+
const branches = await listProjectBranches(api, {
|
|
5212
|
+
projectId: project.id,
|
|
5213
|
+
gitName: production ? void 0 : environment,
|
|
5214
|
+
signal
|
|
5215
|
+
});
|
|
5216
|
+
const branch = production ? branches.find((candidate) => candidate.isDefault) : branches.find((candidate) => candidate.gitName === environment);
|
|
5217
|
+
if (branch === void 0) throw new CliStructuredError("ADDRESS.NOT_FOUND", `No branch for environment "${environment}"`, {
|
|
5218
|
+
why: production ? `Project "${project.name}" (${project.id}) has no default branch. Production is the default branch.` : `Project "${project.name}" (${project.id}) has no branch whose git name is "${environment}".`,
|
|
5219
|
+
meta: {
|
|
5220
|
+
address: subject.text,
|
|
5221
|
+
environment,
|
|
5222
|
+
projectId: project.id
|
|
5223
|
+
},
|
|
5224
|
+
nextActions: [userChoice$4("Use an environment from the Project's branch list: a branch's git name, or production for the default branch."), runCommand$4(`${BRANCH_LIST_COMMAND} --project ${project.id}`)]
|
|
5225
|
+
});
|
|
5226
|
+
return {
|
|
5227
|
+
id: branch.id,
|
|
5228
|
+
gitName: branch.gitName,
|
|
5229
|
+
isDefault: branch.isDefault
|
|
5230
|
+
};
|
|
5231
|
+
}
|
|
5232
|
+
/** The API filters by `logicalId` and `branchId`; the rows are checked
|
|
5233
|
+
* again here so an API that ignored a filter cannot widen the match. */
|
|
5234
|
+
async function listRows(api, kind, subject, projectId, branchId, signal) {
|
|
5235
|
+
const filters = {
|
|
5236
|
+
projectId,
|
|
5237
|
+
logicalId: subject.address,
|
|
5238
|
+
branchId
|
|
5239
|
+
};
|
|
5240
|
+
return (await listAllPages(`Failed to look up ${kind}s by address`, (cursor) => {
|
|
5241
|
+
const init = {
|
|
5242
|
+
params: { query: {
|
|
5243
|
+
...filters,
|
|
5244
|
+
cursor
|
|
5245
|
+
} },
|
|
5246
|
+
signal
|
|
5247
|
+
};
|
|
5248
|
+
switch (kind) {
|
|
5249
|
+
case "service": return api.GET("/v1/services", init);
|
|
5250
|
+
case "database": return api.GET("/v1/databases", init);
|
|
5251
|
+
case "bucket": return api.GET("/v1/buckets", init);
|
|
5252
|
+
}
|
|
5253
|
+
})).filter((row) => row.logicalId === subject.address && row.branchId === branchId);
|
|
5254
|
+
}
|
|
5255
|
+
function idsAndNames(rows) {
|
|
5256
|
+
return rows.map((row) => ({
|
|
5257
|
+
id: row.id,
|
|
5258
|
+
name: row.name
|
|
5259
|
+
}));
|
|
5260
|
+
}
|
|
5261
|
+
function malformedAddressError(subject, why) {
|
|
5262
|
+
return new CliStructuredError("ADDRESS.USAGE_ERROR", `"${subject}" is not a valid address`, {
|
|
5263
|
+
why: `${why} Name a deployed resource with @, then an optional environment and ':', then its address, such as @shop.api for production or @pr-42:shop.api.`,
|
|
5264
|
+
meta: { address: subject },
|
|
5265
|
+
nextActions: [userChoice$4("Fix the address, or pass the id or name instead. Addresses that were deployed are listed by the command below, run in the app's directory."), runCommand$4(DEPLOY_LIST_COMMAND)]
|
|
5266
|
+
});
|
|
5267
|
+
}
|
|
5268
|
+
function projectEnvironmentError(subject) {
|
|
5269
|
+
const projectAddress = `@${subject.appName}`;
|
|
5270
|
+
return new CliStructuredError("ADDRESS.USAGE_ERROR", `A Project's address takes no environment: "${subject.text}"`, {
|
|
5271
|
+
why: `A Project spans every environment of app "${subject.appName}", so naming one environment would still act on all of them. Write ${projectAddress}.`,
|
|
5272
|
+
meta: { address: subject.text },
|
|
5273
|
+
nextActions: [userChoice$4(`Pass ${projectAddress} to name the Project.`)]
|
|
5274
|
+
});
|
|
5275
|
+
}
|
|
5276
|
+
function projectGivenRowAddressError(subject) {
|
|
5277
|
+
const projectAddress = `@${subject.appName}`;
|
|
5278
|
+
return new CliStructuredError("ADDRESS.WRONG_KIND", `"${subject.text}" names something inside app "${subject.appName}", not its Project`, {
|
|
5279
|
+
why: `A Project's address is the app name alone, ${projectAddress}. "${subject.address}" names a service, database or bucket inside it.`,
|
|
5280
|
+
meta: {
|
|
5281
|
+
address: subject.text,
|
|
5282
|
+
expected: "project",
|
|
5283
|
+
actual: "service, database or bucket"
|
|
5284
|
+
},
|
|
5285
|
+
nextActions: [userChoice$4(`Pass ${projectAddress} to name the Project, or use a service, postgres or bucket command for "${subject.text}".`)]
|
|
5286
|
+
});
|
|
5287
|
+
}
|
|
5288
|
+
function addressNamesProjectError(subject, kind) {
|
|
5289
|
+
const projectCommand = `${CLI_NAME} project show @${subject.appName}`;
|
|
5290
|
+
return new CliStructuredError("ADDRESS.WRONG_KIND", `"${subject.text}" names the app's Project, not a ${kind}`, {
|
|
5291
|
+
why: `The app name alone, "${subject.appName}", is the Project's address. A ${kind}'s address continues past it, such as @${subject.appName}.<name>.`,
|
|
5292
|
+
meta: {
|
|
5293
|
+
address: subject.text,
|
|
5294
|
+
expected: kind,
|
|
5295
|
+
actual: "project"
|
|
5296
|
+
},
|
|
5297
|
+
nextActions: [userChoice$4(`Name the ${kind} inside the app, or inspect the Project.`), runCommand$4(projectCommand)]
|
|
5298
|
+
});
|
|
5299
|
+
}
|
|
5300
|
+
function wrongKindError(subject, expected, actual) {
|
|
5301
|
+
return new CliStructuredError("ADDRESS.WRONG_KIND", `"${subject.text}" is a ${actual}, not a ${expected}`, {
|
|
5302
|
+
why: `The address names a ${actual}. The ${KIND_GROUP[actual]} commands act on it.`,
|
|
5303
|
+
meta: {
|
|
5304
|
+
address: subject.text,
|
|
5305
|
+
expected,
|
|
5306
|
+
actual
|
|
5307
|
+
},
|
|
5308
|
+
nextActions: [userChoice$4(`Use a '${CLI_NAME} ${KIND_GROUP[actual]}' command for ${formatCommandArgument(subject.text)}.`), runCommand$4(`${CLI_NAME} ${KIND_GROUP[actual]} --help`)]
|
|
5309
|
+
});
|
|
5310
|
+
}
|
|
5311
|
+
function rowNotFoundError(subject, kind, project, branch) {
|
|
5312
|
+
return new CliStructuredError("ADDRESS.NOT_FOUND", `Nothing is deployed at "${subject.text}"`, {
|
|
5313
|
+
why: `No service, database or bucket on branch "${branch.gitName}" of Project "${project.name}" (${project.id}) has address "${subject.address}".`,
|
|
5314
|
+
meta: {
|
|
5315
|
+
address: subject.text,
|
|
5316
|
+
expected: kind,
|
|
5317
|
+
projectId: project.id,
|
|
5318
|
+
branchId: branch.id
|
|
5319
|
+
},
|
|
5320
|
+
nextActions: [userChoice$4("Check the address and environment against what the app deployed; the command below lists them, run in the app's directory."), runCommand$4(DEPLOY_LIST_COMMAND)]
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5323
|
+
function rowsAmbiguousError(subject, kind, rows) {
|
|
5324
|
+
return new CliStructuredError("ADDRESS.AMBIGUOUS", `Several ${kind} rows have address "${subject.text}"`, {
|
|
5325
|
+
why: `More than one ${kind} on the branch carries address "${subject.address}", so the address does not pick one.`,
|
|
5326
|
+
meta: {
|
|
5327
|
+
address: subject.text,
|
|
5328
|
+
matches: idsAndNames(rows)
|
|
5329
|
+
},
|
|
5330
|
+
nextActions: [userChoice$4(`Pass one of the ids instead: ${rows.map((row) => row.id).join(", ")}.`)]
|
|
5331
|
+
});
|
|
5332
|
+
}
|
|
5333
|
+
function addressApiError(summary, response, error) {
|
|
5334
|
+
const status = response.status;
|
|
5335
|
+
const apiCode = error?.error?.code;
|
|
5336
|
+
return new CliStructuredError("ADDRESS.API_ERROR", summary, {
|
|
5337
|
+
why: error?.error?.message ?? `The Management API returned status ${status || "unknown"}.`,
|
|
5338
|
+
meta: {
|
|
5339
|
+
...status ? { status } : {},
|
|
5340
|
+
...apiCode !== void 0 ? { apiCode } : {}
|
|
5341
|
+
},
|
|
5342
|
+
nextActions: [userChoice$4(error?.error?.hint ?? "Re-run with --log-level verbose for the underlying API response details.")]
|
|
5343
|
+
});
|
|
5344
|
+
}
|
|
5345
|
+
function userChoice$4(label) {
|
|
5346
|
+
return {
|
|
5347
|
+
kind: "user-choice",
|
|
5348
|
+
label
|
|
5349
|
+
};
|
|
5350
|
+
}
|
|
5351
|
+
function runCommand$4(command) {
|
|
5352
|
+
return {
|
|
5353
|
+
kind: "run-command",
|
|
5354
|
+
label: command,
|
|
5355
|
+
command
|
|
5356
|
+
};
|
|
5357
|
+
}
|
|
5358
|
+
//#endregion
|
|
5033
5359
|
//#region ../cli/src/lib/project/setup.ts
|
|
5034
5360
|
function isValidProjectSetupName(projectName) {
|
|
5035
5361
|
return projectName.trim().length > 0;
|
|
@@ -5172,6 +5498,18 @@ function operationContext(ctx) {
|
|
|
5172
5498
|
function listWorkspaceProjects$1(ctx) {
|
|
5173
5499
|
return listRealWorkspaceProjects(ctx.api, ctx.signal);
|
|
5174
5500
|
}
|
|
5501
|
+
/** The Project a command's positional names, trimmed: the id or name as
|
|
5502
|
+
* typed, or the id of the Project an address names. `address` keeps the
|
|
5503
|
+
* address as typed for the consent token. Undefined when the positional
|
|
5504
|
+
* is absent or blank. */
|
|
5505
|
+
async function resolveProjectPositional(ctx, positional) {
|
|
5506
|
+
const subject = positional?.trim();
|
|
5507
|
+
if (!subject) return;
|
|
5508
|
+
return {
|
|
5509
|
+
ref: await resolveProjectSubject(ctx.api, subject, ctx.signal),
|
|
5510
|
+
address: isAddress(subject) ? subject : void 0
|
|
5511
|
+
};
|
|
5512
|
+
}
|
|
5175
5513
|
/** Explicit `--project`, else the `.prisma/local.json` pin, else the
|
|
5176
5514
|
* setup-required error. An absent `commandName` makes that error read
|
|
5177
5515
|
* "this command" and drops its retry step — `branch list`'s legacy
|
|
@@ -5482,7 +5820,7 @@ const branchFlag$2 = flag.string({
|
|
|
5482
5820
|
placeholder: "git-name"
|
|
5483
5821
|
});
|
|
5484
5822
|
const bucketPositional = positional.string({
|
|
5485
|
-
brief: "Bucket id",
|
|
5823
|
+
brief: "Bucket id, or its address: @shop.files (production) or @pr-42:shop.files (environment pr-42)",
|
|
5486
5824
|
placeholder: "bucket-id"
|
|
5487
5825
|
});
|
|
5488
5826
|
/** The legacy `requireBucketContext`: `bucket list` and `bucket create`
|
|
@@ -5502,6 +5840,16 @@ async function resolveBucketContext(ctx, flags, commandName) {
|
|
|
5502
5840
|
function resolveBucketProviderOnly(ctx) {
|
|
5503
5841
|
return createManagementBucketProvider(ctx.api);
|
|
5504
5842
|
}
|
|
5843
|
+
/** The bucket the subject names: the id as typed, or the bucket an
|
|
5844
|
+
* address names. Bucket ids are globally unique, so the Project and
|
|
5845
|
+
* Branch an address names are not needed past the lookup. */
|
|
5846
|
+
async function resolveBucket(ctx, bucketRef) {
|
|
5847
|
+
const subject = await resolveBranchScopedSubject(ctx.api, "bucket", bucketRef, ctx.signal);
|
|
5848
|
+
return {
|
|
5849
|
+
id: subject.ref,
|
|
5850
|
+
address: subject.match
|
|
5851
|
+
};
|
|
5852
|
+
}
|
|
5505
5853
|
//#endregion
|
|
5506
5854
|
//#region ../cli/src/commands/bucket/presentation.ts
|
|
5507
5855
|
/** Legacy `formatBucketTarget`. */
|
|
@@ -5587,7 +5935,9 @@ const bucketCreateCommand = defineCommand({
|
|
|
5587
5935
|
//#endregion
|
|
5588
5936
|
//#region ../cli/src/commands/bucket/delete.ts
|
|
5589
5937
|
/** The `bucket delete` command. */
|
|
5590
|
-
|
|
5938
|
+
function consentQuestion$4(bucketId, address) {
|
|
5939
|
+
return address ? `Deleting bucket ${bucketId} ${describeEnvironment(address)} permanently removes all objects and access keys.` : "Deleting this bucket permanently removes all objects and access keys.";
|
|
5940
|
+
}
|
|
5591
5941
|
function deletePresentations$5(result) {
|
|
5592
5942
|
return {
|
|
5593
5943
|
stdout: noDataLines("A delete has no data; its exit code is the result."),
|
|
@@ -5617,13 +5967,13 @@ const bucketDeleteCommand = defineCommand({
|
|
|
5617
5967
|
args: { positionals: { bucketId: bucketPositional } },
|
|
5618
5968
|
help: {
|
|
5619
5969
|
summary: "Delete a bucket and all its access keys",
|
|
5620
|
-
description: "Deletion is permanent: the stored objects are destroyed and every access key stops working. The exact bucket id is the consent token; pass it with --confirm to run non-interactively.",
|
|
5621
|
-
examples: ["bucket delete bkt_123 --confirm bkt_123"]
|
|
5970
|
+
description: "Deletion is permanent: the stored objects are destroyed and every access key stops working. The exact bucket id is the consent token, or the address when you pass one; pass it with --confirm to run non-interactively.",
|
|
5971
|
+
examples: ["bucket delete bkt_123 --confirm bkt_123", "bucket delete @pr-42:shop.files --confirm @pr-42:shop.files"]
|
|
5622
5972
|
},
|
|
5623
5973
|
needs: { credentials: true },
|
|
5624
5974
|
handler: async (args, ctx) => {
|
|
5625
|
-
const
|
|
5626
|
-
if (!
|
|
5975
|
+
const bucketRef = args.positionals.bucketId.trim();
|
|
5976
|
+
if (!bucketRef) throw new CliStructuredError("BUCKET.USAGE_ERROR", "Bucket id required", {
|
|
5627
5977
|
why: "Bucket deletion needs a bucket id.",
|
|
5628
5978
|
nextActions: [{
|
|
5629
5979
|
kind: "user-choice",
|
|
@@ -5634,7 +5984,8 @@ const bucketDeleteCommand = defineCommand({
|
|
|
5634
5984
|
command: LIST_BUCKETS_COMMAND
|
|
5635
5985
|
}]
|
|
5636
5986
|
});
|
|
5637
|
-
|
|
5987
|
+
const { id: bucketId, address } = await resolveBucket(ctx, bucketRef);
|
|
5988
|
+
await ctx.prompt.consent(consentQuestion$4(bucketId, address), { token: address?.text ?? bucketId });
|
|
5638
5989
|
await resolveBucketProviderOnly(ctx).deleteBucket(bucketId, { signal: ctx.signal });
|
|
5639
5990
|
const result = { bucket: { id: bucketId } };
|
|
5640
5991
|
return ok(ctx.present({ data: result }, deletePresentations$5(result)));
|
|
@@ -5717,8 +6068,8 @@ const bucketKeyCreateCommand = defineCommand({
|
|
|
5717
6068
|
},
|
|
5718
6069
|
needs: { credentials: true },
|
|
5719
6070
|
handler: async (args, ctx) => {
|
|
5720
|
-
const
|
|
5721
|
-
if (!
|
|
6071
|
+
const bucketRef = args.positionals.bucketId.trim();
|
|
6072
|
+
if (!bucketRef) throw new CliStructuredError("BUCKET.USAGE_ERROR", "Bucket id required", {
|
|
5722
6073
|
why: "Bucket key creation needs a bucket id.",
|
|
5723
6074
|
nextActions: [{
|
|
5724
6075
|
kind: "user-choice",
|
|
@@ -5729,6 +6080,7 @@ const bucketKeyCreateCommand = defineCommand({
|
|
|
5729
6080
|
command: LIST_BUCKETS_COMMAND
|
|
5730
6081
|
}]
|
|
5731
6082
|
});
|
|
6083
|
+
const { id: bucketId } = await resolveBucket(ctx, bucketRef);
|
|
5732
6084
|
const result = {
|
|
5733
6085
|
bucketId,
|
|
5734
6086
|
...await resolveBucketProviderOnly(ctx).createKey({
|
|
@@ -5784,9 +6136,9 @@ const bucketKeyDeleteCommand = defineCommand({
|
|
|
5784
6136
|
},
|
|
5785
6137
|
needs: { credentials: true },
|
|
5786
6138
|
handler: async (args, ctx) => {
|
|
5787
|
-
const
|
|
6139
|
+
const bucketRef = args.positionals.bucketId.trim();
|
|
5788
6140
|
const keyId = args.positionals.keyId.trim();
|
|
5789
|
-
if (!
|
|
6141
|
+
if (!bucketRef || !keyId) {
|
|
5790
6142
|
const listKeysCommand = `${CLI_NAME} bucket key list <bucketId>`;
|
|
5791
6143
|
throw new CliStructuredError("BUCKET.USAGE_ERROR", "Bucket id and key id required", {
|
|
5792
6144
|
why: "Bucket key deletion needs both a bucket id and a key id.",
|
|
@@ -5800,6 +6152,7 @@ const bucketKeyDeleteCommand = defineCommand({
|
|
|
5800
6152
|
}]
|
|
5801
6153
|
});
|
|
5802
6154
|
}
|
|
6155
|
+
const { id: bucketId } = await resolveBucket(ctx, bucketRef);
|
|
5803
6156
|
await resolveBucketProviderOnly(ctx).deleteKey(bucketId, keyId, { signal: ctx.signal });
|
|
5804
6157
|
const result = { key: { id: keyId } };
|
|
5805
6158
|
return ok(ctx.present({ data: result }, deletePresentations$4(result)));
|
|
@@ -5898,12 +6251,16 @@ const bucketKeyListCommand = defineCommand({
|
|
|
5898
6251
|
help: {
|
|
5899
6252
|
summary: "List access keys for a bucket",
|
|
5900
6253
|
description: "Shows each key's id, name, and role. Key secrets print once, at 'bucket key create'; listing never reveals them.",
|
|
5901
|
-
examples: [
|
|
6254
|
+
examples: [
|
|
6255
|
+
"bucket key list bkt_123",
|
|
6256
|
+
"bucket key list bkt_123 --json",
|
|
6257
|
+
"bucket key list @shop.files"
|
|
6258
|
+
]
|
|
5902
6259
|
},
|
|
5903
6260
|
needs: { credentials: true },
|
|
5904
6261
|
handler: async (args, ctx) => {
|
|
5905
|
-
const
|
|
5906
|
-
if (!
|
|
6262
|
+
const bucketRef = args.positionals.bucketId.trim();
|
|
6263
|
+
if (!bucketRef) throw new CliStructuredError("BUCKET.USAGE_ERROR", "Bucket id required", {
|
|
5907
6264
|
why: "Bucket key listing needs a bucket id.",
|
|
5908
6265
|
nextActions: [{
|
|
5909
6266
|
kind: "user-choice",
|
|
@@ -5914,6 +6271,7 @@ const bucketKeyListCommand = defineCommand({
|
|
|
5914
6271
|
command: LIST_BUCKETS_COMMAND
|
|
5915
6272
|
}]
|
|
5916
6273
|
});
|
|
6274
|
+
const { id: bucketId } = await resolveBucket(ctx, bucketRef);
|
|
5917
6275
|
const result = {
|
|
5918
6276
|
bucketId,
|
|
5919
6277
|
keys: await resolveBucketProviderOnly(ctx).listKeys(bucketId, { signal: ctx.signal })
|
|
@@ -7903,7 +8261,7 @@ const branchFlag$1 = flag.string({
|
|
|
7903
8261
|
placeholder: "git-name"
|
|
7904
8262
|
});
|
|
7905
8263
|
const databasePositional = positional.string({
|
|
7906
|
-
brief: "Database id or name",
|
|
8264
|
+
brief: "Database id or name, or its address: @shop.db (production) or @pr-42:shop.db (environment pr-42)",
|
|
7907
8265
|
placeholder: "database"
|
|
7908
8266
|
});
|
|
7909
8267
|
async function resolvePostgresContext(ctx, flags, commandName) {
|
|
@@ -7916,6 +8274,23 @@ async function resolvePostgresContext(ctx, flags, commandName) {
|
|
|
7916
8274
|
projectName: target.project.name
|
|
7917
8275
|
};
|
|
7918
8276
|
}
|
|
8277
|
+
/** The project, then the database the subject names. A database
|
|
8278
|
+
* address stands in for the database id, `--project` and `--branch`
|
|
8279
|
+
* together. */
|
|
8280
|
+
async function resolvePostgresDatabase(ctx, flags, databaseRef, commandName) {
|
|
8281
|
+
const subject = await resolveBranchScopedSubject(ctx.api, "database", databaseRef.trim(), ctx.signal, flags);
|
|
8282
|
+
const context = await resolvePostgresContext(ctx, {
|
|
8283
|
+
...subject.project !== void 0 ? { project: subject.project } : {},
|
|
8284
|
+
...subject.branch !== void 0 ? { branch: subject.branch } : {}
|
|
8285
|
+
}, commandName);
|
|
8286
|
+
const database = await resolveDatabase(context.provider, context.target, subject.ref, subject.branch, ctx.signal);
|
|
8287
|
+
return {
|
|
8288
|
+
...context,
|
|
8289
|
+
database,
|
|
8290
|
+
branchName: subject.branch,
|
|
8291
|
+
address: subject.match
|
|
8292
|
+
};
|
|
8293
|
+
}
|
|
7919
8294
|
/** `connection rotate` and `connection delete` address a connection
|
|
7920
8295
|
* directly: no workspace requirement and no project resolution, so
|
|
7921
8296
|
* the workspace is only a plan-limit lookup hint. */
|
|
@@ -8083,8 +8458,7 @@ const postgresBackupListCommand = defineCommand({
|
|
|
8083
8458
|
needs: { credentials: true },
|
|
8084
8459
|
handler: async (args, ctx) => {
|
|
8085
8460
|
const limit = parseBackupLimit(args.flags.limit);
|
|
8086
|
-
const { provider,
|
|
8087
|
-
const database = await resolveDatabase(provider, target, args.positionals.database, args.flags.branch, ctx.signal);
|
|
8461
|
+
const { provider, projectId, projectName, database } = await resolvePostgresDatabase(ctx, args.flags, args.positionals.database, "postgres backup list");
|
|
8088
8462
|
const backups = await provider.listBackups(database.id, {
|
|
8089
8463
|
limit,
|
|
8090
8464
|
signal: ctx.signal
|
|
@@ -8103,7 +8477,9 @@ const postgresBackupListCommand = defineCommand({
|
|
|
8103
8477
|
//#endregion
|
|
8104
8478
|
//#region ../cli/src/commands/postgres/backup-restore.ts
|
|
8105
8479
|
/** The `postgres backup restore` command. */
|
|
8106
|
-
|
|
8480
|
+
function consentQuestion$3(databaseId, address) {
|
|
8481
|
+
return address ? `Restoring immediately and irreversibly overwrites all data in database ${databaseId} ${describeEnvironment(address)}, so it requires the exact target database address.` : "Restoring immediately and irreversibly overwrites all data in the target database, so it requires the exact target database id.";
|
|
8482
|
+
}
|
|
8107
8483
|
function restorePresentations(result, sourceDatabaseId, targetDatabaseId) {
|
|
8108
8484
|
const rows = [
|
|
8109
8485
|
{
|
|
@@ -8155,7 +8531,7 @@ function restorePresentations(result, sourceDatabaseId, targetDatabaseId) {
|
|
|
8155
8531
|
const postgresBackupRestoreCommand = defineCommand({
|
|
8156
8532
|
args: {
|
|
8157
8533
|
positionals: { database: positional.string({
|
|
8158
|
-
brief: "Target database id or name",
|
|
8534
|
+
brief: "Target database id or name, or its address: @shop.db (production) or @pr-42:shop.db (environment pr-42)",
|
|
8159
8535
|
placeholder: "database"
|
|
8160
8536
|
}) },
|
|
8161
8537
|
flags: {
|
|
@@ -8172,8 +8548,8 @@ const postgresBackupRestoreCommand = defineCommand({
|
|
|
8172
8548
|
}
|
|
8173
8549
|
},
|
|
8174
8550
|
help: {
|
|
8175
|
-
summary: "Restore a database from a backup after exact
|
|
8176
|
-
description: "Replaces the target database's current state with the backup's contents; anything written since that backup is lost, so the exact target database id is the consent token. To restore another database's backup into this one, name where the backup came from with --source-database.",
|
|
8551
|
+
summary: "Restore a database from a backup after exact confirmation",
|
|
8552
|
+
description: "Replaces the target database's current state with the backup's contents; anything written since that backup is lost, so the exact target database id is the consent token (or the address, when you pass one). To restore another database's backup into this one, name where the backup came from with --source-database.",
|
|
8177
8553
|
examples: ["postgres backup restore db_123 --backup bkp_456 --confirm db_123"]
|
|
8178
8554
|
},
|
|
8179
8555
|
needs: { credentials: true },
|
|
@@ -8193,10 +8569,9 @@ const postgresBackupRestoreCommand = defineCommand({
|
|
|
8193
8569
|
}]
|
|
8194
8570
|
});
|
|
8195
8571
|
}
|
|
8196
|
-
const { provider, target, projectId, projectName } = await
|
|
8197
|
-
const
|
|
8198
|
-
|
|
8199
|
-
await ctx.prompt.consent(CONSENT_QUESTION$5, { token: database.id });
|
|
8572
|
+
const { provider, target, projectId, projectName, branchName, database, address } = await resolvePostgresDatabase(ctx, args.flags, args.positionals.database, "postgres backup restore");
|
|
8573
|
+
const sourceDatabase = args.flags.sourceDatabase ? await resolveDatabase(provider, target, args.flags.sourceDatabase, branchName, ctx.signal) : database;
|
|
8574
|
+
await ctx.prompt.consent(consentQuestion$3(database.id, address), { token: address?.text ?? database.id });
|
|
8200
8575
|
const result = {
|
|
8201
8576
|
projectId,
|
|
8202
8577
|
projectName,
|
|
@@ -8237,8 +8612,7 @@ const postgresConnectionCreateCommand = defineCommand({
|
|
|
8237
8612
|
},
|
|
8238
8613
|
needs: { credentials: true },
|
|
8239
8614
|
handler: async (args, ctx) => {
|
|
8240
|
-
const { provider,
|
|
8241
|
-
const database = await resolveDatabase(provider, target, args.positionals.database, args.flags.branch, ctx.signal);
|
|
8615
|
+
const { provider, projectId, projectName, database } = await resolvePostgresDatabase(ctx, args.flags, args.positionals.database, "postgres connection create");
|
|
8242
8616
|
const created = await provider.createConnection({
|
|
8243
8617
|
databaseId: database.id,
|
|
8244
8618
|
name: args.flags.name?.trim() || defaultConnectionName(),
|
|
@@ -8262,7 +8636,7 @@ const postgresConnectionCreateCommand = defineCommand({
|
|
|
8262
8636
|
//#endregion
|
|
8263
8637
|
//#region ../cli/src/commands/postgres/connection-delete.ts
|
|
8264
8638
|
/** The `postgres connection delete` command. */
|
|
8265
|
-
const CONSENT_QUESTION$
|
|
8639
|
+
const CONSENT_QUESTION$1 = "Deleting this database connection is destructive and requires the exact id.";
|
|
8266
8640
|
const postgresConnectionDeleteCommand = defineCommand({
|
|
8267
8641
|
args: { positionals: { connection: positional.string({
|
|
8268
8642
|
brief: "Connection id",
|
|
@@ -8290,7 +8664,7 @@ const postgresConnectionDeleteCommand = defineCommand({
|
|
|
8290
8664
|
}]
|
|
8291
8665
|
});
|
|
8292
8666
|
}
|
|
8293
|
-
await ctx.prompt.consent(CONSENT_QUESTION$
|
|
8667
|
+
await ctx.prompt.consent(CONSENT_QUESTION$1, { token: connectionId });
|
|
8294
8668
|
await (await resolvePostgresProviderOnly(ctx)).removeConnection(connectionId, { signal: ctx.signal });
|
|
8295
8669
|
const result = { connection: { id: connectionId } };
|
|
8296
8670
|
return ok(ctx.present({ data: result }, {
|
|
@@ -8388,8 +8762,7 @@ const postgresConnectionListCommand = defineCommand({
|
|
|
8388
8762
|
},
|
|
8389
8763
|
needs: { credentials: true },
|
|
8390
8764
|
handler: async (args, ctx) => {
|
|
8391
|
-
const { provider,
|
|
8392
|
-
const database = await resolveDatabase(provider, target, args.positionals.database, args.flags.branch, ctx.signal);
|
|
8765
|
+
const { provider, projectId, projectName, database } = await resolvePostgresDatabase(ctx, args.flags, args.positionals.database, "postgres connection list");
|
|
8393
8766
|
const result = {
|
|
8394
8767
|
projectId,
|
|
8395
8768
|
projectName,
|
|
@@ -8402,7 +8775,7 @@ const postgresConnectionListCommand = defineCommand({
|
|
|
8402
8775
|
//#endregion
|
|
8403
8776
|
//#region ../cli/src/commands/postgres/connection-rotate.ts
|
|
8404
8777
|
/** The `postgres connection rotate` command. */
|
|
8405
|
-
const CONSENT_QUESTION
|
|
8778
|
+
const CONSENT_QUESTION = "Rotating revokes the previous credentials and breaks clients still using them, so it requires the exact connection id.";
|
|
8406
8779
|
const postgresConnectionRotateCommand = defineCommand({
|
|
8407
8780
|
args: { positionals: { connection: positional.string({
|
|
8408
8781
|
brief: "Connection id",
|
|
@@ -8430,7 +8803,7 @@ const postgresConnectionRotateCommand = defineCommand({
|
|
|
8430
8803
|
}]
|
|
8431
8804
|
});
|
|
8432
8805
|
}
|
|
8433
|
-
await ctx.prompt.consent(CONSENT_QUESTION
|
|
8806
|
+
await ctx.prompt.consent(CONSENT_QUESTION, { token: connectionId });
|
|
8434
8807
|
const rotated = await (await resolvePostgresProviderOnly(ctx)).rotateConnection(connectionId, { signal: ctx.signal });
|
|
8435
8808
|
const result = {
|
|
8436
8809
|
connection: rotated.connection,
|
|
@@ -8512,7 +8885,9 @@ const postgresCreateCommand = defineCommand({
|
|
|
8512
8885
|
//#endregion
|
|
8513
8886
|
//#region ../cli/src/commands/postgres/delete.ts
|
|
8514
8887
|
/** The `postgres delete` command. */
|
|
8515
|
-
|
|
8888
|
+
function consentQuestion$2(databaseId, address) {
|
|
8889
|
+
return address ? `Deleting database ${databaseId} ${describeEnvironment(address)} is destructive and requires the exact address.` : "Deleting this database is destructive and requires the exact id.";
|
|
8890
|
+
}
|
|
8516
8891
|
function deletePresentations$3(result) {
|
|
8517
8892
|
return {
|
|
8518
8893
|
stdout: noDataLines("A delete has no data; its exit code is the result."),
|
|
@@ -8557,15 +8932,14 @@ const postgresDeleteCommand = defineCommand({
|
|
|
8557
8932
|
}
|
|
8558
8933
|
},
|
|
8559
8934
|
help: {
|
|
8560
|
-
summary: "Delete a database after exact
|
|
8561
|
-
description: "Deletion is permanent and destroys the data. The exact database id is the consent token; pass it with --confirm to run non-interactively.",
|
|
8562
|
-
examples: ["postgres delete db_123 --confirm db_123"]
|
|
8935
|
+
summary: "Delete a database after exact confirmation",
|
|
8936
|
+
description: "Deletion is permanent and destroys the data. The exact database id is the consent token, or the address when you pass one; pass it with --confirm to run non-interactively.",
|
|
8937
|
+
examples: ["postgres delete db_123 --confirm db_123", "postgres delete @pr-42:shop.db --confirm @pr-42:shop.db"]
|
|
8563
8938
|
},
|
|
8564
8939
|
needs: { credentials: true },
|
|
8565
8940
|
handler: async (args, ctx) => {
|
|
8566
|
-
const { provider,
|
|
8567
|
-
|
|
8568
|
-
await ctx.prompt.consent(CONSENT_QUESTION$2, { token: database.id });
|
|
8941
|
+
const { provider, projectId, projectName, database, address } = await resolvePostgresDatabase(ctx, args.flags, args.positionals.database, "postgres delete");
|
|
8942
|
+
await ctx.prompt.consent(consentQuestion$2(database.id, address), { token: address?.text ?? database.id });
|
|
8569
8943
|
await provider.removeDatabase(database.id, { signal: ctx.signal });
|
|
8570
8944
|
const result = {
|
|
8571
8945
|
projectId,
|
|
@@ -8769,12 +9143,15 @@ const postgresShowCommand = defineCommand({
|
|
|
8769
9143
|
help: {
|
|
8770
9144
|
summary: "Show database metadata without secret values",
|
|
8771
9145
|
description: "Shows a database's name, branch, region, and status. Connection URLs are secrets printed once, by 'postgres create' or 'postgres connection rotate'; this command never reveals them.",
|
|
8772
|
-
examples: [
|
|
9146
|
+
examples: [
|
|
9147
|
+
"postgres show db_123",
|
|
9148
|
+
"postgres show acme-preview --branch preview --json",
|
|
9149
|
+
"postgres show @shop.db"
|
|
9150
|
+
]
|
|
8773
9151
|
},
|
|
8774
9152
|
needs: { credentials: true },
|
|
8775
9153
|
handler: async (args, ctx) => {
|
|
8776
|
-
const { provider,
|
|
8777
|
-
const database = await resolveDatabase(provider, target, args.positionals.database, args.flags.branch, ctx.signal);
|
|
9154
|
+
const { provider, projectId, projectName, database } = await resolvePostgresDatabase(ctx, args.flags, args.positionals.database, "postgres show");
|
|
8778
9155
|
const result = {
|
|
8779
9156
|
projectId,
|
|
8780
9157
|
projectName,
|
|
@@ -8912,8 +9289,7 @@ const postgresUsageCommand = defineCommand({
|
|
|
8912
9289
|
command: USAGE_PERIOD_EXAMPLE_COMMAND
|
|
8913
9290
|
}]
|
|
8914
9291
|
});
|
|
8915
|
-
const { provider,
|
|
8916
|
-
const database = await resolveDatabase(provider, target, args.positionals.database, args.flags.branch, ctx.signal);
|
|
9292
|
+
const { provider, projectId, projectName, database } = await resolvePostgresDatabase(ctx, args.flags, args.positionals.database, "postgres usage");
|
|
8917
9293
|
const usage = await provider.getUsage(database.id, {
|
|
8918
9294
|
from,
|
|
8919
9295
|
to,
|
|
@@ -9653,7 +10029,9 @@ const projectCreateCommand = defineCommand({
|
|
|
9653
10029
|
//#endregion
|
|
9654
10030
|
//#region ../cli/src/commands/project/delete.ts
|
|
9655
10031
|
/** The `project delete` command. */
|
|
9656
|
-
|
|
10032
|
+
function consentQuestion$1(project, address) {
|
|
10033
|
+
return address ? `Deleting Project "${project.name}" (${project.id}) is permanent, destroys its databases on every branch, and stops its apps, so it requires the exact project address.` : "Deleting a project is permanent, destroys its databases, and stops its apps, so it requires the exact project id.";
|
|
10034
|
+
}
|
|
9657
10035
|
function deletePresentations$2(result) {
|
|
9658
10036
|
return {
|
|
9659
10037
|
stdout: noDataLines("A delete has no data; its exit code is the result."),
|
|
@@ -9691,20 +10069,21 @@ function deletePresentations$2(result) {
|
|
|
9691
10069
|
}
|
|
9692
10070
|
const projectDeleteCommand = defineCommand({
|
|
9693
10071
|
args: { positionals: { project: positional.string({
|
|
9694
|
-
brief: "Project id or name",
|
|
10072
|
+
brief: "Project id or name, or its address: @ and the app name, such as @shop",
|
|
9695
10073
|
placeholder: "id-or-name"
|
|
9696
10074
|
}) } },
|
|
9697
10075
|
help: {
|
|
9698
|
-
summary: "Delete a Project permanently after exact
|
|
9699
|
-
description: "Deletion is permanent: it destroys the project's databases and stops its deployed services. Because of that, the command asks for the exact project id as a consent token; pass it with --confirm to run non-interactively.",
|
|
9700
|
-
examples: ["project delete proj_123 --confirm proj_123"]
|
|
10076
|
+
summary: "Delete a Project permanently after exact confirmation",
|
|
10077
|
+
description: "Deletion is permanent: it destroys the project's databases and stops its deployed services. Because of that, the command asks for the exact project id as a consent token, or the address when you pass one; pass it with --confirm to run non-interactively.",
|
|
10078
|
+
examples: ["project delete proj_123 --confirm proj_123", "project delete @shop --confirm @shop"]
|
|
9701
10079
|
},
|
|
9702
10080
|
needs: { credentials: true },
|
|
9703
10081
|
handler: async (args, ctx) => {
|
|
9704
10082
|
const workspace = await resolveActiveWorkspace(ctx);
|
|
9705
10083
|
const projects = await listWorkspaceProjects$1(ctx);
|
|
9706
|
-
const
|
|
9707
|
-
|
|
10084
|
+
const subject = await resolveProjectPositional(ctx, args.positionals.project);
|
|
10085
|
+
const project = toProjectSummary(resolveProjectForSetup(subject?.ref ?? "", projects, workspace));
|
|
10086
|
+
await ctx.prompt.consent(consentQuestion$1(project, subject?.address), { token: subject?.address ?? project.id });
|
|
9708
10087
|
await createManagementProjectProvider(ctx.api).removeProject({
|
|
9709
10088
|
projectId: project.id,
|
|
9710
10089
|
signal: ctx.signal
|
|
@@ -10939,12 +11318,12 @@ async function pickProject(ctx, workspace, projects) {
|
|
|
10939
11318
|
async function linkDirectoryToProject(ctx, projectRef) {
|
|
10940
11319
|
const workspace = await resolveActiveWorkspace(ctx);
|
|
10941
11320
|
const projects = await listWorkspaceProjects$1(ctx);
|
|
10942
|
-
const ref = projectRef?.
|
|
11321
|
+
const ref = (await resolveProjectPositional(ctx, projectRef))?.ref;
|
|
10943
11322
|
return ref ? await bindDirectoryToProject(ctx, workspace, toProjectSummary(resolveProjectForSetup(ref, projects, workspace)), "linked") : await pickProject(ctx, workspace, projects);
|
|
10944
11323
|
}
|
|
10945
11324
|
const projectLinkCommand = defineCommand({
|
|
10946
11325
|
args: { positionals: { project: positional.optionalString({
|
|
10947
|
-
brief: "Project id or name",
|
|
11326
|
+
brief: "Project id or name, or its address: @ and the app name, such as @shop",
|
|
10948
11327
|
placeholder: "id-or-name"
|
|
10949
11328
|
}) } },
|
|
10950
11329
|
help: {
|
|
@@ -11227,13 +11606,17 @@ function showPresentations$1(result, cwd, env) {
|
|
|
11227
11606
|
}
|
|
11228
11607
|
const projectShowCommand = defineCommand({
|
|
11229
11608
|
args: { positionals: { project: positional.optionalString({
|
|
11230
|
-
brief: "Project id or name (default: the project this directory is linked to)",
|
|
11609
|
+
brief: "Project id or name, or its address: @ and the app name, such as @shop (default: the project this directory is linked to)",
|
|
11231
11610
|
placeholder: "id-or-name"
|
|
11232
11611
|
}) } },
|
|
11233
11612
|
help: {
|
|
11234
11613
|
summary: "Show which Project this directory is linked to",
|
|
11235
11614
|
description: "Reports which Project this directory is linked to, or that it is not linked, with next steps. Pass an id or name to inspect any project without changing the local link.",
|
|
11236
|
-
examples: [
|
|
11615
|
+
examples: [
|
|
11616
|
+
"project show",
|
|
11617
|
+
"project show proj_123 --json",
|
|
11618
|
+
"project show @shop"
|
|
11619
|
+
]
|
|
11237
11620
|
},
|
|
11238
11621
|
needs: { credentials: true },
|
|
11239
11622
|
handler: async (args, ctx) => {
|
|
@@ -11241,7 +11624,7 @@ const projectShowCommand = defineCommand({
|
|
|
11241
11624
|
const inspected = await inspectProjectBinding({
|
|
11242
11625
|
context: operationContext(ctx),
|
|
11243
11626
|
workspace,
|
|
11244
|
-
explicitProject: args.positionals.project,
|
|
11627
|
+
explicitProject: (await resolveProjectPositional(ctx, args.positionals.project))?.ref,
|
|
11245
11628
|
listProjects: () => listWorkspaceProjects$1(ctx),
|
|
11246
11629
|
commandName: "project show"
|
|
11247
11630
|
});
|
|
@@ -11320,7 +11703,9 @@ async function resolveRecipientWorkspaceSession(workspaceRef, env = process.env,
|
|
|
11320
11703
|
//#endregion
|
|
11321
11704
|
//#region ../cli/src/commands/project/transfer.ts
|
|
11322
11705
|
/** The `project transfer` command. */
|
|
11323
|
-
|
|
11706
|
+
function consentQuestion(project, address) {
|
|
11707
|
+
return address ? `Transferring moves Project "${project.name}" (${project.id}) to another workspace and this workspace loses access, so it requires the exact project address.` : "Transferring moves the project to another workspace and this workspace loses access, so it requires the exact project id.";
|
|
11708
|
+
}
|
|
11324
11709
|
/** This CLI's command strings are `${CLI_NAME} …`; the legacy package-runner
|
|
11325
11710
|
* formatter does not port. */
|
|
11326
11711
|
const formatCommand = (args) => [CLI_NAME, ...args].join(" ");
|
|
@@ -11411,7 +11796,7 @@ function transferPresentations(result, toWorkspace) {
|
|
|
11411
11796
|
const projectTransferCommand = defineCommand({
|
|
11412
11797
|
args: {
|
|
11413
11798
|
positionals: { project: positional.string({
|
|
11414
|
-
brief: "Project id or name",
|
|
11799
|
+
brief: "Project id or name, or its address: @ and the app name, such as @shop",
|
|
11415
11800
|
placeholder: "id-or-name"
|
|
11416
11801
|
}) },
|
|
11417
11802
|
flags: {
|
|
@@ -11426,8 +11811,8 @@ const projectTransferCommand = defineCommand({
|
|
|
11426
11811
|
}
|
|
11427
11812
|
},
|
|
11428
11813
|
help: {
|
|
11429
|
-
summary: "Transfer a Project to another workspace after exact
|
|
11430
|
-
description: "Moves a project, with everything in it, out of the current workspace. Name the receiving workspace with --to-workspace when you are logged in to it too, or pass --recipient-token when someone else owns it. The exact project id is the consent token.",
|
|
11814
|
+
summary: "Transfer a Project to another workspace after exact confirmation",
|
|
11815
|
+
description: "Moves a project, with everything in it, out of the current workspace. Name the receiving workspace with --to-workspace when you are logged in to it too, or pass --recipient-token when someone else owns it. The exact project id is the consent token, or the address when you pass one.",
|
|
11431
11816
|
examples: ["project transfer proj_123 --to-workspace \"Prisma Labs\" --confirm proj_123", "project transfer proj_123 --recipient-token <token> --confirm proj_123"]
|
|
11432
11817
|
},
|
|
11433
11818
|
needs: { credentials: true },
|
|
@@ -11459,8 +11844,9 @@ const projectTransferCommand = defineCommand({
|
|
|
11459
11844
|
}
|
|
11460
11845
|
if (!toWorkspace && !recipientToken) throw transferRecipientRequiredError(formatCommand);
|
|
11461
11846
|
const projects = await listWorkspaceProjects$1(ctx);
|
|
11462
|
-
const
|
|
11463
|
-
|
|
11847
|
+
const subject = await resolveProjectPositional(ctx, args.positionals.project);
|
|
11848
|
+
const project = toProjectSummary(resolveProjectForSetup(subject?.ref ?? "", projects, workspace));
|
|
11849
|
+
await ctx.prompt.consent(consentQuestion(project, subject?.address), { token: subject?.address ?? project.id });
|
|
11464
11850
|
const recipient = await resolveRecipient(ctx, {
|
|
11465
11851
|
toWorkspace,
|
|
11466
11852
|
recipientToken
|
|
@@ -12393,20 +12779,10 @@ function domainWaitPresentations(result) {
|
|
|
12393
12779
|
* the project's default branch, else null when the project has no branches.
|
|
12394
12780
|
*/
|
|
12395
12781
|
async function resolveReadBranch(client, options) {
|
|
12396
|
-
const branches =
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
params: {
|
|
12401
|
-
path: { projectId: options.projectId },
|
|
12402
|
-
query: { cursor }
|
|
12403
|
-
},
|
|
12404
|
-
signal: options.signal
|
|
12405
|
-
});
|
|
12406
|
-
if (result.error || !result.data) throw new Error(`Failed to list branches for project ${options.projectId}: ${JSON.stringify(result.error)}`);
|
|
12407
|
-
branches.push(...result.data.data);
|
|
12408
|
-
cursor = result.data.pagination.hasMore ? result.data.pagination.nextCursor ?? void 0 : void 0;
|
|
12409
|
-
} while (cursor);
|
|
12782
|
+
const branches = await listProjectBranches(client, {
|
|
12783
|
+
projectId: options.projectId,
|
|
12784
|
+
signal: options.signal
|
|
12785
|
+
});
|
|
12410
12786
|
const chosen = branches.find((branch) => branch.gitName === options.branchName) ?? branches.find((branch) => branch.isDefault) ?? null;
|
|
12411
12787
|
return chosen ? {
|
|
12412
12788
|
id: chosen.id,
|
|
@@ -12419,6 +12795,11 @@ async function resolveReadBranch(client, options) {
|
|
|
12419
12795
|
/** A hostname's optional root dot, and one DNS label. */
|
|
12420
12796
|
const TRAILING_DOT = /\.$/;
|
|
12421
12797
|
const DNS_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
12798
|
+
/** The subject of every command that acts on one existing service. */
|
|
12799
|
+
const servicePositional = positional.optionalString({
|
|
12800
|
+
brief: "Service id or name, or its address: @shop.api (production) or @pr-42:shop.api (environment pr-42)",
|
|
12801
|
+
placeholder: "service"
|
|
12802
|
+
});
|
|
12422
12803
|
/** The workspace the run is acting as, from the credential the engine
|
|
12423
12804
|
* is authenticating with. A workspace with no name shows its id
|
|
12424
12805
|
* instead: the id is the only other identifier the user can act on,
|
|
@@ -12542,8 +12923,9 @@ async function listServices(ctx, provider, projectId, branchName) {
|
|
|
12542
12923
|
/** The service argument, required: service commands never infer,
|
|
12543
12924
|
* remember, or prompt for a target. */
|
|
12544
12925
|
function requireServiceArgument(serviceRef, commandName) {
|
|
12545
|
-
|
|
12546
|
-
|
|
12926
|
+
const trimmed = serviceRef?.trim();
|
|
12927
|
+
if (!trimmed) throw serviceTargetRequiredError(commandName);
|
|
12928
|
+
return trimmed;
|
|
12547
12929
|
}
|
|
12548
12930
|
/** Matches the service argument against the branch's services: the
|
|
12549
12931
|
* stable platform id is primary, the name is the fallback. An id
|
|
@@ -12667,14 +13049,25 @@ async function resolveServiceProjectState(ctx, options) {
|
|
|
12667
13049
|
}
|
|
12668
13050
|
/** The shared read flow for every command that acts on an existing
|
|
12669
13051
|
* service: project + branch resolution, service listing, and the
|
|
12670
|
-
* parameter-only service match.
|
|
13052
|
+
* parameter-only service match. A service address stands in for the
|
|
13053
|
+
* service id, `--project` and `--branch` together. */
|
|
12671
13054
|
async function resolveServiceReadState(ctx, options) {
|
|
12672
13055
|
const requested = requireServiceArgument(options.serviceName, options.commandName);
|
|
12673
|
-
const
|
|
12674
|
-
|
|
13056
|
+
const subject = await resolveBranchScopedSubject(ctx.api, "service", requested, ctx.signal, {
|
|
13057
|
+
project: options.projectRef,
|
|
13058
|
+
branch: options.branchName
|
|
13059
|
+
});
|
|
13060
|
+
const state = await resolveServiceProjectState(ctx, {
|
|
13061
|
+
commandName: options.commandName,
|
|
13062
|
+
...subject.project !== void 0 ? { projectRef: subject.project } : {},
|
|
13063
|
+
...subject.branch !== void 0 ? { branchName: subject.branch } : {}
|
|
13064
|
+
});
|
|
13065
|
+
const services = await listServices(ctx, state.provider, state.projectId, state.target.branch.name);
|
|
13066
|
+
const service = matchRequestedService(subject.ref, services, state.projectId);
|
|
12675
13067
|
return {
|
|
12676
13068
|
...state,
|
|
12677
|
-
service
|
|
13069
|
+
service,
|
|
13070
|
+
address: subject.match
|
|
12678
13071
|
};
|
|
12679
13072
|
}
|
|
12680
13073
|
async function resolveServiceDomainTarget(ctx, options) {
|
|
@@ -12878,8 +13271,12 @@ function destroyProgressReporter(ctx, serviceName) {
|
|
|
12878
13271
|
const serviceDeleteCommand = defineCommand({
|
|
12879
13272
|
help: {
|
|
12880
13273
|
summary: "Delete a service from one branch",
|
|
12881
|
-
description: "Removes the service from the targeted Branch only: its versions stop serving and its URL goes away. The same service on other branches is untouched.
|
|
12882
|
-
examples: [
|
|
13274
|
+
description: "Removes the service from the targeted Branch only: its versions stop serving and its URL goes away. The same service on other branches is untouched. The confirmation token is the service name, or the address when you pass one; pass it with --confirm to run non-interactively.",
|
|
13275
|
+
examples: [
|
|
13276
|
+
"service delete my-service",
|
|
13277
|
+
"service delete my-service --confirm my-service",
|
|
13278
|
+
"service delete @pr-42:shop.api --confirm @pr-42:shop.api"
|
|
13279
|
+
]
|
|
12883
13280
|
},
|
|
12884
13281
|
args: {
|
|
12885
13282
|
flags: {
|
|
@@ -12892,10 +13289,7 @@ const serviceDeleteCommand = defineCommand({
|
|
|
12892
13289
|
placeholder: "name"
|
|
12893
13290
|
})
|
|
12894
13291
|
},
|
|
12895
|
-
positionals: { service:
|
|
12896
|
-
brief: "Service id or name",
|
|
12897
|
-
placeholder: "service"
|
|
12898
|
-
}) }
|
|
13292
|
+
positionals: { service: servicePositional }
|
|
12899
13293
|
},
|
|
12900
13294
|
needs: { credentials: true },
|
|
12901
13295
|
handler: async (args, ctx) => {
|
|
@@ -12905,7 +13299,8 @@ const serviceDeleteCommand = defineCommand({
|
|
|
12905
13299
|
branchName: args.flags.branch,
|
|
12906
13300
|
commandName: "service delete"
|
|
12907
13301
|
});
|
|
12908
|
-
|
|
13302
|
+
const where = state.address ? ` (${state.service.id}) ${describeEnvironment(state.address)}` : "";
|
|
13303
|
+
if (!await ctx.prompt.consent(`Delete Service "${state.service.name}"${where} and every version it owns?`, { token: state.address?.text ?? state.service.name })) throw userCancelledError("Service deletion canceled");
|
|
12909
13304
|
ctx.report({
|
|
12910
13305
|
kind: "step-started",
|
|
12911
13306
|
step: "delete"
|
|
@@ -13474,14 +13869,12 @@ const serviceLogsCommand = defineSessionCommand({
|
|
|
13474
13869
|
"service logs my-service",
|
|
13475
13870
|
"service logs my-service --tail 500",
|
|
13476
13871
|
"service logs my-service --follow",
|
|
13872
|
+
"service logs @pr-42:shop.api",
|
|
13477
13873
|
"service logs --version-id cpv_123 --from-start"
|
|
13478
13874
|
]
|
|
13479
13875
|
},
|
|
13480
13876
|
args: {
|
|
13481
|
-
positionals: { service:
|
|
13482
|
-
brief: "Service id or name",
|
|
13483
|
-
placeholder: "service"
|
|
13484
|
-
}) },
|
|
13877
|
+
positionals: { service: servicePositional },
|
|
13485
13878
|
flags: {
|
|
13486
13879
|
project: flag.string({
|
|
13487
13880
|
brief: "Project id or name",
|
|
@@ -13545,10 +13938,7 @@ const serviceOpenCommand = defineCommand({
|
|
|
13545
13938
|
placeholder: "name"
|
|
13546
13939
|
})
|
|
13547
13940
|
},
|
|
13548
|
-
positionals: { service:
|
|
13549
|
-
brief: "Service id or name",
|
|
13550
|
-
placeholder: "service"
|
|
13551
|
-
}) }
|
|
13941
|
+
positionals: { service: servicePositional }
|
|
13552
13942
|
},
|
|
13553
13943
|
needs: { credentials: true },
|
|
13554
13944
|
handler: async (args, ctx) => {
|
|
@@ -13599,10 +13989,7 @@ const serviceShowCommand = defineCommand({
|
|
|
13599
13989
|
placeholder: "name"
|
|
13600
13990
|
})
|
|
13601
13991
|
},
|
|
13602
|
-
positionals: { service:
|
|
13603
|
-
brief: "Service id or name",
|
|
13604
|
-
placeholder: "service"
|
|
13605
|
-
}) }
|
|
13992
|
+
positionals: { service: servicePositional }
|
|
13606
13993
|
},
|
|
13607
13994
|
needs: { credentials: true },
|
|
13608
13995
|
handler: async (args, ctx) => {
|
|
@@ -13693,10 +14080,7 @@ const serviceVersionListCommand = defineCommand({
|
|
|
13693
14080
|
placeholder: "name"
|
|
13694
14081
|
})
|
|
13695
14082
|
},
|
|
13696
|
-
positionals: { service:
|
|
13697
|
-
brief: "Service id or name",
|
|
13698
|
-
placeholder: "service"
|
|
13699
|
-
}) }
|
|
14083
|
+
positionals: { service: servicePositional }
|
|
13700
14084
|
},
|
|
13701
14085
|
needs: { credentials: true },
|
|
13702
14086
|
handler: async (args, ctx) => {
|
|
@@ -13808,10 +14192,7 @@ const serviceVersionRollbackCommand = defineCommand({
|
|
|
13808
14192
|
placeholder: "version"
|
|
13809
14193
|
})
|
|
13810
14194
|
},
|
|
13811
|
-
positionals: { service:
|
|
13812
|
-
brief: "Service id or name",
|
|
13813
|
-
placeholder: "service"
|
|
13814
|
-
}) }
|
|
14195
|
+
positionals: { service: servicePositional }
|
|
13815
14196
|
},
|
|
13816
14197
|
needs: { credentials: true },
|
|
13817
14198
|
handler: async (args, ctx) => {
|
|
@@ -14161,7 +14542,7 @@ const cliGroups = {
|
|
|
14161
14542
|
},
|
|
14162
14543
|
project: {
|
|
14163
14544
|
brief: "Manage Prisma Platform projects. CRUD, link a directory, transfer ownership, manage environment variables",
|
|
14164
|
-
description: "A Project groups one product or codebase. It is the child of a workspace and the parent of Branches: isolated environments, one per Git branch, each holding its own services, databases, and buckets. 'Linking' connects a local directory to a Project: the link is stored locally, and every project-scoped command run in that directory targets the linked project unless --project names another. 'create' links automatically; 'link' points a directory at an existing Project; 'show' reports the link.",
|
|
14545
|
+
description: "A Project groups one product or codebase. It is the child of a workspace and the parent of Branches: isolated environments, one per Git branch, each holding its own services, databases, and buckets. 'Linking' connects a local directory to a Project: the link is stored locally, and every project-scoped command run in that directory targets the linked project unless --project names another. 'create' links automatically; 'link' points a directory at an existing Project; 'show' reports the link. Name a Project by its id, its name, or its address: @ and the app name, such as @shop. A Project spans every branch, so its address takes no environment.",
|
|
14165
14546
|
workflow: [
|
|
14166
14547
|
{
|
|
14167
14548
|
run: "project create my-app",
|
|
@@ -14183,7 +14564,7 @@ const cliGroups = {
|
|
|
14183
14564
|
},
|
|
14184
14565
|
postgres: {
|
|
14185
14566
|
brief: "Manage Prisma Postgres databases. CRUD, usage metrics, backups, and connection credentials",
|
|
14186
|
-
description: "Databases are branch-bound: each belongs to a Branch, the isolated environment for one Git branch of a project, so commands take --branch to target one.
|
|
14567
|
+
description: "Databases are branch-bound: each belongs to a Branch, the isolated environment for one Git branch of a project, so commands take --branch to target one. Name a database by its id (db_...), its name, or its address (@shop.db, @pr-42:shop.db). The address is the name the app gave it, such as shop.db; the part before ':' is the environment the app was deployed to: its branch, or production when left out. Connection URLs are secrets that print exactly once, at create or rotate; nothing shows them again. 'backup' restores platform-taken backups, and 'connection' manages per-consumer credentials.",
|
|
14187
14568
|
workflow: [
|
|
14188
14569
|
{
|
|
14189
14570
|
run: "postgres create app-db",
|
|
@@ -14201,7 +14582,7 @@ const cliGroups = {
|
|
|
14201
14582
|
},
|
|
14202
14583
|
"postgres backup": {
|
|
14203
14584
|
brief: "Inspect and restore database backups. The platform takes them automatically",
|
|
14204
|
-
description: "The platform takes backups automatically; there is no backup-create command. Restore replaces a database's current state with a backup's contents after exact id
|
|
14585
|
+
description: "The platform takes backups automatically; there is no backup-create command. Restore replaces a database's current state with a backup's contents after exact confirmation of the database's id, or its address when you name it by one."
|
|
14205
14586
|
},
|
|
14206
14587
|
"postgres connection": {
|
|
14207
14588
|
brief: "Manage database connection credentials. Create, rotate, and revoke per-consumer connection URLs",
|
|
@@ -14209,7 +14590,7 @@ const cliGroups = {
|
|
|
14209
14590
|
},
|
|
14210
14591
|
bucket: {
|
|
14211
14592
|
brief: "Manage S3-compatible object-store buckets for a project. CRUD operations and access keys",
|
|
14212
|
-
description: "A bucket is blob storage for files and uploads, bound to one Branch of a project and reachable through the standard S3 API. Access goes through S3-compatible keys minted per consumer with 'bucket key create', which prints credentials (endpoint, key id, secret) exactly once.",
|
|
14593
|
+
description: "A bucket is blob storage for files and uploads, bound to one Branch of a project and reachable through the standard S3 API. Access goes through S3-compatible keys minted per consumer with 'bucket key create', which prints credentials (endpoint, key id, secret) exactly once. Name a bucket by its id or its address (@shop.files, @pr-42:shop.files). The address is the name the app gave it, such as shop.files; the part before ':' is the environment the app was deployed to: its branch, or production when left out.",
|
|
14213
14594
|
workflow: [{
|
|
14214
14595
|
run: "bucket create --name uploads",
|
|
14215
14596
|
brief: "Create a bucket in the branch"
|
|
@@ -14232,7 +14613,7 @@ const cliGroups = {
|
|
|
14232
14613
|
},
|
|
14233
14614
|
service: {
|
|
14234
14615
|
brief: "Manage deployed services. Logs, versions, promote and rollback releases, custom domains",
|
|
14235
|
-
description: "A service is one HTTP application (a frontend or a backend) deployed on a Branch. Every deploy produces an immutable service version; at most one serves traffic at a time. The 'version' subcommands move which one that is: promote releases a preview build into production, rollback returns production to a previous version without rebuilding. 'logs' reads and streams output, and 'domain' attaches hostnames you own.",
|
|
14616
|
+
description: "A service is one HTTP application (a frontend or a backend) deployed on a Branch. Every deploy produces an immutable service version; at most one serves traffic at a time. The 'version' subcommands move which one that is: promote releases a preview build into production, rollback returns production to a previous version without rebuilding. 'logs' reads and streams output, and 'domain' attaches hostnames you own. Name a service by its id, its name, or its address (@shop.api, @pr-42:shop.api). The address is the name the app gave it, such as shop.api; the part before ':' is the environment the app was deployed to: its branch, or production when left out.",
|
|
14236
14617
|
workflow: [
|
|
14237
14618
|
{
|
|
14238
14619
|
run: "service logs my-api --follow",
|