39 lines
889 B
Go
39 lines
889 B
Go
package usecase
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.maximumdirect.net/promptkit/internal/domain"
|
|
"go.maximumdirect.net/promptkit/internal/jsonvalue"
|
|
)
|
|
|
|
type inspectionProfileRepository struct {
|
|
profile *domain.ExecutionProfile
|
|
err error
|
|
calls int
|
|
id string
|
|
}
|
|
|
|
func (r *inspectionProfileRepository) GetProfile(_ context.Context, id string) (*domain.ExecutionProfile, error) {
|
|
r.calls++
|
|
r.id = id
|
|
if r.err != nil {
|
|
return nil, r.err
|
|
}
|
|
if r.profile == nil {
|
|
return nil, nil
|
|
}
|
|
profile := *r.profile
|
|
if profile.ResolvedTarget != nil {
|
|
target := *profile.ResolvedTarget
|
|
target.ExtraParams = jsonvalue.CloneTrusted(target.ExtraParams).(map[string]any)
|
|
profile.ResolvedTarget = &target
|
|
}
|
|
return &profile, nil
|
|
}
|
|
|
|
func (r *inspectionProfileRepository) GetProfileIdentity(ctx context.Context, id string) (string, error) {
|
|
_, err := r.GetProfile(ctx, id)
|
|
return id, err
|
|
}
|