neon 3.0.0 → 3.1.1
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/README.md +70 -5
- package/dist/_chunks/auth_selection-DGgq6ifc.js +83 -0
- package/dist/_chunks/cmd_pipeline-CUbBO9U_.js +2818 -0
- package/dist/_chunks/credentials-MYdHdKah.js +188 -0
- package/dist/_chunks/env-NbA61JR3.js +585 -0
- package/dist/_chunks/env_services-Tz9G4JeT.js +531 -0
- package/dist/_chunks/paths-DMq0Lt7a.js +151 -0
- package/dist/_chunks/profiles-Ir29rqns.js +217 -0
- package/dist/_chunks/psql-DWH-kc69.js +2169 -0
- package/dist/_chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/_chunks/secure_file-BucZj4yQ.js +39 -0
- package/dist/analytics.js +163 -207
- package/dist/api.js +815 -758
- package/dist/auth.js +121 -141
- package/dist/auth_context.js +39 -53
- package/dist/cli.js +4 -7
- package/dist/commands/api.js +220 -250
- package/dist/commands/api_keys.js +251 -314
- package/dist/commands/auth.js +283 -328
- package/dist/commands/bootstrap.js +372 -437
- package/dist/commands/branches.js +304 -455
- package/dist/commands/bucket.js +374 -514
- package/dist/commands/checkout.js +213 -298
- package/dist/commands/config.js +573 -690
- package/dist/commands/connection_string.js +137 -165
- package/dist/commands/data_api.js +238 -260
- package/dist/commands/databases.js +67 -76
- package/dist/commands/deploy.js +31 -25
- package/dist/commands/dev.js +639 -719
- package/dist/commands/diff.js +156 -200
- package/dist/commands/env.js +255 -305
- package/dist/commands/functions.js +275 -355
- package/dist/commands/index.js +70 -65
- package/dist/commands/init.js +84 -119
- package/dist/commands/inspect.js +55 -55
- package/dist/commands/ip_allow.js +88 -120
- package/dist/commands/link.js +874 -1019
- package/dist/commands/logs.js +291 -0
- package/dist/commands/neon_auth.js +725 -933
- package/dist/commands/operations.js +34 -25
- package/dist/commands/orgs.js +28 -18
- package/dist/commands/profile.js +615 -846
- package/dist/commands/projects.js +313 -373
- package/dist/commands/psql.js +60 -58
- package/dist/commands/roles.js +55 -58
- package/dist/commands/schema_diff.js +87 -131
- package/dist/commands/set_context.js +34 -26
- package/dist/commands/snapshots.js +288 -413
- package/dist/commands/status.js +41 -37
- package/dist/commands/user.js +21 -10
- package/dist/commands/vpc_endpoints.js +85 -113
- package/dist/config.js +7 -6
- package/dist/config_format.js +50 -66
- package/dist/config_template.js +128 -157
- package/dist/context.js +183 -235
- package/dist/current_branch_fast_path.js +40 -49
- package/dist/dev/env.js +2 -446
- package/dist/dev/functions.js +54 -68
- package/dist/dev/inputs.js +46 -58
- package/dist/dev/runtime.js +135 -164
- package/dist/dev/websocket.js +766 -959
- package/dist/env.js +27 -33
- package/dist/env_file.js +118 -132
- package/dist/env_services.js +2 -51
- package/dist/errors.js +57 -68
- package/dist/functions_api.js +45 -43
- package/dist/help.js +189 -140
- package/dist/index.js +182 -257
- package/dist/init/agents.js +137 -118
- package/dist/init/auth.js +58 -68
- package/dist/init/bootstrap.js +325 -396
- package/dist/init/build_config.js +4 -2
- package/dist/init/detect_agent.js +56 -101
- package/dist/init/editors.js +35 -52
- package/dist/init/enrich_output.js +51 -66
- package/dist/init/extension.js +134 -171
- package/dist/init/inspect.js +179 -266
- package/dist/init/interactive.js +510 -622
- package/dist/init/neonctl.js +117 -168
- package/dist/init/orchestrate.js +157 -173
- package/dist/init/phases/auth.js +188 -202
- package/dist/init/phases/cleanup.js +23 -23
- package/dist/init/phases/db.js +251 -277
- package/dist/init/phases/getting_started.js +213 -223
- package/dist/init/phases/mcp.js +174 -224
- package/dist/init/phases/migrations.js +247 -248
- package/dist/init/phases/neon_auth.js +114 -133
- package/dist/init/phases/setup.js +546 -703
- package/dist/init/phases/skills.js +75 -86
- package/dist/init/phases/status.js +72 -67
- package/dist/init/resolve_context.js +102 -99
- package/dist/init/route_command.js +91 -98
- package/dist/init/skills.js +174 -218
- package/dist/init/vsix.js +77 -99
- package/dist/log.js +17 -16
- package/dist/neon_services.js +104 -129
- package/dist/parameters.gen.js +481 -471
- package/dist/pkg.js +17 -19
- package/dist/profile_keys.js +44 -47
- package/dist/psql/cli.js +44 -47
- package/dist/psql/command/cmd_cond.js +231 -406
- package/dist/psql/command/cmd_connect.js +557 -764
- package/dist/psql/command/cmd_copy.js +728 -984
- package/dist/psql/command/cmd_describe.js +1499 -1688
- package/dist/psql/command/cmd_format.js +733 -905
- package/dist/psql/command/cmd_io.js +2 -2193
- package/dist/psql/command/cmd_lo.js +297 -359
- package/dist/psql/command/cmd_meta.js +727 -878
- package/dist/psql/command/cmd_misc.js +138 -172
- package/dist/psql/command/cmd_pipeline.js +2 -1148
- package/dist/psql/command/cmd_restrict.js +119 -155
- package/dist/psql/command/cmd_show.js +529 -688
- package/dist/psql/command/dispatch.js +260 -325
- package/dist/psql/command/inputQueue.js +35 -33
- package/dist/psql/command/shared.js +49 -63
- package/dist/psql/complete/filenames.js +90 -133
- package/dist/psql/complete/index.js +59 -97
- package/dist/psql/complete/matcher.js +236 -300
- package/dist/psql/complete/psqlVars.js +218 -223
- package/dist/psql/complete/queries.js +159 -177
- package/dist/psql/complete/rules.js +1493 -2299
- package/dist/psql/core/common.js +2 -1253
- package/dist/psql/core/help.js +456 -546
- package/dist/psql/core/mainloop.js +692 -1303
- package/dist/psql/core/prompt.js +391 -408
- package/dist/psql/core/settings.js +429 -644
- package/dist/psql/core/sqlHelp.js +480 -554
- package/dist/psql/core/startup.js +2 -846
- package/dist/psql/core/syncVars.js +67 -110
- package/dist/psql/core/variables.js +156 -278
- package/dist/psql/describe/formatters.js +884 -1285
- package/dist/psql/describe/processNamePattern.js +173 -260
- package/dist/psql/describe/queries.js +1368 -2403
- package/dist/psql/describe/versionGate.js +32 -41
- package/dist/psql/index.js +2 -2030
- package/dist/psql/io/history.js +232 -271
- package/dist/psql/io/input.js +103 -108
- package/dist/psql/io/lineEditor/buffer.js +238 -319
- package/dist/psql/io/lineEditor/complete.js +135 -213
- package/dist/psql/io/lineEditor/filename.js +139 -148
- package/dist/psql/io/lineEditor/index.js +653 -870
- package/dist/psql/io/lineEditor/keymap.js +544 -702
- package/dist/psql/io/lineEditor/vt100.js +294 -341
- package/dist/psql/io/pgpass.js +158 -187
- package/dist/psql/io/pgservice.js +146 -183
- package/dist/psql/io/psqlrc.js +328 -403
- package/dist/psql/print/aligned.js +1020 -1683
- package/dist/psql/print/asciidoc.js +180 -214
- package/dist/psql/print/crosstab.js +281 -442
- package/dist/psql/print/csv.js +48 -70
- package/dist/psql/print/html.js +195 -226
- package/dist/psql/print/json.js +75 -88
- package/dist/psql/print/latex.js +291 -364
- package/dist/psql/print/pager.js +171 -242
- package/dist/psql/print/troff.js +194 -226
- package/dist/psql/print/unaligned.js +69 -95
- package/dist/psql/print/units.js +167 -169
- package/dist/psql/scanner/slash.js +428 -483
- package/dist/psql/scanner/sql.js +445 -889
- package/dist/psql/scanner/stringutils.js +309 -379
- package/dist/psql/types/index.js +8 -7
- package/dist/psql/types/scanner.js +25 -22
- package/dist/psql/wire/connection.js +2042 -2803
- package/dist/psql/wire/copy.js +84 -100
- package/dist/psql/wire/notify.js +39 -59
- package/dist/psql/wire/pipeline.js +305 -518
- package/dist/psql/wire/protocol.js +349 -417
- package/dist/psql/wire/sasl.js +180 -265
- package/dist/psql/wire/tls.js +400 -561
- package/dist/storage_api.js +115 -129
- package/dist/test_utils/fixtures.js +94 -113
- package/dist/test_utils/oauth_server.js +10 -7
- package/dist/test_utils/project_dir.js +33 -0
- package/dist/utils/ai_gateway_notice.js +131 -162
- package/dist/utils/api_enums.js +21 -28
- package/dist/utils/auth.js +10 -4
- package/dist/utils/branch_notice.js +20 -19
- package/dist/utils/branch_picker.js +83 -89
- package/dist/utils/cli_name.js +15 -12
- package/dist/utils/compute_units.js +20 -27
- package/dist/utils/config_diff.js +127 -158
- package/dist/utils/enrichers.js +95 -148
- package/dist/utils/esbuild.js +130 -189
- package/dist/utils/flags.js +35 -47
- package/dist/utils/formats.js +8 -15
- package/dist/utils/git_diff.js +69 -80
- package/dist/utils/inspect_db.js +101 -143
- package/dist/utils/inspect_queries.js +179 -142
- package/dist/utils/middlewares.js +39 -45
- package/dist/utils/openapi.js +87 -99
- package/dist/utils/package_manager.js +312 -110
- package/dist/utils/point_in_time.js +49 -53
- package/dist/utils/psql.js +89 -106
- package/dist/utils/service_picker.js +55 -58
- package/dist/utils/string.js +5 -5
- package/dist/utils/ui.js +38 -55
- package/dist/utils/write_sync.js +26 -35
- package/dist/utils/zip.js +4 -3
- package/dist/writer.js +67 -87
- package/package.json +11 -6
- package/dist/_shared/auth_selection.js +0 -86
- package/dist/_shared/credentials.js +0 -209
- package/dist/_shared/env-core/env.js +0 -558
- package/dist/_shared/env-core/reuse-secrets.js +0 -223
- package/dist/_shared/paths.js +0 -148
- package/dist/_shared/profiles.js +0 -276
- package/dist/_shared/secure_file.js +0 -43
|
@@ -1,394 +1,334 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isNeonApiError, messageFromBody } from "../api.js";
|
|
3
|
-
import { updateContextFile } from "../context.js";
|
|
1
|
+
import { t as __exportAll } from "../_chunks/rolldown-runtime-D7D4PA-g.js";
|
|
4
2
|
import { isCi } from "../env.js";
|
|
5
3
|
import { log } from "../log.js";
|
|
6
|
-
import {
|
|
4
|
+
import { isNeonApiError, messageFromBody } from "../api.js";
|
|
5
|
+
import { updateContextFile } from "../context.js";
|
|
7
6
|
import { getCliName } from "../utils/cli_name.js";
|
|
7
|
+
import { writer } from "../writer.js";
|
|
8
|
+
import { projectCreateRequest, projectUpdateRequest } from "../parameters.gen.js";
|
|
8
9
|
import { getComputeUnits } from "../utils/compute_units.js";
|
|
9
10
|
import { psql } from "../utils/psql.js";
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
import prompts from "prompts";
|
|
12
|
+
//#region src/commands/projects.ts
|
|
13
|
+
var projects_exports = /* @__PURE__ */ __exportAll({
|
|
14
|
+
PROJECT_FIELDS: () => PROJECT_FIELDS,
|
|
15
|
+
REGIONS: () => REGIONS,
|
|
16
|
+
aliases: () => aliases,
|
|
17
|
+
builder: () => builder,
|
|
18
|
+
command: () => command,
|
|
19
|
+
describe: () => describe,
|
|
20
|
+
handler: () => handler
|
|
21
|
+
});
|
|
22
|
+
const PROJECT_FIELDS = [
|
|
23
|
+
"id",
|
|
24
|
+
"name",
|
|
25
|
+
"region_id",
|
|
26
|
+
"created_at"
|
|
16
27
|
];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
const REGIONS = [
|
|
29
|
+
"aws-us-west-2",
|
|
30
|
+
"aws-ap-southeast-1",
|
|
31
|
+
"aws-ap-southeast-2",
|
|
32
|
+
"aws-eu-central-1",
|
|
33
|
+
"aws-us-east-2",
|
|
34
|
+
"aws-us-east-1",
|
|
35
|
+
"azure-eastus2"
|
|
25
36
|
];
|
|
26
37
|
const PROJECTS_LIST_LIMIT = 100;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
await deleteProject(args);
|
|
151
|
-
})
|
|
152
|
-
.command("recover <id>", "Recovers a deleted project during the deletion grace period", (yargs) => yargs, async (args) => {
|
|
153
|
-
await recover(args);
|
|
154
|
-
})
|
|
155
|
-
.command("get <id>", "Get a project", (yargs) => yargs, async (args) => {
|
|
156
|
-
await get(args);
|
|
157
|
-
});
|
|
38
|
+
const command = "projects";
|
|
39
|
+
const describe = "Manage projects";
|
|
40
|
+
const aliases = ["project"];
|
|
41
|
+
const builder = (argv) => {
|
|
42
|
+
return argv.usage("$0 projects <sub-command> [options]").middleware((args) => {
|
|
43
|
+
args.projectId = args.id;
|
|
44
|
+
}).command("list", "List projects", (yargs) => yargs.options({
|
|
45
|
+
"org-id": {
|
|
46
|
+
describe: "List projects of a given organization",
|
|
47
|
+
type: "string"
|
|
48
|
+
},
|
|
49
|
+
"recoverable-only": {
|
|
50
|
+
describe: "List only deleted projects within their deletion grace period",
|
|
51
|
+
type: "boolean"
|
|
52
|
+
}
|
|
53
|
+
}), async (args) => {
|
|
54
|
+
await handleMissingOrgId(args, list);
|
|
55
|
+
}).command("create", "Create a project", (yargs) => yargs.options({
|
|
56
|
+
"block-public-connections": {
|
|
57
|
+
describe: projectCreateRequest["project.settings.block_public_connections"].description,
|
|
58
|
+
type: "boolean"
|
|
59
|
+
},
|
|
60
|
+
"block-vpc-connections": {
|
|
61
|
+
describe: projectCreateRequest["project.settings.block_vpc_connections"].description,
|
|
62
|
+
type: "boolean"
|
|
63
|
+
},
|
|
64
|
+
hipaa: {
|
|
65
|
+
describe: projectCreateRequest["project.settings.hipaa"].description,
|
|
66
|
+
type: "boolean"
|
|
67
|
+
},
|
|
68
|
+
name: {
|
|
69
|
+
describe: projectCreateRequest["project.name"].description,
|
|
70
|
+
type: "string"
|
|
71
|
+
},
|
|
72
|
+
"region-id": {
|
|
73
|
+
describe: `The region ID. Possible values: ${REGIONS.join(", ")}`,
|
|
74
|
+
type: "string"
|
|
75
|
+
},
|
|
76
|
+
"org-id": {
|
|
77
|
+
describe: "The project's organization ID",
|
|
78
|
+
type: "string"
|
|
79
|
+
},
|
|
80
|
+
psql: {
|
|
81
|
+
type: "boolean",
|
|
82
|
+
describe: "Connect to a new project via psql",
|
|
83
|
+
default: false
|
|
84
|
+
},
|
|
85
|
+
fallback: {
|
|
86
|
+
type: "boolean",
|
|
87
|
+
describe: "Force the embedded TypeScript psql fallback (for testing)",
|
|
88
|
+
default: false,
|
|
89
|
+
hidden: true
|
|
90
|
+
},
|
|
91
|
+
database: {
|
|
92
|
+
describe: projectCreateRequest["project.branch.database_name"].description,
|
|
93
|
+
type: "string"
|
|
94
|
+
},
|
|
95
|
+
role: {
|
|
96
|
+
describe: projectCreateRequest["project.branch.role_name"].description,
|
|
97
|
+
type: "string"
|
|
98
|
+
},
|
|
99
|
+
"pg-version": {
|
|
100
|
+
describe: "Major PostgreSQL version (14–19). Version 19 is available only in regions where it has been enabled.",
|
|
101
|
+
type: "number",
|
|
102
|
+
choices: [
|
|
103
|
+
14,
|
|
104
|
+
15,
|
|
105
|
+
16,
|
|
106
|
+
17,
|
|
107
|
+
18,
|
|
108
|
+
19
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"set-context": {
|
|
112
|
+
type: "boolean",
|
|
113
|
+
describe: "Set the current context to the new project",
|
|
114
|
+
default: false
|
|
115
|
+
},
|
|
116
|
+
cu: {
|
|
117
|
+
describe: "The number of Compute Units. Could be a fixed size (e.g. \"2\") or a range delimited by a dash (e.g. \"0.5-3\").",
|
|
118
|
+
type: "string"
|
|
119
|
+
}
|
|
120
|
+
}), async (args) => {
|
|
121
|
+
await handleMissingOrgId(args, create);
|
|
122
|
+
}).command("update <id>", "Update a project", (yargs) => yargs.options({
|
|
123
|
+
"block-vpc-connections": {
|
|
124
|
+
describe: projectUpdateRequest["project.settings.block_vpc_connections"].description + " Use --block-vpc-connections=false to set the value to false.",
|
|
125
|
+
type: "boolean"
|
|
126
|
+
},
|
|
127
|
+
"block-public-connections": {
|
|
128
|
+
describe: projectUpdateRequest["project.settings.block_public_connections"].description + " Use --block-public-connections=false to set the value to false.",
|
|
129
|
+
type: "boolean"
|
|
130
|
+
},
|
|
131
|
+
hipaa: {
|
|
132
|
+
describe: projectUpdateRequest["project.settings.hipaa"].description,
|
|
133
|
+
type: "boolean"
|
|
134
|
+
},
|
|
135
|
+
cu: {
|
|
136
|
+
describe: "The number of Compute Units. Could be a fixed size (e.g. \"2\") or a range delimited by a dash (e.g. \"0.5-3\").",
|
|
137
|
+
type: "string"
|
|
138
|
+
},
|
|
139
|
+
name: {
|
|
140
|
+
describe: projectUpdateRequest["project.name"].description,
|
|
141
|
+
type: "string"
|
|
142
|
+
},
|
|
143
|
+
"enable-logical-replication": {
|
|
144
|
+
describe: "Enable logical replication for all project endpoints. This suspends active endpoints and cannot be disabled.",
|
|
145
|
+
type: "boolean"
|
|
146
|
+
},
|
|
147
|
+
yes: {
|
|
148
|
+
type: "boolean",
|
|
149
|
+
default: false,
|
|
150
|
+
describe: "Skip the confirmation prompt when enabling logical replication."
|
|
151
|
+
}
|
|
152
|
+
}), async (args) => {
|
|
153
|
+
await update(args);
|
|
154
|
+
}).command("delete <id>", "Delete a project", (yargs) => yargs, async (args) => {
|
|
155
|
+
await deleteProject(args);
|
|
156
|
+
}).command("recover <id>", "Recovers a deleted project during the deletion grace period", (yargs) => yargs, async (args) => {
|
|
157
|
+
await recover(args);
|
|
158
|
+
}).command("get <id>", "Get a project", (yargs) => yargs, async (args) => {
|
|
159
|
+
await get(args);
|
|
160
|
+
});
|
|
158
161
|
};
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
const handler = (args) => {
|
|
163
|
+
return args;
|
|
161
164
|
};
|
|
162
165
|
const list = async (props) => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
out.write(sharedProjects, {
|
|
200
|
-
fields: PROJECT_FIELDS,
|
|
201
|
-
title: "Shared with you",
|
|
202
|
-
emptyMessage: "No projects have been shared with you",
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
out.end();
|
|
166
|
+
const getList = async (fn) => {
|
|
167
|
+
const result = [];
|
|
168
|
+
let cursor;
|
|
169
|
+
let end = false;
|
|
170
|
+
while (!end) {
|
|
171
|
+
const { data } = await fn({
|
|
172
|
+
limit: PROJECTS_LIST_LIMIT,
|
|
173
|
+
org_id: props.orgId,
|
|
174
|
+
recoverable: props.recoverableOnly,
|
|
175
|
+
cursor
|
|
176
|
+
});
|
|
177
|
+
result.push(...data.projects);
|
|
178
|
+
cursor = data.pagination?.cursor;
|
|
179
|
+
log.debug("Got %d projects, with cursor: %s", data.projects.length, cursor);
|
|
180
|
+
if (data.projects.length < PROJECTS_LIST_LIMIT) end = true;
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
};
|
|
184
|
+
const ownedProjects = await getList(props.apiClient.listProjects);
|
|
185
|
+
const sharedProjects = props.orgId || props.recoverableOnly ? [] : await getList(props.apiClient.listSharedProjects);
|
|
186
|
+
const out = writer(props);
|
|
187
|
+
out.write(ownedProjects, {
|
|
188
|
+
fields: props.recoverableOnly ? [
|
|
189
|
+
...PROJECT_FIELDS,
|
|
190
|
+
"deleted_at",
|
|
191
|
+
"recoverable_until"
|
|
192
|
+
] : PROJECT_FIELDS,
|
|
193
|
+
title: "Projects",
|
|
194
|
+
emptyMessage: props.recoverableOnly ? "You don't have any recoverable projects." : "You don't have any projects yet. See how to create a new project:\n> neon projects create --help"
|
|
195
|
+
});
|
|
196
|
+
if (!props.orgId && !props.recoverableOnly) out.write(sharedProjects, {
|
|
197
|
+
fields: PROJECT_FIELDS,
|
|
198
|
+
title: "Shared with you",
|
|
199
|
+
emptyMessage: "No projects have been shared with you"
|
|
200
|
+
});
|
|
201
|
+
out.end();
|
|
206
202
|
};
|
|
207
203
|
const create = async (props) => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
if (props.cu) {
|
|
248
|
-
project.default_endpoint_settings = props.cu
|
|
249
|
-
? getComputeUnits(props.cu)
|
|
250
|
-
: undefined;
|
|
251
|
-
}
|
|
252
|
-
const { data } = await props.apiClient.createProject({
|
|
253
|
-
project,
|
|
254
|
-
});
|
|
255
|
-
if (props.setContext) {
|
|
256
|
-
updateContextFile(props.contextFile, {
|
|
257
|
-
projectId: data.project.id,
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
const out = writer(props);
|
|
261
|
-
out.write(data.project, { fields: PROJECT_FIELDS, title: "Project" });
|
|
262
|
-
out.write(data.connection_uris, {
|
|
263
|
-
fields: ["connection_uri"],
|
|
264
|
-
title: "Connection URIs",
|
|
265
|
-
});
|
|
266
|
-
out.end();
|
|
267
|
-
if (props.psql) {
|
|
268
|
-
const connection_uri = data.connection_uris[0].connection_uri;
|
|
269
|
-
const psqlArgs = props["--"];
|
|
270
|
-
await psql(connection_uri, psqlArgs, {
|
|
271
|
-
mode: props.fallback ? "ts" : "auto",
|
|
272
|
-
});
|
|
273
|
-
}
|
|
204
|
+
const project = {};
|
|
205
|
+
if (props.hipaa !== void 0) {
|
|
206
|
+
if (!project.settings) project.settings = {};
|
|
207
|
+
project.settings.hipaa = props.hipaa;
|
|
208
|
+
}
|
|
209
|
+
if (props.blockPublicConnections !== void 0) {
|
|
210
|
+
if (!project.settings) project.settings = {};
|
|
211
|
+
project.settings.block_public_connections = props.blockPublicConnections;
|
|
212
|
+
}
|
|
213
|
+
if (props.blockVpcConnections !== void 0) {
|
|
214
|
+
if (!project.settings) project.settings = {};
|
|
215
|
+
project.settings.block_vpc_connections = props.blockVpcConnections;
|
|
216
|
+
}
|
|
217
|
+
if (props.name) project.name = props.name;
|
|
218
|
+
if (props.regionId) project.region_id = props.regionId;
|
|
219
|
+
if (props.orgId) project.org_id = props.orgId;
|
|
220
|
+
project.branch = {};
|
|
221
|
+
if (props.database) project.branch.database_name = props.database;
|
|
222
|
+
if (props.role) project.branch.role_name = props.role;
|
|
223
|
+
if (props.pgVersion !== void 0) project.pg_version = props.pgVersion;
|
|
224
|
+
if (props.cu) project.default_endpoint_settings = props.cu ? getComputeUnits(props.cu) : void 0;
|
|
225
|
+
const { data } = await props.apiClient.createProject({ project });
|
|
226
|
+
if (props.setContext) updateContextFile(props.contextFile, { projectId: data.project.id });
|
|
227
|
+
const out = writer(props);
|
|
228
|
+
out.write(data.project, {
|
|
229
|
+
fields: PROJECT_FIELDS,
|
|
230
|
+
title: "Project"
|
|
231
|
+
});
|
|
232
|
+
out.write(data.connection_uris, {
|
|
233
|
+
fields: ["connection_uri"],
|
|
234
|
+
title: "Connection URIs"
|
|
235
|
+
});
|
|
236
|
+
out.end();
|
|
237
|
+
if (props.psql) {
|
|
238
|
+
const connection_uri = data.connection_uris[0].connection_uri;
|
|
239
|
+
const psqlArgs = props["--"];
|
|
240
|
+
await psql(connection_uri, psqlArgs, { mode: props.fallback ? "ts" : "auto" });
|
|
241
|
+
}
|
|
274
242
|
};
|
|
275
243
|
const deleteProject = async (props) => {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
fields: PROJECT_FIELDS,
|
|
279
|
-
});
|
|
244
|
+
const { data } = await props.apiClient.deleteProject(props.id);
|
|
245
|
+
writer(props).end(data.project, { fields: PROJECT_FIELDS });
|
|
280
246
|
};
|
|
281
247
|
const update = async (props) => {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
project.settings.block_public_connections =
|
|
318
|
-
props.blockPublicConnections;
|
|
319
|
-
}
|
|
320
|
-
if (props.blockVpcConnections !== undefined) {
|
|
321
|
-
if (!project.settings) {
|
|
322
|
-
project.settings = {};
|
|
323
|
-
}
|
|
324
|
-
project.settings.block_vpc_connections = props.blockVpcConnections;
|
|
325
|
-
}
|
|
326
|
-
if (props.name) {
|
|
327
|
-
project.name = props.name;
|
|
328
|
-
}
|
|
329
|
-
if (props.cu) {
|
|
330
|
-
project.default_endpoint_settings = props.cu
|
|
331
|
-
? getComputeUnits(props.cu)
|
|
332
|
-
: undefined;
|
|
333
|
-
}
|
|
334
|
-
const { data } = await props.apiClient.updateProject(props.id, {
|
|
335
|
-
project,
|
|
336
|
-
});
|
|
337
|
-
writer(props).end(data.project, { fields: PROJECT_FIELDS });
|
|
248
|
+
const project = {};
|
|
249
|
+
if (props.enableLogicalReplication !== void 0) {
|
|
250
|
+
if (!props.enableLogicalReplication) throw new Error("Logical replication cannot be disabled once it has been enabled.");
|
|
251
|
+
if (!props.yes) {
|
|
252
|
+
if (isCi() || !process.stdin.isTTY) throw new Error("Enabling logical replication requires confirmation. Re-run interactively or pass --yes.");
|
|
253
|
+
const { proceed } = await prompts({
|
|
254
|
+
onState: onPromptState,
|
|
255
|
+
type: "confirm",
|
|
256
|
+
name: "proceed",
|
|
257
|
+
message: "Enable logical replication? This suspends active endpoints and cannot be undone.",
|
|
258
|
+
initial: false
|
|
259
|
+
});
|
|
260
|
+
if (!proceed) {
|
|
261
|
+
log.info("Logical replication was not enabled.");
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
project.settings = { enable_logical_replication: true };
|
|
266
|
+
}
|
|
267
|
+
if (props.hipaa !== void 0) {
|
|
268
|
+
if (!project.settings) project.settings = {};
|
|
269
|
+
project.settings.hipaa = props.hipaa;
|
|
270
|
+
}
|
|
271
|
+
if (props.blockPublicConnections !== void 0) {
|
|
272
|
+
if (!project.settings) project.settings = {};
|
|
273
|
+
project.settings.block_public_connections = props.blockPublicConnections;
|
|
274
|
+
}
|
|
275
|
+
if (props.blockVpcConnections !== void 0) {
|
|
276
|
+
if (!project.settings) project.settings = {};
|
|
277
|
+
project.settings.block_vpc_connections = props.blockVpcConnections;
|
|
278
|
+
}
|
|
279
|
+
if (props.name) project.name = props.name;
|
|
280
|
+
if (props.cu) project.default_endpoint_settings = props.cu ? getComputeUnits(props.cu) : void 0;
|
|
281
|
+
const { data } = await props.apiClient.updateProject(props.id, { project });
|
|
282
|
+
writer(props).end(data.project, { fields: PROJECT_FIELDS });
|
|
338
283
|
};
|
|
339
284
|
const recover = async (props) => {
|
|
340
|
-
|
|
341
|
-
|
|
285
|
+
const { data } = await props.apiClient.recoverProject(props.id);
|
|
286
|
+
writer(props).end(data.project, { fields: PROJECT_FIELDS });
|
|
342
287
|
};
|
|
343
288
|
const get = async (props) => {
|
|
344
|
-
|
|
345
|
-
|
|
289
|
+
const { data } = await props.apiClient.getProject(props.id);
|
|
290
|
+
writer(props).end(data.project, { fields: PROJECT_FIELDS });
|
|
346
291
|
};
|
|
347
292
|
const handleMissingOrgId = async (args, cmd) => {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
293
|
+
try {
|
|
294
|
+
await cmd(args);
|
|
295
|
+
} catch (err) {
|
|
296
|
+
if (!isCi() && isOrgIdError(err)) {
|
|
297
|
+
const orgId = await selectOrg(args);
|
|
298
|
+
await cmd({
|
|
299
|
+
...args,
|
|
300
|
+
orgId
|
|
301
|
+
});
|
|
302
|
+
} else throw err;
|
|
303
|
+
}
|
|
360
304
|
};
|
|
361
305
|
const isOrgIdError = (err) => {
|
|
362
|
-
|
|
363
|
-
err.status === 400 &&
|
|
364
|
-
messageFromBody(err.data)?.includes("org_id is required"));
|
|
306
|
+
return isNeonApiError(err) && err.status === 400 && messageFromBody(err.data)?.includes("org_id is required");
|
|
365
307
|
};
|
|
366
308
|
const selectOrg = async (props) => {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
updateContextFile(props.contextFile, { orgId });
|
|
391
|
-
writer(props).text(`
|
|
309
|
+
const { data: { organizations } } = await props.apiClient.getCurrentUserOrganizations();
|
|
310
|
+
if (!organizations?.length) throw new Error(`You don't belong to any organizations. Please create an organization first.`);
|
|
311
|
+
const { orgId } = await prompts({
|
|
312
|
+
onState: onPromptState,
|
|
313
|
+
type: "select",
|
|
314
|
+
name: "orgId",
|
|
315
|
+
message: `What organization would you like to use?`,
|
|
316
|
+
choices: organizations.map((org) => ({
|
|
317
|
+
title: `${org.name} (${org.id})`,
|
|
318
|
+
value: org.id
|
|
319
|
+
})),
|
|
320
|
+
initial: 0
|
|
321
|
+
});
|
|
322
|
+
const { save } = await prompts({
|
|
323
|
+
onState: onPromptState,
|
|
324
|
+
type: "confirm",
|
|
325
|
+
name: "save",
|
|
326
|
+
message: `Would you like to use this organization by default?`,
|
|
327
|
+
initial: true
|
|
328
|
+
});
|
|
329
|
+
if (save) {
|
|
330
|
+
updateContextFile(props.contextFile, { orgId });
|
|
331
|
+
writer(props).text(`
|
|
392
332
|
The organization ID has been saved in ${props.contextFile}
|
|
393
333
|
|
|
394
334
|
If you'd like to change the default organization later, use
|
|
@@ -400,15 +340,15 @@ Or to clear the context file and forget the default organization
|
|
|
400
340
|
${getCliName()} link --clear
|
|
401
341
|
|
|
402
342
|
`);
|
|
403
|
-
|
|
404
|
-
|
|
343
|
+
}
|
|
344
|
+
return orgId;
|
|
405
345
|
};
|
|
406
346
|
const onPromptState = (state) => {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
process.exit(1);
|
|
413
|
-
}
|
|
347
|
+
if (state.aborted) {
|
|
348
|
+
process.stdout.write("\x1B[?25h");
|
|
349
|
+
process.stdout.write("\n");
|
|
350
|
+
process.exit(1);
|
|
351
|
+
}
|
|
414
352
|
};
|
|
353
|
+
//#endregion
|
|
354
|
+
export { PROJECT_FIELDS, REGIONS, aliases, builder, command, describe, handler, projects_exports as t };
|