neon 7.0.4 → 7.0.5

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.
@@ -85,17 +85,25 @@ const handler = async (props) => {
85
85
  };
86
86
  if (props.branch) props.branch = parsedPIT.branch;
87
87
  const branchId = await branchIdFromProps(props);
88
- const { data: { endpoints } } = await props.apiClient.listProjectBranchEndpoints(projectId, branchId);
88
+ const endpointsRequest = props.apiClient.listProjectBranchEndpoints(projectId, branchId);
89
+ const rolesRequest = props.roleName ? void 0 : props.apiClient.listProjectBranchRoles(projectId, branchId);
90
+ const databasesRequest = props.apiClient.listProjectBranchDatabases(projectId, branchId);
91
+ for (const request of [
92
+ endpointsRequest,
93
+ rolesRequest,
94
+ databasesRequest
95
+ ]) request?.catch(() => void 0);
96
+ const { data: { endpoints } } = await endpointsRequest;
89
97
  const matchEndpointType = props.endpointType ?? EndpointType.ReadWrite;
90
98
  let endpoint = endpoints.find((e) => e.type === matchEndpointType);
91
99
  if (!endpoint && props.endpointType == null) endpoint = endpoints[0];
92
100
  if (!endpoint) throw new Error(`No ${props.endpointType ?? ""} endpoint found for the branch: ${branchId}`);
93
- const role = props.roleName || await props.apiClient.listProjectBranchRoles(projectId, branchId).then(({ data }) => {
101
+ const role = !rolesRequest ? props.roleName : await rolesRequest.then(({ data }) => {
94
102
  if (data.roles.length === 0) throw new Error(`No roles found for the branch: ${branchId}`);
95
103
  if (data.roles.length === 1) return data.roles[0].name;
96
104
  throw new Error(`Multiple roles found for the branch, please provide one with the --role-name option: ${data.roles.map((r) => r.name).join(", ")}`);
97
105
  });
98
- const { data: { databases: branchDatabases } } = await props.apiClient.listProjectBranchDatabases(projectId, branchId);
106
+ const { data: { databases: branchDatabases } } = await databasesRequest;
99
107
  const database = props.databaseName || (() => {
100
108
  if (branchDatabases.length === 0) throw new Error(`No databases found for the branch: ${branchId}`);
101
109
  if (branchDatabases.length === 1) return branchDatabases[0].name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "7.0.4",
3
+ "version": "7.0.5",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -64,9 +64,9 @@
64
64
  "yaml": "^2.9.0",
65
65
  "yargs": "17.7.2",
66
66
  "yoctocolors": "^2.1.2",
67
- "@neon/config-runtime": "1.7.3",
67
+ "@neon/sdk": "7.0.0",
68
68
  "@neon/config": "1.8.3",
69
- "@neon/sdk": "7.0.0"
69
+ "@neon/config-runtime": "1.7.3"
70
70
  },
71
71
  "optionalDependencies": {
72
72
  "@napi-rs/keyring": "1.3.0",