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: update id while syncing and gist import bug (#5100)
Nivedin0212eba895cc
diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/hoppEnv.ts b/packages/hoppscotch-common/src/helpers/import-export/import/hoppEnv.tsindex f3f4f9b4c..914c47032 100644--- a/packages/hoppscotch-common/src/helpers/import-export/import/hoppEnv.ts+++ b/packages/hoppscotch-common/src/helpers/import-export/import/hoppEnv.ts@@ -22,12 +22,23 @@ export const hoppEnvImporter = (contents: string[]) => {return unwrappedContent.map((contentEntry) => {return {...contentEntry,- variables: contentEntry.variables?.map((valueEntry) => ({- ...valueEntry,- ...("initialValue" in valueEntry- ? { value: String(valueEntry.initialValue) }- : {}),- })),+ variables: contentEntry.variables?.map((valueEntry) => {+ if ("value" in valueEntry) {+ return {+ ...valueEntry,+ value: String(valueEntry.value),+ }+ }++ if ("initialValue" in valueEntry) {+ return {+ ...valueEntry,+ initialValue: String(valueEntry.initialValue),+ }+ }++ return valueEntry+ }),}})}diff --git a/packages/hoppscotch-data/src/environment/v/2.ts b/packages/hoppscotch-data/src/environment/v/2.tsindex cfab8e0f6..7033dc9fe 100644--- a/packages/hoppscotch-data/src/environment/v/2.ts+++ b/packages/hoppscotch-data/src/environment/v/2.ts@@ -1,4 +1,4 @@-import { boolean, z } from "zod"+import { z } from "zod"import { defineVersion } from "verzod"import { V1_SCHEMA } from "./1"@@ -23,14 +23,16 @@ export default defineVersion({...old,v: 2,variables: old.variables.map((variable) => {+ const { key, secret } = variable+// if the variable is secret, set initialValue and currentValue to empty string// else set initialValue and currentValue to value// and delete valuereturn {- ...variable,- initialValue: variable.secret ? "" : variable.value,- currentValue: variable.secret ? "" : variable.value,- value: undefined,+ key,+ secret,+ initialValue: secret ? "" : variable.value,+ currentValue: secret ? "" : variable.value,}}),}diff --git a/packages/hoppscotch-selfhost-desktop/src/platform/environments/environments.sync.ts b/packages/hoppscotch-selfhost-desktop/src/platform/environments/environments.sync.tsindex fb4094204..98e7a1031 100644--- a/packages/hoppscotch-selfhost-desktop/src/platform/environments/environments.sync.ts+++ b/packages/hoppscotch-selfhost-desktop/src/platform/environments/environments.sync.ts@@ -97,7 +97,12 @@ export const storeSyncDefinition: StoreSyncDefinitionOf<setGlobalVariables({ entries }) {const backendId = getGlobalVariableID()if (backendId) {- updateUserEnvironment(backendId, { name: "", variables: entries })()+ updateUserEnvironment(backendId, {+ name: "",+ variables: entries,+ id: "",+ v: 2,+ })()}},clearGlobalVariables() {diff --git a/packages/hoppscotch-selfhost-web/src/platform/environments/desktop/sync.ts b/packages/hoppscotch-selfhost-web/src/platform/environments/desktop/sync.tsindex 8b9023576..4ec26761d 100644--- a/packages/hoppscotch-selfhost-web/src/platform/environments/desktop/sync.ts+++ b/packages/hoppscotch-selfhost-web/src/platform/environments/desktop/sync.ts@@ -22,11 +22,13 @@ import {} from "./api"import { SecretEnvironmentService } from "@hoppscotch/common/services/secret-environment.service"import { getService } from "@hoppscotch/common/modules/dioc"+import { CurrentValueService } from "@hoppscotch/common/services/current-environment-value.service"export const environmentsMapper = createMapper<number, string>()export const globalEnvironmentMapper = createMapper<number, string>()const secretEnvironmentService = getService(SecretEnvironmentService)+const currentEnvironmentValueService = getService(CurrentValueService)export const storeSyncDefinition: StoreSyncDefinitionOf<typeof environmentsStore@@ -44,6 +46,11 @@ export const storeSyncDefinition: StoreSyncDefinitionOf<id)+ currentEnvironmentValueService.updateEnvironmentID(+ environmentsStore.value.environments[lastCreatedEnvIndex].id,+ id+ )+environmentsStore.value.environments[lastCreatedEnvIndex].id = idremoveDuplicateEntry(id)}diff --git a/packages/hoppscotch-selfhost-web/src/platform/environments/web/sync.ts b/packages/hoppscotch-selfhost-web/src/platform/environments/web/sync.tsindex 8b9023576..4ec26761d 100644--- a/packages/hoppscotch-selfhost-web/src/platform/environments/web/sync.ts+++ b/packages/hoppscotch-selfhost-web/src/platform/environments/web/sync.ts@@ -22,11 +22,13 @@ import {} from "./api"import { SecretEnvironmentService } from "@hoppscotch/common/services/secret-environment.service"import { getService } from "@hoppscotch/common/modules/dioc"+import { CurrentValueService } from "@hoppscotch/common/services/current-environment-value.service"export const environmentsMapper = createMapper<number, string>()export const globalEnvironmentMapper = createMapper<number, string>()const secretEnvironmentService = getService(SecretEnvironmentService)+const currentEnvironmentValueService = getService(CurrentValueService)export const storeSyncDefinition: StoreSyncDefinitionOf<typeof environmentsStore@@ -44,6 +46,11 @@ export const storeSyncDefinition: StoreSyncDefinitionOf<id)+ currentEnvironmentValueService.updateEnvironmentID(+ environmentsStore.value.environments[lastCreatedEnvIndex].id,+ id+ )+environmentsStore.value.environments[lastCreatedEnvIndex].id = idremoveDuplicateEntry(id)}