Add compliance registry snapshots
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -40,6 +40,8 @@ type (
|
||||
LastReviewDate *time.Time `db:"last_review_date"`
|
||||
DueDate *time.Time `db:"due_date"`
|
||||
Status ComplianceRegistryStatus `db:"status"`
|
||||
SnapshotID *gid.GID `db:"snapshot_id"`
|
||||
SourceID *gid.GID `db:"source_id"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
@@ -74,6 +76,8 @@ func (cr *ComplianceRegistry) LoadByID(
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
snapshot_id,
|
||||
source_id,
|
||||
reference_id,
|
||||
area,
|
||||
source,
|
||||
@@ -119,6 +123,7 @@ func (crs *ComplianceRegistries) CountByOrganizationID(
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
filter *ComplianceRegistryFilter,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -128,12 +133,14 @@ FROM
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
AND %s
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), filter.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, filter.SQLArguments())
|
||||
|
||||
row := conn.QueryRow(ctx, q, args)
|
||||
|
||||
@@ -152,6 +159,7 @@ func (crs *ComplianceRegistries) LoadByOrganizationID(
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[ComplianceRegistryOrderField],
|
||||
filter *ComplianceRegistryFilter,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -167,6 +175,8 @@ SELECT
|
||||
last_review_date,
|
||||
due_date,
|
||||
status,
|
||||
snapshot_id,
|
||||
source_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -175,12 +185,14 @@ WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
AND %s
|
||||
AND %s
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), filter.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, filter.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
@@ -218,6 +230,8 @@ INSERT INTO compliance_registries (
|
||||
last_review_date,
|
||||
due_date,
|
||||
status,
|
||||
snapshot_id,
|
||||
source_id,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@@ -234,6 +248,8 @@ INSERT INTO compliance_registries (
|
||||
@last_review_date,
|
||||
@due_date,
|
||||
@status,
|
||||
@snapshot_id,
|
||||
@source_id,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
@@ -253,6 +269,8 @@ INSERT INTO compliance_registries (
|
||||
"last_review_date": cr.LastReviewDate,
|
||||
"due_date": cr.DueDate,
|
||||
"status": cr.Status,
|
||||
"snapshot_id": cr.SnapshotID,
|
||||
"source_id": cr.SourceID,
|
||||
"created_at": cr.CreatedAt,
|
||||
"updated_at": cr.UpdatedAt,
|
||||
}
|
||||
@@ -286,6 +304,7 @@ UPDATE compliance_registries SET
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
AND snapshot_id IS NULL
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
@@ -324,6 +343,7 @@ DELETE FROM compliance_registries
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
AND snapshot_id IS NULL
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
@@ -338,3 +358,64 @@ WHERE
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (crs ComplianceRegistries) Snapshot(ctx context.Context, conn pg.Conn, scope Scoper, organizationID, snapshotID gid.GID) error {
|
||||
query := `
|
||||
INSERT INTO compliance_registries (
|
||||
id,
|
||||
tenant_id,
|
||||
snapshot_id,
|
||||
source_id,
|
||||
organization_id,
|
||||
reference_id,
|
||||
area,
|
||||
source,
|
||||
requirement,
|
||||
actions_to_be_implemented,
|
||||
regulator,
|
||||
owner_id,
|
||||
last_review_date,
|
||||
due_date,
|
||||
status,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
SELECT
|
||||
generate_gid(decode_base64_unpadded(@tenant_id), @compliance_registry_entity_type),
|
||||
@tenant_id,
|
||||
@snapshot_id,
|
||||
r.id,
|
||||
r.organization_id,
|
||||
r.reference_id,
|
||||
r.area,
|
||||
r.source,
|
||||
r.requirement,
|
||||
r.actions_to_be_implemented,
|
||||
r.regulator,
|
||||
r.owner_id,
|
||||
r.last_review_date,
|
||||
r.due_date,
|
||||
r.status,
|
||||
r.created_at,
|
||||
r.updated_at
|
||||
FROM compliance_registries r
|
||||
WHERE %s AND r.organization_id = @organization_id AND r.snapshot_id IS NULL
|
||||
`
|
||||
|
||||
query = fmt.Sprintf(query, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"snapshot_id": snapshotID,
|
||||
"organization_id": organizationID,
|
||||
"compliance_registry_entity_type": ComplianceRegistryEntityType,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, query, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert compliance registry snapshots: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
54
pkg/coredata/compliance_registry_filter.go
Normal file
54
pkg/coredata/compliance_registry_filter.go
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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 (
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
type (
|
||||
ComplianceRegistryFilter struct {
|
||||
snapshotID **gid.GID
|
||||
}
|
||||
)
|
||||
|
||||
func NewComplianceRegistryFilter(snapshotID **gid.GID) *ComplianceRegistryFilter {
|
||||
return &ComplianceRegistryFilter{
|
||||
snapshotID: snapshotID,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *ComplianceRegistryFilter) SQLArguments() pgx.NamedArgs {
|
||||
args := pgx.NamedArgs{}
|
||||
|
||||
if f.snapshotID != nil && *f.snapshotID != nil {
|
||||
args["filter_snapshot_id"] = **f.snapshotID
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
func (f *ComplianceRegistryFilter) SQLFragment() string {
|
||||
if f.snapshotID == nil {
|
||||
return "TRUE"
|
||||
}
|
||||
|
||||
if *f.snapshotID == nil {
|
||||
return "snapshot_id IS NULL"
|
||||
} else {
|
||||
return "snapshot_id = @filter_snapshot_id"
|
||||
}
|
||||
}
|
||||
@@ -25,13 +25,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func NewDatumFilter() *DatumFilter {
|
||||
return &DatumFilter{
|
||||
snapshotID: nil,
|
||||
}
|
||||
}
|
||||
|
||||
func NewDatumFilterBySnapshotID(snapshotID **gid.GID) *DatumFilter {
|
||||
func NewDatumFilter(snapshotID **gid.GID) *DatumFilter {
|
||||
return &DatumFilter{
|
||||
snapshotID: snapshotID,
|
||||
}
|
||||
|
||||
11
pkg/coredata/migrations/20250828T201559Z.sql
Normal file
11
pkg/coredata/migrations/20250828T201559Z.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
ALTER TABLE compliance_registries ADD COLUMN snapshot_id TEXT;
|
||||
ALTER TABLE compliance_registries ADD COLUMN source_id TEXT;
|
||||
|
||||
ALTER TABLE compliance_registries ADD CONSTRAINT compliance_registries_snapshot_id_fkey
|
||||
FOREIGN KEY (snapshot_id)
|
||||
REFERENCES snapshots(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE compliance_registries ADD CONSTRAINT compliance_registries_source_id_snapshot_id_key
|
||||
UNIQUE (source_id, snapshot_id);
|
||||
@@ -25,18 +25,12 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func NewNonconformityRegistryFilter() *NonconformityRegistryFilter {
|
||||
func NewNonconformityRegistryFilter(snapshotID **gid.GID) *NonconformityRegistryFilter {
|
||||
return &NonconformityRegistryFilter{
|
||||
snapshotID: nil,
|
||||
}
|
||||
}
|
||||
|
||||
func NewNonconformityRegistryFilterBySnapshotID(snapshotID **gid.GID) *NonconformityRegistryFilter {
|
||||
return &NonconformityRegistryFilter{
|
||||
snapshotID: snapshotID,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *NonconformityRegistryFilter) SQLArguments() pgx.NamedArgs {
|
||||
args := pgx.NamedArgs{}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ func GetSnapshottable(snapshotType SnapshotsType) (Snapshottable, error) {
|
||||
return Data{}, nil
|
||||
case SnapshotsTypeNonConformityRegistries:
|
||||
return NonconformityRegistries{}, nil
|
||||
case SnapshotsTypeComplianceRegistries:
|
||||
return ComplianceRegistries{}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported snapshot type: %s", snapshotType)
|
||||
}
|
||||
|
||||
@@ -26,20 +26,10 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func NewVendorFilter() *VendorFilter {
|
||||
return &VendorFilter{}
|
||||
}
|
||||
|
||||
func NewVendorTrustCenterFilter() *VendorFilter {
|
||||
showOnTrustCenter := true
|
||||
func NewVendorFilter(snapshotID **gid.GID, showOnTrustCenter *bool) *VendorFilter {
|
||||
return &VendorFilter{
|
||||
showOnTrustCenter: &showOnTrustCenter,
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendorFilterBySnapshotID(snapshotID **gid.GID) *VendorFilter {
|
||||
return &VendorFilter{
|
||||
snapshotID: snapshotID,
|
||||
snapshotID: snapshotID,
|
||||
showOnTrustCenter: showOnTrustCenter,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -231,9 +231,10 @@ func (s *ComplianceRegistryService) Delete(
|
||||
return err
|
||||
}
|
||||
|
||||
func (s ComplianceRegistryService) CountByOrganizationID(
|
||||
func (s ComplianceRegistryService) CountForOrganizationID(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
filter *coredata.ComplianceRegistryFilter,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -241,7 +242,7 @@ func (s ComplianceRegistryService) CountByOrganizationID(
|
||||
ctx,
|
||||
func(conn pg.Conn) (err error) {
|
||||
registries := coredata.ComplianceRegistries{}
|
||||
count, err = registries.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID)
|
||||
count, err = registries.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID, filter)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count compliance registries: %w", err)
|
||||
}
|
||||
@@ -261,13 +262,14 @@ func (s ComplianceRegistryService) ListForOrganizationID(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[coredata.ComplianceRegistryOrderField],
|
||||
filter *coredata.ComplianceRegistryFilter,
|
||||
) (*page.Page[*coredata.ComplianceRegistry, coredata.ComplianceRegistryOrderField], error) {
|
||||
var registries coredata.ComplianceRegistries
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := registries.LoadByOrganizationID(ctx, conn, s.svc.scope, organizationID, cursor)
|
||||
err := registries.LoadByOrganizationID(ctx, conn, s.svc.scope, organizationID, cursor, filter)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load compliance registries: %w", err)
|
||||
}
|
||||
|
||||
@@ -1110,6 +1110,10 @@ input NonconformityRegistryFilter {
|
||||
snapshotId: ID
|
||||
}
|
||||
|
||||
input ComplianceRegistryFilter {
|
||||
snapshotId: ID
|
||||
}
|
||||
|
||||
# Core Types
|
||||
type TrustCenter implements Node {
|
||||
id: ID!
|
||||
@@ -1258,6 +1262,7 @@ type Organization implements Node {
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: ComplianceRegistryOrder
|
||||
filter: ComplianceRegistryFilter
|
||||
): ComplianceRegistryConnection! @goField(forceResolver: true)
|
||||
|
||||
continualImprovementRegistries(
|
||||
@@ -1721,6 +1726,8 @@ type NonconformityRegistry implements Node {
|
||||
|
||||
type ComplianceRegistry implements Node {
|
||||
id: ID!
|
||||
snapshotId: ID
|
||||
sourceId: ID
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
referenceId: String!
|
||||
area: String
|
||||
|
||||
@@ -183,7 +183,9 @@ type ComplexityRoot struct {
|
||||
ReferenceID func(childComplexity int) int
|
||||
Regulator func(childComplexity int) int
|
||||
Requirement func(childComplexity int) int
|
||||
SnapshotID func(childComplexity int) int
|
||||
Source func(childComplexity int) int
|
||||
SourceID func(childComplexity int) int
|
||||
Status func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
}
|
||||
@@ -871,7 +873,7 @@ type ComplexityRoot struct {
|
||||
Organization struct {
|
||||
Assets func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.AssetOrderBy) int
|
||||
Audits func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.AuditOrderBy) int
|
||||
ComplianceRegistries func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ComplianceRegistryOrderBy) int
|
||||
ComplianceRegistries func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ComplianceRegistryOrderBy, filter *types.ComplianceRegistryFilter) int
|
||||
Connectors func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ConnectorOrder) int
|
||||
ContinualImprovementRegistries func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ContinualImprovementRegistriesOrderBy) int
|
||||
Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) int
|
||||
@@ -1669,7 +1671,7 @@ type OrganizationResolver interface {
|
||||
Data(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DatumOrderBy, filter *types.DatumFilter) (*types.DatumConnection, error)
|
||||
Audits(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.AuditOrderBy) (*types.AuditConnection, error)
|
||||
NonconformityRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.NonconformityRegistryOrderBy, filter *types.NonconformityRegistryFilter) (*types.NonconformityRegistryConnection, error)
|
||||
ComplianceRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ComplianceRegistryOrderBy) (*types.ComplianceRegistryConnection, error)
|
||||
ComplianceRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ComplianceRegistryOrderBy, filter *types.ComplianceRegistryFilter) (*types.ComplianceRegistryConnection, error)
|
||||
ContinualImprovementRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ContinualImprovementRegistriesOrderBy) (*types.ContinualImprovementRegistryConnection, error)
|
||||
ProcessingActivityRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProcessingActivityRegistryOrderBy) (*types.ProcessingActivityRegistryConnection, error)
|
||||
Snapshots(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.SnapshotOrderBy) (*types.SnapshotConnection, error)
|
||||
@@ -2155,6 +2157,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.ComplianceRegistry.Requirement(childComplexity), true
|
||||
|
||||
case "ComplianceRegistry.snapshotId":
|
||||
if e.complexity.ComplianceRegistry.SnapshotID == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.ComplianceRegistry.SnapshotID(childComplexity), true
|
||||
|
||||
case "ComplianceRegistry.source":
|
||||
if e.complexity.ComplianceRegistry.Source == nil {
|
||||
break
|
||||
@@ -2162,6 +2171,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.ComplianceRegistry.Source(childComplexity), true
|
||||
|
||||
case "ComplianceRegistry.sourceId":
|
||||
if e.complexity.ComplianceRegistry.SourceID == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.ComplianceRegistry.SourceID(childComplexity), true
|
||||
|
||||
case "ComplianceRegistry.status":
|
||||
if e.complexity.ComplianceRegistry.Status == nil {
|
||||
break
|
||||
@@ -5370,7 +5386,7 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Organization.ComplianceRegistries(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.ComplianceRegistryOrderBy)), true
|
||||
return e.complexity.Organization.ComplianceRegistries(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.ComplianceRegistryOrderBy), args["filter"].(*types.ComplianceRegistryFilter)), true
|
||||
|
||||
case "Organization.connectors":
|
||||
if e.complexity.Organization.Connectors == nil {
|
||||
@@ -7655,6 +7671,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
||||
ec.unmarshalInputBulkPublishDocumentVersionsInput,
|
||||
ec.unmarshalInputBulkRequestSignaturesInput,
|
||||
ec.unmarshalInputCancelSignatureRequestInput,
|
||||
ec.unmarshalInputComplianceRegistryFilter,
|
||||
ec.unmarshalInputComplianceRegistryOrder,
|
||||
ec.unmarshalInputConfirmEmailInput,
|
||||
ec.unmarshalInputConnectorOrder,
|
||||
@@ -9002,6 +9019,10 @@ input NonconformityRegistryFilter {
|
||||
snapshotId: ID
|
||||
}
|
||||
|
||||
input ComplianceRegistryFilter {
|
||||
snapshotId: ID
|
||||
}
|
||||
|
||||
# Core Types
|
||||
type TrustCenter implements Node {
|
||||
id: ID!
|
||||
@@ -9150,6 +9171,7 @@ type Organization implements Node {
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: ComplianceRegistryOrder
|
||||
filter: ComplianceRegistryFilter
|
||||
): ComplianceRegistryConnection! @goField(forceResolver: true)
|
||||
|
||||
continualImprovementRegistries(
|
||||
@@ -9613,6 +9635,8 @@ type NonconformityRegistry implements Node {
|
||||
|
||||
type ComplianceRegistry implements Node {
|
||||
id: ID!
|
||||
snapshotId: ID
|
||||
sourceId: ID
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
referenceId: String!
|
||||
area: String
|
||||
@@ -15993,6 +16017,11 @@ func (ec *executionContext) field_Organization_complianceRegistries_args(ctx con
|
||||
return nil, err
|
||||
}
|
||||
args["orderBy"] = arg4
|
||||
arg5, err := ec.field_Organization_complianceRegistries_argsFilter(ctx, rawArgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["filter"] = arg5
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Organization_complianceRegistries_argsFirst(
|
||||
@@ -16060,6 +16089,19 @@ func (ec *executionContext) field_Organization_complianceRegistries_argsOrderBy(
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Organization_complianceRegistries_argsFilter(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (*types.ComplianceRegistryFilter, error) {
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("filter"))
|
||||
if tmp, ok := rawArgs["filter"]; ok {
|
||||
return ec.unmarshalOComplianceRegistryFilter2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐComplianceRegistryFilter(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal *types.ComplianceRegistryFilter
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Organization_connectors_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
@@ -21086,6 +21128,88 @@ func (ec *executionContext) fieldContext_ComplianceRegistry_id(_ context.Context
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _ComplianceRegistry_snapshotId(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceRegistry) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_ComplianceRegistry_snapshotId(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.SnapshotID, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*gid.GID)
|
||||
fc.Result = res
|
||||
return ec.marshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_ComplianceRegistry_snapshotId(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "ComplianceRegistry",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type ID does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _ComplianceRegistry_sourceId(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceRegistry) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_ComplianceRegistry_sourceId(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.SourceID, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*gid.GID)
|
||||
fc.Result = res
|
||||
return ec.marshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_ComplianceRegistry_sourceId(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "ComplianceRegistry",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type ID does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _ComplianceRegistry_organization(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceRegistry) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_ComplianceRegistry_organization(ctx, field)
|
||||
if err != nil {
|
||||
@@ -21942,6 +22066,10 @@ func (ec *executionContext) fieldContext_ComplianceRegistryEdge_node(_ context.C
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_ComplianceRegistry_id(ctx, field)
|
||||
case "snapshotId":
|
||||
return ec.fieldContext_ComplianceRegistry_snapshotId(ctx, field)
|
||||
case "sourceId":
|
||||
return ec.fieldContext_ComplianceRegistry_sourceId(ctx, field)
|
||||
case "organization":
|
||||
return ec.fieldContext_ComplianceRegistry_organization(ctx, field)
|
||||
case "referenceId":
|
||||
@@ -41945,7 +42073,7 @@ func (ec *executionContext) _Organization_complianceRegistries(ctx context.Conte
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Organization().ComplianceRegistries(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey), fc.Args["orderBy"].(*types.ComplianceRegistryOrderBy))
|
||||
return ec.resolvers.Organization().ComplianceRegistries(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey), fc.Args["orderBy"].(*types.ComplianceRegistryOrderBy), fc.Args["filter"].(*types.ComplianceRegistryFilter))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -49630,6 +49758,10 @@ func (ec *executionContext) fieldContext_UpdateComplianceRegistryPayload_complia
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_ComplianceRegistry_id(ctx, field)
|
||||
case "snapshotId":
|
||||
return ec.fieldContext_ComplianceRegistry_snapshotId(ctx, field)
|
||||
case "sourceId":
|
||||
return ec.fieldContext_ComplianceRegistry_sourceId(ctx, field)
|
||||
case "organization":
|
||||
return ec.fieldContext_ComplianceRegistry_organization(ctx, field)
|
||||
case "referenceId":
|
||||
@@ -59434,6 +59566,33 @@ func (ec *executionContext) unmarshalInputCancelSignatureRequestInput(ctx contex
|
||||
return it, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalInputComplianceRegistryFilter(ctx context.Context, obj any) (types.ComplianceRegistryFilter, error) {
|
||||
var it types.ComplianceRegistryFilter
|
||||
asMap := map[string]any{}
|
||||
for k, v := range obj.(map[string]any) {
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"snapshotId"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch k {
|
||||
case "snapshotId":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("snapshotId"))
|
||||
data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.SnapshotID = data
|
||||
}
|
||||
}
|
||||
|
||||
return it, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalInputComplianceRegistryOrder(ctx context.Context, obj any) (types.ComplianceRegistryOrderBy, error) {
|
||||
var it types.ComplianceRegistryOrderBy
|
||||
asMap := map[string]any{}
|
||||
@@ -66673,6 +66832,10 @@ func (ec *executionContext) _ComplianceRegistry(ctx context.Context, sel ast.Sel
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "snapshotId":
|
||||
out.Values[i] = ec._ComplianceRegistry_snapshotId(ctx, field, obj)
|
||||
case "sourceId":
|
||||
out.Values[i] = ec._ComplianceRegistry_sourceId(ctx, field, obj)
|
||||
case "organization":
|
||||
field := field
|
||||
|
||||
@@ -86692,6 +86855,14 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast
|
||||
return res
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOComplianceRegistryFilter2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐComplianceRegistryFilter(ctx context.Context, v any) (*types.ComplianceRegistryFilter, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
res, err := ec.unmarshalInputComplianceRegistryFilter(ctx, v)
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOComplianceRegistryOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐComplianceRegistryOrderBy(ctx context.Context, v any) (*types.ComplianceRegistryOrderBy, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
|
||||
@@ -30,6 +30,7 @@ type (
|
||||
|
||||
Resolver any
|
||||
ParentID gid.GID
|
||||
Filter *ComplianceRegistryFilter
|
||||
}
|
||||
)
|
||||
|
||||
@@ -37,6 +38,7 @@ func NewComplianceRegistryConnection(
|
||||
p *page.Page[*coredata.ComplianceRegistry, coredata.ComplianceRegistryOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
filter *ComplianceRegistryFilter,
|
||||
) *ComplianceRegistryConnection {
|
||||
edges := make([]*ComplianceRegistryEdge, len(p.Data))
|
||||
for i, registry := range p.Data {
|
||||
@@ -49,12 +51,15 @@ func NewComplianceRegistryConnection(
|
||||
|
||||
Resolver: parentType,
|
||||
ParentID: parentID,
|
||||
Filter: filter,
|
||||
}
|
||||
}
|
||||
|
||||
func NewComplianceRegistry(cr *coredata.ComplianceRegistry) *ComplianceRegistry {
|
||||
return &ComplianceRegistry{
|
||||
ID: cr.ID,
|
||||
SnapshotID: cr.SnapshotID,
|
||||
SourceID: cr.SourceID,
|
||||
ReferenceID: cr.ReferenceID,
|
||||
Area: cr.Area,
|
||||
Source: cr.Source,
|
||||
|
||||
@@ -109,6 +109,8 @@ type CancelSignatureRequestPayload struct {
|
||||
|
||||
type ComplianceRegistry struct {
|
||||
ID gid.GID `json:"id"`
|
||||
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"`
|
||||
@@ -132,6 +134,10 @@ type ComplianceRegistryEdge struct {
|
||||
Node *ComplianceRegistry `json:"node"`
|
||||
}
|
||||
|
||||
type ComplianceRegistryFilter struct {
|
||||
SnapshotID *gid.GID `json:"snapshotId,omitempty"`
|
||||
}
|
||||
|
||||
type ConfirmEmailInput struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
@@ -260,7 +260,12 @@ func (r *complianceRegistryConnectionResolver) TotalCount(ctx context.Context, o
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.ComplianceRegistries.CountByOrganizationID(ctx, obj.ParentID)
|
||||
complianceRegistryFilter := coredata.NewComplianceRegistryFilter(nil)
|
||||
if obj.Filter != nil {
|
||||
complianceRegistryFilter = coredata.NewComplianceRegistryFilter(&obj.Filter.SnapshotID)
|
||||
}
|
||||
|
||||
count, err := prb.ComplianceRegistries.CountForOrganizationID(ctx, obj.ParentID, complianceRegistryFilter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count compliance registries: %w", err))
|
||||
}
|
||||
@@ -3313,9 +3318,9 @@ func (r *nonconformityRegistryConnectionResolver) TotalCount(ctx context.Context
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
nonconformityRegistryFilter := coredata.NewNonconformityRegistryFilterBySnapshotID(nil)
|
||||
nonconformityRegistryFilter := coredata.NewNonconformityRegistryFilter(nil)
|
||||
if obj.Filter != nil {
|
||||
nonconformityRegistryFilter = coredata.NewNonconformityRegistryFilterBySnapshotID(&obj.Filter.SnapshotID)
|
||||
nonconformityRegistryFilter = coredata.NewNonconformityRegistryFilter(&obj.Filter.SnapshotID)
|
||||
}
|
||||
|
||||
count, err := prb.NonconformityRegistries.CountForOrganizationID(ctx, obj.ParentID, nonconformityRegistryFilter)
|
||||
@@ -3455,7 +3460,7 @@ func (r *organizationResolver) Vendors(ctx context.Context, obj *types.Organizat
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
var nilSnapshotID *gid.GID = nil
|
||||
vendorFilter := coredata.NewVendorFilterBySnapshotID(&nilSnapshotID)
|
||||
vendorFilter := coredata.NewVendorFilter(&nilSnapshotID, nil)
|
||||
|
||||
page, err := prb.Vendors.ListForOrganizationID(ctx, obj.ID, cursor, vendorFilter)
|
||||
if err != nil {
|
||||
@@ -3652,9 +3657,9 @@ func (r *organizationResolver) Data(ctx context.Context, obj *types.Organization
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
datumFilter := coredata.NewDatumFilterBySnapshotID(nil)
|
||||
datumFilter := coredata.NewDatumFilter(nil)
|
||||
if filter != nil {
|
||||
datumFilter = coredata.NewDatumFilterBySnapshotID(&filter.SnapshotID)
|
||||
datumFilter = coredata.NewDatumFilter(&filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.Data.ListForOrganizationID(ctx, obj.ID, cursor, datumFilter)
|
||||
@@ -3707,9 +3712,9 @@ func (r *organizationResolver) NonconformityRegistries(ctx context.Context, obj
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
nonconformityRegistryFilter := coredata.NewNonconformityRegistryFilterBySnapshotID(nil)
|
||||
nonconformityRegistryFilter := coredata.NewNonconformityRegistryFilter(nil)
|
||||
if filter != nil {
|
||||
nonconformityRegistryFilter = coredata.NewNonconformityRegistryFilterBySnapshotID(&filter.SnapshotID)
|
||||
nonconformityRegistryFilter = coredata.NewNonconformityRegistryFilter(&filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.NonconformityRegistries.ListForOrganizationID(ctx, obj.ID, cursor, nonconformityRegistryFilter)
|
||||
@@ -3721,7 +3726,7 @@ func (r *organizationResolver) NonconformityRegistries(ctx context.Context, obj
|
||||
}
|
||||
|
||||
// ComplianceRegistries is the resolver for the complianceRegistries field.
|
||||
func (r *organizationResolver) ComplianceRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ComplianceRegistryOrderBy) (*types.ComplianceRegistryConnection, error) {
|
||||
func (r *organizationResolver) ComplianceRegistries(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ComplianceRegistryOrderBy, filter *types.ComplianceRegistryFilter) (*types.ComplianceRegistryConnection, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ComplianceRegistryOrderField]{
|
||||
@@ -3737,12 +3742,17 @@ func (r *organizationResolver) ComplianceRegistries(ctx context.Context, obj *ty
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.ComplianceRegistries.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
complianceRegistryFilter := coredata.NewComplianceRegistryFilter(nil)
|
||||
if filter != nil {
|
||||
complianceRegistryFilter = coredata.NewComplianceRegistryFilter(&filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.ComplianceRegistries.ListForOrganizationID(ctx, obj.ID, cursor, complianceRegistryFilter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization compliance registries: %w", err))
|
||||
}
|
||||
|
||||
return types.NewComplianceRegistryConnection(page, r, obj.ID), nil
|
||||
return types.NewComplianceRegistryConnection(page, r, obj.ID, filter), nil
|
||||
}
|
||||
|
||||
// ContinualImprovementRegistries is the resolver for the continualImprovementRegistries field.
|
||||
|
||||
@@ -63,7 +63,8 @@ func (s VendorService) ListForOrganizationId(
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
filter := coredata.NewVendorTrustCenterFilter()
|
||||
showOnTrustCenter := true
|
||||
filter := coredata.NewVendorFilter(nil, &showOnTrustCenter)
|
||||
err := vendors.LoadByOrganizationID(ctx, conn, s.svc.scope, organizationID, cursor, filter)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load vendors: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user