Compare commits

..

6 Commits

Author SHA1 Message Date
mirarifhasan
ca6522f370 test: fix test cases 2024-04-29 23:00:57 +06:00
mirarifhasan
872623231f refactor: remove unused imports 2024-04-29 22:37:07 +06:00
mirarifhasan
20ac35becb refactor: getTeamsOfUser function 2024-04-29 22:35:40 +06:00
mirarifhasan
5eed5ce176 refactor: getTeamMemberTE function removed 2024-04-29 22:33:11 +06:00
mirarifhasan
9694c0d373 refactor: getMembersOfTeam function improved 2024-04-29 22:29:39 +06:00
mirarifhasan
293c93cc79 chore: getTeamWithIDTE function removed 2024-04-29 22:26:00 +06:00
63 changed files with 253 additions and 305 deletions

View File

@@ -3,7 +3,9 @@
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"assets": [{ "include": "mailer/templates/**/*", "outDir": "dist" }],
"assets": [
"**/*.hbs"
],
"watchAssets": true
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "hoppscotch-backend",
"version": "2024.3.2",
"version": "2024.3.1",
"description": "",
"author": "",
"private": true,

View File

@@ -11,6 +11,7 @@ import {
EMAIL_FAILED,
INVALID_EMAIL,
ONLY_ONE_ADMIN_ACCOUNT,
TEAM_INVALID_ID,
TEAM_INVITE_ALREADY_MEMBER,
TEAM_INVITE_NO_INVITE_FOUND,
USERS_NOT_FOUND,
@@ -318,11 +319,11 @@ export class AdminService {
const user = await this.userService.findUserByEmail(userEmail);
if (O.isNone(user)) return E.left(USER_NOT_FOUND);
const teamMember = await this.teamService.getTeamMemberTE(
const teamMember = await this.teamService.getTeamMember(
teamID,
user.value.uid,
)();
if (E.isLeft(teamMember)) {
);
if (!teamMember) {
const addedUser = await this.teamService.addMemberToTeamWithEmail(
teamID,
userEmail,
@@ -590,9 +591,9 @@ export class AdminService {
* @returns an Either of `Team` or error
*/
async getTeamInfo(teamID: string) {
const team = await this.teamService.getTeamWithIDTE(teamID)();
if (E.isLeft(team)) return E.left(team.left);
return E.right(team.right);
const team = await this.teamService.getTeamWithID(teamID);
if (!team) return E.left(TEAM_INVALID_ID);
return E.right(team);
}
/**

View File

@@ -15,7 +15,11 @@ import * as TE from 'fp-ts/TaskEither';
import * as E from 'fp-ts/Either';
import * as O from 'fp-ts/Option';
import { Team, TeamMember, TeamMemberRole } from 'src/team/team.model';
import { TEAM_INVITE_NO_INVITE_FOUND, USER_NOT_FOUND } from 'src/errors';
import {
TEAM_INVALID_ID,
TEAM_INVITE_NO_INVITE_FOUND,
USER_NOT_FOUND,
} from 'src/errors';
import { GqlUser } from 'src/decorators/gql-user.decorator';
import { User } from 'src/user/user.model';
import { UseGuards } from '@nestjs/common';
@@ -50,10 +54,9 @@ export class TeamInvitationResolver {
description: 'Get the team associated to the invite',
})
async team(@Parent() teamInvitation: TeamInvitation): Promise<Team> {
return pipe(
this.teamService.getTeamWithIDTE(teamInvitation.teamID),
TE.getOrElse(throwErr),
)();
const team = await this.teamService.getTeamWithID(teamInvitation.teamID);
if (!team) throwErr(TEAM_INVALID_ID);
return team;
}
@ResolveField(() => User, {

View File

@@ -11,6 +11,7 @@ import {
} from '../errors';
import { mockDeep, mockReset } from 'jest-mock-extended';
import * as O from 'fp-ts/Option';
import { skip } from 'rxjs';
const mockPrisma = mockDeep<PrismaService>();
@@ -755,6 +756,8 @@ describe('getMembersOfTeam', () => {
expect(mockPrisma.teamMember.findMany).toHaveBeenCalledWith({
take: 10,
skip: 0,
cursor: undefined,
where: {
teamID: team.id,
},
@@ -806,6 +809,8 @@ describe('getTeamsOfUser', () => {
expect(mockPrisma.teamMember.findMany).toHaveBeenCalledWith({
take: 10,
skip: 0,
cursor: undefined,
where: {
userUid: dbTeamMember.userUid,
},

View File

@@ -15,7 +15,6 @@ import {
} from '../errors';
import { PubSubService } from '../pubsub/pubsub.service';
import { flow, pipe } from 'fp-ts/function';
import * as TE from 'fp-ts/TaskEither';
import * as TO from 'fp-ts/TaskOption';
import * as O from 'fp-ts/Option';
import * as E from 'fp-ts/Either';
@@ -264,37 +263,25 @@ export class TeamService implements UserDataHandler, OnModuleInit {
}
async getTeamsOfUser(uid: string, cursor: string | null): Promise<Team[]> {
if (!cursor) {
const entries = await this.prisma.teamMember.findMany({
take: 10,
where: {
userUid: uid,
},
include: {
team: true,
},
});
return entries.map((entry) => entry.team);
} else {
const entries = await this.prisma.teamMember.findMany({
take: 10,
skip: 1,
cursor: {
teamID_userUid: {
teamID: cursor,
userUid: uid,
},
},
where: {
userUid: uid,
},
include: {
team: true,
},
});
return entries.map((entry) => entry.team);
}
const entries = await this.prisma.teamMember.findMany({
take: 10,
skip: cursor ? 1 : 0,
cursor: cursor
? {
teamID_userUid: {
teamID: cursor,
userUid: uid,
},
}
: undefined,
where: {
userUid: uid,
},
include: {
team: true,
},
});
return entries.map((entry) => entry.team);
}
async getTeamWithID(teamID: string): Promise<Team | null> {
@@ -311,19 +298,6 @@ export class TeamService implements UserDataHandler, OnModuleInit {
}
}
getTeamWithIDTE(teamID: string): TE.TaskEither<'team/invalid_id', Team> {
return pipe(
() => this.getTeamWithID(teamID),
TE.fromTask,
TE.chain(
TE.fromPredicate(
(x): x is Team => !!x,
() => TEAM_INVALID_ID,
),
),
);
}
/**
* Filters out team members that we weren't able to match
* (also deletes the membership)
@@ -375,19 +349,6 @@ export class TeamService implements UserDataHandler, OnModuleInit {
}
}
getTeamMemberTE(teamID: string, userUid: string) {
return pipe(
() => this.getTeamMember(teamID, userUid),
TE.fromTask,
TE.chain(
TE.fromPredicate(
(x): x is TeamMember => !!x,
() => TEAM_MEMBER_NOT_FOUND,
),
),
);
}
async getRoleOfUserInTeam(
teamID: string,
userUid: string,
@@ -472,25 +433,12 @@ export class TeamService implements UserDataHandler, OnModuleInit {
): Promise<TeamMember[]> {
let teamMembers: DbTeamMember[];
if (!cursor) {
teamMembers = await this.prisma.teamMember.findMany({
take: 10,
where: {
teamID,
},
});
} else {
teamMembers = await this.prisma.teamMember.findMany({
take: 10,
skip: 1,
cursor: {
id: cursor,
},
where: {
teamID,
},
});
}
teamMembers = await this.prisma.teamMember.findMany({
take: 10,
skip: cursor ? 1 : 0,
cursor: cursor ? { id: cursor } : undefined,
where: { teamID },
});
const members = teamMembers.map(
(entry) =>

View File

@@ -374,8 +374,7 @@
"mutations": "Mutations",
"schema": "Schema",
"subscriptions": "Subscriptions",
"switch_connection": "Switch connection",
"url_placeholder": "Enter a GraphQL endpoint URL"
"switch_connection": "Switch connection"
},
"graphql_collections": {
"title": "GraphQL Collections"
@@ -599,7 +598,6 @@
"title": "Request",
"type": "Request type",
"url": "URL",
"url_placeholder": "Enter a URL or paste a cURL command",
"variables": "Variables",
"view_my_links": "View my links"
},

View File

@@ -58,6 +58,24 @@
"new": "Ajouter un nouveau",
"star": "Ajouter une étoile"
},
"cookies": {
"modal": {
"new_domain_name": "Nouveau nom de domaine",
"set": "Définir un cookie",
"cookie_string": "Chaîne de caractères de cookie",
"enter_cookie_string": "Saisir la chaîne de caractères du cookie",
"cookie_name": "Nom",
"cookie_value": "Valeur",
"cookie_path": "Chemin d'accès",
"cookie_expires": "Expiration",
"managed_tab": "Gestion",
"raw_tab": "Brut",
"interceptor_no_support": "L'intercepteur que vous avez sélectionné ne prend pas en charge les cookies. Sélectionnez un autre intercepteur et réessayez.",
"empty_domains": "La liste des domaines est vide",
"empty_domain": "Le domaine est vide",
"no_cookies_in_domain": "Aucun cookie n'est défini pour ce domaine"
}
},
"app": {
"chat_with_us": "Discuter avec nous",
"contact_us": "Nous contacter",
@@ -169,7 +187,7 @@
},
"confirm": {
"close_unsaved_tab": "Êtes-vous sûr de vouloir fermer cet onglet ?",
"close_unsaved_tabs": "Êtes-vous sûr de vouloir fermer tous les onglets ? {count} onglets non enregistrés seront perdus",
"close_unsaved_tabs": "Êtes-vous sûr de vouloir fermer tous les onglets ? {Les onglets non enregistrés seront perdus.",
"exit_team": "Êtes-vous sûr de vouloir quitter cette équipe ?",
"logout": "Êtes-vous sûr de vouloir vous déconnecter?",
"remove_collection": "Voulez-vous vraiment supprimer définitivement cette collection ?",
@@ -189,24 +207,6 @@
"open_request_in_new_tab": "Ouvrir la demande dans un nouvel onglet",
"set_environment_variable": "Définir comme variable"
},
"cookies": {
"modal": {
"new_domain_name": "Nouveau nom de domaine",
"set": "Définir un cookie",
"cookie_string": "Chaîne de caractères de cookie",
"enter_cookie_string": "Saisir la chaîne de caractères du cookie",
"cookie_name": "Nom",
"cookie_value": "Valeur",
"cookie_path": "Chemin d'accès",
"cookie_expires": "Expiration",
"managed_tab": "Gestion",
"raw_tab": "Brut",
"interceptor_no_support": "L'intercepteur que vous avez sélectionné ne prend pas en charge les cookies. Sélectionnez un autre intercepteur et réessayez.",
"empty_domains": "La liste des domaines est vide",
"empty_domain": "Le domaine est vide",
"no_cookies_in_domain": "Aucun cookie n'est défini pour ce domaine"
}
},
"count": {
"header": "En-tête {count}",
"message": "Message {compte}",
@@ -410,7 +410,7 @@
"description": "Inspecter les erreurs possibles",
"environment": {
"add_environment": "Ajouter à l'environnement",
"not_found": "La variable d'environnement “{environment}“ n'a pas été trouvée."
"not_found": "La variable d'environnement “{environnement}“ n'a pas été trouvée."
},
"header": {
"cookie": "Le navigateur ne permet pas à Hoppscotch de définir l'en-tête Cookie. Pendant que nous travaillons sur l'application de bureau Hoppscotch (bientôt disponible), veuillez utiliser l'en-tête d'autorisation à la place."

View File

@@ -1,7 +1,7 @@
{
"name": "@hoppscotch/common",
"private": true,
"version": "2024.3.2",
"version": "2024.3.1",
"scripts": {
"dev": "pnpm exec npm-run-all -p -l dev:*",
"test": "vitest --run",
@@ -50,7 +50,7 @@
"axios": "1.6.2",
"buffer": "6.0.3",
"cookie-es": "1.0.0",
"dioc": "3.0.1",
"dioc": "1.0.1",
"esprima": "4.0.1",
"events": "3.3.0",
"fp-ts": "2.16.1",

View File

@@ -32,7 +32,6 @@ declare module 'vue' {
AppSpotlightEntryRESTHistory: typeof import('./components/app/spotlight/entry/RESTHistory.vue')['default']
AppSpotlightEntryRESTRequest: typeof import('./components/app/spotlight/entry/RESTRequest.vue')['default']
AppSpotlightEntryRESTTeamRequestEntry: typeof import('./components/app/spotlight/entry/RESTTeamRequestEntry.vue')['default']
AppSpotlightSearch: typeof import('./components/app/SpotlightSearch.vue')['default']
AppSupport: typeof import('./components/app/Support.vue')['default']
Collections: typeof import('./components/collections/index.vue')['default']
CollectionsAdd: typeof import('./components/collections/Add.vue')['default']

View File

@@ -54,7 +54,9 @@
:key="tab.id"
:label="tab.label"
>
<div class="divide-y divide-dividerLight">
<div
class="divide-y divide-dividerLight rounded border border-divider"
>
<HoppSmartPlaceholder
v-if="tab.variables.length === 0"
:src="`/images/states/${colorMode.value}/blockchain.svg`"

View File

@@ -56,7 +56,9 @@
:key="tab.id"
:label="tab.label"
>
<div class="divide-y divide-dividerLight">
<div
class="divide-y divide-dividerLight rounded border border-divider"
>
<HoppSmartPlaceholder
v-if="tab.variables.length === 0"
:src="`/images/states/${colorMode.value}/blockchain.svg`"

View File

@@ -10,7 +10,7 @@
autocomplete="off"
spellcheck="false"
class="w-full rounded border border-divider bg-primaryLight px-4 py-2 text-secondaryDark"
:placeholder="`${t('graphql.url_placeholder')}`"
:placeholder="`${t('request.url')}`"
:disabled="connected"
@keyup.enter="onConnectClick"
/>

View File

@@ -54,7 +54,7 @@
>
<SmartEnvInput
v-model="tab.document.request.endpoint"
:placeholder="`${t('request.url_placeholder')}`"
:placeholder="`${t('request.url')}`"
:auto-complete-source="userHistories"
:auto-complete-env="true"
:inspection-results="tabResults"

View File

@@ -201,7 +201,7 @@ export class TeamSearchService extends Service {
expandingCollections: Ref<string[]> = ref([])
expandedCollections: Ref<string[]> = ref([])
// TODO: ideally this should return the search results / formatted results instead of directly manipulating the result set
// FUTURE-TODO: ideally this should return the search results / formatted results instead of directly manipulating the result set
// eg: do the spotlight formatting in the spotlight searcher and not here
searchTeams = async (query: string, teamID: string) => {
if (!query.length) {

View File

@@ -1,5 +1,5 @@
import { HoppModule } from "."
import { Container, ServiceClassInstance } from "dioc"
import { Container, Service } from "dioc"
import { diocPlugin } from "dioc/vue"
import { DebugService } from "~/services/debug.service"
import { platform } from "~/platform"
@@ -22,7 +22,7 @@ if (import.meta.env.DEV) {
* services. Please use `useService` if within components or try to convert your
* legacy subsystem into a service if possible.
*/
export function getService<T extends ServiceClassInstance<any>>(
export function getService<T extends typeof Service<any> & { ID: string }>(
service: T
): InstanceType<T> {
return serviceContainer.bind(service)
@@ -30,10 +30,11 @@ export function getService<T extends ServiceClassInstance<any>>(
export default <HoppModule>{
onVueAppInit(app) {
// TODO: look into this
// @ts-expect-error Something weird with Vue versions
app.use(diocPlugin, {
container: serviceContainer,
})
for (const service of platform.addedServices ?? []) {
serviceContainer.bind(service)
}

View File

@@ -8,14 +8,14 @@ import { AnalyticsPlatformDef } from "./analytics"
import { InterceptorsPlatformDef } from "./interceptors"
import { HoppModule } from "~/modules"
import { InspectorsPlatformDef } from "./inspectors"
import { ServiceClassInstance } from "dioc"
import { Service } from "dioc"
import { IOPlatformDef } from "./io"
import { SpotlightPlatformDef } from "./spotlight"
export type PlatformDef = {
ui?: UIPlatformDef
addedHoppModules?: HoppModule[]
addedServices?: Array<ServiceClassInstance<unknown>>
addedServices?: Array<typeof Service<unknown> & { ID: string }>
auth: AuthPlatformDef
analytics?: AnalyticsPlatformDef
io: IOPlatformDef

View File

@@ -1,4 +1,4 @@
import { Container, ServiceClassInstance } from "dioc"
import { Service } from "dioc"
import { Inspector } from "~/services/inspection"
/**
@@ -8,9 +8,8 @@ export type PlatformInspectorsDef = {
// We are keeping this as the only mode for now
// So that if we choose to add other modes, we can do without breaking
type: "service"
// TODO: I don't think this type is effective, we have to come up with a better impl
service: ServiceClassInstance<unknown> & {
new (c: Container): Inspector
service: typeof Service<unknown> & { ID: string } & {
new (): Service & Inspector
}
}

View File

@@ -1,13 +1,12 @@
import { Container, ServiceClassInstance } from "dioc"
import { Service } from "dioc"
import { Interceptor } from "~/services/interceptor.service"
export type PlatformInterceptorDef =
| { type: "standalone"; interceptor: Interceptor }
| {
type: "service"
// TODO: I don't think this type is effective, we have to come up with a better impl
service: ServiceClassInstance<unknown> & {
new (c: Container): Interceptor
service: typeof Service<unknown> & { ID: string } & {
new (): Service & Interceptor
}
}

View File

@@ -1,10 +1,10 @@
import { Container, ServiceClassInstance } from "dioc"
import { Service } from "dioc"
import { SpotlightSearcher } from "~/services/spotlight"
export type SpotlightPlatformDef = {
additionalSearchers?: Array<
ServiceClassInstance<unknown> & {
new (c: Container): SpotlightSearcher
typeof Service<unknown> & { ID: string } & {
new (): Service & SpotlightSearcher
}
>
}

View File

@@ -31,7 +31,9 @@ export class ExtensionInspectorService extends Service implements Inspector {
private readonly inspection = this.bind(InspectionService)
override onServiceInit() {
constructor() {
super()
this.inspection.registerInspector(this)
}

View File

@@ -133,7 +133,9 @@ export class ExtensionInterceptorService
public selectable = { type: "selectable" as const }
override onServiceInit() {
constructor() {
super()
this.listenForExtensionStatus()
}

View File

@@ -24,7 +24,9 @@ export class EnvironmentMenuService extends Service implements ContextMenu {
private readonly contextMenu = this.bind(ContextMenuService)
override onServiceInit() {
constructor() {
super()
this.contextMenu.registerMenu(this)
}

View File

@@ -41,7 +41,9 @@ export class ParameterMenuService extends Service implements ContextMenu {
private readonly contextMenu = this.bind(ContextMenuService)
override onServiceInit() {
constructor() {
super()
this.contextMenu.registerMenu(this)
}

View File

@@ -39,7 +39,9 @@ export class URLMenuService extends Service implements ContextMenu {
private readonly contextMenu = this.bind(ContextMenuService)
private readonly restTab = this.bind(RESTTabService)
override onServiceInit() {
constructor() {
super()
this.contextMenu.registerMenu(this)
}

View File

@@ -20,6 +20,10 @@ export class CookieJarService extends Service {
*/
public cookieJar = ref(new Map<string, string[]>())
constructor() {
super()
}
public parseSetCookieString(setCookieString: string) {
return setCookieParse(setCookieString)
}

View File

@@ -14,7 +14,9 @@ import { Service } from "dioc"
export class DebugService extends Service {
public static readonly ID = "DEBUG_SERVICE"
override onServiceInit() {
constructor() {
super()
console.log("DebugService is initialized...")
const container = this.getContainer()

View File

@@ -107,7 +107,9 @@ export class InspectionService extends Service {
private readonly restTab = this.bind(RESTTabService)
override onServiceInit() {
constructor() {
super()
this.initializeListeners()
}

View File

@@ -53,7 +53,9 @@ export class EnvironmentInspectorService extends Service implements Inspector {
}
)[0]
override onServiceInit() {
constructor() {
super()
this.inspection.registerInspector(this)
}

View File

@@ -22,7 +22,9 @@ export class HeaderInspectorService extends Service implements Inspector {
private readonly inspection = this.bind(InspectionService)
private readonly interceptorService = this.bind(InterceptorService)
override onServiceInit() {
constructor() {
super()
this.inspection.registerInspector(this)
}

View File

@@ -23,7 +23,9 @@ export class ResponseInspectorService extends Service implements Inspector {
private readonly inspection = this.bind(InspectionService)
override onServiceInit() {
constructor() {
super()
this.inspection.registerInspector(this)
}

View File

@@ -178,7 +178,9 @@ export class InterceptorService extends Service {
return this.interceptors.get(this.currentInterceptorID.value)
})
override onServiceInit() {
constructor() {
super()
// If the current interceptor is unselectable, select the first selectable one, else null
watch([() => this.interceptors, this.currentInterceptorID], () => {
if (!this.currentInterceptorID.value) return

View File

@@ -109,6 +109,10 @@ export class OauthAuthService extends Service {
public static readonly ID = "OAUTH_AUTH_SERVICE"
static redirectURI = `${window.location.origin}/oauth`
constructor() {
super()
}
}
export const generateRandomString = () => {

View File

@@ -89,6 +89,10 @@ export class PersistenceService extends Service {
public hoppLocalConfigStorage: StorageLike = localStorage
constructor() {
super()
}
private showErrorToast(localStorageKey: string) {
const toast = useToast()
toast.error(

View File

@@ -27,6 +27,10 @@ export class SecretEnvironmentService extends Service {
*/
public secretEnvironments = reactive(new Map<string, SecretVariable[]>())
constructor() {
super()
}
/**
* Add a new secret environment.
* @param id ID of the environment

View File

@@ -6,7 +6,6 @@ import {
import { nextTick, reactive, ref } from "vue"
import { SpotlightSearcherResult } from "../../.."
import { TestContainer } from "dioc/testing"
import { Container } from "dioc"
async function flushPromises() {
return await new Promise((r) => setTimeout(r))
@@ -33,15 +32,12 @@ describe("StaticSpotlightSearcherService", () => {
},
})
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text"],
fieldWeights: {},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
}
@@ -98,15 +94,12 @@ describe("StaticSpotlightSearcherService", () => {
},
})
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text"],
fieldWeights: {},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
}
@@ -166,15 +159,12 @@ describe("StaticSpotlightSearcherService", () => {
},
})
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text"],
fieldWeights: {},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
}
@@ -234,15 +224,12 @@ describe("StaticSpotlightSearcherService", () => {
},
})
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text"],
fieldWeights: {},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
}
@@ -298,15 +285,12 @@ describe("StaticSpotlightSearcherService", () => {
},
})
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text"],
fieldWeights: {},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
}
@@ -370,15 +354,12 @@ describe("StaticSpotlightSearcherService", () => {
},
})
// TODO: dioc > v3 does not recommend using constructors, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternate"],
fieldWeights: {},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
}

View File

@@ -1,4 +1,4 @@
import { Container, Service } from "dioc"
import { Service } from "dioc"
import {
type SpotlightSearcher,
type SpotlightSearcherResult,
@@ -67,12 +67,8 @@ export abstract class StaticSpotlightSearcherService<
private _documents: Record<string, Doc> = {}
// TODO: This pattern is no longer recommended in dioc > 3, move to something else
constructor(
c: Container,
private opts: StaticSpotlightSearcherOptions<Doc>
) {
super(c)
constructor(private opts: StaticSpotlightSearcherOptions<Doc>) {
super()
this.minisearch = new MiniSearch({
fields: opts.searchFields as string[],

View File

@@ -50,7 +50,9 @@ export class CollectionsSpotlightSearcherService
private readonly spotlight = this.bind(SpotlightService)
private readonly workspaceService = this.bind(WorkspaceService)
override onServiceInit() {
constructor() {
super()
this.spotlight.registerSearcher(this)
}

View File

@@ -26,7 +26,7 @@ import IconEdit from "~icons/lucide/edit"
import IconLayers from "~icons/lucide/layers"
import IconTrash2 from "~icons/lucide/trash-2"
import { Container, Service } from "dioc"
import { Service } from "dioc"
import * as TE from "fp-ts/TaskEither"
import { pipe } from "fp-ts/function"
import { cloneDeep } from "lodash-es"
@@ -164,18 +164,15 @@ export class EnvironmentsSpotlightSearcherService extends StaticSpotlightSearche
},
})
// TODO: This pattern is no longer recommended in dioc > 3, move to something else
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}
@@ -280,7 +277,9 @@ export class SwitchEnvSpotlightSearcherService
private readonly workspaceService = this.bind(WorkspaceService)
private teamEnvironmentList: TeamEnvironment[] = []
override onServiceInit() {
constructor() {
super()
this.spotlight.registerSearcher(this)
}

View File

@@ -15,7 +15,6 @@ import IconBook from "~icons/lucide/book"
import IconLifeBuoy from "~icons/lucide/life-buoy"
import IconZap from "~icons/lucide/zap"
import { platform } from "~/platform"
import { Container } from "dioc"
type Doc = {
text: string | string[]
@@ -90,18 +89,15 @@ export class GeneralSpotlightSearcherService extends StaticSpotlightSearcherServ
},
})
// TODO: This is not recommended as of dioc > 3. Move to onServiceInit instead
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}

View File

@@ -66,7 +66,9 @@ export class HistorySpotlightSearcherService
}
)[0]
override onServiceInit() {
constructor() {
super()
this.spotlight.registerSearcher(this)
}

View File

@@ -31,7 +31,9 @@ export class InterceptorSpotlightSearcherService
private readonly spotlight = this.bind(SpotlightService)
private interceptorService = this.bind(InterceptorService)
override onServiceInit() {
constructor() {
super()
this.spotlight.registerSearcher(this)
}

View File

@@ -8,7 +8,6 @@ import {
} from "./base/static.searcher"
import IconShare from "~icons/lucide/share"
import { Container } from "dioc"
type Doc = {
text: string
@@ -40,18 +39,15 @@ export class MiscellaneousSpotlightSearcherService extends StaticSpotlightSearch
},
})
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}

View File

@@ -8,7 +8,6 @@ import {
} from "./base/static.searcher"
import IconArrowRight from "~icons/lucide/arrow-right"
import { Container } from "dioc"
type Doc = {
text: string
@@ -62,18 +61,15 @@ export class NavigationSpotlightSearcherService extends StaticSpotlightSearcherS
private docKeys = Object.keys(this.documents)
// TODO: Constructors are no longer recommended as of dioc > 3, use onServiceInit instead
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}

View File

@@ -20,7 +20,6 @@ import IconRotateCCW from "~icons/lucide/rotate-ccw"
import IconSave from "~icons/lucide/save"
import { GQLOptionTabs } from "~/components/graphql/RequestOptions.vue"
import { RESTTabService } from "~/services/tab/rest"
import { Container } from "dioc"
type Doc = {
text: string | string[]
@@ -225,18 +224,15 @@ export class RequestSpotlightSearcherService extends StaticSpotlightSearcherServ
},
})
// TODO: Constructors are no longer recommended as of dioc > 3, use onServiceInit instead
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}

View File

@@ -9,7 +9,6 @@ import {
import IconDownload from "~icons/lucide/download"
import IconCopy from "~icons/lucide/copy"
import { Container } from "dioc"
type Doc = {
text: string
@@ -57,18 +56,15 @@ export class ResponseSpotlightSearcherService extends StaticSpotlightSearcherSer
},
})
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}

View File

@@ -15,7 +15,6 @@ import IconMonitor from "~icons/lucide/monitor"
import IconMoon from "~icons/lucide/moon"
import IconSun from "~icons/lucide/sun"
import IconCheckCircle from "~icons/lucide/check-circle"
import { Container } from "dioc"
type Doc = {
text: string | string[]
@@ -101,18 +100,15 @@ export class SettingsSpotlightSearcherService extends StaticSpotlightSearcherSer
},
})
// TODO: Constuctors are no longer recommended as of dioc > 3, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}

View File

@@ -14,7 +14,6 @@ import IconXSquare from "~icons/lucide/x-square"
import { invokeAction } from "~/helpers/actions"
import { RESTTabService } from "~/services/tab/rest"
import { GQLTabService } from "~/services/tab/graphql"
import { Container } from "dioc"
type Doc = {
text: string | string[]
@@ -90,18 +89,15 @@ export class TabSpotlightSearcherService extends StaticSpotlightSearcherService<
},
})
// TODO: Constructors are no longer recommended as of dioc > 3, use onServiceInit instead
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}

View File

@@ -39,7 +39,9 @@ export class TeamsSpotlightSearcherService
private readonly tabs = this.bind(RESTTabService)
override onServiceInit() {
constructor() {
super()
this.spotlight.registerSearcher(this)
}

View File

@@ -9,7 +9,6 @@ import { useStreamStatic } from "~/composables/stream"
import IconLogin from "~icons/lucide/log-in"
import IconLogOut from "~icons/lucide/log-out"
import { activeActions$, invokeAction } from "~/helpers/actions"
import { Container } from "dioc"
type Doc = {
text: string
@@ -60,18 +59,15 @@ export class UserSpotlightSearcherService extends StaticSpotlightSearcherService
},
})
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit(): void {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}

View File

@@ -21,7 +21,7 @@ import {
StaticSpotlightSearcherService,
} from "./base/static.searcher"
import { Container, Service } from "dioc"
import { Service } from "dioc"
import * as E from "fp-ts/Either"
import MiniSearch from "minisearch"
import IconCheckCircle from "~/components/app/spotlight/entry/IconSelected.vue"
@@ -102,18 +102,15 @@ export class WorkspaceSpotlightSearcherService extends StaticSpotlightSearcherSe
},
})
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
constructor(c: Container) {
super(c, {
constructor() {
super({
searchFields: ["text", "alternates"],
fieldWeights: {
text: 2,
alternates: 1,
},
})
}
override onServiceInit() {
this.setDocuments(this.documents)
this.spotlight.registerSearcher(this)
}
@@ -169,7 +166,9 @@ export class SwitchWorkspaceSpotlightSearcherService
private readonly spotlight = this.bind(SpotlightService)
private readonly workspaceService = this.bind(WorkspaceService)
override onServiceInit() {
constructor() {
super()
this.spotlight.registerSearcher(this)
}

View File

@@ -6,7 +6,9 @@ import { reactive } from "vue"
class MockTabService extends TabService<{ request: string }> {
public static readonly ID = "MOCK_TAB_SERVICE"
override onServiceInit() {
constructor() {
super()
this.tabMap = reactive(
new Map([
[

View File

@@ -3,15 +3,12 @@ import { getDefaultGQLRequest } from "~/helpers/graphql/default"
import { HoppGQLDocument, HoppGQLSaveContext } from "~/helpers/graphql/document"
import { TabService } from "./tab"
import { computed } from "vue"
import { Container } from "dioc"
export class GQLTabService extends TabService<HoppGQLDocument> {
public static readonly ID = "GQL_TAB_SERVICE"
// TODO: Moving this to `onServiceInit` breaks `persistableTabState`
// Figure out how to fix this
constructor(c: Container) {
super(c)
constructor() {
super()
this.tabMap.set("test", {
id: "test",

View File

@@ -3,15 +3,12 @@ import { computed } from "vue"
import { getDefaultRESTRequest } from "~/helpers/rest/default"
import { HoppRESTDocument, HoppRESTSaveContext } from "~/helpers/rest/document"
import { TabService } from "./tab"
import { Container } from "dioc"
export class RESTTabService extends TabService<HoppRESTDocument> {
public static readonly ID = "REST_TAB_SERVICE"
// TODO: Moving this to `onServiceInit` breaks `persistableTabState`
// Figure out how to fix this
constructor(c: Container) {
super(c)
constructor() {
super()
this.tabMap.set("test", {
id: "test",

View File

@@ -48,7 +48,8 @@ export class WorkspaceService extends Service<WorkspaceServiceEvent> {
-1
)
override onServiceInit() {
constructor() {
super()
// Dispose the managed team list adapter when the user logs out
// and initialize it when the user logs in
watch(

View File

@@ -1,7 +1,7 @@
{
"name": "@hoppscotch/selfhost-desktop",
"private": true,
"version": "2024.3.2",
"version": "2024.3.0",
"type": "module",
"scripts": {
"dev:vite": "vite",
@@ -23,7 +23,7 @@
"@vueuse/core": "10.5.0",
"axios": "0.21.4",
"buffer": "6.0.3",
"dioc": "3.0.1",
"dioc": "1.0.1",
"environments.api": "link:@platform/environments/environments.api",
"event": "link:@tauri-apps/api/event",
"fp-ts": "2.16.1",
@@ -78,4 +78,4 @@
"vite-plugin-vue-layouts": "0.7.0",
"vue-tsc": "1.8.8"
}
}
}

View File

@@ -1260,7 +1260,7 @@ dependencies = [
[[package]]
name = "hoppscotch-desktop"
version = "24.3.2"
version = "24.3.1"
dependencies = [
"cocoa 0.25.0",
"hex_color",

View File

@@ -1,6 +1,6 @@
[package]
name = "hoppscotch-desktop"
version = "24.3.2"
version = "24.3.0"
description = "A Tauri App"
authors = ["you"]
license = ""

View File

@@ -8,7 +8,7 @@
},
"package": {
"productName": "Hoppscotch",
"version": "24.3.2"
"version": "24.3.1"
},
"tauri": {
"allowlist": {

View File

@@ -138,6 +138,10 @@ export class NativeInterceptorService extends Service implements Interceptor {
public cookieJarService = this.bind(CookieJarService)
constructor() {
super()
}
public runRequest(req: any) {
const processedReq = preProcessRequest(req)

View File

@@ -1,7 +1,7 @@
{
"name": "@hoppscotch/selfhost-web",
"private": true,
"version": "2024.3.2",
"version": "2024.3.1",
"type": "module",
"scripts": {
"dev:vite": "vite",

View File

@@ -1,7 +1,7 @@
{
"name": "hoppscotch-sh-admin",
"private": true,
"version": "2024.3.2",
"version": "2024.3.1",
"type": "module",
"scripts": {
"dev": "pnpm exec npm-run-all -p -l dev:*",

65
pnpm-lock.yaml generated
View File

@@ -455,8 +455,8 @@ importers:
specifier: 1.0.0
version: 1.0.0
dioc:
specifier: 3.0.1
version: 3.0.1(vue@3.3.9(typescript@5.3.2))
specifier: 1.0.1
version: 1.0.1(vue@3.3.9(typescript@5.3.2))
esprima:
specifier: 4.0.1
version: 4.0.1
@@ -923,8 +923,8 @@ importers:
specifier: 6.0.3
version: 6.0.3
dioc:
specifier: 3.0.1
version: 3.0.1(vue@3.3.9(typescript@4.9.5))
specifier: 1.0.1
version: 1.0.1(vue@3.3.9(typescript@4.9.5))
environments.api:
specifier: link:@platform/environments/environments.api
version: link:@platform/environments/environments.api
@@ -3511,10 +3511,6 @@ packages:
resolution: {integrity: sha512-4ttr/FNO29w+kBbU7HZ/U0Lzuh2cRDhP8UlWOtV9ERcjHzuyXVZmjyleESK6eVP60tGC9QtQW9yZE+JeRhDHkg==}
engines: {node: '>= 14'}
'@intlify/message-compiler@10.0.0-alpha.2':
resolution: {integrity: sha512-OGwttsMwB2BUzhZLraoAfAqcza5UyLMEU013ort3LbmdE6ke/pFONFyxjNQdmFWzW2K868AIVgwx4zo8lbmhjg==}
engines: {node: '>= 16'}
'@intlify/message-compiler@9.2.2':
resolution: {integrity: sha512-IUrQW7byAKN2fMBe8z6sK6riG1pue95e5jfokn8hA5Q3Bqy4MBJ5lJAofUsawQJYHeoPJ7svMDyBaVJ4d0GTtA==}
engines: {node: '>= 14'}
@@ -3523,12 +3519,12 @@ packages:
resolution: {integrity: sha512-hwqQXyTnDzAVZ300SU31jO0+3OJbpOdfVU6iBkrmNpS7t2HRnVACo0EwcEXzJa++4EVDreqz5OeqJbt+PeSGGA==}
engines: {node: '>= 16'}
'@intlify/message-compiler@9.8.0':
resolution: {integrity: sha512-McnYWhcoYmDJvssVu6QGR0shqlkJuL1HHdi5lK7fNqvQqRYaQ4lSLjYmZxwc8tRNMdIe9/KUKfyPxU9M6yCtNQ==}
'@intlify/message-compiler@9.4.1':
resolution: {integrity: sha512-aN2N+dUx320108QhH51Ycd2LEpZ+NKbzyQ2kjjhqMcxhHdxtOnkgdx+MDBhOy/CObwBmhC3Nygzc6hNlfKvPNw==}
engines: {node: '>= 16'}
'@intlify/shared@10.0.0-alpha.2':
resolution: {integrity: sha512-pWlpsC3IqkDuIH/5bNlyyiUbAXYymeNXkznORzPWT3qpAe8MazPOm14wMHGn/wESCdB5b9txQson4+CH0ym1hQ==}
'@intlify/message-compiler@9.8.0':
resolution: {integrity: sha512-McnYWhcoYmDJvssVu6QGR0shqlkJuL1HHdi5lK7fNqvQqRYaQ4lSLjYmZxwc8tRNMdIe9/KUKfyPxU9M6yCtNQ==}
engines: {node: '>= 16'}
'@intlify/shared@9.2.2':
@@ -3539,6 +3535,10 @@ packages:
resolution: {integrity: sha512-RucSPqh8O9FFxlYUysQTerSw0b9HIRpyoN1Zjogpm0qLiHK+lBNSa5sh1nCJ4wSsNcjphzgpLQCyR60GZlRV8g==}
engines: {node: '>= 16'}
'@intlify/shared@9.4.1':
resolution: {integrity: sha512-A51elBmZWf1FS80inf/32diO9DeXoqg9GR9aUDHFcfHoNDuT46Q+fpPOdj8jiJnSHSBh8E1E+6qWRhAZXdK3Ng==}
engines: {node: '>= 16'}
'@intlify/shared@9.8.0':
resolution: {integrity: sha512-TmgR0RCLjzrSo+W3wT0ALf9851iFMlVI9EYNGeWvZFUQTAJx0bvfsMlPdgVtV1tDNRiAfhkFsMKu6jtUY1ZLKQ==}
engines: {node: '>= 16'}
@@ -6457,8 +6457,8 @@ packages:
resolution: {integrity: sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==}
engines: {node: '>=0.3.1'}
dioc@3.0.1:
resolution: {integrity: sha512-LawhI08/B5f5sA6zqrNdtZY9URCjIzmebKVZhmR8lH05HFlx/spAoz4kJ7x1E6pRf/kvWsePSkudv18OR5FT6Q==}
dioc@1.0.1:
resolution: {integrity: sha512-G3T8ThO2WehWJFrKp687wpXU//WLueJA6t5L7yirhWN/jn7BFNRKwskbJn0LEEd6gqI6rwiQE48f2Zqt5jvYVw==}
peerDependencies:
vue: 3.3.9
peerDependenciesMeta:
@@ -9163,8 +9163,8 @@ packages:
no-case@3.0.4:
resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==}
node-abi@3.57.0:
resolution: {integrity: sha512-Dp+A9JWxRaKuHP35H77I4kCKesDy5HUDEmScia2FyncMTOXASMyg251F5PhFoDA5uqBrDDffiLpbqnrZmNXW+g==}
node-abi@3.60.0:
resolution: {integrity: sha512-zcGgwoXbzw9NczqbGzAWL/ToDYAxv1V8gL1D67ClbdkIfeeDBbY0GelZtC25ayLvVjr2q2cloHeQV1R0QAWqRQ==}
engines: {node: '>=10'}
node-abort-controller@3.1.1:
@@ -12132,7 +12132,6 @@ packages:
workbox-google-analytics@7.0.0:
resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==}
deprecated: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained
workbox-navigation-preload@7.0.0:
resolution: {integrity: sha512-juWCSrxo/fiMz3RsvDspeSLGmbgC0U9tKqcUPZBCf35s64wlaLXyn2KdHHXVQrb2cqF7I0Hc9siQalainmnXJA==}
@@ -15445,8 +15444,8 @@ snapshots:
'@intlify/bundle-utils@3.4.0(vue-i18n@9.8.0(vue@3.3.9(typescript@5.3.2)))':
dependencies:
'@intlify/message-compiler': 10.0.0-alpha.2
'@intlify/shared': 10.0.0-alpha.2
'@intlify/message-compiler': 9.4.1
'@intlify/shared': 9.4.1
jsonc-eslint-parser: 1.4.1
source-map: 0.6.1
yaml-eslint-parser: 0.3.2
@@ -15499,11 +15498,6 @@ snapshots:
dependencies:
'@intlify/shared': 9.2.2
'@intlify/message-compiler@10.0.0-alpha.2':
dependencies:
'@intlify/shared': 10.0.0-alpha.2
source-map-js: 1.0.2
'@intlify/message-compiler@9.2.2':
dependencies:
'@intlify/shared': 9.2.2
@@ -15514,17 +15508,22 @@ snapshots:
'@intlify/shared': 9.3.0-beta.20
source-map-js: 1.0.2
'@intlify/message-compiler@9.4.1':
dependencies:
'@intlify/shared': 9.4.1
source-map-js: 1.0.2
'@intlify/message-compiler@9.8.0':
dependencies:
'@intlify/shared': 9.8.0
source-map-js: 1.0.2
'@intlify/shared@10.0.0-alpha.2': {}
'@intlify/shared@9.2.2': {}
'@intlify/shared@9.3.0-beta.20': {}
'@intlify/shared@9.4.1': {}
'@intlify/shared@9.8.0': {}
'@intlify/unplugin-vue-i18n@1.2.0(rollup@3.29.4)(vue-i18n@9.2.2(vue@3.3.9(typescript@4.9.3)))':
@@ -15550,7 +15549,7 @@ snapshots:
'@intlify/vite-plugin-vue-i18n@6.0.1(vite@4.5.0(@types/node@18.18.8)(sass@1.69.5)(terser@5.27.0))(vue-i18n@9.8.0(vue@3.3.9(typescript@4.9.5)))':
dependencies:
'@intlify/bundle-utils': 7.0.0(vue-i18n@9.8.0(vue@3.3.9(typescript@4.9.5)))
'@intlify/shared': 10.0.0-alpha.2
'@intlify/shared': 9.4.1
'@rollup/pluginutils': 4.2.1
debug: 4.3.4(supports-color@9.2.2)
fast-glob: 3.3.2
@@ -15564,7 +15563,7 @@ snapshots:
'@intlify/vite-plugin-vue-i18n@7.0.0(vite@4.5.0(@types/node@18.18.8)(sass@1.69.5)(terser@5.27.0))(vue-i18n@9.8.0(vue@3.3.9(typescript@5.3.2)))':
dependencies:
'@intlify/bundle-utils': 3.4.0(vue-i18n@9.8.0(vue@3.3.9(typescript@5.3.2)))
'@intlify/shared': 10.0.0-alpha.2
'@intlify/shared': 9.4.1
'@rollup/pluginutils': 4.2.1
debug: 4.3.4(supports-color@9.2.2)
fast-glob: 3.3.2
@@ -16674,7 +16673,7 @@ snapshots:
'@types/graceful-fs@4.1.5':
dependencies:
'@types/node': 17.0.45
'@types/node': 18.18.8
'@types/har-format@1.2.15': {}
@@ -19341,13 +19340,13 @@ snapshots:
diff@5.0.0: {}
dioc@3.0.1(vue@3.3.9(typescript@4.9.5)):
dioc@1.0.1(vue@3.3.9(typescript@4.9.5)):
dependencies:
rxjs: 7.8.1
optionalDependencies:
vue: 3.3.9(typescript@4.9.5)
dioc@3.0.1(vue@3.3.9(typescript@5.3.2)):
dioc@1.0.1(vue@3.3.9(typescript@5.3.2)):
dependencies:
rxjs: 7.8.1
optionalDependencies:
@@ -23233,7 +23232,7 @@ snapshots:
lower-case: 2.0.2
tslib: 2.6.2
node-abi@3.57.0:
node-abi@3.60.0:
dependencies:
semver: 7.6.0
@@ -23809,7 +23808,7 @@ snapshots:
minimist: 1.2.6
mkdirp-classic: 0.5.3
napi-build-utils: 1.0.2
node-abi: 3.57.0
node-abi: 3.60.0
pump: 3.0.0
rc: 1.2.8
simple-get: 4.0.1