neon 8.3.3 → 8.3.4
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/commands/dev.js +2 -2
- package/dist/commands/env.js +1 -1
- package/dist/utils/inspect_db.js +32 -24
- package/package.json +1 -1
package/dist/commands/dev.js
CHANGED
|
@@ -4,11 +4,11 @@ import { isClaimableEnvTarget } from "../claimable/state.js";
|
|
|
4
4
|
import { getCliName } from "../utils/cli_name.js";
|
|
5
5
|
import { readEnvFile, resolveEnvFilePath } from "../env_file.js";
|
|
6
6
|
import { l as functionBaseUrlKey } from "../_chunks/env-HYNFtxu5.js";
|
|
7
|
-
import { branchIdResolve } from "../utils/enrichers.js";
|
|
8
|
-
import { bundleEntry } from "../utils/esbuild.js";
|
|
9
7
|
import { a as resolveDevEnv } from "../_chunks/env-BWqJqBDJ.js";
|
|
10
8
|
import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
|
|
11
9
|
import { resolveWatchInputs } from "../dev/inputs.js";
|
|
10
|
+
import { branchIdResolve } from "../utils/enrichers.js";
|
|
11
|
+
import { bundleEntry } from "../utils/esbuild.js";
|
|
12
12
|
import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
13
13
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
package/dist/commands/env.js
CHANGED
|
@@ -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 "../_chunks/env-HYNFtxu5.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 "../_chunks/env-BWqJqBDJ.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 "../_chunks/env-BWqJqBDJ.js";
|
|
13
13
|
import { formatPulledEnv, pulledBranch } from "./env_output.js";
|
|
14
14
|
import { existsSync } from "node:fs";
|
|
15
15
|
import chalk from "chalk";
|
package/dist/utils/inspect_db.js
CHANGED
|
@@ -48,20 +48,36 @@ const connectionUriForDatabase = (connectionUri, database) => {
|
|
|
48
48
|
url.pathname = `/${encodeURIComponent(database)}`;
|
|
49
49
|
return url.toString();
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Resolves the branch once and starts its endpoint, role, and database reads together.
|
|
53
|
+
* Callers read them in the order a sequential run would, so the first error is the same.
|
|
54
|
+
*/
|
|
55
|
+
const startBranchConnectionReads = async (props) => {
|
|
52
56
|
const projectId = props.projectId;
|
|
53
57
|
const parsedPIT = props.branch ? parsePITBranch(props.branch) : {
|
|
54
58
|
tag: "head",
|
|
55
59
|
branch: ""
|
|
56
60
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
if (props.branch) props.branch = parsedPIT.branch;
|
|
62
|
+
const branchId = await branchIdFromProps(props);
|
|
63
|
+
const endpoints = props.apiClient.listProjectBranchEndpoints(projectId, branchId).then(({ data }) => data.endpoints);
|
|
64
|
+
const role = props.roleName ? Promise.resolve(props.roleName) : props.apiClient.listProjectBranchRoles(projectId, branchId).then(({ data }) => {
|
|
65
|
+
if (data.roles.length === 0) throw new Error(`No roles found for the branch: ${branchId}`);
|
|
66
|
+
if (data.roles.length === 1) return data.roles[0].name;
|
|
67
|
+
throw new Error(`Multiple roles found for the branch, please provide one with the --role-name option: ${data.roles.map((r) => r.name).join(", ")}`);
|
|
60
68
|
});
|
|
61
|
-
const
|
|
69
|
+
const databases = props.apiClient.listProjectBranchDatabases(projectId, branchId).then(({ data }) => data.databases);
|
|
70
|
+
for (const read of [
|
|
71
|
+
endpoints,
|
|
72
|
+
role,
|
|
73
|
+
databases
|
|
74
|
+
]) read.catch(() => void 0);
|
|
62
75
|
return {
|
|
63
76
|
branchId,
|
|
64
|
-
|
|
77
|
+
parsedPIT,
|
|
78
|
+
endpoints,
|
|
79
|
+
role,
|
|
80
|
+
databases
|
|
65
81
|
};
|
|
66
82
|
};
|
|
67
83
|
/**
|
|
@@ -70,25 +86,16 @@ const listBranchDatabases = async (props) => {
|
|
|
70
86
|
* pooling, prisma tuning, and SSL mode). Mirrors how `connection-string`
|
|
71
87
|
* resolves a branch so `inspect db` connects the same way.
|
|
72
88
|
*/
|
|
73
|
-
const resolveConnectionUri = async (props) => {
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
branch: ""
|
|
78
|
-
};
|
|
79
|
-
if (props.branch) props.branch = parsedPIT.branch;
|
|
80
|
-
const branchId = await branchIdFromProps(props);
|
|
81
|
-
const { data: { endpoints } } = await props.apiClient.listProjectBranchEndpoints(projectId, branchId);
|
|
89
|
+
const resolveConnectionUri = async (props, started) => {
|
|
90
|
+
const reads = started ?? await startBranchConnectionReads(props);
|
|
91
|
+
const { branchId, parsedPIT } = reads;
|
|
92
|
+
const endpoints = await reads.endpoints;
|
|
82
93
|
const matchEndpointType = props.endpointType ?? EndpointType.ReadWrite;
|
|
83
94
|
let endpoint = endpoints.find((e) => e.type === matchEndpointType);
|
|
84
95
|
if (!endpoint && props.endpointType == null) endpoint = endpoints[0];
|
|
85
96
|
if (!endpoint) throw new Error(`No ${props.endpointType ?? ""} endpoint found for the branch: ${branchId}`);
|
|
86
|
-
const role =
|
|
87
|
-
|
|
88
|
-
if (data.roles.length === 1) return data.roles[0].name;
|
|
89
|
-
throw new Error(`Multiple roles found for the branch, please provide one with the --role-name option: ${data.roles.map((r) => r.name).join(", ")}`);
|
|
90
|
-
});
|
|
91
|
-
const { data: { databases: branchDatabases } } = await props.apiClient.listProjectBranchDatabases(projectId, branchId);
|
|
97
|
+
const role = await reads.role;
|
|
98
|
+
const branchDatabases = await reads.databases;
|
|
92
99
|
const database = props.databaseName || (() => {
|
|
93
100
|
if (branchDatabases.length === 0) throw new Error(`No databases found for the branch: ${branchId}`);
|
|
94
101
|
if (branchDatabases.length === 1) return branchDatabases[0].name;
|
|
@@ -158,8 +165,9 @@ const resolveInspectTargets = async (props, scope) => {
|
|
|
158
165
|
branchDatabaseCount: 1
|
|
159
166
|
};
|
|
160
167
|
}
|
|
161
|
-
const
|
|
162
|
-
|
|
168
|
+
const reads = await startBranchConnectionReads(props);
|
|
169
|
+
const names = (await reads.databases).map((d) => d.name);
|
|
170
|
+
if (names.length === 0) throw new Error(`No databases found for the branch: ${reads.branchId}`);
|
|
163
171
|
const selection = selectInspectTargets({
|
|
164
172
|
branchDatabases: names,
|
|
165
173
|
scope
|
|
@@ -167,7 +175,7 @@ const resolveInspectTargets = async (props, scope) => {
|
|
|
167
175
|
const first = await resolveConnectionUri({
|
|
168
176
|
...props,
|
|
169
177
|
databaseName: selection.databases[0]
|
|
170
|
-
});
|
|
178
|
+
}, reads);
|
|
171
179
|
return {
|
|
172
180
|
targets: selection.databases.map((database) => ({
|
|
173
181
|
database,
|