neon 8.21.0 → 8.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +24 -1
  2. package/dist/_chunks/{api_keys-6Xnxl7a8.js → api_keys-CTFHd5m_.js} +27 -8
  3. package/dist/_chunks/{checkout-CNBIS3gA.js → checkout-BpOcFaAi.js} +3 -3
  4. package/dist/_chunks/{claim-DhV0f_5o.js → claim-B3tMeMuo.js} +1 -1
  5. package/dist/_chunks/{config-CgtJH8xE.js → config-BjCm5cfr.js} +1 -1
  6. package/dist/_chunks/{deploy-Bs5gmi4Q.js → deploy-DmEEhux0.js} +1 -1
  7. package/dist/_chunks/{dev-DxiIp4c9.js → dev-DlUJFzRs.js} +3 -3
  8. package/dist/_chunks/{git-DRUZBCmZ.js → git-j6xSVo3e.js} +2 -2
  9. package/dist/_chunks/{link-CNO-HxHN.js → link-nAiuWKfg.js} +2 -2
  10. package/dist/_chunks/orgs-BrvAWM8Z.js +292 -0
  11. package/dist/_chunks/{postgres-BkJPZRov.js → postgres-BhR1vUFM.js} +1 -1
  12. package/dist/_chunks/{profile-BAlM625e.js → profile-CArcjyS4.js} +1 -1
  13. package/dist/_chunks/{roles-BXGtPGjv.js → roles-BELJqjTy.js} +45 -3
  14. package/dist/_chunks/{status-BlrzeKyA.js → status-BC4XXuuE.js} +1 -1
  15. package/dist/api.js +11 -1
  16. package/dist/claimable/api.js +5 -4
  17. package/dist/commands/api_keys.js +1 -1
  18. package/dist/commands/checkout.js +1 -1
  19. package/dist/commands/claim.js +1 -1
  20. package/dist/commands/config.js +1 -1
  21. package/dist/commands/deploy.js +1 -1
  22. package/dist/commands/dev.js +1 -1
  23. package/dist/commands/env.js +1 -1
  24. package/dist/commands/functions_new.js +1 -1
  25. package/dist/commands/git.js +1 -1
  26. package/dist/commands/index.js +14 -14
  27. package/dist/commands/link.js +1 -1
  28. package/dist/commands/orgs.js +1 -1
  29. package/dist/commands/postgres.js +1 -1
  30. package/dist/commands/profile.js +1 -1
  31. package/dist/commands/roles.js +1 -1
  32. package/dist/commands/status.js +1 -1
  33. package/dist/commands/subscribe.js +1 -1
  34. package/dist/custom_domains_api.js +3 -2
  35. package/dist/functions_api.js +5 -5
  36. package/dist/init/auth.js +1 -1
  37. package/dist/init/deploy.js +1 -1
  38. package/dist/init/link.js +1 -1
  39. package/dist/init/run.js +3 -3
  40. package/dist/mcp/mint.js +1 -1
  41. package/dist/neon_client.js +5 -3
  42. package/dist/storage_api.js +6 -5
  43. package/package.json +6 -6
  44. package/dist/_chunks/orgs-Dpbr-K0A.js +0 -51
  45. package/dist/_chunks/{env-BtG4vH55.js → env-BOt9AZ1j.js} +1 -1
package/README.md CHANGED
@@ -1518,6 +1518,28 @@ Id Name Project Created At Last Used At Last
1518
1518
 
1519
1519
  `last_used_at` and `last_used_from_addr` are how you spot a key worth revoking.
1520
1520
 
1521
+ ## Organizations (`orgs`)
1522
+
1523
+ ```bash
1524
+ neon orgs list
1525
+ neon orgs get # the --org-id, linked, or only organization
1526
+ neon orgs members list
1527
+ neon orgs members get <member-id>
1528
+ neon orgs members update <member-id> --role admin
1529
+ neon orgs members remove <member-id>
1530
+ neon orgs invitations list
1531
+ neon orgs invitations create --email dev@example.com --email ops@example.com --role member
1532
+ neon orgs spending-limit get
1533
+ neon orgs spending-limit set 500 # US dollars per month
1534
+ neon orgs spending-limit delete
1535
+ ```
1536
+
1537
+ Every subcommand except `list` takes `--org-id`. Without it, the CLI uses the organization in `.neon`, then the only organization you belong to, and otherwise fails naming `--org-id`. `orgs get` also takes the id as a positional argument.
1538
+
1539
+ `members update` and `invitations create` take `--role`: `admin`, `member`, `editor`, `viewer`, or `collaborator`. The API decides which of them an organization accepts. Every invitee is emailed, and anyone who already has a Neon account joins immediately.
1540
+
1541
+ `spending-limit set` takes dollars with up to two decimals and sends cents. The limit sends emails at 80% and 100% and does not suspend computes. JSON and YAML output keep the API's `spending_limit_cents`, and `members list` keeps the API's `{ member, user }` items. Role changes, member removal, and the spending limit writes need an organization admin.
1542
+
1521
1543
  ## Commands
1522
1544
 
1523
1545
  | Command | Subcommands | Description |
@@ -1527,6 +1549,7 @@ Id Name Project Created At Last Used At Last
1527
1549
  | profile | `list`, `create`, `rotate-key`, `remove` | Manage named sets of credentials |
1528
1550
  | api-keys | `list`, `create`, `revoke` | Manage API keys |
1529
1551
  | api | | Call any Neon API route |
1552
+ | orgs (`org`) | `list`, `get`, `members`, `invitations`, `spending-limit` | Manage organizations |
1530
1553
  | [projects](https://neon.com/docs/reference/cli-projects) | `list`, `create`, `update`, `delete`, `get` | Manage projects |
1531
1554
  | [ip-allow](https://neon.com/docs/reference/cli-ip-allow) | `list`, `add`, `remove`, `reset` | Manage IP Allow |
1532
1555
  | [me](https://neon.com/docs/reference/cli-me) | | Show current user |
@@ -1534,7 +1557,7 @@ Id Name Project Created At Last Used At Last
1534
1557
  | postgres (`pg`, `lakebase`) | `computes`, `databases`, `roles`, `connection-string`, `psql` | Manage Postgres and connect to it |
1535
1558
  | [databases](https://neon.com/docs/reference/cli-databases) | `list`, `create`, `delete` | Manage databases |
1536
1559
  | function | `deploy`, `list`, `get`, `delete`, `domains list`, `domains register`, `domains delete` | Manage Neon Functions |
1537
- | [roles](https://neon.com/docs/reference/cli-roles) | `list`, `create`, `delete` | Manage roles |
1560
+ | [roles](https://neon.com/docs/reference/cli-roles) | `list`, `get`, `create`, `reset-password`, `delete` | Manage roles |
1538
1561
  | [operations](https://neon.com/docs/reference/cli-operations) | `list`, `get` | Manage operations |
1539
1562
  | logs | `query`, `fields`, `field-values` | Query branch logs (Beta) |
1540
1563
  | inspect | `db stalled-queries` | Inspect Postgres diagnostics |
@@ -109,7 +109,7 @@ const handler = (args) => args;
109
109
  const list = async (props) => {
110
110
  const out = writer(props);
111
111
  if (props.orgId) {
112
- const { data } = await props.apiClient.listOrgApiKeys(props.orgId);
112
+ const data = await (await orgKeys(props)).list(props.orgId);
113
113
  if (props.output === "table") out.write(data.map((key) => ({
114
114
  ...key,
115
115
  project: key.project_id ?? ALL_PROJECTS
@@ -148,7 +148,7 @@ const create = async (props) => {
148
148
  return;
149
149
  }
150
150
  if (!projectId && orgId) {
151
- const { data } = await props.apiClient.createOrgApiKey(orgId, { key_name: name });
151
+ const data = await (await orgKeys(props)).create(orgId, { keyName: name });
152
152
  await assertUsable(props, data, {
153
153
  orgId,
154
154
  expect: NO_PROJECT
@@ -159,9 +159,9 @@ const create = async (props) => {
159
159
  }
160
160
  const scopeTo = projectId;
161
161
  const resolvedOrgId = await orgIdForProject(props.apiClient, scopeTo);
162
- const { data } = await props.apiClient.createOrgApiKey(resolvedOrgId, {
163
- key_name: name,
164
- project_id: scopeTo
162
+ const data = await (await orgKeys(props)).create(resolvedOrgId, {
163
+ keyName: name,
164
+ projectId: scopeTo
165
165
  });
166
166
  await assertUsable(props, data, {
167
167
  orgId: resolvedOrgId,
@@ -170,6 +170,25 @@ const create = async (props) => {
170
170
  report(props, data, CREATE_FIELDS_SCOPED, CREATE_TABLE_FIELDS_SCOPED);
171
171
  log.info("Limited to %s: it cannot create projects, mint API keys, or read any other project. It can still change and delete everything inside that project.", scopeTo);
172
172
  };
173
+ /** Organization keys through `@neon/sdk`, failing with the CLI's `NeonApiError`. */
174
+ const orgKeys = async (props) => {
175
+ const { fromSdkError, getNeonClient } = await import("../neon_client.js");
176
+ const keys = getNeonClient(props).organizations.apiKeys;
177
+ const fail = (error) => {
178
+ throw fromSdkError(error, props.apiHost);
179
+ };
180
+ return {
181
+ list: (orgId) => keys.list({ orgId }).catch(fail),
182
+ create: (orgId, params) => keys.create({
183
+ orgId,
184
+ ...params
185
+ }).catch(fail),
186
+ revoke: (orgId, keyId) => keys.revoke({
187
+ orgId,
188
+ keyId
189
+ }).catch(fail)
190
+ };
191
+ };
173
192
  /**
174
193
  * The key is shown only once, so human output keeps it on a selectable line.
175
194
  * Structured output keeps it in the object for scripts.
@@ -229,7 +248,7 @@ const assertUsable = async (props, data, scope) => {
229
248
  */
230
249
  const revokeOrExplain = async (props) => {
231
250
  try {
232
- return props.orgId ? await props.apiClient.revokeOrgApiKey(props.orgId, props.id) : await props.apiClient.revokeApiKey(props.id);
251
+ return props.orgId ? await (await orgKeys(props)).revoke(props.orgId, props.id) : (await props.apiClient.revokeApiKey(props.id)).data;
233
252
  } catch (err) {
234
253
  if (isNeonApiError(err) && err.status === 404) throw new Error(props.orgId ? `No API key with id ${props.id} in ${props.orgId}. If it is one of your account's own keys, drop --org-id.` : `No account API key with id ${props.id}. If it belongs to an organization, pass --org-id. Organization keys are not visible to your account.`);
235
254
  throw err;
@@ -239,7 +258,7 @@ const revokeOrExplain = async (props) => {
239
258
  const withdraw = async (props, orgId, keyId) => {
240
259
  if (!Number.isSafeInteger(keyId) || keyId <= 0) return false;
241
260
  try {
242
- const { data } = orgId ? await props.apiClient.revokeOrgApiKey(orgId, keyId) : await props.apiClient.revokeApiKey(keyId);
261
+ const data = orgId ? await (await orgKeys(props)).revoke(orgId, keyId) : (await props.apiClient.revokeApiKey(keyId)).data;
243
262
  return data.revoked === true && data.id === keyId;
244
263
  } catch (err) {
245
264
  log.warning("Failed to revoke API key %d: %s", keyId, err instanceof Error ? err.message : String(err));
@@ -248,7 +267,7 @@ const withdraw = async (props, orgId, keyId) => {
248
267
  };
249
268
  const revoke = async (props) => {
250
269
  const out = writer(props);
251
- const { data } = await revokeOrExplain(props);
270
+ const data = await revokeOrExplain(props);
252
271
  out.write(data, {
253
272
  fields: [
254
273
  "id",
@@ -11,9 +11,9 @@ import { looksLikeBranchId } from "../utils/formats.js";
11
11
  import { fillSingleProject, listAllProjectBranches } from "../utils/enrichers.js";
12
12
  import { buildCheckoutEvent, readGitContext } from "../utils/git.js";
13
13
  import { buildHookBranch, loadHookConfig, resolveHookEnv, runCheckoutAfterHook, runCheckoutBeforeHook, runCreateAfterHook, runCreateBeforeHook } from "../utils/hooks.js";
14
- import { n as autoPullEnvAfterPin } from "./env-BtG4vH55.js";
15
- import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-CgtJH8xE.js";
16
- import { i as handler$1 } from "./link-CNO-HxHN.js";
14
+ import { n as autoPullEnvAfterPin } from "./env-BOt9AZ1j.js";
15
+ import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-BjCm5cfr.js";
16
+ import { i as handler$1 } from "./link-nAiuWKfg.js";
17
17
  import chalk from "chalk";
18
18
  import prompts from "prompts";
19
19
  // src/commands/checkout.ts
@@ -12,7 +12,7 @@ import { projectConfigPath } from "../project.js";
12
12
  import { resolveEnvFilePath } from "../env_file.js";
13
13
  import { writer } from "../writer.js";
14
14
  import { noPassthrough } from "../utils/flags.js";
15
- import { c as pull } from "./env-BtG4vH55.js";
15
+ import { c as pull } from "./env-BOt9AZ1j.js";
16
16
  import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
17
17
  import open from "open";
18
18
  import prompts from "prompts";
@@ -26,7 +26,7 @@ import { readGitContext } from "../utils/git.js";
26
26
  import { resolveHookEnv, runDeployAfterHook, runDeployBeforeHook } from "../utils/hooks.js";
27
27
  import { pickServicesInteractively } from "../utils/service_picker.js";
28
28
  import { zipBundle } from "../utils/zip.js";
29
- import { n as autoPullEnvAfterPin } from "./env-BtG4vH55.js";
29
+ import { n as autoPullEnvAfterPin } from "./env-BOt9AZ1j.js";
30
30
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
31
31
  import { dirname, join, relative, resolve } from "node:path";
32
32
  import chalk from "chalk";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { fillSingleProject } from "../utils/enrichers.js";
3
- import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-CgtJH8xE.js";
3
+ import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-BjCm5cfr.js";
4
4
  import { DEPLOY_COMMANDS_EPILOGUE } from "../commands/deploy_help.js";
5
5
  // src/commands/deploy.ts
6
6
  var deploy_exports = /* @__PURE__ */ __exportAll({
@@ -4,12 +4,12 @@ import { isClaimableEnvTarget } from "../claimable/state.js";
4
4
  import { getCliName } from "../utils/cli_name.js";
5
5
  import { defaultDevEnvFiles, readEnvFile, resolveEnvFilePath } from "../env_file.js";
6
6
  import { l as functionBaseUrlKey } from "./env-JgoSsmyt.js";
7
- import { branchIdResolve } from "../utils/enrichers.js";
8
- import { bundleEntry } from "../utils/esbuild.js";
9
7
  import { a as resolveDevEnv } from "./env-CIFMBEon.js";
10
- import { f as envFlag } from "./config-CgtJH8xE.js";
11
8
  import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
12
9
  import { resolveWatchInputs } from "../dev/inputs.js";
10
+ import { branchIdResolve } from "../utils/enrichers.js";
11
+ import { bundleEntry } from "../utils/esbuild.js";
12
+ import { f as envFlag } from "./config-BjCm5cfr.js";
13
13
  import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
14
14
  import { basename, dirname, join, relative, resolve } from "node:path";
15
15
  import { fileURLToPath } from "node:url";
@@ -5,8 +5,8 @@ import { CONTEXT_FILE, contextBranch, gitBranchMap, gitBranchMapping, isUnfollow
5
5
  import { writer } from "../writer.js";
6
6
  import { neonSafeBranchName } from "../utils/branch_name.js";
7
7
  import { currentGitBranch, gitPull, gitRepoRoot, hasUpstream, installPostCheckoutHook, isGitRepo, isManagedHook, localGitBranches, postCheckoutHookPath, readGitContext, removePostCheckoutHook } from "../utils/git.js";
8
- import { o as quoteFlagValue } from "./link-CNO-HxHN.js";
9
- import { o as handler$1 } from "./checkout-CNBIS3gA.js";
8
+ import { o as quoteFlagValue } from "./link-nAiuWKfg.js";
9
+ import { o as handler$1 } from "./checkout-BpOcFaAi.js";
10
10
  import { existsSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import chalk from "chalk";
@@ -13,8 +13,8 @@ import { writer } from "../writer.js";
13
13
  import { createBranch, pickBranchInteractively } from "../utils/branch_picker.js";
14
14
  import { looksLikeBranchId } from "../utils/formats.js";
15
15
  import { listAllProjectBranches } from "../utils/enrichers.js";
16
- import { n as autoPullEnvAfterPin } from "./env-BtG4vH55.js";
17
- import { h as initCmd } from "./config-CgtJH8xE.js";
16
+ import { n as autoPullEnvAfterPin } from "./env-BOt9AZ1j.js";
17
+ import { h as initCmd } from "./config-BjCm5cfr.js";
18
18
  import { formatLinkSummary } from "../commands/link_output.js";
19
19
  import { r as REGIONS } from "./projects-a3X4OFEJ.js";
20
20
  import prompts from "prompts";
@@ -0,0 +1,292 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
+ import { log } from "../log.js";
3
+ import { readContextFile } from "../context.js";
4
+ import { writer } from "../writer.js";
5
+ import { noPassthrough, single } from "../utils/flags.js";
6
+ import chalk from "chalk";
7
+ // src/commands/orgs.ts
8
+ var orgs_exports = /* @__PURE__ */ __exportAll({
9
+ aliases: () => aliases,
10
+ builder: () => builder,
11
+ command: () => command,
12
+ describe: () => describe,
13
+ handler: () => handler,
14
+ parseUsdCents: () => parseUsdCents,
15
+ planName: () => planName
16
+ });
17
+ const ORG_FIELDS = [
18
+ "id",
19
+ "name",
20
+ "plan"
21
+ ];
22
+ const ORG_DETAIL_FIELDS = [
23
+ "id",
24
+ "name",
25
+ "handle",
26
+ "plan",
27
+ "created_at"
28
+ ];
29
+ const MEMBER_TABLE_FIELDS = [
30
+ "id",
31
+ "email",
32
+ "role",
33
+ "joined_at"
34
+ ];
35
+ const MEMBER_FIELDS = [
36
+ "id",
37
+ "user_id",
38
+ "role",
39
+ "joined_at"
40
+ ];
41
+ const INVITATION_FIELDS = [
42
+ "id",
43
+ "email",
44
+ "role",
45
+ "invited_at"
46
+ ];
47
+ const SPENDING_LIMIT_TABLE_FIELDS = ["monthly_limit"];
48
+ const MEMBER_ROLES = [
49
+ "admin",
50
+ "member",
51
+ "editor",
52
+ "viewer",
53
+ "collaborator"
54
+ ];
55
+ const orgIdOption = { "org-id": {
56
+ describe: "Organization ID. Defaults to the linked organization, or your only one",
57
+ type: "string",
58
+ coerce: single("org-id")
59
+ } };
60
+ /**
61
+ * An empty, negated, misspelled, or `--`-separated `--org-id` must fail rather than fall
62
+ * back to the linked organization: these commands change members, invitations, and billing.
63
+ */
64
+ const guarded = (yargs) => yargs.strict().check(noPassthrough("orgs"));
65
+ const roleOption = (describe) => ({ role: {
66
+ describe,
67
+ type: "string",
68
+ choices: MEMBER_ROLES,
69
+ demandOption: true
70
+ } });
71
+ const command = "orgs";
72
+ const describe = "Manage organizations";
73
+ const aliases = ["org"];
74
+ const builder = (argv) => {
75
+ return argv.usage("$0 orgs <sub-command> [options]").command("list", "List organizations", (yargs) => yargs, async (args) => {
76
+ await list(args);
77
+ }).command("get [id]", "Show an organization", (yargs) => yargs.positional("id", {
78
+ describe: "Organization ID. Defaults to --org-id, the linked organization, or your only one",
79
+ type: "string"
80
+ }).options(orgIdOption).strict().check(noPassthrough("orgs")), async (args) => await get(args)).command("members", "Manage organization members", (yargs) => yargs.usage("$0 orgs members <sub-command> [options]").options(orgIdOption).command("list", "List members and their organization role", guarded, async (args) => await listMembers(args)).command("get <member-id>", "Show a member", (yargs) => guarded(yargs.positional("member-id", {
81
+ describe: "Member ID, from `orgs members list`",
82
+ type: "string"
83
+ })), async (args) => await getMember(args)).command("update <member-id>", "Change a member's organization role. Admin only", (yargs) => yargs.positional("member-id", {
84
+ describe: "Member ID, from `orgs members list`",
85
+ type: "string"
86
+ }).options(roleOption("The new organization role")).strict().check(noPassthrough("orgs")), async (args) => await updateMember(args)).command("remove <member-id>", "Remove a member from the organization. Admin only", (yargs) => guarded(yargs.positional("member-id", {
87
+ describe: "Member ID, from `orgs members list`",
88
+ type: "string"
89
+ })), async (args) => await removeMember(args))).command("invitations", "Manage organization invitations", (yargs) => yargs.usage("$0 orgs invitations <sub-command> [options]").options(orgIdOption).command("list", "List invitations", guarded, async (args) => await listInvitations(args)).command("create", "Invite people by email. Each one is emailed, and anyone with a Neon account joins immediately", (yargs) => yargs.options({
90
+ email: {
91
+ describe: "Email address to invite. Repeat to invite several",
92
+ type: "string",
93
+ array: true,
94
+ demandOption: true
95
+ },
96
+ ...roleOption("The organization role every invitee gets")
97
+ }).strict().check(noPassthrough("orgs")), async (args) => await createInvitations(args))).command("spending-limit", "Manage the organization's monthly spending limit (Launch and Scale plans)", (yargs) => yargs.usage("$0 orgs spending-limit <sub-command> [options]").options(orgIdOption).command("get", "Show the monthly spending limit", guarded, async (args) => await getSpendingLimit(args)).command("set <usd>", "Set the monthly spending limit. Neon emails at 80% and 100% and keeps computes running. Admin only", (yargs) => guarded(yargs.positional("usd", {
98
+ describe: "Monthly limit in US dollars, e.g. 500 or 250.50",
99
+ type: "string"
100
+ })), async (args) => await setSpendingLimit(args)).command("delete", "Remove the monthly spending limit. Admin only", guarded, async (args) => await deleteSpendingLimit(args)));
101
+ };
102
+ const handler = (args) => {
103
+ return args;
104
+ };
105
+ const list = async (props) => {
106
+ const out = writer(props);
107
+ const { data: { organizations } } = await props.apiClient.getCurrentUserOrganizations();
108
+ const current = readContextFile(props.contextFile).orgId;
109
+ out.write(organizations, {
110
+ fields: ORG_FIELDS,
111
+ title: "Organizations",
112
+ emptyMessage: "You are not a member of any organization.",
113
+ renderColumns: {
114
+ plan: (org) => planName(org.plan),
115
+ name: (org) => org.id === current ? `${chalk.green("[current]")} ${org.name}` : org.name
116
+ }
117
+ });
118
+ out.end();
119
+ };
120
+ /** The SDK client, its error mapper, and the org from the flag, `.neon`, or the only one. */
121
+ const sdk = async (props) => {
122
+ const [{ fromSdkError, getNeonClient }, { fillSingleOrg }] = await Promise.all([import("../neon_client.js"), import("../utils/enrichers.js")]);
123
+ const { orgId } = await fillSingleOrg({
124
+ ...props,
125
+ orgId: props.orgId ?? ""
126
+ });
127
+ return {
128
+ neon: getNeonClient(props),
129
+ orgId,
130
+ fail: (error) => fromSdkError(error, props.apiHost)
131
+ };
132
+ };
133
+ const get = async (props) => {
134
+ const { neon, fail, orgId } = await sdk({
135
+ ...props,
136
+ orgId: props.id ?? props.orgId
137
+ });
138
+ const org = await neon.organizations.get({ orgId }).catch((error) => {
139
+ throw fail(error);
140
+ });
141
+ writer(props).end(org, {
142
+ fields: ORG_DETAIL_FIELDS,
143
+ renderColumns: { plan: (value) => planName(value.plan) }
144
+ });
145
+ };
146
+ const listMembers = async (props) => {
147
+ const { neon, fail, orgId } = await sdk(props);
148
+ const members = await neon.organizations.members.list({ orgId }).all().catch((error) => {
149
+ throw fail(error);
150
+ });
151
+ const config = {
152
+ title: `Members of ${orgId}`,
153
+ emptyMessage: `No members in ${orgId}.`
154
+ };
155
+ if (props.output === "table") {
156
+ writer(props).end(members.map(memberRow), {
157
+ fields: MEMBER_TABLE_FIELDS,
158
+ ...config
159
+ });
160
+ return;
161
+ }
162
+ writer(props).end(members, {
163
+ fields: [],
164
+ ...config
165
+ });
166
+ };
167
+ const memberRow = ({ member, user }) => ({
168
+ id: member.id,
169
+ email: user.email,
170
+ role: member.role,
171
+ joined_at: member.joined_at
172
+ });
173
+ const getMember = async (props) => {
174
+ const { neon, fail, orgId } = await sdk(props);
175
+ const member = await neon.organizations.members.get({
176
+ orgId,
177
+ memberId: props.memberId
178
+ }).catch((error) => {
179
+ throw fail(error);
180
+ });
181
+ writeMember(props, member);
182
+ };
183
+ const updateMember = async (props) => {
184
+ const { neon, fail, orgId } = await sdk(props);
185
+ const member = await neon.organizations.members.update({
186
+ orgId,
187
+ memberId: props.memberId,
188
+ role: props.role
189
+ }).catch((error) => {
190
+ throw fail(error);
191
+ });
192
+ writeMember(props, member);
193
+ };
194
+ const writeMember = (props, member) => {
195
+ writer(props).end(member, { fields: MEMBER_FIELDS });
196
+ };
197
+ const removeMember = async (props) => {
198
+ const { neon, fail, orgId } = await sdk(props);
199
+ await neon.organizations.members.remove({
200
+ orgId,
201
+ memberId: props.memberId
202
+ }).catch((error) => {
203
+ throw fail(error);
204
+ });
205
+ log.info(`Member ${props.memberId} removed from ${orgId}`);
206
+ };
207
+ const listInvitations = async (props) => {
208
+ const { neon, fail, orgId } = await sdk(props);
209
+ const invitations = await neon.organizations.invitations.list({ orgId }).catch((error) => {
210
+ throw fail(error);
211
+ });
212
+ writeInvitations(props, orgId, invitations);
213
+ };
214
+ const createInvitations = async (props) => {
215
+ const { neon, fail, orgId } = await sdk(props);
216
+ const invitations = await neon.organizations.invitations.create({
217
+ orgId,
218
+ invitations: props.email.map((email) => ({
219
+ email,
220
+ role: props.role
221
+ }))
222
+ }).catch((error) => {
223
+ throw fail(error);
224
+ });
225
+ writeInvitations(props, orgId, invitations);
226
+ };
227
+ const writeInvitations = (props, orgId, invitations) => {
228
+ writer(props).end(invitations, {
229
+ fields: INVITATION_FIELDS,
230
+ title: `Invitations to ${orgId}`,
231
+ emptyMessage: `No invitations to ${orgId}.`
232
+ });
233
+ };
234
+ const getSpendingLimit = async (props) => {
235
+ const { neon, fail, orgId } = await sdk(props);
236
+ const limit = await neon.organizations.spendingLimit.get({ orgId }).catch((error) => {
237
+ throw fail(error);
238
+ });
239
+ writeSpendingLimit(props, orgId, limit);
240
+ };
241
+ const setSpendingLimit = async (props) => {
242
+ const spendingLimitCents = parseUsdCents(props.usd);
243
+ const { neon, fail, orgId } = await sdk(props);
244
+ const limit = await neon.organizations.spendingLimit.set({
245
+ orgId,
246
+ spendingLimitCents
247
+ }).catch((error) => {
248
+ throw fail(error);
249
+ });
250
+ writeSpendingLimit(props, orgId, limit);
251
+ };
252
+ const deleteSpendingLimit = async (props) => {
253
+ const { neon, fail, orgId } = await sdk(props);
254
+ await neon.organizations.spendingLimit.delete({ orgId }).catch((error) => {
255
+ throw fail(error);
256
+ });
257
+ log.info(`Spending limit removed from ${orgId}`);
258
+ };
259
+ /** JSON and YAML keep the API's cents; the table shows dollars. */
260
+ const writeSpendingLimit = (props, orgId, limit) => {
261
+ if (props.output !== "table") {
262
+ writer(props).end(limit, { fields: [] });
263
+ return;
264
+ }
265
+ const cents = limit.spending_limit_cents;
266
+ writer(props).end({ monthly_limit: cents === null ? "Not set" : formatUsd(cents) }, {
267
+ fields: SPENDING_LIMIT_TABLE_FIELDS,
268
+ title: `Spending limit for ${orgId}`
269
+ });
270
+ };
271
+ const USD = new Intl.NumberFormat("en-US", {
272
+ style: "currency",
273
+ currency: "USD"
274
+ });
275
+ const formatUsd = (cents) => USD.format(cents / 100);
276
+ /**
277
+ * `500` or `250.50` → cents. Parsed as text, not with `Number()`: `1e3` and `0x10` are
278
+ * numbers too, and a float multiply turns `0.29` into 28.999… cents.
279
+ */
280
+ const parseUsdCents = (value) => {
281
+ const match = typeof value === "string" ? /^(\d+)(?:\.(\d{1,2}))?$/.exec(value.trim()) : null;
282
+ const cents = match ? Number(match[1]) * 100 + Number((match[2] ?? "").padEnd(2, "0")) : NaN;
283
+ if (!Number.isSafeInteger(cents) || cents <= 0) throw new Error(`spending-limit set needs a positive amount in US dollars, such as 500 or 250.50. Got \`${String(value)}\`. To remove the limit, run \`neon orgs spending-limit delete\`.`);
284
+ return cents;
285
+ };
286
+ const ACRONYMS = {
287
+ aws: "AWS",
288
+ pg: "PG"
289
+ };
290
+ /** `free_v3` -> `Free`, `aws_marketplace` -> `AWS Marketplace`; JSON/YAML keep the API id. */
291
+ const planName = (plan) => (plan ?? "").replace(/_v\d+$/, "").split("_").filter(Boolean).map((word) => ACRONYMS[word] ?? word[0].toUpperCase() + word.slice(1)).join(" ");
292
+ export { handler as a, planName as c, describe as i, builder as n, orgs_exports as o, command as r, parseUsdCents as s, aliases as t };
@@ -3,7 +3,7 @@ import { a as computes_exports } from "./computes-OKFUNFee.js";
3
3
  import { o as connection_string_exports } from "./connection_string-6WhV4WFx.js";
4
4
  import { s as databases_exports } from "./databases-B-qY303S.js";
5
5
  import { o as psql_exports } from "./psql-BcxiPR4W.js";
6
- import { u as roles_exports } from "./roles-BXGtPGjv.js";
6
+ import { f as roles_exports } from "./roles-BELJqjTy.js";
7
7
  // src/commands/postgres.ts
8
8
  var postgres_exports = /* @__PURE__ */ __exportAll({
9
9
  aliases: () => aliases,
@@ -14,7 +14,7 @@ import { m as usableCredential, n as authFlow } from "./auth-rup6nemJ.js";
14
14
  import { identityFromAuthDetails, isApiKeyMethod, mintedKeyName, notAnApiKeyMessage } from "../profile_keys.js";
15
15
  import { writer } from "../writer.js";
16
16
  import { noPassthrough, single } from "../utils/flags.js";
17
- import { s as orgIdForProject } from "./api_keys-6Xnxl7a8.js";
17
+ import { s as orgIdForProject } from "./api_keys-CTFHd5m_.js";
18
18
  import { existsSync, readFileSync, rmSync } from "node:fs";
19
19
  import { isAbsolute, relative } from "node:path";
20
20
  import prompts from "prompts";
@@ -12,8 +12,10 @@ var roles_exports = /* @__PURE__ */ __exportAll({
12
12
  create: () => create,
13
13
  deleteRole: () => deleteRole,
14
14
  describe: () => describe,
15
+ get: () => get,
15
16
  handler: () => handler,
16
- list: () => list
17
+ list: () => list,
18
+ resetPassword: () => resetPassword
17
19
  });
18
20
  const ROLES_FIELDS = ["name", "created_at"];
19
21
  const CREATED_ROLE_FIELDS = [
@@ -21,6 +23,14 @@ const CREATED_ROLE_FIELDS = [
21
23
  "password",
22
24
  "created_at"
23
25
  ];
26
+ const ROLE_DETAIL_FIELDS = [
27
+ "name",
28
+ "branch_id",
29
+ "protected",
30
+ "authentication_method",
31
+ "created_at",
32
+ "updated_at"
33
+ ];
24
34
  const ROLE_ACCESS = [
25
35
  "admin",
26
36
  "read_only",
@@ -66,7 +76,11 @@ const builderFor = (usage) => (argv) => argv.usage(`$0 ${usage} <sub-command> [o
66
76
  }).check((args) => {
67
77
  if (args.access === "admin" && (args.database !== void 0 || args.schema !== void 0)) throw new Error("--database and --schema need --access read_only or --access read_write");
68
78
  return true;
69
- }), (args) => create(args)).command("delete <role>", "Delete a role", (yargs) => yargs, (args) => deleteRole(args));
79
+ }), (args) => create(args)).command("get <role>", "Get a role", (yargs) => yargs, (args) => get(args)).command("reset-password <role>", "Reset a role's password and print the new one", (yargs) => yargs.options({ wait: {
80
+ describe: "Wait until the compute applies the new password. Use --no-wait to return as soon as the API accepts the reset",
81
+ type: "boolean",
82
+ default: true
83
+ } }), (args) => resetPassword(args)).command("delete <role>", "Delete a role", (yargs) => yargs, (args) => deleteRole(args));
70
84
  const builder = builderFor("roles");
71
85
  const handler = (args) => {
72
86
  return args;
@@ -127,4 +141,32 @@ const deleteRole = async (props) => {
127
141
  }
128
142
  log.info(`Role "${props.role}" not found on branch ${branch?.name ?? branchId}; nothing to delete.`);
129
143
  };
130
- export { create as a, handler as c, command as i, list as l, builder as n, deleteRole as o, builderFor as r, describe as s, aliases as t, roles_exports as u };
144
+ const get = async (props) => {
145
+ const { branchId } = await resolveBranchFromProps(props);
146
+ const { fromSdkError, getNeonClient } = await import("../neon_client.js");
147
+ const role = await getNeonClient(props).postgres.roles.get({
148
+ projectId: props.projectId,
149
+ branchId,
150
+ roleName: props.role
151
+ }).catch((error) => {
152
+ throw fromSdkError(error, props.apiHost);
153
+ });
154
+ writer(props).end(role, { fields: ROLE_DETAIL_FIELDS });
155
+ };
156
+ const resetPassword = async (props) => {
157
+ const { branchId, branch } = await resolveBranchFromProps(props);
158
+ const { fromSdkError, getNeonClient } = await import("../neon_client.js");
159
+ const role = await getNeonClient(props).postgres.roles.resetPassword({
160
+ projectId: props.projectId,
161
+ branchId,
162
+ roleName: props.role
163
+ }, { waitForReadiness: props.wait }).catch((error) => {
164
+ throw fromSdkError(error, props.apiHost);
165
+ });
166
+ const branchLabel = branch?.name ?? branchId;
167
+ writer(props).end(role, {
168
+ fields: CREATED_ROLE_FIELDS,
169
+ humanTitle: props.wait ? `Password reset for ${props.role} on ${branchLabel}` : `Password reset for ${props.role} on ${branchLabel} accepted, not yet applied`
170
+ });
171
+ };
172
+ export { create as a, get as c, resetPassword as d, roles_exports as f, command as i, handler as l, builder as n, deleteRole as o, builderFor as r, describe as s, aliases as t, list as u };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { fillSingleProject } from "../utils/enrichers.js";
3
- import { y as status } from "./config-CgtJH8xE.js";
3
+ import { y as status } from "./config-BjCm5cfr.js";
4
4
  // src/commands/status.ts
5
5
  var status_exports = /* @__PURE__ */ __exportAll({
6
6
  builder: () => builder,
package/dist/api.js CHANGED
@@ -194,6 +194,15 @@ function unreadableBodyError(response, cause) {
194
194
  });
195
195
  }
196
196
  /**
197
+ * Encode one segment of a path built outside the SDK. `encodeURIComponent` leaves `.` and
198
+ * `..` intact, and URL parsing then resolves them as dot segments, so the request would go to
199
+ * a different route.
200
+ */
201
+ function pathSegment(name, value) {
202
+ if (value === "." || value === "..") throw new Error(`Path parameter ${name} cannot be "${value}".`);
203
+ return encodeURIComponent(value);
204
+ }
205
+ /**
197
206
  * Translate a thrown `fetch` failure into a {@link NeonApiError}. A request
198
207
  * timeout uses `ECONNABORTED` (matching the old axios behaviour, and excluded
199
208
  * from `isNetworkError`'s connectivity codes so it's still reported as a
@@ -313,6 +322,7 @@ const getApiClient = ({ apiKey, apiHost, requestTimeoutMs = REQUEST_TIMEOUT_MS }
313
322
  } catch (err) {
314
323
  throw networkError(err);
315
324
  }
325
+ if (result.error instanceof Error && "kind" in result.error && result.error.kind === "client") throw result.error;
316
326
  const response = result.response;
317
327
  if (!response) throw networkError(result.error ?? /* @__PURE__ */ new Error("No response from Neon API"));
318
328
  if (!response.ok) throw httpError(response, rawErrorBody(result.error) ?? result.data);
@@ -1088,4 +1098,4 @@ const getApiClient = ({ apiKey, apiHost, requestTimeoutMs = REQUEST_TIMEOUT_MS }
1088
1098
  }))
1089
1099
  };
1090
1100
  };
1091
- export { ContentType, DEFAULT_API_HOST, NeonApiError, RETRY_COUNT, UnreadableResponseError, cliFetch, codeFromBody, getApiClient, httpError, isNeonApiError, messageFromBody, retryOnLock };
1101
+ export { ContentType, DEFAULT_API_HOST, NeonApiError, RETRY_COUNT, UnreadableResponseError, cliFetch, codeFromBody, getApiClient, httpError, isAbortError, isNeonApiError, messageFromBody, networkError, pathSegment, retryOnLock, unreadableBodyError };
@@ -1,3 +1,4 @@
1
+ import { pathSegment } from "../api.js";
1
2
  // src/claimable/api.ts
2
3
  const REQUEST_TIMEOUT_MS = 6e4;
3
4
  const JWT_BEARER_GRANT = "urn:ietf:params:oauth:grant-type:jwt-bearer";
@@ -198,19 +199,19 @@ var ClaimableClient = class {
198
199
  }));
199
200
  }
200
201
  async credentials(projectId, accessToken) {
201
- return parseCredentialsResponse(await this.request(`/v1/projects/${encodeURIComponent(projectId)}/credentials`, { accessToken }));
202
+ return parseCredentialsResponse(await this.request(`/v1/projects/${pathSegment("project_id", projectId)}/credentials`, { accessToken }));
202
203
  }
203
204
  async createClaim(projectId, accessToken) {
204
- return parseClaimCodeResponse(await this.request(`/v1/projects/${encodeURIComponent(projectId)}/claim`, {
205
+ return parseClaimCodeResponse(await this.request(`/v1/projects/${pathSegment("project_id", projectId)}/claim`, {
205
206
  method: "POST",
206
207
  accessToken
207
208
  }));
208
209
  }
209
210
  async claimStatus(projectId, accessToken) {
210
- return parseClaimStatusResponse(await this.request(`/v1/projects/${encodeURIComponent(projectId)}/claim`, { accessToken }));
211
+ return parseClaimStatusResponse(await this.request(`/v1/projects/${pathSegment("project_id", projectId)}/claim`, { accessToken }));
211
212
  }
212
213
  async deleteProject(projectId, accessToken) {
213
- await this.request(`/v1/projects/${encodeURIComponent(projectId)}`, {
214
+ await this.request(`/v1/projects/${pathSegment("project_id", projectId)}`, {
214
215
  method: "DELETE",
215
216
  accessToken
216
217
  });
@@ -1 +1 @@
1
- export { t as aliases, r as builder, i as command, a as describe, o as handler, s as orgIdForProject } from "../_chunks/api_keys-6Xnxl7a8.js";
1
+ export { t as aliases, r as builder, i as command, a as describe, o as handler, s as orgIdForProject } from "../_chunks/api_keys-CTFHd5m_.js";
@@ -1 +1 @@
1
- export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-CNBIS3gA.js";
1
+ export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-BpOcFaAi.js";
@@ -1 +1 @@
1
- export { t as CLAIM_CREATE_FIELDS, n as CLAIM_LIST_FIELDS, r as aliases, i as builder, a as claimCreateFields, s as claimableCapabilities, c as command, l as create, u as describe, d as handler } from "../_chunks/claim-DhV0f_5o.js";
1
+ export { t as CLAIM_CREATE_FIELDS, n as CLAIM_LIST_FIELDS, r as aliases, i as builder, a as claimCreateFields, s as claimableCapabilities, c as command, l as create, u as describe, d as handler } from "../_chunks/claim-B3tMeMuo.js";
@@ -1 +1 @@
1
- export { t as ConfigInstallFailed, n as addCmd, r as applyCmd, i as applyFlags, a as applyPolicyOnCreate, o as builder, s as command, l as createBranchFromPolicyOnCheckout, u as describe, d as ensureConfigPackages, f as envFlag, p as envPullFlag, m as handler, h as initCmd, g as installCommandFrom, _ as missingDependencies, v as planCmd, y as status } from "../_chunks/config-CgtJH8xE.js";
1
+ export { t as ConfigInstallFailed, n as addCmd, r as applyCmd, i as applyFlags, a as applyPolicyOnCreate, o as builder, s as command, l as createBranchFromPolicyOnCheckout, u as describe, d as ensureConfigPackages, f as envFlag, p as envPullFlag, m as handler, h as initCmd, g as installCommandFrom, _ as missingDependencies, v as planCmd, y as status } from "../_chunks/config-BjCm5cfr.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-Bs5gmi4Q.js";
1
+ export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-DmEEhux0.js";
@@ -1 +1 @@
1
- export { t as builder, n as captureShellEnv, r as command, i as describe, a as devBundleDir, o as devEnvContext, c as diffUnits, l as formatEnvFiles, u as formatEnvSummary, d as handler, f as loadDevEnvFiles, p as localFunctionUrlEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-DxiIp4c9.js";
1
+ export { t as builder, n as captureShellEnv, r as command, i as describe, a as devBundleDir, o as devEnvContext, c as diffUnits, l as formatEnvFiles, u as formatEnvSummary, d as handler, f as loadDevEnvFiles, p as localFunctionUrlEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-DlUJFzRs.js";
@@ -1 +1 @@
1
- export { t as ENV_PULL_SKIPPED_HINT, n as autoPullEnvAfterPin, r as builder, i as command, a as describe, s as handler, c as pull } from "../_chunks/env-BtG4vH55.js";
1
+ export { t as ENV_PULL_SKIPPED_HINT, n as autoPullEnvAfterPin, r as builder, i as command, a as describe, s as handler, c as pull } from "../_chunks/env-BOt9AZ1j.js";
@@ -8,7 +8,7 @@ import { writer } from "../writer.js";
8
8
  import { formatInitDone, printInitDone } from "../init/chrome.js";
9
9
  import { FUNCTION_SLUG_PATTERN, deriveFunctionSlug } from "../utils/function_slug.js";
10
10
  import { displayPath } from "./env_output.js";
11
- import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-CgtJH8xE.js";
11
+ import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-BjCm5cfr.js";
12
12
  import { recommendedOperations } from "../functions/registry.js";
13
13
  import { collidingFiles, operationsFromFlags, planConfigRegistration, planEnvExample, planScaffold, writeScaffold } from "../functions/scaffold.js";
14
14
  import { describeRegistrySource, openRegistry } from "../functions/source.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-DRUZBCmZ.js";
1
+ export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-j6xSVo3e.js";
@@ -1,30 +1,30 @@
1
1
  import { r as auth_exports } from "../_chunks/auth-rup6nemJ.js";
2
2
  import { t as api_exports } from "../_chunks/api-1MKsfpY3.js";
3
- import { n as api_keys_exports } from "../_chunks/api_keys-6Xnxl7a8.js";
3
+ import { n as api_keys_exports } from "../_chunks/api_keys-CTFHd5m_.js";
4
4
  import { n as ask_exports } from "../_chunks/ask-Xlek1Pxh.js";
5
- import { o as env_exports } from "../_chunks/env-BtG4vH55.js";
6
- import { c as config_exports } from "../_chunks/config-CgtJH8xE.js";
5
+ import { o as env_exports } from "../_chunks/env-BOt9AZ1j.js";
6
+ import { c as config_exports } from "../_chunks/config-BjCm5cfr.js";
7
7
  import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
8
- import { a as link_exports } from "../_chunks/link-CNO-HxHN.js";
8
+ import { a as link_exports } from "../_chunks/link-nAiuWKfg.js";
9
9
  import { o as mcp_exports } from "../_chunks/mcp-SvqWzHnT.js";
10
10
  import { c as plugins_exports } from "../_chunks/plugins-7cxVcgay.js";
11
11
  import { l as skills_exports } from "../_chunks/skills-Bv8oKKwE.js";
12
12
  import { t as bootstrap_exports } from "../_chunks/bootstrap-Dh7-KDmw.js";
13
13
  import { r as branches_exports } from "../_chunks/branches-Bp-5z1lM.js";
14
14
  import { n as bucket_exports } from "../_chunks/bucket-D06bvDSa.js";
15
- import { n as checkout_exports } from "../_chunks/checkout-CNBIS3gA.js";
16
- import { o as claim_exports } from "../_chunks/claim-DhV0f_5o.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-BpOcFaAi.js";
16
+ import { o as claim_exports } from "../_chunks/claim-B3tMeMuo.js";
17
17
  import { o as connection_string_exports } from "../_chunks/connection_string-6WhV4WFx.js";
18
18
  import { a as credentials_exports } from "../_chunks/credentials-BMBNmW0t.js";
19
19
  import { r as data_api_exports } from "../_chunks/data_api-CHDwvMTG.js";
20
20
  import { s as databases_exports } from "../_chunks/databases-B-qY303S.js";
21
- import { r as deploy_exports } from "../_chunks/deploy-Bs5gmi4Q.js";
22
- import { s as dev_exports } from "../_chunks/dev-DxiIp4c9.js";
21
+ import { r as deploy_exports } from "../_chunks/deploy-DmEEhux0.js";
22
+ import { s as dev_exports } from "../_chunks/dev-DlUJFzRs.js";
23
23
  import { i as diff_exports } from "../_chunks/diff-dnxneH0u.js";
24
24
  import { c as docs_exports } from "../_chunks/docs-BpLiSTmm.js";
25
25
  import { o as feedback_exports } from "../_chunks/feedback-mQmdTRFn.js";
26
26
  import { o as functions_exports } from "../_chunks/functions-PHaU-kRb.js";
27
- import { o as git_exports } from "../_chunks/git-DRUZBCmZ.js";
27
+ import { o as git_exports } from "../_chunks/git-j6xSVo3e.js";
28
28
  import { a as init_exports } from "../_chunks/init-D2fClHtC.js";
29
29
  import { o as inspect_exports } from "../_chunks/inspect-yFAb61qo.js";
30
30
  import { a as ip_allow_exports } from "../_chunks/ip_allow-DBdxNEUa.js";
@@ -32,15 +32,15 @@ import { l as logs_exports } from "../_chunks/logs-BB4uvblR.js";
32
32
  import { a as neon_auth_exports } from "../_chunks/neon_auth-C1CgNTGP.js";
33
33
  import { a as open_exports } from "../_chunks/open-T2nI89Oh.js";
34
34
  import { c as operations_exports } from "../_chunks/operations-D7qGkKo3.js";
35
- import { o as orgs_exports } from "../_chunks/orgs-Dpbr-K0A.js";
35
+ import { o as orgs_exports } from "../_chunks/orgs-BrvAWM8Z.js";
36
36
  import { o as psql_exports } from "../_chunks/psql-BcxiPR4W.js";
37
- import { u as roles_exports } from "../_chunks/roles-BXGtPGjv.js";
38
- import { o as postgres_exports } from "../_chunks/postgres-BkJPZRov.js";
39
- import { o as profile_exports } from "../_chunks/profile-BAlM625e.js";
37
+ import { f as roles_exports } from "../_chunks/roles-BELJqjTy.js";
38
+ import { o as postgres_exports } from "../_chunks/postgres-BhR1vUFM.js";
39
+ import { o as profile_exports } from "../_chunks/profile-CArcjyS4.js";
40
40
  import { s as realtime_exports } from "../_chunks/realtime-BwtzYf5a.js";
41
41
  import { a as set_context_exports } from "../_chunks/set_context-ompB6d2D.js";
42
42
  import { s as snapshots_exports } from "../_chunks/snapshots-DxNhjcco.js";
43
- import { a as status_exports } from "../_chunks/status-BlrzeKyA.js";
43
+ import { a as status_exports } from "../_chunks/status-BC4XXuuE.js";
44
44
  import { d as triggers_exports } from "../_chunks/triggers-BfvyeJUC.js";
45
45
  import { s as user_exports } from "../_chunks/user-D9mC430O.js";
46
46
  import { i as vpc_endpoints_exports } from "../_chunks/vpc_endpoints-C-Y4WK2M.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler, o as quoteFlagValue, s as runLink, c as shouldOfferConfigInit } from "../_chunks/link-CNO-HxHN.js";
1
+ export { t as builder, n as command, r as describe, i as handler, o as quoteFlagValue, s as runLink, c as shouldOfferConfigInit } from "../_chunks/link-nAiuWKfg.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as describe, a as handler, s as planName } from "../_chunks/orgs-Dpbr-K0A.js";
1
+ export { t as aliases, n as builder, r as command, i as describe, a as handler, s as parseUsdCents, c as planName } from "../_chunks/orgs-BrvAWM8Z.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/postgres-BkJPZRov.js";
1
+ export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/postgres-BhR1vUFM.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/profile-BAlM625e.js";
1
+ export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/profile-CArcjyS4.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as builderFor, i as command, a as create, o as deleteRole, s as describe, c as handler, l as list } from "../_chunks/roles-BXGtPGjv.js";
1
+ export { t as aliases, n as builder, r as builderFor, i as command, a as create, o as deleteRole, s as describe, c as get, l as handler, u as list, d as resetPassword } from "../_chunks/roles-BELJqjTy.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-BlrzeKyA.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-BC4XXuuE.js";
@@ -1,6 +1,6 @@
1
1
  import { writer } from "../writer.js";
2
- import { branchIdFromProps } from "../utils/enrichers.js";
3
2
  import { o as resolveNeonEnvVars } from "../_chunks/env-CIFMBEon.js";
3
+ import { branchIdFromProps } from "../utils/enrichers.js";
4
4
  import YAML from "yaml";
5
5
  // src/commands/subscribe.ts
6
6
  const builder = (argv) => argv.usage("$0 realtime subscribe \"<query>\" [options]").positional("query", {
@@ -1,5 +1,6 @@
1
+ import { pathSegment } from "./api.js";
1
2
  // src/custom_domains_api.ts
2
- const customDomainsPath = (projectId, branchId) => `/projects/${encodeURIComponent(projectId)}/branches/${encodeURIComponent(branchId)}/custom-domains`;
3
+ const customDomainsPath = (projectId, branchId) => `/projects/${pathSegment("project_id", projectId)}/branches/${pathSegment("branch_id", branchId)}/custom-domains`;
3
4
  const listCustomDomains = async (apiClient, projectId, branchId, { cursor, limit } = {}) => {
4
5
  const { data } = await apiClient.request({
5
6
  path: customDomainsPath(projectId, branchId),
@@ -28,7 +29,7 @@ const registerCustomDomain = async (apiClient, projectId, branchId, input) => {
28
29
  };
29
30
  const deleteCustomDomain = async (apiClient, projectId, branchId, domain) => {
30
31
  await apiClient.request({
31
- path: `${customDomainsPath(projectId, branchId)}/${encodeURIComponent(domain)}`,
32
+ path: `${customDomainsPath(projectId, branchId)}/${pathSegment("domain", domain)}`,
32
33
  method: "DELETE",
33
34
  secure: true
34
35
  });
@@ -1,6 +1,6 @@
1
- import "./api.js";
1
+ import { pathSegment } from "./api.js";
2
2
  // src/functions_api.ts
3
- const functionsPath = (projectId, branchId) => `/projects/${encodeURIComponent(projectId)}/branches/${encodeURIComponent(branchId)}/functions`;
3
+ const functionsPath = (projectId, branchId) => `/projects/${pathSegment("project_id", projectId)}/branches/${pathSegment("branch_id", branchId)}/functions`;
4
4
  const listFunctions = async (apiClient, projectId, branchId, { cursor, limit } = {}) => {
5
5
  const { data } = await apiClient.request({
6
6
  path: functionsPath(projectId, branchId),
@@ -19,7 +19,7 @@ const listFunctions = async (apiClient, projectId, branchId, { cursor, limit } =
19
19
  };
20
20
  const getFunction = async (apiClient, projectId, branchId, slug) => {
21
21
  const { data } = await apiClient.request({
22
- path: `${functionsPath(projectId, branchId)}/${encodeURIComponent(slug)}`,
22
+ path: `${functionsPath(projectId, branchId)}/${pathSegment("slug", slug)}`,
23
23
  method: "GET",
24
24
  secure: true,
25
25
  format: "json"
@@ -28,7 +28,7 @@ const getFunction = async (apiClient, projectId, branchId, slug) => {
28
28
  };
29
29
  const deleteFunction = async (apiClient, projectId, branchId, slug) => {
30
30
  await apiClient.request({
31
- path: `${functionsPath(projectId, branchId)}/${encodeURIComponent(slug)}`,
31
+ path: `${functionsPath(projectId, branchId)}/${pathSegment("slug", slug)}`,
32
32
  method: "DELETE",
33
33
  secure: true
34
34
  });
@@ -39,7 +39,7 @@ const createDeployment = async (apiClient, projectId, branchId, slug, params) =>
39
39
  form.append("runtime", params.runtime);
40
40
  if (params.environment) form.append("environment", params.environment);
41
41
  await apiClient.request({
42
- path: `${functionsPath(projectId, branchId)}/${encodeURIComponent(slug)}/deployments`,
42
+ path: `${functionsPath(projectId, branchId)}/${pathSegment("slug", slug)}/deployments`,
43
43
  method: "POST",
44
44
  type: "multipart/form-data",
45
45
  body: form,
package/dist/init/auth.js CHANGED
@@ -4,7 +4,7 @@ import "../config.js";
4
4
  import "../auth.js";
5
5
  import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-rup6nemJ.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { c as pull } from "../_chunks/env-BtG4vH55.js";
7
+ import { c as pull } from "../_chunks/env-BOt9AZ1j.js";
8
8
  import { c as setupNeonMcp } from "../_chunks/mcp-SvqWzHnT.js";
9
9
  // src/init/auth.ts
10
10
  const isUnauthorized = (error) => isNeonApiError(error) && error.status === 401;
@@ -4,7 +4,7 @@ import { c as ensureAuth } from "../_chunks/auth-rup6nemJ.js";
4
4
  import { recoverFrom401 } from "../auth_recovery.js";
5
5
  import { loadProjectConfig } from "../project.js";
6
6
  import { loadEnvFileIntoProcess } from "../env_file.js";
7
- import { r as applyCmd } from "../_chunks/config-CgtJH8xE.js";
7
+ import { r as applyCmd } from "../_chunks/config-BjCm5cfr.js";
8
8
  import { authContext } from "./auth.js";
9
9
  import { existsSync } from "node:fs";
10
10
  // src/init/deploy.ts
package/dist/init/link.js CHANGED
@@ -4,7 +4,7 @@ import "../config.js";
4
4
  import "../auth.js";
5
5
  import { c as ensureAuth } from "../_chunks/auth-rup6nemJ.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { s as runLink } from "../_chunks/link-CNO-HxHN.js";
7
+ import { s as runLink } from "../_chunks/link-nAiuWKfg.js";
8
8
  // src/init/link.ts
9
9
  const isUnauthorized = (error) => isNeonApiError(error) && error.status === 401;
10
10
  const authenticationFailed = () => /* @__PURE__ */ new Error("Authentication failed.");
package/dist/init/run.js CHANGED
@@ -14,8 +14,8 @@ import { getAgentDisplayName } from "../mcp/agents.js";
14
14
  import { missingPluginsCommands, pluginsCommandProblemText, pluginsInstallableAgents, unusablePluginsCommands } from "../plugins/targets.js";
15
15
  import { AGENTS_NOT_INSTALLED, CANCELLED_BODY, CLAIMABLE_ACCOUNT_FLAGS, CLAIMABLE_ALREADY_LINKED, CLAIMABLE_MCP_API_KEY, CLAIMABLE_NO_LINK, MCP_API_KEY_NEEDS_AUTH, MCP_SCOPED_NEEDS_PROJECT, NON_TTY_LINK_NEEDS_AUTH, NO_AGENTS_FALLBACK_STATUS, PROGRESS, PROJECT_PINNED_OFFLINE, claimableNext, claimableThenServicesNext, configInitNext, envPullFailedNext, existingConfigNext, installFailedNext, mcpAfterLinkNext, mcpConfigLocationSkipped, mcpConfigLocationUnavailable, mcpKeyFailedNext, namedAgentsUnavailable, newConfigNext, offlinePinNext, skippedLinkNext, toolingFailedNext, unattendedUnauthedNext } from "./copy.js";
16
16
  import { agentsRowValue, configRowValue, formatInitDone, headingForKind, printInitBanner, printInitDone, printInitProgress, projectRowValue, shouldPrintInitBanner } from "./chrome.js";
17
- import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-CgtJH8xE.js";
18
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-CNO-HxHN.js";
17
+ import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-BjCm5cfr.js";
18
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-nAiuWKfg.js";
19
19
  import { runAuthenticatedLink } from "./link.js";
20
20
  import { mcpInstallableAgents } from "../mcp/targets.js";
21
21
  import { skillsInstallableAgents } from "../skills/targets.js";
@@ -25,7 +25,7 @@ import { pullInitEnv, resolveInitConfigApi } from "./auth.js";
25
25
  import { InitCancelled, raceSigint, restoreCursor } from "./cancelled.js";
26
26
  import { pickAgentSetupInteractively, pickInitAgentsInteractively, pickInitConfigInteractively, pickInitMcpAuthInteractively, pickInitMcpConfigLocationInteractively, pickInitModeInteractively, pickInitPackageManagerInteractively, pickInitProjectSetupInteractively, pickInitServicesInteractively, pickInitSkillsInteractively } from "./wizard.js";
27
27
  import { runToolingSteps, toolingStepCommandText } from "./tooling.js";
28
- import { l as create } from "../_chunks/claim-DhV0f_5o.js";
28
+ import { l as create } from "../_chunks/claim-B3tMeMuo.js";
29
29
  import { INIT_CONFIG_SERVICES_CONFLICT, configPlanFromResolution, initEnvPullAfterConfig, resolveInitConfigChoice } from "./choices.js";
30
30
  import { detectInitEnvironment } from "./detect.js";
31
31
  import { createInitFunnel, emitInitStart, finishInitFunnel, initStartProperties, recordInitError, recordInitExit } from "./funnel.js";
package/dist/mcp/mint.js CHANGED
@@ -2,7 +2,7 @@ import { log } from "../log.js";
2
2
  import { isNeonApiError } from "../api.js";
3
3
  import { getCliName } from "../utils/cli_name.js";
4
4
  import { mintedKeyName } from "../profile_keys.js";
5
- import { s as orgIdForProject } from "../_chunks/api_keys-6Xnxl7a8.js";
5
+ import { s as orgIdForProject } from "../_chunks/api_keys-CTFHd5m_.js";
6
6
  // src/mcp/mint.ts
7
7
  var CannotMintApiKeyError = class extends Error {
8
8
  constructor() {
@@ -1,4 +1,4 @@
1
- import { cliFetch, httpError } from "./api.js";
1
+ import { cliFetch, httpError, isAbortError, networkError, unreadableBodyError } from "./api.js";
2
2
  import { NeonApiError, createNeonClient } from "@neon/sdk";
3
3
  // src/neon_client.ts
4
4
  /**
@@ -15,13 +15,15 @@ const getNeonClient = ({ apiKey, apiHost, requestTimeoutMs }) => createNeonClien
15
15
  });
16
16
  /**
17
17
  * Map an error from {@link getNeonClient} for the top-level handler. A management API
18
- * response becomes the CLI's `NeonApiError`, so 401 and SSO recovery apply. Anything else
18
+ * response becomes the CLI's `NeonApiError`, so 401 and SSO recovery apply, and a request
19
+ * timeout becomes the same `ECONNABORTED` error the raw client throws. Anything else
19
20
  * keeps the SDK's message and drops its `cause`, so a socket code deep in the chain cannot
20
21
  * turn a "role was created, but…" message into the generic connectivity hint.
21
22
  */
22
23
  function fromSdkError(error, apiHost) {
23
24
  const base = apiHost ?? "https://console.neon.tech/api/v2";
24
- if (error instanceof NeonApiError && error.response?.url.startsWith(base)) return httpError(error.response, error.body);
25
+ if (error instanceof NeonApiError && error.response?.url.startsWith(base)) return error.response.ok ? unreadableBodyError(error.response, error.body) : httpError(error.response, error.body);
26
+ if (isAbortError(error)) return networkError(error);
25
27
  return new Error(error instanceof Error ? error.message : String(error));
26
28
  }
27
29
  export { fromSdkError, getNeonClient };
@@ -1,6 +1,7 @@
1
+ import { pathSegment } from "./api.js";
1
2
  // src/storage_api.ts
2
- const bucketsPath = (projectId, branchId) => `/projects/${encodeURIComponent(projectId)}/branches/${encodeURIComponent(branchId)}/buckets`;
3
- const bucketPath = (projectId, branchId, bucketName) => `${bucketsPath(projectId, branchId)}/${encodeURIComponent(bucketName)}`;
3
+ const bucketsPath = (projectId, branchId) => `/projects/${pathSegment("project_id", projectId)}/branches/${pathSegment("branch_id", branchId)}/buckets`;
4
+ const bucketPath = (projectId, branchId, bucketName) => `${bucketsPath(projectId, branchId)}/${pathSegment("bucket_name", bucketName)}`;
4
5
  /**
5
6
  * Create a bucket on a branch.
6
7
  *
@@ -66,7 +67,7 @@ const listProjectBranchBucketObjects = (apiClient, { projectId, branchId, bucket
66
67
  * @request GET /projects/{project_id}/branches/{branch_id}/buckets/{bucket_name}/objects/{object_key}/download
67
68
  */
68
69
  const getProjectBranchBucketObject = (apiClient, { projectId, branchId, bucketName, objectKey }) => apiClient.request({
69
- path: `${bucketPath(projectId, branchId, bucketName)}/objects/${encodeURIComponent(objectKey)}/download`,
70
+ path: `${bucketPath(projectId, branchId, bucketName)}/objects/${pathSegment("object_key", objectKey)}/download`,
70
71
  method: "GET",
71
72
  format: "stream",
72
73
  secure: true
@@ -80,7 +81,7 @@ const getProjectBranchBucketObject = (apiClient, { projectId, branchId, bucketNa
80
81
  * @request DELETE /projects/{project_id}/branches/{branch_id}/buckets/{bucket_name}/objects/{object_key}
81
82
  */
82
83
  const deleteProjectBranchBucketObject = (apiClient, { projectId, branchId, bucketName, objectKey }) => apiClient.request({
83
- path: `${bucketPath(projectId, branchId, bucketName)}/objects/${encodeURIComponent(objectKey)}`,
84
+ path: `${bucketPath(projectId, branchId, bucketName)}/objects/${pathSegment("object_key", objectKey)}`,
84
85
  method: "DELETE",
85
86
  secure: true
86
87
  });
@@ -122,7 +123,7 @@ const presignUpload = (apiClient, { projectId, branchId, bucketName, objectKey,
122
123
  if (contentType !== void 0) body.content_type = contentType;
123
124
  if (expiresInSeconds !== void 0) body.expires_in_seconds = expiresInSeconds;
124
125
  return apiClient.request({
125
- path: `${bucketPath(projectId, branchId, bucketName)}/objects/${encodeURIComponent(objectKey)}/presign`,
126
+ path: `${bucketPath(projectId, branchId, bucketName)}/objects/${pathSegment("object_key", objectKey)}/presign`,
126
127
  method: "POST",
127
128
  body,
128
129
  format: "json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "8.21.0",
3
+ "version": "8.23.0",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -73,10 +73,10 @@
73
73
  "yaml": "^2.9.0",
74
74
  "yargs": "17.7.2",
75
75
  "yoctocolors": "^2.1.2",
76
- "@neon/config-runtime": "1.11.4",
77
76
  "@neon/realtime": "0.2.0",
78
- "@neon/sdk": "7.8.1",
79
- "@neon/config": "1.11.0"
77
+ "@neon/sdk": "7.9.0",
78
+ "@neon/config-runtime": "1.11.6",
79
+ "@neon/config": "1.11.2"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@napi-rs/keyring": "1.3.0",
@@ -113,9 +113,9 @@
113
113
  "typescript": "^5.9.0",
114
114
  "vitest": "^3.0.9",
115
115
  "@neon-internals/cli-core": "0.0.0",
116
- "@neon-internals/env-core": "0.0.42",
116
+ "@neon-internals/env-core": "0.0.44",
117
117
  "@neon/e2e-harness": "0.0.0",
118
- "@neon/env": "1.6.12",
118
+ "@neon/env": "1.6.14",
119
119
  "@neon/functions": "0.11.0"
120
120
  },
121
121
  "publishConfig": {
@@ -1,51 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
- import { readContextFile } from "../context.js";
3
- import { writer } from "../writer.js";
4
- import chalk from "chalk";
5
- // src/commands/orgs.ts
6
- var orgs_exports = /* @__PURE__ */ __exportAll({
7
- aliases: () => aliases,
8
- builder: () => builder,
9
- command: () => command,
10
- describe: () => describe,
11
- handler: () => handler,
12
- planName: () => planName
13
- });
14
- const ORG_FIELDS = [
15
- "id",
16
- "name",
17
- "plan"
18
- ];
19
- const command = "orgs";
20
- const describe = "Manage organizations";
21
- const aliases = ["org"];
22
- const builder = (argv) => {
23
- return argv.usage("$0 orgs <sub-command> [options]").command("list", "List organizations", (yargs) => yargs, async (args) => {
24
- await list(args);
25
- });
26
- };
27
- const handler = (args) => {
28
- return args;
29
- };
30
- const list = async (props) => {
31
- const out = writer(props);
32
- const { data: { organizations } } = await props.apiClient.getCurrentUserOrganizations();
33
- const current = readContextFile(props.contextFile).orgId;
34
- out.write(organizations, {
35
- fields: ORG_FIELDS,
36
- title: "Organizations",
37
- emptyMessage: "You are not a member of any organization.",
38
- renderColumns: {
39
- plan: (org) => planName(org.plan),
40
- name: (org) => org.id === current ? `${chalk.green("[current]")} ${org.name}` : org.name
41
- }
42
- });
43
- out.end();
44
- };
45
- const ACRONYMS = {
46
- aws: "AWS",
47
- pg: "PG"
48
- };
49
- /** `free_v3` -> `Free`, `aws_marketplace` -> `AWS Marketplace`; JSON/YAML keep the API id. */
50
- const planName = (plan) => (plan ?? "").replace(/_v\d+$/, "").split("_").filter(Boolean).map((word) => ACRONYMS[word] ?? word[0].toUpperCase() + word.slice(1)).join(" ");
51
- export { handler as a, describe as i, builder as n, orgs_exports as o, command as r, planName as s, aliases as t };
@@ -7,9 +7,9 @@ import { deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOpt
7
7
  import { mergeEnvFile, readEnvFile, resolveEnvFilePath } from "../env_file.js";
8
8
  import { t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "./env-JgoSsmyt.js";
9
9
  import { ENV_PULL_KEY_HELP, ENV_PULL_SERVICES, envKeysForSelection, envPullFlagValue, ownedEnvServiceKeys, parseEnvPullKeys } from "../env_services.js";
10
+ import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-CIFMBEon.js";
10
11
  import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
11
12
  import { warnAiGateway } from "../utils/ai_gateway_notice.js";
12
- import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-CIFMBEon.js";
13
13
  import { formatPulledEnv, pulledBranch } from "../commands/env_output.js";
14
14
  import { existsSync } from "node:fs";
15
15
  import chalk from "chalk";