fix(persistence-service): update global environment variables schema (#3829)
This commit is contained in:
@@ -628,7 +628,7 @@ export class PersistenceService extends Service {
|
|||||||
|
|
||||||
private setupGlobalEnvsPersistence() {
|
private setupGlobalEnvsPersistence() {
|
||||||
const globalEnvKey = "globalEnv"
|
const globalEnvKey = "globalEnv"
|
||||||
let globalEnvData: Environment["variables"] = JSON.parse(
|
let globalEnvData: z.infer<typeof GLOBAL_ENV_SCHEMA> = JSON.parse(
|
||||||
window.localStorage.getItem(globalEnvKey) || "[]"
|
window.localStorage.getItem(globalEnvKey) || "[]"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -644,7 +644,7 @@ export class PersistenceService extends Service {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
setGlobalEnvVariables(globalEnvData)
|
setGlobalEnvVariables(globalEnvData as Environment["variables"])
|
||||||
|
|
||||||
globalEnv$.subscribe((vars) => {
|
globalEnv$.subscribe((vars) => {
|
||||||
window.localStorage.setItem(globalEnvKey, JSON.stringify(vars))
|
window.localStorage.setItem(globalEnvKey, JSON.stringify(vars))
|
||||||
|
|||||||
@@ -229,24 +229,24 @@ export const MQTT_REQUEST_SCHEMA = z.nullable(
|
|||||||
.strict()
|
.strict()
|
||||||
)
|
)
|
||||||
|
|
||||||
export const GLOBAL_ENV_SCHEMA = z.union([
|
const EnvironmentVariablesSchema = z.union([
|
||||||
z.array(z.never()),
|
z.object({
|
||||||
|
key: z.string(),
|
||||||
z.array(
|
value: z.string(),
|
||||||
z.union([
|
secret: z.literal(false),
|
||||||
z.object({
|
}),
|
||||||
key: z.string(),
|
z.object({
|
||||||
secret: z.literal(true),
|
key: z.string(),
|
||||||
}),
|
secret: z.literal(true),
|
||||||
z.object({
|
}),
|
||||||
key: z.string(),
|
z.object({
|
||||||
value: z.string(),
|
key: z.string(),
|
||||||
secret: z.literal(false),
|
value: z.string(),
|
||||||
}),
|
}),
|
||||||
])
|
|
||||||
),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
export const GLOBAL_ENV_SCHEMA = z.array(EnvironmentVariablesSchema)
|
||||||
|
|
||||||
const OperationTypeSchema = z.enum([
|
const OperationTypeSchema = z.enum([
|
||||||
"subscription",
|
"subscription",
|
||||||
"query",
|
"query",
|
||||||
@@ -364,22 +364,6 @@ const HoppTestDataSchema = z.lazy(() =>
|
|||||||
.strict()
|
.strict()
|
||||||
)
|
)
|
||||||
|
|
||||||
const EnvironmentVariablesSchema = z.union([
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
secret: z.literal(false),
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
secret: z.literal(true),
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
|
|
||||||
export const SECRET_ENVIRONMENT_VARIABLE_SCHEMA = z.union([
|
export const SECRET_ENVIRONMENT_VARIABLE_SCHEMA = z.union([
|
||||||
z.object({}).strict(),
|
z.object({}).strict(),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user