neonctl 2.28.0 → 2.29.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.
Files changed (135) hide show
  1. package/README.md +71 -71
  2. package/dist/analytics.js +35 -33
  3. package/dist/api.js +34 -34
  4. package/dist/auth.js +50 -44
  5. package/dist/cli.js +2 -2
  6. package/dist/commands/auth.js +58 -52
  7. package/dist/commands/bootstrap.js +115 -157
  8. package/dist/commands/branches.js +154 -147
  9. package/dist/commands/bucket.js +124 -118
  10. package/dist/commands/checkout.js +49 -49
  11. package/dist/commands/config.js +212 -88
  12. package/dist/commands/connection_string.js +62 -62
  13. package/dist/commands/data_api.js +96 -96
  14. package/dist/commands/databases.js +23 -23
  15. package/dist/commands/deploy.js +12 -12
  16. package/dist/commands/dev.js +114 -114
  17. package/dist/commands/env.js +43 -43
  18. package/dist/commands/functions.js +97 -98
  19. package/dist/commands/index.js +26 -26
  20. package/dist/commands/init.js +23 -22
  21. package/dist/commands/ip_allow.js +29 -29
  22. package/dist/commands/link.js +223 -166
  23. package/dist/commands/neon_auth.js +381 -363
  24. package/dist/commands/operations.js +11 -11
  25. package/dist/commands/orgs.js +8 -8
  26. package/dist/commands/projects.js +101 -99
  27. package/dist/commands/psql.js +31 -31
  28. package/dist/commands/roles.js +21 -21
  29. package/dist/commands/schema_diff.js +23 -23
  30. package/dist/commands/set_context.js +17 -17
  31. package/dist/commands/status.js +17 -17
  32. package/dist/commands/user.js +5 -5
  33. package/dist/commands/vpc_endpoints.js +50 -50
  34. package/dist/config.js +7 -7
  35. package/dist/config_format.js +5 -5
  36. package/dist/context.js +23 -16
  37. package/dist/current_branch_fast_path.js +6 -6
  38. package/dist/dev/env.js +34 -34
  39. package/dist/dev/functions.js +4 -4
  40. package/dist/dev/inputs.js +6 -6
  41. package/dist/dev/runtime.js +25 -25
  42. package/dist/env.js +14 -14
  43. package/dist/env_file.js +13 -13
  44. package/dist/errors.js +19 -19
  45. package/dist/functions_api.js +10 -10
  46. package/dist/help.js +15 -15
  47. package/dist/index.js +94 -92
  48. package/dist/log.js +2 -2
  49. package/dist/pkg.js +5 -5
  50. package/dist/psql/cli.js +4 -2
  51. package/dist/psql/command/cmd_cond.js +61 -61
  52. package/dist/psql/command/cmd_connect.js +159 -154
  53. package/dist/psql/command/cmd_copy.js +107 -97
  54. package/dist/psql/command/cmd_describe.js +368 -363
  55. package/dist/psql/command/cmd_format.js +276 -263
  56. package/dist/psql/command/cmd_io.js +269 -263
  57. package/dist/psql/command/cmd_lo.js +74 -66
  58. package/dist/psql/command/cmd_meta.js +148 -148
  59. package/dist/psql/command/cmd_misc.js +17 -17
  60. package/dist/psql/command/cmd_pipeline.js +142 -135
  61. package/dist/psql/command/cmd_restrict.js +25 -25
  62. package/dist/psql/command/cmd_show.js +183 -168
  63. package/dist/psql/command/dispatch.js +26 -26
  64. package/dist/psql/command/shared.js +14 -14
  65. package/dist/psql/complete/filenames.js +16 -16
  66. package/dist/psql/complete/index.js +4 -4
  67. package/dist/psql/complete/matcher.js +33 -32
  68. package/dist/psql/complete/psqlVars.js +173 -173
  69. package/dist/psql/complete/queries.js +5 -3
  70. package/dist/psql/complete/rules.js +900 -863
  71. package/dist/psql/core/common.js +136 -133
  72. package/dist/psql/core/help.js +343 -343
  73. package/dist/psql/core/mainloop.js +160 -153
  74. package/dist/psql/core/prompt.js +126 -123
  75. package/dist/psql/core/settings.js +111 -111
  76. package/dist/psql/core/sqlHelp.js +150 -150
  77. package/dist/psql/core/startup.js +211 -205
  78. package/dist/psql/core/syncVars.js +14 -14
  79. package/dist/psql/core/variables.js +24 -24
  80. package/dist/psql/describe/formatters.js +302 -289
  81. package/dist/psql/describe/processNamePattern.js +28 -28
  82. package/dist/psql/describe/queries.js +656 -651
  83. package/dist/psql/index.js +436 -411
  84. package/dist/psql/io/history.js +36 -36
  85. package/dist/psql/io/input.js +15 -15
  86. package/dist/psql/io/lineEditor/buffer.js +27 -25
  87. package/dist/psql/io/lineEditor/complete.js +15 -15
  88. package/dist/psql/io/lineEditor/filename.js +22 -22
  89. package/dist/psql/io/lineEditor/index.js +65 -62
  90. package/dist/psql/io/lineEditor/keymap.js +325 -318
  91. package/dist/psql/io/lineEditor/vt100.js +60 -60
  92. package/dist/psql/io/pgpass.js +18 -18
  93. package/dist/psql/io/pgservice.js +14 -14
  94. package/dist/psql/io/psqlrc.js +46 -46
  95. package/dist/psql/print/aligned.js +175 -166
  96. package/dist/psql/print/asciidoc.js +51 -51
  97. package/dist/psql/print/crosstab.js +34 -31
  98. package/dist/psql/print/csv.js +25 -22
  99. package/dist/psql/print/html.js +54 -54
  100. package/dist/psql/print/json.js +12 -12
  101. package/dist/psql/print/latex.js +118 -118
  102. package/dist/psql/print/pager.js +28 -26
  103. package/dist/psql/print/troff.js +48 -48
  104. package/dist/psql/print/unaligned.js +15 -14
  105. package/dist/psql/print/units.js +17 -17
  106. package/dist/psql/scanner/slash.js +48 -46
  107. package/dist/psql/scanner/sql.js +88 -84
  108. package/dist/psql/scanner/stringutils.js +21 -17
  109. package/dist/psql/types/index.js +7 -7
  110. package/dist/psql/types/scanner.js +8 -8
  111. package/dist/psql/wire/connection.js +341 -327
  112. package/dist/psql/wire/copy.js +7 -7
  113. package/dist/psql/wire/pipeline.js +26 -24
  114. package/dist/psql/wire/protocol.js +102 -102
  115. package/dist/psql/wire/sasl.js +62 -62
  116. package/dist/psql/wire/tls.js +79 -73
  117. package/dist/storage_api.js +15 -15
  118. package/dist/test_utils/fixtures.js +34 -31
  119. package/dist/test_utils/oauth_server.js +5 -5
  120. package/dist/utils/api_enums.js +13 -13
  121. package/dist/utils/branch_notice.js +5 -5
  122. package/dist/utils/branch_picker.js +26 -26
  123. package/dist/utils/compute_units.js +4 -4
  124. package/dist/utils/enrichers.js +20 -15
  125. package/dist/utils/esbuild.js +28 -28
  126. package/dist/utils/formats.js +1 -1
  127. package/dist/utils/middlewares.js +3 -3
  128. package/dist/utils/package_manager.js +68 -0
  129. package/dist/utils/point_in_time.js +12 -12
  130. package/dist/utils/psql.js +30 -30
  131. package/dist/utils/string.js +2 -2
  132. package/dist/utils/ui.js +9 -9
  133. package/dist/utils/zip.js +1 -1
  134. package/dist/writer.js +17 -17
  135. package/package.json +6 -7
@@ -1,19 +1,19 @@
1
- import { fillSingleProject } from '../utils/enrichers.js';
2
- import { writer } from '../writer.js';
3
- const OPERATIONS_FIELDS = ['id', 'action', 'status', 'created_at'];
4
- export const command = 'operations';
5
- export const describe = 'Manage operations';
6
- export const aliases = ['operation'];
1
+ import { fillSingleProject } from "../utils/enrichers.js";
2
+ import { writer } from "../writer.js";
3
+ const OPERATIONS_FIELDS = ["id", "action", "status", "created_at"];
4
+ export const command = "operations";
5
+ export const describe = "Manage operations";
6
+ export const aliases = ["operation"];
7
7
  export const builder = (argv) => argv
8
- .usage('$0 operations <sub-command> [options]')
8
+ .usage("$0 operations <sub-command> [options]")
9
9
  .options({
10
- 'project-id': {
11
- describe: 'Project ID',
12
- type: 'string',
10
+ "project-id": {
11
+ describe: "Project ID",
12
+ type: "string",
13
13
  },
14
14
  })
15
15
  .middleware(fillSingleProject)
16
- .command('list', 'List operations', (yargs) => yargs, (args) => list(args));
16
+ .command("list", "List operations", (yargs) => yargs, (args) => list(args));
17
17
  export const handler = (args) => {
18
18
  return args;
19
19
  };
@@ -1,10 +1,10 @@
1
- import { writer } from '../writer.js';
2
- const ORG_FIELDS = ['id', 'name'];
3
- export const command = 'orgs';
4
- export const describe = 'Manage organizations';
5
- export const aliases = ['org'];
1
+ import { writer } from "../writer.js";
2
+ const ORG_FIELDS = ["id", "name"];
3
+ export const command = "orgs";
4
+ export const describe = "Manage organizations";
5
+ export const aliases = ["org"];
6
6
  export const builder = (argv) => {
7
- return argv.usage('$0 orgs <sub-command> [options]').command('list', 'List organizations', (yargs) => yargs, async (args) => {
7
+ return argv.usage("$0 orgs <sub-command> [options]").command("list", "List organizations", (yargs) => yargs, async (args) => {
8
8
  // @ts-expect-error: TODO - Assert `args` is `CommonProps`
9
9
  await list(args);
10
10
  });
@@ -17,8 +17,8 @@ const list = async (props) => {
17
17
  const { data: { organizations }, } = await props.apiClient.getCurrentUserOrganizations();
18
18
  out.write(organizations, {
19
19
  fields: ORG_FIELDS,
20
- title: 'Organizations',
21
- emptyMessage: 'You are not a member of any organization.',
20
+ title: "Organizations",
21
+ emptyMessage: "You are not a member of any organization.",
22
22
  });
23
23
  out.end();
24
24
  };
@@ -1,143 +1,143 @@
1
- import { log } from '../log.js';
2
- import { projectCreateRequest, projectUpdateRequest, } from '../parameters.gen.js';
3
- import { writer } from '../writer.js';
4
- import { psql } from '../utils/psql.js';
5
- import { updateContextFile } from '../context.js';
6
- import { getComputeUnits } from '../utils/compute_units.js';
7
- import { isNeonApiError, messageFromBody } from '../api.js';
8
- import prompts from 'prompts';
9
- import { isCi } from '../env.js';
1
+ import prompts from "prompts";
2
+ import { isNeonApiError, messageFromBody } from "../api.js";
3
+ import { updateContextFile } from "../context.js";
4
+ import { isCi } from "../env.js";
5
+ import { log } from "../log.js";
6
+ import { projectCreateRequest, projectUpdateRequest, } from "../parameters.gen.js";
7
+ import { getComputeUnits } from "../utils/compute_units.js";
8
+ import { psql } from "../utils/psql.js";
9
+ import { writer } from "../writer.js";
10
10
  export const PROJECT_FIELDS = [
11
- 'id',
12
- 'name',
13
- 'region_id',
14
- 'created_at',
11
+ "id",
12
+ "name",
13
+ "region_id",
14
+ "created_at",
15
15
  ];
16
16
  export const REGIONS = [
17
- 'aws-us-west-2',
18
- 'aws-ap-southeast-1',
19
- 'aws-ap-southeast-2',
20
- 'aws-eu-central-1',
21
- 'aws-us-east-2',
22
- 'aws-us-east-1',
23
- 'azure-eastus2',
17
+ "aws-us-west-2",
18
+ "aws-ap-southeast-1",
19
+ "aws-ap-southeast-2",
20
+ "aws-eu-central-1",
21
+ "aws-us-east-2",
22
+ "aws-us-east-1",
23
+ "azure-eastus2",
24
24
  ];
25
25
  const PROJECTS_LIST_LIMIT = 100;
26
- export const command = 'projects';
27
- export const describe = 'Manage projects';
28
- export const aliases = ['project'];
26
+ export const command = "projects";
27
+ export const describe = "Manage projects";
28
+ export const aliases = ["project"];
29
29
  export const builder = (argv) => {
30
30
  return argv
31
- .usage('$0 projects <sub-command> [options]')
31
+ .usage("$0 projects <sub-command> [options]")
32
32
  .middleware((args) => {
33
33
  // Provide alias for analytics
34
34
  args.projectId = args.id;
35
35
  })
36
- .command('list', 'List projects', (yargs) => yargs.options({
37
- 'org-id': {
38
- describe: 'List projects of a given organization',
39
- type: 'string',
36
+ .command("list", "List projects", (yargs) => yargs.options({
37
+ "org-id": {
38
+ describe: "List projects of a given organization",
39
+ type: "string",
40
40
  },
41
- 'recoverable-only': {
42
- describe: 'List only deleted projects within their deletion grace period',
43
- type: 'boolean',
41
+ "recoverable-only": {
42
+ describe: "List only deleted projects within their deletion grace period",
43
+ type: "boolean",
44
44
  },
45
45
  }), async (args) => {
46
46
  await handleMissingOrgId(args, list);
47
47
  })
48
- .command('create', 'Create a project', (yargs) => yargs.options({
49
- 'block-public-connections': {
50
- describe: projectCreateRequest['project.settings.block_public_connections']
51
- .description,
52
- type: 'boolean',
48
+ .command("create", "Create a project", (yargs) => yargs.options({
49
+ "block-public-connections": {
50
+ describe: projectCreateRequest["project.settings.block_public_connections"].description,
51
+ type: "boolean",
53
52
  },
54
- 'block-vpc-connections': {
55
- describe: projectCreateRequest['project.settings.block_vpc_connections']
56
- .description,
57
- type: 'boolean',
53
+ "block-vpc-connections": {
54
+ describe: projectCreateRequest["project.settings.block_vpc_connections"].description,
55
+ type: "boolean",
58
56
  },
59
57
  hipaa: {
60
- describe: projectCreateRequest['project.settings.hipaa'].description,
61
- type: 'boolean',
58
+ describe: projectCreateRequest["project.settings.hipaa"]
59
+ .description,
60
+ type: "boolean",
62
61
  },
63
62
  name: {
64
- describe: projectCreateRequest['project.name'].description,
65
- type: 'string',
63
+ describe: projectCreateRequest["project.name"].description,
64
+ type: "string",
66
65
  },
67
- 'region-id': {
68
- describe: `The region ID. Possible values: ${REGIONS.join(', ')}`,
69
- type: 'string',
66
+ "region-id": {
67
+ describe: `The region ID. Possible values: ${REGIONS.join(", ")}`,
68
+ type: "string",
70
69
  },
71
- 'org-id': {
70
+ "org-id": {
72
71
  describe: "The project's organization ID",
73
- type: 'string',
72
+ type: "string",
74
73
  },
75
74
  psql: {
76
- type: 'boolean',
77
- describe: 'Connect to a new project via psql',
75
+ type: "boolean",
76
+ describe: "Connect to a new project via psql",
78
77
  default: false,
79
78
  },
80
79
  fallback: {
81
- type: 'boolean',
82
- describe: 'Force the embedded TypeScript psql fallback (for testing)',
80
+ type: "boolean",
81
+ describe: "Force the embedded TypeScript psql fallback (for testing)",
83
82
  default: false,
84
83
  hidden: true,
85
84
  },
86
85
  database: {
87
- describe: projectCreateRequest['project.branch.database_name'].description,
88
- type: 'string',
86
+ describe: projectCreateRequest["project.branch.database_name"]
87
+ .description,
88
+ type: "string",
89
89
  },
90
90
  role: {
91
- describe: projectCreateRequest['project.branch.role_name'].description,
92
- type: 'string',
91
+ describe: projectCreateRequest["project.branch.role_name"]
92
+ .description,
93
+ type: "string",
93
94
  },
94
- 'set-context': {
95
- type: 'boolean',
96
- describe: 'Set the current context to the new project',
95
+ "set-context": {
96
+ type: "boolean",
97
+ describe: "Set the current context to the new project",
97
98
  default: false,
98
99
  },
99
100
  cu: {
100
101
  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").',
101
- type: 'string',
102
+ type: "string",
102
103
  },
103
104
  }), async (args) => {
104
105
  await handleMissingOrgId(args, create);
105
106
  })
106
- .command('update <id>', 'Update a project', (yargs) => yargs.options({
107
- 'block-vpc-connections': {
108
- describe: projectUpdateRequest['project.settings.block_vpc_connections']
109
- .description +
110
- ' Use --block-vpc-connections=false to set the value to false.',
111
- type: 'boolean',
107
+ .command("update <id>", "Update a project", (yargs) => yargs.options({
108
+ "block-vpc-connections": {
109
+ describe: projectUpdateRequest["project.settings.block_vpc_connections"].description +
110
+ " Use --block-vpc-connections=false to set the value to false.",
111
+ type: "boolean",
112
112
  },
113
- 'block-public-connections': {
114
- describe: projectUpdateRequest['project.settings.block_public_connections']
115
- .description +
116
- ' Use --block-public-connections=false to set the value to false.',
117
- type: 'boolean',
113
+ "block-public-connections": {
114
+ describe: projectUpdateRequest["project.settings.block_public_connections"].description +
115
+ " Use --block-public-connections=false to set the value to false.",
116
+ type: "boolean",
118
117
  },
119
118
  hipaa: {
120
- describe: projectUpdateRequest['project.settings.hipaa'].description,
121
- type: 'boolean',
119
+ describe: projectUpdateRequest["project.settings.hipaa"]
120
+ .description,
121
+ type: "boolean",
122
122
  },
123
123
  cu: {
124
124
  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").',
125
- type: 'string',
125
+ type: "string",
126
126
  },
127
127
  name: {
128
- describe: projectUpdateRequest['project.name'].description,
129
- type: 'string',
128
+ describe: projectUpdateRequest["project.name"].description,
129
+ type: "string",
130
130
  },
131
131
  }), async (args) => {
132
132
  await update(args);
133
133
  })
134
- .command('delete <id>', 'Delete a project', (yargs) => yargs, async (args) => {
134
+ .command("delete <id>", "Delete a project", (yargs) => yargs, async (args) => {
135
135
  await deleteProject(args);
136
136
  })
137
- .command('recover <id>', 'Recovers a deleted project during the deletion grace period', (yargs) => yargs, async (args) => {
137
+ .command("recover <id>", "Recovers a deleted project during the deletion grace period", (yargs) => yargs, async (args) => {
138
138
  await recover(args);
139
139
  })
140
- .command('get <id>', 'Get a project', (yargs) => yargs, async (args) => {
140
+ .command("get <id>", "Get a project", (yargs) => yargs, async (args) => {
141
141
  await get(args);
142
142
  });
143
143
  };
@@ -158,7 +158,7 @@ const list = async (props) => {
158
158
  });
159
159
  result.push(...data.projects);
160
160
  cursor = data.pagination?.cursor;
161
- log.debug('Got %d projects, with cursor: %s', data.projects.length, cursor);
161
+ log.debug("Got %d projects, with cursor: %s", data.projects.length, cursor);
162
162
  if (data.projects.length < PROJECTS_LIST_LIMIT) {
163
163
  end = true;
164
164
  }
@@ -172,9 +172,9 @@ const list = async (props) => {
172
172
  const out = writer(props);
173
173
  out.write(ownedProjects, {
174
174
  fields: props.recoverableOnly
175
- ? [...PROJECT_FIELDS, 'deleted_at', 'recoverable_until']
175
+ ? [...PROJECT_FIELDS, "deleted_at", "recoverable_until"]
176
176
  : PROJECT_FIELDS,
177
- title: 'Projects',
177
+ title: "Projects",
178
178
  emptyMessage: props.recoverableOnly
179
179
  ? "You don't have any recoverable projects."
180
180
  : "You don't have any projects yet. See how to create a new project:\n> neon projects create --help",
@@ -183,8 +183,8 @@ const list = async (props) => {
183
183
  // We don't list shared projects when listing recoverable projects
184
184
  out.write(sharedProjects, {
185
185
  fields: PROJECT_FIELDS,
186
- title: 'Shared with you',
187
- emptyMessage: 'No projects have been shared with you',
186
+ title: "Shared with you",
187
+ emptyMessage: "No projects have been shared with you",
188
188
  });
189
189
  }
190
190
  out.end();
@@ -201,7 +201,8 @@ const create = async (props) => {
201
201
  if (!project.settings) {
202
202
  project.settings = {};
203
203
  }
204
- project.settings.block_public_connections = props.blockPublicConnections;
204
+ project.settings.block_public_connections =
205
+ props.blockPublicConnections;
205
206
  }
206
207
  if (props.blockVpcConnections !== undefined) {
207
208
  if (!project.settings) {
@@ -239,17 +240,17 @@ const create = async (props) => {
239
240
  });
240
241
  }
241
242
  const out = writer(props);
242
- out.write(data.project, { fields: PROJECT_FIELDS, title: 'Project' });
243
+ out.write(data.project, { fields: PROJECT_FIELDS, title: "Project" });
243
244
  out.write(data.connection_uris, {
244
- fields: ['connection_uri'],
245
- title: 'Connection URIs',
245
+ fields: ["connection_uri"],
246
+ title: "Connection URIs",
246
247
  });
247
248
  out.end();
248
249
  if (props.psql) {
249
250
  const connection_uri = data.connection_uris[0].connection_uri;
250
- const psqlArgs = props['--'];
251
+ const psqlArgs = props["--"];
251
252
  await psql(connection_uri, psqlArgs, {
252
- mode: props.fallback ? 'ts' : 'auto',
253
+ mode: props.fallback ? "ts" : "auto",
253
254
  });
254
255
  }
255
256
  };
@@ -271,7 +272,8 @@ const update = async (props) => {
271
272
  if (!project.settings) {
272
273
  project.settings = {};
273
274
  }
274
- project.settings.block_public_connections = props.blockPublicConnections;
275
+ project.settings.block_public_connections =
276
+ props.blockPublicConnections;
275
277
  }
276
278
  if (props.blockVpcConnections !== undefined) {
277
279
  if (!project.settings) {
@@ -317,7 +319,7 @@ const handleMissingOrgId = async (args, cmd) => {
317
319
  const isOrgIdError = (err) => {
318
320
  return (isNeonApiError(err) &&
319
321
  err.status === 400 &&
320
- messageFromBody(err.data)?.includes('org_id is required'));
322
+ messageFromBody(err.data)?.includes("org_id is required"));
321
323
  };
322
324
  const selectOrg = async (props) => {
323
325
  const { data: { organizations }, } = await props.apiClient.getCurrentUserOrganizations();
@@ -326,8 +328,8 @@ const selectOrg = async (props) => {
326
328
  }
327
329
  const { orgId } = await prompts({
328
330
  onState: onPromptState,
329
- type: 'select',
330
- name: 'orgId',
331
+ type: "select",
332
+ name: "orgId",
331
333
  message: `What organization would you like to use?`,
332
334
  choices: organizations.map((org) => ({
333
335
  title: `${org.name} (${org.id})`,
@@ -337,8 +339,8 @@ const selectOrg = async (props) => {
337
339
  });
338
340
  const { save } = await prompts({
339
341
  onState: onPromptState,
340
- type: 'confirm',
341
- name: 'save',
342
+ type: "confirm",
343
+ name: "save",
342
344
  message: `Would you like to use this organization by default?`,
343
345
  initial: true,
344
346
  });
@@ -363,8 +365,8 @@ const onPromptState = (state) => {
363
365
  if (state.aborted) {
364
366
  // If we don't re-enable the terminal cursor before exiting
365
367
  // the program, the cursor will remain hidden
366
- process.stdout.write('\x1B[?25h');
367
- process.stdout.write('\n');
368
+ process.stdout.write("\x1B[?25h");
369
+ process.stdout.write("\n");
368
370
  process.exit(1);
369
371
  }
370
372
  };
@@ -1,51 +1,51 @@
1
- import { EndpointType } from '../utils/api_enums.js';
2
- import { fillSingleProject } from '../utils/enrichers.js';
3
- import { handler as connectionStringHandler, SSL_MODES, } from './connection_string.js';
4
- export const command = 'psql [branch]';
5
- export const describe = 'Connect to a database via psql';
1
+ import { EndpointType } from "../utils/api_enums.js";
2
+ import { fillSingleProject } from "../utils/enrichers.js";
3
+ import { handler as connectionStringHandler, SSL_MODES, } from "./connection_string.js";
4
+ export const command = "psql [branch]";
5
+ export const describe = "Connect to a database via psql";
6
6
  export const builder = (argv) => {
7
7
  return argv
8
- .usage('$0 psql [branch] [options] [-- psql-args]')
9
- .example('$0 psql', 'Connect to the default branch via psql')
10
- .example('$0 psql main', 'Connect to the main branch via psql')
11
- .example('$0 psql main -- -c "SELECT 1"', 'Run a single query against the main branch')
12
- .example('$0 psql main@2024-01-01T00:00:00Z', 'Connect to the main branch at a specific point in time')
13
- .positional('branch', {
8
+ .usage("$0 psql [branch] [options] [-- psql-args]")
9
+ .example("$0 psql", "Connect to the default branch via psql")
10
+ .example("$0 psql main", "Connect to the main branch via psql")
11
+ .example('$0 psql main -- -c "SELECT 1"', "Run a single query against the main branch")
12
+ .example("$0 psql main@2024-01-01T00:00:00Z", "Connect to the main branch at a specific point in time")
13
+ .positional("branch", {
14
14
  describe: `Branch name or id. Defaults to the default branch if omitted. Can be written in the point-in-time format: "branch@timestamp" or "branch@lsn"`,
15
- type: 'string',
15
+ type: "string",
16
16
  })
17
17
  .options({
18
- 'project-id': {
19
- type: 'string',
20
- describe: 'Project ID',
18
+ "project-id": {
19
+ type: "string",
20
+ describe: "Project ID",
21
21
  },
22
- 'role-name': {
23
- type: 'string',
24
- describe: 'Role name',
22
+ "role-name": {
23
+ type: "string",
24
+ describe: "Role name",
25
25
  },
26
- 'database-name': {
27
- type: 'string',
28
- describe: 'Database name',
26
+ "database-name": {
27
+ type: "string",
28
+ describe: "Database name",
29
29
  },
30
30
  pooled: {
31
- type: 'boolean',
32
- describe: 'Use pooled connection',
31
+ type: "boolean",
32
+ describe: "Use pooled connection",
33
33
  default: false,
34
34
  },
35
- 'endpoint-type': {
36
- type: 'string',
35
+ "endpoint-type": {
36
+ type: "string",
37
37
  choices: Object.values(EndpointType),
38
- describe: 'Endpoint type',
38
+ describe: "Endpoint type",
39
39
  },
40
40
  ssl: {
41
- type: 'string',
41
+ type: "string",
42
42
  choices: SSL_MODES,
43
- default: 'require',
44
- describe: 'SSL mode',
43
+ default: "require",
44
+ describe: "SSL mode",
45
45
  },
46
46
  fallback: {
47
- type: 'boolean',
48
- describe: 'Force the embedded TypeScript psql fallback (for testing)',
47
+ type: "boolean",
48
+ describe: "Force the embedded TypeScript psql fallback (for testing)",
49
49
  default: false,
50
50
  hidden: true,
51
51
  },
@@ -1,36 +1,36 @@
1
- import { retryOnLock } from '../api.js';
2
- import { branchIdFromProps, fillSingleProject } from '../utils/enrichers.js';
3
- import { writer } from '../writer.js';
4
- const ROLES_FIELDS = ['name', 'created_at'];
5
- export const command = 'roles';
6
- export const describe = 'Manage roles';
7
- export const aliases = ['role'];
1
+ import { retryOnLock } from "../api.js";
2
+ import { branchIdFromProps, fillSingleProject } from "../utils/enrichers.js";
3
+ import { writer } from "../writer.js";
4
+ const ROLES_FIELDS = ["name", "created_at"];
5
+ export const command = "roles";
6
+ export const describe = "Manage roles";
7
+ export const aliases = ["role"];
8
8
  export const builder = (argv) => argv
9
- .usage('$0 roles <sub-command> [options]')
9
+ .usage("$0 roles <sub-command> [options]")
10
10
  .options({
11
- 'project-id': {
12
- describe: 'Project ID',
13
- type: 'string',
11
+ "project-id": {
12
+ describe: "Project ID",
13
+ type: "string",
14
14
  },
15
15
  branch: {
16
- describe: 'Branch ID or name',
17
- type: 'string',
16
+ describe: "Branch ID or name",
17
+ type: "string",
18
18
  },
19
19
  })
20
20
  .middleware(fillSingleProject)
21
- .command('list', 'List roles', (yargs) => yargs, (args) => list(args))
22
- .command('create', 'Create a role', (yargs) => yargs.options({
21
+ .command("list", "List roles", (yargs) => yargs, (args) => list(args))
22
+ .command("create", "Create a role", (yargs) => yargs.options({
23
23
  name: {
24
- describe: 'Role name',
25
- type: 'string',
24
+ describe: "Role name",
25
+ type: "string",
26
26
  demandOption: true,
27
27
  },
28
- 'no-login': {
29
- describe: 'Create a passwordless role that cannot login',
28
+ "no-login": {
29
+ describe: "Create a passwordless role that cannot login",
30
30
  boolean: true,
31
31
  },
32
32
  }), (args) => create(args))
33
- .command('delete <role>', 'Delete a role', (yargs) => yargs, (args) => deleteRole(args));
33
+ .command("delete <role>", "Delete a role", (yargs) => yargs, (args) => deleteRole(args));
34
34
  export const handler = (args) => {
35
35
  return args;
36
36
  };
@@ -46,7 +46,7 @@ export const create = async (props) => {
46
46
  const { data } = await retryOnLock(() => props.apiClient.createProjectBranchRole(props.projectId, branchId, {
47
47
  role: {
48
48
  name: props.name,
49
- no_login: props['no-login'],
49
+ no_login: props["no-login"],
50
50
  },
51
51
  }));
52
52
  writer(props).end(data.role, {