refactor: cleanup sync logic and imports (#5428)

This commit is contained in:
Prit Rojivadiya 2025-10-08 13:31:29 +05:30 committed by GitHub
parent bb8b9cec8f
commit c31f74829d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 71 additions and 110 deletions

View file

@ -1,5 +1,4 @@
import { OnModuleInit } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { OnModuleInit, Injectable } from '@nestjs/common';
import { PubSub as LocalPubSub } from 'graphql-subscriptions';
import { TopicDef } from './topicsDefs';

View file

@ -27,6 +27,7 @@ import {
escapeSqlLikeString,
isValidLength,
transformCollectionData,
stringToJson
} from 'src/utils';
import * as E from 'fp-ts/Either';
import * as O from 'fp-ts/Option';
@ -36,7 +37,6 @@ import {
TeamRequest,
} from '@prisma/client';
import { CollectionFolder } from 'src/types/CollectionFolder';
import { stringToJson } from 'src/utils';
import { CollectionSearchNode } from 'src/types/CollectionSearchNode';
import {
GetCollectionResponse,

View file

@ -12,9 +12,9 @@ import {
USERS_NOT_FOUND,
USER_NOT_FOUND,
USER_SHORT_DISPLAY_NAME,
USER_UPDATE_FAILED
} from 'src/errors';
import { SessionType, User } from './user.model';
import { USER_UPDATE_FAILED } from 'src/errors';
import { PubSubService } from 'src/pubsub/pubsub.service';
import { encrypt, stringToJson, taskEitherValidateArraySeq } from 'src/utils';
import { UserDataHandler } from './user.data.handler';

View file

@ -8,6 +8,7 @@ import {
parseTemplateStringE,
generateJWTToken,
HoppCollectionVariable,
calculateHawkHeader
} from "@hoppscotch/data";
import { runPreRequestScript } from "@hoppscotch/js-sandbox/node";
import * as A from "fp-ts/Array";
@ -34,8 +35,6 @@ import {
generateDigestAuthHeader,
} from "./auth/digest";
import { calculateHawkHeader } from "@hoppscotch/data";
/**
* Runs pre-request-script runner over given request which extracts set ENVs and
* applies them on current request to generate updated request.

View file

@ -2,14 +2,13 @@
* For example, sending a request.
*/
import { Ref, onBeforeUnmount, onMounted, reactive, watch } from "vue"
import { Ref, onBeforeUnmount, onMounted, reactive, watch, computed } from "vue"
import { BehaviorSubject } from "rxjs"
import { HoppRequestDocument } from "./rest/document"
import { Environment, HoppGQLRequest, HoppRESTRequest } from "@hoppscotch/data"
import { RESTOptionTabs } from "~/components/http/RequestOptions.vue"
import { HoppGQLSaveContext } from "./graphql/document"
import { GQLOptionTabs } from "~/components/graphql/RequestOptions.vue"
import { computed } from "vue"
import { getKernelMode } from "@hoppscotch/kernel"
import { invoke } from "@tauri-apps/api/core"

View file

@ -4,14 +4,14 @@ import {
getDefaultGQLRequest,
getDefaultRESTRequest,
translateToNewRESTCollection,
HoppGQLRequest,
translateToNewGQLCollection
} from "@hoppscotch/data"
import * as A from "fp-ts/Array"
import * as O from "fp-ts/Option"
import * as RA from "fp-ts/ReadonlyArray"
import * as TE from "fp-ts/TaskEither"
import { flow, pipe } from "fp-ts/function"
import { HoppGQLRequest, translateToNewGQLCollection } from "@hoppscotch/data"
import { safeParseJSON } from "~/helpers/functional/json"
import { IMPORTER_INVALID_FILE_FORMAT } from "."

View file

@ -8,11 +8,11 @@ import {
HoppRESTHeaders,
HoppRESTRequest,
makeCollection,
GQLHeader
} from "@hoppscotch/data"
import { cloneDeep } from "lodash-es"
import { pluck } from "rxjs/operators"
import { resolveSaveContextOnRequestReorder } from "~/helpers/collection/request"
import { GQLHeader } from "@hoppscotch/data"
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
import { getService } from "~/modules/dioc"
import { getI18n } from "~/modules/i18n"

View file

@ -6,9 +6,8 @@ import {
} from "~/services/inspection"
import { getI18n } from "~/modules/i18n"
import { HoppRESTRequest } from "@hoppscotch/data"
import { computed, markRaw } from "vue"
import { computed, markRaw, Ref } from "vue"
import IconAlertTriangle from "~icons/lucide/alert-triangle"
import { Ref } from "vue"
import { InterceptorService } from "~/services/interceptor.service"
import { ExtensionInterceptorService } from "~/platform/std/interceptors/extension"

View file

@ -1,9 +1,8 @@
import { Interceptor, RequestRunResult } from "~/services/interceptor.service"
import { AxiosRequestConfig, CancelToken } from "axios"
import axios, { AxiosRequestConfig, CancelToken } from "axios"
import * as E from "fp-ts/Either"
import { preProcessRequest } from "./helpers"
import { v4 } from "uuid"
import axios from "axios"
import { settingsStore } from "~/newstore/settings"
import { decodeB64StringToArrayBuffer } from "~/helpers/utils/b64"
import SettingsProxy from "~/components/settings/Proxy.vue"

View file

@ -1,6 +1,12 @@
import { Service } from "dioc"
import { markRaw } from "vue"
import { body, relayRequestToNativeAdapter } from "@hoppscotch/kernel"
import {
body,
relayRequestToNativeAdapter,
RelayRequest,
RelayResponse,
RelayCapabilities
} from "@hoppscotch/kernel"
import * as E from "fp-ts/Either"
import { pipe } from "fp-ts/function"
import axios, { CancelTokenSource } from "axios"
@ -8,11 +14,6 @@ import {
postProcessRelayRequest,
preProcessRelayRequest,
} from "~/helpers/functional/process-request"
import {
RelayRequest,
RelayResponse,
RelayCapabilities,
} from "@hoppscotch/kernel"
import type { getI18n } from "~/modules/i18n"
import {
KernelInterceptor,

View file

@ -1,8 +1,6 @@
import { Container, Service } from "dioc"
import { cloneDeep } from "lodash-es"
import { nextTick } from "vue"
import { watch } from "vue"
import { reactive, computed } from "vue"
import { reactive, computed, watch, nextTick } from "vue"
/**
* Defines a environment variable.

View file

@ -4,8 +4,7 @@ import {
} from "@hoppscotch/data"
import { refDebounced } from "@vueuse/core"
import { Service } from "dioc"
import { computed, markRaw, reactive } from "vue"
import { Component, Ref, ref, watch } from "vue"
import { Component, Ref, ref, watch, computed, markRaw, reactive } from "vue"
import { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse"
import { RESTTabService } from "../tab/rest"
/**

View file

@ -6,7 +6,7 @@ import {
InspectorResult,
} from ".."
import { Service } from "dioc"
import { Ref, markRaw } from "vue"
import { Ref, markRaw, computed } from "vue"
import IconPlusCircle from "~icons/lucide/plus-circle"
import {
HoppRESTRequest,
@ -19,7 +19,6 @@ import {
getSelectedEnvironmentType,
} from "~/newstore/environments"
import { invokeAction } from "~/helpers/actions"
import { computed } from "vue"
import { useStreamStatic } from "~/composables/stream"
import { SecretEnvironmentService } from "~/services/secret-environment.service"
import { RESTTabService } from "~/services/tab/rest"

View file

@ -5,11 +5,9 @@ import {
HoppRESTRequest,
HoppRESTResponseOriginalRequest,
} from "@hoppscotch/data"
import { markRaw } from "vue"
import IconAlertTriangle from "~icons/lucide/alert-triangle"
import { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse"
import { Ref } from "vue"
import { computed } from "vue"
import { computed, Ref, markRaw } from "vue"
/**
* This inspector is responsible for inspecting the response of a request.

View file

@ -5,7 +5,7 @@ import { z } from "zod"
import { Service } from "dioc"
import { StorageLike, watchDebounced } from "@vueuse/core"
import { assign, clone, isEmpty } from "lodash-es"
import { assign, clone, isEmpty, cloneDeep } from "lodash-es"
import {
GlobalEnvironmentVariable,
@ -98,7 +98,6 @@ import {
CurrentValueService,
Variable,
} from "../current-environment-value.service"
import { cloneDeep } from "lodash-es"
import { fixBrokenRequestVersion } from "~/helpers/fixBrokenRequestVersion"
import { fixBrokenEnvironmentVersion } from "~/helpers/fixBrokenEnvironmentVersion"
import {

View file

@ -1,6 +1,5 @@
import { Container, Service } from "dioc"
import { nextTick } from "vue"
import { reactive, computed, watch } from "vue"
import { reactive, computed, watch, nextTick } from "vue"
/**
* Defines a secret environment variable.

View file

@ -6,8 +6,10 @@ import {
HoppRESTAuthNone,
} from "../1"
import { HoppRESTAuthAPIKey } from "../4"
import { AuthCodeGrantTypeParams as AuthCodeGrantTypeParamsOld } from "../7"
import { HoppRESTAuthAWSSignature } from "../7"
import {
AuthCodeGrantTypeParams as AuthCodeGrantTypeParamsOld,
HoppRESTAuthAWSSignature,
} from "../7"
import {
HoppRESTAuthDigest,
PasswordGrantTypeParams as PasswordGrantTypeParamsOld,

View file

@ -15,9 +15,8 @@ import {
HoppRESTRequest,
} from "@hoppscotch/data"
import { getSyncInitFunction } from "../../lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "../../lib/sync"
import { StoreSyncDefinitionOf } from "../../lib/sync"
import { createMapper } from "../../lib/sync/mapper"
import {
createRESTChildUserCollection,
@ -144,13 +143,11 @@ const recursivelySyncCollections = async (
// create the requests
if (parentCollectionID) {
collection.requests.forEach(async (request) => {
const res =
parentCollectionID &&
(await createRESTUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
))
const res = await createRESTUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
)
if (res && E.isRight(res)) {
const requestId = res.right.createRESTUserRequest.id

View file

@ -14,9 +14,8 @@ import {
HoppRESTRequest,
} from "@hoppscotch/data"
import { getSyncInitFunction } from "../../lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "../../lib/sync"
import { StoreSyncDefinitionOf } from "../../lib/sync"
import { createMapper } from "../../lib/sync/mapper"
import {
createGQLChildUserCollection,
@ -165,13 +164,11 @@ const recursivelySyncCollections = async (
// create the requests
if (parentCollectionID) {
collection.requests.forEach(async (request) => {
const res =
parentCollectionID &&
(await createGQLUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
))
const res = await createGQLUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
)
if (res && E.isRight(res)) {
const requestId = res.right.createGQLUserRequest.id

View file

@ -8,11 +8,10 @@ import {
settingsStore,
} from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "../../lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "../../lib/sync"
import * as E from "fp-ts/Either"
import { StoreSyncDefinitionOf } from "../../lib/sync"
import { createMapper } from "../../lib/sync/mapper"
import {
clearGlobalEnvironmentVariables,

View file

@ -9,11 +9,10 @@ import {
settingsStore,
} from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "../../lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "../../lib/sync"
import * as E from "fp-ts/Either"
import { StoreSyncDefinitionOf } from "../../lib/sync"
import {
createUserHistory,
deleteAllUserHistory,

View file

@ -1,8 +1,5 @@
import { settingsStore } from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "../../lib/sync"
import { StoreSyncDefinitionOf } from "../../lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "../../lib/sync"
import { updateUserSettings } from "./settings.api"

View file

@ -14,9 +14,8 @@ import {
HoppRESTRequest,
} from "@hoppscotch/data"
import { getSyncInitFunction } from "@lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "@lib/sync"
import { StoreSyncDefinitionOf } from "@lib/sync"
import { createMapper } from "@lib/sync/mapper"
import {
createGQLChildUserCollection,
@ -164,13 +163,11 @@ const recursivelySyncCollections = async (
// create the requests
if (parentCollectionID) {
collection.requests.forEach(async (request) => {
const res =
parentCollectionID &&
(await createGQLUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
))
const res = await createGQLUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
)
if (res && E.isRight(res)) {
const requestId = res.right.createGQLUserRequest.id

View file

@ -160,13 +160,11 @@ const recursivelySyncCollections = async (
// create the requests
if (parentCollectionID) {
collection.requests.forEach(async (request) => {
const res =
parentCollectionID &&
(await createRESTUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
))
const res = await createRESTUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
)
if (res && E.isRight(res)) {
const requestId = res.right.createRESTUserRequest.id

View file

@ -14,9 +14,8 @@ import {
HoppRESTRequest,
} from "@hoppscotch/data"
import { getSyncInitFunction } from "@lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "@lib/sync"
import { StoreSyncDefinitionOf } from "@lib/sync"
import { createMapper } from "@lib/sync/mapper"
import {
createGQLChildUserCollection,
@ -164,13 +163,11 @@ const recursivelySyncCollections = async (
// create the requests
if (parentCollectionID) {
collection.requests.forEach(async (request) => {
const res =
parentCollectionID &&
(await createGQLUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
))
const res = await createGQLUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
)
if (res && E.isRight(res)) {
const requestId = res.right.createGQLUserRequest.id

View file

@ -163,13 +163,11 @@ const recursivelySyncCollections = async (
// create the requests
if (parentCollectionID) {
collection.requests.forEach(async (request) => {
const res =
parentCollectionID &&
(await createRESTUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
))
const res = await createRESTUserRequest(
request.name,
JSON.stringify(request),
parentCollectionID
)
if (res && E.isRight(res)) {
const requestId = res.right.createRESTUserRequest.id

View file

@ -8,11 +8,10 @@ import {
settingsStore,
} from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "@lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "@lib/sync"
import * as E from "fp-ts/Either"
import { StoreSyncDefinitionOf } from "@lib/sync"
import { createMapper } from "@lib/sync/mapper"
import {
clearGlobalEnvironmentVariables,

View file

@ -8,11 +8,10 @@ import {
settingsStore,
} from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "@lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "@lib/sync"
import * as E from "fp-ts/Either"
import { StoreSyncDefinitionOf } from "@lib/sync"
import { createMapper } from "@lib/sync/mapper"
import {
clearGlobalEnvironmentVariables,

View file

@ -9,11 +9,10 @@ import {
settingsStore,
} from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "@lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "@lib/sync"
import * as E from "fp-ts/Either"
import { StoreSyncDefinitionOf } from "@lib/sync"
import {
createUserHistory,
deleteAllUserHistory,

View file

@ -9,11 +9,10 @@ import {
settingsStore,
} from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "@lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "@lib/sync"
import * as E from "fp-ts/Either"
import { StoreSyncDefinitionOf } from "@lib/sync"
import {
createUserHistory,
deleteAllUserHistory,

View file

@ -1,8 +1,6 @@
import { settingsStore } from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "@lib/sync"
import { StoreSyncDefinitionOf } from "@lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "@lib/sync"
import { updateUserSettings } from "./api"

View file

@ -1,8 +1,6 @@
import { settingsStore } from "@hoppscotch/common/newstore/settings"
import { getSyncInitFunction } from "@lib/sync"
import { StoreSyncDefinitionOf } from "@lib/sync"
import { getSyncInitFunction, type StoreSyncDefinitionOf } from "@lib/sync"
import { updateUserSettings } from "./api"

View file

@ -67,7 +67,7 @@ export const handleUserDeletion = (deletedUsersList: UserDeletionResult[]) => {
// Indicates the actual count of users deleted (filtered via the `isDeleted` field)
const deletedUsersCount = deletedUserIDs.length;
if (isBulkAction && deletedUsersCount > 0) {
if (deletedUsersCount > 0) {
toastMessages.push({
message: t('state.delete_some_users_success', {
count: deletedUsersCount,