Skip to content

Commit 7b9acb6

Browse files
committed
feat(api): add source metadata for env var imports
Add an optional discriminated `source` field to the import request schema to capture whether variables are imported by a user or an integration and to include the corresponding identifier (userId or integration). Propagate this source into the database payloads (`lastUpdatedBy`) when creating or syncing environment variables so the system records who/what initiated the import.
1 parent 6ecd2cc commit 7b9acb6

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function action({ params, request }: ActionFunctionArgs) {
4747
key,
4848
value,
4949
})),
50+
lastUpdatedBy: body.source,
5051
});
5152

5253
// Only sync parent variables if this is a branch environment
@@ -58,6 +59,7 @@ export async function action({ params, request }: ActionFunctionArgs) {
5859
key,
5960
value,
6061
})),
62+
lastUpdatedBy: body.source,
6163
});
6264

6365
let childFailure = !result.success ? result : undefined;

packages/core/src/v3/schemas/api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,12 @@ export const ImportEnvironmentVariablesRequestBody = z.object({
11521152
variables: z.record(z.string()),
11531153
parentVariables: z.record(z.string()).optional(),
11541154
override: z.boolean().optional(),
1155+
source: z
1156+
.discriminatedUnion("type", [
1157+
z.object({ type: z.literal("user"), userId: z.string() }),
1158+
z.object({ type: z.literal("integration"), integration: z.string() }),
1159+
])
1160+
.optional(),
11551161
});
11561162

11571163
export type ImportEnvironmentVariablesRequestBody = z.infer<

pnpm-lock.yaml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)