feat: secret variables in environments (#3779)

Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
Nivedin
2024-02-08 21:58:42 +05:30
committed by GitHub
parent 16803acb26
commit 00862eb192
55 changed files with 2141 additions and 439 deletions

View File

@@ -9,10 +9,10 @@ export const V0_SCHEMA = z.object({
key: z.string(),
value: z.string(),
})
)
),
})
export default defineVersion({
initial: true,
schema: V0_SCHEMA
schema: V0_SCHEMA,
})

View File

@@ -0,0 +1,42 @@
import { z } from "zod"
import { defineVersion } from "verzod"
import { V0_SCHEMA } from "./0"
export const V1_SCHEMA = z.object({
v: z.literal(1),
id: z.string(),
name: z.string(),
variables: z.array(
z.union([
z.object({
key: z.string(),
secret: z.literal(true),
}),
z.object({
key: z.string(),
value: z.string(),
secret: z.literal(false),
}),
])
),
})
export default defineVersion({
initial: false,
schema: V1_SCHEMA,
up(old: z.infer<typeof V0_SCHEMA>) {
const result: z.infer<typeof V1_SCHEMA> = {
...old,
v: 1,
id: old.id ?? "",
variables: old.variables.map((variable) => {
return {
...variable,
secret: false,
}
}),
}
return result
},
})