Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Merge remote-tracking branch 'origin/main' into feat/user-history

ankitsridhar16f7070dd3f753
diff --cc packages/hoppscotch-backend/prisma/schema.prisma
index bf9b68236,0d6e7c56d..1ec28dc6e
--- a/packages/hoppscotch-backend/prisma/schema.prisma
+++ b/packages/hoppscotch-backend/prisma/schema.prisma
@@@ -79,27 -79,20 +79,42 @@@ model TeamEnvironment
}
model User {
+ uid String @id @default(cuid())
+ displayName String?
+ email String?
+ photoURL String?
+ UserHistory UserHistory[]
++ UserEnvironments UserEnvironment[]
+}
+
+model UserHistory {
+ id String @id @default(cuid())
+ userUid String
+ user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
+ type ReqType
+ request Json
+ responseMetadata Json
+ isStarred Boolean
+ executedOn DateTime @default(now()) @db.Timestamp(3)
+}
+
+enum ReqType {
+ REST
+ GQL
+ uid String @id @default(cuid())
+ displayName String?
+ email String?
+ photoURL String?
+ UserEnvironments UserEnvironment[]
+ }
+
+ model UserEnvironment {
+ id String @id @default(cuid())
+ userUid String
+ user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
+ name String?
+ variables Json
+ isGlobal Boolean
}
enum TeamMemberRole {
diff --cc packages/hoppscotch-backend/src/app.module.ts
index 2a82e76c8,b9281e55d..bd6b8d47a
--- a/packages/hoppscotch-backend/src/app.module.ts
+++ b/packages/hoppscotch-backend/src/app.module.ts
@@@ -3,7 -3,7 +3,8 @@@ import { GraphQLModule } from '@nestjs/
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { UserModule } from './user/user.module';
import { GQLComplexityPlugin } from './plugins/GQLComplexityPlugin';
+ import { UserEnvironmentsModule } from './user-environment/user-environments.module';
+import { UserHistoryModule } from './user-history/user-history.module';
@Module({
imports: [
@@@ -45,7 -45,7 +46,8 @@@
driver: ApolloDriver,
}),
UserModule,
+ UserEnvironmentsModule,
+ UserHistoryModule,
],
providers: [GQLComplexityPlugin],
})
diff --cc packages/hoppscotch-backend/src/errors.ts
index e856fdc01,a03e437c2..c52f3af85
--- a/packages/hoppscotch-backend/src/errors.ts
+++ b/packages/hoppscotch-backend/src/errors.ts
@@@ -155,25 -161,62 +161,79 @@@ export const TEAM_ENVIRONMMENT_NOT_FOUN
export const TEAM_ENVIRONMENT_NOT_TEAM_MEMBER =
'team_environment/not_team_member' as const;
+ /**
+ * Global environment doesnt exists for the user
+ * (UserEnvironmentsService)
+ */
+ export const USER_ENVIRONMENT_GLOBAL_ENV_DOES_NOT_EXISTS =
+ 'user_environment/global_env_does_not_exists' as const;
+ /*
+
+ /**
+ * Global environment already exists for the user
+ * (UserEnvironmentsService)
+ */
+ export const USER_ENVIRONMENT_GLOBAL_ENV_EXISTS =
+ 'user_environment/global_env_already_exists' as const;
+ /*
+
+ /**
+ * User environment doesn't exist for the user
+ * (UserEnvironmentsService)
+ */
+ export const USER_ENVIRONMENT_ENV_DOES_NOT_EXISTS =
+ 'user_environment/user_env_does_not_exists' as const;
+ /*
+
+ /**
+ * Cannot delete the global user environment
+ * (UserEnvironmentsService)
+ */
+ export const USER_ENVIRONMENT_GLOBAL_ENV_DELETION_FAILED =
+ 'user_environment/user_env_global_env_deletion_failed' as const;
+ /*
+
+ /**
+ * User environment is not a global environment
+ * (UserEnvironmentsService)
+ */
+ export const USER_ENVIRONMENT_IS_NOT_GLOBAL =
+ 'user_environment/user_env_is_not_global' as const;
+ /*
+
+ /**
+ * User environment update failed
+ * (UserEnvironmentsService)
+ */
+ export const USER_ENVIRONMENT_UPDATE_FAILED =
+ 'user_environment/user_env_update_failed' as const;
+ /*
+
+ /**
+ * User environment invalid environment name
+ * (UserEnvironmentsService)
+ */
+ export const USER_ENVIRONMENT_INVALID_ENVIRONMENT_NAME =
+ 'user_environment/user_env_invalid_env_name' as const;
/*
+/**
+ * User history not found
+ * (UserHistoryService)
+ */
+export const USER_HISTORY_NOT_FOUND = 'user_history/history_not_found' as const;
+
+/*
+
+/**
+ * Invalid Request Type in History
+ * (UserHistoryService)
+ */
+export const USER_HISTORY_INVALID_REQ_TYPE =
+ 'user_history/req_type_invalid' as const;
+
+/*
+
|------------------------------------|
|Server errors that are actually bugs|
|------------------------------------|