Skip to content

Commit

Permalink
feat: Add tables for tracking loaded packages and entitlements
Browse files Browse the repository at this point in the history
  • Loading branch information
KallynGowdy committed Dec 11, 2024
1 parent eba1a81 commit 53289de
Showing 1 changed file with 64 additions and 2 deletions.
66 changes: 64 additions & 2 deletions src/aux-server/aux-backend/schemas/auth.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ model User {
sentNotifications SentPushNotification[]
packageReviews PackageRecordVersionReview[]
grantedPackageEntitlements GrantedPackageEntitlement[]
loadedPackages LoadedPackage[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand Down Expand Up @@ -344,6 +346,8 @@ model Record {
resourceAssignments ResourcePermissionAssignment[]
markerAssignments MarkerPermissionAssignment[]
grantedEntitlements GrantedPackageEntitlement[]
userInstReports UserInstReport[]
createdAt DateTime @default(now())
Expand Down Expand Up @@ -554,6 +558,34 @@ model MarkerPermissionAssignment {
@@index([recordName, marker, action, subjectType, subjectId])
}

model GrantedPackageEntitlement {
id String @db.Uuid @id
// The ID of the user that granted the entitlement
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "GrantedPackageEntitlement_userId_fkey1")
// The name of the record that the package is stored in
packageRecordName String @db.String(128)
record Record @relation(fields: [packageRecordName], references: [name], onDelete: Cascade, map: "GrantedPackageEntitlement_packageRecordName_fkey1")
// The name of the address that the package is stored in
packageAddress String @db.String(128)
package PackageRecord @relation(fields: [packageRecordName, packageAddress], references: [recordName, address], onDelete: Cascade, map: "GrantedPackageEntitlement_packageAddress_fkey1")
// The feature that the entitlement covers
feature String @db.String(32)
// The scope of the entitlement
scope String @db.String(32)
// The records that were designated by the entitlement
designatedRecords String[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

// Example query:
// SELECT * FROM "ResourcePermissionAssignment"
// WHERE "recordName" = recordName AND "marker" = marker AND "action" = action
Expand Down Expand Up @@ -673,6 +705,7 @@ model InstRecord {
updates BranchUpdate[]
userInstReports UserInstReport[]
webhookRecords WebhookRecord[]
loadedPackages LoadedPackage[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand Down Expand Up @@ -717,6 +750,33 @@ model BranchUpdate {
@@index([recordName, instName, branchName, id])
}

// A package that has been loaded into an inst
model LoadedPackage {
id String @id @db.Uuid
// The ID of the user that loaded the package
// Null if the user was deleted or if the package was loaded by the system
userId String?
user User? @relation(fields: [userId], references: [id], onDelete: SetNull, map: "LoadedPackage_user_fkey1")
// The name of the record that the package is stored in
packageRecordName String @db.String(128)
packageAddress String @db.String(128)
packageMajor Int
packageMinor Int
packagePatch Int
packageTag String @db.String(16)
packageVersion PackageRecordVersion @relation(fields: [packageRecordName, packageAddress, packageMajor, packageMinor, packagePatch, packageTag], references: [recordName, address, major, minor, patch, tag], onDelete: Cascade, map: "LoadedPackage_packageVersion_fkey1")
// The inst that the package was loaded into
instRecordName String @db.String(128)
instName String @db.String(128)
inst InstRecord @relation(fields: [instRecordName, instName], references: [recordName, name], onDelete: Cascade, map: "LoadedPackage_inst_fkey1")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model WebhookRecord {
@@id([recordName, address])
Expand Down Expand Up @@ -911,6 +971,7 @@ model PackageRecord {
versions PackageRecordVersion[]
reviews PackageRecordVersionReview[]
grantedEntitlements GrantedPackageEntitlement[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand Down Expand Up @@ -938,7 +999,7 @@ model PackageRecordVersion {
tag String @db.String(16)
// The SHA256 hash of the package
sha256 String @db.String(64)
sha256 String @db.String(64) @unique
// The aux data of the package
aux Json
Expand All @@ -950,7 +1011,7 @@ model PackageRecordVersion {
scriptSha256 String @db.String(64)
// The list of entitlements that this package version requires
entitlements String[]
entitlements Json
// The README of the package
readme String
Expand All @@ -960,6 +1021,7 @@ model PackageRecordVersion {
// The list of reviews for the package version
reviews PackageRecordVersionReview[]
loadedPackages LoadedPackage[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand Down

0 comments on commit 53289de

Please sign in to comment.