neonctl 2.37.0 → 2.38.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 (160) hide show
  1. package/{LICENSE.md → LICENSE} +27 -3
  2. package/README.md +15 -700
  3. package/bin/cli.js +3 -0
  4. package/package.json +8 -75
  5. package/dist/analytics.js +0 -168
  6. package/dist/api.js +0 -720
  7. package/dist/auth.js +0 -125
  8. package/dist/callback.html +0 -51
  9. package/dist/cli.js +0 -9
  10. package/dist/commands/api.js +0 -278
  11. package/dist/commands/auth.js +0 -214
  12. package/dist/commands/bootstrap.js +0 -481
  13. package/dist/commands/branches.js +0 -488
  14. package/dist/commands/bucket.js +0 -549
  15. package/dist/commands/checkout.js +0 -321
  16. package/dist/commands/config.js +0 -626
  17. package/dist/commands/connection_string.js +0 -172
  18. package/dist/commands/data_api.js +0 -284
  19. package/dist/commands/databases.js +0 -82
  20. package/dist/commands/deploy.js +0 -26
  21. package/dist/commands/dev.js +0 -698
  22. package/dist/commands/diff.js +0 -222
  23. package/dist/commands/env.js +0 -189
  24. package/dist/commands/functions.js +0 -373
  25. package/dist/commands/index.js +0 -62
  26. package/dist/commands/init.js +0 -73
  27. package/dist/commands/inspect.js +0 -65
  28. package/dist/commands/ip_allow.js +0 -137
  29. package/dist/commands/link.js +0 -1121
  30. package/dist/commands/neon_auth.js +0 -1028
  31. package/dist/commands/operations.js +0 -28
  32. package/dist/commands/orgs.js +0 -24
  33. package/dist/commands/projects.js +0 -413
  34. package/dist/commands/psql.js +0 -62
  35. package/dist/commands/roles.js +0 -65
  36. package/dist/commands/schema_diff.js +0 -151
  37. package/dist/commands/set_context.js +0 -29
  38. package/dist/commands/snapshots.js +0 -455
  39. package/dist/commands/status.js +0 -40
  40. package/dist/commands/user.js +0 -15
  41. package/dist/commands/vpc_endpoints.js +0 -134
  42. package/dist/config.js +0 -11
  43. package/dist/config_format.js +0 -72
  44. package/dist/context.js +0 -231
  45. package/dist/current_branch_fast_path.js +0 -55
  46. package/dist/dev/env.js +0 -244
  47. package/dist/dev/functions.js +0 -70
  48. package/dist/dev/inputs.js +0 -63
  49. package/dist/dev/runtime.js +0 -146
  50. package/dist/env.js +0 -36
  51. package/dist/env_file.js +0 -159
  52. package/dist/errors.js +0 -80
  53. package/dist/functions_api.js +0 -48
  54. package/dist/help.js +0 -146
  55. package/dist/index.js +0 -240
  56. package/dist/log.js +0 -18
  57. package/dist/parameters.gen.js +0 -480
  58. package/dist/pkg.js +0 -25
  59. package/dist/psql/cli.js +0 -53
  60. package/dist/psql/command/cmd_cond.js +0 -437
  61. package/dist/psql/command/cmd_connect.js +0 -820
  62. package/dist/psql/command/cmd_copy.js +0 -1035
  63. package/dist/psql/command/cmd_describe.js +0 -1815
  64. package/dist/psql/command/cmd_format.js +0 -948
  65. package/dist/psql/command/cmd_io.js +0 -2193
  66. package/dist/psql/command/cmd_lo.js +0 -393
  67. package/dist/psql/command/cmd_meta.js +0 -969
  68. package/dist/psql/command/cmd_misc.js +0 -187
  69. package/dist/psql/command/cmd_pipeline.js +0 -1148
  70. package/dist/psql/command/cmd_restrict.js +0 -171
  71. package/dist/psql/command/cmd_show.js +0 -766
  72. package/dist/psql/command/dispatch.js +0 -343
  73. package/dist/psql/command/inputQueue.js +0 -42
  74. package/dist/psql/command/shared.js +0 -71
  75. package/dist/psql/complete/filenames.js +0 -139
  76. package/dist/psql/complete/index.js +0 -104
  77. package/dist/psql/complete/matcher.js +0 -315
  78. package/dist/psql/complete/psqlVars.js +0 -249
  79. package/dist/psql/complete/queries.js +0 -493
  80. package/dist/psql/complete/rules.js +0 -2424
  81. package/dist/psql/core/common.js +0 -1253
  82. package/dist/psql/core/help.js +0 -576
  83. package/dist/psql/core/mainloop.js +0 -1360
  84. package/dist/psql/core/prompt.js +0 -439
  85. package/dist/psql/core/settings.js +0 -686
  86. package/dist/psql/core/sqlHelp.js +0 -1066
  87. package/dist/psql/core/startup.js +0 -846
  88. package/dist/psql/core/syncVars.js +0 -116
  89. package/dist/psql/core/variables.js +0 -287
  90. package/dist/psql/describe/formatters.js +0 -1330
  91. package/dist/psql/describe/processNamePattern.js +0 -270
  92. package/dist/psql/describe/queries.js +0 -2452
  93. package/dist/psql/describe/versionGate.js +0 -44
  94. package/dist/psql/index.js +0 -2030
  95. package/dist/psql/io/history.js +0 -299
  96. package/dist/psql/io/input.js +0 -120
  97. package/dist/psql/io/lineEditor/buffer.js +0 -325
  98. package/dist/psql/io/lineEditor/complete.js +0 -227
  99. package/dist/psql/io/lineEditor/filename.js +0 -159
  100. package/dist/psql/io/lineEditor/index.js +0 -893
  101. package/dist/psql/io/lineEditor/keymap.js +0 -745
  102. package/dist/psql/io/lineEditor/vt100.js +0 -363
  103. package/dist/psql/io/pgpass.js +0 -202
  104. package/dist/psql/io/pgservice.js +0 -194
  105. package/dist/psql/io/psqlrc.js +0 -422
  106. package/dist/psql/print/aligned.js +0 -1748
  107. package/dist/psql/print/asciidoc.js +0 -230
  108. package/dist/psql/print/crosstab.js +0 -463
  109. package/dist/psql/print/csv.js +0 -76
  110. package/dist/psql/print/html.js +0 -240
  111. package/dist/psql/print/json.js +0 -96
  112. package/dist/psql/print/latex.js +0 -379
  113. package/dist/psql/print/pager.js +0 -267
  114. package/dist/psql/print/troff.js +0 -240
  115. package/dist/psql/print/unaligned.js +0 -99
  116. package/dist/psql/print/units.js +0 -188
  117. package/dist/psql/scanner/slash.js +0 -515
  118. package/dist/psql/scanner/sql.js +0 -914
  119. package/dist/psql/scanner/stringutils.js +0 -394
  120. package/dist/psql/types/backslash.js +0 -1
  121. package/dist/psql/types/connection.js +0 -1
  122. package/dist/psql/types/index.js +0 -7
  123. package/dist/psql/types/printer.js +0 -1
  124. package/dist/psql/types/repl.js +0 -1
  125. package/dist/psql/types/scanner.js +0 -24
  126. package/dist/psql/types/settings.js +0 -1
  127. package/dist/psql/types/variables.js +0 -1
  128. package/dist/psql/wire/connection.js +0 -2857
  129. package/dist/psql/wire/copy.js +0 -108
  130. package/dist/psql/wire/notify.js +0 -59
  131. package/dist/psql/wire/pipeline.js +0 -521
  132. package/dist/psql/wire/protocol.js +0 -466
  133. package/dist/psql/wire/sasl.js +0 -294
  134. package/dist/psql/wire/tls.js +0 -602
  135. package/dist/storage_api.js +0 -147
  136. package/dist/test_utils/fixtures.js +0 -121
  137. package/dist/test_utils/oauth_server.js +0 -9
  138. package/dist/types.js +0 -1
  139. package/dist/utils/ai_gateway_notice.js +0 -180
  140. package/dist/utils/api_enums.js +0 -33
  141. package/dist/utils/auth.js +0 -5
  142. package/dist/utils/branch_notice.js +0 -22
  143. package/dist/utils/branch_picker.js +0 -103
  144. package/dist/utils/compute_units.js +0 -28
  145. package/dist/utils/config_diff.js +0 -185
  146. package/dist/utils/enrichers.js +0 -161
  147. package/dist/utils/esbuild.js +0 -158
  148. package/dist/utils/formats.js +0 -18
  149. package/dist/utils/git_diff.js +0 -90
  150. package/dist/utils/inspect_db.js +0 -153
  151. package/dist/utils/inspect_queries.js +0 -372
  152. package/dist/utils/middlewares.js +0 -20
  153. package/dist/utils/openapi.js +0 -114
  154. package/dist/utils/package_manager.js +0 -68
  155. package/dist/utils/point_in_time.js +0 -56
  156. package/dist/utils/psql.js +0 -120
  157. package/dist/utils/string.js +0 -5
  158. package/dist/utils/ui.js +0 -59
  159. package/dist/utils/zip.js +0 -4
  160. package/dist/writer.js +0 -97
@@ -1,270 +0,0 @@
1
- /**
2
- * Port of upstream `processSQLNamePattern()` from
3
- * `src/fe_utils/string_utils.c`.
4
- *
5
- * psql's `\d*` commands accept shell-style name patterns of the form
6
- * `[db.][schema.]name`. Each component supports `*` and `?` wildcards;
7
- * components may be double-quoted to preserve case and treat regex
8
- * metacharacters literally. This routine parses the pattern into one or
9
- * more regex strings (one per dotted component) and emits the SQL
10
- * conditions that constrain the relevant catalog columns.
11
- *
12
- * The upstream entry point writes directly into a `PQExpBuffer`; we
13
- * return a structured {@link NamePatternResult} instead, leaving the
14
- * actual splicing to the caller (see `applyPattern` in `formatters.ts`).
15
- *
16
- * Differences from the C version:
17
- *
18
- * - We don't have a `PGconn` so we can't issue `appendStringLiteralConn`
19
- * or read `PQclientEncoding`. The regex strings are emitted as plain
20
- * JS strings; the caller is expected to bind them via `$N` parameters
21
- * to the prepared query. (Upstream inlines them as quoted SQL literals
22
- * because libpq doesn't have a generic parameter-binding API for
23
- * `psql`'s simple-query queries.) Binding via params is strictly
24
- * safer and arguably more faithful to the *intent* of the C code.
25
- * - `force_escape` is exposed as `forceLower` (Mac/Linux psql default
26
- * is `force_escape = false`; we still always lowercase outside
27
- * quotes because that's the documented psql user model).
28
- * - The `dotcnt` output is implicit: callers can inspect
29
- * `result.schemaConditions.length + result.nameConditions.length` if
30
- * needed.
31
- * - The `COLLATE pg_catalog.default` suffix that upstream emits for
32
- * PG >= 12 is omitted; our regex parameters are bound as text and the
33
- * server applies the default collation already. (If a follow-up WP
34
- * discovers a real divergence we can revisit.)
35
- */
36
- /**
37
- * Lower-case ASCII letters. Mirrors upstream's `pg_tolower` for the
38
- * ASCII range — we don't need full locale folding because catalog
39
- * identifiers are stored as-typed and case-folding only happens for
40
- * unquoted user input (which is restricted to lower-case anyway).
41
- */
42
- const toLower = (ch) => ch >= "A" && ch <= "Z" ? String.fromCharCode(ch.charCodeAt(0) + 32) : ch;
43
- const REGEX_SPECIALS = "|*+?()[]{}.^$\\";
44
- /**
45
- * Translate a shell-style pattern into one or more regex strings, one
46
- * per `.`-separated component. Mirrors upstream `patternToSQLRegex()`.
47
- *
48
- * Component layout: callers requesting both schema and db split keep
49
- * receiving regexes for `name`, `schema`, `db` in that *reverse* order
50
- * (matching the upstream buffer-rotation trick). We expose the regexes
51
- * in name-first order; the caller maps slots to columns.
52
- */
53
- const patternToSQLRegex = (pattern, forceLower, wantSchema, wantDb) => {
54
- // Whenever a schema column exists, accept up to 3 dotted components
55
- // (`db.schema.name`) — NOT 2. Capping at 2 made `\d mydb.public.users`
56
- // shift: it searched schema=`mydb`, relation=`public.users` and returned
57
- // nothing. The 3rd (db) slot is the cross-db literal even without a
58
- // dbnamevar column; the dispatcher validates it against the current DB
59
- // (review item #23).
60
- const maxComponents = wantSchema || wantDb ? 3 : 1;
61
- const buffers = ["^("];
62
- let leftLiteral = "";
63
- // Upstream's `want_literal_dbname`: track the first component's
64
- // literal text unconditionally so the dispatcher can detect
65
- // cross-database references and emit the canonical error message.
66
- let trackingLeft = true;
67
- let inQuotes = false;
68
- // Total separator count, independent of `maxComponents`. Upstream
69
- // increments `dotcnt` past the budget so callers can raise
70
- // "improper qualified name (too many dotted names)".
71
- let dotCount = 0;
72
- let cp = 0;
73
- while (cp < pattern.length) {
74
- const ch = pattern[cp];
75
- if (ch === '"') {
76
- if (inQuotes && pattern[cp + 1] === '"') {
77
- buffers[buffers.length - 1] += '"';
78
- if (trackingLeft)
79
- leftLiteral += '"';
80
- cp += 2;
81
- continue;
82
- }
83
- inQuotes = !inQuotes;
84
- cp++;
85
- continue;
86
- }
87
- if (!inQuotes && ch >= "A" && ch <= "Z") {
88
- const lo = toLower(ch);
89
- buffers[buffers.length - 1] += lo;
90
- if (trackingLeft)
91
- leftLiteral += lo;
92
- cp++;
93
- continue;
94
- }
95
- if (!inQuotes && ch === "*") {
96
- buffers[buffers.length - 1] += ".*";
97
- if (trackingLeft)
98
- leftLiteral += "*";
99
- cp++;
100
- continue;
101
- }
102
- if (!inQuotes && ch === "?") {
103
- buffers[buffers.length - 1] += ".";
104
- if (trackingLeft)
105
- leftLiteral += "?";
106
- cp++;
107
- continue;
108
- }
109
- if (!inQuotes && ch === ".") {
110
- dotCount++;
111
- trackingLeft = false;
112
- if (buffers.length < maxComponents) {
113
- buffers[buffers.length - 1] += ")$";
114
- buffers.push("^(");
115
- }
116
- else {
117
- buffers[buffers.length - 1] += ".";
118
- }
119
- cp++;
120
- continue;
121
- }
122
- if (ch === "$") {
123
- // Always quote $ — upstream rationale: identifiers may legitimately
124
- // contain $ (e.g. function-language names) so the literal sense wins.
125
- buffers[buffers.length - 1] += "\\$";
126
- if (trackingLeft)
127
- leftLiteral += "$";
128
- cp++;
129
- continue;
130
- }
131
- // Ordinary data character.
132
- let prefix = "";
133
- if (inQuotes || forceLower) {
134
- if (REGEX_SPECIALS.includes(ch))
135
- prefix = "\\";
136
- }
137
- else if (ch === "[" && pattern[cp + 1] === "]") {
138
- // Special: array-type bracket pair is always escaped to avoid
139
- // psql users hitting an empty-character-class regex error.
140
- prefix = "\\";
141
- }
142
- buffers[buffers.length - 1] += prefix + ch;
143
- if (trackingLeft)
144
- leftLiteral += ch;
145
- cp++;
146
- }
147
- buffers[buffers.length - 1] += ")$";
148
- // Upstream emits buffers in *reverse* assignment order: namebuf gets
149
- // the *last* component, schemabuf the second-to-last, dbnamebuf the
150
- // first. So we reverse for downstream consumption.
151
- const regexes = [...buffers].reverse();
152
- return {
153
- dotCount,
154
- regexes,
155
- // Expose the first-component literal whenever the pattern was dotted
156
- // (so the dispatcher can do the cross-db check) or when the caller
157
- // explicitly asked for it via `wantDb` (the `\l` style three-part
158
- // matcher).
159
- dbLiteral: dotCount > 0 || wantDb ? leftLiteral : null,
160
- };
161
- };
162
- /**
163
- * Build the SQL conditions and parameter values for a single name pattern.
164
- *
165
- * See module docstring for the contract. Pass-through pattern handling:
166
- * an `^(.*)$` regex is optimized away (upstream does the same), so a
167
- * bare `*` or empty unquoted segment emits no constraint.
168
- */
169
- export const processSQLNamePattern = (opts) => {
170
- const { pattern, forceLower = false, schemavar = null, namevar, altnamevar = null, visibilityrule = null, dbnamevar = null, } = opts;
171
- const result = {
172
- schemaConditions: [],
173
- nameConditions: [],
174
- visibilityConditions: [],
175
- params: [],
176
- dotCount: 0,
177
- dbLiteral: null,
178
- };
179
- if (pattern === null) {
180
- if (visibilityrule) {
181
- result.visibilityConditions.push(visibilityrule);
182
- }
183
- return result;
184
- }
185
- const parts = patternToSQLRegex(pattern, forceLower, schemavar !== null, dbnamevar !== null);
186
- result.dotCount = parts.dotCount;
187
- result.dbLiteral = parts.dbLiteral;
188
- // parts.regexes is name-first: [nameRegex, schemaRegex?, dbRegex?]
189
- const nameRegex = parts.regexes[0];
190
- const schemaRegex = parts.regexes[1] ?? null;
191
- const dbRegex = parts.regexes[2] ?? null;
192
- // Name constraint
193
- if (nameRegex && nameRegex !== "^(.*)$") {
194
- const placeholder = `$${result.params.length + 1}`;
195
- if (altnamevar) {
196
- result.nameConditions.push(`(${namevar} OPERATOR(pg_catalog.~) ${placeholder} OR ${altnamevar} OPERATOR(pg_catalog.~) ${placeholder})`);
197
- }
198
- else {
199
- result.nameConditions.push(`${namevar} OPERATOR(pg_catalog.~) ${placeholder}`);
200
- }
201
- result.params.push(nameRegex);
202
- }
203
- // Schema constraint
204
- if (schemavar && schemaRegex && schemaRegex !== "^(.*)$") {
205
- const placeholder = `$${result.params.length + 1}`;
206
- result.schemaConditions.push(`${schemavar} OPERATOR(pg_catalog.~) ${placeholder}`);
207
- result.params.push(schemaRegex);
208
- }
209
- else if (!schemaRegex && visibilityrule) {
210
- // No schema part given → use the visibility check instead.
211
- result.visibilityConditions.push(visibilityrule);
212
- }
213
- // Database constraint (rarely used; \l)
214
- if (dbnamevar && dbRegex && dbRegex !== "^(.*)$") {
215
- const placeholder = `$${result.params.length + 1}`;
216
- result.schemaConditions.push(`${dbnamevar} OPERATOR(pg_catalog.~) ${placeholder}`);
217
- result.params.push(dbRegex);
218
- }
219
- return result;
220
- };
221
- /**
222
- * Apply a {@link NamePatternResult} to a SQL string emitted by
223
- * `queries.ts` (WP-19). The placeholder string the templates emit is
224
- * `true /<!---->* TODO(WP-20): pattern matching *<!---->/` (literal).
225
- * We substitute the conjoined conditions in its place. If no conditions
226
- * were produced
227
- * (e.g. pattern was null and no visibility rule), we leave the `true`
228
- * tautology so the query semantics are unchanged.
229
- *
230
- * The placeholder may appear multiple times in a single query (e.g.
231
- * `listCasts` matches both ends of a cast). All occurrences receive the
232
- * same substitution and parameter list — that mirrors upstream, which
233
- * threads the same pattern into both columns. Parameters get renumbered
234
- * to be unique across the substituted query.
235
- */
236
- export const applyPattern = (sql, result, baseParams = []) => {
237
- const placeholder = "true /* TODO(WP-20): pattern matching */";
238
- if (!sql.includes(placeholder)) {
239
- return { sql, params: baseParams };
240
- }
241
- const conditions = [
242
- ...result.schemaConditions,
243
- ...result.nameConditions,
244
- ...result.visibilityConditions,
245
- ];
246
- if (conditions.length === 0) {
247
- return { sql, params: baseParams };
248
- }
249
- // Detect occurrences. For each occurrence we need a fresh, renumbered
250
- // parameter slot so the same regex appears with different `$N` values.
251
- const occurrences = sql.split(placeholder).length - 1;
252
- let renumbered = sql;
253
- const params = [...baseParams];
254
- for (let occ = 0; occ < occurrences; occ++) {
255
- // For this occurrence, rewrite the conditions to use the next set
256
- // of parameter slots starting at params.length + 1.
257
- const slotOffset = params.length;
258
- const conds = conditions.map((c) => c.replace(/\$(\d+)/g, (_, n) => `$${Number(n) + slotOffset}`));
259
- params.push(...result.params);
260
- const replacement = `(${conds.join(" AND ")})`;
261
- // Replace just the first remaining occurrence (others stay until
262
- // their iteration).
263
- const idx = renumbered.indexOf(placeholder);
264
- renumbered =
265
- renumbered.slice(0, idx) +
266
- replacement +
267
- renumbered.slice(idx + placeholder.length);
268
- }
269
- return { sql: renumbered, params };
270
- };