From 60bfb6fe2ca7c702e054228d7f7c840ef7eddca9 Mon Sep 17 00:00:00 2001 From: James George Date: Wed, 29 Nov 2023 22:40:26 +0530 Subject: [PATCH] refactor: move persistence logic into a dedicated service (#3493) --- packages/hoppscotch-common/.eslintrc.js | 4 +- packages/hoppscotch-common/package.json | 7 +- .../src/components/app/PaneLayout.vue | 15 +- .../src/components/firebase/Login.vue | 11 +- .../src/components/graphql/RequestOptions.vue | 2 +- .../hoppscotch-common/src/helpers/oauth.ts | 39 +- packages/hoppscotch-common/src/index.ts | 24 +- .../hoppscotch-common/src/layouts/default.vue | 23 +- .../hoppscotch-common/src/modules/i18n.ts | 15 +- .../hoppscotch-common/src/modules/theming.ts | 14 +- .../src/newstore/localpersistence.ts | 457 ----- .../persistence/__tests__/__mocks__/index.ts | 208 +++ .../persistence/__tests__/index.spec.ts | 1641 +++++++++++++++++ .../src/services/persistence/index.ts | 724 ++++++++ .../persistence/validation-schemas/index.ts | 470 +++++ .../src/platform/auth.ts | 38 +- .../src/platform/auth.ts | 34 +- pnpm-lock.yaml | 100 +- 18 files changed, 3179 insertions(+), 647 deletions(-) delete mode 100644 packages/hoppscotch-common/src/newstore/localpersistence.ts create mode 100644 packages/hoppscotch-common/src/services/persistence/__tests__/__mocks__/index.ts create mode 100644 packages/hoppscotch-common/src/services/persistence/__tests__/index.spec.ts create mode 100644 packages/hoppscotch-common/src/services/persistence/index.ts create mode 100644 packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts diff --git a/packages/hoppscotch-common/.eslintrc.js b/packages/hoppscotch-common/.eslintrc.js index 6eab64c37..f7b487189 100644 --- a/packages/hoppscotch-common/.eslintrc.js +++ b/packages/hoppscotch-common/.eslintrc.js @@ -57,7 +57,7 @@ module.exports = { { name: "localStorage", message: - "Do not use 'localStorage' directly. Please use localpersistence.ts functions or stores", + "Do not use 'localStorage' directly. Please use the PersistenceService", }, ], // window.localStorage block @@ -66,7 +66,7 @@ module.exports = { { selector: "CallExpression[callee.object.property.name='localStorage']", message: - "Do not use 'localStorage' directly. Please use localpersistence.ts functions or stores", + "Do not use 'localStorage' directly. Please use the PersistenceService", }, ], }, diff --git a/packages/hoppscotch-common/package.json b/packages/hoppscotch-common/package.json index 7f4020036..a5f50a23d 100644 --- a/packages/hoppscotch-common/package.json +++ b/packages/hoppscotch-common/package.json @@ -92,6 +92,7 @@ "url": "^0.11.1", "util": "^0.12.5", "uuid": "^9.0.0", + "verzod": "^0.2.0", "vue": "^3.3.4", "vue-i18n": "^9.2.2", "vue-pdf-embed": "^1.1.6", @@ -143,19 +144,19 @@ "eslint-plugin-vue": "^9.17.0", "glob": "^10.3.10", "npm-run-all": "^4.1.5", + "openapi-types": "^12.1.3", "postcss": "^8.4.23", "prettier-plugin-tailwindcss": "^0.5.6", - "tailwindcss": "^3.3.2", - "vite-plugin-fonts": "^0.6.0", - "openapi-types": "^12.1.3", "rollup-plugin-polyfill-node": "^0.12.0", "sass": "^1.66.0", + "tailwindcss": "^3.3.2", "typescript": "^5.1.6", "unplugin-fonts": "^1.0.3", "unplugin-icons": "^0.16.5", "unplugin-vue-components": "^0.25.1", "vite": "^4.4.9", "vite-plugin-checker": "^0.6.1", + "vite-plugin-fonts": "^0.6.0", "vite-plugin-html-config": "^1.0.11", "vite-plugin-inspect": "^0.7.38", "vite-plugin-pages": "^0.31.0", diff --git a/packages/hoppscotch-common/src/components/app/PaneLayout.vue b/packages/hoppscotch-common/src/components/app/PaneLayout.vue index 837220f8f..e8b930a1c 100644 --- a/packages/hoppscotch-common/src/components/app/PaneLayout.vue +++ b/packages/hoppscotch-common/src/components/app/PaneLayout.vue @@ -47,14 +47,15 @@