Update obligations
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -169,17 +169,17 @@ enum NonconformityStatus
|
||||
|
||||
enum ObligationStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.ObligationStatus") {
|
||||
OPEN
|
||||
NON_COMPLIANT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationStatusOpen"
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationStatusNonCompliant"
|
||||
)
|
||||
IN_PROGRESS
|
||||
PARTIALLY_COMPLIANT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationStatusInProgress"
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationStatusPartiallyCompliant"
|
||||
)
|
||||
CLOSED
|
||||
COMPLIANT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationStatusClosed"
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationStatusCompliant"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1044,10 +1044,6 @@ enum ObligationOrderField
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationOrderFieldCreatedAt"
|
||||
)
|
||||
REFERENCE_ID
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationOrderFieldReferenceId"
|
||||
)
|
||||
LAST_REVIEW_DATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ObligationOrderFieldLastReviewDate"
|
||||
@@ -2004,6 +2000,15 @@ type Risk implements Node {
|
||||
filter: ControlFilter
|
||||
): ControlConnection! @goField(forceResolver: true)
|
||||
|
||||
obligations(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: ObligationOrder
|
||||
filter: ObligationFilter
|
||||
): ObligationConnection! @goField(forceResolver: true)
|
||||
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
@@ -2056,7 +2061,6 @@ type Obligation implements Node {
|
||||
snapshotId: ID
|
||||
sourceId: ID
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
referenceId: String!
|
||||
area: String
|
||||
source: String
|
||||
requirement: String
|
||||
@@ -2669,6 +2673,13 @@ type Mutation {
|
||||
input: DeleteRiskDocumentMappingInput!
|
||||
): DeleteRiskDocumentMappingPayload!
|
||||
|
||||
createRiskObligationMapping(
|
||||
input: CreateRiskObligationMappingInput!
|
||||
): CreateRiskObligationMappingPayload!
|
||||
deleteRiskObligationMapping(
|
||||
input: DeleteRiskObligationMappingInput!
|
||||
): DeleteRiskObligationMappingPayload!
|
||||
|
||||
# Evidence mutations
|
||||
requestEvidence(input: RequestEvidenceInput!): RequestEvidencePayload!
|
||||
fulfillEvidence(input: FulfillEvidenceInput!): FulfillEvidencePayload!
|
||||
@@ -3187,6 +3198,16 @@ input DeleteRiskDocumentMappingInput {
|
||||
documentId: ID!
|
||||
}
|
||||
|
||||
input CreateRiskObligationMappingInput {
|
||||
riskId: ID!
|
||||
obligationId: ID!
|
||||
}
|
||||
|
||||
input DeleteRiskObligationMappingInput {
|
||||
riskId: ID!
|
||||
obligationId: ID!
|
||||
}
|
||||
|
||||
input RequestEvidenceInput {
|
||||
taskId: ID!
|
||||
name: String!
|
||||
@@ -3392,7 +3413,6 @@ input DeleteNonconformityInput {
|
||||
|
||||
input CreateObligationInput {
|
||||
organizationId: ID!
|
||||
referenceId: String!
|
||||
area: String
|
||||
source: String
|
||||
requirement: String
|
||||
@@ -3406,7 +3426,6 @@ input CreateObligationInput {
|
||||
|
||||
input UpdateObligationInput {
|
||||
id: ID!
|
||||
referenceId: String
|
||||
area: String
|
||||
source: String
|
||||
requirement: String
|
||||
@@ -3734,6 +3753,16 @@ type DeleteRiskDocumentMappingPayload {
|
||||
deletedDocumentId: ID!
|
||||
}
|
||||
|
||||
type CreateRiskObligationMappingPayload {
|
||||
riskEdge: RiskEdge!
|
||||
obligationEdge: ObligationEdge!
|
||||
}
|
||||
|
||||
type DeleteRiskObligationMappingPayload {
|
||||
deletedRiskId: ID!
|
||||
deletedObligationId: ID!
|
||||
}
|
||||
|
||||
type RequestEvidencePayload {
|
||||
evidenceEdge: EvidenceEdge!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -60,7 +60,6 @@ func NewObligation(cr *coredata.Obligation) *Obligation {
|
||||
ID: cr.ID,
|
||||
SnapshotID: cr.SnapshotID,
|
||||
SourceID: cr.SourceID,
|
||||
ReferenceID: cr.ReferenceID,
|
||||
Area: cr.Area,
|
||||
Source: cr.Source,
|
||||
Requirement: cr.Requirement,
|
||||
|
||||
@@ -401,7 +401,6 @@ type CreateNonconformityPayload struct {
|
||||
|
||||
type CreateObligationInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
Area *string `json:"area,omitempty"`
|
||||
Source *string `json:"source,omitempty"`
|
||||
Requirement *string `json:"requirement,omitempty"`
|
||||
@@ -497,6 +496,16 @@ type CreateRiskMeasureMappingPayload struct {
|
||||
MeasureEdge *MeasureEdge `json:"measureEdge"`
|
||||
}
|
||||
|
||||
type CreateRiskObligationMappingInput struct {
|
||||
RiskID gid.GID `json:"riskId"`
|
||||
ObligationID gid.GID `json:"obligationId"`
|
||||
}
|
||||
|
||||
type CreateRiskObligationMappingPayload struct {
|
||||
RiskEdge *RiskEdge `json:"riskEdge"`
|
||||
ObligationEdge *ObligationEdge `json:"obligationEdge"`
|
||||
}
|
||||
|
||||
type CreateRiskPayload struct {
|
||||
RiskEdge *RiskEdge `json:"riskEdge"`
|
||||
}
|
||||
@@ -828,6 +837,16 @@ type DeleteRiskMeasureMappingPayload struct {
|
||||
DeletedRiskID gid.GID `json:"deletedRiskId"`
|
||||
}
|
||||
|
||||
type DeleteRiskObligationMappingInput struct {
|
||||
RiskID gid.GID `json:"riskId"`
|
||||
ObligationID gid.GID `json:"obligationId"`
|
||||
}
|
||||
|
||||
type DeleteRiskObligationMappingPayload struct {
|
||||
DeletedRiskID gid.GID `json:"deletedRiskId"`
|
||||
DeletedObligationID gid.GID `json:"deletedObligationId"`
|
||||
}
|
||||
|
||||
type DeleteRiskPayload struct {
|
||||
DeletedRiskID gid.GID `json:"deletedRiskId"`
|
||||
}
|
||||
@@ -1187,7 +1206,6 @@ type Obligation struct {
|
||||
SnapshotID *gid.GID `json:"snapshotId,omitempty"`
|
||||
SourceID *gid.GID `json:"sourceId,omitempty"`
|
||||
Organization *Organization `json:"organization"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
Area *string `json:"area,omitempty"`
|
||||
Source *string `json:"source,omitempty"`
|
||||
Requirement *string `json:"requirement,omitempty"`
|
||||
@@ -1409,6 +1427,7 @@ type Risk struct {
|
||||
Measures *MeasureConnection `json:"measures"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
Obligations *ObligationConnection `json:"obligations"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
@@ -1687,7 +1706,6 @@ type UpdateNonconformityPayload struct {
|
||||
|
||||
type UpdateObligationInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
ReferenceID *string `json:"referenceId,omitempty"`
|
||||
Area *string `json:"area,omitempty"`
|
||||
Source *string `json:"source,omitempty"`
|
||||
Requirement *string `json:"requirement,omitempty"`
|
||||
|
||||
@@ -2209,6 +2209,36 @@ func (r *mutationResolver) DeleteRiskDocumentMapping(ctx context.Context, input
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateRiskObligationMapping is the resolver for the createRiskObligationMapping field.
|
||||
func (r *mutationResolver) CreateRiskObligationMapping(ctx context.Context, input types.CreateRiskObligationMappingInput) (*types.CreateRiskObligationMappingPayload, error) {
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
|
||||
risk, obligation, err := prb.Risks.CreateObligationMapping(ctx, input.RiskID, input.ObligationID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot create risk obligation mapping: %w", err))
|
||||
}
|
||||
|
||||
return &types.CreateRiskObligationMappingPayload{
|
||||
RiskEdge: types.NewRiskEdge(risk, coredata.RiskOrderFieldCreatedAt),
|
||||
ObligationEdge: types.NewObligationEdge(obligation, coredata.ObligationOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteRiskObligationMapping is the resolver for the deleteRiskObligationMapping field.
|
||||
func (r *mutationResolver) DeleteRiskObligationMapping(ctx context.Context, input types.DeleteRiskObligationMappingInput) (*types.DeleteRiskObligationMappingPayload, error) {
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
|
||||
risk, obligation, err := prb.Risks.DeleteObligationMapping(ctx, input.RiskID, input.ObligationID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot delete risk obligation mapping: %w", err))
|
||||
}
|
||||
|
||||
return &types.DeleteRiskObligationMappingPayload{
|
||||
DeletedRiskID: risk.ID,
|
||||
DeletedObligationID: obligation.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// RequestEvidence is the resolver for the requestEvidence field.
|
||||
func (r *mutationResolver) RequestEvidence(ctx context.Context, input types.RequestEvidenceInput) (*types.RequestEvidencePayload, error) {
|
||||
prb := r.ProboService(ctx, input.TaskID.TenantID())
|
||||
@@ -3118,7 +3148,6 @@ func (r *mutationResolver) CreateObligation(ctx context.Context, input types.Cre
|
||||
|
||||
req := probo.CreateObligationRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
ReferenceID: input.ReferenceID,
|
||||
Area: input.Area,
|
||||
Source: input.Source,
|
||||
Requirement: input.Requirement,
|
||||
@@ -3146,7 +3175,6 @@ func (r *mutationResolver) UpdateObligation(ctx context.Context, input types.Upd
|
||||
|
||||
req := probo.UpdateObligationRequest{
|
||||
ID: input.ID,
|
||||
ReferenceID: input.ReferenceID,
|
||||
Area: &input.Area,
|
||||
Source: &input.Source,
|
||||
Requirement: &input.Requirement,
|
||||
@@ -3478,6 +3506,17 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
panic(fmt.Errorf("cannot count obligations: %w", err))
|
||||
}
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
obligationFilter := coredata.NewObligationFilter(nil)
|
||||
if obj.Filter != nil {
|
||||
obligationFilter = coredata.NewObligationFilter(&obj.Filter.SnapshotID)
|
||||
}
|
||||
|
||||
count, err := prb.Obligations.CountForRiskID(ctx, obj.ParentID, obligationFilter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count risk obligations: %w", err))
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
return 0, fmt.Errorf("unsupported resolver: %T", obj.Resolver)
|
||||
@@ -4388,6 +4427,36 @@ func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int
|
||||
return types.NewControlConnection(page, r, obj.ID, filters), nil
|
||||
}
|
||||
|
||||
// Obligations is the resolver for the obligations field.
|
||||
func (r *riskResolver) Obligations(ctx context.Context, obj *types.Risk, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ObligationOrderBy, filter *types.ObligationFilter) (*types.ObligationConnection, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ObligationOrderField]{
|
||||
Field: coredata.ObligationOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.ObligationOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
var obligationFilter = coredata.NewObligationFilter(nil)
|
||||
if filter != nil {
|
||||
obligationFilter = coredata.NewObligationFilter(&filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.Obligations.ListForRiskID(ctx, obj.ID, cursor, obligationFilter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list risk obligations: %w", err))
|
||||
}
|
||||
|
||||
return types.NewObligationConnection(page, r, obj.ID, filter), nil
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.RiskConnection) (int, error) {
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
|
||||
Reference in New Issue
Block a user