neonctl 2.37.1 → 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 (159) hide show
  1. package/README.md +15 -700
  2. package/bin/cli.js +3 -0
  3. package/package.json +8 -75
  4. package/dist/analytics.js +0 -168
  5. package/dist/api.js +0 -720
  6. package/dist/auth.js +0 -125
  7. package/dist/callback.html +0 -60
  8. package/dist/cli.js +0 -9
  9. package/dist/commands/api.js +0 -278
  10. package/dist/commands/auth.js +0 -214
  11. package/dist/commands/bootstrap.js +0 -481
  12. package/dist/commands/branches.js +0 -488
  13. package/dist/commands/bucket.js +0 -549
  14. package/dist/commands/checkout.js +0 -321
  15. package/dist/commands/config.js +0 -626
  16. package/dist/commands/connection_string.js +0 -172
  17. package/dist/commands/data_api.js +0 -284
  18. package/dist/commands/databases.js +0 -82
  19. package/dist/commands/deploy.js +0 -26
  20. package/dist/commands/dev.js +0 -698
  21. package/dist/commands/diff.js +0 -222
  22. package/dist/commands/env.js +0 -189
  23. package/dist/commands/functions.js +0 -373
  24. package/dist/commands/index.js +0 -62
  25. package/dist/commands/init.js +0 -73
  26. package/dist/commands/inspect.js +0 -65
  27. package/dist/commands/ip_allow.js +0 -137
  28. package/dist/commands/link.js +0 -1121
  29. package/dist/commands/neon_auth.js +0 -1028
  30. package/dist/commands/operations.js +0 -28
  31. package/dist/commands/orgs.js +0 -24
  32. package/dist/commands/projects.js +0 -413
  33. package/dist/commands/psql.js +0 -62
  34. package/dist/commands/roles.js +0 -65
  35. package/dist/commands/schema_diff.js +0 -151
  36. package/dist/commands/set_context.js +0 -29
  37. package/dist/commands/snapshots.js +0 -455
  38. package/dist/commands/status.js +0 -40
  39. package/dist/commands/user.js +0 -15
  40. package/dist/commands/vpc_endpoints.js +0 -134
  41. package/dist/config.js +0 -11
  42. package/dist/config_format.js +0 -72
  43. package/dist/context.js +0 -231
  44. package/dist/current_branch_fast_path.js +0 -55
  45. package/dist/dev/env.js +0 -244
  46. package/dist/dev/functions.js +0 -70
  47. package/dist/dev/inputs.js +0 -63
  48. package/dist/dev/runtime.js +0 -146
  49. package/dist/env.js +0 -36
  50. package/dist/env_file.js +0 -159
  51. package/dist/errors.js +0 -80
  52. package/dist/functions_api.js +0 -48
  53. package/dist/help.js +0 -146
  54. package/dist/index.js +0 -240
  55. package/dist/log.js +0 -18
  56. package/dist/parameters.gen.js +0 -480
  57. package/dist/pkg.js +0 -25
  58. package/dist/psql/cli.js +0 -53
  59. package/dist/psql/command/cmd_cond.js +0 -437
  60. package/dist/psql/command/cmd_connect.js +0 -820
  61. package/dist/psql/command/cmd_copy.js +0 -1035
  62. package/dist/psql/command/cmd_describe.js +0 -1815
  63. package/dist/psql/command/cmd_format.js +0 -948
  64. package/dist/psql/command/cmd_io.js +0 -2193
  65. package/dist/psql/command/cmd_lo.js +0 -393
  66. package/dist/psql/command/cmd_meta.js +0 -969
  67. package/dist/psql/command/cmd_misc.js +0 -187
  68. package/dist/psql/command/cmd_pipeline.js +0 -1148
  69. package/dist/psql/command/cmd_restrict.js +0 -171
  70. package/dist/psql/command/cmd_show.js +0 -766
  71. package/dist/psql/command/dispatch.js +0 -343
  72. package/dist/psql/command/inputQueue.js +0 -42
  73. package/dist/psql/command/shared.js +0 -71
  74. package/dist/psql/complete/filenames.js +0 -139
  75. package/dist/psql/complete/index.js +0 -104
  76. package/dist/psql/complete/matcher.js +0 -315
  77. package/dist/psql/complete/psqlVars.js +0 -249
  78. package/dist/psql/complete/queries.js +0 -493
  79. package/dist/psql/complete/rules.js +0 -2424
  80. package/dist/psql/core/common.js +0 -1253
  81. package/dist/psql/core/help.js +0 -576
  82. package/dist/psql/core/mainloop.js +0 -1360
  83. package/dist/psql/core/prompt.js +0 -439
  84. package/dist/psql/core/settings.js +0 -686
  85. package/dist/psql/core/sqlHelp.js +0 -1066
  86. package/dist/psql/core/startup.js +0 -846
  87. package/dist/psql/core/syncVars.js +0 -116
  88. package/dist/psql/core/variables.js +0 -287
  89. package/dist/psql/describe/formatters.js +0 -1330
  90. package/dist/psql/describe/processNamePattern.js +0 -270
  91. package/dist/psql/describe/queries.js +0 -2452
  92. package/dist/psql/describe/versionGate.js +0 -44
  93. package/dist/psql/index.js +0 -2030
  94. package/dist/psql/io/history.js +0 -299
  95. package/dist/psql/io/input.js +0 -120
  96. package/dist/psql/io/lineEditor/buffer.js +0 -325
  97. package/dist/psql/io/lineEditor/complete.js +0 -227
  98. package/dist/psql/io/lineEditor/filename.js +0 -159
  99. package/dist/psql/io/lineEditor/index.js +0 -893
  100. package/dist/psql/io/lineEditor/keymap.js +0 -745
  101. package/dist/psql/io/lineEditor/vt100.js +0 -363
  102. package/dist/psql/io/pgpass.js +0 -202
  103. package/dist/psql/io/pgservice.js +0 -194
  104. package/dist/psql/io/psqlrc.js +0 -422
  105. package/dist/psql/print/aligned.js +0 -1748
  106. package/dist/psql/print/asciidoc.js +0 -230
  107. package/dist/psql/print/crosstab.js +0 -463
  108. package/dist/psql/print/csv.js +0 -76
  109. package/dist/psql/print/html.js +0 -240
  110. package/dist/psql/print/json.js +0 -96
  111. package/dist/psql/print/latex.js +0 -379
  112. package/dist/psql/print/pager.js +0 -267
  113. package/dist/psql/print/troff.js +0 -240
  114. package/dist/psql/print/unaligned.js +0 -99
  115. package/dist/psql/print/units.js +0 -188
  116. package/dist/psql/scanner/slash.js +0 -515
  117. package/dist/psql/scanner/sql.js +0 -914
  118. package/dist/psql/scanner/stringutils.js +0 -394
  119. package/dist/psql/types/backslash.js +0 -1
  120. package/dist/psql/types/connection.js +0 -1
  121. package/dist/psql/types/index.js +0 -7
  122. package/dist/psql/types/printer.js +0 -1
  123. package/dist/psql/types/repl.js +0 -1
  124. package/dist/psql/types/scanner.js +0 -24
  125. package/dist/psql/types/settings.js +0 -1
  126. package/dist/psql/types/variables.js +0 -1
  127. package/dist/psql/wire/connection.js +0 -2857
  128. package/dist/psql/wire/copy.js +0 -108
  129. package/dist/psql/wire/notify.js +0 -59
  130. package/dist/psql/wire/pipeline.js +0 -521
  131. package/dist/psql/wire/protocol.js +0 -466
  132. package/dist/psql/wire/sasl.js +0 -294
  133. package/dist/psql/wire/tls.js +0 -602
  134. package/dist/storage_api.js +0 -147
  135. package/dist/test_utils/fixtures.js +0 -121
  136. package/dist/test_utils/oauth_server.js +0 -9
  137. package/dist/types.js +0 -1
  138. package/dist/utils/ai_gateway_notice.js +0 -180
  139. package/dist/utils/api_enums.js +0 -33
  140. package/dist/utils/auth.js +0 -5
  141. package/dist/utils/branch_notice.js +0 -22
  142. package/dist/utils/branch_picker.js +0 -103
  143. package/dist/utils/compute_units.js +0 -28
  144. package/dist/utils/config_diff.js +0 -185
  145. package/dist/utils/enrichers.js +0 -161
  146. package/dist/utils/esbuild.js +0 -158
  147. package/dist/utils/formats.js +0 -18
  148. package/dist/utils/git_diff.js +0 -90
  149. package/dist/utils/inspect_db.js +0 -153
  150. package/dist/utils/inspect_queries.js +0 -372
  151. package/dist/utils/middlewares.js +0 -20
  152. package/dist/utils/openapi.js +0 -114
  153. package/dist/utils/package_manager.js +0 -68
  154. package/dist/utils/point_in_time.js +0 -56
  155. package/dist/utils/psql.js +0 -120
  156. package/dist/utils/string.js +0 -5
  157. package/dist/utils/ui.js +0 -59
  158. package/dist/utils/zip.js +0 -4
  159. package/dist/writer.js +0 -97
@@ -1,171 +0,0 @@
1
- /**
2
- * `\restrict` and `\unrestrict` — PG 18 introduced these to lock the
3
- * psql REPL into a "restricted" sub-shell where shell-side or
4
- * filesystem-side backslash commands are refused.
5
- *
6
- * Implementation notes (deviations from upstream by design):
7
- *
8
- * - Upstream PG 18 blocks **every** backslash command except
9
- * `\unrestrict` while restricted. The brief for this work package
10
- * instructs a narrower policy: block only the commands that can
11
- * spawn a child process, write to the local filesystem, or mutate
12
- * the surrounding environment (`\!`, `\cd`, `\copy`, `\setenv`,
13
- * `\write` / `\w`). Plain SQL and read-only meta commands continue
14
- * to run. The trade-off: easier for scripted use, slightly looser
15
- * than upstream. Documented here and surfaced to the user via the
16
- * error message.
17
- *
18
- * - The restriction state lives in `settings.restrictedKey`, NOT in the
19
- * user-writable `vars` store. An earlier design kept it in a psql
20
- * variable named `RESTRICTED`, which let `\set RESTRICTED ''` (or
21
- * `\unset` / `\getenv` / `\gset` of that name) silently leave restricted
22
- * mode without knowing the `\restrict` key — fully defeating the control
23
- * (review item #12). Only `\restrict` / `\unrestrict` touch the field.
24
- *
25
- * - `\copy` is restricted in full, not only `\copy ... FROM PROGRAM`.
26
- * The brief explicitly asks for registry-level interception
27
- * (avoid touching every cmd_* file) — that constrains us to whole
28
- * commands by name. Documented as a deliberate over-restriction.
29
- *
30
- * - Name matching: `\unrestrict NAME` requires the same NAME that
31
- * `\restrict NAME` provided. A mismatch keeps the session in
32
- * restricted mode and returns an error.
33
- */
34
- import { writeErr } from "./shared.js";
35
- /** Standard refusal message emitted when a gated command is invoked while
36
- * the session is in restricted mode. Public so callers and tests can match
37
- * against the exact string. */
38
- export const RESTRICTED_REFUSAL_MESSAGE = (cmdName) => `\\${cmdName}: command is not allowed in restricted mode; ` +
39
- `use \\unrestrict to leave restricted mode\n`;
40
- /**
41
- * Backslash command names blocked while restricted. Lookup is by
42
- * **primary** name — aliases (e.g. `write` → `w`, `quit` → `q`)
43
- * resolve to the primary spec before the gate runs, so the gate sees
44
- * the canonical name.
45
- *
46
- * Trade-off (per the WP brief): block `\copy` entirely rather than
47
- * inspect the args for `PROGRAM`. Aligns with "intercept at the
48
- * registry level" and avoids touching cmd_copy.ts internals.
49
- */
50
- export const RESTRICTED_COMMANDS = new Set([
51
- "!", // shell escape
52
- "cd", // change directory
53
- "copy", // \copy — including \copy FROM PROGRAM
54
- "setenv", // mutate process env
55
- "w", // \w / \write — file write of query buffer
56
- // `\o`/`\g`/`\gx` route through openWriter(), which spawns `sh -c <cmd>`
57
- // for a `|command` target (arbitrary shell exec) and writes the filesystem
58
- // for a FILE target; `\s FILE` writes history to disk. Block them by name
59
- // (review item #13). Plain query execution still works via `;`.
60
- "o", // \o [FILE | |cmd]
61
- "g", // \g [FILE | |cmd]
62
- "gx", // \gx [FILE | |cmd]
63
- "s", // \s [FILE] — write command history
64
- ]);
65
- /**
66
- * True iff the session is currently in restricted mode. Reads the
67
- * protected {@link PsqlSettings.restrictedKey} field (NOT a psql var, so
68
- * `\set`/`\unset`/`\getenv`/`\gset` cannot flip it — review item #12).
69
- */
70
- export const isRestricted = (settings) => settings.restrictedKey !== null;
71
- /**
72
- * Return the active restriction name (the value supplied to
73
- * `\restrict NAME`), or `null` if not restricted.
74
- */
75
- export const restrictedName = (settings) => settings.restrictedKey;
76
- /**
77
- * Predicate used by the dispatcher: should the given primary command
78
- * name be refused right now?
79
- */
80
- export const isCommandRestricted = (settings, primaryName) => isRestricted(settings) && RESTRICTED_COMMANDS.has(primaryName);
81
- /**
82
- * `\restrict NAME` — enter restricted mode. `NAME` (any non-empty
83
- * string) becomes the key that `\unrestrict` must match to leave.
84
- *
85
- * If already restricted, this is an error — upstream treats this
86
- * with an Assert; we surface it as a regular command error.
87
- */
88
- export const cmdRestrict = {
89
- name: "restrict",
90
- helpKey: "restrict",
91
- run: (ctx) => {
92
- const arg = ctx.nextArg("normal");
93
- if (arg === null || arg.length === 0) {
94
- writeErr(`\\${ctx.cmdName}: missing required argument\n`);
95
- return Promise.resolve({ status: "error" });
96
- }
97
- if (isRestricted(ctx.settings)) {
98
- writeErr(`\\${ctx.cmdName}: already in restricted mode\n`);
99
- return Promise.resolve({ status: "error" });
100
- }
101
- ctx.settings.restrictedKey = arg;
102
- return Promise.resolve({ status: "ok" });
103
- },
104
- };
105
- /**
106
- * `\unrestrict NAME` — leave restricted mode if NAME matches the key
107
- * given to the original `\restrict`.
108
- */
109
- export const cmdUnrestrict = {
110
- name: "unrestrict",
111
- helpKey: "unrestrict",
112
- run: (ctx) => {
113
- const arg = ctx.nextArg("normal");
114
- if (arg === null || arg.length === 0) {
115
- writeErr(`\\${ctx.cmdName}: missing required argument\n`);
116
- return Promise.resolve({ status: "error" });
117
- }
118
- const current = restrictedName(ctx.settings);
119
- if (current === null) {
120
- writeErr(`\\${ctx.cmdName}: not currently in restricted mode\n`);
121
- return Promise.resolve({ status: "error" });
122
- }
123
- if (arg !== current) {
124
- writeErr(`\\${ctx.cmdName}: wrong key\n`);
125
- return Promise.resolve({ status: "error" });
126
- }
127
- ctx.settings.restrictedKey = null;
128
- return Promise.resolve({ status: "ok" });
129
- },
130
- };
131
- /**
132
- * Convenience registration helper, used by `defaultRegistry()` in
133
- * `dispatch.ts`. Kept in this file so the dispatch.ts addition is a
134
- * single line.
135
- */
136
- export const registerRestrictCommands = (registry) => {
137
- registry.register(cmdRestrict);
138
- registry.register(cmdUnrestrict);
139
- };
140
- /**
141
- * Wrap every already-registered spec whose primary name is in
142
- * {@link RESTRICTED_COMMANDS} so its `run` gates on the live restriction
143
- * state. Without this the gate in `dispatch.ts::dispatchBackslash` only
144
- * fires for the `psqlrc` path; the REPL mainloop currently invokes
145
- * `spec.run` directly and would bypass the check.
146
- *
147
- * Idempotent: a wrapped spec carries a `[WRAPPED_FLAG]` marker so a second
148
- * call is a no-op. Must be called *after* all restricted commands have
149
- * been registered (so we see them via `registry.lookup`).
150
- */
151
- const WRAPPED_FLAG = Symbol.for("neonctl.psql.restrictWrapped");
152
- export const wrapRestrictedCommands = (registry) => {
153
- for (const name of RESTRICTED_COMMANDS) {
154
- const spec = registry.lookup(name);
155
- if (!spec || spec[WRAPPED_FLAG])
156
- continue;
157
- const originalRun = spec.run.bind(spec);
158
- const gated = {
159
- ...spec,
160
- run: (ctx) => {
161
- if (isRestricted(ctx.settings)) {
162
- writeErr(RESTRICTED_REFUSAL_MESSAGE(ctx.cmdName));
163
- return Promise.resolve({ status: "error" });
164
- }
165
- return originalRun(ctx);
166
- },
167
- };
168
- gated[WRAPPED_FLAG] = true;
169
- registry.register(gated);
170
- }
171
- };