api-client/packages/hoppscotch-backend/prisma/schema.prisma

354 lines
11 KiB
Text
Raw Normal View History

generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
datasource db {
provider = "postgresql"
}
model Team {
id String @id @default(cuid())
name String
TeamCollection TeamCollection[]
TeamEnvironment TeamEnvironment[]
TeamInvitation TeamInvitation[]
members TeamMember[]
TeamRequest TeamRequest[]
}
model TeamMember {
id String @id @default(uuid())
role TeamAccessRole
userUid String
teamID String
team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
@@unique([teamID, userUid])
}
model TeamInvitation {
id String @id @default(cuid())
teamID String
creatorUid String
inviteeEmail String
inviteeRole TeamAccessRole
team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
@@unique([teamID, inviteeEmail])
@@index([teamID])
}
model TeamCollection {
id String @id @default(cuid())
refactor: refactoring Team-Collections with reordering in self-host (HBE-150) (#34) * chore: removed firebase module as a dependency from team-collection module * chore: modified team-collection resolver file to use input-args types * chore: modified getTeamOfCollection service method and resolver * chore: modified getParentOfCollection service method in team-collection module * chore: modified getChildrenOfCollection service method in team-collection module * chore: added new fields to TeamCollection model in prisma schema file * chore: modified getCollection service method and resolver in team-collection module * chore: modified createCollection service method and resolver in team-collection module * chore: created cast helper function to resolve issue with creation mutation in team-collection * chore: modified teamCollectionRemoved subscription return types * chore: removed return types from subscriptions in team-collection module * chore: removed all instances of getTeamCollections service method in team-collection module * feat: added mutation to handle moving collections and supporting subscriptions * feat: added mutation to re-ordering team-collection order * chore: added teacher comments to both collection modules * test: added test cases for getTeamOfCollection service method * test: added test cases for getParentOfCollection service method * test: added test cases for getChildrenOfCollection service method * test: added test cases for getTeamRootCollections service method * test: added test cases for getCollection service method * test: added test cases for createCollection service method * chore: renamed renameCollection to renameUserCollection in UserCollection module * test: added test cases for renameCollection service method * test: added test cases for deleteCollection service method * test: added test cases for moveCollection service method * test: added test cases for updateCollectionOrder service method * chore: added import and export to JSON mutations to team-collection module * chore: created replaceCollectionsWithJSON mutation in team-collection module * chore: moved the mutation and service method of importCollectionFromFirestore to the end of file * chore: added helper comments to all import,export functions * chore: exportCollectionsToJSON service method orders collections and requests in ascending order * chore: added test cases for importCollectionsFromJSON service method * chore: added ToDo to write test cases for exportCollectionsToJSON * chore: removed prisma migration folder * chore: completed all changes requested in inital PR review * chore: completed all changes requested in second PR review * chore: completed all changes requested in third PR review
2023-03-09 14:07:40 +00:00
parentID String?
teamID String
title String
orderIndex Int
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
data Json?
parent TeamCollection? @relation("TeamCollectionChildParent", fields: [parentID], references: [id], onDelete: Cascade)
children TeamCollection[] @relation("TeamCollectionChildParent")
team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
requests TeamRequest[]
@@unique([teamID, parentID, orderIndex])
}
model TeamRequest {
id String @id @default(cuid())
collectionID String
teamID String
title String
request Json
mockExamples Json?
refactor: refactoring Team-Collections with reordering in self-host (HBE-150) (#34) * chore: removed firebase module as a dependency from team-collection module * chore: modified team-collection resolver file to use input-args types * chore: modified getTeamOfCollection service method and resolver * chore: modified getParentOfCollection service method in team-collection module * chore: modified getChildrenOfCollection service method in team-collection module * chore: added new fields to TeamCollection model in prisma schema file * chore: modified getCollection service method and resolver in team-collection module * chore: modified createCollection service method and resolver in team-collection module * chore: created cast helper function to resolve issue with creation mutation in team-collection * chore: modified teamCollectionRemoved subscription return types * chore: removed return types from subscriptions in team-collection module * chore: removed all instances of getTeamCollections service method in team-collection module * feat: added mutation to handle moving collections and supporting subscriptions * feat: added mutation to re-ordering team-collection order * chore: added teacher comments to both collection modules * test: added test cases for getTeamOfCollection service method * test: added test cases for getParentOfCollection service method * test: added test cases for getChildrenOfCollection service method * test: added test cases for getTeamRootCollections service method * test: added test cases for getCollection service method * test: added test cases for createCollection service method * chore: renamed renameCollection to renameUserCollection in UserCollection module * test: added test cases for renameCollection service method * test: added test cases for deleteCollection service method * test: added test cases for moveCollection service method * test: added test cases for updateCollectionOrder service method * chore: added import and export to JSON mutations to team-collection module * chore: created replaceCollectionsWithJSON mutation in team-collection module * chore: moved the mutation and service method of importCollectionFromFirestore to the end of file * chore: added helper comments to all import,export functions * chore: exportCollectionsToJSON service method orders collections and requests in ascending order * chore: added test cases for importCollectionsFromJSON service method * chore: added ToDo to write test cases for exportCollectionsToJSON * chore: removed prisma migration folder * chore: completed all changes requested in inital PR review * chore: completed all changes requested in second PR review * chore: completed all changes requested in third PR review
2023-03-09 14:07:40 +00:00
orderIndex Int
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
collection TeamCollection @relation(fields: [collectionID], references: [id], onDelete: Cascade)
team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
@@unique([teamID, collectionID, orderIndex])
}
model Shortcode {
feat: introduction of shared-requests (#3476) * feat: added new property to existing shortcode model in prisma schema * chore: created shared-requests module * chore: created shared-request model * chore: complete sharedRequest query * chore: completed mutation to create a SharedRequest * chore: completed subscription to create a SharedRequest * chore: completed query to fetch all user created shared-requests * chore: completed mutation to delete a SharedRequest * chore: completed subscription to delete a SharedRequest * chore: removed unused dependncues in share-requests module * chore: added shared-requests into user deletion spec * test: added all testcases for shared-request module * test: modified all relevant tests in shortcode module * chore: added deprecated label to all queries,mutations and subscriptions in the shortcode module * chore: resolved all comments raised in review * feat: added ability to update and listen to updates of shared-requests * chore: added updatedOn field to shortcode model * chore: fixed issue with updateSharedRequest method * chore: fixed incorrect value getting updated * chore: added all test-cases for updateSharedRequest method * chore: created migration for shared-requests * chore: moved shared-requests into shortcode module * chore: added missing import in shortcode tests * chore: changed properties to embedProperties in shortcode model * feat: generated migrations file for new schema changes to Shortcodes table * chore: changed target of old-backend service in docker-compose file * chore: fixed issue with updatedOn field in shortcodes model * chore: removed unused dependencies * fix: handle invalid input for shortcode properties * Revert "fix: handle invalid input for shortcode properties" This reverts commit 4dcb0afb184749068a11afbbb0087570d01df5d5. * chore: changed updateShortcode method name to updateEmbedProperties * chore: changed target of hoppscotch-old-backend service to prod --------- Co-authored-by: Mir Arif Hasan <arif.ishan05@gmail.com>
2023-11-07 12:27:51 +00:00
id String @id @unique
request Json
creatorUid String?
createdOn DateTime @default(now()) @db.Timestamptz(3)
embedProperties Json?
updatedOn DateTime @default(now()) @updatedAt @db.Timestamptz(3)
User User? @relation(fields: [creatorUid], references: [uid])
@@unique([id, creatorUid], name: "creator_uid_shortcode_unique")
}
model TeamEnvironment {
id String @id @default(cuid())
teamID String
name String
variables Json
team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
}
model User {
feat: adding support for `hopp-cli` in self-host Hoppscotch (#4079) * feat: created a new table to store user PATs * chore: renamed UserTokens table name to PersonalAccessToken * chore: added unique property to token column * chore: made expiresOn field optional * chore: created access-token module * feat: created access-token rest routes * chore: created a new auth guard for PATs * chore: scaffolded routes in team collection and environments modules for CLI * chore: created method to update lastUsedOn property for accessTokens * chore: created interceptor to update lastUsedOn property of PAT * feat: interceptor to update lastUpdatedOn property complete * chore: removed unused imports in access-token interceptor * chore: moved routes to fetch collection and environment into access-token module * feat: added routes to fetch collections and environments for CLI * chore: modified access-token interceptor * chore: removed log statement from interceptor * chore: added team member checking logic to ForCLI methods in team collection and environments module * chore: changed return error messages to those defined in spec * chore: added comments to all service methods * chore: removed unused imports * chore: updated testcases for team-environments module service file * chore: added and updated testcases * chore: removed unneseccary SQL from auto-generated migration sql for PAT * chore: remobed JWTAuthGuard from relevant routes in PAT controllers file * chore: modified token for auth in PATAuthGuard * chore: changed error codes in some certain service methods in access-token module * feat: worked on feedback for PR review * chore: renamed service method in access-token module * chore: removed console log statements * chore: modified cli error type * test: fix broken test case * chore: changed target of hopp-old-backend to prod --------- Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
2024-05-28 11:09:50 +00:00
uid String @id @default(cuid())
2026-05-06 06:17:05 +00:00
username String? @unique
feat: adding support for `hopp-cli` in self-host Hoppscotch (#4079) * feat: created a new table to store user PATs * chore: renamed UserTokens table name to PersonalAccessToken * chore: added unique property to token column * chore: made expiresOn field optional * chore: created access-token module * feat: created access-token rest routes * chore: created a new auth guard for PATs * chore: scaffolded routes in team collection and environments modules for CLI * chore: created method to update lastUsedOn property for accessTokens * chore: created interceptor to update lastUsedOn property of PAT * feat: interceptor to update lastUpdatedOn property complete * chore: removed unused imports in access-token interceptor * chore: moved routes to fetch collection and environment into access-token module * feat: added routes to fetch collections and environments for CLI * chore: modified access-token interceptor * chore: removed log statement from interceptor * chore: added team member checking logic to ForCLI methods in team collection and environments module * chore: changed return error messages to those defined in spec * chore: added comments to all service methods * chore: removed unused imports * chore: updated testcases for team-environments module service file * chore: added and updated testcases * chore: removed unneseccary SQL from auto-generated migration sql for PAT * chore: remobed JWTAuthGuard from relevant routes in PAT controllers file * chore: modified token for auth in PATAuthGuard * chore: changed error codes in some certain service methods in access-token module * feat: worked on feedback for PR review * chore: renamed service method in access-token module * chore: removed console log statements * chore: modified cli error type * test: fix broken test case * chore: changed target of hopp-old-backend to prod --------- Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
2024-05-28 11:09:50 +00:00
displayName String?
email String? @unique
photoURL String?
isAdmin Boolean @default(false)
refreshToken String?
currentRESTSession Json?
currentGQLSession Json?
createdOn DateTime @default(now()) @db.Timestamptz(3)
lastLoggedOn DateTime? @db.Timestamptz(3)
lastActiveOn DateTime? @db.Timestamptz(3)
2026-05-06 06:17:05 +00:00
localCredential LocalCredential?
providerAccounts Account[]
feat: adding support for `hopp-cli` in self-host Hoppscotch (#4079) * feat: created a new table to store user PATs * chore: renamed UserTokens table name to PersonalAccessToken * chore: added unique property to token column * chore: made expiresOn field optional * chore: created access-token module * feat: created access-token rest routes * chore: created a new auth guard for PATs * chore: scaffolded routes in team collection and environments modules for CLI * chore: created method to update lastUsedOn property for accessTokens * chore: created interceptor to update lastUsedOn property of PAT * feat: interceptor to update lastUpdatedOn property complete * chore: removed unused imports in access-token interceptor * chore: moved routes to fetch collection and environment into access-token module * feat: added routes to fetch collections and environments for CLI * chore: modified access-token interceptor * chore: removed log statement from interceptor * chore: added team member checking logic to ForCLI methods in team collection and environments module * chore: changed return error messages to those defined in spec * chore: added comments to all service methods * chore: removed unused imports * chore: updated testcases for team-environments module service file * chore: added and updated testcases * chore: removed unneseccary SQL from auto-generated migration sql for PAT * chore: remobed JWTAuthGuard from relevant routes in PAT controllers file * chore: modified token for auth in PATAuthGuard * chore: changed error codes in some certain service methods in access-token module * feat: worked on feedback for PR review * chore: renamed service method in access-token module * chore: removed console log statements * chore: modified cli error type * test: fix broken test case * chore: changed target of hopp-old-backend to prod --------- Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
2024-05-28 11:09:50 +00:00
invitedUsers InvitedUsers[]
mockServers MockServer[]
feat: adding support for `hopp-cli` in self-host Hoppscotch (#4079) * feat: created a new table to store user PATs * chore: renamed UserTokens table name to PersonalAccessToken * chore: added unique property to token column * chore: made expiresOn field optional * chore: created access-token module * feat: created access-token rest routes * chore: created a new auth guard for PATs * chore: scaffolded routes in team collection and environments modules for CLI * chore: created method to update lastUsedOn property for accessTokens * chore: created interceptor to update lastUsedOn property of PAT * feat: interceptor to update lastUpdatedOn property complete * chore: removed unused imports in access-token interceptor * chore: moved routes to fetch collection and environment into access-token module * feat: added routes to fetch collections and environments for CLI * chore: modified access-token interceptor * chore: removed log statement from interceptor * chore: added team member checking logic to ForCLI methods in team collection and environments module * chore: changed return error messages to those defined in spec * chore: added comments to all service methods * chore: removed unused imports * chore: updated testcases for team-environments module service file * chore: added and updated testcases * chore: removed unneseccary SQL from auto-generated migration sql for PAT * chore: remobed JWTAuthGuard from relevant routes in PAT controllers file * chore: modified token for auth in PATAuthGuard * chore: changed error codes in some certain service methods in access-token module * feat: worked on feedback for PR review * chore: renamed service method in access-token module * chore: removed console log statements * chore: modified cli error type * test: fix broken test case * chore: changed target of hopp-old-backend to prod --------- Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
2024-05-28 11:09:50 +00:00
personalAccessTokens PersonalAccessToken[]
shortcodes Shortcode[]
userCollections UserCollection[]
UserEnvironments UserEnvironment[]
UserHistory UserHistory[]
userRequests UserRequest[]
settings UserSettings?
VerificationToken VerificationToken[]
}
2026-05-06 06:17:05 +00:00
model LocalCredential {
id String @id @default(cuid())
userUid String @unique
passwordHash String
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
}
model Account {
id String @id @default(cuid())
userId String
provider String
providerAccountId String
providerRefreshToken String?
providerAccessToken String?
providerScope String?
loggedIn DateTime @default(now()) @db.Timestamptz(3)
user User @relation(fields: [userId], references: [uid], onDelete: Cascade)
@@unique([provider, providerAccountId], name: "verifyProviderAccount")
}
model VerificationToken {
deviceIdentifier String
token String @unique @default(cuid())
userUid String
expiresOn DateTime @db.Timestamptz(3)
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
@@unique([deviceIdentifier, token], name: "passwordless_deviceIdentifier_tokens")
}
2023-01-24 09:24:11 +00:00
model UserSettings {
id String @id @default(cuid())
userUid String @unique
properties Json
updatedOn DateTime @updatedAt @db.Timestamptz(3)
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
2023-01-24 09:24:11 +00:00
}
model UserHistory {
id String @id @default(cuid())
userUid String
reqType ReqType
request Json
responseMetadata Json
isStarred Boolean
executedOn DateTime @default(now()) @db.Timestamptz(3)
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
2023-01-24 09:24:11 +00:00
}
model UserEnvironment {
id String @id @default(cuid())
userUid String
name String?
variables Json
isGlobal Boolean
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
}
feat: Introducing Admin Module to Backend (HBE-83) (#21) * feat: introducing admin module, resolvers and service files as a module * feat: adding admin module in the app module * feat: introducing admin guard and decorator for allowing admin operations * feat: invited user model * chore: added user invitation mail description to mailer service * chore: added admin and user related error * feat: added invited users as a new model in prisma * chore: added admin related topics to pubsub * chore: added service method to fetch all users from user table * chore: added user deletion base implementation * Revert "chore: added user deletion base implementation" This reverts commit d1615ad83db2bae946e2d366a903d2f95051dabb. * feat: adding team related operations to admin * chore: adding admin related service methods to teams module service * chore: adding admin related service methods to team coll invitations requests envs * chore: added more module error messages * chore: added admin check service method * chore: added find individual user by UID in admin * HBE-106 feat: introduced code to handle first time admin login setup (#23) * test: wrote test cases for verifyAdmin route service method * chore: added comments to verifyAdmin service method * chore: deleted the prisma migration file * chore: added find admin users * feat: added user deletion into admin module * chore: admin user related errors * chore: fixed registry pattern in the shortcodes and teams to handle user deletion * chore: add subscription topic for user deletion * chore: updated user type in data handler * feat: implement and fix user deletion * feat: added make user admin mutation * chore: added unit tests for admin specific service methods in admin module * chore: added invitation not found error * chore: added admin specific operation test cases in specific modules * chore: added tests related to user deletion and admin related operation in user module * chore: updated to error constant when invitations not found * chore: fix rebase overwritten methods * feat: implement remove user as admin * chore: add new line * feat: introducing basic metrics into the self-hosted admin module (HBE-104) (#43) * feat: introducing admin module, resolvers and service files as a module * feat: adding admin module in the app module * feat: introducing admin guard and decorator for allowing admin operations * feat: invited user model * chore: added user invitation mail description to mailer service * chore: added admin and user related error * feat: added invited users as a new model in prisma * chore: added admin related topics to pubsub * chore: added service method to fetch all users from user table * chore: added user deletion base implementation * Revert "chore: added user deletion base implementation" This reverts commit d1615ad83db2bae946e2d366a903d2f95051dabb. * feat: adding team related operations to admin * chore: adding admin related service methods to teams module service * chore: adding admin related service methods to team coll invitations requests envs * chore: added more module error messages * chore: added admin check service method * chore: added find individual user by UID in admin * HBE-106 feat: introduced code to handle first time admin login setup (#23) * test: wrote test cases for verifyAdmin route service method * chore: added comments to verifyAdmin service method * chore: deleted the prisma migration file * chore: added find admin users * feat: added user deletion into admin module * chore: admin user related errors * chore: fixed registry pattern in the shortcodes and teams to handle user deletion * chore: add subscription topic for user deletion * chore: updated user type in data handler * feat: implement and fix user deletion * feat: added make user admin mutation * chore: added unit tests for admin specific service methods in admin module * chore: added invitation not found error * chore: added admin specific operation test cases in specific modules * chore: added tests related to user deletion and admin related operation in user module * chore: updated to error constant when invitations not found * chore: fix rebase overwritten methods * feat: implement remove user as admin * chore: add new line * chore: created new GQL return type for admin module * chore: created resolver and service method for method to fetch org metrics * chore: removed all entities relevant to seperate query for fetching admin metrics * chore: created all resolvers for metrics * feat: completed adding field resolves to query org metrics * test: wrote tests for all metrics related methods in admin module * test: added test cases for get count functions in multiple modules * chore: removed prisma migration folder * Delete backend-schema.gql * chore: resolved merge conflicts in team test file --------- Co-authored-by: ankitsridhar16 <ankit.sridhar16@gmail.com> * refactor: update mailer service to stop using postmark (#38) * refactor: update mailer service to stop using postmark * chore: remove postmark as a dep and move out postmark code * chore: remove postmark variables from .env.example * chore: add formal errors for mailer initialization errors * chore: add and update jsdoc comments in mailer service methods * chore: added user invitation mail description to mailer service * chore: updated with review changes requested for admin module * feat: adding admin resolver to gql schema * feat: adding input args for admin resolvers * chore: invited user renamed * chore: updated mailer service to be compatible with new mailer * chore: updated team service with review changes * chore: updated team collection service with review changes * chore: updated team environments service with review changes * chore: updated team requests service with review changes * chore: updated user service with review changes * refactor: invited user model * chore: review changes implemented * chore: implemented the review changes for admin, user and teams module * chore: removed error handling and implemented review changes * refactor: naming change for IsAdmin --------- Co-authored-by: Balu Babu <balub997@gmail.com> Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
2023-03-21 11:12:30 +00:00
model InvitedUsers {
adminUid String
adminEmail String
inviteeEmail String @unique
invitedOn DateTime @default(now()) @db.Timestamptz(3)
user User @relation(fields: [adminUid], references: [uid], onDelete: Cascade)
feat: Introducing Admin Module to Backend (HBE-83) (#21) * feat: introducing admin module, resolvers and service files as a module * feat: adding admin module in the app module * feat: introducing admin guard and decorator for allowing admin operations * feat: invited user model * chore: added user invitation mail description to mailer service * chore: added admin and user related error * feat: added invited users as a new model in prisma * chore: added admin related topics to pubsub * chore: added service method to fetch all users from user table * chore: added user deletion base implementation * Revert "chore: added user deletion base implementation" This reverts commit d1615ad83db2bae946e2d366a903d2f95051dabb. * feat: adding team related operations to admin * chore: adding admin related service methods to teams module service * chore: adding admin related service methods to team coll invitations requests envs * chore: added more module error messages * chore: added admin check service method * chore: added find individual user by UID in admin * HBE-106 feat: introduced code to handle first time admin login setup (#23) * test: wrote test cases for verifyAdmin route service method * chore: added comments to verifyAdmin service method * chore: deleted the prisma migration file * chore: added find admin users * feat: added user deletion into admin module * chore: admin user related errors * chore: fixed registry pattern in the shortcodes and teams to handle user deletion * chore: add subscription topic for user deletion * chore: updated user type in data handler * feat: implement and fix user deletion * feat: added make user admin mutation * chore: added unit tests for admin specific service methods in admin module * chore: added invitation not found error * chore: added admin specific operation test cases in specific modules * chore: added tests related to user deletion and admin related operation in user module * chore: updated to error constant when invitations not found * chore: fix rebase overwritten methods * feat: implement remove user as admin * chore: add new line * feat: introducing basic metrics into the self-hosted admin module (HBE-104) (#43) * feat: introducing admin module, resolvers and service files as a module * feat: adding admin module in the app module * feat: introducing admin guard and decorator for allowing admin operations * feat: invited user model * chore: added user invitation mail description to mailer service * chore: added admin and user related error * feat: added invited users as a new model in prisma * chore: added admin related topics to pubsub * chore: added service method to fetch all users from user table * chore: added user deletion base implementation * Revert "chore: added user deletion base implementation" This reverts commit d1615ad83db2bae946e2d366a903d2f95051dabb. * feat: adding team related operations to admin * chore: adding admin related service methods to teams module service * chore: adding admin related service methods to team coll invitations requests envs * chore: added more module error messages * chore: added admin check service method * chore: added find individual user by UID in admin * HBE-106 feat: introduced code to handle first time admin login setup (#23) * test: wrote test cases for verifyAdmin route service method * chore: added comments to verifyAdmin service method * chore: deleted the prisma migration file * chore: added find admin users * feat: added user deletion into admin module * chore: admin user related errors * chore: fixed registry pattern in the shortcodes and teams to handle user deletion * chore: add subscription topic for user deletion * chore: updated user type in data handler * feat: implement and fix user deletion * feat: added make user admin mutation * chore: added unit tests for admin specific service methods in admin module * chore: added invitation not found error * chore: added admin specific operation test cases in specific modules * chore: added tests related to user deletion and admin related operation in user module * chore: updated to error constant when invitations not found * chore: fix rebase overwritten methods * feat: implement remove user as admin * chore: add new line * chore: created new GQL return type for admin module * chore: created resolver and service method for method to fetch org metrics * chore: removed all entities relevant to seperate query for fetching admin metrics * chore: created all resolvers for metrics * feat: completed adding field resolves to query org metrics * test: wrote tests for all metrics related methods in admin module * test: added test cases for get count functions in multiple modules * chore: removed prisma migration folder * Delete backend-schema.gql * chore: resolved merge conflicts in team test file --------- Co-authored-by: ankitsridhar16 <ankit.sridhar16@gmail.com> * refactor: update mailer service to stop using postmark (#38) * refactor: update mailer service to stop using postmark * chore: remove postmark as a dep and move out postmark code * chore: remove postmark variables from .env.example * chore: add formal errors for mailer initialization errors * chore: add and update jsdoc comments in mailer service methods * chore: added user invitation mail description to mailer service * chore: updated with review changes requested for admin module * feat: adding admin resolver to gql schema * feat: adding input args for admin resolvers * chore: invited user renamed * chore: updated mailer service to be compatible with new mailer * chore: updated team service with review changes * chore: updated team collection service with review changes * chore: updated team environments service with review changes * chore: updated team requests service with review changes * chore: updated user service with review changes * refactor: invited user model * chore: review changes implemented * chore: implemented the review changes for admin, user and teams module * chore: removed error handling and implemented review changes * refactor: naming change for IsAdmin --------- Co-authored-by: Balu Babu <balub997@gmail.com> Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
2023-03-21 11:12:30 +00:00
}
feat: user request module with re-ordering (HBE-78) (#11) * feat: added user-request schema in prisma * feat: basic mutation and queries implementation * fix: enum registration in graphql * feat: user resolver added for user requests * chore: refactor codes * feat: transaction added in request reordering operation * feat: pubsub added in user request * refactor: user request service * chore: feedback added * chore: code improvement * fix: bug fix * feat: request type update in schema and JSDoc added * test: fetchUserRequests and fetchUserRequest unit test added * chore: refactor two functions * test: unit test added for more functions * chore: code readability improved * test: added unit test for reorderRequests function * feat: subscriptions added * fix: User reference to AuthUser * fix: User to AuthUser in test file * chore: update dto file extensions * feat: relation added in schema level * chore: add function for db to model type casting * feat: filter with title and collectionID add in userRequest resolver * feat: resolvers added for userCollection in request module, and move inputTypes in a single file * test: test file updated * docs: description updated * feat: createdOn, updatedOn added in user request schema * chore: (delete in future) user collection module add for testing purpose * feat: separate resolvers for create, update, delete user request based on req type * feat: used paginationArgs from common types * fix: shift InputTypes to ArgsTypes * docs: update docs * feat: avoid destructuring * test: fix test cases for create and update * docs: update JS doc * feat: separate object variables for moveRequest function * test: fix test case for moveRequest function * feat: saperate parameters for fetchUserRequest * test: fix test cases for fetchUserRequests * feat: update some query names and made review changes * test: fix test cases * feat: remove filtering with title * test: fix text cases for fetchUserRequests func * feat: update subscription key * feat: edge case handled for user request creation * test: fix test case * fix: user field resolver * fix: fetch user req issue * fix: update with type check * test: fix test cases * feat: type checked on move request * test: add test case for typeValidity check func * fix: edge condition added in if statement * fix: error message * chore: removed user collection from this branch * fix: typos
2023-03-03 10:51:49 +00:00
model UserRequest {
id String @id @default(cuid())
collectionID String
userUid String
title String
request Json
mockExamples Json?
feat: user request module with re-ordering (HBE-78) (#11) * feat: added user-request schema in prisma * feat: basic mutation and queries implementation * fix: enum registration in graphql * feat: user resolver added for user requests * chore: refactor codes * feat: transaction added in request reordering operation * feat: pubsub added in user request * refactor: user request service * chore: feedback added * chore: code improvement * fix: bug fix * feat: request type update in schema and JSDoc added * test: fetchUserRequests and fetchUserRequest unit test added * chore: refactor two functions * test: unit test added for more functions * chore: code readability improved * test: added unit test for reorderRequests function * feat: subscriptions added * fix: User reference to AuthUser * fix: User to AuthUser in test file * chore: update dto file extensions * feat: relation added in schema level * chore: add function for db to model type casting * feat: filter with title and collectionID add in userRequest resolver * feat: resolvers added for userCollection in request module, and move inputTypes in a single file * test: test file updated * docs: description updated * feat: createdOn, updatedOn added in user request schema * chore: (delete in future) user collection module add for testing purpose * feat: separate resolvers for create, update, delete user request based on req type * feat: used paginationArgs from common types * fix: shift InputTypes to ArgsTypes * docs: update docs * feat: avoid destructuring * test: fix test cases for create and update * docs: update JS doc * feat: separate object variables for moveRequest function * test: fix test case for moveRequest function * feat: saperate parameters for fetchUserRequest * test: fix test cases for fetchUserRequests * feat: update some query names and made review changes * test: fix test cases * feat: remove filtering with title * test: fix text cases for fetchUserRequests func * feat: update subscription key * feat: edge case handled for user request creation * test: fix test case * fix: user field resolver * fix: fetch user req issue * fix: update with type check * test: fix test cases * feat: type checked on move request * test: add test case for typeValidity check func * fix: edge condition added in if statement * fix: error message * chore: removed user collection from this branch * fix: typos
2023-03-03 10:51:49 +00:00
type ReqType
orderIndex Int
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
userCollection UserCollection @relation(fields: [collectionID], references: [id], onDelete: Cascade)
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
@@unique([userUid, collectionID, orderIndex])
feat: user request module with re-ordering (HBE-78) (#11) * feat: added user-request schema in prisma * feat: basic mutation and queries implementation * fix: enum registration in graphql * feat: user resolver added for user requests * chore: refactor codes * feat: transaction added in request reordering operation * feat: pubsub added in user request * refactor: user request service * chore: feedback added * chore: code improvement * fix: bug fix * feat: request type update in schema and JSDoc added * test: fetchUserRequests and fetchUserRequest unit test added * chore: refactor two functions * test: unit test added for more functions * chore: code readability improved * test: added unit test for reorderRequests function * feat: subscriptions added * fix: User reference to AuthUser * fix: User to AuthUser in test file * chore: update dto file extensions * feat: relation added in schema level * chore: add function for db to model type casting * feat: filter with title and collectionID add in userRequest resolver * feat: resolvers added for userCollection in request module, and move inputTypes in a single file * test: test file updated * docs: description updated * feat: createdOn, updatedOn added in user request schema * chore: (delete in future) user collection module add for testing purpose * feat: separate resolvers for create, update, delete user request based on req type * feat: used paginationArgs from common types * fix: shift InputTypes to ArgsTypes * docs: update docs * feat: avoid destructuring * test: fix test cases for create and update * docs: update JS doc * feat: separate object variables for moveRequest function * test: fix test case for moveRequest function * feat: saperate parameters for fetchUserRequest * test: fix test cases for fetchUserRequests * feat: update some query names and made review changes * test: fix test cases * feat: remove filtering with title * test: fix text cases for fetchUserRequests func * feat: update subscription key * feat: edge case handled for user request creation * test: fix test case * fix: user field resolver * fix: fetch user req issue * fix: update with type check * test: fix test cases * feat: type checked on move request * test: add test case for typeValidity check func * fix: edge condition added in if statement * fix: error message * chore: removed user collection from this branch * fix: typos
2023-03-03 10:51:49 +00:00
}
feat: Introducing user-collections into self-host (HBE-98) (#18) * feat: team module added * feat: teamEnvironment module added * feat: teamCollection module added * feat: team request module added * feat: team invitation module added * feat: selfhost auth frontend (#15) Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com> * feat: bringing shortcodes from central to selfhost * chore: added review changes in resolver * chore: commented out subscriptions * chore: bump backend prettier version * feat: created new user-collections module with base files * feat: added new models for user-collection and user-request tables in schema.prisma file * feat: mutations to create user-collections complete * feat: added user field resolver for userCollections * feat: added parent field resolver for userCollections * feat: added child field resolver with pagination for userCollections * feat: added query to fetch root user-collections with pagination for userCollections * feat: added query to fetch user-collections for userCollections * feat: added mutation to rename user-collections * feat: added mutation to delete user-collections * feat: added mutation to delete user-collections * refactor: changed the way we fetch root and child user-collection counts for other operations * feat: added mutation to move user-collections between root and other child collections * refactor: abstracted orderIndex update logic into helpert function * chore: mutation to update order root user-collections complete * feat: user-collections order can be updated when moving it to the end of list * feat: user-collections order update feature complete * feat: subscriptions for user-collection module complete * chore: removed all console.logs from user-collection.service file * test: added tests for all field resolvers for user-collection module * test: test cases for getUserCollection is complete * test: test cases for getUserRootCollections is complete * test: test cases for createUserCollection is complete * test: test cases for renameCollection is complete * test: test cases for moveUserCollection is complete * test: test cases for updateUserCollectionOrder is complete * chore: added createdOn and updatedOn fields to userCollections and userRequests schema * chore: created function to check if title are of valid size * refactor: simplified user-collection creation code * chore: made changed requested in initial PR review * chore: added requestType enum to user-collections * refactor: created two seperate queries to fetch root REST or GQL queries * chore: created seperate mutations and queries for REST and GQL root/child collections * chore: migrated all input args classess into a single file * chore: modified createUserCollection service method to work with different creation inputs args type * chore: rewrote all test cases for user-collections service methods with new CollType * fix: added updated and deleted subscription changes * fix: made all the changes requested in the initial PR review * fix: made all the changes requested in the second PR review * chore: removed migrations from prisma directory * fix: made all the changes requested in the third PR review * chore: added collection type checking to updateUserCollectionOrder service method * chore: refactored all test cases to reflect new additions to service methods * chore: fixed issues with pnpm-lock * chore: removed migrations from prisma directory * chore: hopefully fixed pnpm-lock issues * chore: removed console logs in auth controller --------- Co-authored-by: Mir Arif Hasan <arif.ishan05@gmail.com> Co-authored-by: Akash K <57758277+amk-dev@users.noreply.github.com> Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com> Co-authored-by: ankitsridhar16 <ankit.sridhar16@gmail.com>
2023-03-03 09:33:05 +00:00
model UserCollection {
id String @id @default(cuid())
parentID String?
userUid String
title String
orderIndex Int
type ReqType
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
data Json?
parent UserCollection? @relation("ParentUserCollection", fields: [parentID], references: [id], onDelete: Cascade)
children UserCollection[] @relation("ParentUserCollection")
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
requests UserRequest[]
@@unique([userUid, parentID, orderIndex])
feat: Introducing user-collections into self-host (HBE-98) (#18) * feat: team module added * feat: teamEnvironment module added * feat: teamCollection module added * feat: team request module added * feat: team invitation module added * feat: selfhost auth frontend (#15) Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com> * feat: bringing shortcodes from central to selfhost * chore: added review changes in resolver * chore: commented out subscriptions * chore: bump backend prettier version * feat: created new user-collections module with base files * feat: added new models for user-collection and user-request tables in schema.prisma file * feat: mutations to create user-collections complete * feat: added user field resolver for userCollections * feat: added parent field resolver for userCollections * feat: added child field resolver with pagination for userCollections * feat: added query to fetch root user-collections with pagination for userCollections * feat: added query to fetch user-collections for userCollections * feat: added mutation to rename user-collections * feat: added mutation to delete user-collections * feat: added mutation to delete user-collections * refactor: changed the way we fetch root and child user-collection counts for other operations * feat: added mutation to move user-collections between root and other child collections * refactor: abstracted orderIndex update logic into helpert function * chore: mutation to update order root user-collections complete * feat: user-collections order can be updated when moving it to the end of list * feat: user-collections order update feature complete * feat: subscriptions for user-collection module complete * chore: removed all console.logs from user-collection.service file * test: added tests for all field resolvers for user-collection module * test: test cases for getUserCollection is complete * test: test cases for getUserRootCollections is complete * test: test cases for createUserCollection is complete * test: test cases for renameCollection is complete * test: test cases for moveUserCollection is complete * test: test cases for updateUserCollectionOrder is complete * chore: added createdOn and updatedOn fields to userCollections and userRequests schema * chore: created function to check if title are of valid size * refactor: simplified user-collection creation code * chore: made changed requested in initial PR review * chore: added requestType enum to user-collections * refactor: created two seperate queries to fetch root REST or GQL queries * chore: created seperate mutations and queries for REST and GQL root/child collections * chore: migrated all input args classess into a single file * chore: modified createUserCollection service method to work with different creation inputs args type * chore: rewrote all test cases for user-collections service methods with new CollType * fix: added updated and deleted subscription changes * fix: made all the changes requested in the initial PR review * fix: made all the changes requested in the second PR review * chore: removed migrations from prisma directory * fix: made all the changes requested in the third PR review * chore: added collection type checking to updateUserCollectionOrder service method * chore: refactored all test cases to reflect new additions to service methods * chore: fixed issues with pnpm-lock * chore: removed migrations from prisma directory * chore: hopefully fixed pnpm-lock issues * chore: removed console logs in auth controller --------- Co-authored-by: Mir Arif Hasan <arif.ishan05@gmail.com> Co-authored-by: Akash K <57758277+amk-dev@users.noreply.github.com> Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com> Co-authored-by: ankitsridhar16 <ankit.sridhar16@gmail.com>
2023-03-03 09:33:05 +00:00
}
model InfraConfig {
id String @id @default(cuid())
name String @unique
value String?
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
isEncrypted Boolean @default(false)
lastSyncedEnvFileValue String?
}
feat: adding support for `hopp-cli` in self-host Hoppscotch (#4079) * feat: created a new table to store user PATs * chore: renamed UserTokens table name to PersonalAccessToken * chore: added unique property to token column * chore: made expiresOn field optional * chore: created access-token module * feat: created access-token rest routes * chore: created a new auth guard for PATs * chore: scaffolded routes in team collection and environments modules for CLI * chore: created method to update lastUsedOn property for accessTokens * chore: created interceptor to update lastUsedOn property of PAT * feat: interceptor to update lastUpdatedOn property complete * chore: removed unused imports in access-token interceptor * chore: moved routes to fetch collection and environment into access-token module * feat: added routes to fetch collections and environments for CLI * chore: modified access-token interceptor * chore: removed log statement from interceptor * chore: added team member checking logic to ForCLI methods in team collection and environments module * chore: changed return error messages to those defined in spec * chore: added comments to all service methods * chore: removed unused imports * chore: updated testcases for team-environments module service file * chore: added and updated testcases * chore: removed unneseccary SQL from auto-generated migration sql for PAT * chore: remobed JWTAuthGuard from relevant routes in PAT controllers file * chore: modified token for auth in PATAuthGuard * chore: changed error codes in some certain service methods in access-token module * feat: worked on feedback for PR review * chore: renamed service method in access-token module * chore: removed console log statements * chore: modified cli error type * test: fix broken test case * chore: changed target of hopp-old-backend to prod --------- Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
2024-05-28 11:09:50 +00:00
model PersonalAccessToken {
id String @id @default(cuid())
userUid String
label String
token String @unique @default(uuid())
expiresOn DateTime? @db.Timestamptz(3)
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
feat: adding support for `hopp-cli` in self-host Hoppscotch (#4079) * feat: created a new table to store user PATs * chore: renamed UserTokens table name to PersonalAccessToken * chore: added unique property to token column * chore: made expiresOn field optional * chore: created access-token module * feat: created access-token rest routes * chore: created a new auth guard for PATs * chore: scaffolded routes in team collection and environments modules for CLI * chore: created method to update lastUsedOn property for accessTokens * chore: created interceptor to update lastUsedOn property of PAT * feat: interceptor to update lastUpdatedOn property complete * chore: removed unused imports in access-token interceptor * chore: moved routes to fetch collection and environment into access-token module * feat: added routes to fetch collections and environments for CLI * chore: modified access-token interceptor * chore: removed log statement from interceptor * chore: added team member checking logic to ForCLI methods in team collection and environments module * chore: changed return error messages to those defined in spec * chore: added comments to all service methods * chore: removed unused imports * chore: updated testcases for team-environments module service file * chore: added and updated testcases * chore: removed unneseccary SQL from auto-generated migration sql for PAT * chore: remobed JWTAuthGuard from relevant routes in PAT controllers file * chore: modified token for auth in PATAuthGuard * chore: changed error codes in some certain service methods in access-token module * feat: worked on feedback for PR review * chore: renamed service method in access-token module * chore: removed console log statements * chore: modified cli error type * test: fix broken test case * chore: changed target of hopp-old-backend to prod --------- Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
2024-05-28 11:09:50 +00:00
}
model InfraToken {
id String @id @default(cuid())
creatorUid String
label String
token String @unique @default(uuid())
expiresOn DateTime? @db.Timestamptz(3)
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @default(now()) @db.Timestamptz(3)
}
model MockServer {
id String @id @default(cuid())
name String
subdomain String @unique
creatorUid String?
collectionID String
workspaceType WorkspaceType
workspaceID String
delayInMs Int @default(0)
isPublic Boolean @default(true)
isActive Boolean @default(true)
hitCount Int @default(0)
lastHitAt DateTime? @db.Timestamptz(3)
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
deletedAt DateTime? @db.Timestamptz(3)
user User? @relation(fields: [creatorUid], references: [uid], onDelete: SetNull)
requestLogs MockServerLog[]
activityHistory MockServerActivity[]
}
model MockServerLog {
id String @id @default(cuid())
mockServerID String
requestMethod String
requestPath String
requestHeaders Json
requestBody Json?
requestQuery Json?
responseStatus Int
responseHeaders Json
responseBody Json?
responseTime Int
ipAddress String?
userAgent String?
executedAt DateTime @default(now()) @db.Timestamptz(3)
mockServer MockServer @relation(fields: [mockServerID], references: [id], onDelete: Cascade)
@@index([mockServerID])
@@index([mockServerID, executedAt])
}
model MockServerActivity {
id String @id @default(cuid())
mockServerID String
action MockServerAction
performedBy String?
performedAt DateTime @default(now()) @db.Timestamptz(3)
mockServer MockServer @relation(fields: [mockServerID], references: [id], onDelete: Cascade)
@@index([mockServerID])
}
model PublishedDocs {
id String @id @default(cuid())
slug String
title String
collectionID String
creatorUid String
version String
autoSync Boolean
documentTree Json? // Optional if autoSync is true
workspaceType WorkspaceType
workspaceID String
environmentID String?
environmentName String?
environmentVariables Json?
metadata Json?
createdOn DateTime @default(now()) @db.Timestamptz(3)
updatedOn DateTime @updatedAt @db.Timestamptz(3)
@@unique([slug, version])
@@index([collectionID])
}
enum WorkspaceType {
USER
TEAM
}
enum ReqType {
REST
GQL
}
enum TeamAccessRole {
OWNER
VIEWER
EDITOR
}
enum MockServerAction {
CREATED
DELETED
ACTIVATED
DEACTIVATED
}