@@ -10,7 +10,11 @@ import {
1010 TeamEnvironmentUpdatedDocument ,
1111} from "../backend/graphql"
1212import { TeamEnvironment } from "./TeamEnvironment"
13- import { Environment , EnvironmentSchemaVersion } from "@hoppscotch/data"
13+ import {
14+ Environment ,
15+ EnvironmentSchemaVersion ,
16+ translateToNewEnvironmentVariables ,
17+ } from "@hoppscotch/data"
1418
1519type EntityType = "environment"
1620type EntityID = `${EntityType } -${string } `
@@ -114,10 +118,15 @@ export default class TeamEnvironmentAdapter {
114118 if ( result . right . team ) {
115119 results . push (
116120 ...result . right . team . teamEnvironments . map ( ( x ) => {
121+ // Keep the environment structure consistent with the new schema
117122 const environment = < Environment > {
123+ v : EnvironmentSchemaVersion ,
118124 id : x . id ,
119125 name : x . name ,
120- variables : JSON . parse ( x . variables ) ,
126+ variables : JSON . parse ( x . variables ) . map (
127+ ( variable : Environment [ "variables" ] [ number ] ) =>
128+ translateToNewEnvironmentVariables ( variable )
129+ ) ,
121130 }
122131
123132 const parsedEnvironment = Environment . safeParse ( environment )
@@ -128,10 +137,7 @@ export default class TeamEnvironmentAdapter {
128137 environment :
129138 parsedEnvironment . type === "ok"
130139 ? parsedEnvironment . value
131- : {
132- ...environment ,
133- v : EnvironmentSchemaVersion ,
134- } ,
140+ : environment ,
135141 }
136142 } )
137143 )
0 commit comments