neonctl 1.29.1 → 1.29.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/analytics.js +78 -0
- package/api.js +35 -0
- package/auth.js +101 -0
- package/{src/cli.ts → cli.js} +0 -1
- package/commands/auth.js +102 -0
- package/commands/auth.test.js +42 -0
- package/commands/branches.js +303 -0
- package/commands/branches.test.js +321 -0
- package/commands/connection_string.js +158 -0
- package/commands/connection_string.test.js +253 -0
- package/commands/databases.js +79 -0
- package/commands/databases.test.js +51 -0
- package/commands/help.test.js +11 -0
- package/{src/commands/index.ts → commands/index.js} +10 -11
- package/commands/ip_allow.js +135 -0
- package/commands/ip_allow.test.js +78 -0
- package/commands/operations.js +28 -0
- package/commands/operations.test.js +11 -0
- package/commands/projects.js +186 -0
- package/commands/projects.test.js +132 -0
- package/commands/roles.js +57 -0
- package/commands/roles.test.js +42 -0
- package/commands/set_context.js +22 -0
- package/commands/set_context.test.js +53 -0
- package/commands/user.js +15 -0
- package/config.js +11 -0
- package/context.js +48 -0
- package/env.js +6 -0
- package/errors.js +16 -0
- package/help.js +146 -0
- package/index.js +168 -0
- package/log.js +15 -0
- package/package.json +1 -1
- package/parameters.gen.js +322 -0
- package/pkg.js +3 -45
- package/test_utils/mock_server.js +16 -0
- package/test_utils/oauth_server.js +9 -0
- package/test_utils/test_cli_command.js +80 -0
- package/types.js +1 -0
- package/utils/enrichers.js +49 -0
- package/utils/formats.js +5 -0
- package/utils/formats.test.js +32 -0
- package/utils/middlewares.js +20 -0
- package/utils/point_in_time.js +50 -0
- package/utils/psql.js +24 -0
- package/utils/string.js +5 -0
- package/utils/ui.js +59 -0
- package/writer.js +87 -0
- package/writer.test.js +86 -0
- package/.bump +0 -1
- package/.editorconfig +0 -7
- package/.eslintrc.cjs +0 -15
- package/.github/workflows/commitlint.yml +0 -46
- package/.github/workflows/pr.yml +0 -25
- package/.github/workflows/release.yml +0 -30
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/.prettierignore +0 -3
- package/.prettierrc.json +0 -3
- package/.releaserc.json +0 -47
- package/LICENSE +0 -202
- package/commitlint.config.cjs +0 -7
- package/generateOptionsFromSpec.ts +0 -68
- package/jest/setup.js +0 -5
- package/jest.config.ts +0 -199
- package/mocks/bin/psql.cjs +0 -9
- package/mocks/main/projects/GET.js +0 -27
- package/mocks/main/projects/POST.js +0 -22
- package/mocks/main/projects/shared/GET.js +0 -16
- package/mocks/main/projects/test/DELETE.json +0 -7
- package/mocks/main/projects/test/GET.json +0 -13
- package/mocks/main/projects/test/PATCH.js +0 -18
- package/mocks/main/projects/test/branches/GET.json +0 -25
- package/mocks/main/projects/test/branches/POST.js +0 -83
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/DELETE.json +0 -7
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/GET.json +0 -9
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/PATCH.js +0 -14
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/GET.json +0 -6
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/POST.js +0 -13
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/databases/test_db/DELETE.json +0 -6
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/endpoints/GET.json +0 -26
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/endpoints/POST.json +0 -6
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/GET.json +0 -3
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/POST.js +0 -14
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/test_role/DELETE.json +0 -6
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/roles/test_role/reveal_password/GET.json +0 -3
- package/mocks/main/projects/test/branches/br-cloudy-branch-12345678/set_as_primary/POST.json +0 -9
- package/mocks/main/projects/test/branches/br-numbered-branch-123456/GET.json +0 -10
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/DELETE.json +0 -7
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/GET.json +0 -10
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/PATCH.js +0 -14
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/GET.json +0 -6
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/POST.js +0 -13
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/databases/test_db/DELETE.json +0 -6
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/endpoints/GET.json +0 -26
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/endpoints/POST.json +0 -6
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/restore/POST.js +0 -16
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/GET.json +0 -3
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/POST.js +0 -14
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/test_role/DELETE.json +0 -6
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/roles/test_role/reveal_password/GET.json +0 -3
- package/mocks/main/projects/test/branches/br-sunny-branch-123456/set_as_primary/POST.json +0 -9
- package/mocks/main/projects/test/endpoints/GET.json +0 -9
- package/mocks/main/projects/test/endpoints/POST.js +0 -32
- package/mocks/main/projects/test/endpoints/test_endpoint_id/DELETE.json +0 -7
- package/mocks/main/projects/test/endpoints/test_endpoint_id/GET.json +0 -9
- package/mocks/main/projects/test/endpoints/test_endpoint_id/PATCH.js +0 -17
- package/mocks/main/projects/test/operations/GET.json +0 -22
- package/mocks/main/users/me/GET.json +0 -5
- package/mocks/restore/projects/test/branches/GET.json +0 -21
- package/mocks/restore/projects/test/branches/br-another-branch-123456/GET.json +0 -6
- package/mocks/restore/projects/test/branches/br-another-branch-123456/restore/POST.js +0 -13
- package/mocks/restore/projects/test/branches/br-any-branch-123456/GET.json +0 -6
- package/mocks/restore/projects/test/branches/br-parent-tots-123456/GET.json +0 -7
- package/mocks/restore/projects/test/branches/br-parent-tots-123456/restore/POST.js +0 -14
- package/mocks/restore/projects/test/branches/br-self-tolsn-123456/GET.json +0 -6
- package/mocks/restore/projects/test/branches/br-self-tolsn-123456/restore/POST.js +0 -15
- package/mocks/single_project/projects/GET.json +0 -10
- package/mocks/single_project/projects/test-project-123456/GET.json +0 -14
- package/mocks/single_project/projects/test-project-123456/branches/GET.json +0 -11
- package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/databases/GET.json +0 -3
- package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/endpoints/GET.json +0 -10
- package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/roles/GET.json +0 -3
- package/mocks/single_project/projects/test-project-123456/branches/br-main-branch-123456/roles/test_role/reveal_password/GET.json +0 -3
- package/rollup.config.js +0 -20
- package/snapshots/commands/branches.test.snap +0 -221
- package/snapshots/commands/connection_string.test.snap +0 -70
- package/snapshots/commands/databases.test.snap +0 -20
- package/snapshots/commands/ip_allow.test.snap +0 -55
- package/snapshots/commands/operations.test.snap +0 -17
- package/snapshots/commands/projects.test.snap +0 -141
- package/snapshots/commands/roles.test.snap +0 -19
- package/snapshots/commands/set_context.test.snap +0 -30
- package/snapshots/writer.test.snap +0 -60
- package/snapshotsResolver.cjs +0 -32
- package/src/analytics.ts +0 -95
- package/src/api.ts +0 -44
- package/src/auth.ts +0 -137
- package/src/commands/auth.test.ts +0 -62
- package/src/commands/auth.ts +0 -148
- package/src/commands/branches.test.ts +0 -354
- package/src/commands/branches.ts +0 -451
- package/src/commands/connection_string.test.ts +0 -250
- package/src/commands/connection_string.ts +0 -210
- package/src/commands/databases.test.ts +0 -55
- package/src/commands/databases.ts +0 -129
- package/src/commands/help.test.ts +0 -13
- package/src/commands/ip_allow.test.ts +0 -86
- package/src/commands/ip_allow.ts +0 -202
- package/src/commands/operations.test.ts +0 -13
- package/src/commands/operations.ts +0 -41
- package/src/commands/projects.test.ts +0 -147
- package/src/commands/projects.ts +0 -275
- package/src/commands/roles.test.ts +0 -46
- package/src/commands/roles.ts +0 -100
- package/src/commands/set_context.test.ts +0 -64
- package/src/commands/set_context.ts +0 -27
- package/src/commands/user.ts +0 -21
- package/src/config.ts +0 -22
- package/src/context.ts +0 -61
- package/src/env.ts +0 -7
- package/src/errors.ts +0 -24
- package/src/help.ts +0 -185
- package/src/index.ts +0 -180
- package/src/log.ts +0 -16
- package/src/parameters.gen.ts +0 -332
- package/src/pkg.ts +0 -9
- package/src/test_utils/mock_server.ts +0 -27
- package/src/test_utils/oauth_server.ts +0 -10
- package/src/test_utils/test_cli_command.ts +0 -117
- package/src/types.ts +0 -25
- package/src/utils/enrichers.ts +0 -73
- package/src/utils/formats.test.ts +0 -41
- package/src/utils/formats.ts +0 -11
- package/src/utils/middlewares.ts +0 -23
- package/src/utils/point_in_time.ts +0 -86
- package/src/utils/psql.ts +0 -29
- package/src/utils/string.ts +0 -8
- package/src/utils/ui.ts +0 -64
- package/src/writer.test.ts +0 -98
- package/src/writer.ts +0 -131
- package/tsconfig.json +0 -17
- /package/{src/callback.html → callback.html} +0 -0
package/src/parameters.gen.ts
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
// FILE IS GENERATED, DO NOT EDIT
|
|
2
|
-
|
|
3
|
-
export const projectCreateRequest = {
|
|
4
|
-
'project.settings.quota.active_time_seconds': {
|
|
5
|
-
type: "number",
|
|
6
|
-
description: "The total amount of wall-clock time allowed to be spent by the project's compute endpoints.\n",
|
|
7
|
-
demandOption: false,
|
|
8
|
-
},
|
|
9
|
-
'project.settings.quota.compute_time_seconds': {
|
|
10
|
-
type: "number",
|
|
11
|
-
description: "The total amount of CPU seconds allowed to be spent by the project's compute endpoints.\n",
|
|
12
|
-
demandOption: false,
|
|
13
|
-
},
|
|
14
|
-
'project.settings.quota.written_data_bytes': {
|
|
15
|
-
type: "number",
|
|
16
|
-
description: "Total amount of data written to all of a project's branches.\n",
|
|
17
|
-
demandOption: false,
|
|
18
|
-
},
|
|
19
|
-
'project.settings.quota.data_transfer_bytes': {
|
|
20
|
-
type: "number",
|
|
21
|
-
description: "Total amount of data transferred from all of a project's branches using the proxy.\n",
|
|
22
|
-
demandOption: false,
|
|
23
|
-
},
|
|
24
|
-
'project.settings.quota.logical_size_bytes': {
|
|
25
|
-
type: "number",
|
|
26
|
-
description: "Limit on the logical size of every project's branch.\n",
|
|
27
|
-
demandOption: false,
|
|
28
|
-
},
|
|
29
|
-
'project.settings.allowed_ips.ips': {
|
|
30
|
-
type: "array",
|
|
31
|
-
description: "A list of IP addresses that are allowed to connect to the endpoint.",
|
|
32
|
-
demandOption: false,
|
|
33
|
-
},
|
|
34
|
-
'project.settings.allowed_ips.primary_branch_only': {
|
|
35
|
-
type: "boolean",
|
|
36
|
-
description: "If true, the list will be applied only to the primary branch.",
|
|
37
|
-
demandOption: true,
|
|
38
|
-
},
|
|
39
|
-
'project.settings.enable_logical_replication': {
|
|
40
|
-
type: "boolean",
|
|
41
|
-
description: "Sets wal_level=logical for all compute endpoints in this project.\nAll active endpoints will be suspended.\nOnce enabled, logical replication cannot be disabled.\n",
|
|
42
|
-
demandOption: false,
|
|
43
|
-
},
|
|
44
|
-
'project.name': {
|
|
45
|
-
type: "string",
|
|
46
|
-
description: "The project name",
|
|
47
|
-
demandOption: false,
|
|
48
|
-
},
|
|
49
|
-
'project.branch.name': {
|
|
50
|
-
type: "string",
|
|
51
|
-
description: "The branch name. If not specified, the default branch name will be used.\n",
|
|
52
|
-
demandOption: false,
|
|
53
|
-
},
|
|
54
|
-
'project.branch.role_name': {
|
|
55
|
-
type: "string",
|
|
56
|
-
description: "The role name. If not specified, the default role name will be used.\n",
|
|
57
|
-
demandOption: false,
|
|
58
|
-
},
|
|
59
|
-
'project.branch.database_name': {
|
|
60
|
-
type: "string",
|
|
61
|
-
description: "The database name. If not specified, the default database name will be used.\n",
|
|
62
|
-
demandOption: false,
|
|
63
|
-
},
|
|
64
|
-
'project.provisioner': {
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
|
|
67
|
-
demandOption: false,
|
|
68
|
-
choices: ["k8s-pod","k8s-neonvm"],
|
|
69
|
-
},
|
|
70
|
-
'project.region_id': {
|
|
71
|
-
type: "string",
|
|
72
|
-
description: "The region identifier. Refer to our [Regions](https://neon.tech/docs/introduction/regions) documentation for supported regions. Values are specified in this format: `aws-us-east-1`\n",
|
|
73
|
-
demandOption: false,
|
|
74
|
-
},
|
|
75
|
-
'project.default_endpoint_settings.suspend_timeout_seconds': {
|
|
76
|
-
type: "number",
|
|
77
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe minimum value is `60` seconds (1 minute).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
78
|
-
demandOption: false,
|
|
79
|
-
},
|
|
80
|
-
'project.pg_version': {
|
|
81
|
-
type: "number",
|
|
82
|
-
description: "The major Postgres version number. Currently supported versions are `14`, `15`, and `16`.",
|
|
83
|
-
demandOption: false,
|
|
84
|
-
},
|
|
85
|
-
'project.store_passwords': {
|
|
86
|
-
type: "boolean",
|
|
87
|
-
description: "Whether or not passwords are stored for roles in the Neon project. Storing passwords facilitates access to Neon features that require authorization.\n",
|
|
88
|
-
demandOption: false,
|
|
89
|
-
},
|
|
90
|
-
'project.history_retention_seconds': {
|
|
91
|
-
type: "number",
|
|
92
|
-
description: "The number of seconds to retain the point-in-time restore (PITR) backup history for this project.\nThe default is 604800 seconds (7 days).\n",
|
|
93
|
-
demandOption: false,
|
|
94
|
-
},
|
|
95
|
-
} as const;
|
|
96
|
-
|
|
97
|
-
export const projectUpdateRequest = {
|
|
98
|
-
'project.settings.quota.active_time_seconds': {
|
|
99
|
-
type: "number",
|
|
100
|
-
description: "The total amount of wall-clock time allowed to be spent by the project's compute endpoints.\n",
|
|
101
|
-
demandOption: false,
|
|
102
|
-
},
|
|
103
|
-
'project.settings.quota.compute_time_seconds': {
|
|
104
|
-
type: "number",
|
|
105
|
-
description: "The total amount of CPU seconds allowed to be spent by the project's compute endpoints.\n",
|
|
106
|
-
demandOption: false,
|
|
107
|
-
},
|
|
108
|
-
'project.settings.quota.written_data_bytes': {
|
|
109
|
-
type: "number",
|
|
110
|
-
description: "Total amount of data written to all of a project's branches.\n",
|
|
111
|
-
demandOption: false,
|
|
112
|
-
},
|
|
113
|
-
'project.settings.quota.data_transfer_bytes': {
|
|
114
|
-
type: "number",
|
|
115
|
-
description: "Total amount of data transferred from all of a project's branches using the proxy.\n",
|
|
116
|
-
demandOption: false,
|
|
117
|
-
},
|
|
118
|
-
'project.settings.quota.logical_size_bytes': {
|
|
119
|
-
type: "number",
|
|
120
|
-
description: "Limit on the logical size of every project's branch.\n",
|
|
121
|
-
demandOption: false,
|
|
122
|
-
},
|
|
123
|
-
'project.settings.allowed_ips.ips': {
|
|
124
|
-
type: "array",
|
|
125
|
-
description: "A list of IP addresses that are allowed to connect to the endpoint.",
|
|
126
|
-
demandOption: false,
|
|
127
|
-
},
|
|
128
|
-
'project.settings.allowed_ips.primary_branch_only': {
|
|
129
|
-
type: "boolean",
|
|
130
|
-
description: "If true, the list will be applied only to the primary branch.",
|
|
131
|
-
demandOption: true,
|
|
132
|
-
},
|
|
133
|
-
'project.settings.enable_logical_replication': {
|
|
134
|
-
type: "boolean",
|
|
135
|
-
description: "Sets wal_level=logical for all compute endpoints in this project.\nAll active endpoints will be suspended.\nOnce enabled, logical replication cannot be disabled.\n",
|
|
136
|
-
demandOption: false,
|
|
137
|
-
},
|
|
138
|
-
'project.name': {
|
|
139
|
-
type: "string",
|
|
140
|
-
description: "The project name",
|
|
141
|
-
demandOption: false,
|
|
142
|
-
},
|
|
143
|
-
'project.default_endpoint_settings.suspend_timeout_seconds': {
|
|
144
|
-
type: "number",
|
|
145
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe minimum value is `60` seconds (1 minute).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
146
|
-
demandOption: false,
|
|
147
|
-
},
|
|
148
|
-
'project.history_retention_seconds': {
|
|
149
|
-
type: "number",
|
|
150
|
-
description: "The number of seconds to retain the point-in-time restore (PITR) backup history for this project.\nThe default is 604800 seconds (7 days).\n",
|
|
151
|
-
demandOption: false,
|
|
152
|
-
},
|
|
153
|
-
} as const;
|
|
154
|
-
|
|
155
|
-
export const branchCreateRequest = {
|
|
156
|
-
'endpoints': {
|
|
157
|
-
type: "array",
|
|
158
|
-
description: undefined,
|
|
159
|
-
demandOption: false,
|
|
160
|
-
},
|
|
161
|
-
'branch.parent_id': {
|
|
162
|
-
type: "string",
|
|
163
|
-
description: "The `branch_id` of the parent branch. If omitted or empty, the branch will be created from the project's primary branch.\n",
|
|
164
|
-
demandOption: false,
|
|
165
|
-
},
|
|
166
|
-
'branch.name': {
|
|
167
|
-
type: "string",
|
|
168
|
-
description: "The branch name\n",
|
|
169
|
-
demandOption: false,
|
|
170
|
-
},
|
|
171
|
-
'branch.parent_lsn': {
|
|
172
|
-
type: "string",
|
|
173
|
-
description: "A Log Sequence Number (LSN) on the parent branch. The branch will be created with data from this LSN.\n",
|
|
174
|
-
demandOption: false,
|
|
175
|
-
},
|
|
176
|
-
'branch.parent_timestamp': {
|
|
177
|
-
type: "string",
|
|
178
|
-
description: "A timestamp identifying a point in time on the parent branch. The branch will be created with data starting from this point in time.\nThe timestamp must be provided in ISO 8601 format; for example: `2024-02-26T12:00:00Z`.\n",
|
|
179
|
-
demandOption: false,
|
|
180
|
-
},
|
|
181
|
-
'branch.protected': {
|
|
182
|
-
type: "boolean",
|
|
183
|
-
description: "Whether the branch is protected\n",
|
|
184
|
-
demandOption: false,
|
|
185
|
-
},
|
|
186
|
-
} as const;
|
|
187
|
-
|
|
188
|
-
export const branchCreateRequestEndpointOptions = {
|
|
189
|
-
'type': {
|
|
190
|
-
type: "string",
|
|
191
|
-
description: "The compute endpoint type. Either `read_write` or `read_only`.\nThe `read_only` compute endpoint type is not yet supported.\n",
|
|
192
|
-
demandOption: true,
|
|
193
|
-
choices: ["read_only","read_write"],
|
|
194
|
-
},
|
|
195
|
-
'provisioner': {
|
|
196
|
-
type: "string",
|
|
197
|
-
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
|
|
198
|
-
demandOption: false,
|
|
199
|
-
choices: ["k8s-pod","k8s-neonvm"],
|
|
200
|
-
},
|
|
201
|
-
'suspend_timeout_seconds': {
|
|
202
|
-
type: "number",
|
|
203
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe minimum value is `60` seconds (1 minute).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
204
|
-
demandOption: false,
|
|
205
|
-
},
|
|
206
|
-
} as const;
|
|
207
|
-
|
|
208
|
-
export const branchUpdateRequest = {
|
|
209
|
-
'branch.name': {
|
|
210
|
-
type: "string",
|
|
211
|
-
description: undefined,
|
|
212
|
-
demandOption: false,
|
|
213
|
-
},
|
|
214
|
-
'branch.protected': {
|
|
215
|
-
type: "boolean",
|
|
216
|
-
description: undefined,
|
|
217
|
-
demandOption: false,
|
|
218
|
-
},
|
|
219
|
-
} as const;
|
|
220
|
-
|
|
221
|
-
export const endpointCreateRequest = {
|
|
222
|
-
'endpoint.branch_id': {
|
|
223
|
-
type: "string",
|
|
224
|
-
description: "The ID of the branch the compute endpoint will be associated with\n",
|
|
225
|
-
demandOption: true,
|
|
226
|
-
},
|
|
227
|
-
'endpoint.region_id': {
|
|
228
|
-
type: "string",
|
|
229
|
-
description: "The region where the compute endpoint will be created. Only the project's `region_id` is permitted.\n",
|
|
230
|
-
demandOption: false,
|
|
231
|
-
},
|
|
232
|
-
'endpoint.type': {
|
|
233
|
-
type: "string",
|
|
234
|
-
description: "The compute endpoint type. Either `read_write` or `read_only`.\nThe `read_only` compute endpoint type is not yet supported.\n",
|
|
235
|
-
demandOption: true,
|
|
236
|
-
choices: ["read_only","read_write"],
|
|
237
|
-
},
|
|
238
|
-
'endpoint.provisioner': {
|
|
239
|
-
type: "string",
|
|
240
|
-
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
|
|
241
|
-
demandOption: false,
|
|
242
|
-
choices: ["k8s-pod","k8s-neonvm"],
|
|
243
|
-
},
|
|
244
|
-
'endpoint.pooler_enabled': {
|
|
245
|
-
type: "boolean",
|
|
246
|
-
description: "Whether to enable connection pooling for the compute endpoint\n",
|
|
247
|
-
demandOption: false,
|
|
248
|
-
},
|
|
249
|
-
'endpoint.pooler_mode': {
|
|
250
|
-
type: "string",
|
|
251
|
-
description: "The connection pooler mode. Neon supports PgBouncer in `transaction` mode only.\n",
|
|
252
|
-
demandOption: false,
|
|
253
|
-
choices: ["transaction"],
|
|
254
|
-
},
|
|
255
|
-
'endpoint.disabled': {
|
|
256
|
-
type: "boolean",
|
|
257
|
-
description: "Whether to restrict connections to the compute endpoint.\nEnabling this option schedules a suspend compute operation.\nA disabled compute endpoint cannot be enabled by a connection or\nconsole action. However, the compute endpoint is periodically\nenabled by check_availability operations.\n",
|
|
258
|
-
demandOption: false,
|
|
259
|
-
},
|
|
260
|
-
'endpoint.passwordless_access': {
|
|
261
|
-
type: "boolean",
|
|
262
|
-
description: "NOT YET IMPLEMENTED. Whether to permit passwordless access to the compute endpoint.\n",
|
|
263
|
-
demandOption: false,
|
|
264
|
-
},
|
|
265
|
-
'endpoint.suspend_timeout_seconds': {
|
|
266
|
-
type: "number",
|
|
267
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe minimum value is `60` seconds (1 minute).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
268
|
-
demandOption: false,
|
|
269
|
-
},
|
|
270
|
-
} as const;
|
|
271
|
-
|
|
272
|
-
export const endpointUpdateRequest = {
|
|
273
|
-
'endpoint.branch_id': {
|
|
274
|
-
type: "string",
|
|
275
|
-
description: "The destination branch ID. The destination branch must not have an exsiting read-write endpoint.\n",
|
|
276
|
-
demandOption: false,
|
|
277
|
-
},
|
|
278
|
-
'endpoint.provisioner': {
|
|
279
|
-
type: "string",
|
|
280
|
-
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
|
|
281
|
-
demandOption: false,
|
|
282
|
-
choices: ["k8s-pod","k8s-neonvm"],
|
|
283
|
-
},
|
|
284
|
-
'endpoint.pooler_enabled': {
|
|
285
|
-
type: "boolean",
|
|
286
|
-
description: "Whether to enable connection pooling for the compute endpoint\n",
|
|
287
|
-
demandOption: false,
|
|
288
|
-
},
|
|
289
|
-
'endpoint.pooler_mode': {
|
|
290
|
-
type: "string",
|
|
291
|
-
description: "The connection pooler mode. Neon supports PgBouncer in `transaction` mode only.\n",
|
|
292
|
-
demandOption: false,
|
|
293
|
-
choices: ["transaction"],
|
|
294
|
-
},
|
|
295
|
-
'endpoint.disabled': {
|
|
296
|
-
type: "boolean",
|
|
297
|
-
description: "Whether to restrict connections to the compute endpoint.\nEnabling this option schedules a suspend compute operation.\nA disabled compute endpoint cannot be enabled by a connection or\nconsole action. However, the compute endpoint is periodically\nenabled by check_availability operations.\n",
|
|
298
|
-
demandOption: false,
|
|
299
|
-
},
|
|
300
|
-
'endpoint.passwordless_access': {
|
|
301
|
-
type: "boolean",
|
|
302
|
-
description: "NOT YET IMPLEMENTED. Whether to permit passwordless access to the compute endpoint.\n",
|
|
303
|
-
demandOption: false,
|
|
304
|
-
},
|
|
305
|
-
'endpoint.suspend_timeout_seconds': {
|
|
306
|
-
type: "number",
|
|
307
|
-
description: "Duration of inactivity in seconds after which the compute endpoint is\nautomatically suspended. The value `0` means use the global default.\nThe value `-1` means never suspend. The default value is `300` seconds (5 minutes).\nThe minimum value is `60` seconds (1 minute).\nThe maximum value is `604800` seconds (1 week). For more information, see\n[Auto-suspend configuration](https://neon.tech/docs/manage/endpoints#auto-suspend-configuration).\n",
|
|
308
|
-
demandOption: false,
|
|
309
|
-
},
|
|
310
|
-
} as const;
|
|
311
|
-
|
|
312
|
-
export const databaseCreateRequest = {
|
|
313
|
-
'database.name': {
|
|
314
|
-
type: "string",
|
|
315
|
-
description: "The name of the datbase\n",
|
|
316
|
-
demandOption: true,
|
|
317
|
-
},
|
|
318
|
-
'database.owner_name': {
|
|
319
|
-
type: "string",
|
|
320
|
-
description: "The name of the role that owns the database\n",
|
|
321
|
-
demandOption: true,
|
|
322
|
-
},
|
|
323
|
-
} as const;
|
|
324
|
-
|
|
325
|
-
export const roleCreateRequest = {
|
|
326
|
-
'role.name': {
|
|
327
|
-
type: "string",
|
|
328
|
-
description: "The role name. Cannot exceed 63 bytes in length.\n",
|
|
329
|
-
demandOption: true,
|
|
330
|
-
},
|
|
331
|
-
} as const;
|
|
332
|
-
|
package/src/pkg.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import emocks from 'emocks';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import { Server } from 'node:http';
|
|
4
|
-
import { AddressInfo } from 'node:net';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { log } from '../log';
|
|
7
|
-
|
|
8
|
-
export const runMockServer = async (mockDir: string) =>
|
|
9
|
-
new Promise<Server>((resolve) => {
|
|
10
|
-
const app = express();
|
|
11
|
-
app.use(express.json());
|
|
12
|
-
app.use(
|
|
13
|
-
'/',
|
|
14
|
-
emocks(join(process.cwd(), 'mocks', mockDir), {
|
|
15
|
-
'404': (req, res) => res.status(404).send({ message: 'Not Found' }),
|
|
16
|
-
}),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const server = app.listen(0);
|
|
20
|
-
server.on('listening', () => {
|
|
21
|
-
resolve(server);
|
|
22
|
-
log.info(
|
|
23
|
-
'Mock server listening at %d',
|
|
24
|
-
(server.address() as AddressInfo).port,
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { log } from '../log';
|
|
2
|
-
import { OAuth2Server } from 'oauth2-mock-server';
|
|
3
|
-
|
|
4
|
-
export const startOauthServer = async () => {
|
|
5
|
-
const server = new OAuth2Server();
|
|
6
|
-
await server.issuer.keys.generate('RS256');
|
|
7
|
-
await server.start(0, 'localhost');
|
|
8
|
-
log.info('Started OAuth server');
|
|
9
|
-
return server;
|
|
10
|
-
};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { test, expect, describe, beforeAll, afterAll } from '@jest/globals';
|
|
2
|
-
import { fork } from 'node:child_process';
|
|
3
|
-
import { Server } from 'node:http';
|
|
4
|
-
import { AddressInfo } from 'node:net';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { log } from '../log.js';
|
|
7
|
-
import strip from 'strip-ansi';
|
|
8
|
-
|
|
9
|
-
import { runMockServer } from './mock_server.js';
|
|
10
|
-
|
|
11
|
-
export type TestCliCommandOptions = {
|
|
12
|
-
name: string;
|
|
13
|
-
args: string[];
|
|
14
|
-
before?: () => Promise<void>;
|
|
15
|
-
after?: () => Promise<void>;
|
|
16
|
-
mockDir?: string;
|
|
17
|
-
expected?: {
|
|
18
|
-
snapshot?: true;
|
|
19
|
-
stdout?: string | ReturnType<typeof expect.stringMatching>;
|
|
20
|
-
stderr?: string | ReturnType<typeof expect.stringMatching>;
|
|
21
|
-
code?: number;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const testCliCommand = ({
|
|
26
|
-
args,
|
|
27
|
-
name,
|
|
28
|
-
expected,
|
|
29
|
-
before,
|
|
30
|
-
after,
|
|
31
|
-
mockDir = 'main',
|
|
32
|
-
}: TestCliCommandOptions) => {
|
|
33
|
-
let server: Server;
|
|
34
|
-
describe(name, () => {
|
|
35
|
-
beforeAll(async () => {
|
|
36
|
-
if (before) {
|
|
37
|
-
await before();
|
|
38
|
-
}
|
|
39
|
-
server = await runMockServer(mockDir);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
afterAll(async () => {
|
|
43
|
-
if (after) {
|
|
44
|
-
await after();
|
|
45
|
-
}
|
|
46
|
-
return new Promise<void>((resolve) => {
|
|
47
|
-
server.close(() => {
|
|
48
|
-
resolve();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('test', async () => {
|
|
54
|
-
let output = '';
|
|
55
|
-
let error = '';
|
|
56
|
-
|
|
57
|
-
const cp = fork(
|
|
58
|
-
join(process.cwd(), './dist/index.js'),
|
|
59
|
-
[
|
|
60
|
-
'--api-host',
|
|
61
|
-
`http://localhost:${(server.address() as AddressInfo).port}`,
|
|
62
|
-
'--output',
|
|
63
|
-
'yaml',
|
|
64
|
-
'--api-key',
|
|
65
|
-
'test-key',
|
|
66
|
-
'--no-analytics',
|
|
67
|
-
...args,
|
|
68
|
-
],
|
|
69
|
-
{
|
|
70
|
-
stdio: 'pipe',
|
|
71
|
-
env: {
|
|
72
|
-
PATH: `mocks/bin:${process.env.PATH}`,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
return new Promise<void>((resolve, reject) => {
|
|
78
|
-
cp.stdout?.on('data', (data) => {
|
|
79
|
-
output += data.toString();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
cp.stderr?.on('data', (data) => {
|
|
83
|
-
error += data.toString();
|
|
84
|
-
log.error(data.toString());
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
cp.on('error', (err) => {
|
|
88
|
-
throw err;
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
cp.on('close', (code) => {
|
|
92
|
-
try {
|
|
93
|
-
expect(code).toBe(expected?.code ?? 0);
|
|
94
|
-
if (expected) {
|
|
95
|
-
if (expected.snapshot) {
|
|
96
|
-
expect(output).toMatchSnapshot();
|
|
97
|
-
}
|
|
98
|
-
if (expected.stdout !== undefined) {
|
|
99
|
-
expect(strip(output)).toEqual(expected.stdout);
|
|
100
|
-
}
|
|
101
|
-
if (expected.stderr !== undefined) {
|
|
102
|
-
expect(strip(error).replace(/\s+/g, ' ').trim()).toEqual(
|
|
103
|
-
typeof expected.stderr === 'string'
|
|
104
|
-
? expected.stderr.toString().replace(/\s+/g, ' ')
|
|
105
|
-
: expected.stderr,
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
resolve();
|
|
110
|
-
} catch (err) {
|
|
111
|
-
reject(err);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
};
|
package/src/types.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Api } from '@neondatabase/api-client';
|
|
2
|
-
|
|
3
|
-
export type CommonProps = {
|
|
4
|
-
apiClient: Api<unknown>;
|
|
5
|
-
apiKey: string;
|
|
6
|
-
apiHost: string;
|
|
7
|
-
output: 'yaml' | 'json' | 'table';
|
|
8
|
-
contextFile: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type ProjectScopeProps = CommonProps & {
|
|
12
|
-
projectId: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type IdOrNameProps = {
|
|
16
|
-
id: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type BranchScopeProps = ProjectScopeProps &
|
|
20
|
-
(
|
|
21
|
-
| {
|
|
22
|
-
branch: string;
|
|
23
|
-
}
|
|
24
|
-
| IdOrNameProps
|
|
25
|
-
);
|
package/src/utils/enrichers.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { BranchScopeProps, CommonProps, ProjectScopeProps } from '../types.js';
|
|
2
|
-
import { looksLikeBranchId } from './formats.js';
|
|
3
|
-
|
|
4
|
-
export const branchIdResolve = async ({
|
|
5
|
-
branch,
|
|
6
|
-
apiClient,
|
|
7
|
-
projectId,
|
|
8
|
-
}: {
|
|
9
|
-
branch: string | number;
|
|
10
|
-
apiClient: CommonProps['apiClient'];
|
|
11
|
-
projectId: string;
|
|
12
|
-
}) => {
|
|
13
|
-
branch = branch.toString();
|
|
14
|
-
if (looksLikeBranchId(branch)) {
|
|
15
|
-
return branch;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const { data } = await apiClient.listProjectBranches(projectId);
|
|
19
|
-
const branchData = data.branches.find((b) => b.name === branch);
|
|
20
|
-
if (!branchData) {
|
|
21
|
-
throw new Error(
|
|
22
|
-
`Branch ${branch} not found.\nAvailable branches: ${data.branches
|
|
23
|
-
.map((b) => b.name)
|
|
24
|
-
.join(', ')}`,
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
return branchData.id;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const branchIdFromProps = async (props: BranchScopeProps) => {
|
|
31
|
-
const branch =
|
|
32
|
-
'branch' in props && typeof props.branch === 'string'
|
|
33
|
-
? props.branch
|
|
34
|
-
: (props as any).id;
|
|
35
|
-
|
|
36
|
-
if (branch) {
|
|
37
|
-
return await branchIdResolve({
|
|
38
|
-
branch,
|
|
39
|
-
apiClient: props.apiClient,
|
|
40
|
-
projectId: props.projectId,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const { data } = await props.apiClient.listProjectBranches(props.projectId);
|
|
45
|
-
const primaryBranch = data.branches.find((b) => b.primary);
|
|
46
|
-
|
|
47
|
-
if (primaryBranch) {
|
|
48
|
-
return primaryBranch.id;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
throw new Error('No primary branch found');
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const fillSingleProject = async (
|
|
55
|
-
props: CommonProps & Partial<Pick<ProjectScopeProps, 'projectId'>>,
|
|
56
|
-
) => {
|
|
57
|
-
if (props.projectId) {
|
|
58
|
-
return props;
|
|
59
|
-
}
|
|
60
|
-
const { data } = await props.apiClient.listProjects({});
|
|
61
|
-
if (data.projects.length === 0) {
|
|
62
|
-
throw new Error('No projects found');
|
|
63
|
-
}
|
|
64
|
-
if (data.projects.length > 1) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
`Multiple projects found, please provide one with the --project-id option`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
...props,
|
|
71
|
-
projectId: data.projects[0].id,
|
|
72
|
-
};
|
|
73
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { test, describe, expect } from '@jest/globals';
|
|
2
|
-
|
|
3
|
-
import { looksLikeBranchId, looksLikeLSN, looksLikeTimestamp } from './formats';
|
|
4
|
-
|
|
5
|
-
describe('branch formats', () => {
|
|
6
|
-
test('branch name', () => {
|
|
7
|
-
expect(looksLikeBranchId('master')).toBe(false);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test('initial short', () => {
|
|
11
|
-
expect(looksLikeBranchId('br-flower-sunshine-123456')).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('update 1, longer version', () => {
|
|
15
|
-
expect(looksLikeBranchId('br-flower-sunshine-12345678')).toBe(true);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('update 2, includes region', () => {
|
|
19
|
-
expect(looksLikeBranchId('br-bold-recipe-a13oexw7')).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe('timestamp formats', () => {
|
|
24
|
-
test('valid', () => {
|
|
25
|
-
expect(looksLikeTimestamp('2021-03-13T19:47:33.000Z')).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('invalid', () => {
|
|
29
|
-
expect(looksLikeTimestamp('branch_name')).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('LSN formats', () => {
|
|
34
|
-
test('valid', () => {
|
|
35
|
-
expect(looksLikeLSN('0/1F56000')).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('invalid', () => {
|
|
39
|
-
expect(looksLikeLSN('branch_name')).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
});
|
package/src/utils/formats.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const HAIKU_REGEX = /^[a-z]+-[a-z]+-[a-z0-9]+$/;
|
|
2
|
-
|
|
3
|
-
export const looksLikeBranchId = (branch: string) =>
|
|
4
|
-
branch.startsWith('br-') && HAIKU_REGEX.test(branch.substring(3));
|
|
5
|
-
|
|
6
|
-
const LSN_REGEX = /^[a-fA-F0-9]{1,8}\/[a-fA-F0-9]{1,8}$/;
|
|
7
|
-
|
|
8
|
-
export const looksLikeLSN = (lsn: string) => LSN_REGEX.test(lsn);
|
|
9
|
-
|
|
10
|
-
export const looksLikeTimestamp = (timestamp: string) =>
|
|
11
|
-
!isNaN(Date.parse(timestamp));
|
package/src/utils/middlewares.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This middleware is needed to fill in the args for nested objects,
|
|
3
|
-
* so that required arguments would work
|
|
4
|
-
* otherwise yargs just throws an error
|
|
5
|
-
*/
|
|
6
|
-
export const fillInArgs = (
|
|
7
|
-
args: Record<string, unknown>,
|
|
8
|
-
currentArgs: Record<string, unknown> = args,
|
|
9
|
-
acc: string[] = [],
|
|
10
|
-
) => {
|
|
11
|
-
Object.entries(currentArgs).forEach(([k, v]) => {
|
|
12
|
-
if (k === '_') {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
// check if the value is an Object
|
|
16
|
-
if (typeof v === 'object' && v !== null) {
|
|
17
|
-
fillInArgs(args, v as any, [...acc, k]);
|
|
18
|
-
} else if (acc.length > 0) {
|
|
19
|
-
// if it's not an object, and we have a path, fill it in
|
|
20
|
-
args[acc.join('.') + '.' + k] = v;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|