Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: team env not migrating in edge cases (#5160)
Nivedinf6550350e01e
diff --git a/packages/hoppscotch-common/src/helpers/teams/TeamEnvironmentAdapter.ts b/packages/hoppscotch-common/src/helpers/teams/TeamEnvironmentAdapter.tsindex 6f1143c78..e240fae78 100644--- a/packages/hoppscotch-common/src/helpers/teams/TeamEnvironmentAdapter.ts+++ b/packages/hoppscotch-common/src/helpers/teams/TeamEnvironmentAdapter.ts@@ -10,7 +10,11 @@ import {TeamEnvironmentUpdatedDocument,} from "../backend/graphql"import { TeamEnvironment } from "./TeamEnvironment"-import { Environment, EnvironmentSchemaVersion } from "@hoppscotch/data"+import {+ Environment,+ EnvironmentSchemaVersion,+ translateToNewEnvironmentVariables,+} from "@hoppscotch/data"type EntityType = "environment"type EntityID = `${EntityType}-${string}`@@ -114,10 +118,15 @@ export default class TeamEnvironmentAdapter {if (result.right.team) {results.push(...result.right.team.teamEnvironments.map((x) => {+ // Keep the environment structure consistent with the new schemaconst environment = <Environment>{+ v: EnvironmentSchemaVersion,id: x.id,name: x.name,- variables: JSON.parse(x.variables),+ variables: JSON.parse(x.variables).map(+ (variable: Environment["variables"][number]) =>+ translateToNewEnvironmentVariables(variable)+ ),}const parsedEnvironment = Environment.safeParse(environment)@@ -128,10 +137,7 @@ export default class TeamEnvironmentAdapter {environment:parsedEnvironment.type === "ok"? parsedEnvironment.value- : {- ...environment,- v: EnvironmentSchemaVersion,- },+ : environment,}}))