Remove tenant service pattern

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-05-20 16:18:23 -07:00
parent 30db98455d
commit 3e4a9be7c0
89 changed files with 3510 additions and 3031 deletions

View File

@@ -52,7 +52,8 @@ func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework,
return nil, err
}
prb := r.ProboService(ctx, obj.ID.TenantID())
scope := coredata.NewScopeFromObjectID(obj.ID)
prb := r.probo
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
Field: coredata.ControlOrderFieldCreatedAt,
@@ -72,7 +73,7 @@ func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework,
controlFilter = coredata.NewControlFilter(filter.Query)
}
page, err := prb.Controls.ListForFrameworkID(ctx, obj.ID, cursor, controlFilter)
page, err := prb.Controls.ListForFrameworkID(ctx, scope, obj.ID, cursor, controlFilter)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list controls", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -87,9 +88,10 @@ func (r *frameworkResolver) LightLogoURL(ctx context.Context, obj *types.Framewo
return nil, err
}
prb := r.ProboService(ctx, obj.ID.TenantID())
scope := coredata.NewScopeFromObjectID(obj.ID)
prb := r.probo
return prb.Frameworks.GenerateLightLogoURL(ctx, obj.ID, 1*time.Hour)
return prb.Frameworks.GenerateLightLogoURL(ctx, scope, obj.ID, 1*time.Hour)
}
// DarkLogoURL is the resolver for the darkLogoURL field.
@@ -98,9 +100,10 @@ func (r *frameworkResolver) DarkLogoURL(ctx context.Context, obj *types.Framewor
return nil, err
}
prb := r.ProboService(ctx, obj.ID.TenantID())
scope := coredata.NewScopeFromObjectID(obj.ID)
prb := r.probo
return prb.Frameworks.GenerateDarkLogoURL(ctx, obj.ID, 1*time.Hour)
return prb.Frameworks.GenerateDarkLogoURL(ctx, scope, obj.ID, 1*time.Hour)
}
// Permission is the resolver for the permission field.
@@ -116,9 +119,10 @@ func (r *frameworkConnectionResolver) TotalCount(ctx context.Context, obj *types
switch obj.Resolver.(type) {
case *organizationResolver:
prb := r.ProboService(ctx, obj.ParentID.TenantID())
scope := coredata.NewScopeFromObjectID(obj.ParentID)
prb := r.probo
count, err := prb.Frameworks.CountForOrganizationID(ctx, obj.ParentID)
count, err := prb.Frameworks.CountForOrganizationID(ctx, scope, obj.ParentID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot count frameworks", log.Error(err))
return 0, gqlutils.Internal(ctx)
@@ -138,10 +142,11 @@ func (r *mutationResolver) CreateFramework(ctx context.Context, input types.Crea
return nil, err
}
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
prb := r.probo
framework, err := prb.Frameworks.Create(
ctx,
ctx, scope,
probo.CreateFrameworkRequest{
OrganizationID: input.OrganizationID,
Name: input.Name,
@@ -168,10 +173,11 @@ func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.Upda
return nil, err
}
prb := r.ProboService(ctx, input.ID.TenantID())
scope := coredata.NewScopeFromObjectID(input.ID)
prb := r.probo
framework, err := prb.Frameworks.Update(
ctx,
ctx, scope,
probo.UpdateFrameworkRequest{
ID: input.ID,
Name: input.Name,
@@ -199,7 +205,8 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
return nil, err
}
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
prb := r.probo
req := probo.ImportFrameworkRequest{}
if err := json.NewDecoder(input.File.File).Decode(&req.Framework); err != nil {
@@ -207,7 +214,7 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
return nil, gqlutils.Internal(ctx)
}
framework, err := prb.Frameworks.Import(ctx, input.OrganizationID, req)
framework, err := prb.Frameworks.Import(ctx, scope, input.OrganizationID, req)
if err != nil {
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
return nil, gqlutils.Conflict(ctx, err)
@@ -229,9 +236,10 @@ func (r *mutationResolver) DeleteFramework(ctx context.Context, input types.Dele
return nil, err
}
prb := r.ProboService(ctx, input.FrameworkID.TenantID())
scope := coredata.NewScopeFromObjectID(input.FrameworkID)
prb := r.probo
err := prb.Frameworks.Delete(ctx, input.FrameworkID)
err := prb.Frameworks.Delete(ctx, scope, input.FrameworkID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot delete framework", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -248,11 +256,13 @@ func (r *mutationResolver) ExportFramework(ctx context.Context, input types.Expo
return nil, err
}
prb := r.ProboService(ctx, input.FrameworkID.TenantID())
scope := coredata.NewScopeFromObjectID(input.FrameworkID)
prb := r.probo
identity := authn.IdentityFromContext(ctx)
exportJob, exportErr := prb.Frameworks.RequestExport(
ctx,
ctx, scope,
input.FrameworkID,
identity.EmailAddress,
identity.FullName,