chore: merge hoppscotch/hoppscotch/staging into hoppscotch/self-hosted/main

This commit is contained in:
Andrew Bastin
2023-03-13 17:09:53 +05:30
7 changed files with 44 additions and 69 deletions

View File

@@ -1,7 +1,6 @@
import { initializeApp } from "firebase/app" import { initializeApp } from "firebase/app"
import { platform } from "~/platform" import { platform } from "~/platform"
import { initAnalytics } from "./analytics" import { initAnalytics } from "./analytics"
import { initCollections } from "./collections"
import { initHistory } from "./history" import { initHistory } from "./history"
import { initSettings } from "./settings" import { initSettings } from "./settings"
@@ -25,7 +24,7 @@ export function initializeFirebase() {
platform.auth.performAuthInit() platform.auth.performAuthInit()
initSettings() initSettings()
initCollections() platform.sync.collections.initCollectionsSync()
initHistory() initHistory()
platform.sync.environments.initEnvironmentsSync() platform.sync.environments.initEnvironmentsSync()
initAnalytics() initAnalytics()

View File

@@ -0,0 +1,3 @@
export type CollectionsPlatformDef = {
initCollectionsSync: () => void
}

View File

@@ -1,12 +1,14 @@
import { AuthPlatformDef } from "./auth" import { AuthPlatformDef } from "./auth"
import { UIPlatformDef } from "./ui" import { UIPlatformDef } from "./ui"
import { EnvironmentsPlatformDef } from "./environments" import { EnvironmentsPlatformDef } from "./environments"
import { CollectionsPlatformDef } from "./collections"
export type PlatformDef = { export type PlatformDef = {
ui?: UIPlatformDef ui?: UIPlatformDef
auth: AuthPlatformDef auth: AuthPlatformDef
sync: { sync: {
environments: EnvironmentsPlatformDef environments: EnvironmentsPlatformDef
collections: CollectionsPlatformDef
} }
} }

View File

@@ -28,7 +28,8 @@
"stream-browserify": "^3.0.0", "stream-browserify": "^3.0.0",
"util": "^0.12.4", "util": "^0.12.4",
"vue": "^3.2.41", "vue": "^3.2.41",
"workbox-window": "^6.5.4" "workbox-window": "^6.5.4",
"@hoppscotch/data": "workspace:^0.4.4"
}, },
"devDependencies": { "devDependencies": {
"@intlify/vite-plugin-vue-i18n": "^6.0.1", "@intlify/vite-plugin-vue-i18n": "^6.0.1",

View File

@@ -9,14 +9,22 @@ import {
translateToNewRESTCollection, translateToNewRESTCollection,
translateToNewGQLCollection, translateToNewGQLCollection,
} from "@hoppscotch/data" } from "@hoppscotch/data"
import { platform } from "~/platform"
import { def as platformAuth } from "./firebase/auth"
import { import {
restCollections$, restCollections$,
graphqlCollections$, graphqlCollections$,
setRESTCollections, setRESTCollections,
setGraphqlCollections, setGraphqlCollections,
} from "~/newstore/collections" } from "@hoppscotch/common/newstore/collections"
import { getSettingSubject, settingsStore } from "~/newstore/settings"
import {
getSettingSubject,
settingsStore,
} from "@hoppscotch/common/newstore/settings"
import { CollectionsPlatformDef } from "@hoppscotch/common/platform/collections"
type CollectionFlags = "collectionsGraphql" | "collections" type CollectionFlags = "collectionsGraphql" | "collections"
@@ -40,11 +48,8 @@ let loadedRESTCollections = false
*/ */
let loadedGraphqlCollections = false let loadedGraphqlCollections = false
export async function writeCollections( async function writeCollections(collection: any[], flag: CollectionFlags) {
collection: any[], const currentUser = platformAuth.getCurrentUser()
flag: CollectionFlags
) {
const currentUser = platform.auth.getCurrentUser()
if (currentUser === null) if (currentUser === null)
throw new Error("User not logged in to write collections") throw new Error("User not logged in to write collections")
@@ -68,11 +73,11 @@ export async function writeCollections(
} }
} }
export function initCollections() { function initCollectionsSync() {
const currentUser$ = platform.auth.getCurrentUserStream() const currentUser$ = platformAuth.getCurrentUserStream()
const restCollSub = restCollections$.subscribe((collections) => { const restCollSub = restCollections$.subscribe((collections) => {
const currentUser = platform.auth.getCurrentUser() const currentUser = platformAuth.getCurrentUser()
if ( if (
loadedRESTCollections && loadedRESTCollections &&
@@ -84,7 +89,7 @@ export function initCollections() {
}) })
const gqlCollSub = graphqlCollections$.subscribe((collections) => { const gqlCollSub = graphqlCollections$.subscribe((collections) => {
const currentUser = platform.auth.getCurrentUser() const currentUser = platformAuth.getCurrentUser()
if ( if (
loadedGraphqlCollections && loadedGraphqlCollections &&
@@ -177,8 +182,12 @@ export function initCollections() {
gqlCollSub.unsubscribe() gqlCollSub.unsubscribe()
currentUserSub.unsubscribe() currentUserSub.unsubscribe()
initCollections() initCollectionsSync()
} }
} }
) )
} }
export const def: CollectionsPlatformDef = {
initCollectionsSync,
}

View File

@@ -1,10 +1,12 @@
import { createHoppApp } from "@hoppscotch/common" import { createHoppApp } from "@hoppscotch/common"
import { def as authDef } from "./firebase/auth" import { def as authDef } from "./firebase/auth"
import { def as envDef } from "./environments" import { def as envDef } from "./environments"
import { def as collectionsDef } from "./collections"
createHoppApp("#app", { createHoppApp("#app", {
auth: authDef, auth: authDef,
sync: { sync: {
environments: envDef, environments: envDef,
collections: collectionsDef,
}, },
}) })

65
pnpm-lock.yaml generated
View File

@@ -876,6 +876,7 @@ importers:
packages/hoppscotch-web: packages/hoppscotch-web:
specifiers: specifiers:
'@hoppscotch/common': workspace:^ '@hoppscotch/common': workspace:^
'@hoppscotch/data': workspace:^0.4.4
'@hoppscotch/ui': workspace:^ '@hoppscotch/ui': workspace:^
'@intlify/vite-plugin-vue-i18n': ^6.0.1 '@intlify/vite-plugin-vue-i18n': ^6.0.1
'@rushstack/eslint-patch': ^1.1.4 '@rushstack/eslint-patch': ^1.1.4
@@ -913,6 +914,7 @@ importers:
workbox-window: ^6.5.4 workbox-window: ^6.5.4
dependencies: dependencies:
'@hoppscotch/common': link:../hoppscotch-common '@hoppscotch/common': link:../hoppscotch-common
'@hoppscotch/data': link:../hoppscotch-data
'@hoppscotch/ui': link:../hoppscotch-ui '@hoppscotch/ui': link:../hoppscotch-ui
buffer: 6.0.3 buffer: 6.0.3
firebase: 9.8.4 firebase: 9.8.4
@@ -1474,11 +1476,6 @@ packages:
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
dev: true dev: true
/@babel/helper-environment-visitor/7.18.9:
resolution: {integrity: sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==}
engines: {node: '>=6.9.0'}
dev: true
/@babel/helper-explode-assignable-expression/7.18.6: /@babel/helper-explode-assignable-expression/7.18.6:
resolution: {integrity: sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg==} resolution: {integrity: sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@@ -1494,14 +1491,6 @@ packages:
'@babel/types': 7.18.7 '@babel/types': 7.18.7
dev: true dev: true
/@babel/helper-function-name/7.21.0:
resolution: {integrity: sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/template': 7.20.7
'@babel/types': 7.21.2
dev: true
/@babel/helper-hoist-variables/7.18.6: /@babel/helper-hoist-variables/7.18.6:
resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==} resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@@ -1670,14 +1659,6 @@ packages:
'@babel/types': 7.20.7 '@babel/types': 7.20.7
dev: true dev: true
/@babel/parser/7.21.2:
resolution: {integrity: sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ==}
engines: {node: '>=6.0.0'}
hasBin: true
dependencies:
'@babel/types': 7.21.2
dev: true
/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/7.18.6_@babel+core@7.18.6: /@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/7.18.6_@babel+core@7.18.6:
resolution: {integrity: sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==} resolution: {integrity: sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@@ -2623,24 +2604,6 @@ packages:
- supports-color - supports-color
dev: true dev: true
/@babel/traverse/7.21.2:
resolution: {integrity: sha512-ts5FFU/dSUPS13tv8XiEObDu9K+iagEKME9kAbaP7r0Y9KtZJZ+NGndDvWoRAYNpeWafbpFeki3q9QoMD6gxyw==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/code-frame': 7.18.6
'@babel/generator': 7.21.1
'@babel/helper-environment-visitor': 7.18.9
'@babel/helper-function-name': 7.21.0
'@babel/helper-hoist-variables': 7.18.6
'@babel/helper-split-export-declaration': 7.18.6
'@babel/parser': 7.21.2
'@babel/types': 7.21.2
debug: 4.3.4
globals: 11.12.0
transitivePeerDependencies:
- supports-color
dev: true
/@babel/types/7.18.7: /@babel/types/7.18.7:
resolution: {integrity: sha512-QG3yxTcTIBoAcQmkCs+wAPYZhu7Dk9rXKacINfNbdJDNERTbLQbHGyVG8q/YGMPeCJRIhSY0+fTc5+xuh6WPSQ==} resolution: {integrity: sha512-QG3yxTcTIBoAcQmkCs+wAPYZhu7Dk9rXKacINfNbdJDNERTbLQbHGyVG8q/YGMPeCJRIhSY0+fTc5+xuh6WPSQ==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@@ -5142,8 +5105,8 @@ packages:
- supports-color - supports-color
dev: true dev: true
/@intlify/bundle-utils/5.0.1: /@intlify/bundle-utils/5.2.0:
resolution: {integrity: sha512-qF6reZHDm+h7jUId2npzwNZYCvrUcr0bAYnJXgiShKBxTFpxOq7nrqy7UrRWj8M2w4GTCJczeQZmQGFxc/GdFA==} resolution: {integrity: sha512-rIfoNUTBoZK6IfaEeuoYMQZSuAXhPyZoy+UsdZj+V4eM632ynN1bGt5ttkpGO8xe0c+esfYslgJxBz//bdu4qg==}
engines: {node: '>= 12'} engines: {node: '>= 12'}
peerDependencies: peerDependencies:
petite-vue-i18n: '*' petite-vue-i18n: '*'
@@ -5154,19 +5117,17 @@ packages:
vue-i18n: vue-i18n:
optional: true optional: true
dependencies: dependencies:
'@babel/parser': 7.21.2
'@babel/traverse': 7.21.2
'@intlify/message-compiler': 9.3.0-beta.16 '@intlify/message-compiler': 9.3.0-beta.16
'@intlify/shared': 9.3.0-beta.16 '@intlify/shared': 9.3.0-beta.16
acorn: 8.8.2
estree-walker: 2.0.2
jsonc-eslint-parser: 1.4.1 jsonc-eslint-parser: 1.4.1
source-map: 0.6.1 source-map: 0.6.1
yaml-eslint-parser: 0.3.2 yaml-eslint-parser: 0.3.2
transitivePeerDependencies:
- supports-color
dev: true dev: true
/@intlify/bundle-utils/5.0.1_vue-i18n@9.2.2: /@intlify/bundle-utils/5.2.0_vue-i18n@9.2.2:
resolution: {integrity: sha512-qF6reZHDm+h7jUId2npzwNZYCvrUcr0bAYnJXgiShKBxTFpxOq7nrqy7UrRWj8M2w4GTCJczeQZmQGFxc/GdFA==} resolution: {integrity: sha512-rIfoNUTBoZK6IfaEeuoYMQZSuAXhPyZoy+UsdZj+V4eM632ynN1bGt5ttkpGO8xe0c+esfYslgJxBz//bdu4qg==}
engines: {node: '>= 12'} engines: {node: '>= 12'}
peerDependencies: peerDependencies:
petite-vue-i18n: '*' petite-vue-i18n: '*'
@@ -5177,16 +5138,14 @@ packages:
vue-i18n: vue-i18n:
optional: true optional: true
dependencies: dependencies:
'@babel/parser': 7.21.2
'@babel/traverse': 7.21.2
'@intlify/message-compiler': 9.3.0-beta.16 '@intlify/message-compiler': 9.3.0-beta.16
'@intlify/shared': 9.3.0-beta.16 '@intlify/shared': 9.3.0-beta.16
acorn: 8.8.2
estree-walker: 2.0.2
jsonc-eslint-parser: 1.4.1 jsonc-eslint-parser: 1.4.1
source-map: 0.6.1 source-map: 0.6.1
vue-i18n: 9.2.2_vue@3.2.37 vue-i18n: 9.2.2_vue@3.2.37
yaml-eslint-parser: 0.3.2 yaml-eslint-parser: 0.3.2
transitivePeerDependencies:
- supports-color
dev: true dev: true
/@intlify/core-base/9.2.2: /@intlify/core-base/9.2.2:
@@ -5243,7 +5202,7 @@ packages:
vue-i18n: vue-i18n:
optional: true optional: true
dependencies: dependencies:
'@intlify/bundle-utils': 5.0.1_vue-i18n@9.2.2 '@intlify/bundle-utils': 5.2.0_vue-i18n@9.2.2
'@intlify/shared': 9.3.0-beta.16 '@intlify/shared': 9.3.0-beta.16
'@rollup/pluginutils': 4.2.1 '@rollup/pluginutils': 4.2.1
debug: 4.3.4 debug: 4.3.4
@@ -5270,7 +5229,7 @@ packages:
vue-i18n: vue-i18n:
optional: true optional: true
dependencies: dependencies:
'@intlify/bundle-utils': 5.0.1 '@intlify/bundle-utils': 5.2.0
'@intlify/shared': 9.3.0-beta.16 '@intlify/shared': 9.3.0-beta.16
'@rollup/pluginutils': 4.2.1 '@rollup/pluginutils': 4.2.1
debug: 4.3.4 debug: 4.3.4