neon 3.0.0 → 3.1.0

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 (198) hide show
  1. package/README.md +54 -0
  2. package/dist/_shared/auth_selection.js +76 -79
  3. package/dist/_shared/credentials.js +166 -187
  4. package/dist/_shared/env-core/env.js +354 -517
  5. package/dist/_shared/env-core/reuse-secrets.js +159 -203
  6. package/dist/_shared/paths.js +129 -126
  7. package/dist/_shared/profiles.js +192 -242
  8. package/dist/_shared/secure_file.js +36 -38
  9. package/dist/_virtual/_rolldown/runtime.js +13 -0
  10. package/dist/analytics.js +163 -207
  11. package/dist/api.js +815 -758
  12. package/dist/auth.js +121 -141
  13. package/dist/auth_context.js +39 -53
  14. package/dist/cli.js +4 -7
  15. package/dist/commands/api.js +220 -250
  16. package/dist/commands/api_keys.js +251 -314
  17. package/dist/commands/auth.js +283 -328
  18. package/dist/commands/bootstrap.js +372 -437
  19. package/dist/commands/branches.js +304 -455
  20. package/dist/commands/bucket.js +374 -514
  21. package/dist/commands/checkout.js +213 -298
  22. package/dist/commands/config.js +573 -690
  23. package/dist/commands/connection_string.js +137 -165
  24. package/dist/commands/data_api.js +238 -260
  25. package/dist/commands/databases.js +67 -76
  26. package/dist/commands/deploy.js +31 -25
  27. package/dist/commands/dev.js +639 -719
  28. package/dist/commands/diff.js +156 -200
  29. package/dist/commands/env.js +243 -303
  30. package/dist/commands/functions.js +275 -355
  31. package/dist/commands/index.js +70 -65
  32. package/dist/commands/init.js +84 -119
  33. package/dist/commands/inspect.js +55 -55
  34. package/dist/commands/ip_allow.js +88 -120
  35. package/dist/commands/link.js +874 -1019
  36. package/dist/commands/logs.js +291 -0
  37. package/dist/commands/neon_auth.js +725 -933
  38. package/dist/commands/operations.js +34 -25
  39. package/dist/commands/orgs.js +28 -18
  40. package/dist/commands/profile.js +614 -845
  41. package/dist/commands/projects.js +313 -373
  42. package/dist/commands/psql.js +60 -58
  43. package/dist/commands/roles.js +55 -58
  44. package/dist/commands/schema_diff.js +87 -131
  45. package/dist/commands/set_context.js +34 -26
  46. package/dist/commands/snapshots.js +288 -413
  47. package/dist/commands/status.js +41 -37
  48. package/dist/commands/user.js +21 -10
  49. package/dist/commands/vpc_endpoints.js +85 -113
  50. package/dist/config.js +7 -6
  51. package/dist/config_format.js +50 -66
  52. package/dist/config_template.js +128 -157
  53. package/dist/context.js +183 -235
  54. package/dist/current_branch_fast_path.js +40 -49
  55. package/dist/dev/env.js +313 -394
  56. package/dist/dev/functions.js +54 -68
  57. package/dist/dev/inputs.js +46 -58
  58. package/dist/dev/runtime.js +135 -164
  59. package/dist/dev/websocket.js +766 -959
  60. package/dist/env.js +27 -33
  61. package/dist/env_file.js +118 -132
  62. package/dist/env_services.js +36 -38
  63. package/dist/errors.js +57 -68
  64. package/dist/functions_api.js +45 -43
  65. package/dist/help.js +189 -140
  66. package/dist/index.js +182 -257
  67. package/dist/init/agents.js +137 -118
  68. package/dist/init/auth.js +58 -68
  69. package/dist/init/bootstrap.js +325 -396
  70. package/dist/init/build_config.js +4 -2
  71. package/dist/init/detect_agent.js +56 -101
  72. package/dist/init/editors.js +35 -52
  73. package/dist/init/enrich_output.js +51 -66
  74. package/dist/init/extension.js +134 -171
  75. package/dist/init/inspect.js +179 -266
  76. package/dist/init/interactive.js +510 -622
  77. package/dist/init/neonctl.js +117 -168
  78. package/dist/init/orchestrate.js +157 -173
  79. package/dist/init/phases/auth.js +188 -202
  80. package/dist/init/phases/cleanup.js +23 -23
  81. package/dist/init/phases/db.js +251 -277
  82. package/dist/init/phases/getting_started.js +213 -223
  83. package/dist/init/phases/mcp.js +174 -224
  84. package/dist/init/phases/migrations.js +247 -248
  85. package/dist/init/phases/neon_auth.js +114 -133
  86. package/dist/init/phases/setup.js +546 -703
  87. package/dist/init/phases/skills.js +75 -86
  88. package/dist/init/phases/status.js +72 -67
  89. package/dist/init/resolve_context.js +102 -99
  90. package/dist/init/route_command.js +91 -98
  91. package/dist/init/skills.js +174 -218
  92. package/dist/init/vsix.js +77 -99
  93. package/dist/log.js +17 -16
  94. package/dist/neon_services.js +104 -129
  95. package/dist/parameters.gen.js +481 -471
  96. package/dist/pkg.js +17 -19
  97. package/dist/profile_keys.js +44 -47
  98. package/dist/psql/cli.js +44 -47
  99. package/dist/psql/command/cmd_cond.js +231 -406
  100. package/dist/psql/command/cmd_connect.js +557 -764
  101. package/dist/psql/command/cmd_copy.js +727 -983
  102. package/dist/psql/command/cmd_describe.js +1499 -1688
  103. package/dist/psql/command/cmd_format.js +733 -905
  104. package/dist/psql/command/cmd_io.js +1293 -2082
  105. package/dist/psql/command/cmd_lo.js +297 -359
  106. package/dist/psql/command/cmd_meta.js +727 -878
  107. package/dist/psql/command/cmd_misc.js +138 -172
  108. package/dist/psql/command/cmd_pipeline.js +547 -1099
  109. package/dist/psql/command/cmd_restrict.js +119 -155
  110. package/dist/psql/command/cmd_show.js +529 -688
  111. package/dist/psql/command/dispatch.js +261 -325
  112. package/dist/psql/command/inputQueue.js +35 -33
  113. package/dist/psql/command/shared.js +49 -63
  114. package/dist/psql/complete/filenames.js +90 -133
  115. package/dist/psql/complete/index.js +59 -97
  116. package/dist/psql/complete/matcher.js +236 -300
  117. package/dist/psql/complete/psqlVars.js +218 -223
  118. package/dist/psql/complete/queries.js +159 -177
  119. package/dist/psql/complete/rules.js +1493 -2299
  120. package/dist/psql/core/common.js +762 -1180
  121. package/dist/psql/core/help.js +456 -546
  122. package/dist/psql/core/mainloop.js +692 -1302
  123. package/dist/psql/core/prompt.js +391 -408
  124. package/dist/psql/core/settings.js +429 -644
  125. package/dist/psql/core/sqlHelp.js +480 -554
  126. package/dist/psql/core/startup.js +626 -815
  127. package/dist/psql/core/syncVars.js +67 -110
  128. package/dist/psql/core/variables.js +156 -278
  129. package/dist/psql/describe/formatters.js +884 -1285
  130. package/dist/psql/describe/processNamePattern.js +173 -260
  131. package/dist/psql/describe/queries.js +1368 -2403
  132. package/dist/psql/describe/versionGate.js +32 -41
  133. package/dist/psql/index.js +1414 -1927
  134. package/dist/psql/io/history.js +232 -271
  135. package/dist/psql/io/input.js +103 -108
  136. package/dist/psql/io/lineEditor/buffer.js +238 -319
  137. package/dist/psql/io/lineEditor/complete.js +135 -213
  138. package/dist/psql/io/lineEditor/filename.js +139 -148
  139. package/dist/psql/io/lineEditor/index.js +653 -870
  140. package/dist/psql/io/lineEditor/keymap.js +544 -702
  141. package/dist/psql/io/lineEditor/vt100.js +294 -341
  142. package/dist/psql/io/pgpass.js +158 -187
  143. package/dist/psql/io/pgservice.js +146 -183
  144. package/dist/psql/io/psqlrc.js +328 -403
  145. package/dist/psql/print/aligned.js +1020 -1683
  146. package/dist/psql/print/asciidoc.js +180 -214
  147. package/dist/psql/print/crosstab.js +281 -442
  148. package/dist/psql/print/csv.js +48 -70
  149. package/dist/psql/print/html.js +195 -226
  150. package/dist/psql/print/json.js +75 -88
  151. package/dist/psql/print/latex.js +291 -364
  152. package/dist/psql/print/pager.js +171 -242
  153. package/dist/psql/print/troff.js +194 -226
  154. package/dist/psql/print/unaligned.js +69 -95
  155. package/dist/psql/print/units.js +167 -169
  156. package/dist/psql/scanner/slash.js +428 -483
  157. package/dist/psql/scanner/sql.js +445 -889
  158. package/dist/psql/scanner/stringutils.js +309 -379
  159. package/dist/psql/types/index.js +2 -7
  160. package/dist/psql/types/scanner.js +25 -22
  161. package/dist/psql/wire/connection.js +2042 -2803
  162. package/dist/psql/wire/copy.js +84 -100
  163. package/dist/psql/wire/notify.js +39 -59
  164. package/dist/psql/wire/pipeline.js +305 -518
  165. package/dist/psql/wire/protocol.js +349 -417
  166. package/dist/psql/wire/sasl.js +180 -265
  167. package/dist/psql/wire/tls.js +400 -561
  168. package/dist/storage_api.js +115 -129
  169. package/dist/test_utils/fixtures.js +94 -113
  170. package/dist/test_utils/oauth_server.js +10 -7
  171. package/dist/test_utils/project_dir.js +33 -0
  172. package/dist/utils/ai_gateway_notice.js +131 -162
  173. package/dist/utils/api_enums.js +21 -28
  174. package/dist/utils/auth.js +10 -4
  175. package/dist/utils/branch_notice.js +20 -19
  176. package/dist/utils/branch_picker.js +83 -89
  177. package/dist/utils/cli_name.js +15 -12
  178. package/dist/utils/compute_units.js +20 -27
  179. package/dist/utils/config_diff.js +127 -158
  180. package/dist/utils/enrichers.js +95 -148
  181. package/dist/utils/esbuild.js +130 -189
  182. package/dist/utils/flags.js +35 -47
  183. package/dist/utils/formats.js +8 -15
  184. package/dist/utils/git_diff.js +69 -80
  185. package/dist/utils/inspect_db.js +101 -143
  186. package/dist/utils/inspect_queries.js +179 -142
  187. package/dist/utils/middlewares.js +37 -44
  188. package/dist/utils/openapi.js +87 -99
  189. package/dist/utils/package_manager.js +312 -110
  190. package/dist/utils/point_in_time.js +49 -53
  191. package/dist/utils/psql.js +89 -106
  192. package/dist/utils/service_picker.js +55 -58
  193. package/dist/utils/string.js +5 -5
  194. package/dist/utils/ui.js +38 -55
  195. package/dist/utils/write_sync.js +26 -35
  196. package/dist/utils/zip.js +4 -3
  197. package/dist/writer.js +67 -87
  198. package/package.json +7 -5
@@ -1,23 +1,7 @@
1
- /**
2
- * Catalog-query templates for tab completion.
3
- *
4
- * Each template returns a single column of completion candidates and takes
5
- * one parameter — the LIKE pattern (i.e. the user's partial prefix with a
6
- * trailing `%`). We use `pg_catalog.quote_ident()` so identifiers that need
7
- * quoting come back already wrapped in `"..."`.
8
- *
9
- * The templates are intentionally narrow: psql's upstream tab-complete uses
10
- * elaborate `SchemaQuery` structs that synthesize visibility predicates
11
- * (search-path awareness) at runtime. We trade that nuance for portability
12
- * — these queries just `LIKE` against the system catalogs and let the user
13
- * see everything they have access to, sorted alphabetically.
14
- *
15
- * Every query takes a single `$1` parameter (the LIKE pattern) and is
16
- * capped at 1000 rows so a wildcard `%` doesn't dump entire databases.
17
- */
18
- const LIMIT = 1000;
1
+ //#region src/psql/complete/queries.ts
2
+ const LIMIT = 1e3;
19
3
  /** Tables (incl. partitioned tables). */
20
- export const Query_for_list_of_tables = `
4
+ const Query_for_list_of_tables = `
21
5
  SELECT pg_catalog.quote_ident(c.relname)
22
6
  FROM pg_catalog.pg_class c
23
7
  WHERE c.relkind IN ('r','p')
@@ -27,7 +11,7 @@ export const Query_for_list_of_tables = `
27
11
  LIMIT ${LIMIT}
28
12
  `;
29
13
  /** Views. */
30
- export const Query_for_list_of_views = `
14
+ const Query_for_list_of_views = `
31
15
  SELECT pg_catalog.quote_ident(c.relname)
32
16
  FROM pg_catalog.pg_class c
33
17
  WHERE c.relkind = 'v'
@@ -37,7 +21,7 @@ export const Query_for_list_of_views = `
37
21
  LIMIT ${LIMIT}
38
22
  `;
39
23
  /** Materialized views. */
40
- export const Query_for_list_of_matviews = `
24
+ const Query_for_list_of_matviews = `
41
25
  SELECT pg_catalog.quote_ident(c.relname)
42
26
  FROM pg_catalog.pg_class c
43
27
  WHERE c.relkind = 'm'
@@ -47,7 +31,7 @@ export const Query_for_list_of_matviews = `
47
31
  LIMIT ${LIMIT}
48
32
  `;
49
33
  /** Sequences. */
50
- export const Query_for_list_of_sequences = `
34
+ const Query_for_list_of_sequences = `
51
35
  SELECT pg_catalog.quote_ident(c.relname)
52
36
  FROM pg_catalog.pg_class c
53
37
  WHERE c.relkind = 'S'
@@ -57,7 +41,7 @@ export const Query_for_list_of_sequences = `
57
41
  LIMIT ${LIMIT}
58
42
  `;
59
43
  /** Indexes. */
60
- export const Query_for_list_of_indexes = `
44
+ const Query_for_list_of_indexes = `
61
45
  SELECT pg_catalog.quote_ident(c.relname)
62
46
  FROM pg_catalog.pg_class c
63
47
  WHERE c.relkind IN ('i','I')
@@ -67,7 +51,7 @@ export const Query_for_list_of_indexes = `
67
51
  LIMIT ${LIMIT}
68
52
  `;
69
53
  /** Foreign tables. */
70
- export const Query_for_list_of_foreign_tables = `
54
+ const Query_for_list_of_foreign_tables = `
71
55
  SELECT pg_catalog.quote_ident(c.relname)
72
56
  FROM pg_catalog.pg_class c
73
57
  WHERE c.relkind = 'f'
@@ -77,7 +61,7 @@ export const Query_for_list_of_foreign_tables = `
77
61
  LIMIT ${LIMIT}
78
62
  `;
79
63
  /** Any relation (tables, views, mviews, indexes, sequences, foreign tables). */
80
- export const Query_for_list_of_relations = `
64
+ const Query_for_list_of_relations = `
81
65
  SELECT pg_catalog.quote_ident(c.relname)
82
66
  FROM pg_catalog.pg_class c
83
67
  WHERE c.relkind IN ('r','v','m','S','f','p')
@@ -87,7 +71,7 @@ export const Query_for_list_of_relations = `
87
71
  LIMIT ${LIMIT}
88
72
  `;
89
73
  /** Tables + views + matviews (what FROM/UPDATE/INSERT INTO accept). */
90
- export const Query_for_list_of_tables_views = `
74
+ const Query_for_list_of_tables_views = `
91
75
  SELECT pg_catalog.quote_ident(c.relname)
92
76
  FROM pg_catalog.pg_class c
93
77
  WHERE c.relkind IN ('r','v','m','p','f')
@@ -97,7 +81,7 @@ export const Query_for_list_of_tables_views = `
97
81
  LIMIT ${LIMIT}
98
82
  `;
99
83
  /** Schemas. */
100
- export const Query_for_list_of_schemas = `
84
+ const Query_for_list_of_schemas = `
101
85
  SELECT pg_catalog.quote_ident(nspname)
102
86
  FROM pg_catalog.pg_namespace
103
87
  WHERE nspname ILIKE $1
@@ -105,7 +89,7 @@ export const Query_for_list_of_schemas = `
105
89
  LIMIT ${LIMIT}
106
90
  `;
107
91
  /** Functions (not procedures). */
108
- export const Query_for_list_of_functions = `
92
+ const Query_for_list_of_functions = `
109
93
  SELECT pg_catalog.quote_ident(p.proname)
110
94
  FROM pg_catalog.pg_proc p
111
95
  WHERE p.proname ILIKE $1
@@ -114,7 +98,7 @@ export const Query_for_list_of_functions = `
114
98
  LIMIT ${LIMIT}
115
99
  `;
116
100
  /** Roles. */
117
- export const Query_for_list_of_roles = `
101
+ const Query_for_list_of_roles = `
118
102
  SELECT pg_catalog.quote_ident(rolname)
119
103
  FROM pg_catalog.pg_roles
120
104
  WHERE rolname ILIKE $1
@@ -122,7 +106,7 @@ export const Query_for_list_of_roles = `
122
106
  LIMIT ${LIMIT}
123
107
  `;
124
108
  /** Extensions. */
125
- export const Query_for_list_of_extensions = `
109
+ const Query_for_list_of_extensions = `
126
110
  SELECT pg_catalog.quote_ident(extname)
127
111
  FROM pg_catalog.pg_extension
128
112
  WHERE extname ILIKE $1
@@ -130,7 +114,7 @@ export const Query_for_list_of_extensions = `
130
114
  LIMIT ${LIMIT}
131
115
  `;
132
116
  /** Available extensions (installable). */
133
- export const Query_for_list_of_available_extensions = `
117
+ const Query_for_list_of_available_extensions = `
134
118
  SELECT pg_catalog.quote_ident(name)
135
119
  FROM pg_catalog.pg_available_extensions
136
120
  WHERE name ILIKE $1
@@ -138,7 +122,7 @@ export const Query_for_list_of_available_extensions = `
138
122
  LIMIT ${LIMIT}
139
123
  `;
140
124
  /** Databases. */
141
- export const Query_for_list_of_databases = `
125
+ const Query_for_list_of_databases = `
142
126
  SELECT pg_catalog.quote_ident(datname)
143
127
  FROM pg_catalog.pg_database
144
128
  WHERE datname ILIKE $1
@@ -146,7 +130,7 @@ export const Query_for_list_of_databases = `
146
130
  LIMIT ${LIMIT}
147
131
  `;
148
132
  /** Types. */
149
- export const Query_for_list_of_types = `
133
+ const Query_for_list_of_types = `
150
134
  SELECT pg_catalog.quote_ident(t.typname)
151
135
  FROM pg_catalog.pg_type t
152
136
  WHERE (t.typrelid = 0 OR
@@ -158,7 +142,7 @@ export const Query_for_list_of_types = `
158
142
  LIMIT ${LIMIT}
159
143
  `;
160
144
  /** Languages. */
161
- export const Query_for_list_of_languages = `
145
+ const Query_for_list_of_languages = `
162
146
  SELECT pg_catalog.quote_ident(lanname)
163
147
  FROM pg_catalog.pg_language
164
148
  WHERE lanname != 'internal'
@@ -167,7 +151,7 @@ export const Query_for_list_of_languages = `
167
151
  LIMIT ${LIMIT}
168
152
  `;
169
153
  /** Tablespaces. */
170
- export const Query_for_list_of_tablespaces = `
154
+ const Query_for_list_of_tablespaces = `
171
155
  SELECT pg_catalog.quote_ident(spcname)
172
156
  FROM pg_catalog.pg_tablespace
173
157
  WHERE spcname ILIKE $1
@@ -175,7 +159,7 @@ export const Query_for_list_of_tablespaces = `
175
159
  LIMIT ${LIMIT}
176
160
  `;
177
161
  /** Operators. */
178
- export const Query_for_list_of_operators = `
162
+ const Query_for_list_of_operators = `
179
163
  SELECT pg_catalog.quote_ident(o.oprname)
180
164
  FROM pg_catalog.pg_operator o
181
165
  WHERE o.oprname ILIKE $1
@@ -184,7 +168,7 @@ export const Query_for_list_of_operators = `
184
168
  LIMIT ${LIMIT}
185
169
  `;
186
170
  /** Casts (no quoting; format is "type AS type" — used rarely). */
187
- export const Query_for_list_of_casts = `
171
+ const Query_for_list_of_casts = `
188
172
  SELECT pg_catalog.format_type(castsource, NULL)
189
173
  || ' AS '
190
174
  || pg_catalog.format_type(casttarget, NULL) AS cast
@@ -196,7 +180,7 @@ export const Query_for_list_of_casts = `
196
180
  LIMIT ${LIMIT}
197
181
  `;
198
182
  /** Configuration parameter (GUC) names — `pg_settings`. */
199
- export const Query_for_list_of_set_vars = `
183
+ const Query_for_list_of_set_vars = `
200
184
  SELECT pg_catalog.lower(name)
201
185
  FROM pg_catalog.pg_settings
202
186
  WHERE name ILIKE $1
@@ -204,18 +188,18 @@ export const Query_for_list_of_set_vars = `
204
188
  LIMIT ${LIMIT}
205
189
  `;
206
190
  /**
207
- * Allowed values of an enum-typed GUC — `pg_settings.enumvals`.
208
- *
209
- * The GUC name is the first parameter (matched case-insensitively against
210
- * `pg_settings.name`, since names like `IntervalStyle` appear mixed-case in
211
- * the catalog but are addressed in lowercase from user input). The ILIKE
212
- * prefix on the unnested values is the trailing parameter.
213
- *
214
- * Mirrors upstream `tab-complete.in.c`'s `Query_for_values_of_enum_GUC`. The
215
- * catalog stores enum values in lowercase (e.g. `iso_8601`, `use_column`),
216
- * which matches how `SET <name> TO <value>` expects them.
217
- */
218
- export const Query_for_values_of_enum_GUC = `
191
+ * Allowed values of an enum-typed GUC — `pg_settings.enumvals`.
192
+ *
193
+ * The GUC name is the first parameter (matched case-insensitively against
194
+ * `pg_settings.name`, since names like `IntervalStyle` appear mixed-case in
195
+ * the catalog but are addressed in lowercase from user input). The ILIKE
196
+ * prefix on the unnested values is the trailing parameter.
197
+ *
198
+ * Mirrors upstream `tab-complete.in.c`'s `Query_for_values_of_enum_GUC`. The
199
+ * catalog stores enum values in lowercase (e.g. `iso_8601`, `use_column`),
200
+ * which matches how `SET <name> TO <value>` expects them.
201
+ */
202
+ const Query_for_values_of_enum_GUC = `
219
203
  SELECT val
220
204
  FROM (
221
205
  SELECT pg_catalog.unnest(enumvals) AS val
@@ -228,7 +212,7 @@ export const Query_for_values_of_enum_GUC = `
228
212
  LIMIT ${LIMIT}
229
213
  `;
230
214
  /** Access methods (index AMs primarily). */
231
- export const Query_for_list_of_access_methods = `
215
+ const Query_for_list_of_access_methods = `
232
216
  SELECT pg_catalog.quote_ident(amname)
233
217
  FROM pg_catalog.pg_am
234
218
  WHERE amname ILIKE $1
@@ -236,7 +220,7 @@ export const Query_for_list_of_access_methods = `
236
220
  LIMIT ${LIMIT}
237
221
  `;
238
222
  /** Index access methods only (`amtype = 'i'`). */
239
- export const Query_for_list_of_index_access_methods = `
223
+ const Query_for_list_of_index_access_methods = `
240
224
  SELECT pg_catalog.quote_ident(amname)
241
225
  FROM pg_catalog.pg_am
242
226
  WHERE amname ILIKE $1
@@ -245,7 +229,7 @@ export const Query_for_list_of_index_access_methods = `
245
229
  LIMIT ${LIMIT}
246
230
  `;
247
231
  /** Built-in type names — for CREATE TABLE column-type completion. */
248
- export const Query_for_list_of_datatypes = `
232
+ const Query_for_list_of_datatypes = `
249
233
  SELECT pg_catalog.format_type(t.oid, NULL)
250
234
  FROM pg_catalog.pg_type t
251
235
  WHERE (t.typrelid = 0 OR
@@ -260,7 +244,7 @@ export const Query_for_list_of_datatypes = `
260
244
  LIMIT ${LIMIT}
261
245
  `;
262
246
  /** Publications. */
263
- export const Query_for_list_of_publications = `
247
+ const Query_for_list_of_publications = `
264
248
  SELECT pg_catalog.quote_ident(pubname)
265
249
  FROM pg_catalog.pg_publication
266
250
  WHERE pubname ILIKE $1
@@ -268,7 +252,7 @@ export const Query_for_list_of_publications = `
268
252
  LIMIT ${LIMIT}
269
253
  `;
270
254
  /** Subscriptions. */
271
- export const Query_for_list_of_subscriptions = `
255
+ const Query_for_list_of_subscriptions = `
272
256
  SELECT pg_catalog.quote_ident(subname)
273
257
  FROM pg_catalog.pg_subscription
274
258
  WHERE subname ILIKE $1
@@ -276,17 +260,17 @@ export const Query_for_list_of_subscriptions = `
276
260
  LIMIT ${LIMIT}
277
261
  `;
278
262
  /**
279
- * Relations qualified by an explicit schema. The caller passes the schema
280
- * name as $1 and the ILIKE prefix as $2 — this lets `SELECT * FROM pg_catalog.x`
281
- * complete to `pg_catalog.xxxx`. The schema name is matched
282
- * case-insensitively so `PUBLIC.t` resolves to relations in `public`.
283
- *
284
- * Note: deliberately excludes `relkind = 'i'` (indexes) so that
285
- * `SELECT * FROM public.tab<tab>` doesn't include `tab1_pkey` alongside
286
- * `tab1`. Index-qualifying completions (REINDEX, DROP INDEX, ALTER INDEX)
287
- * have their own table-kind queries and don't route through this helper.
288
- */
289
- export const Query_for_list_of_relations_in_schema = `
263
+ * Relations qualified by an explicit schema. The caller passes the schema
264
+ * name as $1 and the ILIKE prefix as $2 — this lets `SELECT * FROM pg_catalog.x`
265
+ * complete to `pg_catalog.xxxx`. The schema name is matched
266
+ * case-insensitively so `PUBLIC.t` resolves to relations in `public`.
267
+ *
268
+ * Note: deliberately excludes `relkind = 'i'` (indexes) so that
269
+ * `SELECT * FROM public.tab<tab>` doesn't include `tab1_pkey` alongside
270
+ * `tab1`. Index-qualifying completions (REINDEX, DROP INDEX, ALTER INDEX)
271
+ * have their own table-kind queries and don't route through this helper.
272
+ */
273
+ const Query_for_list_of_relations_in_schema = `
290
274
  SELECT pg_catalog.quote_ident(c.relname)
291
275
  FROM pg_catalog.pg_class c
292
276
  JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
@@ -297,20 +281,20 @@ export const Query_for_list_of_relations_in_schema = `
297
281
  LIMIT ${LIMIT}
298
282
  `;
299
283
  /**
300
- * Constraint names attached to a referenced table. Mirrors upstream's
301
- * `Query_for_constraint_of_table` (tab-complete.in.c ~line 453), which
302
- * joins `pg_constraint` to `pg_class` via `conrelid` and filters by the
303
- * referenced table name.
304
- *
305
- * Caller passes `[refName]` (the table the user typed between
306
- * `ALTER TABLE` and `DROP CONSTRAINT`, already case-folded for unquoted
307
- * input — see `parseTableRef` in rules.ts) and the ILIKE prefix.
308
- *
309
- * Visibility is checked via `pg_table_is_visible(c.oid)` so the user's
310
- * `search_path` controls which schema's `tab1` is matched when the user
311
- * gives an unqualified reference.
312
- */
313
- export const Query_for_constraint_of_table = `
284
+ * Constraint names attached to a referenced table. Mirrors upstream's
285
+ * `Query_for_constraint_of_table` (tab-complete.in.c ~line 453), which
286
+ * joins `pg_constraint` to `pg_class` via `conrelid` and filters by the
287
+ * referenced table name.
288
+ *
289
+ * Caller passes `[refName]` (the table the user typed between
290
+ * `ALTER TABLE` and `DROP CONSTRAINT`, already case-folded for unquoted
291
+ * input — see `parseTableRef` in rules.ts) and the ILIKE prefix.
292
+ *
293
+ * Visibility is checked via `pg_table_is_visible(c.oid)` so the user's
294
+ * `search_path` controls which schema's `tab1` is matched when the user
295
+ * gives an unqualified reference.
296
+ */
297
+ const Query_for_constraint_of_table = `
314
298
  SELECT pg_catalog.quote_ident(con.conname)
315
299
  FROM pg_catalog.pg_constraint con, pg_catalog.pg_class c
316
300
  WHERE con.conrelid = c.oid
@@ -321,16 +305,16 @@ export const Query_for_constraint_of_table = `
321
305
  LIMIT ${LIMIT}
322
306
  `;
323
307
  /**
324
- * Constraint names attached to a referenced table within a specific
325
- * schema. Used when the user qualified the reference, e.g.
326
- * `ALTER TABLE public."tab1" DROP CONSTRAINT t<TAB>`. The schema name is
327
- * matched case-insensitively against `pg_namespace.nspname` so
328
- * `PUBLIC.tab1` still resolves to constraints in the `public` schema.
329
- *
330
- * Caller passes `[schema, refName]` (with `refName` already case-folded
331
- * for the unquoted form), and the ILIKE prefix as the trailing parameter.
332
- */
333
- export const Query_for_constraint_of_table_in_schema = `
308
+ * Constraint names attached to a referenced table within a specific
309
+ * schema. Used when the user qualified the reference, e.g.
310
+ * `ALTER TABLE public."tab1" DROP CONSTRAINT t<TAB>`. The schema name is
311
+ * matched case-insensitively against `pg_namespace.nspname` so
312
+ * `PUBLIC.tab1` still resolves to constraints in the `public` schema.
313
+ *
314
+ * Caller passes `[schema, refName]` (with `refName` already case-folded
315
+ * for the unquoted form), and the ILIKE prefix as the trailing parameter.
316
+ */
317
+ const Query_for_constraint_of_table_in_schema = `
334
318
  SELECT pg_catalog.quote_ident(con.conname)
335
319
  FROM pg_catalog.pg_constraint con
336
320
  JOIN pg_catalog.pg_class c ON con.conrelid = c.oid
@@ -342,20 +326,20 @@ export const Query_for_constraint_of_table_in_schema = `
342
326
  LIMIT ${LIMIT}
343
327
  `;
344
328
  /**
345
- * Tables (regular + partitioned) that have a constraint with the given
346
- * name. The reverse direction of `Query_for_constraint_of_table` — used by
347
- * the `COMMENT ON CONSTRAINT <name> ON <prefix>` completion to resolve the
348
- * relation that owns the named constraint.
349
- *
350
- * Caller passes `[constraintName]`, then the ILIKE prefix on the relname.
351
- * Mirrors upstream's `Query_for_list_of_tables_for_constraint` SchemaQuery
352
- * (tab-complete.in.c ~line 694), which uses
353
- * `selcondition = "c.oid=con.conrelid and c.relkind IN ('r','p')"` and
354
- * `refname = "con.conname"`. The `quote_ident()` wrapper ensures
355
- * names that need quoting (mixed case, reserved words) come back in a
356
- * paste-safe form.
357
- */
358
- export const Query_for_list_of_tables_for_constraint = `
329
+ * Tables (regular + partitioned) that have a constraint with the given
330
+ * name. The reverse direction of `Query_for_constraint_of_table` — used by
331
+ * the `COMMENT ON CONSTRAINT <name> ON <prefix>` completion to resolve the
332
+ * relation that owns the named constraint.
333
+ *
334
+ * Caller passes `[constraintName]`, then the ILIKE prefix on the relname.
335
+ * Mirrors upstream's `Query_for_list_of_tables_for_constraint` SchemaQuery
336
+ * (tab-complete.in.c ~line 694), which uses
337
+ * `selcondition = "c.oid=con.conrelid and c.relkind IN ('r','p')"` and
338
+ * `refname = "con.conname"`. The `quote_ident()` wrapper ensures
339
+ * names that need quoting (mixed case, reserved words) come back in a
340
+ * paste-safe form.
341
+ */
342
+ const Query_for_list_of_tables_for_constraint = `
359
343
  SELECT DISTINCT pg_catalog.quote_ident(c.relname)
360
344
  FROM pg_catalog.pg_class c, pg_catalog.pg_constraint con
361
345
  WHERE c.oid = con.conrelid
@@ -367,14 +351,14 @@ export const Query_for_list_of_tables_for_constraint = `
367
351
  LIMIT ${LIMIT}
368
352
  `;
369
353
  /**
370
- * Same as `Query_for_list_of_tables_for_constraint` but scoped to a
371
- * specific schema (so `COMMENT ON CONSTRAINT foo ON public.<TAB>` only
372
- * shows relations in `public`).
373
- *
374
- * Caller passes `[constraintName, schema]`, then the ILIKE prefix. Schema
375
- * is matched case-insensitively to handle `PUBLIC.<TAB>` → `public.*`.
376
- */
377
- export const Query_for_list_of_tables_for_constraint_in_schema = `
354
+ * Same as `Query_for_list_of_tables_for_constraint` but scoped to a
355
+ * specific schema (so `COMMENT ON CONSTRAINT foo ON public.<TAB>` only
356
+ * shows relations in `public`).
357
+ *
358
+ * Caller passes `[constraintName, schema]`, then the ILIKE prefix. Schema
359
+ * is matched case-insensitively to handle `PUBLIC.<TAB>` → `public.*`.
360
+ */
361
+ const Query_for_list_of_tables_for_constraint_in_schema = `
378
362
  SELECT DISTINCT pg_catalog.quote_ident(c.relname)
379
363
  FROM pg_catalog.pg_class c
380
364
  JOIN pg_catalog.pg_constraint con ON c.oid = con.conrelid
@@ -387,19 +371,19 @@ export const Query_for_list_of_tables_for_constraint_in_schema = `
387
371
  LIMIT ${LIMIT}
388
372
  `;
389
373
  /**
390
- * Enum label values for the named enum type. Mirrors upstream's
391
- * `Query_for_list_of_enum_values_quoted` / `…_unquoted` (tab-complete.in.c
392
- * ~line 602-618), with a parameter-bound type name in place of upstream's
393
- * `set_completion_reference()` macro state.
394
- *
395
- * The caller picks the variant based on whether the user is mid-string-
396
- * literal (current word starts with `'`), and passes `[typeName]` along
397
- * with the ILIKE prefix as the trailing parameter. The quoted variant
398
- * uses `quote_literal` so candidates come back as `'BLACK'` rather than
399
- * bare `BLACK`, and the case-sensitive `enumlabel LIKE` ensures upstream
400
- * parity for tests like `RENAME VALUE 'B<TAB>` → `'BLACK'`.
401
- */
402
- export const Query_for_list_of_enum_values_quoted = `
374
+ * Enum label values for the named enum type. Mirrors upstream's
375
+ * `Query_for_list_of_enum_values_quoted` / `…_unquoted` (tab-complete.in.c
376
+ * ~line 602-618), with a parameter-bound type name in place of upstream's
377
+ * `set_completion_reference()` macro state.
378
+ *
379
+ * The caller picks the variant based on whether the user is mid-string-
380
+ * literal (current word starts with `'`), and passes `[typeName]` along
381
+ * with the ILIKE prefix as the trailing parameter. The quoted variant
382
+ * uses `quote_literal` so candidates come back as `'BLACK'` rather than
383
+ * bare `BLACK`, and the case-sensitive `enumlabel LIKE` ensures upstream
384
+ * parity for tests like `RENAME VALUE 'B<TAB>` → `'BLACK'`.
385
+ */
386
+ const Query_for_list_of_enum_values_quoted = `
403
387
  SELECT pg_catalog.quote_literal(e.enumlabel)
404
388
  FROM pg_catalog.pg_enum e, pg_catalog.pg_type t
405
389
  WHERE t.oid = e.enumtypid
@@ -409,7 +393,7 @@ export const Query_for_list_of_enum_values_quoted = `
409
393
  ORDER BY 1
410
394
  LIMIT ${LIMIT}
411
395
  `;
412
- export const Query_for_list_of_enum_values_unquoted = `
396
+ const Query_for_list_of_enum_values_unquoted = `
413
397
  SELECT e.enumlabel
414
398
  FROM pg_catalog.pg_enum e, pg_catalog.pg_type t
415
399
  WHERE t.oid = e.enumtypid
@@ -420,44 +404,44 @@ export const Query_for_list_of_enum_values_unquoted = `
420
404
  LIMIT ${LIMIT}
421
405
  `;
422
406
  /**
423
- * Timezone names from `pg_timezone_names()`. Three variants mirror
424
- * upstream's `COMPLETE_WITH_TIMEZONE_NAME()` macro (tab-complete.in.c
425
- * ~line 1160-1173) — different result shapes for the three contexts:
426
- *
427
- * - `…_unquoted` emits the bare name `America/New_York`. Used when
428
- * the cursor is already inside an opened single-
429
- * quoted string (`SET timezone TO 'America/New_<TAB>`),
430
- * so the editor inserts the rest of the name and the
431
- * closing quote.
432
- * - `…_quoted_out` emits the candidate wrapped in single quotes —
433
- * `'America/New_York'`. Used when the user hasn't
434
- * typed any quote yet (`SET timezone TO am<TAB>` →
435
- * `'America/`).
436
- * - `…_quoted_in` emits the quoted form AND matches the quoted form
437
- * against the LIKE pattern. Used when the user's
438
- * partial word itself starts with `'` (so we feed
439
- * `'am%` to the LIKE), so the editor can complete
440
- * from inside the literal.
441
- *
442
- * All three are case-insensitive on the name (lower(name) LIKE lower(pat))
443
- * because IANA names like `America/New_York` mix case but should still
444
- * match a lowercase prefix.
445
- */
446
- export const Query_for_list_of_timezone_names_unquoted = `
407
+ * Timezone names from `pg_timezone_names()`. Three variants mirror
408
+ * upstream's `COMPLETE_WITH_TIMEZONE_NAME()` macro (tab-complete.in.c
409
+ * ~line 1160-1173) — different result shapes for the three contexts:
410
+ *
411
+ * - `…_unquoted` emits the bare name `America/New_York`. Used when
412
+ * the cursor is already inside an opened single-
413
+ * quoted string (`SET timezone TO 'America/New_<TAB>`),
414
+ * so the editor inserts the rest of the name and the
415
+ * closing quote.
416
+ * - `…_quoted_out` emits the candidate wrapped in single quotes —
417
+ * `'America/New_York'`. Used when the user hasn't
418
+ * typed any quote yet (`SET timezone TO am<TAB>` →
419
+ * `'America/`).
420
+ * - `…_quoted_in` emits the quoted form AND matches the quoted form
421
+ * against the LIKE pattern. Used when the user's
422
+ * partial word itself starts with `'` (so we feed
423
+ * `'am%` to the LIKE), so the editor can complete
424
+ * from inside the literal.
425
+ *
426
+ * All three are case-insensitive on the name (lower(name) LIKE lower(pat))
427
+ * because IANA names like `America/New_York` mix case but should still
428
+ * match a lowercase prefix.
429
+ */
430
+ const Query_for_list_of_timezone_names_unquoted = `
447
431
  SELECT name
448
432
  FROM pg_catalog.pg_timezone_names()
449
433
  WHERE pg_catalog.lower(name) LIKE pg_catalog.lower($1)
450
434
  ORDER BY 1
451
435
  LIMIT ${LIMIT}
452
436
  `;
453
- export const Query_for_list_of_timezone_names_quoted_out = `
437
+ const Query_for_list_of_timezone_names_quoted_out = `
454
438
  SELECT pg_catalog.quote_literal(name) AS name
455
439
  FROM pg_catalog.pg_timezone_names()
456
440
  WHERE pg_catalog.lower(name) LIKE pg_catalog.lower($1)
457
441
  ORDER BY 1
458
442
  LIMIT ${LIMIT}
459
443
  `;
460
- export const Query_for_list_of_timezone_names_quoted_in = `
444
+ const Query_for_list_of_timezone_names_quoted_in = `
461
445
  SELECT pg_catalog.quote_literal(name) AS name
462
446
  FROM pg_catalog.pg_timezone_names()
463
447
  WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower($1)
@@ -465,29 +449,27 @@ export const Query_for_list_of_timezone_names_quoted_in = `
465
449
  LIMIT ${LIMIT}
466
450
  `;
467
451
  /**
468
- * Run one of the templates above against a connection and return the
469
- * single-column results as a string array. Empty array on any error so the
470
- * completer degrades gracefully — a flaky catalog query shouldn't crash the
471
- * REPL.
472
- *
473
- * `pattern` is the user's partial input; we append `%` automatically.
474
- */
475
- export const runCatalogQuery = async (conn, sql, pattern, extraParams = []) => {
476
- try {
477
- const likePattern = pattern + "%";
478
- const params = extraParams.length > 0
479
- ? [...extraParams, likePattern]
480
- : [likePattern];
481
- const rs = await conn.query(sql, params);
482
- const out = [];
483
- for (const row of rs.rows) {
484
- const v = row[0];
485
- if (typeof v === "string")
486
- out.push(v);
487
- }
488
- return out;
489
- }
490
- catch {
491
- return [];
492
- }
452
+ * Run one of the templates above against a connection and return the
453
+ * single-column results as a string array. Empty array on any error so the
454
+ * completer degrades gracefully — a flaky catalog query shouldn't crash the
455
+ * REPL.
456
+ *
457
+ * `pattern` is the user's partial input; we append `%` automatically.
458
+ */
459
+ const runCatalogQuery = async (conn, sql, pattern, extraParams = []) => {
460
+ try {
461
+ const likePattern = pattern + "%";
462
+ const params = extraParams.length > 0 ? [...extraParams, likePattern] : [likePattern];
463
+ const rs = await conn.query(sql, params);
464
+ const out = [];
465
+ for (const row of rs.rows) {
466
+ const v = row[0];
467
+ if (typeof v === "string") out.push(v);
468
+ }
469
+ return out;
470
+ } catch {
471
+ return [];
472
+ }
493
473
  };
474
+ //#endregion
475
+ export { Query_for_constraint_of_table, Query_for_constraint_of_table_in_schema, Query_for_list_of_access_methods, Query_for_list_of_available_extensions, Query_for_list_of_casts, Query_for_list_of_databases, Query_for_list_of_datatypes, Query_for_list_of_enum_values_quoted, Query_for_list_of_enum_values_unquoted, Query_for_list_of_extensions, Query_for_list_of_foreign_tables, Query_for_list_of_functions, Query_for_list_of_index_access_methods, Query_for_list_of_indexes, Query_for_list_of_languages, Query_for_list_of_matviews, Query_for_list_of_operators, Query_for_list_of_publications, Query_for_list_of_relations, Query_for_list_of_relations_in_schema, Query_for_list_of_roles, Query_for_list_of_schemas, Query_for_list_of_sequences, Query_for_list_of_set_vars, Query_for_list_of_subscriptions, Query_for_list_of_tables, Query_for_list_of_tables_for_constraint, Query_for_list_of_tables_for_constraint_in_schema, Query_for_list_of_tables_views, Query_for_list_of_tablespaces, Query_for_list_of_timezone_names_quoted_in, Query_for_list_of_timezone_names_quoted_out, Query_for_list_of_timezone_names_unquoted, Query_for_list_of_types, Query_for_list_of_views, Query_for_values_of_enum_GUC, runCatalogQuery };