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(persistence-service): update schemas found to differ in runtime (#3671)
James George3d25ef48d16c
diff --git a/packages/hoppscotch-common/src/services/persistence/index.ts b/packages/hoppscotch-common/src/services/persistence/index.tsindex 04575e281..04a153853 100644--- a/packages/hoppscotch-common/src/services/persistence/index.ts+++ b/packages/hoppscotch-common/src/services/persistence/index.ts@@ -244,9 +244,13 @@ export class PersistenceService extends Service {private setupSettingsPersistence() {const settingsKey = "settings"let settingsData = JSON.parse(- window.localStorage.getItem(settingsKey) || "{}"+ window.localStorage.getItem(settingsKey) ?? "null")+ if (!settingsData) {+ settingsData = getDefaultSettings()+ }+// Validate data read from localStorageconst result = SETTINGS_SCHEMA.safeParse(settingsData)if (result.success) {diff --git a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.tsindex 5a471ec85..72ca18415 100644--- a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts+++ b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts@@ -36,7 +36,7 @@ const SettingsDefSchema = z.object({httpUser: z.boolean(),httpPassword: z.boolean(),bearerToken: z.boolean(),- oauth2Token: z.boolean(),+ oauth2Token: z.optional(z.boolean()),}),THEME_COLOR: ThemeColorSchema,BG_COLOR: BgColorSchema,@@ -103,13 +103,10 @@ export const LOCAL_STATE_SCHEMA = z.union([.strict(),])-export const SETTINGS_SCHEMA = z.union([- z.object({}).strict(),- SettingsDefSchema.extend({- EXTENSIONS_ENABLED: z.optional(z.boolean()),- PROXY_ENABLED: z.optional(z.boolean()),- }),-])+export const SETTINGS_SCHEMA = SettingsDefSchema.extend({+ EXTENSIONS_ENABLED: z.optional(z.boolean()),+ PROXY_ENABLED: z.optional(z.boolean()),+})export const REST_HISTORY_ENTRY_SCHEMA = z.object({@@ -208,7 +205,7 @@ export const MQTT_REQUEST_SCHEMA = z.nullable(z.object({endpoint: z.string(),- clientID: z.string(),+ clientID: z.optional(z.string()),}).strict())