Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
feat: used new pubsub method and resolve conflicts
Mir Arif Hasanbf09786423f3
diff --cc packages/hoppscotch-backend/prisma/migrations/20230123090914_craete_user_settings/migration.sqlindex 000000000,000000000..f0ec24276new file mode 100644--- /dev/null+++ b/packages/hoppscotch-backend/prisma/migrations/20230123090914_craete_user_settings/migration.sql@@@ -1,0 -1,0 +1,15 @@@++-- CreateTable++CREATE TABLE "UserSettings" (++ "id" TEXT NOT NULL,++ "userUid" TEXT NOT NULL,++ "settings" JSONB NOT NULL,++ "updatedOn" TIMESTAMP(3) NOT NULL,++++ CONSTRAINT "UserSettings_pkey" PRIMARY KEY ("id")++);++++-- CreateIndex++CREATE UNIQUE INDEX "UserSettings_userUid_key" ON "UserSettings"("userUid");++++-- AddForeignKey++ALTER TABLE "UserSettings" ADD CONSTRAINT "UserSettings_userUid_fkey" FOREIGN KEY ("userUid") REFERENCES "User"("uid") ON DELETE CASCADE ON UPDATE CASCADE;diff --cc packages/hoppscotch-backend/prisma/schema.prismaindex 2d10e28cd,0d6e7c56d..ab3346a23--- a/packages/hoppscotch-backend/prisma/schema.prisma+++ b/packages/hoppscotch-backend/prisma/schema.prisma@@@ -79,21 -79,22 +79,31 @@@ model TeamEnvironment}model User {- uid String @id @default(cuid())- displayName String?- email String?- photoURL String?- settings UserSettings?+ uid String @id @default(cuid())+ displayName String?+ email String?+ photoURL String?++ settings UserSettings?+ UserEnvironments UserEnvironment[]}+model UserSettings {+ id String @id @default(cuid())+ userUid String @unique+ user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)+ settings Json+ updatedOn DateTime @updatedAt @db.Timestamp(3)+}++ 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 {OWNERVIEWERdiff --cc packages/hoppscotch-backend/src/app.module.tsindex 92c105f00,b9281e55d..3ba7c17b2--- 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 { UserSettingsModule } from './user-settings/user-settings.module';+ import { UserEnvironmentsModule } from './user-environment/user-environments.module';@Module({imports: [@@@ -45,7 -45,7 +46,8 @@@driver: ApolloDriver,}),UserModule,- UserSettingsModule++ UserSettingsModule,+ UserEnvironmentsModule,],providers: [GQLComplexityPlugin],})diff --cc packages/hoppscotch-backend/src/errors.tsindex da6426178,a03e437c2..706d660d5--- a/packages/hoppscotch-backend/src/errors.ts+++ b/packages/hoppscotch-backend/src/errors.ts@@@ -162,25 -162,59 +162,76 @@@ export const TEAM_ENVIRONMENT_NOT_TEAM_'team_environment/not_team_member' as const;/**+ * User setting not found for a user+ * (UserSettingsService)+ */+export const USER_SETTINGS_DATA_NOT_FOUND = 'user_settings/data_not_found' as const;+-+/**+ * User setting not found for a user+ * (UserSettingsService)+ */+export const USER_SETTINGS_ALREADY_EXISTS = 'user_settings/settings_already_present' as const;++/**+ * User setting invalid (null) settings+ * (UserSettingsService)+ */+export const USER_SETTINGS_NULL_SETTINGS = 'user_settings/null_settings' 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;/*|------------------------------------|diff --cc packages/hoppscotch-backend/src/pubsub/topicsDefs.tsindex 000000000,4a1fbcb27..d16c26b4cmode 000000,100644..100644--- a/packages/hoppscotch-backend/src/pubsub/topicsDefs.ts+++ b/packages/hoppscotch-backend/src/pubsub/topicsDefs.ts@@@ -1,0 -1,10 +1,14 @@@++import { UserSettings } from 'src/user-settings/user-settings.model';+ import { UserEnvironment } from '../user-environment/user-environments.model';++ // A custom message type that defines the topic and the corresponding payload.+ // For every module that publishes a subscription add its type def and the possible subscription type.+ export type TopicDef = {+ [+ topic: `user_environment/${string}/${'created' | 'updated' | 'deleted'}`+ ]: UserEnvironment;++ [++ topic: `user_settings/${string}/${'created' | 'updated' | 'deleted'}`++ ]: UserSettings;+ [topic: `user_environment/${string}/deleted_many`]: number;+ };