From 4bf3d4df793d7a79a4f25966069c56fdfb5e0bfc Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Mon, 20 Jul 2026 18:08:13 +0200 Subject: [PATCH] Rename trust center coredata types Align entity types, order fields, and visibility enums with the Compliance Portal product name so the data layer matches the rest of the rename. Signed-off-by: Bryan Frimin --- pkg/coredata/audit.go | 26 +- pkg/coredata/audit_filter.go | 22 +- pkg/coredata/audit_log_resource_type.go | 20 +- pkg/coredata/compliance_custom_link.go | 26 +- pkg/coredata/compliance_framework.go | 38 +-- .../{trust_center.go => compliance_portal.go} | 74 ++--- ..._access.go => compliance_portal_access.go} | 60 ++-- ...> compliance_portal_access_order_field.go} | 36 +-- ...e.go => compliance_portal_access_state.go} | 36 +-- pkg/coredata/compliance_portal_commitment.go | 24 +- .../compliance_portal_commitment_group.go | 32 +-- ...o => compliance_portal_document_access.go} | 262 +++++++++--------- ...nce_portal_document_access_order_field.go} | 34 +-- ...ompliance_portal_document_access_status.go | 82 ++++++ ...nter_file.go => compliance_portal_file.go} | 84 +++--- ...er.go => compliance_portal_file_filter.go} | 26 +- ... => compliance_portal_file_order_field.go} | 57 ++-- ...ld.go => compliance_portal_order_field.go} | 34 +-- ...ence.go => compliance_portal_reference.go} | 86 +++--- ...compliance_portal_reference_order_field.go | 102 +++++++ ...ity.go => compliance_portal_visibility.go} | 42 +-- pkg/coredata/document.go | 24 +- pkg/coredata/document_filter.go | 36 +-- pkg/coredata/entity_type_reg.go | 30 +- pkg/coredata/membership_profile_filter.go | 24 +- pkg/coredata/slack_message_type.go | 8 +- pkg/coredata/third_party.go | 10 +- pkg/coredata/third_party_filter.go | 26 +- .../trust_center_document_access_status.go | 82 ------ pkg/coredata/trust_center_file_order_field.go | 97 ------- 30 files changed, 770 insertions(+), 770 deletions(-) rename pkg/coredata/{trust_center.go => compliance_portal.go} (83%) rename pkg/coredata/{trust_center_access.go => compliance_portal_access.go} (80%) rename pkg/coredata/{trust_center_access_order_field.go => compliance_portal_access_order_field.go} (56%) rename pkg/coredata/{trust_center_access_state.go => compliance_portal_access_state.go} (57%) rename pkg/coredata/{trust_center_document_access.go => compliance_portal_document_access.go} (76%) rename pkg/coredata/{trust_center_document_access_order_field.go => compliance_portal_document_access_order_field.go} (53%) create mode 100644 pkg/coredata/compliance_portal_document_access_status.go rename pkg/coredata/{trust_center_file.go => compliance_portal_file.go} (75%) rename pkg/coredata/{trust_center_file_filter.go => compliance_portal_file_filter.go} (66%) rename pkg/coredata/{trust_center_reference_order_field.go => compliance_portal_file_order_field.go} (50%) rename pkg/coredata/{trust_center_order_field.go => compliance_portal_order_field.go} (59%) rename pkg/coredata/{trust_center_reference.go => compliance_portal_reference.go} (76%) create mode 100644 pkg/coredata/compliance_portal_reference_order_field.go rename pkg/coredata/{trust_center_visibility.go => compliance_portal_visibility.go} (54%) delete mode 100644 pkg/coredata/trust_center_document_access_status.go delete mode 100644 pkg/coredata/trust_center_file_order_field.go diff --git a/pkg/coredata/audit.go b/pkg/coredata/audit.go index 126aacc58..4d693f50a 100644 --- a/pkg/coredata/audit.go +++ b/pkg/coredata/audit.go @@ -36,17 +36,17 @@ import ( type ( Audit struct { - ID gid.GID `db:"id"` - Name *string `db:"name"` - OrganizationID gid.GID `db:"organization_id"` - FrameworkID gid.GID `db:"framework_id"` - ReportFileID *gid.GID `db:"report_file_id"` - ValidFrom *time.Time `db:"valid_from"` - ValidUntil *time.Time `db:"valid_until"` - State AuditState `db:"state"` - TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + Name *string `db:"name"` + OrganizationID gid.GID `db:"organization_id"` + FrameworkID gid.GID `db:"framework_id"` + ReportFileID *gid.GID `db:"report_file_id"` + ValidFrom *time.Time `db:"valid_from"` + ValidUntil *time.Time `db:"valid_until"` + State AuditState `db:"state"` + CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } Audits []*Audit @@ -288,7 +288,7 @@ INSERT INTO audits ( "valid_from": a.ValidFrom, "valid_until": a.ValidUntil, "state": a.State, - "trust_center_visibility": a.TrustCenterVisibility, + "trust_center_visibility": a.CompliancePortalVisibility, "created_at": a.CreatedAt, "updated_at": a.UpdatedAt, } @@ -330,7 +330,7 @@ WHERE "valid_from": a.ValidFrom, "valid_until": a.ValidUntil, "state": a.State, - "trust_center_visibility": a.TrustCenterVisibility, + "trust_center_visibility": a.CompliancePortalVisibility, "updated_at": a.UpdatedAt, } maps.Copy(args, scope.SQLArguments()) diff --git a/pkg/coredata/audit_filter.go b/pkg/coredata/audit_filter.go index d37075143..17250f8e1 100644 --- a/pkg/coredata/audit_filter.go +++ b/pkg/coredata/audit_filter.go @@ -26,7 +26,7 @@ import ( type ( AuditFilter struct { - trustCenterVisibilities []TrustCenterVisibility + compliancePortalVisibilities []CompliancePortalVisibility } ) @@ -34,26 +34,26 @@ func NewAuditFilter() *AuditFilter { return &AuditFilter{} } -func NewAuditTrustCenterFilter() *AuditFilter { +func NewAuditCompliancePortalFilter() *AuditFilter { return &AuditFilter{ - trustCenterVisibilities: []TrustCenterVisibility{ - TrustCenterVisibilityPrivate, - TrustCenterVisibilityPublic, + compliancePortalVisibilities: []CompliancePortalVisibility{ + CompliancePortalVisibilityPrivate, + CompliancePortalVisibilityPublic, }, } } -func (f *AuditFilter) WithTrustCenterVisibilities(visibilities ...TrustCenterVisibility) *AuditFilter { - f.trustCenterVisibilities = visibilities +func (f *AuditFilter) WithCompliancePortalVisibilities(visibilities ...CompliancePortalVisibility) *AuditFilter { + f.compliancePortalVisibilities = visibilities return f } func (f *AuditFilter) SQLArguments() pgx.NamedArgs { args := pgx.NamedArgs{} - if f.trustCenterVisibilities != nil { - visibilities := make([]string, len(f.trustCenterVisibilities)) - for i, v := range f.trustCenterVisibilities { + if f.compliancePortalVisibilities != nil { + visibilities := make([]string, len(f.compliancePortalVisibilities)) + for i, v := range f.compliancePortalVisibilities { visibilities[i] = v.String() } @@ -64,7 +64,7 @@ func (f *AuditFilter) SQLArguments() pgx.NamedArgs { } func (f *AuditFilter) SQLFragment() string { - if f.trustCenterVisibilities != nil { + if f.compliancePortalVisibilities != nil { return "trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])" } diff --git a/pkg/coredata/audit_log_resource_type.go b/pkg/coredata/audit_log_resource_type.go index 8a272e43e..67da8b189 100644 --- a/pkg/coredata/audit_log_resource_type.go +++ b/pkg/coredata/audit_log_resource_type.go @@ -59,10 +59,10 @@ func ResourceTypeName(entityType uint16) string { return "Datum" case AuditEntityType: return "Audit" - case TrustCenterEntityType: - return "TrustCenter" - case TrustCenterAccessEntityType: - return "TrustCenterAccess" + case CompliancePortalEntityType: + return "CompliancePortal" + case CompliancePortalAccessEntityType: + return "CompliancePortalAccess" case ThirdPartyBusinessAssociateAgreementEntityType: return "ThirdPartyBusinessAssociateAgreement" case FileEntityType: @@ -79,18 +79,18 @@ func ResourceTypeName(entityType uint16) string { return "ThirdPartyService" case ProcessingActivityEntityType: return "ProcessingActivity" - case TrustCenterReferenceEntityType: - return "TrustCenterReference" - case TrustCenterDocumentAccessEntityType: - return "TrustCenterDocumentAccess" + case CompliancePortalReferenceEntityType: + return "CompliancePortalReference" + case CompliancePortalDocumentAccessEntityType: + return "CompliancePortalDocumentAccess" case CustomDomainEntityType: return "CustomDomain" case InvitationEntityType: return "Invitation" case MembershipEntityType: return "Membership" - case TrustCenterFileEntityType: - return "TrustCenterFile" + case CompliancePortalFileEntityType: + return "CompliancePortalFile" case DataProtectionImpactAssessmentEntityType: return "DataProtectionImpactAssessment" case TransferImpactAssessmentEntityType: diff --git a/pkg/coredata/compliance_custom_link.go b/pkg/coredata/compliance_custom_link.go index 6bc53c9d4..9f2ad2c6a 100644 --- a/pkg/coredata/compliance_custom_link.go +++ b/pkg/coredata/compliance_custom_link.go @@ -36,14 +36,14 @@ import ( type ( ComplianceCustomLink struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - TrustCenterID gid.GID `db:"trust_center_id"` - Name string `db:"name"` - URL string `db:"url"` - Rank int `db:"rank"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CompliancePortalID gid.GID `db:"trust_center_id"` + Name string `db:"name"` + URL string `db:"url"` + Rank int `db:"rank"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } ComplianceCustomLinks []*ComplianceCustomLink @@ -182,7 +182,7 @@ RETURNING rank; "id": c.ID, "tenant_id": scope.GetTenantID(), "organization_id": c.OrganizationID, - "trust_center_id": c.TrustCenterID, + "trust_center_id": c.CompliancePortalID, "name": c.Name, "url": c.URL, "created_at": c.CreatedAt, @@ -267,7 +267,7 @@ WHERE %s args := pgx.StrictNamedArgs{ "id": c.ID, "new_rank": c.Rank, - "trust_center_id": c.TrustCenterID, + "trust_center_id": c.CompliancePortalID, "updated_at": c.UpdatedAt, } maps.Copy(args, scope.SQLArguments()) @@ -305,11 +305,11 @@ WHERE return nil } -func (c *ComplianceCustomLinks) LoadByTrustCenterID( +func (c *ComplianceCustomLinks) LoadByCompliancePortalID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, cursor *page.Cursor[ComplianceCustomLinkOrderField], ) error { q := ` @@ -331,7 +331,7 @@ WHERE ` q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) - args := pgx.NamedArgs{"trust_center_id": trustCenterID} + args := pgx.NamedArgs{"trust_center_id": compliancePortalID} maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) diff --git a/pkg/coredata/compliance_framework.go b/pkg/coredata/compliance_framework.go index 415897278..1f5a6990d 100644 --- a/pkg/coredata/compliance_framework.go +++ b/pkg/coredata/compliance_framework.go @@ -37,15 +37,15 @@ import ( type ( ComplianceFramework struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - TrustCenterID gid.GID `db:"trust_center_id"` - FrameworkID gid.GID `db:"framework_id"` - Rank int `db:"rank"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CompliancePortalID gid.GID `db:"trust_center_id"` + FrameworkID gid.GID `db:"framework_id"` + Rank int `db:"rank"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` - // Visibility is a non-db field used to return all frameworks for a trust center, including hidden ones. + // Visibility is a non-db field used to return all frameworks for a compliance portal, including hidden ones. Visibility ComplianceFrameworkVisibility `db:"visibility"` } @@ -149,11 +149,11 @@ LIMIT 1; return nil } -func (c *ComplianceFramework) LoadByTrustCenterIDAndFrameworkID( +func (c *ComplianceFramework) LoadByCompliancePortalIDAndFrameworkID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, frameworkID gid.GID, ) error { q := ` @@ -177,7 +177,7 @@ LIMIT 1; q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_id": trustCenterID, + "trust_center_id": compliancePortalID, "framework_id": frameworkID, } maps.Copy(args, scope.SQLArguments()) @@ -235,7 +235,7 @@ RETURNING rank; "id": c.ID, "tenant_id": scope.GetTenantID(), "organization_id": c.OrganizationID, - "trust_center_id": c.TrustCenterID, + "trust_center_id": c.CompliancePortalID, "framework_id": c.FrameworkID, "created_at": c.CreatedAt, "updated_at": c.UpdatedAt, @@ -292,7 +292,7 @@ WHERE %s args := pgx.StrictNamedArgs{ "id": c.ID, "new_rank": c.Rank, - "trust_center_id": c.TrustCenterID, + "trust_center_id": c.CompliancePortalID, "updated_at": c.UpdatedAt, } maps.Copy(args, scope.SQLArguments()) @@ -330,11 +330,11 @@ WHERE return nil } -func (c *ComplianceFrameworks) LoadByTrustCenterID( +func (c *ComplianceFrameworks) LoadByCompliancePortalID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, cursor *page.Cursor[ComplianceFrameworkOrderField], ) error { q := ` @@ -356,7 +356,7 @@ WHERE ` q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) - args := pgx.NamedArgs{"trust_center_id": trustCenterID} + args := pgx.NamedArgs{"trust_center_id": compliancePortalID} maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) @@ -375,11 +375,11 @@ WHERE return nil } -func (c *ComplianceFrameworks) LoadWithHiddenByTrustCenterID( +func (c *ComplianceFrameworks) LoadWithHiddenByCompliancePortalID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, cursor *page.Cursor[ComplianceFrameworkOrderField], ) error { q := ` @@ -413,7 +413,7 @@ WHERE %s ` q = fmt.Sprintf(q, cursor.SQLFragment()) - args := pgx.NamedArgs{"trust_center_id": trustCenterID} + args := pgx.NamedArgs{"trust_center_id": compliancePortalID} maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) diff --git a/pkg/coredata/trust_center.go b/pkg/coredata/compliance_portal.go similarity index 83% rename from pkg/coredata/trust_center.go rename to pkg/coredata/compliance_portal.go index 4ceb5739d..1a39ba441 100644 --- a/pkg/coredata/trust_center.go +++ b/pkg/coredata/compliance_portal.go @@ -36,7 +36,7 @@ import ( ) type ( - TrustCenter struct { + CompliancePortal struct { ID gid.GID `db:"id"` OrganizationID gid.GID `db:"organization_id"` TenantID gid.TenantID `db:"tenant_id"` @@ -58,19 +58,19 @@ type ( UpdatedAt time.Time `db:"updated_at"` } - TrustCenters []*TrustCenter + CompliancePortals []*CompliancePortal ) -func (tc *TrustCenter) CursorKey(orderBy TrustCenterOrderField) page.CursorKey { +func (tc *CompliancePortal) CursorKey(orderBy CompliancePortalOrderField) page.CursorKey { switch orderBy { - case TrustCenterOrderFieldCreatedAt: + case CompliancePortalOrderFieldCreatedAt: return page.NewCursorKey(tc.ID, tc.CreatedAt) } panic(fmt.Sprintf("unsupported order by: %s", orderBy)) } -func (tc *TrustCenter) AuthorizationAttributes( +func (tc *CompliancePortal) AuthorizationAttributes( ctx context.Context, conn pg.Querier, resourceIDs []gid.GID, @@ -109,11 +109,11 @@ func (tc *TrustCenter) AuthorizationAttributes( return attrsByID, nil } -func (tc *TrustCenter) LoadByID( +func (tc *CompliancePortal) LoadByID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, ) error { q := ` SELECT @@ -146,29 +146,29 @@ LIMIT 1; q = fmt.Sprintf(q, scope.SQLFragment()) - args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID} + args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID} maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center: %w", err) + return fmt.Errorf("cannot query compliance portal: %w", err) } - trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter]) + compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center: %w", err) + return fmt.Errorf("cannot collect compliance portal: %w", err) } - *tc = trustCenter + *tc = compliancePortal return nil } -func (tc *TrustCenter) LoadByMailingListID( +func (tc *CompliancePortal) LoadByMailingListID( ctx context.Context, conn pg.Querier, scope Scoper, @@ -210,24 +210,24 @@ LIMIT 1; rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center by mailing list id: %w", err) + return fmt.Errorf("cannot query compliance portal by mailing list id: %w", err) } - trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter]) + compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center: %w", err) + return fmt.Errorf("cannot collect compliance portal: %w", err) } - *tc = trustCenter + *tc = compliancePortal return nil } -func (tc *TrustCenter) LoadByOrganizationID( +func (tc *CompliancePortal) LoadByOrganizationID( ctx context.Context, conn pg.Querier, scope Scoper, @@ -269,25 +269,25 @@ LIMIT 1; rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center: %w", err) + return fmt.Errorf("cannot query compliance portal: %w", err) } - trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter]) + compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center: %w", err) + return fmt.Errorf("cannot collect compliance portal: %w", err) } - *tc = trustCenter + *tc = compliancePortal return nil } -// Tenant id scope is not applied because we want to access trust centers by slug across all tenants for public access. -func (tc *TrustCenter) LoadBySlug( +// Tenant id scope is not applied because we want to access compliance portals by slug across all tenants for public access. +func (tc *CompliancePortal) LoadBySlug( ctx context.Context, conn pg.Querier, slug string, @@ -324,19 +324,19 @@ LIMIT 1; rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center: %w", err) + return fmt.Errorf("cannot query compliance portal: %w", err) } - trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter]) + compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center: %w", err) + return fmt.Errorf("cannot collect compliance portal: %w", err) } - *tc = trustCenter + *tc = compliancePortal return nil } @@ -346,7 +346,7 @@ LIMIT 1; // reverse SNI lookup: a served host resolves to a custom domain, which resolves // back to its page. Tenant scope is not applied because SNI resolution happens // across all tenants for public access. -func (tc *TrustCenter) LoadByDomainID( +func (tc *CompliancePortal) LoadByDomainID( ctx context.Context, conn pg.Querier, domainID gid.GID, @@ -384,24 +384,24 @@ LIMIT 1; rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center by domain id: %w", err) + return fmt.Errorf("cannot query compliance portal by domain id: %w", err) } - trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter]) + compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center: %w", err) + return fmt.Errorf("cannot collect compliance portal: %w", err) } - *tc = trustCenter + *tc = compliancePortal return nil } -func (tc *TrustCenter) Insert( +func (tc *CompliancePortal) Insert( ctx context.Context, conn pg.Tx, scope Scoper, @@ -480,13 +480,13 @@ INSERT INTO trust_centers ( } } - return fmt.Errorf("cannot insert trust center: %w", err) + return fmt.Errorf("cannot insert compliance portal: %w", err) } return nil } -func (tc *TrustCenter) Update( +func (tc *CompliancePortal) Update( ctx context.Context, conn pg.Tx, scope Scoper, @@ -536,7 +536,7 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot update trust center: %w", err) + return fmt.Errorf("cannot update compliance portal: %w", err) } return nil diff --git a/pkg/coredata/trust_center_access.go b/pkg/coredata/compliance_portal_access.go similarity index 80% rename from pkg/coredata/trust_center_access.go rename to pkg/coredata/compliance_portal_access.go index 84eecd3c7..e16889ce5 100644 --- a/pkg/coredata/trust_center_access.go +++ b/pkg/coredata/compliance_portal_access.go @@ -36,30 +36,30 @@ import ( ) type ( - TrustCenterAccess struct { + CompliancePortalAccess struct { ID gid.GID `db:"id"` OrganizationID gid.GID `db:"organization_id"` TenantID gid.TenantID `db:"tenant_id"` IdentityID gid.GID `db:"identity_id"` - TrustCenterID gid.GID `db:"trust_center_id"` + CompliancePortalID gid.GID `db:"trust_center_id"` ElectronicSignatureID *gid.GID `db:"electronic_signature_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } - TrustCenterAccesses []*TrustCenterAccess + CompliancePortalAccesses []*CompliancePortalAccess ) -func (tca *TrustCenterAccess) CursorKey(orderBy TrustCenterAccessOrderField) page.CursorKey { +func (tca *CompliancePortalAccess) CursorKey(orderBy CompliancePortalAccessOrderField) page.CursorKey { switch orderBy { - case TrustCenterAccessOrderFieldCreatedAt: + case CompliancePortalAccessOrderFieldCreatedAt: return page.NewCursorKey(tca.ID, tca.CreatedAt) } panic(fmt.Sprintf("unsupported order by: %s", orderBy)) } -func (tca *TrustCenterAccess) AuthorizationAttributes( +func (tca *CompliancePortalAccess) AuthorizationAttributes( ctx context.Context, conn pg.Querier, resourceIDs []gid.GID, @@ -98,7 +98,7 @@ func (tca *TrustCenterAccess) AuthorizationAttributes( return attrsByID, nil } -func (tca *TrustCenterAccess) LoadByID( +func (tca *CompliancePortalAccess) LoadByID( ctx context.Context, conn pg.Querier, scope Scoper, @@ -129,16 +129,16 @@ LIMIT 1; rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center access: %w", err) + return fmt.Errorf("cannot query compliance portal access: %w", err) } - access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterAccess]) + access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalAccess]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center access: %w", err) + return fmt.Errorf("cannot collect compliance portal access: %w", err) } *tca = access @@ -146,11 +146,11 @@ LIMIT 1; return nil } -func (tca *TrustCenterAccess) LoadByTrustCenterIDAndIdentityID( +func (tca *CompliancePortalAccess) LoadByCompliancePortalIDAndIdentityID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, identityID gid.GID, ) error { q := ` @@ -175,23 +175,23 @@ LIMIT 1; q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_id": trustCenterID, + "trust_center_id": compliancePortalID, "identity_id": identityID, } maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center access: %w", err) + return fmt.Errorf("cannot query compliance portal access: %w", err) } - access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterAccess]) + access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalAccess]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center access: %w", err) + return fmt.Errorf("cannot collect compliance portal access: %w", err) } *tca = access @@ -199,7 +199,7 @@ LIMIT 1; return nil } -func (tca *TrustCenterAccess) Insert( +func (tca *CompliancePortalAccess) Insert( ctx context.Context, conn pg.Tx, scope Scoper, @@ -231,7 +231,7 @@ INSERT INTO trust_center_accesses ( "tenant_id": tca.TenantID, "organization_id": tca.OrganizationID, "identity_id": tca.IdentityID, - "trust_center_id": tca.TrustCenterID, + "trust_center_id": tca.CompliancePortalID, "electronic_signature_id": tca.ElectronicSignatureID, "created_at": tca.CreatedAt, "updated_at": tca.UpdatedAt, @@ -245,13 +245,13 @@ INSERT INTO trust_center_accesses ( } } - return fmt.Errorf("cannot insert trust center access: %w", err) + return fmt.Errorf("cannot insert compliance portal access: %w", err) } return nil } -func (tca *TrustCenterAccess) Update( +func (tca *CompliancePortalAccess) Update( ctx context.Context, conn pg.Tx, scope Scoper, @@ -276,13 +276,13 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot update trust center access: %w", err) + return fmt.Errorf("cannot update compliance portal access: %w", err) } return nil } -func (tca *TrustCenterAccess) Delete( +func (tca *CompliancePortalAccess) Delete( ctx context.Context, conn pg.Tx, scope Scoper, @@ -303,18 +303,18 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot delete trust center access: %w", err) + return fmt.Errorf("cannot delete compliance portal access: %w", err) } return nil } -func (tcas *TrustCenterAccesses) LoadByTrustCenterID( +func (tcas *CompliancePortalAccesses) LoadByCompliancePortalID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, - cursor *page.Cursor[TrustCenterAccessOrderField], + compliancePortalID gid.GID, + cursor *page.Cursor[CompliancePortalAccessOrderField], ) error { q := ` SELECT @@ -337,19 +337,19 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_id": trustCenterID, + "trust_center_id": compliancePortalID, } maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center accesses: %w", err) + return fmt.Errorf("cannot query compliance portal accesses: %w", err) } - accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterAccess]) + accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalAccess]) if err != nil { - return fmt.Errorf("cannot collect trust center accesses: %w", err) + return fmt.Errorf("cannot collect compliance portal accesses: %w", err) } *tcas = accesses diff --git a/pkg/coredata/trust_center_access_order_field.go b/pkg/coredata/compliance_portal_access_order_field.go similarity index 56% rename from pkg/coredata/trust_center_access_order_field.go rename to pkg/coredata/compliance_portal_access_order_field.go index cac5fb43d..40075fbfd 100644 --- a/pkg/coredata/trust_center_access_order_field.go +++ b/pkg/coredata/compliance_portal_access_order_field.go @@ -27,47 +27,47 @@ import ( "go.probo.inc/probo/pkg/page" ) -type TrustCenterAccessOrderField string +type CompliancePortalAccessOrderField string const ( - TrustCenterAccessOrderFieldCreatedAt TrustCenterAccessOrderField = "CREATED_AT" + CompliancePortalAccessOrderFieldCreatedAt CompliancePortalAccessOrderField = "CREATED_AT" ) var ( - _ page.OrderField = TrustCenterAccessOrderField("") - _ fmt.Stringer = TrustCenterAccessOrderField("") - _ encoding.TextMarshaler = TrustCenterAccessOrderField("") - _ encoding.TextUnmarshaler = (*TrustCenterAccessOrderField)(nil) + _ page.OrderField = CompliancePortalAccessOrderField("") + _ fmt.Stringer = CompliancePortalAccessOrderField("") + _ encoding.TextMarshaler = CompliancePortalAccessOrderField("") + _ encoding.TextUnmarshaler = (*CompliancePortalAccessOrderField)(nil) ) -func TrustCenterAccessOrderFields() []TrustCenterAccessOrderField { - return []TrustCenterAccessOrderField{ - TrustCenterAccessOrderFieldCreatedAt, +func CompliancePortalAccessOrderFields() []CompliancePortalAccessOrderField { + return []CompliancePortalAccessOrderField{ + CompliancePortalAccessOrderFieldCreatedAt, } } -func (v TrustCenterAccessOrderField) IsValid() bool { +func (v CompliancePortalAccessOrderField) IsValid() bool { switch v { case - TrustCenterAccessOrderFieldCreatedAt: + CompliancePortalAccessOrderFieldCreatedAt: return true } return false } -func (v TrustCenterAccessOrderField) String() string { +func (v CompliancePortalAccessOrderField) String() string { return string(v) } -func (v TrustCenterAccessOrderField) MarshalText() ([]byte, error) { +func (v CompliancePortalAccessOrderField) MarshalText() ([]byte, error) { return []byte(v.String()), nil } -func (v *TrustCenterAccessOrderField) UnmarshalText(text []byte) error { - val := TrustCenterAccessOrderField(text) +func (v *CompliancePortalAccessOrderField) UnmarshalText(text []byte) error { + val := CompliancePortalAccessOrderField(text) if !val.IsValid() { - return fmt.Errorf("invalid TrustCenterAccessOrderField value: %q", string(text)) + return fmt.Errorf("invalid CompliancePortalAccessOrderField value: %q", string(text)) } *v = val @@ -75,9 +75,9 @@ func (v *TrustCenterAccessOrderField) UnmarshalText(text []byte) error { return nil } -func (tcaof TrustCenterAccessOrderField) Column() string { +func (tcaof CompliancePortalAccessOrderField) Column() string { switch tcaof { - case TrustCenterAccessOrderFieldCreatedAt: + case CompliancePortalAccessOrderFieldCreatedAt: return "created_at" } diff --git a/pkg/coredata/trust_center_access_state.go b/pkg/coredata/compliance_portal_access_state.go similarity index 57% rename from pkg/coredata/trust_center_access_state.go rename to pkg/coredata/compliance_portal_access_state.go index 83f31de58..d9857d6c8 100644 --- a/pkg/coredata/trust_center_access_state.go +++ b/pkg/coredata/compliance_portal_access_state.go @@ -25,49 +25,49 @@ import ( "fmt" ) -type TrustCenterAccessState string +type CompliancePortalAccessState string const ( - TrustCenterAccessStateActive TrustCenterAccessState = "ACTIVE" - TrustCenterAccessStateInactive TrustCenterAccessState = "INACTIVE" + CompliancePortalAccessStateActive CompliancePortalAccessState = "ACTIVE" + CompliancePortalAccessStateInactive CompliancePortalAccessState = "INACTIVE" ) var ( - _ fmt.Stringer = TrustCenterAccessState("") - _ encoding.TextMarshaler = TrustCenterAccessState("") - _ encoding.TextUnmarshaler = (*TrustCenterAccessState)(nil) + _ fmt.Stringer = CompliancePortalAccessState("") + _ encoding.TextMarshaler = CompliancePortalAccessState("") + _ encoding.TextUnmarshaler = (*CompliancePortalAccessState)(nil) ) -func TrustCenterAccessStates() []TrustCenterAccessState { - return []TrustCenterAccessState{ - TrustCenterAccessStateActive, - TrustCenterAccessStateInactive, +func CompliancePortalAccessStates() []CompliancePortalAccessState { + return []CompliancePortalAccessState{ + CompliancePortalAccessStateActive, + CompliancePortalAccessStateInactive, } } -func (v TrustCenterAccessState) IsValid() bool { +func (v CompliancePortalAccessState) IsValid() bool { switch v { case - TrustCenterAccessStateActive, - TrustCenterAccessStateInactive: + CompliancePortalAccessStateActive, + CompliancePortalAccessStateInactive: return true } return false } -func (v TrustCenterAccessState) String() string { +func (v CompliancePortalAccessState) String() string { return string(v) } -func (v TrustCenterAccessState) MarshalText() ([]byte, error) { +func (v CompliancePortalAccessState) MarshalText() ([]byte, error) { return []byte(v.String()), nil } -func (v *TrustCenterAccessState) UnmarshalText(text []byte) error { - val := TrustCenterAccessState(text) +func (v *CompliancePortalAccessState) UnmarshalText(text []byte) error { + val := CompliancePortalAccessState(text) if !val.IsValid() { - return fmt.Errorf("invalid TrustCenterAccessState value: %q", string(text)) + return fmt.Errorf("invalid CompliancePortalAccessState value: %q", string(text)) } *v = val diff --git a/pkg/coredata/compliance_portal_commitment.go b/pkg/coredata/compliance_portal_commitment.go index 92ad82076..90a03cc0b 100644 --- a/pkg/coredata/compliance_portal_commitment.go +++ b/pkg/coredata/compliance_portal_commitment.go @@ -37,17 +37,17 @@ import ( type ( CompliancePortalCommitment struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - TrustCenterID gid.GID `db:"trust_center_id"` - GroupID gid.GID `db:"group_id"` - Icon CompliancePortalCommitmentIcon `db:"icon"` - Eyebrow string `db:"eyebrow"` - Title string `db:"title"` - Description string `db:"description"` - Rank int `db:"rank"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CompliancePortalID gid.GID `db:"trust_center_id"` + GroupID gid.GID `db:"group_id"` + Icon CompliancePortalCommitmentIcon `db:"icon"` + Eyebrow string `db:"eyebrow"` + Title string `db:"title"` + Description string `db:"description"` + Rank int `db:"rank"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } CompliancePortalCommitments []*CompliancePortalCommitment @@ -193,7 +193,7 @@ RETURNING rank; "tenant_id": scope.GetTenantID(), "id": t.ID, "organization_id": t.OrganizationID, - "trust_center_id": t.TrustCenterID, + "trust_center_id": t.CompliancePortalID, "group_id": t.GroupID, "icon": t.Icon, "eyebrow": t.Eyebrow, diff --git a/pkg/coredata/compliance_portal_commitment_group.go b/pkg/coredata/compliance_portal_commitment_group.go index 31c7d0c3d..10406b419 100644 --- a/pkg/coredata/compliance_portal_commitment_group.go +++ b/pkg/coredata/compliance_portal_commitment_group.go @@ -37,14 +37,14 @@ import ( type ( CompliancePortalCommitmentGroup struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - TrustCenterID gid.GID `db:"trust_center_id"` - Title string `db:"title"` - Description string `db:"description"` - Rank int `db:"rank"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CompliancePortalID gid.GID `db:"trust_center_id"` + Title string `db:"title"` + Description string `db:"description"` + Rank int `db:"rank"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } CompliancePortalCommitmentGroups []*CompliancePortalCommitmentGroup @@ -181,7 +181,7 @@ RETURNING rank; "tenant_id": scope.GetTenantID(), "id": t.ID, "organization_id": t.OrganizationID, - "trust_center_id": t.TrustCenterID, + "trust_center_id": t.CompliancePortalID, "title": t.Title, "description": t.Description, "created_at": t.CreatedAt, @@ -276,7 +276,7 @@ WHERE %s args := pgx.StrictNamedArgs{ "id": t.ID, "new_rank": t.Rank, - "trust_center_id": t.TrustCenterID, + "trust_center_id": t.CompliancePortalID, "updated_at": t.UpdatedAt, } maps.Copy(args, scope.SQLArguments()) @@ -315,11 +315,11 @@ WHERE return nil } -func (t *CompliancePortalCommitmentGroups) LoadByTrustCenterID( +func (t *CompliancePortalCommitmentGroups) LoadByCompliancePortalID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, cursor *page.Cursor[CompliancePortalCommitmentGroupOrderField], ) error { q := ` @@ -342,7 +342,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) - args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID} + args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID} maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) @@ -361,11 +361,11 @@ WHERE return nil } -func (t *CompliancePortalCommitmentGroups) CountByTrustCenterID( +func (t *CompliancePortalCommitmentGroups) CountByCompliancePortalID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, ) (int, error) { q := ` SELECT @@ -379,7 +379,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) - args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID} + args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID} maps.Copy(args, scope.SQLArguments()) var count int diff --git a/pkg/coredata/trust_center_document_access.go b/pkg/coredata/compliance_portal_document_access.go similarity index 76% rename from pkg/coredata/trust_center_document_access.go rename to pkg/coredata/compliance_portal_document_access.go index 94bc22677..21e8bf759 100644 --- a/pkg/coredata/trust_center_document_access.go +++ b/pkg/coredata/compliance_portal_document_access.go @@ -36,31 +36,31 @@ import ( ) type ( - TrustCenterDocumentAccess struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - TrustCenterAccessID gid.GID `db:"trust_center_access_id"` - DocumentID *gid.GID `db:"document_id"` - ReportFileID *gid.GID `db:"report_file_id"` - TrustCenterFileID *gid.GID `db:"trust_center_file_id"` - Status TrustCenterDocumentAccessStatus `db:"status"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + CompliancePortalDocumentAccess struct { + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CompliancePortalAccessID gid.GID `db:"trust_center_access_id"` + DocumentID *gid.GID `db:"document_id"` + ReportFileID *gid.GID `db:"report_file_id"` + CompliancePortalFileID *gid.GID `db:"trust_center_file_id"` + Status CompliancePortalDocumentAccessStatus `db:"status"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } - TrustCenterDocumentAccesses []*TrustCenterDocumentAccess + CompliancePortalDocumentAccesses []*CompliancePortalDocumentAccess ) -func (tcda *TrustCenterDocumentAccess) CursorKey(orderBy TrustCenterDocumentAccessOrderField) page.CursorKey { +func (tcda *CompliancePortalDocumentAccess) CursorKey(orderBy CompliancePortalDocumentAccessOrderField) page.CursorKey { switch orderBy { - case TrustCenterDocumentAccessOrderFieldCreatedAt: + case CompliancePortalDocumentAccessOrderFieldCreatedAt: return page.NewCursorKey(tcda.ID, tcda.CreatedAt) } panic(fmt.Sprintf("unsupported order by: %s", orderBy)) } -func (tcda *TrustCenterDocumentAccess) AuthorizationAttributes( +func (tcda *CompliancePortalDocumentAccess) AuthorizationAttributes( ctx context.Context, conn pg.Querier, resourceIDs []gid.GID, @@ -99,7 +99,7 @@ func (tcda *TrustCenterDocumentAccess) AuthorizationAttributes( return attrsByID, nil } -func (tcda *TrustCenterDocumentAccess) LoadByID( +func (tcda *CompliancePortalDocumentAccess) LoadByID( ctx context.Context, conn pg.Querier, scope Scoper, @@ -131,16 +131,16 @@ LIMIT 1; rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center document access: %w", err) + return fmt.Errorf("cannot query compliance portal document access: %w", err) } - access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterDocumentAccess]) + access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalDocumentAccess]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center document access: %w", err) + return fmt.Errorf("cannot collect compliance portal document access: %w", err) } *tcda = access @@ -148,11 +148,11 @@ LIMIT 1; return nil } -func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndDocumentID( +func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndDocumentID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, documentID gid.GID, ) error { q := ` @@ -178,23 +178,23 @@ LIMIT 1; q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "document_id": documentID, } maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center document access: %w", err) + return fmt.Errorf("cannot query compliance portal document access: %w", err) } - access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterDocumentAccess]) + access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalDocumentAccess]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center document access: %w", err) + return fmt.Errorf("cannot collect compliance portal document access: %w", err) } *tcda = access @@ -202,11 +202,11 @@ LIMIT 1; return nil } -func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndReportFileID( +func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndReportFileID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, reportFileID gid.GID, ) error { q := ` @@ -232,23 +232,23 @@ LIMIT 1; q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "report_file_id": reportFileID, } maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center document access: %w", err) + return fmt.Errorf("cannot query compliance portal document access: %w", err) } - access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterDocumentAccess]) + access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalDocumentAccess]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center document access: %w", err) + return fmt.Errorf("cannot collect compliance portal document access: %w", err) } *tcda = access @@ -256,7 +256,7 @@ LIMIT 1; return nil } -func (tcda *TrustCenterDocumentAccess) Insert( +func (tcda *CompliancePortalDocumentAccess) Insert( ctx context.Context, conn pg.Tx, scope Scoper, @@ -291,10 +291,10 @@ INSERT INTO trust_center_document_accesses ( "id": tcda.ID, "tenant_id": scope.GetTenantID(), "organization_id": tcda.OrganizationID, - "trust_center_access_id": tcda.TrustCenterAccessID, + "trust_center_access_id": tcda.CompliancePortalAccessID, "document_id": tcda.DocumentID, "report_file_id": tcda.ReportFileID, - "trust_center_file_id": tcda.TrustCenterFileID, + "trust_center_file_id": tcda.CompliancePortalFileID, "status": tcda.Status, "created_at": tcda.CreatedAt, "updated_at": tcda.UpdatedAt, @@ -313,13 +313,13 @@ INSERT INTO trust_center_document_accesses ( } } - return fmt.Errorf("cannot insert trust center document access: %w", err) + return fmt.Errorf("cannot insert compliance portal document access: %w", err) } return nil } -func (tcda *TrustCenterDocumentAccess) Update( +func (tcda *CompliancePortalDocumentAccess) Update( ctx context.Context, conn pg.Tx, scope Scoper, @@ -344,13 +344,13 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot update trust center document access: %w", err) + return fmt.Errorf("cannot update compliance portal document access: %w", err) } return nil } -func (tcda *TrustCenterDocumentAccess) Delete( +func (tcda *CompliancePortalDocumentAccess) Delete( ctx context.Context, conn pg.Tx, scope Scoper, @@ -371,17 +371,17 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot delete trust center document access: %w", err) + return fmt.Errorf("cannot delete compliance portal document access: %w", err) } return nil } -func (tcdas *TrustCenterDocumentAccesses) CountByTrustCenterAccessID( +func (tcdas *CompliancePortalDocumentAccesses) CountByCompliancePortalAccessID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, ) (int, error) { q := ` SELECT @@ -396,7 +396,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, } maps.Copy(args, scope.SQLArguments()) @@ -410,11 +410,11 @@ WHERE return count, nil } -func (tcdas *TrustCenterDocumentAccesses) CountPendingRequestByTrustCenterAccessID( +func (tcdas *CompliancePortalDocumentAccesses) CountPendingRequestByCompliancePortalAccessID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, ) (int, error) { q := ` SELECT @@ -430,7 +430,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, } maps.Copy(args, scope.SQLArguments()) @@ -444,11 +444,11 @@ WHERE return count, nil } -func (tcdas *TrustCenterDocumentAccesses) CountActiveByTrustCenterAccessID( +func (tcdas *CompliancePortalDocumentAccesses) CountActiveByCompliancePortalAccessID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, ) (int, error) { q := ` SELECT @@ -464,7 +464,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, } maps.Copy(args, scope.SQLArguments()) @@ -478,12 +478,12 @@ WHERE return count, nil } -func (tcdas *TrustCenterDocumentAccesses) LoadAvailableByTrustCenterAccessID( +func (tcdas *CompliancePortalDocumentAccesses) LoadAvailableByCompliancePortalAccessID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, - cursor *page.Cursor[TrustCenterDocumentAccessOrderField], + compliancePortalAccessID gid.GID, + cursor *page.Cursor[CompliancePortalDocumentAccessOrderField], ) error { q := ` WITH organization AS ( @@ -581,19 +581,19 @@ WHERE %s q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, } maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center document accesses: %w", err) + return fmt.Errorf("cannot query compliance portal document accesses: %w", err) } - accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterDocumentAccess]) + accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalDocumentAccess]) if err != nil { - return fmt.Errorf("cannot collect trust center document accesses: %w", err) + return fmt.Errorf("cannot collect compliance portal document accesses: %w", err) } *tcdas = accesses @@ -601,12 +601,12 @@ WHERE %s return nil } -func (tcdas *TrustCenterDocumentAccesses) LoadByTrustCenterAccessID( +func (tcdas *CompliancePortalDocumentAccesses) LoadByCompliancePortalAccessID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, - cursor *page.Cursor[TrustCenterDocumentAccessOrderField], + compliancePortalAccessID gid.GID, + cursor *page.Cursor[CompliancePortalDocumentAccessOrderField], ) error { q := ` SELECT @@ -630,19 +630,19 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, } maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center document accesses: %w", err) + return fmt.Errorf("cannot query compliance portal document accesses: %w", err) } - accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterDocumentAccess]) + accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalDocumentAccess]) if err != nil { - return fmt.Errorf("cannot collect trust center document accesses: %w", err) + return fmt.Errorf("cannot collect compliance portal document accesses: %w", err) } *tcdas = accesses @@ -654,7 +654,7 @@ func GrantByDocumentIDs( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, documentIDs []gid.GID, updatedAt time.Time, ) error { @@ -670,7 +670,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "document_ids": documentIDs, "updated_at": updatedAt, } @@ -678,7 +678,7 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot grant trust center document accesses by document IDs: %w", err) + return fmt.Errorf("cannot grant compliance portal document accesses by document IDs: %w", err) } return nil @@ -688,7 +688,7 @@ func RejectOrRevokeByDocumentIDs( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, documentIDs []gid.GID, updatedAt time.Time, ) error { @@ -709,7 +709,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "document_ids": documentIDs, "updated_at": updatedAt, } @@ -717,7 +717,7 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot reject trust center document accesses by document IDs: %w", err) + return fmt.Errorf("cannot reject compliance portal document accesses by document IDs: %w", err) } return nil @@ -727,7 +727,7 @@ func GrantByReportFileIDs( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, reportFileIDs []gid.GID, updatedAt time.Time, ) error { @@ -743,7 +743,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "report_file_ids": reportFileIDs, "updated_at": updatedAt, } @@ -751,7 +751,7 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot grant trust center document accesses by report file IDs: %w", err) + return fmt.Errorf("cannot grant compliance portal document accesses by report file IDs: %w", err) } return nil @@ -761,7 +761,7 @@ func RejectOrRevokeByReportFileIDs( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, reportFileIDs []gid.GID, updatedAt time.Time, ) error { @@ -782,7 +782,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "report_file_ids": reportFileIDs, "updated_at": updatedAt, } @@ -790,24 +790,24 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot reject trust center document accesses by report file IDs: %w", err) + return fmt.Errorf("cannot reject compliance portal document accesses by report file IDs: %w", err) } return nil } -type MergeTrustCenterDocumentAccessesData struct { - ID gid.GID `json:"id"` - Status TrustCenterDocumentAccessStatus `json:"status"` +type MergeCompliancePortalDocumentAccessesData struct { + ID gid.GID `json:"id"` + Status CompliancePortalDocumentAccessStatus `json:"status"` } -func (tcdas TrustCenterDocumentAccesses) MergeDocumentAccesses( +func (tcdas CompliancePortalDocumentAccesses) MergeDocumentAccesses( ctx context.Context, conn pg.Querier, scope Scoper, organizationID gid.GID, - trustCenterAccessID gid.GID, - data []MergeTrustCenterDocumentAccessesData, + compliancePortalAccessID gid.GID, + data []MergeCompliancePortalDocumentAccessesData, ) error { q := ` WITH data AS ( @@ -859,9 +859,9 @@ WHEN NOT MATCHED ` args := pgx.StrictNamedArgs{ - "trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, + "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType, "tenant_id": scope.GetTenantID(), - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "organization_id": organizationID, "now": time.Now(), "data": data, @@ -874,14 +874,14 @@ WHEN NOT MATCHED return nil } -func (tcdas TrustCenterDocumentAccesses) BulkInsertDocumentAccesses( +func (tcdas CompliancePortalDocumentAccesses) BulkInsertDocumentAccesses( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, organizationID gid.GID, documentIDs []gid.GID, - status TrustCenterDocumentAccessStatus, + status CompliancePortalDocumentAccessStatus, createdAt time.Time, ) error { if len(documentIDs) == 0 { @@ -921,28 +921,28 @@ ON CONFLICT DO NOTHING args := pgx.StrictNamedArgs{ "tenant_id": scope.GetTenantID(), "organization_id": organizationID, - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "document_ids": documentIDs, - "trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, + "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType, "status": status, "created_at": createdAt, "updated_at": createdAt, } if _, err := conn.Exec(ctx, q, args); err != nil { - return fmt.Errorf("cannot bulk insert trust center document accesses: %w", err) + return fmt.Errorf("cannot bulk insert compliance portal document accesses: %w", err) } return nil } -func (tcdas TrustCenterDocumentAccesses) MergeReportFileAccesses( +func (tcdas CompliancePortalDocumentAccesses) MergeReportFileAccesses( ctx context.Context, conn pg.Querier, scope Scoper, organizationID gid.GID, - trustCenterAccessID gid.GID, - data []MergeTrustCenterDocumentAccessesData, + compliancePortalAccessID gid.GID, + data []MergeCompliancePortalDocumentAccessesData, ) error { q := ` WITH data AS ( @@ -994,9 +994,9 @@ WHEN NOT MATCHED ` args := pgx.StrictNamedArgs{ - "trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, + "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType, "tenant_id": scope.GetTenantID(), - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "organization_id": organizationID, "now": time.Now(), "data": data, @@ -1009,14 +1009,14 @@ WHEN NOT MATCHED return nil } -func (tcdas TrustCenterDocumentAccesses) BulkInsertReportFileAccesses( +func (tcdas CompliancePortalDocumentAccesses) BulkInsertReportFileAccesses( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, organizationID gid.GID, reportFileIDs []gid.GID, - status TrustCenterDocumentAccessStatus, + status CompliancePortalDocumentAccessStatus, createdAt time.Time, ) error { if len(reportFileIDs) == 0 { @@ -1056,8 +1056,8 @@ ON CONFLICT DO NOTHING args := pgx.StrictNamedArgs{ "tenant_id": scope.GetTenantID(), "organization_id": organizationID, - "trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, - "trust_center_access_id": trustCenterAccessID, + "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType, + "trust_center_access_id": compliancePortalAccessID, "report_file_ids": reportFileIDs, "status": status, "created_at": createdAt, @@ -1065,18 +1065,18 @@ ON CONFLICT DO NOTHING } if _, err := conn.Exec(ctx, q, args); err != nil { - return fmt.Errorf("cannot bulk insert trust center report file accesses: %w", err) + return fmt.Errorf("cannot bulk insert compliance portal report file accesses: %w", err) } return nil } -func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndTrustCenterFileID( +func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndCompliancePortalFileID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, - trustCenterFileID gid.GID, + compliancePortalAccessID gid.GID, + compliancePortalFileID gid.GID, ) error { q := ` SELECT @@ -1101,23 +1101,23 @@ LIMIT 1; q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, - "trust_center_file_id": trustCenterFileID, + "trust_center_access_id": compliancePortalAccessID, + "trust_center_file_id": compliancePortalFileID, } maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot query trust center document access: %w", err) + return fmt.Errorf("cannot query compliance portal document access: %w", err) } - access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterDocumentAccess]) + access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalDocumentAccess]) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return ErrResourceNotFound } - return fmt.Errorf("cannot collect trust center document access: %w", err) + return fmt.Errorf("cannot collect compliance portal document access: %w", err) } *tcda = access @@ -1125,12 +1125,12 @@ LIMIT 1; return nil } -func GrantByTrustCenterFileIDs( +func GrantByCompliancePortalFileIDs( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, - trustCenterFileIDs []gid.GID, + compliancePortalAccessID gid.GID, + compliancePortalFileIDs []gid.GID, updatedAt time.Time, ) error { q := ` @@ -1145,26 +1145,26 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, - "trust_center_file_ids": trustCenterFileIDs, + "trust_center_access_id": compliancePortalAccessID, + "trust_center_file_ids": compliancePortalFileIDs, "updated_at": updatedAt, } maps.Copy(args, scope.SQLArguments()) _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot grant trust center document accesses by trust center file IDs: %w", err) + return fmt.Errorf("cannot grant compliance portal document accesses by compliance portal file IDs: %w", err) } return nil } -func RejectOrRevokeByTrustCenterFileIDs( +func RejectOrRevokeByCompliancePortalFileIDs( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, - trustCenterFileIDs []gid.GID, + compliancePortalAccessID gid.GID, + compliancePortalFileIDs []gid.GID, updatedAt time.Time, ) error { q := ` @@ -1184,27 +1184,27 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "trust_center_access_id": trustCenterAccessID, - "trust_center_file_ids": trustCenterFileIDs, + "trust_center_access_id": compliancePortalAccessID, + "trust_center_file_ids": compliancePortalFileIDs, "updated_at": updatedAt, } maps.Copy(args, scope.SQLArguments()) _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot reject trust center document accesses by trust center file IDs: %w", err) + return fmt.Errorf("cannot reject compliance portal document accesses by compliance portal file IDs: %w", err) } return nil } -func (tcdas TrustCenterDocumentAccesses) MergeTrustCenterFileAccesses( +func (tcdas CompliancePortalDocumentAccesses) MergeCompliancePortalFileAccesses( ctx context.Context, conn pg.Querier, scope Scoper, organizationID gid.GID, - trustCenterAccessID gid.GID, - data []MergeTrustCenterDocumentAccessesData, + compliancePortalAccessID gid.GID, + data []MergeCompliancePortalDocumentAccessesData, ) error { q := ` WITH data AS ( @@ -1256,9 +1256,9 @@ WHEN NOT MATCHED ` args := pgx.StrictNamedArgs{ - "trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, + "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType, "tenant_id": scope.GetTenantID(), - "trust_center_access_id": trustCenterAccessID, + "trust_center_access_id": compliancePortalAccessID, "organization_id": organizationID, "now": time.Now(), "data": data, @@ -1271,14 +1271,14 @@ WHEN NOT MATCHED return nil } -func (tcdas TrustCenterDocumentAccesses) BulkInsertTrustCenterFileAccesses( +func (tcdas CompliancePortalDocumentAccesses) BulkInsertCompliancePortalFileAccesses( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterAccessID gid.GID, + compliancePortalAccessID gid.GID, organizationID gid.GID, - trustCenterFileIDs []gid.GID, - status TrustCenterDocumentAccessStatus, + compliancePortalFileIDs []gid.GID, + status CompliancePortalDocumentAccessStatus, createdAt time.Time, ) error { q := ` @@ -1314,16 +1314,16 @@ ON CONFLICT DO NOTHING args := pgx.StrictNamedArgs{ "tenant_id": scope.GetTenantID(), "organization_id": organizationID, - "trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, - "trust_center_access_id": trustCenterAccessID, - "trust_center_file_ids": trustCenterFileIDs, + "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType, + "trust_center_access_id": compliancePortalAccessID, + "trust_center_file_ids": compliancePortalFileIDs, "status": status, "created_at": createdAt, "updated_at": createdAt, } if _, err := conn.Exec(ctx, q, args); err != nil { - return fmt.Errorf("cannot bulk insert trust center file accesses: %w", err) + return fmt.Errorf("cannot bulk insert compliance portal file accesses: %w", err) } return nil diff --git a/pkg/coredata/trust_center_document_access_order_field.go b/pkg/coredata/compliance_portal_document_access_order_field.go similarity index 53% rename from pkg/coredata/trust_center_document_access_order_field.go rename to pkg/coredata/compliance_portal_document_access_order_field.go index 54d39cdd8..7847a516a 100644 --- a/pkg/coredata/trust_center_document_access_order_field.go +++ b/pkg/coredata/compliance_portal_document_access_order_field.go @@ -27,47 +27,47 @@ import ( "go.probo.inc/probo/pkg/page" ) -type TrustCenterDocumentAccessOrderField string +type CompliancePortalDocumentAccessOrderField string const ( - TrustCenterDocumentAccessOrderFieldCreatedAt TrustCenterDocumentAccessOrderField = "CREATED_AT" + CompliancePortalDocumentAccessOrderFieldCreatedAt CompliancePortalDocumentAccessOrderField = "CREATED_AT" ) var ( - _ page.OrderField = TrustCenterDocumentAccessOrderField("") - _ fmt.Stringer = TrustCenterDocumentAccessOrderField("") - _ encoding.TextMarshaler = TrustCenterDocumentAccessOrderField("") - _ encoding.TextUnmarshaler = (*TrustCenterDocumentAccessOrderField)(nil) + _ page.OrderField = CompliancePortalDocumentAccessOrderField("") + _ fmt.Stringer = CompliancePortalDocumentAccessOrderField("") + _ encoding.TextMarshaler = CompliancePortalDocumentAccessOrderField("") + _ encoding.TextUnmarshaler = (*CompliancePortalDocumentAccessOrderField)(nil) ) -func TrustCenterDocumentAccessOrderFields() []TrustCenterDocumentAccessOrderField { - return []TrustCenterDocumentAccessOrderField{ - TrustCenterDocumentAccessOrderFieldCreatedAt, +func CompliancePortalDocumentAccessOrderFields() []CompliancePortalDocumentAccessOrderField { + return []CompliancePortalDocumentAccessOrderField{ + CompliancePortalDocumentAccessOrderFieldCreatedAt, } } -func (v TrustCenterDocumentAccessOrderField) IsValid() bool { +func (v CompliancePortalDocumentAccessOrderField) IsValid() bool { switch v { case - TrustCenterDocumentAccessOrderFieldCreatedAt: + CompliancePortalDocumentAccessOrderFieldCreatedAt: return true } return false } -func (v TrustCenterDocumentAccessOrderField) String() string { +func (v CompliancePortalDocumentAccessOrderField) String() string { return string(v) } -func (v TrustCenterDocumentAccessOrderField) MarshalText() ([]byte, error) { +func (v CompliancePortalDocumentAccessOrderField) MarshalText() ([]byte, error) { return []byte(v.String()), nil } -func (v *TrustCenterDocumentAccessOrderField) UnmarshalText(text []byte) error { - val := TrustCenterDocumentAccessOrderField(text) +func (v *CompliancePortalDocumentAccessOrderField) UnmarshalText(text []byte) error { + val := CompliancePortalDocumentAccessOrderField(text) if !val.IsValid() { - return fmt.Errorf("invalid TrustCenterDocumentAccessOrderField value: %q", string(text)) + return fmt.Errorf("invalid CompliancePortalDocumentAccessOrderField value: %q", string(text)) } *v = val @@ -75,6 +75,6 @@ func (v *TrustCenterDocumentAccessOrderField) UnmarshalText(text []byte) error { return nil } -func (tcdaof TrustCenterDocumentAccessOrderField) Column() string { +func (tcdaof CompliancePortalDocumentAccessOrderField) Column() string { return string(tcdaof) } diff --git a/pkg/coredata/compliance_portal_document_access_status.go b/pkg/coredata/compliance_portal_document_access_status.go new file mode 100644 index 000000000..ec5399201 --- /dev/null +++ b/pkg/coredata/compliance_portal_document_access_status.go @@ -0,0 +1,82 @@ +// Copyright (c) 2025-2026 Probo Inc . +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package coredata + +import ( + "encoding" + "fmt" +) + +type CompliancePortalDocumentAccessStatus string + +const ( + CompliancePortalDocumentAccessStatusRequested CompliancePortalDocumentAccessStatus = "REQUESTED" + CompliancePortalDocumentAccessStatusGranted CompliancePortalDocumentAccessStatus = "GRANTED" + CompliancePortalDocumentAccessStatusRejected CompliancePortalDocumentAccessStatus = "REJECTED" + CompliancePortalDocumentAccessStatusRevoked CompliancePortalDocumentAccessStatus = "REVOKED" +) + +var ( + _ fmt.Stringer = CompliancePortalDocumentAccessStatus("") + _ encoding.TextMarshaler = CompliancePortalDocumentAccessStatus("") + _ encoding.TextUnmarshaler = (*CompliancePortalDocumentAccessStatus)(nil) +) + +func CompliancePortalDocumentAccessStatuses() []CompliancePortalDocumentAccessStatus { + return []CompliancePortalDocumentAccessStatus{ + CompliancePortalDocumentAccessStatusRequested, + CompliancePortalDocumentAccessStatusGranted, + CompliancePortalDocumentAccessStatusRejected, + CompliancePortalDocumentAccessStatusRevoked, + } +} + +func (v CompliancePortalDocumentAccessStatus) IsValid() bool { + switch v { + case + CompliancePortalDocumentAccessStatusRequested, + CompliancePortalDocumentAccessStatusGranted, + CompliancePortalDocumentAccessStatusRejected, + CompliancePortalDocumentAccessStatusRevoked: + return true + } + + return false +} + +func (v CompliancePortalDocumentAccessStatus) String() string { + return string(v) +} + +func (v CompliancePortalDocumentAccessStatus) MarshalText() ([]byte, error) { + return []byte(v.String()), nil +} + +func (v *CompliancePortalDocumentAccessStatus) UnmarshalText(text []byte) error { + val := CompliancePortalDocumentAccessStatus(text) + if !val.IsValid() { + return fmt.Errorf("invalid CompliancePortalDocumentAccessStatus value: %q", string(text)) + } + + *v = val + + return nil +} diff --git a/pkg/coredata/trust_center_file.go b/pkg/coredata/compliance_portal_file.go similarity index 75% rename from pkg/coredata/trust_center_file.go rename to pkg/coredata/compliance_portal_file.go index 83219c803..713d37d99 100644 --- a/pkg/coredata/trust_center_file.go +++ b/pkg/coredata/compliance_portal_file.go @@ -34,34 +34,34 @@ import ( ) type ( - TrustCenterFile struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - Name string `db:"name"` - Category string `db:"category"` - FileID gid.GID `db:"file_id"` - TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + CompliancePortalFile struct { + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + Name string `db:"name"` + Category string `db:"category"` + FileID gid.GID `db:"file_id"` + CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } - TrustCenterFiles []*TrustCenterFile + CompliancePortalFiles []*CompliancePortalFile ) -func (t TrustCenterFile) CursorKey(orderBy TrustCenterFileOrderField) page.CursorKey { +func (t CompliancePortalFile) CursorKey(orderBy CompliancePortalFileOrderField) page.CursorKey { switch orderBy { - case TrustCenterFileOrderFieldName: + case CompliancePortalFileOrderFieldName: return page.NewCursorKey(t.ID, t.Name) - case TrustCenterFileOrderFieldCreatedAt: + case CompliancePortalFileOrderFieldCreatedAt: return page.NewCursorKey(t.ID, t.CreatedAt) - case TrustCenterFileOrderFieldUpdatedAt: + case CompliancePortalFileOrderFieldUpdatedAt: return page.NewCursorKey(t.ID, t.UpdatedAt) } panic(fmt.Sprintf("unsupported order by: %s", orderBy)) } -func (t *TrustCenterFile) AuthorizationAttributes( +func (t *CompliancePortalFile) AuthorizationAttributes( ctx context.Context, conn pg.Querier, resourceIDs []gid.GID, @@ -100,11 +100,11 @@ func (t *TrustCenterFile) AuthorizationAttributes( return attrsByID, nil } -func (t *TrustCenterFile) LoadByID( +func (t *CompliancePortalFile) LoadByID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterFileID gid.GID, + compliancePortalFileID gid.GID, ) error { q := ` SELECT @@ -125,7 +125,7 @@ LIMIT 1; ` q = fmt.Sprintf(q, scope.SQLFragment()) - args := pgx.StrictNamedArgs{"trust_center_file_id": trustCenterFileID} + args := pgx.StrictNamedArgs{"trust_center_file_id": compliancePortalFileID} maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) @@ -133,9 +133,9 @@ LIMIT 1; return fmt.Errorf("cannot query trust_center_files: %w", err) } - file, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterFile]) + file, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalFile]) if err != nil { - return fmt.Errorf("cannot collect trust center file: %w", err) + return fmt.Errorf("cannot collect compliance portal file: %w", err) } *t = file @@ -143,11 +143,11 @@ LIMIT 1; return nil } -func (f *TrustCenterFiles) LoadByIDs( +func (f *CompliancePortalFiles) LoadByIDs( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterFileIDs []gid.GID, + compliancePortalFileIDs []gid.GID, ) error { q := ` SELECT @@ -168,7 +168,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) - args := pgx.StrictNamedArgs{"ids": trustCenterFileIDs} + args := pgx.StrictNamedArgs{"ids": compliancePortalFileIDs} maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) @@ -177,21 +177,21 @@ WHERE } defer rows.Close() - files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterFile]) + files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalFile]) if err != nil { return fmt.Errorf("cannot collect file: %w", err) } *f = files - if len(files) != len(gid.NewSet(trustCenterFileIDs...)) { + if len(files) != len(gid.NewSet(compliancePortalFileIDs...)) { return ErrResourceNotFound } return nil } -func (t TrustCenterFile) Insert( +func (t CompliancePortalFile) Insert( ctx context.Context, conn pg.Tx, scope Scoper, @@ -229,20 +229,20 @@ VALUES ( "name": t.Name, "category": t.Category, "file_id": t.FileID, - "trust_center_visibility": t.TrustCenterVisibility, + "trust_center_visibility": t.CompliancePortalVisibility, "created_at": t.CreatedAt, "updated_at": t.UpdatedAt, } _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot insert trust center file: %w", err) + return fmt.Errorf("cannot insert compliance portal file: %w", err) } return nil } -func (t *TrustCenterFile) Update( +func (t *CompliancePortalFile) Update( ctx context.Context, conn pg.Tx, scope Scoper, @@ -274,19 +274,19 @@ RETURNING "id": t.ID, "name": t.Name, "category": t.Category, - "trust_center_visibility": t.TrustCenterVisibility, + "trust_center_visibility": t.CompliancePortalVisibility, "updated_at": t.UpdatedAt, } maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) if err != nil { - return fmt.Errorf("cannot update trust center file: %w", err) + return fmt.Errorf("cannot update compliance portal file: %w", err) } - file, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterFile]) + file, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalFile]) if err != nil { - return fmt.Errorf("cannot collect updated trust center file: %w", err) + return fmt.Errorf("cannot collect updated compliance portal file: %w", err) } *t = file @@ -294,7 +294,7 @@ RETURNING return nil } -func (t *TrustCenterFile) Delete( +func (t *CompliancePortalFile) Delete( ctx context.Context, conn pg.Tx, scope Scoper, @@ -314,19 +314,19 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot delete trust center file: %w", err) + return fmt.Errorf("cannot delete compliance portal file: %w", err) } return nil } -func (t *TrustCenterFiles) LoadByOrganizationID( +func (t *CompliancePortalFiles) LoadByOrganizationID( ctx context.Context, conn pg.Querier, scope Scoper, organizationID gid.GID, - cursor *page.Cursor[TrustCenterFileOrderField], - filter *TrustCenterFileFilter, + cursor *page.Cursor[CompliancePortalFileOrderField], + filter *CompliancePortalFileFilter, ) error { q := ` SELECT @@ -359,9 +359,9 @@ WHERE return fmt.Errorf("cannot query trust_center_files: %w", err) } - files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterFile]) + files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalFile]) if err != nil { - return fmt.Errorf("cannot collect trust center files: %w", err) + return fmt.Errorf("cannot collect compliance portal files: %w", err) } *t = files @@ -369,7 +369,7 @@ WHERE return nil } -func (t *TrustCenterFiles) CountByOrganizationID( +func (t *CompliancePortalFiles) CountByOrganizationID( ctx context.Context, conn pg.Querier, scope Scoper, @@ -394,7 +394,7 @@ WHERE err := conn.QueryRow(ctx, q, args).Scan(&count) if err != nil { - return 0, fmt.Errorf("cannot count trust center files: %w", err) + return 0, fmt.Errorf("cannot count compliance portal files: %w", err) } return count, nil diff --git a/pkg/coredata/trust_center_file_filter.go b/pkg/coredata/compliance_portal_file_filter.go similarity index 66% rename from pkg/coredata/trust_center_file_filter.go rename to pkg/coredata/compliance_portal_file_filter.go index 4e259ccb8..9012a4aca 100644 --- a/pkg/coredata/trust_center_file_filter.go +++ b/pkg/coredata/compliance_portal_file_filter.go @@ -25,15 +25,15 @@ import ( ) type ( - TrustCenterFileFilter struct { - trustCenterVisibilities []TrustCenterVisibility + CompliancePortalFileFilter struct { + compliancePortalVisibilities []CompliancePortalVisibility } ) -type TrustCenterFileFilterOption func(f *TrustCenterFileFilter) +type CompliancePortalFileFilterOption func(f *CompliancePortalFileFilter) -func NewTrustCenterFileFilter(opts ...TrustCenterFileFilterOption) *TrustCenterFileFilter { - f := &TrustCenterFileFilter{} +func NewCompliancePortalFileFilter(opts ...CompliancePortalFileFilterOption) *CompliancePortalFileFilter { + f := &CompliancePortalFileFilter{} for _, opt := range opts { opt(f) @@ -42,17 +42,17 @@ func NewTrustCenterFileFilter(opts ...TrustCenterFileFilterOption) *TrustCenterF return f } -func WithTrustCenterFileVisibilities(visibilities ...TrustCenterVisibility) TrustCenterFileFilterOption { - return func(f *TrustCenterFileFilter) { - f.trustCenterVisibilities = visibilities +func WithCompliancePortalFileVisibilities(visibilities ...CompliancePortalVisibility) CompliancePortalFileFilterOption { + return func(f *CompliancePortalFileFilter) { + f.compliancePortalVisibilities = visibilities } } -func (f *TrustCenterFileFilter) SQLArguments() pgx.NamedArgs { +func (f *CompliancePortalFileFilter) SQLArguments() pgx.NamedArgs { var visibilities []string - if f.trustCenterVisibilities != nil { - visibilities = make([]string, len(f.trustCenterVisibilities)) - for i, v := range f.trustCenterVisibilities { + if f.compliancePortalVisibilities != nil { + visibilities = make([]string, len(f.compliancePortalVisibilities)) + for i, v := range f.compliancePortalVisibilities { visibilities[i] = v.String() } } @@ -62,7 +62,7 @@ func (f *TrustCenterFileFilter) SQLArguments() pgx.NamedArgs { } } -func (f *TrustCenterFileFilter) SQLFragment() string { +func (f *CompliancePortalFileFilter) SQLFragment() string { return `CASE WHEN @trust_center_visibilities::trust_center_visibility[] IS NOT NULL THEN trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[]) diff --git a/pkg/coredata/trust_center_reference_order_field.go b/pkg/coredata/compliance_portal_file_order_field.go similarity index 50% rename from pkg/coredata/trust_center_reference_order_field.go rename to pkg/coredata/compliance_portal_file_order_field.go index 1109a6136..ebc82924f 100644 --- a/pkg/coredata/trust_center_reference_order_field.go +++ b/pkg/coredata/compliance_portal_file_order_field.go @@ -28,57 +28,54 @@ import ( ) type ( - TrustCenterReferenceOrderField string + CompliancePortalFileOrderField string ) const ( - TrustCenterReferenceOrderFieldRank TrustCenterReferenceOrderField = "RANK" - TrustCenterReferenceOrderFieldName TrustCenterReferenceOrderField = "NAME" - TrustCenterReferenceOrderFieldCreatedAt TrustCenterReferenceOrderField = "CREATED_AT" - TrustCenterReferenceOrderFieldUpdatedAt TrustCenterReferenceOrderField = "UPDATED_AT" + CompliancePortalFileOrderFieldName CompliancePortalFileOrderField = "NAME" + CompliancePortalFileOrderFieldCreatedAt CompliancePortalFileOrderField = "CREATED_AT" + CompliancePortalFileOrderFieldUpdatedAt CompliancePortalFileOrderField = "UPDATED_AT" ) var ( - _ page.OrderField = TrustCenterReferenceOrderField("") - _ fmt.Stringer = TrustCenterReferenceOrderField("") - _ encoding.TextMarshaler = TrustCenterReferenceOrderField("") - _ encoding.TextUnmarshaler = (*TrustCenterReferenceOrderField)(nil) + _ page.OrderField = CompliancePortalFileOrderField("") + _ fmt.Stringer = CompliancePortalFileOrderField("") + _ encoding.TextMarshaler = CompliancePortalFileOrderField("") + _ encoding.TextUnmarshaler = (*CompliancePortalFileOrderField)(nil) ) -func TrustCenterReferenceOrderFields() []TrustCenterReferenceOrderField { - return []TrustCenterReferenceOrderField{ - TrustCenterReferenceOrderFieldRank, - TrustCenterReferenceOrderFieldName, - TrustCenterReferenceOrderFieldCreatedAt, - TrustCenterReferenceOrderFieldUpdatedAt, +func CompliancePortalFileOrderFields() []CompliancePortalFileOrderField { + return []CompliancePortalFileOrderField{ + CompliancePortalFileOrderFieldName, + CompliancePortalFileOrderFieldCreatedAt, + CompliancePortalFileOrderFieldUpdatedAt, } } -func (v TrustCenterReferenceOrderField) IsValid() bool { +func (v CompliancePortalFileOrderField) IsValid() bool { switch v { case - TrustCenterReferenceOrderFieldRank, - TrustCenterReferenceOrderFieldName, - TrustCenterReferenceOrderFieldCreatedAt, - TrustCenterReferenceOrderFieldUpdatedAt: + CompliancePortalFileOrderFieldName, + CompliancePortalFileOrderFieldCreatedAt, + CompliancePortalFileOrderFieldUpdatedAt: return true } return false } -func (v TrustCenterReferenceOrderField) String() string { +func (v CompliancePortalFileOrderField) String() string { return string(v) } -func (v TrustCenterReferenceOrderField) MarshalText() ([]byte, error) { +func (v CompliancePortalFileOrderField) MarshalText() ([]byte, error) { return []byte(v.String()), nil } -func (v *TrustCenterReferenceOrderField) UnmarshalText(text []byte) error { - val := TrustCenterReferenceOrderField(text) +func (v *CompliancePortalFileOrderField) UnmarshalText(text []byte) error { + val := CompliancePortalFileOrderField(text) if !val.IsValid() { - return fmt.Errorf("invalid TrustCenterReferenceOrderField value: %q", string(text)) + return fmt.Errorf("invalid CompliancePortalFileOrderField value: %q", string(text)) } *v = val @@ -86,15 +83,13 @@ func (v *TrustCenterReferenceOrderField) UnmarshalText(text []byte) error { return nil } -func (p TrustCenterReferenceOrderField) Column() string { +func (p CompliancePortalFileOrderField) Column() string { switch p { - case TrustCenterReferenceOrderFieldRank: - return "rank" - case TrustCenterReferenceOrderFieldName: + case CompliancePortalFileOrderFieldName: return "name" - case TrustCenterReferenceOrderFieldCreatedAt: + case CompliancePortalFileOrderFieldCreatedAt: return "created_at" - case TrustCenterReferenceOrderFieldUpdatedAt: + case CompliancePortalFileOrderFieldUpdatedAt: return "updated_at" default: return string(p) diff --git a/pkg/coredata/trust_center_order_field.go b/pkg/coredata/compliance_portal_order_field.go similarity index 59% rename from pkg/coredata/trust_center_order_field.go rename to pkg/coredata/compliance_portal_order_field.go index c27171ebe..af83681b0 100644 --- a/pkg/coredata/trust_center_order_field.go +++ b/pkg/coredata/compliance_portal_order_field.go @@ -27,47 +27,47 @@ import ( "go.probo.inc/probo/pkg/page" ) -type TrustCenterOrderField string +type CompliancePortalOrderField string const ( - TrustCenterOrderFieldCreatedAt TrustCenterOrderField = "CREATED_AT" + CompliancePortalOrderFieldCreatedAt CompliancePortalOrderField = "CREATED_AT" ) var ( - _ page.OrderField = TrustCenterOrderField("") - _ fmt.Stringer = TrustCenterOrderField("") - _ encoding.TextMarshaler = TrustCenterOrderField("") - _ encoding.TextUnmarshaler = (*TrustCenterOrderField)(nil) + _ page.OrderField = CompliancePortalOrderField("") + _ fmt.Stringer = CompliancePortalOrderField("") + _ encoding.TextMarshaler = CompliancePortalOrderField("") + _ encoding.TextUnmarshaler = (*CompliancePortalOrderField)(nil) ) -func TrustCenterOrderFields() []TrustCenterOrderField { - return []TrustCenterOrderField{ - TrustCenterOrderFieldCreatedAt, +func CompliancePortalOrderFields() []CompliancePortalOrderField { + return []CompliancePortalOrderField{ + CompliancePortalOrderFieldCreatedAt, } } -func (v TrustCenterOrderField) IsValid() bool { +func (v CompliancePortalOrderField) IsValid() bool { switch v { case - TrustCenterOrderFieldCreatedAt: + CompliancePortalOrderFieldCreatedAt: return true } return false } -func (v TrustCenterOrderField) String() string { +func (v CompliancePortalOrderField) String() string { return string(v) } -func (v TrustCenterOrderField) MarshalText() ([]byte, error) { +func (v CompliancePortalOrderField) MarshalText() ([]byte, error) { return []byte(v.String()), nil } -func (v *TrustCenterOrderField) UnmarshalText(text []byte) error { - val := TrustCenterOrderField(text) +func (v *CompliancePortalOrderField) UnmarshalText(text []byte) error { + val := CompliancePortalOrderField(text) if !val.IsValid() { - return fmt.Errorf("invalid TrustCenterOrderField value: %q", string(text)) + return fmt.Errorf("invalid CompliancePortalOrderField value: %q", string(text)) } *v = val @@ -75,6 +75,6 @@ func (v *TrustCenterOrderField) UnmarshalText(text []byte) error { return nil } -func (p TrustCenterOrderField) Column() string { +func (p CompliancePortalOrderField) Column() string { return string(p) } diff --git a/pkg/coredata/trust_center_reference.go b/pkg/coredata/compliance_portal_reference.go similarity index 76% rename from pkg/coredata/trust_center_reference.go rename to pkg/coredata/compliance_portal_reference.go index cde2d0b7a..42831f0ed 100644 --- a/pkg/coredata/trust_center_reference.go +++ b/pkg/coredata/compliance_portal_reference.go @@ -36,38 +36,38 @@ import ( ) type ( - TrustCenterReference struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - TrustCenterID gid.GID `db:"trust_center_id"` - Name string `db:"name"` - Description *string `db:"description"` - WebsiteURL string `db:"website_url"` - LogoFileID gid.GID `db:"logo_file_id"` - Rank int `db:"rank"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + CompliancePortalReference struct { + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CompliancePortalID gid.GID `db:"trust_center_id"` + Name string `db:"name"` + Description *string `db:"description"` + WebsiteURL string `db:"website_url"` + LogoFileID gid.GID `db:"logo_file_id"` + Rank int `db:"rank"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } - TrustCenterReferences []*TrustCenterReference + CompliancePortalReferences []*CompliancePortalReference ) -func (t TrustCenterReference) CursorKey(orderBy TrustCenterReferenceOrderField) page.CursorKey { +func (t CompliancePortalReference) CursorKey(orderBy CompliancePortalReferenceOrderField) page.CursorKey { switch orderBy { - case TrustCenterReferenceOrderFieldRank: + case CompliancePortalReferenceOrderFieldRank: return page.NewCursorKey(t.ID, t.Rank) - case TrustCenterReferenceOrderFieldName: + case CompliancePortalReferenceOrderFieldName: return page.NewCursorKey(t.ID, t.Name) - case TrustCenterReferenceOrderFieldCreatedAt: + case CompliancePortalReferenceOrderFieldCreatedAt: return page.NewCursorKey(t.ID, t.CreatedAt) - case TrustCenterReferenceOrderFieldUpdatedAt: + case CompliancePortalReferenceOrderFieldUpdatedAt: return page.NewCursorKey(t.ID, t.UpdatedAt) } panic(fmt.Sprintf("unsupported order by: %s", orderBy)) } -func (t *TrustCenterReference) AuthorizationAttributes( +func (t *CompliancePortalReference) AuthorizationAttributes( ctx context.Context, conn pg.Querier, resourceIDs []gid.GID, @@ -106,11 +106,11 @@ func (t *TrustCenterReference) AuthorizationAttributes( return attrsByID, nil } -func (t *TrustCenterReference) LoadByID( +func (t *CompliancePortalReference) LoadByID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterReferenceID gid.GID, + compliancePortalReferenceID gid.GID, ) error { q := ` SELECT @@ -133,7 +133,7 @@ LIMIT 1; ` q = fmt.Sprintf(q, scope.SQLFragment()) - args := pgx.StrictNamedArgs{"trust_center_reference_id": trustCenterReferenceID} + args := pgx.StrictNamedArgs{"trust_center_reference_id": compliancePortalReferenceID} maps.Copy(args, scope.SQLArguments()) rows, err := conn.Query(ctx, q, args) @@ -141,9 +141,9 @@ LIMIT 1; return fmt.Errorf("cannot query trust_center_references: %w", err) } - reference, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterReference]) + reference, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalReference]) if err != nil { - return fmt.Errorf("cannot collect trust center reference: %w", err) + return fmt.Errorf("cannot collect compliance portal reference: %w", err) } *t = reference @@ -151,7 +151,7 @@ LIMIT 1; return nil } -func (t *TrustCenterReference) Insert( +func (t *CompliancePortalReference) Insert( ctx context.Context, conn pg.Tx, scope Scoper, @@ -191,7 +191,7 @@ RETURNING rank; "tenant_id": scope.GetTenantID(), "id": t.ID, "organization_id": t.OrganizationID, - "trust_center_id": t.TrustCenterID, + "trust_center_id": t.CompliancePortalID, "name": t.Name, "description": t.Description, "website_url": t.WebsiteURL, @@ -208,13 +208,13 @@ RETURNING rank; } } - return fmt.Errorf("cannot insert trust center reference: %w", err) + return fmt.Errorf("cannot insert compliance portal reference: %w", err) } return nil } -func (t *TrustCenterReference) Update( +func (t *CompliancePortalReference) Update( ctx context.Context, conn pg.Tx, scope Scoper, @@ -246,7 +246,7 @@ WHERE result, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot update trust center reference: %w", err) + return fmt.Errorf("cannot update compliance portal reference: %w", err) } if result.RowsAffected() == 0 { @@ -256,7 +256,7 @@ WHERE return nil } -func (t *TrustCenterReference) UpdateRank( +func (t *CompliancePortalReference) UpdateRank( ctx context.Context, conn pg.Tx, scope Scoper, @@ -293,20 +293,20 @@ WHERE %s args := pgx.StrictNamedArgs{ "id": t.ID, "new_rank": t.Rank, - "trust_center_id": t.TrustCenterID, + "trust_center_id": t.CompliancePortalID, "updated_at": t.UpdatedAt, } maps.Copy(args, scope.SQLArguments()) _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot update trust center reference rank: %w", err) + return fmt.Errorf("cannot update compliance portal reference rank: %w", err) } return nil } -func (t *TrustCenterReference) Delete( +func (t *CompliancePortalReference) Delete( ctx context.Context, conn pg.Tx, scope Scoper, @@ -326,18 +326,18 @@ WHERE _, err := conn.Exec(ctx, q, args) if err != nil { - return fmt.Errorf("cannot delete trust center reference: %w", err) + return fmt.Errorf("cannot delete compliance portal reference: %w", err) } return nil } -func (t *TrustCenterReferences) LoadByTrustCenterID( +func (t *CompliancePortalReferences) LoadByCompliancePortalID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, - cursor *page.Cursor[TrustCenterReferenceOrderField], + compliancePortalID gid.GID, + cursor *page.Cursor[CompliancePortalReferenceOrderField], ) error { q := ` SELECT @@ -361,7 +361,7 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) - args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID} + args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID} maps.Copy(args, scope.SQLArguments()) maps.Copy(args, cursor.SQLArguments()) @@ -370,9 +370,9 @@ WHERE return fmt.Errorf("cannot query trust_center_references: %w", err) } - references, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterReference]) + references, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalReference]) if err != nil { - return fmt.Errorf("cannot collect trust center references: %w", err) + return fmt.Errorf("cannot collect compliance portal references: %w", err) } *t = references @@ -380,11 +380,11 @@ WHERE return nil } -func (t *TrustCenterReferences) CountByTrustCenterID( +func (t *CompliancePortalReferences) CountByCompliancePortalID( ctx context.Context, conn pg.Querier, scope Scoper, - trustCenterID gid.GID, + compliancePortalID gid.GID, ) (int, error) { q := ` SELECT @@ -398,14 +398,14 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) - args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID} + args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID} maps.Copy(args, scope.SQLArguments()) var count int err := conn.QueryRow(ctx, q, args).Scan(&count) if err != nil { - return 0, fmt.Errorf("cannot count trust center references: %w", err) + return 0, fmt.Errorf("cannot count compliance portal references: %w", err) } return count, nil diff --git a/pkg/coredata/compliance_portal_reference_order_field.go b/pkg/coredata/compliance_portal_reference_order_field.go new file mode 100644 index 000000000..4d4151eab --- /dev/null +++ b/pkg/coredata/compliance_portal_reference_order_field.go @@ -0,0 +1,102 @@ +// Copyright (c) 2025-2026 Probo Inc . +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package coredata + +import ( + "encoding" + "fmt" + + "go.probo.inc/probo/pkg/page" +) + +type ( + CompliancePortalReferenceOrderField string +) + +const ( + CompliancePortalReferenceOrderFieldRank CompliancePortalReferenceOrderField = "RANK" + CompliancePortalReferenceOrderFieldName CompliancePortalReferenceOrderField = "NAME" + CompliancePortalReferenceOrderFieldCreatedAt CompliancePortalReferenceOrderField = "CREATED_AT" + CompliancePortalReferenceOrderFieldUpdatedAt CompliancePortalReferenceOrderField = "UPDATED_AT" +) + +var ( + _ page.OrderField = CompliancePortalReferenceOrderField("") + _ fmt.Stringer = CompliancePortalReferenceOrderField("") + _ encoding.TextMarshaler = CompliancePortalReferenceOrderField("") + _ encoding.TextUnmarshaler = (*CompliancePortalReferenceOrderField)(nil) +) + +func CompliancePortalReferenceOrderFields() []CompliancePortalReferenceOrderField { + return []CompliancePortalReferenceOrderField{ + CompliancePortalReferenceOrderFieldRank, + CompliancePortalReferenceOrderFieldName, + CompliancePortalReferenceOrderFieldCreatedAt, + CompliancePortalReferenceOrderFieldUpdatedAt, + } +} + +func (v CompliancePortalReferenceOrderField) IsValid() bool { + switch v { + case + CompliancePortalReferenceOrderFieldRank, + CompliancePortalReferenceOrderFieldName, + CompliancePortalReferenceOrderFieldCreatedAt, + CompliancePortalReferenceOrderFieldUpdatedAt: + return true + } + + return false +} + +func (v CompliancePortalReferenceOrderField) String() string { + return string(v) +} + +func (v CompliancePortalReferenceOrderField) MarshalText() ([]byte, error) { + return []byte(v.String()), nil +} + +func (v *CompliancePortalReferenceOrderField) UnmarshalText(text []byte) error { + val := CompliancePortalReferenceOrderField(text) + if !val.IsValid() { + return fmt.Errorf("invalid CompliancePortalReferenceOrderField value: %q", string(text)) + } + + *v = val + + return nil +} + +func (p CompliancePortalReferenceOrderField) Column() string { + switch p { + case CompliancePortalReferenceOrderFieldRank: + return "rank" + case CompliancePortalReferenceOrderFieldName: + return "name" + case CompliancePortalReferenceOrderFieldCreatedAt: + return "created_at" + case CompliancePortalReferenceOrderFieldUpdatedAt: + return "updated_at" + default: + return string(p) + } +} diff --git a/pkg/coredata/trust_center_visibility.go b/pkg/coredata/compliance_portal_visibility.go similarity index 54% rename from pkg/coredata/trust_center_visibility.go rename to pkg/coredata/compliance_portal_visibility.go index 808b7bf4b..62b84f2e3 100644 --- a/pkg/coredata/trust_center_visibility.go +++ b/pkg/coredata/compliance_portal_visibility.go @@ -25,52 +25,52 @@ import ( "fmt" ) -type TrustCenterVisibility string +type CompliancePortalVisibility string const ( - TrustCenterVisibilityNone TrustCenterVisibility = "NONE" - TrustCenterVisibilityPrivate TrustCenterVisibility = "PRIVATE" - TrustCenterVisibilityPublic TrustCenterVisibility = "PUBLIC" + CompliancePortalVisibilityNone CompliancePortalVisibility = "NONE" + CompliancePortalVisibilityPrivate CompliancePortalVisibility = "PRIVATE" + CompliancePortalVisibilityPublic CompliancePortalVisibility = "PUBLIC" ) var ( - _ fmt.Stringer = TrustCenterVisibility("") - _ encoding.TextMarshaler = TrustCenterVisibility("") - _ encoding.TextUnmarshaler = (*TrustCenterVisibility)(nil) + _ fmt.Stringer = CompliancePortalVisibility("") + _ encoding.TextMarshaler = CompliancePortalVisibility("") + _ encoding.TextUnmarshaler = (*CompliancePortalVisibility)(nil) ) -func TrustCenterVisibilities() []TrustCenterVisibility { - return []TrustCenterVisibility{ - TrustCenterVisibilityNone, - TrustCenterVisibilityPrivate, - TrustCenterVisibilityPublic, +func CompliancePortalVisibilities() []CompliancePortalVisibility { + return []CompliancePortalVisibility{ + CompliancePortalVisibilityNone, + CompliancePortalVisibilityPrivate, + CompliancePortalVisibilityPublic, } } -func (v TrustCenterVisibility) IsValid() bool { +func (v CompliancePortalVisibility) IsValid() bool { switch v { case - TrustCenterVisibilityNone, - TrustCenterVisibilityPrivate, - TrustCenterVisibilityPublic: + CompliancePortalVisibilityNone, + CompliancePortalVisibilityPrivate, + CompliancePortalVisibilityPublic: return true } return false } -func (v TrustCenterVisibility) String() string { +func (v CompliancePortalVisibility) String() string { return string(v) } -func (v TrustCenterVisibility) MarshalText() ([]byte, error) { +func (v CompliancePortalVisibility) MarshalText() ([]byte, error) { return []byte(v.String()), nil } -func (v *TrustCenterVisibility) UnmarshalText(text []byte) error { - val := TrustCenterVisibility(text) +func (v *CompliancePortalVisibility) UnmarshalText(text []byte) error { + val := CompliancePortalVisibility(text) if !val.IsValid() { - return fmt.Errorf("invalid TrustCenterVisibility value: %q", string(text)) + return fmt.Errorf("invalid CompliancePortalVisibility value: %q", string(text)) } *v = val diff --git a/pkg/coredata/document.go b/pkg/coredata/document.go index 231a5e7d2..5e5bdcbd9 100644 --- a/pkg/coredata/document.go +++ b/pkg/coredata/document.go @@ -37,16 +37,16 @@ import ( type ( Document struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - CurrentPublishedMajor *int `db:"current_published_major"` - CurrentPublishedMinor *int `db:"current_published_minor"` - TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"` - WriteMode DocumentWriteMode `db:"write_mode"` - Status DocumentStatus `db:"status"` - ArchivedAt *time.Time `db:"archived_at"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CurrentPublishedMajor *int `db:"current_published_major"` + CurrentPublishedMinor *int `db:"current_published_minor"` + CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"` + WriteMode DocumentWriteMode `db:"write_mode"` + Status DocumentStatus `db:"status"` + ArchivedAt *time.Time `db:"archived_at"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` // ordering only Title string `db:"title"` @@ -505,7 +505,7 @@ VALUES ( "current_published_major": p.CurrentPublishedMajor, "current_published_minor": p.CurrentPublishedMinor, "write_mode": p.WriteMode, - "trust_center_visibility": p.TrustCenterVisibility, + "trust_center_visibility": p.CompliancePortalVisibility, "status": p.Status, "archived_at": p.ArchivedAt, "created_at": p.CreatedAt, @@ -582,7 +582,7 @@ WHERE "updated_at": time.Now(), "current_published_major": p.CurrentPublishedMajor, "current_published_minor": p.CurrentPublishedMinor, - "trust_center_visibility": p.TrustCenterVisibility, + "trust_center_visibility": p.CompliancePortalVisibility, "status": p.Status, "archived_at": p.ArchivedAt, } diff --git a/pkg/coredata/document_filter.go b/pkg/coredata/document_filter.go index a56f80dbd..99952d755 100644 --- a/pkg/coredata/document_filter.go +++ b/pkg/coredata/document_filter.go @@ -27,15 +27,15 @@ import ( type ( DocumentFilter struct { - query *string - trustCenterVisibilities []TrustCenterVisibility - published *bool - employeeIdentityID *gid.GID - employeeFilterModes []EmployeeFilterMode - documentTypes []DocumentType - classifications []DocumentClassification - writeModes []DocumentWriteMode - status []DocumentStatus + query *string + compliancePortalVisibilities []CompliancePortalVisibility + published *bool + employeeIdentityID *gid.GID + employeeFilterModes []EmployeeFilterMode + documentTypes []DocumentType + classifications []DocumentClassification + writeModes []DocumentWriteMode + status []DocumentStatus } ) @@ -45,13 +45,13 @@ func NewDocumentFilter(query *string) *DocumentFilter { } } -func NewDocumentTrustCenterFilter() *DocumentFilter { +func NewDocumentCompliancePortalFilter() *DocumentFilter { published := true return &DocumentFilter{ - trustCenterVisibilities: []TrustCenterVisibility{ - TrustCenterVisibilityPrivate, - TrustCenterVisibilityPublic, + compliancePortalVisibilities: []CompliancePortalVisibility{ + CompliancePortalVisibilityPrivate, + CompliancePortalVisibilityPublic, }, published: &published, status: []DocumentStatus{DocumentStatusActive}, @@ -63,8 +63,8 @@ func (f *DocumentFilter) WithPublished(published *bool) *DocumentFilter { return f } -func (f *DocumentFilter) WithTrustCenterVisibilities(visibilities ...TrustCenterVisibility) *DocumentFilter { - f.trustCenterVisibilities = visibilities +func (f *DocumentFilter) WithCompliancePortalVisibilities(visibilities ...CompliancePortalVisibility) *DocumentFilter { + f.compliancePortalVisibilities = visibilities return f } @@ -97,9 +97,9 @@ func (f *DocumentFilter) WithStatus(status []DocumentStatus) *DocumentFilter { func (f *DocumentFilter) SQLArguments() pgx.NamedArgs { var visibilities []string - if f.trustCenterVisibilities != nil { - visibilities = make([]string, len(f.trustCenterVisibilities)) - for i, v := range f.trustCenterVisibilities { + if f.compliancePortalVisibilities != nil { + visibilities = make([]string, len(f.compliancePortalVisibilities)) + for i, v := range f.compliancePortalVisibilities { visibilities[i] = v.String() } } diff --git a/pkg/coredata/entity_type_reg.go b/pkg/coredata/entity_type_reg.go index 257adada1..e4b01d482 100644 --- a/pkg/coredata/entity_type_reg.go +++ b/pkg/coredata/entity_type_reg.go @@ -51,8 +51,8 @@ const ( DatumEntityType uint16 = 19 AuditEntityType uint16 = 20 _ uint16 = 21 // ReportEntityType - removed - TrustCenterEntityType uint16 = 22 - TrustCenterAccessEntityType uint16 = 23 + CompliancePortalEntityType uint16 = 22 + CompliancePortalAccessEntityType uint16 = 23 ThirdPartyBusinessAssociateAgreementEntityType uint16 = 24 FileEntityType uint16 = 25 ThirdPartyContactEntityType uint16 = 26 @@ -64,13 +64,13 @@ const ( _ uint16 = 32 // ContinualImprovementEntityType - removed ProcessingActivityEntityType uint16 = 33 ExportJobEntityType uint16 = 34 - TrustCenterReferenceEntityType uint16 = 35 - TrustCenterDocumentAccessEntityType uint16 = 36 + CompliancePortalReferenceEntityType uint16 = 35 + CompliancePortalDocumentAccessEntityType uint16 = 36 CustomDomainEntityType uint16 = 37 InvitationEntityType uint16 = 38 MembershipEntityType uint16 = 39 SlackMessageEntityType uint16 = 40 - TrustCenterFileEntityType uint16 = 41 + CompliancePortalFileEntityType uint16 = 41 SAMLConfigurationEntityType uint16 = 42 PersonalAPIKeyEntityType uint16 = 43 _ uint16 = 44 // PersonalAPIKeyMembershipEntityType - removed @@ -180,10 +180,10 @@ func NewEntityFromID(id gid.GID) (any, bool) { return &Datum{ID: id}, true case AuditEntityType: return &Audit{ID: id}, true - case TrustCenterEntityType: - return &TrustCenter{ID: id}, true - case TrustCenterAccessEntityType: - return &TrustCenterAccess{ID: id}, true + case CompliancePortalEntityType: + return &CompliancePortal{ID: id}, true + case CompliancePortalAccessEntityType: + return &CompliancePortalAccess{ID: id}, true case ThirdPartyBusinessAssociateAgreementEntityType: return &ThirdPartyBusinessAssociateAgreement{ID: id}, true case FileEntityType: @@ -202,10 +202,10 @@ func NewEntityFromID(id gid.GID) (any, bool) { return &ProcessingActivity{ID: id}, true case ExportJobEntityType: return &ExportJob{ID: id}, true - case TrustCenterReferenceEntityType: - return &TrustCenterReference{ID: id}, true - case TrustCenterDocumentAccessEntityType: - return &TrustCenterDocumentAccess{ID: id}, true + case CompliancePortalReferenceEntityType: + return &CompliancePortalReference{ID: id}, true + case CompliancePortalDocumentAccessEntityType: + return &CompliancePortalDocumentAccess{ID: id}, true case CustomDomainEntityType: return &CustomDomain{ID: id}, true case InvitationEntityType: @@ -214,8 +214,8 @@ func NewEntityFromID(id gid.GID) (any, bool) { return &Membership{ID: id}, true case SlackMessageEntityType: return &SlackMessage{ID: id}, true - case TrustCenterFileEntityType: - return &TrustCenterFile{ID: id}, true + case CompliancePortalFileEntityType: + return &CompliancePortalFile{ID: id}, true case SAMLConfigurationEntityType: return &SAMLConfiguration{ID: id}, true case PersonalAPIKeyEntityType: diff --git a/pkg/coredata/membership_profile_filter.go b/pkg/coredata/membership_profile_filter.go index 795f9ad69..1de3f2763 100644 --- a/pkg/coredata/membership_profile_filter.go +++ b/pkg/coredata/membership_profile_filter.go @@ -29,15 +29,15 @@ import ( type ( MembershipProfileFilter struct { - withMembership *bool - withTrustCenterAccess *bool - contractEnded *bool - currentDate time.Time - email *mail.Addr - userName *string - externalID *string - state *ProfileState - source *ProfileSource + withMembership *bool + withCompliancePortalAccess *bool + contractEnded *bool + currentDate time.Time + email *mail.Addr + userName *string + externalID *string + state *ProfileState + source *ProfileSource } ) @@ -53,8 +53,8 @@ func (f *MembershipProfileFilter) WithMembership() *MembershipProfileFilter { return f } -func (f *MembershipProfileFilter) WithTrustCenterAccess() *MembershipProfileFilter { - f.withTrustCenterAccess = new(true) +func (f *MembershipProfileFilter) WithCompliancePortalAccess() *MembershipProfileFilter { + f.withCompliancePortalAccess = new(true) return f } @@ -101,7 +101,7 @@ func (f *MembershipProfileFilter) SQLArguments() pgx.StrictNamedArgs { "filter_user_name": f.userName, "filter_external_id": f.externalID, "with_membership": f.withMembership, - "with_trust_center_access": f.withTrustCenterAccess, + "with_trust_center_access": f.withCompliancePortalAccess, "contract_ended": f.contractEnded, "current_date": f.currentDate, "filter_state": f.state, diff --git a/pkg/coredata/slack_message_type.go b/pkg/coredata/slack_message_type.go index 9c3756ae9..f06c25c17 100644 --- a/pkg/coredata/slack_message_type.go +++ b/pkg/coredata/slack_message_type.go @@ -28,8 +28,8 @@ import ( type SlackMessageType string const ( - SlackMessageTypeTrustCenterAccessRequest SlackMessageType = "TRUST_CENTER_ACCESS_REQUEST" - SlackMessageTypeWelcome SlackMessageType = "WELCOME" + SlackMessageTypeCompliancePortalAccessRequest SlackMessageType = "TRUST_CENTER_ACCESS_REQUEST" + SlackMessageTypeWelcome SlackMessageType = "WELCOME" ) var ( @@ -40,7 +40,7 @@ var ( func SlackMessageTypes() []SlackMessageType { return []SlackMessageType{ - SlackMessageTypeTrustCenterAccessRequest, + SlackMessageTypeCompliancePortalAccessRequest, SlackMessageTypeWelcome, } } @@ -48,7 +48,7 @@ func SlackMessageTypes() []SlackMessageType { func (v SlackMessageType) IsValid() bool { switch v { case - SlackMessageTypeTrustCenterAccessRequest, + SlackMessageTypeCompliancePortalAccessRequest, SlackMessageTypeWelcome: return true } diff --git a/pkg/coredata/third_party.go b/pkg/coredata/third_party.go index c63bc1317..41cb143de 100644 --- a/pkg/coredata/third_party.go +++ b/pkg/coredata/third_party.go @@ -172,7 +172,7 @@ type ( TermsOfServiceURL *string `db:"terms_of_service_url"` SecurityPageURL *string `db:"security_page_url"` TrustPageURL *string `db:"trust_page_url"` - ShowOnTrustCenter bool `db:"show_on_trust_center"` + ShowOnCompliancePortal bool `db:"show_on_trust_center"` Level int `db:"level"` VettingStatus *ThirdPartyVettingStatus `db:"vetting_status"` VettingWebsiteURL *string `db:"vetting_website_url"` @@ -716,7 +716,7 @@ VALUES ( "terms_of_service_url": v.TermsOfServiceURL, "security_page_url": v.SecurityPageURL, "trust_page_url": v.TrustPageURL, - "show_on_trust_center": v.ShowOnTrustCenter, + "show_on_trust_center": v.ShowOnCompliancePortal, "level": v.Level, "vetting_status": v.VettingStatus, "vetting_website_url": v.VettingWebsiteURL, @@ -786,7 +786,7 @@ WHERE return count, nil } -func (v *ThirdParties) LoadDistinctTrustCenterCategoriesByOrganizationID( +func (v *ThirdParties) LoadDistinctCompliancePortalCategoriesByOrganizationID( ctx context.Context, conn pg.Querier, scope Scoper, @@ -822,7 +822,7 @@ ORDER BY return categories, nil } -func (v *ThirdParties) LoadDistinctTrustCenterCountriesByOrganizationID( +func (v *ThirdParties) LoadDistinctCompliancePortalCountriesByOrganizationID( ctx context.Context, conn pg.Querier, scope Scoper, @@ -996,7 +996,7 @@ WHERE %s "trust_page_url": v.TrustPageURL, "business_owner_profile_id": v.BusinessOwnerID, "security_owner_profile_id": v.SecurityOwnerID, - "show_on_trust_center": v.ShowOnTrustCenter, + "show_on_trust_center": v.ShowOnCompliancePortal, "level": v.Level, "vetting_status": v.VettingStatus, "vetting_website_url": v.VettingWebsiteURL, diff --git a/pkg/coredata/third_party_filter.go b/pkg/coredata/third_party_filter.go index f9942b830..436aaf226 100644 --- a/pkg/coredata/third_party_filter.go +++ b/pkg/coredata/third_party_filter.go @@ -26,27 +26,27 @@ import ( type ( ThirdPartyFilter struct { - showOnTrustCenter *bool - level *int - query *string - category *ThirdPartyCategory - country *CountryCode + showOnCompliancePortal *bool + level *int + query *string + category *ThirdPartyCategory + country *CountryCode } ) func NewThirdPartyFilter( - showOnTrustCenter *bool, + showOnCompliancePortal *bool, level *int, query *string, category *ThirdPartyCategory, country *CountryCode, ) *ThirdPartyFilter { return &ThirdPartyFilter{ - showOnTrustCenter: showOnTrustCenter, - level: level, - query: query, - category: category, - country: country, + showOnCompliancePortal: showOnCompliancePortal, + level: level, + query: query, + category: category, + country: country, } } @@ -59,8 +59,8 @@ func (f *ThirdPartyFilter) SQLArguments() pgx.StrictNamedArgs { "filter_country": nil, } - if f.showOnTrustCenter != nil { - args["show_on_trust_center"] = *f.showOnTrustCenter + if f.showOnCompliancePortal != nil { + args["show_on_trust_center"] = *f.showOnCompliancePortal } if f.query != nil && *f.query != "" { diff --git a/pkg/coredata/trust_center_document_access_status.go b/pkg/coredata/trust_center_document_access_status.go deleted file mode 100644 index aced9c4b6..000000000 --- a/pkg/coredata/trust_center_document_access_status.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2025-2026 Probo Inc . -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -package coredata - -import ( - "encoding" - "fmt" -) - -type TrustCenterDocumentAccessStatus string - -const ( - TrustCenterDocumentAccessStatusRequested TrustCenterDocumentAccessStatus = "REQUESTED" - TrustCenterDocumentAccessStatusGranted TrustCenterDocumentAccessStatus = "GRANTED" - TrustCenterDocumentAccessStatusRejected TrustCenterDocumentAccessStatus = "REJECTED" - TrustCenterDocumentAccessStatusRevoked TrustCenterDocumentAccessStatus = "REVOKED" -) - -var ( - _ fmt.Stringer = TrustCenterDocumentAccessStatus("") - _ encoding.TextMarshaler = TrustCenterDocumentAccessStatus("") - _ encoding.TextUnmarshaler = (*TrustCenterDocumentAccessStatus)(nil) -) - -func TrustCenterDocumentAccessStatuses() []TrustCenterDocumentAccessStatus { - return []TrustCenterDocumentAccessStatus{ - TrustCenterDocumentAccessStatusRequested, - TrustCenterDocumentAccessStatusGranted, - TrustCenterDocumentAccessStatusRejected, - TrustCenterDocumentAccessStatusRevoked, - } -} - -func (v TrustCenterDocumentAccessStatus) IsValid() bool { - switch v { - case - TrustCenterDocumentAccessStatusRequested, - TrustCenterDocumentAccessStatusGranted, - TrustCenterDocumentAccessStatusRejected, - TrustCenterDocumentAccessStatusRevoked: - return true - } - - return false -} - -func (v TrustCenterDocumentAccessStatus) String() string { - return string(v) -} - -func (v TrustCenterDocumentAccessStatus) MarshalText() ([]byte, error) { - return []byte(v.String()), nil -} - -func (v *TrustCenterDocumentAccessStatus) UnmarshalText(text []byte) error { - val := TrustCenterDocumentAccessStatus(text) - if !val.IsValid() { - return fmt.Errorf("invalid TrustCenterDocumentAccessStatus value: %q", string(text)) - } - - *v = val - - return nil -} diff --git a/pkg/coredata/trust_center_file_order_field.go b/pkg/coredata/trust_center_file_order_field.go deleted file mode 100644 index 6c8a32f96..000000000 --- a/pkg/coredata/trust_center_file_order_field.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2025-2026 Probo Inc . -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -package coredata - -import ( - "encoding" - "fmt" - - "go.probo.inc/probo/pkg/page" -) - -type ( - TrustCenterFileOrderField string -) - -const ( - TrustCenterFileOrderFieldName TrustCenterFileOrderField = "NAME" - TrustCenterFileOrderFieldCreatedAt TrustCenterFileOrderField = "CREATED_AT" - TrustCenterFileOrderFieldUpdatedAt TrustCenterFileOrderField = "UPDATED_AT" -) - -var ( - _ page.OrderField = TrustCenterFileOrderField("") - _ fmt.Stringer = TrustCenterFileOrderField("") - _ encoding.TextMarshaler = TrustCenterFileOrderField("") - _ encoding.TextUnmarshaler = (*TrustCenterFileOrderField)(nil) -) - -func TrustCenterFileOrderFields() []TrustCenterFileOrderField { - return []TrustCenterFileOrderField{ - TrustCenterFileOrderFieldName, - TrustCenterFileOrderFieldCreatedAt, - TrustCenterFileOrderFieldUpdatedAt, - } -} - -func (v TrustCenterFileOrderField) IsValid() bool { - switch v { - case - TrustCenterFileOrderFieldName, - TrustCenterFileOrderFieldCreatedAt, - TrustCenterFileOrderFieldUpdatedAt: - return true - } - - return false -} - -func (v TrustCenterFileOrderField) String() string { - return string(v) -} - -func (v TrustCenterFileOrderField) MarshalText() ([]byte, error) { - return []byte(v.String()), nil -} - -func (v *TrustCenterFileOrderField) UnmarshalText(text []byte) error { - val := TrustCenterFileOrderField(text) - if !val.IsValid() { - return fmt.Errorf("invalid TrustCenterFileOrderField value: %q", string(text)) - } - - *v = val - - return nil -} - -func (p TrustCenterFileOrderField) Column() string { - switch p { - case TrustCenterFileOrderFieldName: - return "name" - case TrustCenterFileOrderFieldCreatedAt: - return "created_at" - case TrustCenterFileOrderFieldUpdatedAt: - return "updated_at" - default: - return string(p) - } -}