Skip to content

Commit ed45faa

Browse files
committed
Finish env var endpoints and add resolveEnvVars hook
1 parent 481bd44 commit ed45faa

File tree

23 files changed

+998
-185
lines changed

23 files changed

+998
-185
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.environment-variables.new/route.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const Variable = z.object({
7070
type Variable = z.infer<typeof Variable>;
7171

7272
const schema = z.object({
73-
overwrite: z.preprocess((i) => {
73+
override: z.preprocess((i) => {
7474
if (i === "true") return true;
7575
if (i === "false") return false;
7676
return;
@@ -256,18 +256,18 @@ export default function Page() {
256256
type="submit"
257257
variant="primary/small"
258258
disabled={isLoading}
259-
name="overwrite"
259+
name="override"
260260
value="false"
261261
>
262262
{isLoading ? "Saving" : "Save"}
263263
</Button>
264264
<Button
265265
variant="secondary/small"
266266
disabled={isLoading}
267-
name="overwrite"
267+
name="override"
268268
value="true"
269269
>
270-
{isLoading ? "Overwriting" : "Overwrite"}
270+
{isLoading ? "Overriding" : "Override"}
271271
</Button>
272272
</div>
273273
}

apps/webapp/app/routes/api.v1.projects.$projectRef.envvars.$slug.import.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function action({ params, request }: ActionFunctionArgs) {
3737
const body = await parseImportBody(request);
3838

3939
const result = await repository.create(environment.project.id, {
40-
overwrite: body.overwrite === true ? true : false,
40+
override: typeof body.override === "boolean" ? body.override : false,
4141
environmentIds: [environment.id],
4242
variables: Object.entries(body.variables).map(([key, value]) => ({
4343
key,
@@ -59,14 +59,14 @@ async function parseImportBody(request: Request): Promise<ImportEnvironmentVaria
5959
const formData = await request.formData();
6060

6161
const file = formData.get("variables");
62-
const overwrite = formData.get("overwrite") === "true";
62+
const override = formData.get("override") === "true";
6363

6464
if (file instanceof File) {
6565
const buffer = await file.arrayBuffer();
6666

6767
const variables = parse(Buffer.from(buffer));
6868

69-
return { variables, overwrite };
69+
return { variables, override };
7070
} else {
7171
throw json({ error: "Invalid file" }, { status: 400 });
7272
}

apps/webapp/app/routes/api.v1.projects.$projectRef.envvars.$slug.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function action({ params, request }: ActionFunctionArgs) {
4242
const repository = new EnvironmentVariablesRepository();
4343

4444
const result = await repository.create(environment.project.id, {
45-
overwrite: true,
45+
override: true,
4646
environmentIds: [environment.id],
4747
variables: [
4848
{
@@ -82,5 +82,5 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
8282

8383
const variables = await repository.getEnvironment(environment.project.id, environment.id, true);
8484

85-
return json(variables);
85+
return json(variables.map((variable) => ({ name: variable.key, value: variable.value })));
8686
}

apps/webapp/app/v3/environmentVariables/environmentVariablesRepository.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class EnvironmentVariablesRepository implements Repository {
4444
async create(
4545
projectId: string,
4646
options: {
47-
overwrite: boolean;
47+
override: boolean;
4848
environmentIds: string[];
4949
variables: {
5050
key: string;
@@ -102,7 +102,7 @@ export class EnvironmentVariablesRepository implements Repository {
102102
}
103103

104104
//check if any of them exist in an environment we're setting
105-
if (!options.overwrite) {
105+
if (!options.override) {
106106
const existingVariableKeys: { key: string; environments: RuntimeEnvironmentType[] }[] = [];
107107
for (const variable of values) {
108108
const existingVariable = project.environmentVariables.find((v) => v.key === variable.key);
@@ -122,7 +122,7 @@ export class EnvironmentVariablesRepository implements Repository {
122122
if (existingVariableKeys.length > 0) {
123123
return {
124124
success: false as const,
125-
error: `Some of the variables are already set for these environments. Set overwrite to true to overwrite them.`,
125+
error: `Some of the variables are already set for these environments. Set override to true to override them.`,
126126
variableErrors: existingVariableKeys.map((val) => ({
127127
key: val.key,
128128
error: `Variable already set in ${val.environments

docs/mint.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
"v3 (Developer Preview)",
1010
"v2"
1111
],
12+
"api": {
13+
"playground": {
14+
"mode": "hide"
15+
},
16+
"maintainOrder": true
17+
},
1218
"logo": {
1319
"dark": "/logo/dark.png",
1420
"light": "/logo/light.png",

0 commit comments

Comments
 (0)