@neondatabase/env 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +178 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +61 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/dist/lib/neon-api.d.ts +264 -0
- package/dist/config/dist/lib/neon-api.d.ts.map +1 -0
- package/dist/config/dist/lib/types.d.ts +209 -0
- package/dist/config/dist/lib/types.d.ts.map +1 -0
- package/dist/config/dist/v1.d.ts +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/lib/cli/commands.d.ts +46 -0
- package/dist/lib/cli/commands.d.ts.map +1 -0
- package/dist/lib/cli/commands.js +181 -0
- package/dist/lib/cli/commands.js.map +1 -0
- package/dist/lib/cli/resolve-context.d.ts +35 -0
- package/dist/lib/cli/resolve-context.d.ts.map +1 -0
- package/dist/lib/cli/resolve-context.js +90 -0
- package/dist/lib/cli/resolve-context.js.map +1 -0
- package/dist/lib/env.d.ts +194 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/env.js +263 -0
- package/dist/lib/env.js.map +1 -0
- package/dist/v1.d.ts +2 -0
- package/dist/v1.js +2 -0
- package/package.json +72 -21
- package/.env.example +0 -5
- package/e2e/env.e2e.test.ts +0 -36
- package/e2e/helpers.ts +0 -188
- package/e2e/load-env.ts +0 -29
- package/e2e/setup.ts +0 -24
- package/src/cli.ts +0 -107
- package/src/index.ts +0 -5
- package/src/lib/cli/commands.test.ts +0 -101
- package/src/lib/cli/commands.ts +0 -267
- package/src/lib/cli/resolve-context.test.ts +0 -242
- package/src/lib/cli/resolve-context.ts +0 -142
- package/src/lib/env.test.ts +0 -172
- package/src/lib/env.ts +0 -610
- package/src/lib/fake-neon-api.ts +0 -782
- package/src/lib/test-utils.ts +0 -83
- package/src/v1.ts +0 -32
- package/tsconfig.json +0 -4
- package/tsdown.config.ts +0 -20
- package/vitest.config.ts +0 -19
- package/vitest.e2e.config.ts +0 -29
package/LICENSE.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { runEnvRun } from "./lib/cli/commands.js";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import yargs from "yargs";
|
|
6
|
+
import { hideBin } from "yargs/helpers";
|
|
7
|
+
//#region src/cli.ts
|
|
8
|
+
const pkgVersion = readPackageVersion();
|
|
9
|
+
const argv = yargs(hideBin(process.argv)).scriptName("neon-env").usage("$0 run -- <command> [options]").parserConfiguration({ "populate--": true }).option("debug", {
|
|
10
|
+
type: "boolean",
|
|
11
|
+
default: false,
|
|
12
|
+
describe: "Print stack traces and structured error details when something fails"
|
|
13
|
+
}).command("run", "Run a command with Neon env vars (from your neon.ts policy) injected into its environment. Use `--` to separate the command: `neon-env run -- npm run dev`.", (y) => y.option("config", {
|
|
14
|
+
type: "string",
|
|
15
|
+
describe: "Path to neon.ts (defaults to walking up from cwd)"
|
|
16
|
+
}).option("project-id", {
|
|
17
|
+
type: "string",
|
|
18
|
+
describe: "Override the .neon/project.json projectId"
|
|
19
|
+
}).option("branch", {
|
|
20
|
+
type: "string",
|
|
21
|
+
describe: "Override the .neon/project.json branchId / NEON_BRANCH_ID"
|
|
22
|
+
}).option("api-key", {
|
|
23
|
+
type: "string",
|
|
24
|
+
describe: "Neon API key (defaults to NEON_API_KEY)"
|
|
25
|
+
})).demandCommand(1, "Run `neon-env --help` to see the available commands.").strict().help().version(pkgVersion).parseSync();
|
|
26
|
+
const command = String(argv._[0]);
|
|
27
|
+
const cwd = process.cwd();
|
|
28
|
+
let result;
|
|
29
|
+
switch (command) {
|
|
30
|
+
case "run":
|
|
31
|
+
result = await runEnvRun({
|
|
32
|
+
command: Array.isArray(argv["--"]) ? argv["--"].map(String) : [],
|
|
33
|
+
...typeof argv.config === "string" ? { configPath: argv.config } : {},
|
|
34
|
+
...typeof argv["project-id"] === "string" ? { projectId: argv["project-id"] } : {},
|
|
35
|
+
...typeof argv.branch === "string" ? { branch: argv.branch } : {},
|
|
36
|
+
...typeof argv["api-key"] === "string" ? { apiKey: argv["api-key"] } : {}
|
|
37
|
+
}, { cwd });
|
|
38
|
+
break;
|
|
39
|
+
default: result = {
|
|
40
|
+
exitCode: 1,
|
|
41
|
+
stdout: "",
|
|
42
|
+
stderr: `Unknown command: ${command}\n`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
46
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
47
|
+
if (argv.debug && result.exitCode !== 0 && result.debugInfo) process.stderr.write(`\n--- debug ---\n${result.debugInfo}\n`);
|
|
48
|
+
process.exit(result.exitCode);
|
|
49
|
+
function readPackageVersion() {
|
|
50
|
+
try {
|
|
51
|
+
const raw = readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf-8");
|
|
52
|
+
const parsed = JSON.parse(raw);
|
|
53
|
+
return typeof parsed.version === "string" ? parsed.version : "0.0.0";
|
|
54
|
+
} catch {
|
|
55
|
+
return "0.0.0";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export {};
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { type CommandResult, runEnvRun } from \"./lib/cli/commands.js\";\n\nconst pkgVersion = readPackageVersion();\n\nconst argv = yargs(hideBin(process.argv))\n\t.scriptName(\"neon-env\")\n\t.usage(\"$0 run -- <command> [options]\")\n\t.parserConfiguration({ \"populate--\": true })\n\t.option(\"debug\", {\n\t\ttype: \"boolean\",\n\t\tdefault: false,\n\t\tdescribe:\n\t\t\t\"Print stack traces and structured error details when something fails\",\n\t})\n\t.command(\n\t\t\"run\",\n\t\t\"Run a command with Neon env vars (from your neon.ts policy) injected into its environment. Use `--` to separate the command: `neon-env run -- npm run dev`.\",\n\t\t(y) =>\n\t\t\ty\n\t\t\t\t.option(\"config\", {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescribe:\n\t\t\t\t\t\t\"Path to neon.ts (defaults to walking up from cwd)\",\n\t\t\t\t})\n\t\t\t\t.option(\"project-id\", {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescribe: \"Override the .neon/project.json projectId\",\n\t\t\t\t})\n\t\t\t\t.option(\"branch\", {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescribe:\n\t\t\t\t\t\t\"Override the .neon/project.json branchId / NEON_BRANCH_ID\",\n\t\t\t\t})\n\t\t\t\t.option(\"api-key\", {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescribe: \"Neon API key (defaults to NEON_API_KEY)\",\n\t\t\t\t}),\n\t)\n\t.demandCommand(1, \"Run `neon-env --help` to see the available commands.\")\n\t.strict()\n\t.help()\n\t.version(pkgVersion)\n\t.parseSync();\n\nconst command = String(argv._[0]);\nconst cwd = process.cwd();\n\nlet result: CommandResult;\nswitch (command) {\n\tcase \"run\": {\n\t\tconst passthrough = Array.isArray(argv[\"--\"])\n\t\t\t? argv[\"--\"].map(String)\n\t\t\t: [];\n\t\tresult = await runEnvRun(\n\t\t\t{\n\t\t\t\tcommand: passthrough,\n\t\t\t\t...(typeof argv.config === \"string\"\n\t\t\t\t\t? { configPath: argv.config }\n\t\t\t\t\t: {}),\n\t\t\t\t...(typeof argv[\"project-id\"] === \"string\"\n\t\t\t\t\t? { projectId: argv[\"project-id\"] }\n\t\t\t\t\t: {}),\n\t\t\t\t...(typeof argv.branch === \"string\"\n\t\t\t\t\t? { branch: argv.branch }\n\t\t\t\t\t: {}),\n\t\t\t\t...(typeof argv[\"api-key\"] === \"string\"\n\t\t\t\t\t? { apiKey: argv[\"api-key\"] }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t\t{ cwd },\n\t\t);\n\t\tbreak;\n\t}\n\tdefault:\n\t\tresult = {\n\t\t\texitCode: 1,\n\t\t\tstdout: \"\",\n\t\t\tstderr: `Unknown command: ${command}\\n`,\n\t\t};\n}\n\nif (result.stdout) process.stdout.write(result.stdout);\nif (result.stderr) process.stderr.write(result.stderr);\nif (argv.debug && result.exitCode !== 0 && result.debugInfo) {\n\tprocess.stderr.write(`\\n--- debug ---\\n${result.debugInfo}\\n`);\n}\nprocess.exit(result.exitCode);\n\nfunction readPackageVersion(): string {\n\t// The built CLI lives at `dist/cli.js`, so `package.json` is one directory up. When\n\t// running from source (tsx, vitest), the file lives at `src/cli.ts` and `package.json`\n\t// is again one directory up. Single resolution covers both layouts.\n\ttry {\n\t\tconst pkgUrl = new URL(\"../package.json\", import.meta.url);\n\t\tconst raw = readFileSync(fileURLToPath(pkgUrl), \"utf-8\");\n\t\tconst parsed = JSON.parse(raw) as { version?: unknown };\n\t\treturn typeof parsed.version === \"string\" ? parsed.version : \"0.0.0\";\n\t} catch {\n\t\treturn \"0.0.0\";\n\t}\n}\n"],"mappings":";;;;;;;AAQA,MAAM,aAAa,mBAAmB;AAEtC,MAAM,OAAO,MAAM,QAAQ,QAAQ,IAAI,CAAC,EACtC,WAAW,UAAU,EACrB,MAAM,+BAA+B,EACrC,oBAAoB,EAAE,cAAc,KAAK,CAAC,EAC1C,OAAO,SAAS;CAChB,MAAM;CACN,SAAS;CACT,UACC;AACF,CAAC,EACA,QACA,OACA,gKACC,MACA,EACE,OAAO,UAAU;CACjB,MAAM;CACN,UACC;AACF,CAAC,EACA,OAAO,cAAc;CACrB,MAAM;CACN,UAAU;AACX,CAAC,EACA,OAAO,UAAU;CACjB,MAAM;CACN,UACC;AACF,CAAC,EACA,OAAO,WAAW;CAClB,MAAM;CACN,UAAU;AACX,CAAC,CACJ,EACC,cAAc,GAAG,sDAAsD,EACvE,OAAO,EACP,KAAK,EACL,QAAQ,UAAU,EAClB,UAAU;AAEZ,MAAM,UAAU,OAAO,KAAK,EAAE,EAAE;AAChC,MAAM,MAAM,QAAQ,IAAI;AAExB,IAAI;AACJ,QAAQ,SAAR;CACC,KAAK;EAIJ,SAAS,MAAM,UACd;GACC,SALkB,MAAM,QAAQ,KAAK,KAAK,IACzC,KAAK,MAAM,IAAI,MAAM,IACrB,CAAC;GAIF,GAAI,OAAO,KAAK,WAAW,WACxB,EAAE,YAAY,KAAK,OAAO,IAC1B,CAAC;GACJ,GAAI,OAAO,KAAK,kBAAkB,WAC/B,EAAE,WAAW,KAAK,cAAc,IAChC,CAAC;GACJ,GAAI,OAAO,KAAK,WAAW,WACxB,EAAE,QAAQ,KAAK,OAAO,IACtB,CAAC;GACJ,GAAI,OAAO,KAAK,eAAe,WAC5B,EAAE,QAAQ,KAAK,WAAW,IAC1B,CAAC;EACL,GACA,EAAE,IAAI,CACP;EACA;CAED,SACC,SAAS;EACR,UAAU;EACV,QAAQ;EACR,QAAQ,oBAAoB,QAAQ;CACrC;AACF;AAEA,IAAI,OAAO,QAAQ,QAAQ,OAAO,MAAM,OAAO,MAAM;AACrD,IAAI,OAAO,QAAQ,QAAQ,OAAO,MAAM,OAAO,MAAM;AACrD,IAAI,KAAK,SAAS,OAAO,aAAa,KAAK,OAAO,WACjD,QAAQ,OAAO,MAAM,oBAAoB,OAAO,UAAU,GAAG;AAE9D,QAAQ,KAAK,OAAO,QAAQ;AAE5B,SAAS,qBAA6B;CAIrC,IAAI;EAEH,MAAM,MAAM,aAAa,cAAc,IADpB,IAAI,mBAAmB,OAAO,KAAK,GACV,CAAC,GAAG,OAAO;EACvD,MAAM,SAAS,KAAK,MAAM,GAAG;EAC7B,OAAO,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU;CAC9D,QAAQ;EACP,OAAO;CACR;AACD"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { BucketAccessLevel, ComputeSettings, FunctionMemoryMib, FunctionRuntime } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region ../config/dist/lib/neon-api.d.ts
|
|
4
|
+
|
|
5
|
+
//#region src/lib/neon-api.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Snapshot of a Neon project field set we care about. Maps onto a subset of the upstream
|
|
8
|
+
* `@neondatabase/api-client` `Project` type. We do **not** widen this to the full upstream
|
|
9
|
+
* shape — keeping the surface narrow makes the in-memory fake practical to maintain.
|
|
10
|
+
*/
|
|
11
|
+
interface NeonProjectSnapshot {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
regionId: string;
|
|
15
|
+
pgVersion: number;
|
|
16
|
+
orgId?: string;
|
|
17
|
+
defaultEndpointSettings?: ComputeSettings;
|
|
18
|
+
}
|
|
19
|
+
interface NeonBranchSnapshot {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
parentId?: string;
|
|
23
|
+
isDefault: boolean;
|
|
24
|
+
/** Whether the branch is marked protected on Neon. */
|
|
25
|
+
protected: boolean;
|
|
26
|
+
expiresAt?: string;
|
|
27
|
+
}
|
|
28
|
+
interface NeonEndpointSnapshot {
|
|
29
|
+
id: string;
|
|
30
|
+
branchId: string;
|
|
31
|
+
type: "read_only" | "read_write";
|
|
32
|
+
autoscalingLimitMinCu: ComputeSettings["autoscalingLimitMinCu"];
|
|
33
|
+
autoscalingLimitMaxCu: ComputeSettings["autoscalingLimitMaxCu"];
|
|
34
|
+
suspendTimeout: ComputeSettings["suspendTimeout"];
|
|
35
|
+
}
|
|
36
|
+
interface CreateProjectInput {
|
|
37
|
+
name: string;
|
|
38
|
+
regionId: string;
|
|
39
|
+
pgVersion?: number;
|
|
40
|
+
orgId?: string;
|
|
41
|
+
defaultEndpointSettings?: ComputeSettings;
|
|
42
|
+
/**
|
|
43
|
+
* Optional name for the project's auto-created default branch. When omitted, Neon
|
|
44
|
+
* uses its own default (`main`).
|
|
45
|
+
*/
|
|
46
|
+
defaultBranchName?: string;
|
|
47
|
+
}
|
|
48
|
+
interface CreateBranchInput {
|
|
49
|
+
name: string;
|
|
50
|
+
parentId?: string;
|
|
51
|
+
expiresAt?: string;
|
|
52
|
+
/** When `true`, the branch is created with the `protected` flag set on Neon. */
|
|
53
|
+
protected?: boolean;
|
|
54
|
+
computeSettings?: ComputeSettings;
|
|
55
|
+
}
|
|
56
|
+
interface UpdateBranchInput {
|
|
57
|
+
name?: string;
|
|
58
|
+
expiresAt?: string | null;
|
|
59
|
+
/** When set, toggles the branch's `protected` flag on Neon. */
|
|
60
|
+
protected?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A role on a Neon branch (e.g. `neondb_owner`). Passwords are never returned by
|
|
64
|
+
* {@link NeonApi.listBranchRoles}; use {@link NeonApi.getConnectionUri} to fetch a URI
|
|
65
|
+
* with the role's password baked in.
|
|
66
|
+
*/
|
|
67
|
+
interface NeonRoleSnapshot {
|
|
68
|
+
name: string;
|
|
69
|
+
branchId: string;
|
|
70
|
+
/** Whether the role is system-protected (cannot be deleted). */
|
|
71
|
+
protected: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A database on a Neon branch (e.g. `neondb`).
|
|
75
|
+
*/
|
|
76
|
+
interface NeonDatabaseSnapshot {
|
|
77
|
+
name: string;
|
|
78
|
+
branchId: string;
|
|
79
|
+
/** The role that owns the database (one role can own multiple databases). */
|
|
80
|
+
ownerName: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Bits of a Neon Auth integration. The key fields are optional because the Neon API only
|
|
84
|
+
* includes them on create / rotate responses; `GET /auth` returns the public fields.
|
|
85
|
+
*/
|
|
86
|
+
interface NeonAuthSnapshot {
|
|
87
|
+
/** The Neon Auth project id (`auth_provider_project_id` on the Neon API). */
|
|
88
|
+
projectId: string;
|
|
89
|
+
/** Public client key (`pub_client_key`), only present on create / rotate responses. */
|
|
90
|
+
publishableClientKey?: string;
|
|
91
|
+
/** Secret server key (`secret_server_key`), only present on create / rotate responses. */
|
|
92
|
+
secretServerKey?: string;
|
|
93
|
+
/** JWKS URL for verifying tokens issued by Neon Auth. */
|
|
94
|
+
jwksUrl: string;
|
|
95
|
+
/** Optional base URL of the Neon Auth deployment. */
|
|
96
|
+
baseUrl?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Public, fetchable bits of a Neon Data API integration on a specific branch.
|
|
100
|
+
*/
|
|
101
|
+
interface NeonDataApiSnapshot {
|
|
102
|
+
/** REST endpoint URL. */
|
|
103
|
+
url: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A branchable object-storage bucket (Preview). Backed by the Neon Platform
|
|
107
|
+
* branchable-storage service.
|
|
108
|
+
*/
|
|
109
|
+
interface NeonBucketSnapshot {
|
|
110
|
+
name: string;
|
|
111
|
+
accessLevel: BucketAccessLevel;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Input for creating a bucket on a branch.
|
|
115
|
+
*/
|
|
116
|
+
interface CreateBucketInput {
|
|
117
|
+
name: string;
|
|
118
|
+
accessLevel?: BucketAccessLevel;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A Neon Function on a branch (Preview). Mirrors the subset of the Functions API we model:
|
|
122
|
+
* the immutable `slug`, the display `name`, and the active deployment id when one exists.
|
|
123
|
+
*/
|
|
124
|
+
interface NeonFunctionSnapshot {
|
|
125
|
+
/** Opaque, stable function identifier. */
|
|
126
|
+
id: string;
|
|
127
|
+
/** Branch-unique slug (the invocation path segment). Immutable. */
|
|
128
|
+
slug: string;
|
|
129
|
+
/** Free-form display name. */
|
|
130
|
+
name: string;
|
|
131
|
+
/** URL at which the function is invoked. */
|
|
132
|
+
invocationUrl: string;
|
|
133
|
+
/** Id (platform version number) of the active deployment, when any code is deployed. */
|
|
134
|
+
activeDeploymentId?: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Input for deploying code to a function. `bundle` is the already-built ZIP archive of the
|
|
138
|
+
* function source — building it (esbuild + zip) is an imperative step performed by the
|
|
139
|
+
* caller, not by the {@link NeonApi} adapter.
|
|
140
|
+
*/
|
|
141
|
+
interface DeployFunctionInput {
|
|
142
|
+
bundle: Uint8Array;
|
|
143
|
+
runtime: FunctionRuntime;
|
|
144
|
+
memoryMib: FunctionMemoryMib;
|
|
145
|
+
environment: Record<string, string>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A function deployment (Preview).
|
|
149
|
+
*/
|
|
150
|
+
interface NeonFunctionDeploymentSnapshot {
|
|
151
|
+
/** The deployment id (monotonic per function). */
|
|
152
|
+
id: number;
|
|
153
|
+
status: "pending" | "building" | "completed" | "failed";
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Parameters accepted by {@link NeonApi.getConnectionUri}. `branchId` and `endpointId`
|
|
157
|
+
* are optional — when omitted, the API uses the project's default branch and that
|
|
158
|
+
* branch's read-write endpoint, respectively.
|
|
159
|
+
*/
|
|
160
|
+
interface GetConnectionUriInput {
|
|
161
|
+
branchId?: string;
|
|
162
|
+
endpointId?: string;
|
|
163
|
+
databaseName: string;
|
|
164
|
+
roleName: string;
|
|
165
|
+
/** When `true`, returns the pooled (PgBouncer) URI instead of the direct URI. */
|
|
166
|
+
pooled?: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Narrow façade over the Neon management API. `pullConfig`, `pushConfig`, and `fetchEnv`
|
|
170
|
+
* depend on this interface — *not* on `@neondatabase/api-client` directly — which lets us
|
|
171
|
+
* inject a real in-memory fake during tests without resorting to module mocks.
|
|
172
|
+
*/
|
|
173
|
+
interface NeonApi {
|
|
174
|
+
listProjects(filter: {
|
|
175
|
+
orgId?: string;
|
|
176
|
+
}): Promise<NeonProjectSnapshot[]>;
|
|
177
|
+
getProject(projectId: string): Promise<NeonProjectSnapshot>;
|
|
178
|
+
createProject(input: CreateProjectInput): Promise<NeonProjectSnapshot>;
|
|
179
|
+
updateProject(projectId: string, input: {
|
|
180
|
+
name?: string;
|
|
181
|
+
defaultEndpointSettings?: ComputeSettings;
|
|
182
|
+
}): Promise<NeonProjectSnapshot>;
|
|
183
|
+
listBranches(projectId: string): Promise<NeonBranchSnapshot[]>;
|
|
184
|
+
createBranch(projectId: string, input: CreateBranchInput): Promise<{
|
|
185
|
+
branch: NeonBranchSnapshot;
|
|
186
|
+
endpoints: NeonEndpointSnapshot[];
|
|
187
|
+
}>;
|
|
188
|
+
updateBranch(projectId: string, branchId: string, input: UpdateBranchInput): Promise<NeonBranchSnapshot>;
|
|
189
|
+
listEndpoints(projectId: string): Promise<NeonEndpointSnapshot[]>;
|
|
190
|
+
updateEndpoint(projectId: string, endpointId: string, settings: ComputeSettings): Promise<NeonEndpointSnapshot>;
|
|
191
|
+
/** List roles on a branch. Used by {@link fetchEnv} to auto-pick the role when only one exists. */
|
|
192
|
+
listBranchRoles(projectId: string, branchId: string): Promise<NeonRoleSnapshot[]>;
|
|
193
|
+
/** List databases on a branch. Used by {@link fetchEnv} to auto-pick the database when only one exists. */
|
|
194
|
+
listBranchDatabases(projectId: string, branchId: string): Promise<NeonDatabaseSnapshot[]>;
|
|
195
|
+
/**
|
|
196
|
+
* Fetch a Postgres connection URI for the given role + database on a branch.
|
|
197
|
+
* Returns the same string the Neon Console shows under "Connection Details".
|
|
198
|
+
*/
|
|
199
|
+
getConnectionUri(projectId: string, input: GetConnectionUriInput): Promise<{
|
|
200
|
+
uri: string;
|
|
201
|
+
}>;
|
|
202
|
+
/**
|
|
203
|
+
* Fetch the Neon Auth integration attached to a specific branch. Returns `null` when
|
|
204
|
+
* no integration is enabled — used by `fetchEnv` to decide whether the `env.auth`
|
|
205
|
+
* namespace can be populated.
|
|
206
|
+
*/
|
|
207
|
+
getNeonAuth(projectId: string, branchId: string): Promise<NeonAuthSnapshot | null>;
|
|
208
|
+
/**
|
|
209
|
+
* Enable the Neon Auth integration on a specific branch. Idempotent: if an integration
|
|
210
|
+
* is already enabled, the existing snapshot is returned unchanged. Used by
|
|
211
|
+
* `pushConfig` and `branch` to honour branch policy `auth: {}` / `auth.enabled: true`.
|
|
212
|
+
*/
|
|
213
|
+
enableNeonAuth(projectId: string, branchId: string, input?: {
|
|
214
|
+
databaseName?: string;
|
|
215
|
+
}): Promise<NeonAuthSnapshot>;
|
|
216
|
+
/**
|
|
217
|
+
* Fetch the Neon Data API integration attached to a specific branch + database.
|
|
218
|
+
* Returns `null` when no integration is enabled — used by `fetchEnv` to decide
|
|
219
|
+
* whether the `env.dataApi` namespace can be populated.
|
|
220
|
+
*/
|
|
221
|
+
getNeonDataApi(projectId: string, branchId: string, databaseName: string): Promise<NeonDataApiSnapshot | null>;
|
|
222
|
+
/**
|
|
223
|
+
* Enable the Neon Data API integration on a specific branch + database. Idempotent:
|
|
224
|
+
* if an integration is already enabled, the existing snapshot is returned unchanged.
|
|
225
|
+
* Used by `pushConfig` and `branch` to honour branch policy `dataApi: {}` / `dataApi.enabled: true`.
|
|
226
|
+
*/
|
|
227
|
+
enableProjectBranchDataApi(projectId: string, branchId: string, databaseName: string): Promise<NeonDataApiSnapshot>;
|
|
228
|
+
/** List branchable object-storage buckets visible on a branch. */
|
|
229
|
+
listBranchBuckets(projectId: string, branchId: string): Promise<NeonBucketSnapshot[]>;
|
|
230
|
+
/** Create a bucket on a branch. Used by `pushConfig` to honour `preview.buckets`. */
|
|
231
|
+
createBranchBucket(projectId: string, branchId: string, input: CreateBucketInput): Promise<NeonBucketSnapshot>;
|
|
232
|
+
/** Delete a bucket from a branch. */
|
|
233
|
+
deleteBranchBucket(projectId: string, branchId: string, bucketName: string): Promise<void>;
|
|
234
|
+
/** List functions on a branch. */
|
|
235
|
+
listBranchFunctions(projectId: string, branchId: string): Promise<NeonFunctionSnapshot[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Create a function on a branch. The function has no deployment until code is deployed
|
|
238
|
+
* to it with {@link deployBranchFunction}.
|
|
239
|
+
*/
|
|
240
|
+
createBranchFunction(projectId: string, branchId: string, input: {
|
|
241
|
+
slug: string;
|
|
242
|
+
name: string;
|
|
243
|
+
}): Promise<NeonFunctionSnapshot>;
|
|
244
|
+
/** Delete a function (by slug) from a branch. */
|
|
245
|
+
deleteBranchFunction(projectId: string, branchId: string, slug: string): Promise<void>;
|
|
246
|
+
/**
|
|
247
|
+
* Deploy a built bundle to a function. The newest deployment becomes active. The
|
|
248
|
+
* `bundle` is built (esbuild + zip) by the caller and passed in as bytes.
|
|
249
|
+
*/
|
|
250
|
+
deployBranchFunction(projectId: string, branchId: string, slug: string, input: DeployFunctionInput): Promise<NeonFunctionDeploymentSnapshot>;
|
|
251
|
+
/**
|
|
252
|
+
* Whether the AI Gateway is enabled on a branch. Toggle-style, like Neon Auth / Data
|
|
253
|
+
* API: used by both `fetchEnv` (to decide visibility) and `pushConfig` (to diff intent).
|
|
254
|
+
*/
|
|
255
|
+
getAiGatewayEnabled(projectId: string, branchId: string): Promise<boolean>;
|
|
256
|
+
/** Enable the AI Gateway on a branch. Idempotent. */
|
|
257
|
+
enableAiGateway(projectId: string, branchId: string): Promise<void>;
|
|
258
|
+
/** Disable the AI Gateway on a branch. Idempotent. */
|
|
259
|
+
disableAiGateway(projectId: string, branchId: string): Promise<void>;
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#endregion
|
|
263
|
+
export { CreateBranchInput, CreateBucketInput, CreateProjectInput, DeployFunctionInput, GetConnectionUriInput, NeonApi, NeonAuthSnapshot, NeonBranchSnapshot, NeonBucketSnapshot, NeonDataApiSnapshot, NeonDatabaseSnapshot, NeonEndpointSnapshot, NeonFunctionDeploymentSnapshot, NeonFunctionSnapshot, NeonProjectSnapshot, NeonRoleSnapshot, UpdateBranchInput };
|
|
264
|
+
//# sourceMappingURL=neon-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neon-api.d.ts","names":["BucketAccessLevel","ComputeSettings","FunctionMemoryMib","FunctionRuntime","NeonProjectSnapshot","NeonBranchSnapshot","NeonEndpointSnapshot","CreateProjectInput","CreateBranchInput","UpdateBranchInput","NeonRoleSnapshot","NeonDatabaseSnapshot","NeonAuthSnapshot","NeonDataApiSnapshot","NeonBucketSnapshot","CreateBucketInput","NeonFunctionSnapshot","DeployFunctionInput","Uint8Array","Record","NeonFunctionDeploymentSnapshot","GetConnectionUriInput","NeonApi","Promise"],"sources":["../../../../../config/dist/lib/neon-api.d.ts"],"sourcesContent":["import { BucketAccessLevel, ComputeSettings, FunctionMemoryMib, FunctionRuntime } from \"./types.js\";\n\n//#region src/lib/neon-api.d.ts\n\n/**\n * Snapshot of a Neon project field set we care about. Maps onto a subset of the upstream\n * `@neondatabase/api-client` `Project` type. We do **not** widen this to the full upstream\n * shape — keeping the surface narrow makes the in-memory fake practical to maintain.\n */\ninterface NeonProjectSnapshot {\n id: string;\n name: string;\n regionId: string;\n pgVersion: number;\n orgId?: string;\n defaultEndpointSettings?: ComputeSettings;\n}\ninterface NeonBranchSnapshot {\n id: string;\n name: string;\n parentId?: string;\n isDefault: boolean;\n /** Whether the branch is marked protected on Neon. */\n protected: boolean;\n expiresAt?: string;\n}\ninterface NeonEndpointSnapshot {\n id: string;\n branchId: string;\n type: \"read_only\" | \"read_write\";\n autoscalingLimitMinCu: ComputeSettings[\"autoscalingLimitMinCu\"];\n autoscalingLimitMaxCu: ComputeSettings[\"autoscalingLimitMaxCu\"];\n suspendTimeout: ComputeSettings[\"suspendTimeout\"];\n}\ninterface CreateProjectInput {\n name: string;\n regionId: string;\n pgVersion?: number;\n orgId?: string;\n defaultEndpointSettings?: ComputeSettings;\n /**\n * Optional name for the project's auto-created default branch. When omitted, Neon\n * uses its own default (`main`).\n */\n defaultBranchName?: string;\n}\ninterface CreateBranchInput {\n name: string;\n parentId?: string;\n expiresAt?: string;\n /** When `true`, the branch is created with the `protected` flag set on Neon. */\n protected?: boolean;\n computeSettings?: ComputeSettings;\n}\ninterface UpdateBranchInput {\n name?: string;\n expiresAt?: string | null;\n /** When set, toggles the branch's `protected` flag on Neon. */\n protected?: boolean;\n}\n/**\n * A role on a Neon branch (e.g. `neondb_owner`). Passwords are never returned by\n * {@link NeonApi.listBranchRoles}; use {@link NeonApi.getConnectionUri} to fetch a URI\n * with the role's password baked in.\n */\ninterface NeonRoleSnapshot {\n name: string;\n branchId: string;\n /** Whether the role is system-protected (cannot be deleted). */\n protected: boolean;\n}\n/**\n * A database on a Neon branch (e.g. `neondb`).\n */\ninterface NeonDatabaseSnapshot {\n name: string;\n branchId: string;\n /** The role that owns the database (one role can own multiple databases). */\n ownerName: string;\n}\n/**\n * Bits of a Neon Auth integration. The key fields are optional because the Neon API only\n * includes them on create / rotate responses; `GET /auth` returns the public fields.\n */\ninterface NeonAuthSnapshot {\n /** The Neon Auth project id (`auth_provider_project_id` on the Neon API). */\n projectId: string;\n /** Public client key (`pub_client_key`), only present on create / rotate responses. */\n publishableClientKey?: string;\n /** Secret server key (`secret_server_key`), only present on create / rotate responses. */\n secretServerKey?: string;\n /** JWKS URL for verifying tokens issued by Neon Auth. */\n jwksUrl: string;\n /** Optional base URL of the Neon Auth deployment. */\n baseUrl?: string;\n}\n/**\n * Public, fetchable bits of a Neon Data API integration on a specific branch.\n */\ninterface NeonDataApiSnapshot {\n /** REST endpoint URL. */\n url: string;\n}\n/**\n * A branchable object-storage bucket (Preview). Backed by the Neon Platform\n * branchable-storage service.\n */\ninterface NeonBucketSnapshot {\n name: string;\n accessLevel: BucketAccessLevel;\n}\n/**\n * Input for creating a bucket on a branch.\n */\ninterface CreateBucketInput {\n name: string;\n accessLevel?: BucketAccessLevel;\n}\n/**\n * A Neon Function on a branch (Preview). Mirrors the subset of the Functions API we model:\n * the immutable `slug`, the display `name`, and the active deployment id when one exists.\n */\ninterface NeonFunctionSnapshot {\n /** Opaque, stable function identifier. */\n id: string;\n /** Branch-unique slug (the invocation path segment). Immutable. */\n slug: string;\n /** Free-form display name. */\n name: string;\n /** URL at which the function is invoked. */\n invocationUrl: string;\n /** Id (platform version number) of the active deployment, when any code is deployed. */\n activeDeploymentId?: number;\n}\n/**\n * Input for deploying code to a function. `bundle` is the already-built ZIP archive of the\n * function source — building it (esbuild + zip) is an imperative step performed by the\n * caller, not by the {@link NeonApi} adapter.\n */\ninterface DeployFunctionInput {\n bundle: Uint8Array;\n runtime: FunctionRuntime;\n memoryMib: FunctionMemoryMib;\n environment: Record<string, string>;\n}\n/**\n * A function deployment (Preview).\n */\ninterface NeonFunctionDeploymentSnapshot {\n /** The deployment id (monotonic per function). */\n id: number;\n status: \"pending\" | \"building\" | \"completed\" | \"failed\";\n}\n/**\n * Parameters accepted by {@link NeonApi.getConnectionUri}. `branchId` and `endpointId`\n * are optional — when omitted, the API uses the project's default branch and that\n * branch's read-write endpoint, respectively.\n */\ninterface GetConnectionUriInput {\n branchId?: string;\n endpointId?: string;\n databaseName: string;\n roleName: string;\n /** When `true`, returns the pooled (PgBouncer) URI instead of the direct URI. */\n pooled?: boolean;\n}\n/**\n * Narrow façade over the Neon management API. `pullConfig`, `pushConfig`, and `fetchEnv`\n * depend on this interface — *not* on `@neondatabase/api-client` directly — which lets us\n * inject a real in-memory fake during tests without resorting to module mocks.\n */\ninterface NeonApi {\n listProjects(filter: {\n orgId?: string;\n }): Promise<NeonProjectSnapshot[]>;\n getProject(projectId: string): Promise<NeonProjectSnapshot>;\n createProject(input: CreateProjectInput): Promise<NeonProjectSnapshot>;\n updateProject(projectId: string, input: {\n name?: string;\n defaultEndpointSettings?: ComputeSettings;\n }): Promise<NeonProjectSnapshot>;\n listBranches(projectId: string): Promise<NeonBranchSnapshot[]>;\n createBranch(projectId: string, input: CreateBranchInput): Promise<{\n branch: NeonBranchSnapshot;\n endpoints: NeonEndpointSnapshot[];\n }>;\n updateBranch(projectId: string, branchId: string, input: UpdateBranchInput): Promise<NeonBranchSnapshot>;\n listEndpoints(projectId: string): Promise<NeonEndpointSnapshot[]>;\n updateEndpoint(projectId: string, endpointId: string, settings: ComputeSettings): Promise<NeonEndpointSnapshot>;\n /** List roles on a branch. Used by {@link fetchEnv} to auto-pick the role when only one exists. */\n listBranchRoles(projectId: string, branchId: string): Promise<NeonRoleSnapshot[]>;\n /** List databases on a branch. Used by {@link fetchEnv} to auto-pick the database when only one exists. */\n listBranchDatabases(projectId: string, branchId: string): Promise<NeonDatabaseSnapshot[]>;\n /**\n * Fetch a Postgres connection URI for the given role + database on a branch.\n * Returns the same string the Neon Console shows under \"Connection Details\".\n */\n getConnectionUri(projectId: string, input: GetConnectionUriInput): Promise<{\n uri: string;\n }>;\n /**\n * Fetch the Neon Auth integration attached to a specific branch. Returns `null` when\n * no integration is enabled — used by `fetchEnv` to decide whether the `env.auth`\n * namespace can be populated.\n */\n getNeonAuth(projectId: string, branchId: string): Promise<NeonAuthSnapshot | null>;\n /**\n * Enable the Neon Auth integration on a specific branch. Idempotent: if an integration\n * is already enabled, the existing snapshot is returned unchanged. Used by\n * `pushConfig` and `branch` to honour branch policy `auth: {}` / `auth.enabled: true`.\n */\n enableNeonAuth(projectId: string, branchId: string, input?: {\n databaseName?: string;\n }): Promise<NeonAuthSnapshot>;\n /**\n * Fetch the Neon Data API integration attached to a specific branch + database.\n * Returns `null` when no integration is enabled — used by `fetchEnv` to decide\n * whether the `env.dataApi` namespace can be populated.\n */\n getNeonDataApi(projectId: string, branchId: string, databaseName: string): Promise<NeonDataApiSnapshot | null>;\n /**\n * Enable the Neon Data API integration on a specific branch + database. Idempotent:\n * if an integration is already enabled, the existing snapshot is returned unchanged.\n * Used by `pushConfig` and `branch` to honour branch policy `dataApi: {}` / `dataApi.enabled: true`.\n */\n enableProjectBranchDataApi(projectId: string, branchId: string, databaseName: string): Promise<NeonDataApiSnapshot>;\n /** List branchable object-storage buckets visible on a branch. */\n listBranchBuckets(projectId: string, branchId: string): Promise<NeonBucketSnapshot[]>;\n /** Create a bucket on a branch. Used by `pushConfig` to honour `preview.buckets`. */\n createBranchBucket(projectId: string, branchId: string, input: CreateBucketInput): Promise<NeonBucketSnapshot>;\n /** Delete a bucket from a branch. */\n deleteBranchBucket(projectId: string, branchId: string, bucketName: string): Promise<void>;\n /** List functions on a branch. */\n listBranchFunctions(projectId: string, branchId: string): Promise<NeonFunctionSnapshot[]>;\n /**\n * Create a function on a branch. The function has no deployment until code is deployed\n * to it with {@link deployBranchFunction}.\n */\n createBranchFunction(projectId: string, branchId: string, input: {\n slug: string;\n name: string;\n }): Promise<NeonFunctionSnapshot>;\n /** Delete a function (by slug) from a branch. */\n deleteBranchFunction(projectId: string, branchId: string, slug: string): Promise<void>;\n /**\n * Deploy a built bundle to a function. The newest deployment becomes active. The\n * `bundle` is built (esbuild + zip) by the caller and passed in as bytes.\n */\n deployBranchFunction(projectId: string, branchId: string, slug: string, input: DeployFunctionInput): Promise<NeonFunctionDeploymentSnapshot>;\n /**\n * Whether the AI Gateway is enabled on a branch. Toggle-style, like Neon Auth / Data\n * API: used by both `fetchEnv` (to decide visibility) and `pushConfig` (to diff intent).\n */\n getAiGatewayEnabled(projectId: string, branchId: string): Promise<boolean>;\n /** Enable the AI Gateway on a branch. Idempotent. */\n enableAiGateway(projectId: string, branchId: string): Promise<void>;\n /** Disable the AI Gateway on a branch. Idempotent. */\n disableAiGateway(projectId: string, branchId: string): Promise<void>;\n}\n//#endregion\nexport { CreateBranchInput, CreateBucketInput, CreateProjectInput, DeployFunctionInput, GetConnectionUriInput, NeonApi, NeonAuthSnapshot, NeonBranchSnapshot, NeonBucketSnapshot, NeonDataApiSnapshot, NeonDatabaseSnapshot, NeonEndpointSnapshot, NeonFunctionDeploymentSnapshot, NeonFunctionSnapshot, NeonProjectSnapshot, NeonRoleSnapshot, UpdateBranchInput };\n//# sourceMappingURL=neon-api.d.ts.map"],"mappings":";;;;;AAe2C;AAEf;;;;UARlBI,mBAAAA,CAuBQH;EAAe,EAAA,EAAA,MAAA;EAAA,IAEvBM,EAAAA,MAAAA;EAKiC,QAOjCC,EAAAA,MAAAA;EAMyB,SAEzBC,EAAAA,MAAAA;EAAiB,KAWjBC,CAAAA,EAAAA,MAAAA;EAAgB,uBAShBC,CAAAA,EA3DkBV,eA2DE;AAAA;AAUJ,UAnEhBI,kBAAAA,CAkFmB;EAAA,EAQnBS,EAAAA,MAAAA;EAEsB,IAKtBC,EAAAA,MAAAA;EAEuB,QAMvBC,CAAAA,EAAAA,MAAAA;EAAoB,SAiBpBC,EAAAA,OAAAA;EAAmB;WACnBC,EAAAA,OAAAA;WACCf,CAAAA,EAAAA,MAAAA;;UAnHDG,oBAAAA,CAqHKa;EAAM,EAAA,EAAA,MAAA;EAAA,QAKXC,EAAAA,MAAAA;EAA8B,IAU9BC,EAAAA,WAAAA,GAAAA,YAAqB;EAAA,qBAad,EA7IQpB,eA6IR,CAAA,uBAAA,CAAA;EAAA,qBAAA,EA5IQA,eA4IR,CAAA,uBAAA,CAAA;gBAGHG,EA9IIH,eA8IJG,CAAAA,gBAAAA,CAAAA;;UA5IJG,kBAAAA,CA6I+BH;QAARmB,MAAAA;UACVhB,EAAAA,MAAAA;WAA6BH,CAAAA,EAAAA,MAAAA;OAARmB,CAAAA,EAAAA,MAAAA;yBAGdtB,CAAAA,EA5IFA,eA4IEA;;;;;mBAGWO,CAAAA,EAAAA,MAAAA;;UAxI/BA,iBAAAA,CA0IKF;QAF8CiB,MAAAA;UAIFd,CAAAA,EAAAA,MAAAA;WAA4BJ,CAAAA,EAAAA,MAAAA;;WAC3CC,CAAAA,EAAAA,OAAAA;iBAARiB,CAAAA,EAvIhBtB,eAuIgBsB;;UArI1Bd,iBAAAA,CAsIkFH;OAARiB,EAAAA,MAAAA;WAEpBb,CAAAA,EAAAA,MAAAA,GAAAA,IAAAA;;WAEIC,CAAAA,EAAAA,OAAAA;;;;;;;UA/H1DD,gBAAAA,CAoJJa;QAM+EV,MAAAA;UAARU,EAAAA,MAAAA;;WAMYA,EAAAA,OAAAA;;;;;UAvJ/EZ,oBAAAA,CA2J2EY;QAENA,MAAAA;UAEXP,EAAAA,MAAAA;;WAQtDA,EAAAA,MAAAA;;;;;;UA7JJJ,gBAAAA,CAyKkDW;;WAIHA,EAAAA,MAAAA;EAAO;;;;;;;;;;;;UA9JtDV,mBAAAA;;;;;;;;UAQAC,kBAAAA;;eAEKd;;;;;UAKLe,iBAAAA;;gBAEMf;;;;;;UAMNgB,oBAAAA;;;;;;;;;;;;;;;;;UAiBAC,mBAAAA;UACAC;WACCf;aACED;eACEiB;;;;;UAKLC,8BAAAA;;;;;;;;;;UAUAC,qBAAAA;;;;;;;;;;;;;UAaAC,OAAAA;;;MAGJC,QAAQnB;iCACmBmB,QAAQnB;uBAClBG,qBAAqBgB,QAAQnB;;;8BAGtBH;MACxBsB,QAAQnB;mCACqBmB,QAAQlB;yCACFG,oBAAoBe;YACjDlB;eACGC;;2DAE4CG,oBAAoBc,QAAQlB;oCACnDkB,QAAQjB;kEACsBL,kBAAkBsB,QAAQjB;;wDAEpCiB,QAAQb;;4DAEJa,QAAQZ;;;;;6CAKvBU,wBAAwBE;;;;;;;;oDAQjBA,QAAQX;;;;;;;;MAQtDW,QAAQX;;;;;;6EAM+DW,QAAQV;;;;;;yFAMIU,QAAQV;;0DAEvCU,QAAQT;;iEAEDC,oBAAoBQ,QAAQT;;+EAEdS;;4DAEnBA,QAAQP;;;;;;;;MAQ9DO,QAAQP;;2EAE6DO;;;;;iFAKMN,sBAAsBM,QAAQH;;;;;4DAKnDG;;wDAEJA;;yDAECA"}
|