namespace marlin.web.Data; using System.Linq.Expressions; using System.Text.Json; using core; using core.functional; using core.models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Models; // user-based session grant // agent id/token grant // agent job claim session grant // service grant public interface IActiveGrant { bool CanAccessSource(Guid sourceId); } public class ApplicationDbContext : DbContext { public DbSet Sources => this.Set(); public DbSet SourceBranches => this.Set(); public DbSet SourceCommits => this.Set(); public DbSet SourceBlobs => this.Set(); public DbSet Secrets => this.Set(); public DbSet Jobs => this.Set(); public DbSet Agents => this.Set(); public DbSet WorkflowSnapshots => this.Set(); public ApplicationDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder .Entity() .Property(p => p.Capabilities) .HasJsonConversion(); modelBuilder .Entity() .HasAlternateKey(x => new { x.SourceId, x.Hash }); modelBuilder .Entity() .Property(p => p.Content) .HasJsonConversion(); modelBuilder .Entity() .HasOne(x => x.WorkflowSnapshot) .WithOne(x => x.Commit) .HasForeignKey(x => x.CommitId); modelBuilder .Entity() .Property(p => p.Workflow) .HasJsonConversion(); base.OnModelCreating(modelBuilder); } }