Add risk tier, criticality on vendors

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-18 11:14:20 +01:00
parent 53bceb5479
commit 6da223ed36
10 changed files with 940 additions and 236 deletions

View File

@@ -117,6 +117,11 @@ type Vendor implements Node {
name: String!
createdAt: Datetime!
updatedAt: Datetime!
serviceStartDate: Datetime!
serviceTerminationDate: Datetime
serviceCriticality: ServiceCriticality!
riskTier: RiskTier!
statusPageUrl: String
}
type FrameworkConnection {
@@ -328,4 +333,26 @@ input CreatePeopleInput {
fullName: String!
primaryEmailAddress: String!
kind: PeopleKind!
}
enum ServiceCriticality @goModel(model: "github.com/getprobo/probo/pkg/probo/coredata.ServiceCriticality") {
LOW @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.ServiceCriticalityLow")
MEDIUM @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.ServiceCriticalityMedium")
HIGH @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.ServiceCriticalityHigh")
}
enum RiskTier @goModel(model: "github.com/getprobo/probo/pkg/probo/coredata.RiskTier") {
CRITICAL @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.RiskTierCritical")
SIGNIFICANT @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.RiskTierSignificant")
GENERAL @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.RiskTierGeneral")
}
input UpdateVendorInput {
id: ID!
name: String
serviceStartDate: Datetime
serviceTerminationDate: Datetime
serviceCriticality: ServiceCriticality
riskTier: RiskTier
statusPageUrl: String
}

View File

@@ -245,10 +245,15 @@ type ComplexityRoot struct {
}
Vendor struct {
CreatedAt func(childComplexity int) int
ID func(childComplexity int) int
Name func(childComplexity int) int
UpdatedAt func(childComplexity int) int
CreatedAt func(childComplexity int) int
ID func(childComplexity int) int
Name func(childComplexity int) int
RiskTier func(childComplexity int) int
ServiceCriticality func(childComplexity int) int
ServiceStartDate func(childComplexity int) int
ServiceTerminationDate func(childComplexity int) int
StatusPageURL func(childComplexity int) int
UpdatedAt func(childComplexity int) int
}
VendorConnection struct {
@@ -1136,6 +1141,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Vendor.Name(childComplexity), true
case "Vendor.riskTier":
if e.complexity.Vendor.RiskTier == nil {
break
}
return e.complexity.Vendor.RiskTier(childComplexity), true
case "Vendor.serviceCriticality":
if e.complexity.Vendor.ServiceCriticality == nil {
break
}
return e.complexity.Vendor.ServiceCriticality(childComplexity), true
case "Vendor.serviceStartDate":
if e.complexity.Vendor.ServiceStartDate == nil {
break
}
return e.complexity.Vendor.ServiceStartDate(childComplexity), true
case "Vendor.serviceTerminationDate":
if e.complexity.Vendor.ServiceTerminationDate == nil {
break
}
return e.complexity.Vendor.ServiceTerminationDate(childComplexity), true
case "Vendor.statusPageUrl":
if e.complexity.Vendor.StatusPageURL == nil {
break
}
return e.complexity.Vendor.StatusPageURL(childComplexity), true
case "Vendor.updatedAt":
if e.complexity.Vendor.UpdatedAt == nil {
break
@@ -1183,6 +1223,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
ec.unmarshalInputCreateVendorInput,
ec.unmarshalInputDeletePeopleInput,
ec.unmarshalInputDeleteVendorInput,
ec.unmarshalInputUpdateVendorInput,
)
first := true
@@ -1399,6 +1440,11 @@ type Vendor implements Node {
name: String!
createdAt: Datetime!
updatedAt: Datetime!
serviceStartDate: Datetime!
serviceTerminationDate: Datetime
serviceCriticality: ServiceCriticality!
riskTier: RiskTier!
statusPageUrl: String
}
type FrameworkConnection {
@@ -1610,6 +1656,28 @@ input CreatePeopleInput {
fullName: String!
primaryEmailAddress: String!
kind: PeopleKind!
}
enum ServiceCriticality @goModel(model: "github.com/getprobo/probo/pkg/probo/coredata.ServiceCriticality") {
LOW @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.ServiceCriticalityLow")
MEDIUM @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.ServiceCriticalityMedium")
HIGH @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.ServiceCriticalityHigh")
}
enum RiskTier @goModel(model: "github.com/getprobo/probo/pkg/probo/coredata.RiskTier") {
CRITICAL @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.RiskTierCritical")
SIGNIFICANT @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.RiskTierSignificant")
GENERAL @goEnum(value: "github.com/getprobo/probo/pkg/probo/coredata.RiskTierGeneral")
}
input UpdateVendorInput {
id: ID!
name: String
serviceStartDate: Datetime
serviceTerminationDate: Datetime
serviceCriticality: ServiceCriticality
riskTier: RiskTier
statusPageUrl: String
}`, BuiltIn: false},
}
var parsedSchema = gqlparser.MustLoadSchema(sources...)
@@ -4826,6 +4894,16 @@ func (ec *executionContext) fieldContext_Mutation_createVendor(ctx context.Conte
return ec.fieldContext_Vendor_createdAt(ctx, field)
case "updatedAt":
return ec.fieldContext_Vendor_updatedAt(ctx, field)
case "serviceStartDate":
return ec.fieldContext_Vendor_serviceStartDate(ctx, field)
case "serviceTerminationDate":
return ec.fieldContext_Vendor_serviceTerminationDate(ctx, field)
case "serviceCriticality":
return ec.fieldContext_Vendor_serviceCriticality(ctx, field)
case "riskTier":
return ec.fieldContext_Vendor_riskTier(ctx, field)
case "statusPageUrl":
return ec.fieldContext_Vendor_statusPageUrl(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Vendor", field.Name)
},
@@ -7138,6 +7216,190 @@ func (ec *executionContext) fieldContext_Vendor_updatedAt(_ context.Context, fie
return fc, nil
}
func (ec *executionContext) _Vendor_serviceStartDate(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Vendor_serviceStartDate(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.ServiceStartDate, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(time.Time)
fc.Result = res
return ec.marshalNDatetime2timeᚐTime(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Vendor_serviceStartDate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Vendor",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Datetime does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Vendor_serviceTerminationDate(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Vendor_serviceTerminationDate(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.ServiceTerminationDate, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*time.Time)
fc.Result = res
return ec.marshalODatetime2ᚖtimeᚐTime(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Vendor_serviceTerminationDate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Vendor",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Datetime does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Vendor_serviceCriticality(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Vendor_serviceCriticality(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.ServiceCriticality, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(coredata.ServiceCriticality)
fc.Result = res
return ec.marshalNServiceCriticality2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Vendor_serviceCriticality(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Vendor",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type ServiceCriticality does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Vendor_riskTier(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Vendor_riskTier(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.RiskTier, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(coredata.RiskTier)
fc.Result = res
return ec.marshalNRiskTier2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Vendor_riskTier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Vendor",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type RiskTier does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Vendor_statusPageUrl(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Vendor_statusPageUrl(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.StatusPageURL, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
fc.Result = res
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Vendor_statusPageUrl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Vendor",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _VendorConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.VendorConnection) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_VendorConnection_edges(ctx, field)
if err != nil {
@@ -7309,6 +7571,16 @@ func (ec *executionContext) fieldContext_VendorEdge_node(_ context.Context, fiel
return ec.fieldContext_Vendor_createdAt(ctx, field)
case "updatedAt":
return ec.fieldContext_Vendor_updatedAt(ctx, field)
case "serviceStartDate":
return ec.fieldContext_Vendor_serviceStartDate(ctx, field)
case "serviceTerminationDate":
return ec.fieldContext_Vendor_serviceTerminationDate(ctx, field)
case "serviceCriticality":
return ec.fieldContext_Vendor_serviceCriticality(ctx, field)
case "riskTier":
return ec.fieldContext_Vendor_riskTier(ctx, field)
case "statusPageUrl":
return ec.fieldContext_Vendor_statusPageUrl(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Vendor", field.Name)
},
@@ -9003,6 +9275,75 @@ func (ec *executionContext) unmarshalInputDeleteVendorInput(ctx context.Context,
return it, nil
}
func (ec *executionContext) unmarshalInputUpdateVendorInput(ctx context.Context, obj any) (types.UpdateVendorInput, error) {
var it types.UpdateVendorInput
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
asMap[k] = v
}
fieldsInOrder := [...]string{"id", "name", "serviceStartDate", "serviceTerminationDate", "serviceCriticality", "riskTier", "statusPageUrl"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
continue
}
switch k {
case "id":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
if err != nil {
return it, err
}
it.ID = data
case "name":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
if err != nil {
return it, err
}
it.Name = data
case "serviceStartDate":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceStartDate"))
data, err := ec.unmarshalODatetime2ᚖtimeᚐTime(ctx, v)
if err != nil {
return it, err
}
it.ServiceStartDate = data
case "serviceTerminationDate":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceTerminationDate"))
data, err := ec.unmarshalODatetime2ᚖtimeᚐTime(ctx, v)
if err != nil {
return it, err
}
it.ServiceTerminationDate = data
case "serviceCriticality":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceCriticality"))
data, err := ec.unmarshalOServiceCriticality2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality(ctx, v)
if err != nil {
return it, err
}
it.ServiceCriticality = data
case "riskTier":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("riskTier"))
data, err := ec.unmarshalORiskTier2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier(ctx, v)
if err != nil {
return it, err
}
it.RiskTier = data
case "statusPageUrl":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusPageUrl"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
if err != nil {
return it, err
}
it.StatusPageURL = data
}
}
return it, nil
}
// endregion **************************** input.gotpl *****************************
// region ************************** interface.gotpl ***************************
@@ -10831,6 +11172,25 @@ func (ec *executionContext) _Vendor(ctx context.Context, sel ast.SelectionSet, o
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "serviceStartDate":
out.Values[i] = ec._Vendor_serviceStartDate(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "serviceTerminationDate":
out.Values[i] = ec._Vendor_serviceTerminationDate(ctx, field, obj)
case "serviceCriticality":
out.Values[i] = ec._Vendor_serviceCriticality(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "riskTier":
out.Values[i] = ec._Vendor_riskTier(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "statusPageUrl":
out.Values[i] = ec._Vendor_statusPageUrl(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -11906,6 +12266,64 @@ var (
}
)
func (ec *executionContext) unmarshalNRiskTier2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier(ctx context.Context, v any) (coredata.RiskTier, error) {
tmp, err := graphql.UnmarshalString(v)
res := unmarshalNRiskTier2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier[tmp]
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNRiskTier2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier(ctx context.Context, sel ast.SelectionSet, v coredata.RiskTier) graphql.Marshaler {
res := graphql.MarshalString(marshalNRiskTier2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier[v])
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
var (
unmarshalNRiskTier2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier = map[string]coredata.RiskTier{
"CRITICAL": coredata.RiskTierCritical,
"SIGNIFICANT": coredata.RiskTierSignificant,
"GENERAL": coredata.RiskTierGeneral,
}
marshalNRiskTier2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier = map[coredata.RiskTier]string{
coredata.RiskTierCritical: "CRITICAL",
coredata.RiskTierSignificant: "SIGNIFICANT",
coredata.RiskTierGeneral: "GENERAL",
}
)
func (ec *executionContext) unmarshalNServiceCriticality2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality(ctx context.Context, v any) (coredata.ServiceCriticality, error) {
tmp, err := graphql.UnmarshalString(v)
res := unmarshalNServiceCriticality2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality[tmp]
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNServiceCriticality2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality(ctx context.Context, sel ast.SelectionSet, v coredata.ServiceCriticality) graphql.Marshaler {
res := graphql.MarshalString(marshalNServiceCriticality2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality[v])
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
var (
unmarshalNServiceCriticality2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality = map[string]coredata.ServiceCriticality{
"LOW": coredata.ServiceCriticalityLow,
"MEDIUM": coredata.ServiceCriticalityMedium,
"HIGH": coredata.ServiceCriticalityHigh,
}
marshalNServiceCriticality2githubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality = map[coredata.ServiceCriticality]string{
coredata.ServiceCriticalityLow: "LOW",
coredata.ServiceCriticalityMedium: "MEDIUM",
coredata.ServiceCriticalityHigh: "HIGH",
}
)
func (ec *executionContext) unmarshalNString2string(ctx context.Context, v any) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -12518,6 +12936,22 @@ func (ec *executionContext) marshalOCursorKey2ᚖgithubᚗcomᚋgetproboᚋprobo
return res
}
func (ec *executionContext) unmarshalODatetime2ᚖtimeᚐTime(ctx context.Context, v any) (*time.Time, error) {
if v == nil {
return nil, nil
}
res, err := graphql.UnmarshalTime(v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalODatetime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler {
if v == nil {
return graphql.Null
}
res := graphql.MarshalTime(*v)
return res
}
func (ec *executionContext) unmarshalOEvidenceState2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐEvidenceState(ctx context.Context, v any) (*coredata.EvidenceState, error) {
if v == nil {
return nil, nil
@@ -12564,6 +12998,66 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele
return res
}
func (ec *executionContext) unmarshalORiskTier2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier(ctx context.Context, v any) (*coredata.RiskTier, error) {
if v == nil {
return nil, nil
}
tmp, err := graphql.UnmarshalString(v)
res := unmarshalORiskTier2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier[tmp]
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalORiskTier2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier(ctx context.Context, sel ast.SelectionSet, v *coredata.RiskTier) graphql.Marshaler {
if v == nil {
return graphql.Null
}
res := graphql.MarshalString(marshalORiskTier2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier[*v])
return res
}
var (
unmarshalORiskTier2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier = map[string]coredata.RiskTier{
"CRITICAL": coredata.RiskTierCritical,
"SIGNIFICANT": coredata.RiskTierSignificant,
"GENERAL": coredata.RiskTierGeneral,
}
marshalORiskTier2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐRiskTier = map[coredata.RiskTier]string{
coredata.RiskTierCritical: "CRITICAL",
coredata.RiskTierSignificant: "SIGNIFICANT",
coredata.RiskTierGeneral: "GENERAL",
}
)
func (ec *executionContext) unmarshalOServiceCriticality2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality(ctx context.Context, v any) (*coredata.ServiceCriticality, error) {
if v == nil {
return nil, nil
}
tmp, err := graphql.UnmarshalString(v)
res := unmarshalOServiceCriticality2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality[tmp]
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOServiceCriticality2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality(ctx context.Context, sel ast.SelectionSet, v *coredata.ServiceCriticality) graphql.Marshaler {
if v == nil {
return graphql.Null
}
res := graphql.MarshalString(marshalOServiceCriticality2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality[*v])
return res
}
var (
unmarshalOServiceCriticality2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality = map[string]coredata.ServiceCriticality{
"LOW": coredata.ServiceCriticalityLow,
"MEDIUM": coredata.ServiceCriticalityMedium,
"HIGH": coredata.ServiceCriticalityHigh,
}
marshalOServiceCriticality2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋproboᚋcoredataᚐServiceCriticality = map[coredata.ServiceCriticality]string{
coredata.ServiceCriticalityLow: "LOW",
coredata.ServiceCriticalityMedium: "MEDIUM",
coredata.ServiceCriticalityHigh: "HIGH",
}
)
func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
if v == nil {
return nil, nil

View File

@@ -237,11 +237,26 @@ type TaskStateTransitionEdge struct {
Node *TaskStateTransition `json:"node"`
}
type UpdateVendorInput struct {
ID gid.GID `json:"id"`
Name *string `json:"name,omitempty"`
ServiceStartDate *time.Time `json:"serviceStartDate,omitempty"`
ServiceTerminationDate *time.Time `json:"serviceTerminationDate,omitempty"`
ServiceCriticality *coredata.ServiceCriticality `json:"serviceCriticality,omitempty"`
RiskTier *coredata.RiskTier `json:"riskTier,omitempty"`
StatusPageURL *string `json:"statusPageUrl,omitempty"`
}
type Vendor struct {
ID gid.GID `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
ID gid.GID `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
ServiceStartDate time.Time `json:"serviceStartDate"`
ServiceTerminationDate *time.Time `json:"serviceTerminationDate,omitempty"`
ServiceCriticality coredata.ServiceCriticality `json:"serviceCriticality"`
RiskTier coredata.RiskTier `json:"riskTier"`
StatusPageURL *string `json:"statusPageUrl,omitempty"`
}
func (Vendor) IsNode() {}

View File

@@ -41,9 +41,14 @@ func NewVendorEdge(v *coredata.Vendor) *VendorEdge {
func NewVendor(v *coredata.Vendor) *Vendor {
return &Vendor{
ID: v.ID,
Name: v.Name,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
ID: v.ID,
Name: v.Name,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
ServiceStartDate: v.ServiceStartDate,
ServiceTerminationDate: v.ServiceTerminationDate,
ServiceCriticality: v.ServiceCriticality,
RiskTier: v.RiskTier,
StatusPageURL: v.StatusPageURL,
}
}

View File

@@ -0,0 +1,15 @@
CREATE TYPE service_criticality AS ENUM ('LOW', 'MEDIUM', 'HIGH');
CREATE TYPE risk_tier AS ENUM ('CRITICAL', 'SIGNIFICANT', 'GENERAL');
ALTER TABLE vendors
ADD COLUMN service_start_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
ADD COLUMN service_termination_date TIMESTAMP WITH TIME ZONE,
ADD COLUMN service_criticality service_criticality NOT NULL DEFAULT 'LOW',
ADD COLUMN risk_tier risk_tier NOT NULL DEFAULT 'GENERAL',
ADD COLUMN status_page_url TEXT;
UPDATE vendors SET service_start_date = created_at;
ALTER TABLE vendors ALTER COLUMN service_start_date DROP DEFAULT;
ALTER TABLE vendors ALTER COLUMN service_criticality DROP DEFAULT;
ALTER TABLE vendors ALTER COLUMN risk_tier DROP DEFAULT;

View File

@@ -0,0 +1,66 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package coredata
import (
"database/sql/driver"
"fmt"
)
type RiskTier string
const (
RiskTierCritical RiskTier = "CRITICAL" // Handles sensitive data, critical for platform operation
RiskTierSignificant RiskTier = "SIGNIFICANT" // No user data access, but important for platform management
RiskTierGeneral RiskTier = "GENERAL" // General vendor with minimal risk
)
func (rt RiskTier) MarshalText() ([]byte, error) {
return []byte(rt.String()), nil
}
func (rt *RiskTier) UnmarshalText(data []byte) error {
val := string(data)
switch val {
case RiskTierCritical.String():
*rt = RiskTierCritical
case RiskTierSignificant.String():
*rt = RiskTierSignificant
case RiskTierGeneral.String():
*rt = RiskTierGeneral
default:
return fmt.Errorf("invalid RiskTier value: %q", val)
}
return nil
}
func (rt RiskTier) String() string {
return string(rt)
}
func (rt *RiskTier) Scan(value any) error {
val, ok := value.(string)
if !ok {
return fmt.Errorf("invalid scan source for RiskTier, expected string got %T", value)
}
return rt.UnmarshalText([]byte(val))
}
func (rt RiskTier) Value() (driver.Value, error) {
return rt.String(), nil
}

View File

@@ -0,0 +1,66 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package coredata
import (
"database/sql/driver"
"fmt"
)
type ServiceCriticality string
const (
ServiceCriticalityLow ServiceCriticality = "LOW"
ServiceCriticalityMedium ServiceCriticality = "MEDIUM"
ServiceCriticalityHigh ServiceCriticality = "HIGH"
)
func (sc ServiceCriticality) MarshalText() ([]byte, error) {
return []byte(sc.String()), nil
}
func (sc *ServiceCriticality) UnmarshalText(data []byte) error {
val := string(data)
switch val {
case ServiceCriticalityLow.String():
*sc = ServiceCriticalityLow
case ServiceCriticalityMedium.String():
*sc = ServiceCriticalityMedium
case ServiceCriticalityHigh.String():
*sc = ServiceCriticalityHigh
default:
return fmt.Errorf("invalid ServiceCriticality value: %q", val)
}
return nil
}
func (sc ServiceCriticality) String() string {
return string(sc)
}
func (sc *ServiceCriticality) Scan(value any) error {
val, ok := value.(string)
if !ok {
return fmt.Errorf("invalid scan source for ServiceCriticality, expected string got %T", value)
}
return sc.UnmarshalText([]byte(val))
}
func (sc ServiceCriticality) Value() (driver.Value, error) {
return sc.String(), nil
}

View File

@@ -28,11 +28,16 @@ import (
type (
Vendor struct {
ID gid.GID
OrganizationID gid.GID
Name string
CreatedAt time.Time
UpdatedAt time.Time
ID gid.GID
OrganizationID gid.GID
Name string
ServiceStartDate time.Time
ServiceTerminationDate *time.Time
ServiceCriticality ServiceCriticality
RiskTier RiskTier
StatusPageURL *string
CreatedAt time.Time
UpdatedAt time.Time
}
Vendors []*Vendor
@@ -47,6 +52,11 @@ func (v *Vendor) scan(r pgx.Row) error {
&v.ID,
&v.OrganizationID,
&v.Name,
&v.ServiceStartDate,
&v.ServiceTerminationDate,
&v.ServiceCriticality,
&v.RiskTier,
&v.StatusPageURL,
&v.CreatedAt,
&v.UpdatedAt,
)
@@ -63,6 +73,11 @@ SELECT
id,
organization_id,
name,
service_start_date,
service_termination_date,
service_criticality,
risk_tier,
status_page_url,
created_at,
updated_at
FROM
@@ -100,6 +115,11 @@ INSERT INTO
id,
organization_id,
name,
service_start_date,
service_termination_date,
service_criticality,
risk_tier,
status_page_url,
created_at,
updated_at
)
@@ -107,17 +127,27 @@ VALUES (
@vendor_id,
@organization_id,
@name,
@service_start_date,
@service_termination_date,
@service_criticality,
@risk_tier,
@status_page_url,
@created_at,
@updated_at
)
`
args := pgx.NamedArgs{
"vendor_id": v.ID,
"organization_id": v.OrganizationID,
"name": v.Name,
"created_at": v.CreatedAt,
"updated_at": v.UpdatedAt,
"vendor_id": v.ID,
"organization_id": v.OrganizationID,
"name": v.Name,
"service_start_date": v.ServiceStartDate,
"service_termination_date": v.ServiceTerminationDate,
"service_criticality": v.ServiceCriticality,
"risk_tier": v.RiskTier,
"status_page_url": v.StatusPageURL,
"created_at": v.CreatedAt,
"updated_at": v.UpdatedAt,
}
_, err := conn.Exec(ctx, q, args)
return err
@@ -153,6 +183,11 @@ SELECT
id,
organization_id,
name,
service_start_date,
service_termination_date,
service_criticality,
risk_tier,
status_page_url,
created_at,
updated_at
FROM
@@ -167,7 +202,7 @@ WHERE
args := pgx.NamedArgs{"organization_id": organizationID}
maps.Copy(args, cursor.SQLArguments())
maps.Copy(args, cursor.SQLArguments())
maps.Copy(args, scope.SQLArguments())
r, err := conn.Query(ctx, q, args)
if err != nil {