chore: merge hoppscotch/hoppscotch/staging into hoppscotch/self-hosted/main
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { initializeApp } from "firebase/app"
|
||||
import { platform } from "~/platform"
|
||||
import { initAnalytics } from "./analytics"
|
||||
import { initCollections } from "./collections"
|
||||
import { initHistory } from "./history"
|
||||
import { initSettings } from "./settings"
|
||||
|
||||
@@ -25,7 +24,7 @@ export function initializeFirebase() {
|
||||
|
||||
platform.auth.performAuthInit()
|
||||
initSettings()
|
||||
initCollections()
|
||||
platform.sync.collections.initCollectionsSync()
|
||||
initHistory()
|
||||
platform.sync.environments.initEnvironmentsSync()
|
||||
initAnalytics()
|
||||
|
||||
3
packages/hoppscotch-common/src/platform/collections.ts
Normal file
3
packages/hoppscotch-common/src/platform/collections.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type CollectionsPlatformDef = {
|
||||
initCollectionsSync: () => void
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import { AuthPlatformDef } from "./auth"
|
||||
import { UIPlatformDef } from "./ui"
|
||||
import { EnvironmentsPlatformDef } from "./environments"
|
||||
import { CollectionsPlatformDef } from "./collections"
|
||||
|
||||
export type PlatformDef = {
|
||||
ui?: UIPlatformDef
|
||||
auth: AuthPlatformDef
|
||||
sync: {
|
||||
environments: EnvironmentsPlatformDef
|
||||
collections: CollectionsPlatformDef
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
"stream-browserify": "^3.0.0",
|
||||
"util": "^0.12.4",
|
||||
"vue": "^3.2.41",
|
||||
"workbox-window": "^6.5.4"
|
||||
"workbox-window": "^6.5.4",
|
||||
"@hoppscotch/data": "workspace:^0.4.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@intlify/vite-plugin-vue-i18n": "^6.0.1",
|
||||
|
||||
@@ -9,14 +9,22 @@ import {
|
||||
translateToNewRESTCollection,
|
||||
translateToNewGQLCollection,
|
||||
} from "@hoppscotch/data"
|
||||
import { platform } from "~/platform"
|
||||
|
||||
import { def as platformAuth } from "./firebase/auth"
|
||||
|
||||
import {
|
||||
restCollections$,
|
||||
graphqlCollections$,
|
||||
setRESTCollections,
|
||||
setGraphqlCollections,
|
||||
} from "~/newstore/collections"
|
||||
import { getSettingSubject, settingsStore } from "~/newstore/settings"
|
||||
} from "@hoppscotch/common/newstore/collections"
|
||||
|
||||
import {
|
||||
getSettingSubject,
|
||||
settingsStore,
|
||||
} from "@hoppscotch/common/newstore/settings"
|
||||
|
||||
import { CollectionsPlatformDef } from "@hoppscotch/common/platform/collections"
|
||||
|
||||
type CollectionFlags = "collectionsGraphql" | "collections"
|
||||
|
||||
@@ -40,11 +48,8 @@ let loadedRESTCollections = false
|
||||
*/
|
||||
let loadedGraphqlCollections = false
|
||||
|
||||
export async function writeCollections(
|
||||
collection: any[],
|
||||
flag: CollectionFlags
|
||||
) {
|
||||
const currentUser = platform.auth.getCurrentUser()
|
||||
async function writeCollections(collection: any[], flag: CollectionFlags) {
|
||||
const currentUser = platformAuth.getCurrentUser()
|
||||
|
||||
if (currentUser === null)
|
||||
throw new Error("User not logged in to write collections")
|
||||
@@ -68,11 +73,11 @@ export async function writeCollections(
|
||||
}
|
||||
}
|
||||
|
||||
export function initCollections() {
|
||||
const currentUser$ = platform.auth.getCurrentUserStream()
|
||||
function initCollectionsSync() {
|
||||
const currentUser$ = platformAuth.getCurrentUserStream()
|
||||
|
||||
const restCollSub = restCollections$.subscribe((collections) => {
|
||||
const currentUser = platform.auth.getCurrentUser()
|
||||
const currentUser = platformAuth.getCurrentUser()
|
||||
|
||||
if (
|
||||
loadedRESTCollections &&
|
||||
@@ -84,7 +89,7 @@ export function initCollections() {
|
||||
})
|
||||
|
||||
const gqlCollSub = graphqlCollections$.subscribe((collections) => {
|
||||
const currentUser = platform.auth.getCurrentUser()
|
||||
const currentUser = platformAuth.getCurrentUser()
|
||||
|
||||
if (
|
||||
loadedGraphqlCollections &&
|
||||
@@ -177,8 +182,12 @@ export function initCollections() {
|
||||
gqlCollSub.unsubscribe()
|
||||
currentUserSub.unsubscribe()
|
||||
|
||||
initCollections()
|
||||
initCollectionsSync()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export const def: CollectionsPlatformDef = {
|
||||
initCollectionsSync,
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
import { createHoppApp } from "@hoppscotch/common"
|
||||
import { def as authDef } from "./firebase/auth"
|
||||
import { def as envDef } from "./environments"
|
||||
import { def as collectionsDef } from "./collections"
|
||||
|
||||
createHoppApp("#app", {
|
||||
auth: authDef,
|
||||
sync: {
|
||||
environments: envDef,
|
||||
collections: collectionsDef,
|
||||
},
|
||||
})
|
||||
|
||||
65
pnpm-lock.yaml
generated
65
pnpm-lock.yaml
generated
@@ -876,6 +876,7 @@ importers:
|
||||
packages/hoppscotch-web:
|
||||
specifiers:
|
||||
'@hoppscotch/common': workspace:^
|
||||
'@hoppscotch/data': workspace:^0.4.4
|
||||
'@hoppscotch/ui': workspace:^
|
||||
'@intlify/vite-plugin-vue-i18n': ^6.0.1
|
||||
'@rushstack/eslint-patch': ^1.1.4
|
||||
@@ -913,6 +914,7 @@ importers:
|
||||
workbox-window: ^6.5.4
|
||||
dependencies:
|
||||
'@hoppscotch/common': link:../hoppscotch-common
|
||||
'@hoppscotch/data': link:../hoppscotch-data
|
||||
'@hoppscotch/ui': link:../hoppscotch-ui
|
||||
buffer: 6.0.3
|
||||
firebase: 9.8.4
|
||||
@@ -1474,11 +1476,6 @@ packages:
|
||||
engines: {node: '>=6.9.0'}
|
||||
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:
|
||||
resolution: {integrity: sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -1494,14 +1491,6 @@ packages:
|
||||
'@babel/types': 7.18.7
|
||||
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:
|
||||
resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -1670,14 +1659,6 @@ packages:
|
||||
'@babel/types': 7.20.7
|
||||
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:
|
||||
resolution: {integrity: sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -2623,24 +2604,6 @@ packages:
|
||||
- supports-color
|
||||
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:
|
||||
resolution: {integrity: sha512-QG3yxTcTIBoAcQmkCs+wAPYZhu7Dk9rXKacINfNbdJDNERTbLQbHGyVG8q/YGMPeCJRIhSY0+fTc5+xuh6WPSQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -5142,8 +5105,8 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@intlify/bundle-utils/5.0.1:
|
||||
resolution: {integrity: sha512-qF6reZHDm+h7jUId2npzwNZYCvrUcr0bAYnJXgiShKBxTFpxOq7nrqy7UrRWj8M2w4GTCJczeQZmQGFxc/GdFA==}
|
||||
/@intlify/bundle-utils/5.2.0:
|
||||
resolution: {integrity: sha512-rIfoNUTBoZK6IfaEeuoYMQZSuAXhPyZoy+UsdZj+V4eM632ynN1bGt5ttkpGO8xe0c+esfYslgJxBz//bdu4qg==}
|
||||
engines: {node: '>= 12'}
|
||||
peerDependencies:
|
||||
petite-vue-i18n: '*'
|
||||
@@ -5154,19 +5117,17 @@ packages:
|
||||
vue-i18n:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@babel/parser': 7.21.2
|
||||
'@babel/traverse': 7.21.2
|
||||
'@intlify/message-compiler': 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
|
||||
source-map: 0.6.1
|
||||
yaml-eslint-parser: 0.3.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@intlify/bundle-utils/5.0.1_vue-i18n@9.2.2:
|
||||
resolution: {integrity: sha512-qF6reZHDm+h7jUId2npzwNZYCvrUcr0bAYnJXgiShKBxTFpxOq7nrqy7UrRWj8M2w4GTCJczeQZmQGFxc/GdFA==}
|
||||
/@intlify/bundle-utils/5.2.0_vue-i18n@9.2.2:
|
||||
resolution: {integrity: sha512-rIfoNUTBoZK6IfaEeuoYMQZSuAXhPyZoy+UsdZj+V4eM632ynN1bGt5ttkpGO8xe0c+esfYslgJxBz//bdu4qg==}
|
||||
engines: {node: '>= 12'}
|
||||
peerDependencies:
|
||||
petite-vue-i18n: '*'
|
||||
@@ -5177,16 +5138,14 @@ packages:
|
||||
vue-i18n:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@babel/parser': 7.21.2
|
||||
'@babel/traverse': 7.21.2
|
||||
'@intlify/message-compiler': 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
|
||||
source-map: 0.6.1
|
||||
vue-i18n: 9.2.2_vue@3.2.37
|
||||
yaml-eslint-parser: 0.3.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@intlify/core-base/9.2.2:
|
||||
@@ -5243,7 +5202,7 @@ packages:
|
||||
vue-i18n:
|
||||
optional: true
|
||||
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
|
||||
'@rollup/pluginutils': 4.2.1
|
||||
debug: 4.3.4
|
||||
@@ -5270,7 +5229,7 @@ packages:
|
||||
vue-i18n:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@intlify/bundle-utils': 5.0.1
|
||||
'@intlify/bundle-utils': 5.2.0
|
||||
'@intlify/shared': 9.3.0-beta.16
|
||||
'@rollup/pluginutils': 4.2.1
|
||||
debug: 4.3.4
|
||||
|
||||
Reference in New Issue
Block a user