neon 2.47.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 +395 -0
  5. package/dist/_shared/env-core/reuse-secrets.js +179 -0
  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 +575 -658
  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 +642 -681
  28. package/dist/commands/diff.js +156 -200
  29. package/dist/commands/env.js +243 -303
  30. package/dist/commands/functions.js +275 -341
  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 -64
  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 +133 -147
  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 +9 -7
package/dist/api.js CHANGED
@@ -1,808 +1,865 @@
1
- // Thin fetch-based client layer over `@neon/sdk` (the official, fetch-native
2
- // Neon SDK). neonctl was originally built on the axios-based
3
- // `@neondatabase/api-client`, whose generated `Api` object exposes one
4
- // positional method per endpoint and resolves to an `AxiosResponse`. This module
5
- // reproduces exactly the subset of `Api` methods neonctl uses, backed by the
6
- // tree-shakeable `@neon/sdk/raw` functions, and returns a small
7
- // `{ data, status, headers }` envelope the call sites destructure.
8
- //
9
- // On a non-2xx response (or a network/timeout failure) it throws a single typed
10
- // {@link NeonApiError}; every call site narrows failures with
11
- // {@link isNeonApiError} and reads `error.status` / `error.data`. There is no
12
- // axios anywhere in neonctl: requests go through the global `fetch`, and this is
13
- // the one place HTTP errors are shaped.
1
+ import { log } from "./log.js";
2
+ import pkg_default from "./pkg.js";
14
3
  import { Readable } from "node:stream";
15
4
  import * as raw from "@neon/sdk/raw";
16
5
  import { createClient, createConfig } from "@neon/sdk/raw";
17
6
  import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
18
- import { log } from "./log.js";
19
- import pkg from "./pkg.js";
20
- // Node's global `fetch` (undici) ignores HTTP_PROXY / HTTPS_PROXY / NO_PROXY,
21
- // whereas the axios-based client neonctl used previously honored them. Restore
22
- // that behaviour by installing a proxy-aware global dispatcher — but only when a
23
- // proxy is actually configured, so the default (no-proxy) path stays untouched.
24
- // This covers every `fetch` neonctl makes, including the direct S3 upload.
25
- const PROXY_ENV_VARS = [
26
- "HTTP_PROXY",
27
- "http_proxy",
28
- "HTTPS_PROXY",
29
- "https_proxy",
30
- "ALL_PROXY",
31
- "all_proxy",
32
- ];
33
- if (PROXY_ENV_VARS.some((name) => process.env[name])) {
34
- setGlobalDispatcher(new EnvHttpProxyAgent());
35
- }
7
+ //#region src/api.ts
8
+ if ([
9
+ "HTTP_PROXY",
10
+ "http_proxy",
11
+ "HTTPS_PROXY",
12
+ "https_proxy",
13
+ "ALL_PROXY",
14
+ "all_proxy"
15
+ ].some((name) => process.env[name])) setGlobalDispatcher(new EnvHttpProxyAgent());
36
16
  const DEFAULT_API_HOST = "https://console.neon.tech/api/v2";
37
- const REQUEST_TIMEOUT_MS = 60000;
38
- const USER_AGENT = `neonctl v${pkg.version}`;
17
+ const REQUEST_TIMEOUT_MS = 6e4;
18
+ const USER_AGENT = `neonctl v${pkg_default.version}`;
39
19
  /** Mirrors the api-client `ContentType` enum used by the `request()` escape hatch. */
40
- export var ContentType;
41
- (function (ContentType) {
42
- ContentType["Json"] = "application/json";
43
- ContentType["FormData"] = "multipart/form-data";
44
- ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
45
- ContentType["Text"] = "text/plain";
46
- })(ContentType || (ContentType = {}));
20
+ let ContentType = /* @__PURE__ */ function(ContentType) {
21
+ ContentType["Json"] = "application/json";
22
+ ContentType["FormData"] = "multipart/form-data";
23
+ ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
24
+ ContentType["Text"] = "text/plain";
25
+ return ContentType;
26
+ }({});
47
27
  /**
48
- * The single error type thrown by the neonctl API layer. It carries the HTTP
49
- * status and parsed body for a non-2xx response, or a `code` (e.g. `ETIMEDOUT`)
50
- * for a network/timeout failure. Call sites narrow with {@link isNeonApiError}
51
- * and read `status` / `data` rather than reaching into an axios-shaped object.
52
- */
53
- export class NeonApiError extends Error {
54
- constructor(message, init = {}) {
55
- super(message);
56
- this.name = "NeonApiError";
57
- this.status = init.status;
58
- this.statusText = init.statusText;
59
- this.data = init.data;
60
- this.headers = init.headers;
61
- this.requestPath = init.requestPath;
62
- this.code = init.code;
63
- }
64
- }
28
+ * The single error type thrown by the neonctl API layer. It carries the HTTP
29
+ * status and parsed body for a non-2xx response, or a `code` (e.g. `ETIMEDOUT`)
30
+ * for a network/timeout failure. Call sites narrow with {@link isNeonApiError}
31
+ * and read `status` / `data` rather than reaching into an axios-shaped object.
32
+ */
33
+ var NeonApiError = class extends Error {
34
+ constructor(message, init = {}) {
35
+ super(message);
36
+ this.name = "NeonApiError";
37
+ this.status = init.status;
38
+ this.statusText = init.statusText;
39
+ this.data = init.data;
40
+ this.headers = init.headers;
41
+ this.requestPath = init.requestPath;
42
+ this.code = init.code;
43
+ }
44
+ };
65
45
  /** Narrow an unknown error to a {@link NeonApiError}. */
66
- export function isNeonApiError(err) {
67
- return err instanceof NeonApiError;
46
+ function isNeonApiError(err) {
47
+ return err instanceof NeonApiError;
68
48
  }
69
49
  /** Extract a `message` string from a parsed error body, if present. */
70
- export function messageFromBody(body) {
71
- if (body && typeof body === "object" && "message" in body) {
72
- const message = body.message;
73
- if (typeof message === "string")
74
- return message;
75
- }
76
- return undefined;
50
+ function messageFromBody(body) {
51
+ if (body && typeof body === "object" && "message" in body) {
52
+ const message = body.message;
53
+ if (typeof message === "string") return message;
54
+ }
77
55
  }
78
56
  /** Extract a machine-readable `code` string from a parsed error body, if present. */
79
- export function codeFromBody(body) {
80
- if (body && typeof body === "object" && "code" in body) {
81
- const code = body.code;
82
- if (typeof code === "string")
83
- return code;
84
- }
85
- return undefined;
57
+ function codeFromBody(body) {
58
+ if (body && typeof body === "object" && "code" in body) {
59
+ const code = body.code;
60
+ if (typeof code === "string") return code;
61
+ }
86
62
  }
87
63
  /**
88
- * Adapt a WHATWG `ReadableStream` (what `fetch` gives us as `response.body`) to
89
- * a Node `Readable`, so callers can `pipeline()` the body straight to disk. Done
90
- * by hand rather than `Readable.fromWeb` to sidestep the DOM-vs-`node:stream/web`
91
- * `ReadableStream` type friction without an unsafe cast.
92
- */
64
+ * Adapt a WHATWG `ReadableStream` (what `fetch` gives us as `response.body`) to
65
+ * a Node `Readable`, so callers can `pipeline()` the body straight to disk. Done
66
+ * by hand rather than `Readable.fromWeb` to sidestep the DOM-vs-`node:stream/web`
67
+ * `ReadableStream` type friction without an unsafe cast.
68
+ */
93
69
  function webStreamToNodeReadable(body) {
94
- const reader = body.getReader();
95
- return new Readable({
96
- async read() {
97
- try {
98
- const { done, value } = await reader.read();
99
- this.push(done ? null : Buffer.from(value));
100
- }
101
- catch (err) {
102
- this.destroy(err instanceof Error ? err : new Error(String(err)));
103
- }
104
- },
105
- });
70
+ const reader = body.getReader();
71
+ return new Readable({ async read() {
72
+ try {
73
+ const { done, value } = await reader.read();
74
+ this.push(done ? null : Buffer.from(value));
75
+ } catch (err) {
76
+ this.destroy(err instanceof Error ? err : new Error(String(err)));
77
+ }
78
+ } });
106
79
  }
107
80
  function headersToObject(headers) {
108
- const out = {};
109
- headers.forEach((value, key) => {
110
- out[key] = value;
111
- });
112
- return out;
81
+ const out = {};
82
+ headers.forEach((value, key) => {
83
+ out[key] = value;
84
+ });
85
+ return out;
113
86
  }
114
87
  /**
115
- * Raised by {@link makeTimedFetch} when the CLI's own request timeout fires. Owning the
116
- * type is what makes the timeout recognisable further up: `@neon/sdk` reports every
117
- * transport failure as a `NeonNetworkError`, so matching on names or codes cannot tell a
118
- * timeout from a reset connection.
119
- */
120
- class RequestTimeoutError extends Error {
121
- constructor(timeoutMs, reason) {
122
- super(`Request timed out after ${timeoutMs}ms`);
123
- this.name = "RequestTimeoutError";
124
- this.reason = reason;
125
- }
126
- }
88
+ * Raised by {@link makeTimedFetch} when the CLI's own request timeout fires. Owning the
89
+ * type is what makes the timeout recognisable further up: `@neon/sdk` reports every
90
+ * transport failure as a `NeonNetworkError`, so matching on names or codes cannot tell a
91
+ * timeout from a reset connection.
92
+ */
93
+ var RequestTimeoutError = class extends Error {
94
+ constructor(timeoutMs, reason) {
95
+ super(`Request timed out after ${timeoutMs}ms`);
96
+ this.name = "RequestTimeoutError";
97
+ this.reason = reason;
98
+ }
99
+ };
127
100
  /**
128
- * Whether a failure was a request timeout rather than a connectivity problem.
129
- *
130
- * Walks the `cause` chain, because the SDK wraps whatever `fetch` threw. Before this, the
131
- * check only looked at the top-level error's `name` — which is `NeonNetworkError` on every
132
- * SDK path — so a timeout fell through to the connectivity branch and the user was told to
133
- * check an internet connection that was working.
134
- */
101
+ * Whether a failure was a request timeout rather than a connectivity problem.
102
+ *
103
+ * Walks the `cause` chain, because the SDK wraps whatever `fetch` threw. Before this, the
104
+ * check only looked at the top-level error's `name` — which is `NeonNetworkError` on every
105
+ * SDK path — so a timeout fell through to the connectivity branch and the user was told to
106
+ * check an internet connection that was working.
107
+ */
135
108
  function isAbortError(err) {
136
- let current = err;
137
- for (let depth = 0; depth < 6 && current != null; depth++) {
138
- if (current instanceof RequestTimeoutError)
139
- return true;
140
- if (current instanceof Error &&
141
- (current.name === "AbortError" || current.name === "TimeoutError")) {
142
- return true;
143
- }
144
- // `@neon/sdk` classifies its own deadlines and cancellations by kind; the CLI
145
- // does not set them today, but reading them keeps this correct if it ever does.
146
- const kind = current.kind;
147
- if (kind === "timeout" || kind === "aborted")
148
- return true;
149
- current = current.cause;
150
- }
151
- return false;
109
+ let current = err;
110
+ for (let depth = 0; depth < 6 && current != null; depth++) {
111
+ if (current instanceof RequestTimeoutError) return true;
112
+ if (current instanceof Error && (current.name === "AbortError" || current.name === "TimeoutError")) return true;
113
+ const kind = current.kind;
114
+ if (kind === "timeout" || kind === "aborted") return true;
115
+ current = current.cause;
116
+ }
117
+ return false;
152
118
  }
153
119
  /**
154
- * Walk an error's `cause` chain to find the underlying socket/DNS `code` (e.g.
155
- * `ECONNREFUSED`, `ENOTFOUND`) — `fetch` surfaces these as the `cause` of a bare
156
- * `TypeError: fetch failed`. Preserving the code lets `isNetworkError` classify
157
- * the resulting {@link NeonApiError} as a connectivity failure.
158
- */
120
+ * Walk an error's `cause` chain to find the underlying socket/DNS `code` (e.g.
121
+ * `ECONNREFUSED`, `ENOTFOUND`) — `fetch` surfaces these as the `cause` of a bare
122
+ * `TypeError: fetch failed`. Preserving the code lets `isNetworkError` classify
123
+ * the resulting {@link NeonApiError} as a connectivity failure.
124
+ */
159
125
  function readSocketCode(err) {
160
- let current = err;
161
- for (let depth = 0; depth < 6 && current != null; depth++) {
162
- if (typeof current === "object" && "code" in current) {
163
- const code = current.code;
164
- if (typeof code === "string")
165
- return code;
166
- }
167
- current = current.cause;
168
- }
169
- return undefined;
126
+ let current = err;
127
+ for (let depth = 0; depth < 6 && current != null; depth++) {
128
+ if (typeof current === "object" && "code" in current) {
129
+ const code = current.code;
130
+ if (typeof code === "string") return code;
131
+ }
132
+ current = current.cause;
133
+ }
170
134
  }
171
135
  /**
172
- * The wrapped `@neon/sdk/raw` layer surfaces a typed `NeonError` on `.error`, whose `.body`
173
- * holds the original parsed API error body. Unwrap it so {@link httpError} sees the body
174
- * (message/code) rather than the SDK wrapper object.
175
- */
136
+ * The wrapped `@neon/sdk/raw` layer surfaces a typed `NeonError` on `.error`, whose `.body`
137
+ * holds the original parsed API error body. Unwrap it so {@link httpError} sees the body
138
+ * (message/code) rather than the SDK wrapper object.
139
+ */
176
140
  function rawErrorBody(error) {
177
- if (error && typeof error === "object" && "body" in error) {
178
- return error.body;
179
- }
180
- return error;
141
+ if (error && typeof error === "object" && "body" in error) return error.body;
142
+ return error;
181
143
  }
182
144
  /** Build a {@link NeonApiError} from a non-2xx `Response` and its parsed body. */
183
145
  function httpError(response, body) {
184
- let requestPath;
185
- try {
186
- requestPath = new URL(response.url).pathname;
187
- }
188
- catch {
189
- // response.url may be empty in some runtimes; the path is best-effort.
190
- }
191
- return new NeonApiError(messageFromBody(body) ??
192
- `Request failed with status code ${response.status}`, {
193
- status: response.status,
194
- statusText: response.statusText,
195
- data: body,
196
- headers: headersToObject(response.headers),
197
- requestPath,
198
- });
146
+ let requestPath;
147
+ try {
148
+ requestPath = new URL(response.url).pathname;
149
+ } catch {}
150
+ return new NeonApiError(messageFromBody(body) ?? `Request failed with status code ${response.status}`, {
151
+ status: response.status,
152
+ statusText: response.statusText,
153
+ data: body,
154
+ headers: headersToObject(response.headers),
155
+ requestPath
156
+ });
199
157
  }
200
158
  /**
201
- * Translate a thrown `fetch` failure into a {@link NeonApiError}. A request
202
- * timeout uses `ECONNABORTED` (matching the old axios behaviour, and excluded
203
- * from `isNetworkError`'s connectivity codes so it's still reported as a
204
- * timeout). A connection failure keeps its real socket code (e.g.
205
- * `ECONNREFUSED`) so `isNetworkError` recognises it as a connectivity problem.
206
- */
159
+ * Translate a thrown `fetch` failure into a {@link NeonApiError}. A request
160
+ * timeout uses `ECONNABORTED` (matching the old axios behaviour, and excluded
161
+ * from `isNetworkError`'s connectivity codes so it's still reported as a
162
+ * timeout). A connection failure keeps its real socket code (e.g.
163
+ * `ECONNREFUSED`) so `isNetworkError` recognises it as a connectivity problem.
164
+ */
207
165
  function networkError(err) {
208
- if (isAbortError(err)) {
209
- return new NeonApiError("Request timed out", { code: "ECONNABORTED" });
210
- }
211
- return new NeonApiError(err instanceof Error ? err.message : String(err), {
212
- code: readSocketCode(err) ?? "ENETWORK",
213
- });
166
+ if (isAbortError(err)) return new NeonApiError("Request timed out", { code: "ECONNABORTED" });
167
+ return new NeonApiError(err instanceof Error ? err.message : String(err), { code: readSocketCode(err) ?? "ENETWORK" });
214
168
  }
215
169
  /**
216
- * `fetch` with neonctl's request timeout applied (preserving any caller signal)
217
- * and lightweight debug logging of the request line + response status — the
218
- * fetch-native replacement for the old `axios-debug-log` wiring.
219
- */
170
+ * `fetch` with neonctl's request timeout applied (preserving any caller signal)
171
+ * and lightweight debug logging of the request line + response status — the
172
+ * fetch-native replacement for the old `axios-debug-log` wiring.
173
+ */
220
174
  /**
221
- * The largest delay a timer can represent. Above it Node warns
222
- * (`TimeoutOverflowWarning`) and fires after 1ms instead.
223
- */
175
+ * The largest delay a timer can represent. Above it Node warns
176
+ * (`TimeoutOverflowWarning`) and fires after 1ms instead.
177
+ */
224
178
  const MAX_TIMER_MS = 2 ** 31 - 1;
225
179
  /**
226
- * Reject a timeout `AbortSignal.timeout` would refuse or silently mistreat.
227
- *
228
- * Without this the bad value surfaces as the very failure this classification exists to
229
- * prevent: `-1`, `NaN`, `Infinity`, fractions and anything above `4294967295` throw
230
- * `ERR_OUT_OF_RANGE` from inside the fetch wrapper, which is then wrapped as a
231
- * `NeonNetworkError` and reported as a broken internet connection.
232
- *
233
- * `0`, and the band from {@link MAX_TIMER_MS} + 1 up to `4294967295`, are worse still:
234
- * both are accepted, and both make every request time out immediately — `0` by asking for
235
- * it, the band because a timer above the signed 32-bit ceiling collapses to 1ms.
236
- */
180
+ * Reject a timeout `AbortSignal.timeout` would refuse or silently mistreat.
181
+ *
182
+ * Without this the bad value surfaces as the very failure this classification exists to
183
+ * prevent: `-1`, `NaN`, `Infinity`, fractions and anything above `4294967295` throw
184
+ * `ERR_OUT_OF_RANGE` from inside the fetch wrapper, which is then wrapped as a
185
+ * `NeonNetworkError` and reported as a broken internet connection.
186
+ *
187
+ * `0`, and the band from {@link MAX_TIMER_MS} + 1 up to `4294967295`, are worse still:
188
+ * both are accepted, and both make every request time out immediately — `0` by asking for
189
+ * it, the band because a timer above the signed 32-bit ceiling collapses to 1ms.
190
+ */
237
191
  function validateRequestTimeout(ms) {
238
- if (!Number.isInteger(ms) || ms < 1 || ms > MAX_TIMER_MS) {
239
- throw new Error(`requestTimeoutMs must be a whole number of milliseconds between 1 and ${MAX_TIMER_MS}; received ${ms}.`);
240
- }
241
- return ms;
192
+ if (!Number.isInteger(ms) || ms < 1 || ms > MAX_TIMER_MS) throw new Error(`requestTimeoutMs must be a whole number of milliseconds between 1 and ${MAX_TIMER_MS}; received ${ms}.`);
193
+ return ms;
242
194
  }
243
195
  const makeTimedFetch = (requestTimeoutMs) => async (input, init) => {
244
- const timeout = AbortSignal.timeout(requestTimeoutMs);
245
- const signal = init?.signal
246
- ? AbortSignal.any([init.signal, timeout])
247
- : timeout;
248
- const method = init?.method ?? (input instanceof Request ? input.method : "GET");
249
- const url = input instanceof Request ? input.url : String(input);
250
- log.debug("%s %s", method.toUpperCase(), url);
251
- try {
252
- const response = await fetch(input, { ...init, signal });
253
- log.debug("%d %s", response.status, response.statusText);
254
- return response;
255
- }
256
- catch (err) {
257
- // Our own timeout fired, and we are the only code that knows that: by the
258
- // time this reaches `networkError` the SDK has wrapped it as a
259
- // `NeonNetworkError`, and neither its name nor its `cause` chain carries a
260
- // string code to recognise. Raise something we own instead of leaving the
261
- // classification to guess.
262
- if (timeout.aborted && !init?.signal?.aborted) {
263
- throw new RequestTimeoutError(requestTimeoutMs, err);
264
- }
265
- throw err;
266
- }
196
+ const timeout = AbortSignal.timeout(requestTimeoutMs);
197
+ const signal = init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout;
198
+ const method = init?.method ?? (input instanceof Request ? input.method : "GET");
199
+ const url = input instanceof Request ? input.url : String(input);
200
+ log.debug("%s %s", method.toUpperCase(), url);
201
+ try {
202
+ const response = await fetch(input, {
203
+ ...init,
204
+ signal
205
+ });
206
+ log.debug("%d %s", response.status, response.statusText);
207
+ return response;
208
+ } catch (err) {
209
+ if (timeout.aborted && !init?.signal?.aborted) throw new RequestTimeoutError(requestTimeoutMs, err);
210
+ throw err;
211
+ }
267
212
  };
268
213
  const RETRY_COUNT = 5;
269
- const RETRY_DELAY = 3000;
214
+ const RETRY_DELAY = 3e3;
270
215
  /**
271
- * Retry a call while the API answers 423 (Locked) — Neon's "a prior mutation on
272
- * this resource is still in flight" signal.
273
- */
274
- export const retryOnLock = async (fn) => {
275
- let attempt = 0;
276
- let errOut;
277
- while (attempt < RETRY_COUNT) {
278
- try {
279
- return await fn();
280
- }
281
- catch (err) {
282
- errOut = err;
283
- if (isNeonApiError(err) && err.status === 423) {
284
- attempt++;
285
- log.info(`Resource is locked. Waiting ${RETRY_DELAY}ms before retrying...`);
286
- await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
287
- }
288
- else {
289
- throw err;
290
- }
291
- }
292
- }
293
- throw errOut;
216
+ * Retry a call while the API answers 423 (Locked) — Neon's "a prior mutation on
217
+ * this resource is still in flight" signal.
218
+ */
219
+ const retryOnLock = async (fn) => {
220
+ let attempt = 0;
221
+ let errOut;
222
+ while (attempt < RETRY_COUNT) try {
223
+ return await fn();
224
+ } catch (err) {
225
+ errOut = err;
226
+ if (isNeonApiError(err) && err.status === 423) {
227
+ attempt++;
228
+ log.info(`Resource is locked. Waiting ${RETRY_DELAY}ms before retrying...`);
229
+ await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
230
+ } else throw err;
231
+ }
232
+ throw errOut;
294
233
  };
295
234
  function buildUrl(apiHost, path, query) {
296
- const url = new URL(`${apiHost.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`);
297
- if (query) {
298
- for (const [key, value] of Object.entries(query)) {
299
- if (value === undefined || value === null)
300
- continue;
301
- url.searchParams.set(key, String(value));
302
- }
303
- }
304
- return url.toString();
235
+ const url = new URL(`${apiHost.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`);
236
+ if (query) for (const [key, value] of Object.entries(query)) {
237
+ if (value === void 0 || value === null) continue;
238
+ url.searchParams.set(key, String(value));
239
+ }
240
+ return url.toString();
305
241
  }
306
242
  async function readJsonBody(response) {
307
- const text = await response.text();
308
- if (text.trim() === "")
309
- return undefined;
310
- try {
311
- return JSON.parse(text);
312
- }
313
- catch {
314
- // Match axios' `responseType: 'json'` behaviour: a body that isn't valid
315
- // JSON is surfaced as the raw string rather than coerced into an object, so
316
- // callers' `body?.message` checks correctly see "no structured message".
317
- return text;
318
- }
243
+ const text = await response.text();
244
+ if (text.trim() === "") return void 0;
245
+ try {
246
+ return JSON.parse(text);
247
+ } catch {
248
+ return text;
249
+ }
319
250
  }
320
- export const getApiClient = ({ apiKey, apiHost, requestTimeoutMs = REQUEST_TIMEOUT_MS, }) => {
321
- const baseUrl = apiHost ?? DEFAULT_API_HOST;
322
- // Shared by the generated client and the low-level `request()` escape hatch, so both
323
- // paths get the same timeout and the same timeout classification.
324
- const fetchWithTimeout = makeTimedFetch(validateRequestTimeout(requestTimeoutMs));
325
- const client = createClient(createConfig({
326
- auth: () => apiKey,
327
- baseUrl,
328
- fetch: fetchWithTimeout,
329
- headers: { "User-Agent": USER_AGENT },
330
- }));
331
- /** Await a raw call, unwrap to a `{ data, status, headers }` envelope, or throw {@link NeonApiError}. */
332
- async function call(run) {
333
- let result;
334
- try {
335
- result = await run();
336
- }
337
- catch (err) {
338
- throw networkError(err);
339
- }
340
- const response = result.response;
341
- if (!response) {
342
- throw networkError(result.error ?? new Error("No response from Neon API"));
343
- }
344
- if (!response.ok) {
345
- throw httpError(response, rawErrorBody(result.error) ?? result.data);
346
- }
347
- return {
348
- data: result.data,
349
- status: response.status,
350
- statusText: response.statusText,
351
- headers: headersToObject(response.headers),
352
- };
353
- }
354
- /**
355
- * Low-level request used by the object-storage and functions helpers for
356
- * endpoints not (yet) modeled as typed SDK functions. Mirrors the api-client
357
- * `HttpClient.request()`: `format: 'json'` parses the body, `format: 'stream'`
358
- * returns a Node `Readable`, and `type: ContentType.FormData` sends multipart.
359
- */
360
- async function request(params) {
361
- const url = buildUrl(baseUrl, params.path, params.query);
362
- const headers = { "User-Agent": USER_AGENT };
363
- if (params.secure !== false) {
364
- headers.Authorization = `Bearer ${apiKey}`;
365
- }
366
- let payload;
367
- if (params.body instanceof FormData ||
368
- params.type === ContentType.FormData) {
369
- payload = params.body;
370
- }
371
- else if (params.body !== undefined) {
372
- headers["Content-Type"] = ContentType.Json;
373
- payload = JSON.stringify(params.body);
374
- }
375
- // Caller-supplied headers win over the defaults set above.
376
- if (params.headers) {
377
- for (const [key, value] of Object.entries(params.headers)) {
378
- headers[key] = value;
379
- }
380
- }
381
- let response;
382
- try {
383
- response = await fetchWithTimeout(url, {
384
- method: params.method,
385
- headers,
386
- ...(payload !== undefined ? { body: payload } : {}),
387
- });
388
- }
389
- catch (err) {
390
- throw networkError(err);
391
- }
392
- if (!response.ok) {
393
- // For a streamed download the error body arrives as a stream too; hand it
394
- // back as a Node `Readable` so the caller can drain it for a message.
395
- const errorBody = params.format === "stream" && response.body
396
- ? webStreamToNodeReadable(response.body)
397
- : await readJsonBody(response);
398
- throw httpError(response, errorBody);
399
- }
400
- let data;
401
- if (params.format === "stream") {
402
- data = response.body
403
- ? webStreamToNodeReadable(response.body)
404
- : undefined;
405
- }
406
- else {
407
- data = await readJsonBody(response);
408
- }
409
- return {
410
- data: data,
411
- status: response.status,
412
- statusText: response.statusText,
413
- headers: headersToObject(response.headers),
414
- };
415
- }
416
- return {
417
- request,
418
- // ─── Account / user ──────────────────────────────────────────────────
419
- getCurrentUserInfo: () => call(() => raw.getCurrentUserInfo({ client })),
420
- getCurrentUserOrganizations: () => call(() => raw.getCurrentUserOrganizations({ client })),
421
- getAuthDetails: () => call(() => raw.getAuthDetails({ client })),
422
- getActiveRegions: () => call(() => raw.getActiveRegions({ client })),
423
- // ─── API keys ────────────────────────────────────────────────────────
424
- // Account keys reach everything the account can. Org keys can additionally be
425
- // narrowed to a single project via `project_id`, which is the only way to mint a
426
- // least-privilege credential — so the org endpoints are not merely the org
427
- // equivalent of the account ones.
428
- listApiKeys: () => call(() => raw.listApiKeys({ client })),
429
- createApiKey: (body) => call(() => raw.createApiKey({ client, body })),
430
- revokeApiKey: (keyId) => call(() => raw.revokeApiKey({ client, path: { key_id: keyId } })),
431
- listOrgApiKeys: (orgId) => call(() => raw.listOrgApiKeys({ client, path: { org_id: orgId } })),
432
- createOrgApiKey: (orgId, body) => call(() => raw.createOrgApiKey({ client, path: { org_id: orgId }, body })),
433
- revokeOrgApiKey: (orgId, keyId) => call(() => raw.revokeOrgApiKey({
434
- client,
435
- path: { org_id: orgId, key_id: keyId },
436
- })),
437
- // ─── Projects ────────────────────────────────────────────────────────
438
- listProjects: (query = {}) => call(() => raw.listProjects({ client, query })),
439
- listSharedProjects: (query = {}) => call(() => raw.listSharedProjects({
440
- client,
441
- query: {
442
- ...(query.cursor !== undefined
443
- ? { cursor: query.cursor }
444
- : {}),
445
- ...(query.limit !== undefined
446
- ? { limit: query.limit }
447
- : {}),
448
- ...(query.search !== undefined
449
- ? { search: query.search }
450
- : {}),
451
- },
452
- })),
453
- getProject: (projectId) => call(() => raw.getProject({ client, path: { project_id: projectId } })),
454
- createProject: (data) => call(() => raw.createProject({ client, body: data })),
455
- updateProject: (projectId, data) => call(() => raw.updateProject({
456
- client,
457
- path: { project_id: projectId },
458
- body: data,
459
- })),
460
- deleteProject: (projectId) => call(() => raw.deleteProject({ client, path: { project_id: projectId } })),
461
- recoverProject: (projectId) => call(() => raw.recoverProject({ client, path: { project_id: projectId } })),
462
- listProjectOperations: ({ projectId, ...query }) => call(() => raw.listProjectOperations({
463
- client,
464
- path: { project_id: projectId },
465
- query,
466
- })),
467
- // ─── Branches ────────────────────────────────────────────────────────
468
- listProjectBranches: ({ projectId, ...query }) => call(() => raw.listProjectBranches({
469
- client,
470
- path: { project_id: projectId },
471
- query,
472
- })),
473
- createProjectBranch: (projectId, data) => call(() => raw.createProjectBranch({
474
- client,
475
- path: { project_id: projectId },
476
- ...(data !== undefined ? { body: data } : {}),
477
- })),
478
- getProjectBranch: (projectId, branchId) => call(() => raw.getProjectBranch({
479
- client,
480
- path: { project_id: projectId, branch_id: branchId },
481
- })),
482
- updateProjectBranch: (projectId, branchId, data) => call(() => raw.updateProjectBranch({
483
- client,
484
- path: { project_id: projectId, branch_id: branchId },
485
- body: data,
486
- })),
487
- deleteProjectBranch: (projectId, branchId) => call(() => raw.deleteProjectBranch({
488
- client,
489
- path: { project_id: projectId, branch_id: branchId },
490
- })),
491
- restoreProjectBranch: (projectId, branchId, data) => call(() => raw.restoreProjectBranch({
492
- client,
493
- path: { project_id: projectId, branch_id: branchId },
494
- body: data,
495
- })),
496
- setDefaultProjectBranch: (projectId, branchId) => call(() => raw.setDefaultProjectBranch({
497
- client,
498
- path: { project_id: projectId, branch_id: branchId },
499
- })),
500
- getProjectBranchSchema: ({ projectId, branchId, ...query }) => call(() => raw.getProjectBranchSchema({
501
- client,
502
- path: { project_id: projectId, branch_id: branchId },
503
- query,
504
- })),
505
- listProjectBranchEndpoints: (projectId, branchId) => call(() => raw.listProjectBranchEndpoints({
506
- client,
507
- path: { project_id: projectId, branch_id: branchId },
508
- })),
509
- createProjectEndpoint: (projectId, data) => call(() => raw.createProjectEndpoint({
510
- client,
511
- path: { project_id: projectId },
512
- body: data,
513
- })),
514
- // ─── Snapshots ───────────────────────────────────────────────────────
515
- listSnapshots: (projectId) => call(() => raw.listSnapshots({
516
- client,
517
- path: { project_id: projectId },
518
- })),
519
- createSnapshot: (projectId, branchId, query) => call(() => raw.createSnapshot({
520
- client,
521
- path: { project_id: projectId, branch_id: branchId },
522
- ...(query !== undefined ? { query } : {}),
523
- })),
524
- updateSnapshot: (projectId, snapshotId, data) => call(() => raw.updateSnapshot({
525
- client,
526
- path: { project_id: projectId, snapshot_id: snapshotId },
527
- body: data,
528
- })),
529
- deleteSnapshot: (projectId, snapshotId) => call(() => raw.deleteSnapshot({
530
- client,
531
- path: { project_id: projectId, snapshot_id: snapshotId },
532
- })),
533
- restoreSnapshot: (projectId, snapshotId, data) => call(() => raw.restoreSnapshot({
534
- client,
535
- path: { project_id: projectId, snapshot_id: snapshotId },
536
- ...(data !== undefined ? { body: data } : {}),
537
- })),
538
- finalizeRestoreBranch: (projectId, branchId, data) => call(() => raw.finalizeRestoreBranch({
539
- client,
540
- path: { project_id: projectId, branch_id: branchId },
541
- ...(data !== undefined ? { body: data } : {}),
542
- })),
543
- getSnapshotSchedule: (projectId, branchId) => call(() => raw.getSnapshotSchedule({
544
- client,
545
- path: { project_id: projectId, branch_id: branchId },
546
- })),
547
- setSnapshotSchedule: (projectId, branchId, data) => call(() => raw.setSnapshotSchedule({
548
- client,
549
- path: { project_id: projectId, branch_id: branchId },
550
- body: data,
551
- })),
552
- // ─── Databases ───────────────────────────────────────────────────────
553
- listProjectBranchDatabases: (projectId, branchId) => call(() => raw.listProjectBranchDatabases({
554
- client,
555
- path: { project_id: projectId, branch_id: branchId },
556
- })),
557
- createProjectBranchDatabase: (projectId, branchId, data) => call(() => raw.createProjectBranchDatabase({
558
- client,
559
- path: { project_id: projectId, branch_id: branchId },
560
- body: data,
561
- })),
562
- deleteProjectBranchDatabase: (projectId, branchId, databaseName) => call(() => raw.deleteProjectBranchDatabase({
563
- client,
564
- path: {
565
- project_id: projectId,
566
- branch_id: branchId,
567
- database_name: databaseName,
568
- },
569
- })),
570
- // ─── Roles ───────────────────────────────────────────────────────────
571
- listProjectBranchRoles: (projectId, branchId) => call(() => raw.listProjectBranchRoles({
572
- client,
573
- path: { project_id: projectId, branch_id: branchId },
574
- })),
575
- createProjectBranchRole: (projectId, branchId, data) => call(() => raw.createProjectBranchRole({
576
- client,
577
- path: { project_id: projectId, branch_id: branchId },
578
- body: data,
579
- })),
580
- deleteProjectBranchRole: (projectId, branchId, roleName) => call(() => raw.deleteProjectBranchRole({
581
- client,
582
- path: {
583
- project_id: projectId,
584
- branch_id: branchId,
585
- role_name: roleName,
586
- },
587
- })),
588
- getProjectBranchRolePassword: (projectId, branchId, roleName) => call(() => raw.getProjectBranchRolePassword({
589
- client,
590
- path: {
591
- project_id: projectId,
592
- branch_id: branchId,
593
- role_name: roleName,
594
- },
595
- })),
596
- // ─── Data API ────────────────────────────────────────────────────────
597
- createProjectBranchDataApi: (projectId, branchId, databaseName, data) => call(() => raw.createProjectBranchDataApi({
598
- client,
599
- path: {
600
- project_id: projectId,
601
- branch_id: branchId,
602
- database_name: databaseName,
603
- },
604
- body: data,
605
- })),
606
- updateProjectBranchDataApi: (projectId, branchId, databaseName, data) => call(() => raw.updateProjectBranchDataApi({
607
- client,
608
- path: {
609
- project_id: projectId,
610
- branch_id: branchId,
611
- database_name: databaseName,
612
- },
613
- body: data,
614
- })),
615
- deleteProjectBranchDataApi: (projectId, branchId, databaseName) => call(() => raw.deleteProjectBranchDataApi({
616
- client,
617
- path: {
618
- project_id: projectId,
619
- branch_id: branchId,
620
- database_name: databaseName,
621
- },
622
- })),
623
- getProjectBranchDataApi: (projectId, branchId, databaseName) => call(() => raw.getProjectBranchDataApi({
624
- client,
625
- path: {
626
- project_id: projectId,
627
- branch_id: branchId,
628
- database_name: databaseName,
629
- },
630
- })),
631
- // ─── VPC endpoints (project + organization) ──────────────────────────
632
- listProjectVpcEndpoints: (projectId) => call(() => raw.listProjectVpcEndpoints({
633
- client,
634
- path: { project_id: projectId },
635
- })),
636
- assignProjectVpcEndpoint: (projectId, vpcEndpointId, data) => call(() => raw.assignProjectVpcEndpoint({
637
- client,
638
- path: {
639
- project_id: projectId,
640
- vpc_endpoint_id: vpcEndpointId,
641
- },
642
- body: data,
643
- })),
644
- deleteProjectVpcEndpoint: (projectId, vpcEndpointId) => call(() => raw.deleteProjectVpcEndpoint({
645
- client,
646
- path: {
647
- project_id: projectId,
648
- vpc_endpoint_id: vpcEndpointId,
649
- },
650
- })),
651
- listOrganizationVpcEndpoints: (orgId, regionId) => call(() => raw.listOrganizationVpcEndpoints({
652
- client,
653
- path: { org_id: orgId, region_id: regionId },
654
- })),
655
- getOrganizationVpcEndpointDetails: (orgId, regionId, vpcEndpointId) => call(() => raw.getOrganizationVpcEndpointDetails({
656
- client,
657
- path: {
658
- org_id: orgId,
659
- region_id: regionId,
660
- vpc_endpoint_id: vpcEndpointId,
661
- },
662
- })),
663
- assignOrganizationVpcEndpoint: (orgId, regionId, vpcEndpointId, data) => call(() => raw.assignOrganizationVpcEndpoint({
664
- client,
665
- path: {
666
- org_id: orgId,
667
- region_id: regionId,
668
- vpc_endpoint_id: vpcEndpointId,
669
- },
670
- body: data,
671
- })),
672
- deleteOrganizationVpcEndpoint: (orgId, regionId, vpcEndpointId) => call(() => raw.deleteOrganizationVpcEndpoint({
673
- client,
674
- path: {
675
- org_id: orgId,
676
- region_id: regionId,
677
- vpc_endpoint_id: vpcEndpointId,
678
- },
679
- })),
680
- // ─── Neon Auth ───────────────────────────────────────────────────────
681
- getNeonAuth: (projectId, branchId) => call(() => raw.getNeonAuth({
682
- client,
683
- path: { project_id: projectId, branch_id: branchId },
684
- })),
685
- createNeonAuth: (projectId, branchId, data) => call(() => raw.createNeonAuth({
686
- client,
687
- path: { project_id: projectId, branch_id: branchId },
688
- body: data,
689
- })),
690
- disableNeonAuth: (projectId, branchId, data) => call(() => raw.disableNeonAuth({
691
- client,
692
- path: { project_id: projectId, branch_id: branchId },
693
- body: data,
694
- })),
695
- listBranchNeonAuthOauthProviders: (projectId, branchId) => call(() => raw.listBranchNeonAuthOauthProviders({
696
- client,
697
- path: { project_id: projectId, branch_id: branchId },
698
- })),
699
- addBranchNeonAuthOauthProvider: (projectId, branchId, data) => call(() => raw.addBranchNeonAuthOauthProvider({
700
- client,
701
- path: { project_id: projectId, branch_id: branchId },
702
- body: data,
703
- })),
704
- updateBranchNeonAuthOauthProvider: (projectId, branchId, oauthProviderId, data) => call(() => raw.updateBranchNeonAuthOauthProvider({
705
- client,
706
- path: {
707
- project_id: projectId,
708
- branch_id: branchId,
709
- oauth_provider_id: oauthProviderId,
710
- },
711
- body: data,
712
- })),
713
- deleteBranchNeonAuthOauthProvider: (projectId, branchId, oauthProviderId) => call(() => raw.deleteBranchNeonAuthOauthProvider({
714
- client,
715
- path: {
716
- project_id: projectId,
717
- branch_id: branchId,
718
- oauth_provider_id: oauthProviderId,
719
- },
720
- })),
721
- listBranchNeonAuthTrustedDomains: (projectId, branchId) => call(() => raw.listBranchNeonAuthTrustedDomains({
722
- client,
723
- path: { project_id: projectId, branch_id: branchId },
724
- })),
725
- addBranchNeonAuthTrustedDomain: (projectId, branchId, data) => call(() => raw.addBranchNeonAuthTrustedDomain({
726
- client,
727
- path: { project_id: projectId, branch_id: branchId },
728
- body: data,
729
- })),
730
- deleteBranchNeonAuthTrustedDomain: (projectId, branchId, data) => call(() => raw.deleteBranchNeonAuthTrustedDomain({
731
- client,
732
- path: { project_id: projectId, branch_id: branchId },
733
- body: data,
734
- })),
735
- getNeonAuthAllowLocalhost: (projectId, branchId) => call(() => raw.getNeonAuthAllowLocalhost({
736
- client,
737
- path: { project_id: projectId, branch_id: branchId },
738
- })),
739
- updateNeonAuthAllowLocalhost: (projectId, branchId, data) => call(() => raw.updateNeonAuthAllowLocalhost({
740
- client,
741
- path: { project_id: projectId, branch_id: branchId },
742
- body: data,
743
- })),
744
- getNeonAuthEmailAndPasswordConfig: (projectId, branchId) => call(() => raw.getNeonAuthEmailAndPasswordConfig({
745
- client,
746
- path: { project_id: projectId, branch_id: branchId },
747
- })),
748
- updateNeonAuthEmailAndPasswordConfig: (projectId, branchId, data) => call(() => raw.updateNeonAuthEmailAndPasswordConfig({
749
- client,
750
- path: { project_id: projectId, branch_id: branchId },
751
- body: data,
752
- })),
753
- getNeonAuthEmailProvider: (projectId, branchId) => call(() => raw.getNeonAuthEmailProvider({
754
- client,
755
- path: { project_id: projectId, branch_id: branchId },
756
- })),
757
- updateNeonAuthEmailProvider: (projectId, branchId, data) => call(() => raw.updateNeonAuthEmailProvider({
758
- client,
759
- path: { project_id: projectId, branch_id: branchId },
760
- body: data,
761
- })),
762
- sendNeonAuthTestEmail: (projectId, branchId, data) => call(() => raw.sendNeonAuthTestEmail({
763
- client,
764
- path: { project_id: projectId, branch_id: branchId },
765
- body: data,
766
- })),
767
- getNeonAuthPluginConfigs: (projectId, branchId) => call(() => raw.getNeonAuthPluginConfigs({
768
- client,
769
- path: { project_id: projectId, branch_id: branchId },
770
- })),
771
- updateNeonAuthOrganizationPlugin: (projectId, branchId, data) => call(() => raw.updateNeonAuthOrganizationPlugin({
772
- client,
773
- path: { project_id: projectId, branch_id: branchId },
774
- body: data,
775
- })),
776
- getNeonAuthWebhookConfig: (projectId, branchId) => call(() => raw.getNeonAuthWebhookConfig({
777
- client,
778
- path: { project_id: projectId, branch_id: branchId },
779
- })),
780
- updateNeonAuthWebhookConfig: (projectId, branchId, data) => call(() => raw.updateNeonAuthWebhookConfig({
781
- client,
782
- path: { project_id: projectId, branch_id: branchId },
783
- body: data,
784
- })),
785
- createBranchNeonAuthNewUser: (projectId, branchId, data) => call(() => raw.createBranchNeonAuthNewUser({
786
- client,
787
- path: { project_id: projectId, branch_id: branchId },
788
- body: data,
789
- })),
790
- deleteBranchNeonAuthUser: (projectId, branchId, authUserId) => call(() => raw.deleteBranchNeonAuthUser({
791
- client,
792
- path: {
793
- project_id: projectId,
794
- branch_id: branchId,
795
- auth_user_id: authUserId,
796
- },
797
- })),
798
- updateNeonAuthUserRole: (projectId, branchId, authUserId, data) => call(() => raw.updateNeonAuthUserRole({
799
- client,
800
- path: {
801
- project_id: projectId,
802
- branch_id: branchId,
803
- auth_user_id: authUserId,
804
- },
805
- body: data,
806
- })),
807
- };
251
+ const getApiClient = ({ apiKey, apiHost, requestTimeoutMs = REQUEST_TIMEOUT_MS }) => {
252
+ const baseUrl = apiHost ?? DEFAULT_API_HOST;
253
+ const fetchWithTimeout = makeTimedFetch(validateRequestTimeout(requestTimeoutMs));
254
+ const client = createClient(createConfig({
255
+ auth: () => apiKey,
256
+ baseUrl,
257
+ fetch: fetchWithTimeout,
258
+ headers: { "User-Agent": USER_AGENT }
259
+ }));
260
+ /** Await a raw call, unwrap to a `{ data, status, headers }` envelope, or throw {@link NeonApiError}. */
261
+ async function call(run) {
262
+ let result;
263
+ try {
264
+ result = await run();
265
+ } catch (err) {
266
+ throw networkError(err);
267
+ }
268
+ const response = result.response;
269
+ if (!response) throw networkError(result.error ?? /* @__PURE__ */ new Error("No response from Neon API"));
270
+ if (!response.ok) throw httpError(response, rawErrorBody(result.error) ?? result.data);
271
+ return {
272
+ data: result.data,
273
+ status: response.status,
274
+ statusText: response.statusText,
275
+ headers: headersToObject(response.headers)
276
+ };
277
+ }
278
+ /**
279
+ * Low-level request used by the object-storage and functions helpers for
280
+ * endpoints not (yet) modeled as typed SDK functions. Mirrors the api-client
281
+ * `HttpClient.request()`: `format: 'json'` parses the body, `format: 'stream'`
282
+ * returns a Node `Readable`, and `type: ContentType.FormData` sends multipart.
283
+ */
284
+ async function request(params) {
285
+ const url = buildUrl(baseUrl, params.path, params.query);
286
+ const headers = { "User-Agent": USER_AGENT };
287
+ if (params.secure !== false) headers.Authorization = `Bearer ${apiKey}`;
288
+ let payload;
289
+ if (params.body instanceof FormData || params.type === "multipart/form-data") payload = params.body;
290
+ else if (params.body !== void 0) {
291
+ headers["Content-Type"] = "application/json";
292
+ payload = JSON.stringify(params.body);
293
+ }
294
+ if (params.headers) for (const [key, value] of Object.entries(params.headers)) headers[key] = value;
295
+ let response;
296
+ try {
297
+ response = await fetchWithTimeout(url, {
298
+ method: params.method,
299
+ headers,
300
+ ...payload !== void 0 ? { body: payload } : {}
301
+ });
302
+ } catch (err) {
303
+ throw networkError(err);
304
+ }
305
+ if (!response.ok) {
306
+ const errorBody = params.format === "stream" && response.body ? webStreamToNodeReadable(response.body) : await readJsonBody(response);
307
+ throw httpError(response, errorBody);
308
+ }
309
+ let data;
310
+ if (params.format === "stream") data = response.body ? webStreamToNodeReadable(response.body) : void 0;
311
+ else data = await readJsonBody(response);
312
+ return {
313
+ data,
314
+ status: response.status,
315
+ statusText: response.statusText,
316
+ headers: headersToObject(response.headers)
317
+ };
318
+ }
319
+ return {
320
+ request,
321
+ getCurrentUserInfo: () => call(() => raw.getCurrentUserInfo({ client })),
322
+ getCurrentUserOrganizations: () => call(() => raw.getCurrentUserOrganizations({ client })),
323
+ getAuthDetails: () => call(() => raw.getAuthDetails({ client })),
324
+ getActiveRegions: () => call(() => raw.getActiveRegions({ client })),
325
+ listApiKeys: () => call(() => raw.listApiKeys({ client })),
326
+ createApiKey: (body) => call(() => raw.createApiKey({
327
+ client,
328
+ body
329
+ })),
330
+ revokeApiKey: (keyId) => call(() => raw.revokeApiKey({
331
+ client,
332
+ path: { key_id: keyId }
333
+ })),
334
+ listOrgApiKeys: (orgId) => call(() => raw.listOrgApiKeys({
335
+ client,
336
+ path: { org_id: orgId }
337
+ })),
338
+ createOrgApiKey: (orgId, body) => call(() => raw.createOrgApiKey({
339
+ client,
340
+ path: { org_id: orgId },
341
+ body
342
+ })),
343
+ revokeOrgApiKey: (orgId, keyId) => call(() => raw.revokeOrgApiKey({
344
+ client,
345
+ path: {
346
+ org_id: orgId,
347
+ key_id: keyId
348
+ }
349
+ })),
350
+ listProjects: (query = {}) => call(() => raw.listProjects({
351
+ client,
352
+ query
353
+ })),
354
+ listSharedProjects: (query = {}) => call(() => raw.listSharedProjects({
355
+ client,
356
+ query: {
357
+ ...query.cursor !== void 0 ? { cursor: query.cursor } : {},
358
+ ...query.limit !== void 0 ? { limit: query.limit } : {},
359
+ ...query.search !== void 0 ? { search: query.search } : {}
360
+ }
361
+ })),
362
+ getProject: (projectId) => call(() => raw.getProject({
363
+ client,
364
+ path: { project_id: projectId }
365
+ })),
366
+ createProject: (data) => call(() => raw.createProject({
367
+ client,
368
+ body: data
369
+ })),
370
+ updateProject: (projectId, data) => call(() => raw.updateProject({
371
+ client,
372
+ path: { project_id: projectId },
373
+ body: data
374
+ })),
375
+ deleteProject: (projectId) => call(() => raw.deleteProject({
376
+ client,
377
+ path: { project_id: projectId }
378
+ })),
379
+ recoverProject: (projectId) => call(() => raw.recoverProject({
380
+ client,
381
+ path: { project_id: projectId }
382
+ })),
383
+ listProjectOperations: ({ projectId, ...query }) => call(() => raw.listProjectOperations({
384
+ client,
385
+ path: { project_id: projectId },
386
+ query
387
+ })),
388
+ listProjectBranches: ({ projectId, ...query }) => call(() => raw.listProjectBranches({
389
+ client,
390
+ path: { project_id: projectId },
391
+ query
392
+ })),
393
+ createProjectBranch: (projectId, data) => call(() => raw.createProjectBranch({
394
+ client,
395
+ path: { project_id: projectId },
396
+ ...data !== void 0 ? { body: data } : {}
397
+ })),
398
+ getProjectBranch: (projectId, branchId) => call(() => raw.getProjectBranch({
399
+ client,
400
+ path: {
401
+ project_id: projectId,
402
+ branch_id: branchId
403
+ }
404
+ })),
405
+ updateProjectBranch: (projectId, branchId, data) => call(() => raw.updateProjectBranch({
406
+ client,
407
+ path: {
408
+ project_id: projectId,
409
+ branch_id: branchId
410
+ },
411
+ body: data
412
+ })),
413
+ deleteProjectBranch: (projectId, branchId) => call(() => raw.deleteProjectBranch({
414
+ client,
415
+ path: {
416
+ project_id: projectId,
417
+ branch_id: branchId
418
+ }
419
+ })),
420
+ restoreProjectBranch: (projectId, branchId, data) => call(() => raw.restoreProjectBranch({
421
+ client,
422
+ path: {
423
+ project_id: projectId,
424
+ branch_id: branchId
425
+ },
426
+ body: data
427
+ })),
428
+ setDefaultProjectBranch: (projectId, branchId) => call(() => raw.setDefaultProjectBranch({
429
+ client,
430
+ path: {
431
+ project_id: projectId,
432
+ branch_id: branchId
433
+ }
434
+ })),
435
+ getProjectBranchSchema: ({ projectId, branchId, ...query }) => call(() => raw.getProjectBranchSchema({
436
+ client,
437
+ path: {
438
+ project_id: projectId,
439
+ branch_id: branchId
440
+ },
441
+ query
442
+ })),
443
+ listProjectBranchEndpoints: (projectId, branchId) => call(() => raw.listProjectBranchEndpoints({
444
+ client,
445
+ path: {
446
+ project_id: projectId,
447
+ branch_id: branchId
448
+ }
449
+ })),
450
+ createProjectEndpoint: (projectId, data) => call(() => raw.createProjectEndpoint({
451
+ client,
452
+ path: { project_id: projectId },
453
+ body: data
454
+ })),
455
+ listSnapshots: (projectId) => call(() => raw.listSnapshots({
456
+ client,
457
+ path: { project_id: projectId }
458
+ })),
459
+ createSnapshot: (projectId, branchId, query) => call(() => raw.createSnapshot({
460
+ client,
461
+ path: {
462
+ project_id: projectId,
463
+ branch_id: branchId
464
+ },
465
+ ...query !== void 0 ? { query } : {}
466
+ })),
467
+ updateSnapshot: (projectId, snapshotId, data) => call(() => raw.updateSnapshot({
468
+ client,
469
+ path: {
470
+ project_id: projectId,
471
+ snapshot_id: snapshotId
472
+ },
473
+ body: data
474
+ })),
475
+ deleteSnapshot: (projectId, snapshotId) => call(() => raw.deleteSnapshot({
476
+ client,
477
+ path: {
478
+ project_id: projectId,
479
+ snapshot_id: snapshotId
480
+ }
481
+ })),
482
+ restoreSnapshot: (projectId, snapshotId, data) => call(() => raw.restoreSnapshot({
483
+ client,
484
+ path: {
485
+ project_id: projectId,
486
+ snapshot_id: snapshotId
487
+ },
488
+ ...data !== void 0 ? { body: data } : {}
489
+ })),
490
+ finalizeRestoreBranch: (projectId, branchId, data) => call(() => raw.finalizeRestoreBranch({
491
+ client,
492
+ path: {
493
+ project_id: projectId,
494
+ branch_id: branchId
495
+ },
496
+ ...data !== void 0 ? { body: data } : {}
497
+ })),
498
+ getSnapshotSchedule: (projectId, branchId) => call(() => raw.getSnapshotSchedule({
499
+ client,
500
+ path: {
501
+ project_id: projectId,
502
+ branch_id: branchId
503
+ }
504
+ })),
505
+ setSnapshotSchedule: (projectId, branchId, data) => call(() => raw.setSnapshotSchedule({
506
+ client,
507
+ path: {
508
+ project_id: projectId,
509
+ branch_id: branchId
510
+ },
511
+ body: data
512
+ })),
513
+ listProjectBranchDatabases: (projectId, branchId) => call(() => raw.listProjectBranchDatabases({
514
+ client,
515
+ path: {
516
+ project_id: projectId,
517
+ branch_id: branchId
518
+ }
519
+ })),
520
+ createProjectBranchDatabase: (projectId, branchId, data) => call(() => raw.createProjectBranchDatabase({
521
+ client,
522
+ path: {
523
+ project_id: projectId,
524
+ branch_id: branchId
525
+ },
526
+ body: data
527
+ })),
528
+ deleteProjectBranchDatabase: (projectId, branchId, databaseName) => call(() => raw.deleteProjectBranchDatabase({
529
+ client,
530
+ path: {
531
+ project_id: projectId,
532
+ branch_id: branchId,
533
+ database_name: databaseName
534
+ }
535
+ })),
536
+ listProjectBranchRoles: (projectId, branchId) => call(() => raw.listProjectBranchRoles({
537
+ client,
538
+ path: {
539
+ project_id: projectId,
540
+ branch_id: branchId
541
+ }
542
+ })),
543
+ createProjectBranchRole: (projectId, branchId, data) => call(() => raw.createProjectBranchRole({
544
+ client,
545
+ path: {
546
+ project_id: projectId,
547
+ branch_id: branchId
548
+ },
549
+ body: data
550
+ })),
551
+ deleteProjectBranchRole: (projectId, branchId, roleName) => call(() => raw.deleteProjectBranchRole({
552
+ client,
553
+ path: {
554
+ project_id: projectId,
555
+ branch_id: branchId,
556
+ role_name: roleName
557
+ }
558
+ })),
559
+ getProjectBranchRolePassword: (projectId, branchId, roleName) => call(() => raw.getProjectBranchRolePassword({
560
+ client,
561
+ path: {
562
+ project_id: projectId,
563
+ branch_id: branchId,
564
+ role_name: roleName
565
+ }
566
+ })),
567
+ queryProjectBranchLogs: (projectId, branchId, data) => call(() => raw.queryProjectBranchLogs({
568
+ client,
569
+ path: {
570
+ project_id: projectId,
571
+ branch_id: branchId
572
+ },
573
+ body: data
574
+ })),
575
+ listProjectBranchLogFields: (projectId, branchId) => call(() => raw.listProjectBranchLogFields({
576
+ client,
577
+ path: {
578
+ project_id: projectId,
579
+ branch_id: branchId
580
+ }
581
+ })),
582
+ listProjectBranchLogFieldValues: ({ projectId, branchId, fieldName, ...query }) => call(() => raw.listProjectBranchLogFieldValues({
583
+ client,
584
+ path: {
585
+ project_id: projectId,
586
+ branch_id: branchId,
587
+ field_name: fieldName
588
+ },
589
+ query
590
+ })),
591
+ createProjectBranchDataApi: (projectId, branchId, databaseName, data) => call(() => raw.createProjectBranchDataApi({
592
+ client,
593
+ path: {
594
+ project_id: projectId,
595
+ branch_id: branchId,
596
+ database_name: databaseName
597
+ },
598
+ body: data
599
+ })),
600
+ updateProjectBranchDataApi: (projectId, branchId, databaseName, data) => call(() => raw.updateProjectBranchDataApi({
601
+ client,
602
+ path: {
603
+ project_id: projectId,
604
+ branch_id: branchId,
605
+ database_name: databaseName
606
+ },
607
+ body: data
608
+ })),
609
+ deleteProjectBranchDataApi: (projectId, branchId, databaseName) => call(() => raw.deleteProjectBranchDataApi({
610
+ client,
611
+ path: {
612
+ project_id: projectId,
613
+ branch_id: branchId,
614
+ database_name: databaseName
615
+ }
616
+ })),
617
+ getProjectBranchDataApi: (projectId, branchId, databaseName) => call(() => raw.getProjectBranchDataApi({
618
+ client,
619
+ path: {
620
+ project_id: projectId,
621
+ branch_id: branchId,
622
+ database_name: databaseName
623
+ }
624
+ })),
625
+ listProjectVpcEndpoints: (projectId) => call(() => raw.listProjectVpcEndpoints({
626
+ client,
627
+ path: { project_id: projectId }
628
+ })),
629
+ assignProjectVpcEndpoint: (projectId, vpcEndpointId, data) => call(() => raw.assignProjectVpcEndpoint({
630
+ client,
631
+ path: {
632
+ project_id: projectId,
633
+ vpc_endpoint_id: vpcEndpointId
634
+ },
635
+ body: data
636
+ })),
637
+ deleteProjectVpcEndpoint: (projectId, vpcEndpointId) => call(() => raw.deleteProjectVpcEndpoint({
638
+ client,
639
+ path: {
640
+ project_id: projectId,
641
+ vpc_endpoint_id: vpcEndpointId
642
+ }
643
+ })),
644
+ listOrganizationVpcEndpoints: (orgId, regionId) => call(() => raw.listOrganizationVpcEndpoints({
645
+ client,
646
+ path: {
647
+ org_id: orgId,
648
+ region_id: regionId
649
+ }
650
+ })),
651
+ getOrganizationVpcEndpointDetails: (orgId, regionId, vpcEndpointId) => call(() => raw.getOrganizationVpcEndpointDetails({
652
+ client,
653
+ path: {
654
+ org_id: orgId,
655
+ region_id: regionId,
656
+ vpc_endpoint_id: vpcEndpointId
657
+ }
658
+ })),
659
+ assignOrganizationVpcEndpoint: (orgId, regionId, vpcEndpointId, data) => call(() => raw.assignOrganizationVpcEndpoint({
660
+ client,
661
+ path: {
662
+ org_id: orgId,
663
+ region_id: regionId,
664
+ vpc_endpoint_id: vpcEndpointId
665
+ },
666
+ body: data
667
+ })),
668
+ deleteOrganizationVpcEndpoint: (orgId, regionId, vpcEndpointId) => call(() => raw.deleteOrganizationVpcEndpoint({
669
+ client,
670
+ path: {
671
+ org_id: orgId,
672
+ region_id: regionId,
673
+ vpc_endpoint_id: vpcEndpointId
674
+ }
675
+ })),
676
+ getNeonAuth: (projectId, branchId) => call(() => raw.getNeonAuth({
677
+ client,
678
+ path: {
679
+ project_id: projectId,
680
+ branch_id: branchId
681
+ }
682
+ })),
683
+ createNeonAuth: (projectId, branchId, data) => call(() => raw.createNeonAuth({
684
+ client,
685
+ path: {
686
+ project_id: projectId,
687
+ branch_id: branchId
688
+ },
689
+ body: data
690
+ })),
691
+ disableNeonAuth: (projectId, branchId, data) => call(() => raw.disableNeonAuth({
692
+ client,
693
+ path: {
694
+ project_id: projectId,
695
+ branch_id: branchId
696
+ },
697
+ body: data
698
+ })),
699
+ listBranchNeonAuthOauthProviders: (projectId, branchId) => call(() => raw.listBranchNeonAuthOauthProviders({
700
+ client,
701
+ path: {
702
+ project_id: projectId,
703
+ branch_id: branchId
704
+ }
705
+ })),
706
+ addBranchNeonAuthOauthProvider: (projectId, branchId, data) => call(() => raw.addBranchNeonAuthOauthProvider({
707
+ client,
708
+ path: {
709
+ project_id: projectId,
710
+ branch_id: branchId
711
+ },
712
+ body: data
713
+ })),
714
+ updateBranchNeonAuthOauthProvider: (projectId, branchId, oauthProviderId, data) => call(() => raw.updateBranchNeonAuthOauthProvider({
715
+ client,
716
+ path: {
717
+ project_id: projectId,
718
+ branch_id: branchId,
719
+ oauth_provider_id: oauthProviderId
720
+ },
721
+ body: data
722
+ })),
723
+ deleteBranchNeonAuthOauthProvider: (projectId, branchId, oauthProviderId) => call(() => raw.deleteBranchNeonAuthOauthProvider({
724
+ client,
725
+ path: {
726
+ project_id: projectId,
727
+ branch_id: branchId,
728
+ oauth_provider_id: oauthProviderId
729
+ }
730
+ })),
731
+ listBranchNeonAuthTrustedDomains: (projectId, branchId) => call(() => raw.listBranchNeonAuthTrustedDomains({
732
+ client,
733
+ path: {
734
+ project_id: projectId,
735
+ branch_id: branchId
736
+ }
737
+ })),
738
+ addBranchNeonAuthTrustedDomain: (projectId, branchId, data) => call(() => raw.addBranchNeonAuthTrustedDomain({
739
+ client,
740
+ path: {
741
+ project_id: projectId,
742
+ branch_id: branchId
743
+ },
744
+ body: data
745
+ })),
746
+ deleteBranchNeonAuthTrustedDomain: (projectId, branchId, data) => call(() => raw.deleteBranchNeonAuthTrustedDomain({
747
+ client,
748
+ path: {
749
+ project_id: projectId,
750
+ branch_id: branchId
751
+ },
752
+ body: data
753
+ })),
754
+ getNeonAuthAllowLocalhost: (projectId, branchId) => call(() => raw.getNeonAuthAllowLocalhost({
755
+ client,
756
+ path: {
757
+ project_id: projectId,
758
+ branch_id: branchId
759
+ }
760
+ })),
761
+ updateNeonAuthAllowLocalhost: (projectId, branchId, data) => call(() => raw.updateNeonAuthAllowLocalhost({
762
+ client,
763
+ path: {
764
+ project_id: projectId,
765
+ branch_id: branchId
766
+ },
767
+ body: data
768
+ })),
769
+ getNeonAuthEmailAndPasswordConfig: (projectId, branchId) => call(() => raw.getNeonAuthEmailAndPasswordConfig({
770
+ client,
771
+ path: {
772
+ project_id: projectId,
773
+ branch_id: branchId
774
+ }
775
+ })),
776
+ updateNeonAuthEmailAndPasswordConfig: (projectId, branchId, data) => call(() => raw.updateNeonAuthEmailAndPasswordConfig({
777
+ client,
778
+ path: {
779
+ project_id: projectId,
780
+ branch_id: branchId
781
+ },
782
+ body: data
783
+ })),
784
+ getNeonAuthEmailProvider: (projectId, branchId) => call(() => raw.getNeonAuthEmailProvider({
785
+ client,
786
+ path: {
787
+ project_id: projectId,
788
+ branch_id: branchId
789
+ }
790
+ })),
791
+ updateNeonAuthEmailProvider: (projectId, branchId, data) => call(() => raw.updateNeonAuthEmailProvider({
792
+ client,
793
+ path: {
794
+ project_id: projectId,
795
+ branch_id: branchId
796
+ },
797
+ body: data
798
+ })),
799
+ sendNeonAuthTestEmail: (projectId, branchId, data) => call(() => raw.sendNeonAuthTestEmail({
800
+ client,
801
+ path: {
802
+ project_id: projectId,
803
+ branch_id: branchId
804
+ },
805
+ body: data
806
+ })),
807
+ getNeonAuthPluginConfigs: (projectId, branchId) => call(() => raw.getNeonAuthPluginConfigs({
808
+ client,
809
+ path: {
810
+ project_id: projectId,
811
+ branch_id: branchId
812
+ }
813
+ })),
814
+ updateNeonAuthOrganizationPlugin: (projectId, branchId, data) => call(() => raw.updateNeonAuthOrganizationPlugin({
815
+ client,
816
+ path: {
817
+ project_id: projectId,
818
+ branch_id: branchId
819
+ },
820
+ body: data
821
+ })),
822
+ getNeonAuthWebhookConfig: (projectId, branchId) => call(() => raw.getNeonAuthWebhookConfig({
823
+ client,
824
+ path: {
825
+ project_id: projectId,
826
+ branch_id: branchId
827
+ }
828
+ })),
829
+ updateNeonAuthWebhookConfig: (projectId, branchId, data) => call(() => raw.updateNeonAuthWebhookConfig({
830
+ client,
831
+ path: {
832
+ project_id: projectId,
833
+ branch_id: branchId
834
+ },
835
+ body: data
836
+ })),
837
+ createBranchNeonAuthNewUser: (projectId, branchId, data) => call(() => raw.createBranchNeonAuthNewUser({
838
+ client,
839
+ path: {
840
+ project_id: projectId,
841
+ branch_id: branchId
842
+ },
843
+ body: data
844
+ })),
845
+ deleteBranchNeonAuthUser: (projectId, branchId, authUserId) => call(() => raw.deleteBranchNeonAuthUser({
846
+ client,
847
+ path: {
848
+ project_id: projectId,
849
+ branch_id: branchId,
850
+ auth_user_id: authUserId
851
+ }
852
+ })),
853
+ updateNeonAuthUserRole: (projectId, branchId, authUserId, data) => call(() => raw.updateNeonAuthUserRole({
854
+ client,
855
+ path: {
856
+ project_id: projectId,
857
+ branch_id: branchId,
858
+ auth_user_id: authUserId
859
+ },
860
+ body: data
861
+ }))
862
+ };
808
863
  };
864
+ //#endregion
865
+ export { ContentType, NeonApiError, codeFromBody, getApiClient, isNeonApiError, messageFromBody, retryOnLock };