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 <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-07-20 18:08:13 +02:00
parent 69a7c5fca7
commit 4bf3d4df79
30 changed files with 770 additions and 770 deletions

View File

@@ -44,7 +44,7 @@ type (
ValidFrom *time.Time `db:"valid_from"` ValidFrom *time.Time `db:"valid_from"`
ValidUntil *time.Time `db:"valid_until"` ValidUntil *time.Time `db:"valid_until"`
State AuditState `db:"state"` State AuditState `db:"state"`
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"` CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"` UpdatedAt time.Time `db:"updated_at"`
} }
@@ -288,7 +288,7 @@ INSERT INTO audits (
"valid_from": a.ValidFrom, "valid_from": a.ValidFrom,
"valid_until": a.ValidUntil, "valid_until": a.ValidUntil,
"state": a.State, "state": a.State,
"trust_center_visibility": a.TrustCenterVisibility, "trust_center_visibility": a.CompliancePortalVisibility,
"created_at": a.CreatedAt, "created_at": a.CreatedAt,
"updated_at": a.UpdatedAt, "updated_at": a.UpdatedAt,
} }
@@ -330,7 +330,7 @@ WHERE
"valid_from": a.ValidFrom, "valid_from": a.ValidFrom,
"valid_until": a.ValidUntil, "valid_until": a.ValidUntil,
"state": a.State, "state": a.State,
"trust_center_visibility": a.TrustCenterVisibility, "trust_center_visibility": a.CompliancePortalVisibility,
"updated_at": a.UpdatedAt, "updated_at": a.UpdatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())

View File

@@ -26,7 +26,7 @@ import (
type ( type (
AuditFilter struct { AuditFilter struct {
trustCenterVisibilities []TrustCenterVisibility compliancePortalVisibilities []CompliancePortalVisibility
} }
) )
@@ -34,26 +34,26 @@ func NewAuditFilter() *AuditFilter {
return &AuditFilter{} return &AuditFilter{}
} }
func NewAuditTrustCenterFilter() *AuditFilter { func NewAuditCompliancePortalFilter() *AuditFilter {
return &AuditFilter{ return &AuditFilter{
trustCenterVisibilities: []TrustCenterVisibility{ compliancePortalVisibilities: []CompliancePortalVisibility{
TrustCenterVisibilityPrivate, CompliancePortalVisibilityPrivate,
TrustCenterVisibilityPublic, CompliancePortalVisibilityPublic,
}, },
} }
} }
func (f *AuditFilter) WithTrustCenterVisibilities(visibilities ...TrustCenterVisibility) *AuditFilter { func (f *AuditFilter) WithCompliancePortalVisibilities(visibilities ...CompliancePortalVisibility) *AuditFilter {
f.trustCenterVisibilities = visibilities f.compliancePortalVisibilities = visibilities
return f return f
} }
func (f *AuditFilter) SQLArguments() pgx.NamedArgs { func (f *AuditFilter) SQLArguments() pgx.NamedArgs {
args := pgx.NamedArgs{} args := pgx.NamedArgs{}
if f.trustCenterVisibilities != nil { if f.compliancePortalVisibilities != nil {
visibilities := make([]string, len(f.trustCenterVisibilities)) visibilities := make([]string, len(f.compliancePortalVisibilities))
for i, v := range f.trustCenterVisibilities { for i, v := range f.compliancePortalVisibilities {
visibilities[i] = v.String() visibilities[i] = v.String()
} }
@@ -64,7 +64,7 @@ func (f *AuditFilter) SQLArguments() pgx.NamedArgs {
} }
func (f *AuditFilter) SQLFragment() string { func (f *AuditFilter) SQLFragment() string {
if f.trustCenterVisibilities != nil { if f.compliancePortalVisibilities != nil {
return "trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])" return "trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])"
} }

View File

@@ -59,10 +59,10 @@ func ResourceTypeName(entityType uint16) string {
return "Datum" return "Datum"
case AuditEntityType: case AuditEntityType:
return "Audit" return "Audit"
case TrustCenterEntityType: case CompliancePortalEntityType:
return "TrustCenter" return "CompliancePortal"
case TrustCenterAccessEntityType: case CompliancePortalAccessEntityType:
return "TrustCenterAccess" return "CompliancePortalAccess"
case ThirdPartyBusinessAssociateAgreementEntityType: case ThirdPartyBusinessAssociateAgreementEntityType:
return "ThirdPartyBusinessAssociateAgreement" return "ThirdPartyBusinessAssociateAgreement"
case FileEntityType: case FileEntityType:
@@ -79,18 +79,18 @@ func ResourceTypeName(entityType uint16) string {
return "ThirdPartyService" return "ThirdPartyService"
case ProcessingActivityEntityType: case ProcessingActivityEntityType:
return "ProcessingActivity" return "ProcessingActivity"
case TrustCenterReferenceEntityType: case CompliancePortalReferenceEntityType:
return "TrustCenterReference" return "CompliancePortalReference"
case TrustCenterDocumentAccessEntityType: case CompliancePortalDocumentAccessEntityType:
return "TrustCenterDocumentAccess" return "CompliancePortalDocumentAccess"
case CustomDomainEntityType: case CustomDomainEntityType:
return "CustomDomain" return "CustomDomain"
case InvitationEntityType: case InvitationEntityType:
return "Invitation" return "Invitation"
case MembershipEntityType: case MembershipEntityType:
return "Membership" return "Membership"
case TrustCenterFileEntityType: case CompliancePortalFileEntityType:
return "TrustCenterFile" return "CompliancePortalFile"
case DataProtectionImpactAssessmentEntityType: case DataProtectionImpactAssessmentEntityType:
return "DataProtectionImpactAssessment" return "DataProtectionImpactAssessment"
case TransferImpactAssessmentEntityType: case TransferImpactAssessmentEntityType:

View File

@@ -38,7 +38,7 @@ type (
ComplianceCustomLink struct { ComplianceCustomLink struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
TrustCenterID gid.GID `db:"trust_center_id"` CompliancePortalID gid.GID `db:"trust_center_id"`
Name string `db:"name"` Name string `db:"name"`
URL string `db:"url"` URL string `db:"url"`
Rank int `db:"rank"` Rank int `db:"rank"`
@@ -182,7 +182,7 @@ RETURNING rank;
"id": c.ID, "id": c.ID,
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"organization_id": c.OrganizationID, "organization_id": c.OrganizationID,
"trust_center_id": c.TrustCenterID, "trust_center_id": c.CompliancePortalID,
"name": c.Name, "name": c.Name,
"url": c.URL, "url": c.URL,
"created_at": c.CreatedAt, "created_at": c.CreatedAt,
@@ -267,7 +267,7 @@ WHERE %s
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"id": c.ID, "id": c.ID,
"new_rank": c.Rank, "new_rank": c.Rank,
"trust_center_id": c.TrustCenterID, "trust_center_id": c.CompliancePortalID,
"updated_at": c.UpdatedAt, "updated_at": c.UpdatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
@@ -305,11 +305,11 @@ WHERE
return nil return nil
} }
func (c *ComplianceCustomLinks) LoadByTrustCenterID( func (c *ComplianceCustomLinks) LoadByCompliancePortalID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
cursor *page.Cursor[ComplianceCustomLinkOrderField], cursor *page.Cursor[ComplianceCustomLinkOrderField],
) error { ) error {
q := ` q := `
@@ -331,7 +331,7 @@ WHERE
` `
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) 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, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())

View File

@@ -39,13 +39,13 @@ type (
ComplianceFramework struct { ComplianceFramework struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
TrustCenterID gid.GID `db:"trust_center_id"` CompliancePortalID gid.GID `db:"trust_center_id"`
FrameworkID gid.GID `db:"framework_id"` FrameworkID gid.GID `db:"framework_id"`
Rank int `db:"rank"` Rank int `db:"rank"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_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"` Visibility ComplianceFrameworkVisibility `db:"visibility"`
} }
@@ -149,11 +149,11 @@ LIMIT 1;
return nil return nil
} }
func (c *ComplianceFramework) LoadByTrustCenterIDAndFrameworkID( func (c *ComplianceFramework) LoadByCompliancePortalIDAndFrameworkID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
frameworkID gid.GID, frameworkID gid.GID,
) error { ) error {
q := ` q := `
@@ -177,7 +177,7 @@ LIMIT 1;
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_id": trustCenterID, "trust_center_id": compliancePortalID,
"framework_id": frameworkID, "framework_id": frameworkID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
@@ -235,7 +235,7 @@ RETURNING rank;
"id": c.ID, "id": c.ID,
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"organization_id": c.OrganizationID, "organization_id": c.OrganizationID,
"trust_center_id": c.TrustCenterID, "trust_center_id": c.CompliancePortalID,
"framework_id": c.FrameworkID, "framework_id": c.FrameworkID,
"created_at": c.CreatedAt, "created_at": c.CreatedAt,
"updated_at": c.UpdatedAt, "updated_at": c.UpdatedAt,
@@ -292,7 +292,7 @@ WHERE %s
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"id": c.ID, "id": c.ID,
"new_rank": c.Rank, "new_rank": c.Rank,
"trust_center_id": c.TrustCenterID, "trust_center_id": c.CompliancePortalID,
"updated_at": c.UpdatedAt, "updated_at": c.UpdatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
@@ -330,11 +330,11 @@ WHERE
return nil return nil
} }
func (c *ComplianceFrameworks) LoadByTrustCenterID( func (c *ComplianceFrameworks) LoadByCompliancePortalID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
cursor *page.Cursor[ComplianceFrameworkOrderField], cursor *page.Cursor[ComplianceFrameworkOrderField],
) error { ) error {
q := ` q := `
@@ -356,7 +356,7 @@ WHERE
` `
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) 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, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())
@@ -375,11 +375,11 @@ WHERE
return nil return nil
} }
func (c *ComplianceFrameworks) LoadWithHiddenByTrustCenterID( func (c *ComplianceFrameworks) LoadWithHiddenByCompliancePortalID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
cursor *page.Cursor[ComplianceFrameworkOrderField], cursor *page.Cursor[ComplianceFrameworkOrderField],
) error { ) error {
q := ` q := `
@@ -413,7 +413,7 @@ WHERE %s
` `
q = fmt.Sprintf(q, cursor.SQLFragment()) 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, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())

View File

@@ -36,7 +36,7 @@ import (
) )
type ( type (
TrustCenter struct { CompliancePortal struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
TenantID gid.TenantID `db:"tenant_id"` TenantID gid.TenantID `db:"tenant_id"`
@@ -58,19 +58,19 @@ type (
UpdatedAt time.Time `db:"updated_at"` 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 { switch orderBy {
case TrustCenterOrderFieldCreatedAt: case CompliancePortalOrderFieldCreatedAt:
return page.NewCursorKey(tc.ID, tc.CreatedAt) return page.NewCursorKey(tc.ID, tc.CreatedAt)
} }
panic(fmt.Sprintf("unsupported order by: %s", orderBy)) panic(fmt.Sprintf("unsupported order by: %s", orderBy))
} }
func (tc *TrustCenter) AuthorizationAttributes( func (tc *CompliancePortal) AuthorizationAttributes(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
resourceIDs []gid.GID, resourceIDs []gid.GID,
@@ -109,11 +109,11 @@ func (tc *TrustCenter) AuthorizationAttributes(
return attrsByID, nil return attrsByID, nil
} }
func (tc *TrustCenter) LoadByID( func (tc *CompliancePortal) LoadByID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -146,29 +146,29 @@ LIMIT 1;
q = fmt.Sprintf(q, scope.SQLFragment()) 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()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 return nil
} }
func (tc *TrustCenter) LoadByMailingListID( func (tc *CompliancePortal) LoadByMailingListID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
@@ -210,24 +210,24 @@ LIMIT 1;
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 return nil
} }
func (tc *TrustCenter) LoadByOrganizationID( func (tc *CompliancePortal) LoadByOrganizationID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
@@ -269,25 +269,25 @@ LIMIT 1;
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 return nil
} }
// Tenant id scope is not applied because we want to access trust centers by slug across all tenants for public access. // Tenant id scope is not applied because we want to access compliance portals by slug across all tenants for public access.
func (tc *TrustCenter) LoadBySlug( func (tc *CompliancePortal) LoadBySlug(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
slug string, slug string,
@@ -324,19 +324,19 @@ LIMIT 1;
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 return nil
} }
@@ -346,7 +346,7 @@ LIMIT 1;
// reverse SNI lookup: a served host resolves to a custom domain, which resolves // 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 // back to its page. Tenant scope is not applied because SNI resolution happens
// across all tenants for public access. // across all tenants for public access.
func (tc *TrustCenter) LoadByDomainID( func (tc *CompliancePortal) LoadByDomainID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
domainID gid.GID, domainID gid.GID,
@@ -384,24 +384,24 @@ LIMIT 1;
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 return nil
} }
func (tc *TrustCenter) Insert( func (tc *CompliancePortal) Insert(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, 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 return nil
} }
func (tc *TrustCenter) Update( func (tc *CompliancePortal) Update(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -536,7 +536,7 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot update trust center: %w", err) return fmt.Errorf("cannot update compliance portal: %w", err)
} }
return nil return nil

View File

@@ -36,30 +36,30 @@ import (
) )
type ( type (
TrustCenterAccess struct { CompliancePortalAccess struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
TenantID gid.TenantID `db:"tenant_id"` TenantID gid.TenantID `db:"tenant_id"`
IdentityID gid.GID `db:"identity_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"` ElectronicSignatureID *gid.GID `db:"electronic_signature_id"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_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 { switch orderBy {
case TrustCenterAccessOrderFieldCreatedAt: case CompliancePortalAccessOrderFieldCreatedAt:
return page.NewCursorKey(tca.ID, tca.CreatedAt) return page.NewCursorKey(tca.ID, tca.CreatedAt)
} }
panic(fmt.Sprintf("unsupported order by: %s", orderBy)) panic(fmt.Sprintf("unsupported order by: %s", orderBy))
} }
func (tca *TrustCenterAccess) AuthorizationAttributes( func (tca *CompliancePortalAccess) AuthorizationAttributes(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
resourceIDs []gid.GID, resourceIDs []gid.GID,
@@ -98,7 +98,7 @@ func (tca *TrustCenterAccess) AuthorizationAttributes(
return attrsByID, nil return attrsByID, nil
} }
func (tca *TrustCenterAccess) LoadByID( func (tca *CompliancePortalAccess) LoadByID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
@@ -129,16 +129,16 @@ LIMIT 1;
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound return ErrResourceNotFound
} }
return fmt.Errorf("cannot collect trust center access: %w", err) return fmt.Errorf("cannot collect compliance portal access: %w", err)
} }
*tca = access *tca = access
@@ -146,11 +146,11 @@ LIMIT 1;
return nil return nil
} }
func (tca *TrustCenterAccess) LoadByTrustCenterIDAndIdentityID( func (tca *CompliancePortalAccess) LoadByCompliancePortalIDAndIdentityID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
identityID gid.GID, identityID gid.GID,
) error { ) error {
q := ` q := `
@@ -175,23 +175,23 @@ LIMIT 1;
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_id": trustCenterID, "trust_center_id": compliancePortalID,
"identity_id": identityID, "identity_id": identityID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound return ErrResourceNotFound
} }
return fmt.Errorf("cannot collect trust center access: %w", err) return fmt.Errorf("cannot collect compliance portal access: %w", err)
} }
*tca = access *tca = access
@@ -199,7 +199,7 @@ LIMIT 1;
return nil return nil
} }
func (tca *TrustCenterAccess) Insert( func (tca *CompliancePortalAccess) Insert(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -231,7 +231,7 @@ INSERT INTO trust_center_accesses (
"tenant_id": tca.TenantID, "tenant_id": tca.TenantID,
"organization_id": tca.OrganizationID, "organization_id": tca.OrganizationID,
"identity_id": tca.IdentityID, "identity_id": tca.IdentityID,
"trust_center_id": tca.TrustCenterID, "trust_center_id": tca.CompliancePortalID,
"electronic_signature_id": tca.ElectronicSignatureID, "electronic_signature_id": tca.ElectronicSignatureID,
"created_at": tca.CreatedAt, "created_at": tca.CreatedAt,
"updated_at": tca.UpdatedAt, "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 return nil
} }
func (tca *TrustCenterAccess) Update( func (tca *CompliancePortalAccess) Update(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -276,13 +276,13 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (tca *TrustCenterAccess) Delete( func (tca *CompliancePortalAccess) Delete(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -303,18 +303,18 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (tcas *TrustCenterAccesses) LoadByTrustCenterID( func (tcas *CompliancePortalAccesses) LoadByCompliancePortalID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
cursor *page.Cursor[TrustCenterAccessOrderField], cursor *page.Cursor[CompliancePortalAccessOrderField],
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -337,19 +337,19 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_id": trustCenterID, "trust_center_id": compliancePortalID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 { 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 *tcas = accesses

View File

@@ -27,47 +27,47 @@ import (
"go.probo.inc/probo/pkg/page" "go.probo.inc/probo/pkg/page"
) )
type TrustCenterAccessOrderField string type CompliancePortalAccessOrderField string
const ( const (
TrustCenterAccessOrderFieldCreatedAt TrustCenterAccessOrderField = "CREATED_AT" CompliancePortalAccessOrderFieldCreatedAt CompliancePortalAccessOrderField = "CREATED_AT"
) )
var ( var (
_ page.OrderField = TrustCenterAccessOrderField("") _ page.OrderField = CompliancePortalAccessOrderField("")
_ fmt.Stringer = TrustCenterAccessOrderField("") _ fmt.Stringer = CompliancePortalAccessOrderField("")
_ encoding.TextMarshaler = TrustCenterAccessOrderField("") _ encoding.TextMarshaler = CompliancePortalAccessOrderField("")
_ encoding.TextUnmarshaler = (*TrustCenterAccessOrderField)(nil) _ encoding.TextUnmarshaler = (*CompliancePortalAccessOrderField)(nil)
) )
func TrustCenterAccessOrderFields() []TrustCenterAccessOrderField { func CompliancePortalAccessOrderFields() []CompliancePortalAccessOrderField {
return []TrustCenterAccessOrderField{ return []CompliancePortalAccessOrderField{
TrustCenterAccessOrderFieldCreatedAt, CompliancePortalAccessOrderFieldCreatedAt,
} }
} }
func (v TrustCenterAccessOrderField) IsValid() bool { func (v CompliancePortalAccessOrderField) IsValid() bool {
switch v { switch v {
case case
TrustCenterAccessOrderFieldCreatedAt: CompliancePortalAccessOrderFieldCreatedAt:
return true return true
} }
return false return false
} }
func (v TrustCenterAccessOrderField) String() string { func (v CompliancePortalAccessOrderField) String() string {
return string(v) return string(v)
} }
func (v TrustCenterAccessOrderField) MarshalText() ([]byte, error) { func (v CompliancePortalAccessOrderField) MarshalText() ([]byte, error) {
return []byte(v.String()), nil return []byte(v.String()), nil
} }
func (v *TrustCenterAccessOrderField) UnmarshalText(text []byte) error { func (v *CompliancePortalAccessOrderField) UnmarshalText(text []byte) error {
val := TrustCenterAccessOrderField(text) val := CompliancePortalAccessOrderField(text)
if !val.IsValid() { if !val.IsValid() {
return fmt.Errorf("invalid TrustCenterAccessOrderField value: %q", string(text)) return fmt.Errorf("invalid CompliancePortalAccessOrderField value: %q", string(text))
} }
*v = val *v = val
@@ -75,9 +75,9 @@ func (v *TrustCenterAccessOrderField) UnmarshalText(text []byte) error {
return nil return nil
} }
func (tcaof TrustCenterAccessOrderField) Column() string { func (tcaof CompliancePortalAccessOrderField) Column() string {
switch tcaof { switch tcaof {
case TrustCenterAccessOrderFieldCreatedAt: case CompliancePortalAccessOrderFieldCreatedAt:
return "created_at" return "created_at"
} }

View File

@@ -25,49 +25,49 @@ import (
"fmt" "fmt"
) )
type TrustCenterAccessState string type CompliancePortalAccessState string
const ( const (
TrustCenterAccessStateActive TrustCenterAccessState = "ACTIVE" CompliancePortalAccessStateActive CompliancePortalAccessState = "ACTIVE"
TrustCenterAccessStateInactive TrustCenterAccessState = "INACTIVE" CompliancePortalAccessStateInactive CompliancePortalAccessState = "INACTIVE"
) )
var ( var (
_ fmt.Stringer = TrustCenterAccessState("") _ fmt.Stringer = CompliancePortalAccessState("")
_ encoding.TextMarshaler = TrustCenterAccessState("") _ encoding.TextMarshaler = CompliancePortalAccessState("")
_ encoding.TextUnmarshaler = (*TrustCenterAccessState)(nil) _ encoding.TextUnmarshaler = (*CompliancePortalAccessState)(nil)
) )
func TrustCenterAccessStates() []TrustCenterAccessState { func CompliancePortalAccessStates() []CompliancePortalAccessState {
return []TrustCenterAccessState{ return []CompliancePortalAccessState{
TrustCenterAccessStateActive, CompliancePortalAccessStateActive,
TrustCenterAccessStateInactive, CompliancePortalAccessStateInactive,
} }
} }
func (v TrustCenterAccessState) IsValid() bool { func (v CompliancePortalAccessState) IsValid() bool {
switch v { switch v {
case case
TrustCenterAccessStateActive, CompliancePortalAccessStateActive,
TrustCenterAccessStateInactive: CompliancePortalAccessStateInactive:
return true return true
} }
return false return false
} }
func (v TrustCenterAccessState) String() string { func (v CompliancePortalAccessState) String() string {
return string(v) return string(v)
} }
func (v TrustCenterAccessState) MarshalText() ([]byte, error) { func (v CompliancePortalAccessState) MarshalText() ([]byte, error) {
return []byte(v.String()), nil return []byte(v.String()), nil
} }
func (v *TrustCenterAccessState) UnmarshalText(text []byte) error { func (v *CompliancePortalAccessState) UnmarshalText(text []byte) error {
val := TrustCenterAccessState(text) val := CompliancePortalAccessState(text)
if !val.IsValid() { if !val.IsValid() {
return fmt.Errorf("invalid TrustCenterAccessState value: %q", string(text)) return fmt.Errorf("invalid CompliancePortalAccessState value: %q", string(text))
} }
*v = val *v = val

View File

@@ -39,7 +39,7 @@ type (
CompliancePortalCommitment struct { CompliancePortalCommitment struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
TrustCenterID gid.GID `db:"trust_center_id"` CompliancePortalID gid.GID `db:"trust_center_id"`
GroupID gid.GID `db:"group_id"` GroupID gid.GID `db:"group_id"`
Icon CompliancePortalCommitmentIcon `db:"icon"` Icon CompliancePortalCommitmentIcon `db:"icon"`
Eyebrow string `db:"eyebrow"` Eyebrow string `db:"eyebrow"`
@@ -193,7 +193,7 @@ RETURNING rank;
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"id": t.ID, "id": t.ID,
"organization_id": t.OrganizationID, "organization_id": t.OrganizationID,
"trust_center_id": t.TrustCenterID, "trust_center_id": t.CompliancePortalID,
"group_id": t.GroupID, "group_id": t.GroupID,
"icon": t.Icon, "icon": t.Icon,
"eyebrow": t.Eyebrow, "eyebrow": t.Eyebrow,

View File

@@ -39,7 +39,7 @@ type (
CompliancePortalCommitmentGroup struct { CompliancePortalCommitmentGroup struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
TrustCenterID gid.GID `db:"trust_center_id"` CompliancePortalID gid.GID `db:"trust_center_id"`
Title string `db:"title"` Title string `db:"title"`
Description string `db:"description"` Description string `db:"description"`
Rank int `db:"rank"` Rank int `db:"rank"`
@@ -181,7 +181,7 @@ RETURNING rank;
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"id": t.ID, "id": t.ID,
"organization_id": t.OrganizationID, "organization_id": t.OrganizationID,
"trust_center_id": t.TrustCenterID, "trust_center_id": t.CompliancePortalID,
"title": t.Title, "title": t.Title,
"description": t.Description, "description": t.Description,
"created_at": t.CreatedAt, "created_at": t.CreatedAt,
@@ -276,7 +276,7 @@ WHERE %s
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"id": t.ID, "id": t.ID,
"new_rank": t.Rank, "new_rank": t.Rank,
"trust_center_id": t.TrustCenterID, "trust_center_id": t.CompliancePortalID,
"updated_at": t.UpdatedAt, "updated_at": t.UpdatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
@@ -315,11 +315,11 @@ WHERE
return nil return nil
} }
func (t *CompliancePortalCommitmentGroups) LoadByTrustCenterID( func (t *CompliancePortalCommitmentGroups) LoadByCompliancePortalID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
cursor *page.Cursor[CompliancePortalCommitmentGroupOrderField], cursor *page.Cursor[CompliancePortalCommitmentGroupOrderField],
) error { ) error {
q := ` q := `
@@ -342,7 +342,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) 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, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())
@@ -361,11 +361,11 @@ WHERE
return nil return nil
} }
func (t *CompliancePortalCommitmentGroups) CountByTrustCenterID( func (t *CompliancePortalCommitmentGroups) CountByCompliancePortalID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
) (int, error) { ) (int, error) {
q := ` q := `
SELECT SELECT
@@ -379,7 +379,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) 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()) maps.Copy(args, scope.SQLArguments())
var count int var count int

View File

@@ -36,31 +36,31 @@ import (
) )
type ( type (
TrustCenterDocumentAccess struct { CompliancePortalDocumentAccess struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
TrustCenterAccessID gid.GID `db:"trust_center_access_id"` CompliancePortalAccessID gid.GID `db:"trust_center_access_id"`
DocumentID *gid.GID `db:"document_id"` DocumentID *gid.GID `db:"document_id"`
ReportFileID *gid.GID `db:"report_file_id"` ReportFileID *gid.GID `db:"report_file_id"`
TrustCenterFileID *gid.GID `db:"trust_center_file_id"` CompliancePortalFileID *gid.GID `db:"trust_center_file_id"`
Status TrustCenterDocumentAccessStatus `db:"status"` Status CompliancePortalDocumentAccessStatus `db:"status"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_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 { switch orderBy {
case TrustCenterDocumentAccessOrderFieldCreatedAt: case CompliancePortalDocumentAccessOrderFieldCreatedAt:
return page.NewCursorKey(tcda.ID, tcda.CreatedAt) return page.NewCursorKey(tcda.ID, tcda.CreatedAt)
} }
panic(fmt.Sprintf("unsupported order by: %s", orderBy)) panic(fmt.Sprintf("unsupported order by: %s", orderBy))
} }
func (tcda *TrustCenterDocumentAccess) AuthorizationAttributes( func (tcda *CompliancePortalDocumentAccess) AuthorizationAttributes(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
resourceIDs []gid.GID, resourceIDs []gid.GID,
@@ -99,7 +99,7 @@ func (tcda *TrustCenterDocumentAccess) AuthorizationAttributes(
return attrsByID, nil return attrsByID, nil
} }
func (tcda *TrustCenterDocumentAccess) LoadByID( func (tcda *CompliancePortalDocumentAccess) LoadByID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
@@ -131,16 +131,16 @@ LIMIT 1;
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 *tcda = access
@@ -148,11 +148,11 @@ LIMIT 1;
return nil return nil
} }
func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndDocumentID( func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndDocumentID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
documentID gid.GID, documentID gid.GID,
) error { ) error {
q := ` q := `
@@ -178,23 +178,23 @@ LIMIT 1;
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"document_id": documentID, "document_id": documentID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 *tcda = access
@@ -202,11 +202,11 @@ LIMIT 1;
return nil return nil
} }
func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndReportFileID( func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndReportFileID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
reportFileID gid.GID, reportFileID gid.GID,
) error { ) error {
q := ` q := `
@@ -232,23 +232,23 @@ LIMIT 1;
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"report_file_id": reportFileID, "report_file_id": reportFileID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 *tcda = access
@@ -256,7 +256,7 @@ LIMIT 1;
return nil return nil
} }
func (tcda *TrustCenterDocumentAccess) Insert( func (tcda *CompliancePortalDocumentAccess) Insert(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -291,10 +291,10 @@ INSERT INTO trust_center_document_accesses (
"id": tcda.ID, "id": tcda.ID,
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"organization_id": tcda.OrganizationID, "organization_id": tcda.OrganizationID,
"trust_center_access_id": tcda.TrustCenterAccessID, "trust_center_access_id": tcda.CompliancePortalAccessID,
"document_id": tcda.DocumentID, "document_id": tcda.DocumentID,
"report_file_id": tcda.ReportFileID, "report_file_id": tcda.ReportFileID,
"trust_center_file_id": tcda.TrustCenterFileID, "trust_center_file_id": tcda.CompliancePortalFileID,
"status": tcda.Status, "status": tcda.Status,
"created_at": tcda.CreatedAt, "created_at": tcda.CreatedAt,
"updated_at": tcda.UpdatedAt, "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 return nil
} }
func (tcda *TrustCenterDocumentAccess) Update( func (tcda *CompliancePortalDocumentAccess) Update(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -344,13 +344,13 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (tcda *TrustCenterDocumentAccess) Delete( func (tcda *CompliancePortalDocumentAccess) Delete(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -371,17 +371,17 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (tcdas *TrustCenterDocumentAccesses) CountByTrustCenterAccessID( func (tcdas *CompliancePortalDocumentAccesses) CountByCompliancePortalAccessID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
) (int, error) { ) (int, error) {
q := ` q := `
SELECT SELECT
@@ -396,7 +396,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
@@ -410,11 +410,11 @@ WHERE
return count, nil return count, nil
} }
func (tcdas *TrustCenterDocumentAccesses) CountPendingRequestByTrustCenterAccessID( func (tcdas *CompliancePortalDocumentAccesses) CountPendingRequestByCompliancePortalAccessID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
) (int, error) { ) (int, error) {
q := ` q := `
SELECT SELECT
@@ -430,7 +430,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
@@ -444,11 +444,11 @@ WHERE
return count, nil return count, nil
} }
func (tcdas *TrustCenterDocumentAccesses) CountActiveByTrustCenterAccessID( func (tcdas *CompliancePortalDocumentAccesses) CountActiveByCompliancePortalAccessID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
) (int, error) { ) (int, error) {
q := ` q := `
SELECT SELECT
@@ -464,7 +464,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
@@ -478,12 +478,12 @@ WHERE
return count, nil return count, nil
} }
func (tcdas *TrustCenterDocumentAccesses) LoadAvailableByTrustCenterAccessID( func (tcdas *CompliancePortalDocumentAccesses) LoadAvailableByCompliancePortalAccessID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
cursor *page.Cursor[TrustCenterDocumentAccessOrderField], cursor *page.Cursor[CompliancePortalDocumentAccessOrderField],
) error { ) error {
q := ` q := `
WITH organization AS ( WITH organization AS (
@@ -581,19 +581,19 @@ WHERE %s
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 { 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 *tcdas = accesses
@@ -601,12 +601,12 @@ WHERE %s
return nil return nil
} }
func (tcdas *TrustCenterDocumentAccesses) LoadByTrustCenterAccessID( func (tcdas *CompliancePortalDocumentAccesses) LoadByCompliancePortalAccessID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
cursor *page.Cursor[TrustCenterDocumentAccessOrderField], cursor *page.Cursor[CompliancePortalDocumentAccessOrderField],
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -630,19 +630,19 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 { 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 *tcdas = accesses
@@ -654,7 +654,7 @@ func GrantByDocumentIDs(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
documentIDs []gid.GID, documentIDs []gid.GID,
updatedAt time.Time, updatedAt time.Time,
) error { ) error {
@@ -670,7 +670,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"document_ids": documentIDs, "document_ids": documentIDs,
"updated_at": updatedAt, "updated_at": updatedAt,
} }
@@ -678,7 +678,7 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
@@ -688,7 +688,7 @@ func RejectOrRevokeByDocumentIDs(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
documentIDs []gid.GID, documentIDs []gid.GID,
updatedAt time.Time, updatedAt time.Time,
) error { ) error {
@@ -709,7 +709,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"document_ids": documentIDs, "document_ids": documentIDs,
"updated_at": updatedAt, "updated_at": updatedAt,
} }
@@ -717,7 +717,7 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
@@ -727,7 +727,7 @@ func GrantByReportFileIDs(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
reportFileIDs []gid.GID, reportFileIDs []gid.GID,
updatedAt time.Time, updatedAt time.Time,
) error { ) error {
@@ -743,7 +743,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"report_file_ids": reportFileIDs, "report_file_ids": reportFileIDs,
"updated_at": updatedAt, "updated_at": updatedAt,
} }
@@ -751,7 +751,7 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
@@ -761,7 +761,7 @@ func RejectOrRevokeByReportFileIDs(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
reportFileIDs []gid.GID, reportFileIDs []gid.GID,
updatedAt time.Time, updatedAt time.Time,
) error { ) error {
@@ -782,7 +782,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"report_file_ids": reportFileIDs, "report_file_ids": reportFileIDs,
"updated_at": updatedAt, "updated_at": updatedAt,
} }
@@ -790,24 +790,24 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
type MergeTrustCenterDocumentAccessesData struct { type MergeCompliancePortalDocumentAccessesData struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Status TrustCenterDocumentAccessStatus `json:"status"` Status CompliancePortalDocumentAccessStatus `json:"status"`
} }
func (tcdas TrustCenterDocumentAccesses) MergeDocumentAccesses( func (tcdas CompliancePortalDocumentAccesses) MergeDocumentAccesses(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
organizationID gid.GID, organizationID gid.GID,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
data []MergeTrustCenterDocumentAccessesData, data []MergeCompliancePortalDocumentAccessesData,
) error { ) error {
q := ` q := `
WITH data AS ( WITH data AS (
@@ -859,9 +859,9 @@ WHEN NOT MATCHED
` `
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"organization_id": organizationID, "organization_id": organizationID,
"now": time.Now(), "now": time.Now(),
"data": data, "data": data,
@@ -874,14 +874,14 @@ WHEN NOT MATCHED
return nil return nil
} }
func (tcdas TrustCenterDocumentAccesses) BulkInsertDocumentAccesses( func (tcdas CompliancePortalDocumentAccesses) BulkInsertDocumentAccesses(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
organizationID gid.GID, organizationID gid.GID,
documentIDs []gid.GID, documentIDs []gid.GID,
status TrustCenterDocumentAccessStatus, status CompliancePortalDocumentAccessStatus,
createdAt time.Time, createdAt time.Time,
) error { ) error {
if len(documentIDs) == 0 { if len(documentIDs) == 0 {
@@ -921,28 +921,28 @@ ON CONFLICT DO NOTHING
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"organization_id": organizationID, "organization_id": organizationID,
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"document_ids": documentIDs, "document_ids": documentIDs,
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
"status": status, "status": status,
"created_at": createdAt, "created_at": createdAt,
"updated_at": createdAt, "updated_at": createdAt,
} }
if _, err := conn.Exec(ctx, q, args); err != nil { 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 return nil
} }
func (tcdas TrustCenterDocumentAccesses) MergeReportFileAccesses( func (tcdas CompliancePortalDocumentAccesses) MergeReportFileAccesses(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
organizationID gid.GID, organizationID gid.GID,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
data []MergeTrustCenterDocumentAccessesData, data []MergeCompliancePortalDocumentAccessesData,
) error { ) error {
q := ` q := `
WITH data AS ( WITH data AS (
@@ -994,9 +994,9 @@ WHEN NOT MATCHED
` `
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"organization_id": organizationID, "organization_id": organizationID,
"now": time.Now(), "now": time.Now(),
"data": data, "data": data,
@@ -1009,14 +1009,14 @@ WHEN NOT MATCHED
return nil return nil
} }
func (tcdas TrustCenterDocumentAccesses) BulkInsertReportFileAccesses( func (tcdas CompliancePortalDocumentAccesses) BulkInsertReportFileAccesses(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
organizationID gid.GID, organizationID gid.GID,
reportFileIDs []gid.GID, reportFileIDs []gid.GID,
status TrustCenterDocumentAccessStatus, status CompliancePortalDocumentAccessStatus,
createdAt time.Time, createdAt time.Time,
) error { ) error {
if len(reportFileIDs) == 0 { if len(reportFileIDs) == 0 {
@@ -1056,8 +1056,8 @@ ON CONFLICT DO NOTHING
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"organization_id": organizationID, "organization_id": organizationID,
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"report_file_ids": reportFileIDs, "report_file_ids": reportFileIDs,
"status": status, "status": status,
"created_at": createdAt, "created_at": createdAt,
@@ -1065,18 +1065,18 @@ ON CONFLICT DO NOTHING
} }
if _, err := conn.Exec(ctx, q, args); err != nil { 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 return nil
} }
func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndTrustCenterFileID( func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndCompliancePortalFileID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -1101,23 +1101,23 @@ LIMIT 1;
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"trust_center_file_id": trustCenterFileID, "trust_center_file_id": compliancePortalFileID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound 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 *tcda = access
@@ -1125,12 +1125,12 @@ LIMIT 1;
return nil return nil
} }
func GrantByTrustCenterFileIDs( func GrantByCompliancePortalFileIDs(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
trustCenterFileIDs []gid.GID, compliancePortalFileIDs []gid.GID,
updatedAt time.Time, updatedAt time.Time,
) error { ) error {
q := ` q := `
@@ -1145,26 +1145,26 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"trust_center_file_ids": trustCenterFileIDs, "trust_center_file_ids": compliancePortalFileIDs,
"updated_at": updatedAt, "updated_at": updatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func RejectOrRevokeByTrustCenterFileIDs( func RejectOrRevokeByCompliancePortalFileIDs(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
trustCenterFileIDs []gid.GID, compliancePortalFileIDs []gid.GID,
updatedAt time.Time, updatedAt time.Time,
) error { ) error {
q := ` q := `
@@ -1184,27 +1184,27 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"trust_center_file_ids": trustCenterFileIDs, "trust_center_file_ids": compliancePortalFileIDs,
"updated_at": updatedAt, "updated_at": updatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (tcdas TrustCenterDocumentAccesses) MergeTrustCenterFileAccesses( func (tcdas CompliancePortalDocumentAccesses) MergeCompliancePortalFileAccesses(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
organizationID gid.GID, organizationID gid.GID,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
data []MergeTrustCenterDocumentAccessesData, data []MergeCompliancePortalDocumentAccessesData,
) error { ) error {
q := ` q := `
WITH data AS ( WITH data AS (
@@ -1256,9 +1256,9 @@ WHEN NOT MATCHED
` `
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"organization_id": organizationID, "organization_id": organizationID,
"now": time.Now(), "now": time.Now(),
"data": data, "data": data,
@@ -1271,14 +1271,14 @@ WHEN NOT MATCHED
return nil return nil
} }
func (tcdas TrustCenterDocumentAccesses) BulkInsertTrustCenterFileAccesses( func (tcdas CompliancePortalDocumentAccesses) BulkInsertCompliancePortalFileAccesses(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
organizationID gid.GID, organizationID gid.GID,
trustCenterFileIDs []gid.GID, compliancePortalFileIDs []gid.GID,
status TrustCenterDocumentAccessStatus, status CompliancePortalDocumentAccessStatus,
createdAt time.Time, createdAt time.Time,
) error { ) error {
q := ` q := `
@@ -1314,16 +1314,16 @@ ON CONFLICT DO NOTHING
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"organization_id": organizationID, "organization_id": organizationID,
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType, "trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
"trust_center_access_id": trustCenterAccessID, "trust_center_access_id": compliancePortalAccessID,
"trust_center_file_ids": trustCenterFileIDs, "trust_center_file_ids": compliancePortalFileIDs,
"status": status, "status": status,
"created_at": createdAt, "created_at": createdAt,
"updated_at": createdAt, "updated_at": createdAt,
} }
if _, err := conn.Exec(ctx, q, args); err != nil { 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 return nil

View File

@@ -27,47 +27,47 @@ import (
"go.probo.inc/probo/pkg/page" "go.probo.inc/probo/pkg/page"
) )
type TrustCenterDocumentAccessOrderField string type CompliancePortalDocumentAccessOrderField string
const ( const (
TrustCenterDocumentAccessOrderFieldCreatedAt TrustCenterDocumentAccessOrderField = "CREATED_AT" CompliancePortalDocumentAccessOrderFieldCreatedAt CompliancePortalDocumentAccessOrderField = "CREATED_AT"
) )
var ( var (
_ page.OrderField = TrustCenterDocumentAccessOrderField("") _ page.OrderField = CompliancePortalDocumentAccessOrderField("")
_ fmt.Stringer = TrustCenterDocumentAccessOrderField("") _ fmt.Stringer = CompliancePortalDocumentAccessOrderField("")
_ encoding.TextMarshaler = TrustCenterDocumentAccessOrderField("") _ encoding.TextMarshaler = CompliancePortalDocumentAccessOrderField("")
_ encoding.TextUnmarshaler = (*TrustCenterDocumentAccessOrderField)(nil) _ encoding.TextUnmarshaler = (*CompliancePortalDocumentAccessOrderField)(nil)
) )
func TrustCenterDocumentAccessOrderFields() []TrustCenterDocumentAccessOrderField { func CompliancePortalDocumentAccessOrderFields() []CompliancePortalDocumentAccessOrderField {
return []TrustCenterDocumentAccessOrderField{ return []CompliancePortalDocumentAccessOrderField{
TrustCenterDocumentAccessOrderFieldCreatedAt, CompliancePortalDocumentAccessOrderFieldCreatedAt,
} }
} }
func (v TrustCenterDocumentAccessOrderField) IsValid() bool { func (v CompliancePortalDocumentAccessOrderField) IsValid() bool {
switch v { switch v {
case case
TrustCenterDocumentAccessOrderFieldCreatedAt: CompliancePortalDocumentAccessOrderFieldCreatedAt:
return true return true
} }
return false return false
} }
func (v TrustCenterDocumentAccessOrderField) String() string { func (v CompliancePortalDocumentAccessOrderField) String() string {
return string(v) return string(v)
} }
func (v TrustCenterDocumentAccessOrderField) MarshalText() ([]byte, error) { func (v CompliancePortalDocumentAccessOrderField) MarshalText() ([]byte, error) {
return []byte(v.String()), nil return []byte(v.String()), nil
} }
func (v *TrustCenterDocumentAccessOrderField) UnmarshalText(text []byte) error { func (v *CompliancePortalDocumentAccessOrderField) UnmarshalText(text []byte) error {
val := TrustCenterDocumentAccessOrderField(text) val := CompliancePortalDocumentAccessOrderField(text)
if !val.IsValid() { if !val.IsValid() {
return fmt.Errorf("invalid TrustCenterDocumentAccessOrderField value: %q", string(text)) return fmt.Errorf("invalid CompliancePortalDocumentAccessOrderField value: %q", string(text))
} }
*v = val *v = val
@@ -75,6 +75,6 @@ func (v *TrustCenterDocumentAccessOrderField) UnmarshalText(text []byte) error {
return nil return nil
} }
func (tcdaof TrustCenterDocumentAccessOrderField) Column() string { func (tcdaof CompliancePortalDocumentAccessOrderField) Column() string {
return string(tcdaof) return string(tcdaof)
} }

View File

@@ -0,0 +1,82 @@
// Copyright (c) 2025-2026 Probo Inc <hello@probo.com>.
//
// 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
}

View File

@@ -34,34 +34,34 @@ import (
) )
type ( type (
TrustCenterFile struct { CompliancePortalFile struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
Name string `db:"name"` Name string `db:"name"`
Category string `db:"category"` Category string `db:"category"`
FileID gid.GID `db:"file_id"` FileID gid.GID `db:"file_id"`
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"` CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_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 { switch orderBy {
case TrustCenterFileOrderFieldName: case CompliancePortalFileOrderFieldName:
return page.NewCursorKey(t.ID, t.Name) return page.NewCursorKey(t.ID, t.Name)
case TrustCenterFileOrderFieldCreatedAt: case CompliancePortalFileOrderFieldCreatedAt:
return page.NewCursorKey(t.ID, t.CreatedAt) return page.NewCursorKey(t.ID, t.CreatedAt)
case TrustCenterFileOrderFieldUpdatedAt: case CompliancePortalFileOrderFieldUpdatedAt:
return page.NewCursorKey(t.ID, t.UpdatedAt) return page.NewCursorKey(t.ID, t.UpdatedAt)
} }
panic(fmt.Sprintf("unsupported order by: %s", orderBy)) panic(fmt.Sprintf("unsupported order by: %s", orderBy))
} }
func (t *TrustCenterFile) AuthorizationAttributes( func (t *CompliancePortalFile) AuthorizationAttributes(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
resourceIDs []gid.GID, resourceIDs []gid.GID,
@@ -100,11 +100,11 @@ func (t *TrustCenterFile) AuthorizationAttributes(
return attrsByID, nil return attrsByID, nil
} }
func (t *TrustCenterFile) LoadByID( func (t *CompliancePortalFile) LoadByID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -125,7 +125,7 @@ LIMIT 1;
` `
q = fmt.Sprintf(q, scope.SQLFragment()) 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()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
@@ -133,9 +133,9 @@ LIMIT 1;
return fmt.Errorf("cannot query trust_center_files: %w", err) 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 { 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 *t = file
@@ -143,11 +143,11 @@ LIMIT 1;
return nil return nil
} }
func (f *TrustCenterFiles) LoadByIDs( func (f *CompliancePortalFiles) LoadByIDs(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterFileIDs []gid.GID, compliancePortalFileIDs []gid.GID,
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -168,7 +168,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"ids": trustCenterFileIDs} args := pgx.StrictNamedArgs{"ids": compliancePortalFileIDs}
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
@@ -177,21 +177,21 @@ WHERE
} }
defer rows.Close() defer rows.Close()
files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterFile]) files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalFile])
if err != nil { if err != nil {
return fmt.Errorf("cannot collect file: %w", err) return fmt.Errorf("cannot collect file: %w", err)
} }
*f = files *f = files
if len(files) != len(gid.NewSet(trustCenterFileIDs...)) { if len(files) != len(gid.NewSet(compliancePortalFileIDs...)) {
return ErrResourceNotFound return ErrResourceNotFound
} }
return nil return nil
} }
func (t TrustCenterFile) Insert( func (t CompliancePortalFile) Insert(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -229,20 +229,20 @@ VALUES (
"name": t.Name, "name": t.Name,
"category": t.Category, "category": t.Category,
"file_id": t.FileID, "file_id": t.FileID,
"trust_center_visibility": t.TrustCenterVisibility, "trust_center_visibility": t.CompliancePortalVisibility,
"created_at": t.CreatedAt, "created_at": t.CreatedAt,
"updated_at": t.UpdatedAt, "updated_at": t.UpdatedAt,
} }
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (t *TrustCenterFile) Update( func (t *CompliancePortalFile) Update(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -274,19 +274,19 @@ RETURNING
"id": t.ID, "id": t.ID,
"name": t.Name, "name": t.Name,
"category": t.Category, "category": t.Category,
"trust_center_visibility": t.TrustCenterVisibility, "trust_center_visibility": t.CompliancePortalVisibility,
"updated_at": t.UpdatedAt, "updated_at": t.UpdatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { 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 { 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 *t = file
@@ -294,7 +294,7 @@ RETURNING
return nil return nil
} }
func (t *TrustCenterFile) Delete( func (t *CompliancePortalFile) Delete(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -314,19 +314,19 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (t *TrustCenterFiles) LoadByOrganizationID( func (t *CompliancePortalFiles) LoadByOrganizationID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
organizationID gid.GID, organizationID gid.GID,
cursor *page.Cursor[TrustCenterFileOrderField], cursor *page.Cursor[CompliancePortalFileOrderField],
filter *TrustCenterFileFilter, filter *CompliancePortalFileFilter,
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -359,9 +359,9 @@ WHERE
return fmt.Errorf("cannot query trust_center_files: %w", err) 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 { 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 *t = files
@@ -369,7 +369,7 @@ WHERE
return nil return nil
} }
func (t *TrustCenterFiles) CountByOrganizationID( func (t *CompliancePortalFiles) CountByOrganizationID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
@@ -394,7 +394,7 @@ WHERE
err := conn.QueryRow(ctx, q, args).Scan(&count) err := conn.QueryRow(ctx, q, args).Scan(&count)
if err != nil { 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 return count, nil

View File

@@ -25,15 +25,15 @@ import (
) )
type ( type (
TrustCenterFileFilter struct { CompliancePortalFileFilter struct {
trustCenterVisibilities []TrustCenterVisibility compliancePortalVisibilities []CompliancePortalVisibility
} }
) )
type TrustCenterFileFilterOption func(f *TrustCenterFileFilter) type CompliancePortalFileFilterOption func(f *CompliancePortalFileFilter)
func NewTrustCenterFileFilter(opts ...TrustCenterFileFilterOption) *TrustCenterFileFilter { func NewCompliancePortalFileFilter(opts ...CompliancePortalFileFilterOption) *CompliancePortalFileFilter {
f := &TrustCenterFileFilter{} f := &CompliancePortalFileFilter{}
for _, opt := range opts { for _, opt := range opts {
opt(f) opt(f)
@@ -42,17 +42,17 @@ func NewTrustCenterFileFilter(opts ...TrustCenterFileFilterOption) *TrustCenterF
return f return f
} }
func WithTrustCenterFileVisibilities(visibilities ...TrustCenterVisibility) TrustCenterFileFilterOption { func WithCompliancePortalFileVisibilities(visibilities ...CompliancePortalVisibility) CompliancePortalFileFilterOption {
return func(f *TrustCenterFileFilter) { return func(f *CompliancePortalFileFilter) {
f.trustCenterVisibilities = visibilities f.compliancePortalVisibilities = visibilities
} }
} }
func (f *TrustCenterFileFilter) SQLArguments() pgx.NamedArgs { func (f *CompliancePortalFileFilter) SQLArguments() pgx.NamedArgs {
var visibilities []string var visibilities []string
if f.trustCenterVisibilities != nil { if f.compliancePortalVisibilities != nil {
visibilities = make([]string, len(f.trustCenterVisibilities)) visibilities = make([]string, len(f.compliancePortalVisibilities))
for i, v := range f.trustCenterVisibilities { for i, v := range f.compliancePortalVisibilities {
visibilities[i] = v.String() 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 return `CASE
WHEN @trust_center_visibilities::trust_center_visibility[] IS NOT NULL THEN WHEN @trust_center_visibilities::trust_center_visibility[] IS NOT NULL THEN
trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[]) trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])

View File

@@ -28,57 +28,54 @@ import (
) )
type ( type (
TrustCenterReferenceOrderField string CompliancePortalFileOrderField string
) )
const ( const (
TrustCenterReferenceOrderFieldRank TrustCenterReferenceOrderField = "RANK" CompliancePortalFileOrderFieldName CompliancePortalFileOrderField = "NAME"
TrustCenterReferenceOrderFieldName TrustCenterReferenceOrderField = "NAME" CompliancePortalFileOrderFieldCreatedAt CompliancePortalFileOrderField = "CREATED_AT"
TrustCenterReferenceOrderFieldCreatedAt TrustCenterReferenceOrderField = "CREATED_AT" CompliancePortalFileOrderFieldUpdatedAt CompliancePortalFileOrderField = "UPDATED_AT"
TrustCenterReferenceOrderFieldUpdatedAt TrustCenterReferenceOrderField = "UPDATED_AT"
) )
var ( var (
_ page.OrderField = TrustCenterReferenceOrderField("") _ page.OrderField = CompliancePortalFileOrderField("")
_ fmt.Stringer = TrustCenterReferenceOrderField("") _ fmt.Stringer = CompliancePortalFileOrderField("")
_ encoding.TextMarshaler = TrustCenterReferenceOrderField("") _ encoding.TextMarshaler = CompliancePortalFileOrderField("")
_ encoding.TextUnmarshaler = (*TrustCenterReferenceOrderField)(nil) _ encoding.TextUnmarshaler = (*CompliancePortalFileOrderField)(nil)
) )
func TrustCenterReferenceOrderFields() []TrustCenterReferenceOrderField { func CompliancePortalFileOrderFields() []CompliancePortalFileOrderField {
return []TrustCenterReferenceOrderField{ return []CompliancePortalFileOrderField{
TrustCenterReferenceOrderFieldRank, CompliancePortalFileOrderFieldName,
TrustCenterReferenceOrderFieldName, CompliancePortalFileOrderFieldCreatedAt,
TrustCenterReferenceOrderFieldCreatedAt, CompliancePortalFileOrderFieldUpdatedAt,
TrustCenterReferenceOrderFieldUpdatedAt,
} }
} }
func (v TrustCenterReferenceOrderField) IsValid() bool { func (v CompliancePortalFileOrderField) IsValid() bool {
switch v { switch v {
case case
TrustCenterReferenceOrderFieldRank, CompliancePortalFileOrderFieldName,
TrustCenterReferenceOrderFieldName, CompliancePortalFileOrderFieldCreatedAt,
TrustCenterReferenceOrderFieldCreatedAt, CompliancePortalFileOrderFieldUpdatedAt:
TrustCenterReferenceOrderFieldUpdatedAt:
return true return true
} }
return false return false
} }
func (v TrustCenterReferenceOrderField) String() string { func (v CompliancePortalFileOrderField) String() string {
return string(v) return string(v)
} }
func (v TrustCenterReferenceOrderField) MarshalText() ([]byte, error) { func (v CompliancePortalFileOrderField) MarshalText() ([]byte, error) {
return []byte(v.String()), nil return []byte(v.String()), nil
} }
func (v *TrustCenterReferenceOrderField) UnmarshalText(text []byte) error { func (v *CompliancePortalFileOrderField) UnmarshalText(text []byte) error {
val := TrustCenterReferenceOrderField(text) val := CompliancePortalFileOrderField(text)
if !val.IsValid() { if !val.IsValid() {
return fmt.Errorf("invalid TrustCenterReferenceOrderField value: %q", string(text)) return fmt.Errorf("invalid CompliancePortalFileOrderField value: %q", string(text))
} }
*v = val *v = val
@@ -86,15 +83,13 @@ func (v *TrustCenterReferenceOrderField) UnmarshalText(text []byte) error {
return nil return nil
} }
func (p TrustCenterReferenceOrderField) Column() string { func (p CompliancePortalFileOrderField) Column() string {
switch p { switch p {
case TrustCenterReferenceOrderFieldRank: case CompliancePortalFileOrderFieldName:
return "rank"
case TrustCenterReferenceOrderFieldName:
return "name" return "name"
case TrustCenterReferenceOrderFieldCreatedAt: case CompliancePortalFileOrderFieldCreatedAt:
return "created_at" return "created_at"
case TrustCenterReferenceOrderFieldUpdatedAt: case CompliancePortalFileOrderFieldUpdatedAt:
return "updated_at" return "updated_at"
default: default:
return string(p) return string(p)

View File

@@ -27,47 +27,47 @@ import (
"go.probo.inc/probo/pkg/page" "go.probo.inc/probo/pkg/page"
) )
type TrustCenterOrderField string type CompliancePortalOrderField string
const ( const (
TrustCenterOrderFieldCreatedAt TrustCenterOrderField = "CREATED_AT" CompliancePortalOrderFieldCreatedAt CompliancePortalOrderField = "CREATED_AT"
) )
var ( var (
_ page.OrderField = TrustCenterOrderField("") _ page.OrderField = CompliancePortalOrderField("")
_ fmt.Stringer = TrustCenterOrderField("") _ fmt.Stringer = CompliancePortalOrderField("")
_ encoding.TextMarshaler = TrustCenterOrderField("") _ encoding.TextMarshaler = CompliancePortalOrderField("")
_ encoding.TextUnmarshaler = (*TrustCenterOrderField)(nil) _ encoding.TextUnmarshaler = (*CompliancePortalOrderField)(nil)
) )
func TrustCenterOrderFields() []TrustCenterOrderField { func CompliancePortalOrderFields() []CompliancePortalOrderField {
return []TrustCenterOrderField{ return []CompliancePortalOrderField{
TrustCenterOrderFieldCreatedAt, CompliancePortalOrderFieldCreatedAt,
} }
} }
func (v TrustCenterOrderField) IsValid() bool { func (v CompliancePortalOrderField) IsValid() bool {
switch v { switch v {
case case
TrustCenterOrderFieldCreatedAt: CompliancePortalOrderFieldCreatedAt:
return true return true
} }
return false return false
} }
func (v TrustCenterOrderField) String() string { func (v CompliancePortalOrderField) String() string {
return string(v) return string(v)
} }
func (v TrustCenterOrderField) MarshalText() ([]byte, error) { func (v CompliancePortalOrderField) MarshalText() ([]byte, error) {
return []byte(v.String()), nil return []byte(v.String()), nil
} }
func (v *TrustCenterOrderField) UnmarshalText(text []byte) error { func (v *CompliancePortalOrderField) UnmarshalText(text []byte) error {
val := TrustCenterOrderField(text) val := CompliancePortalOrderField(text)
if !val.IsValid() { if !val.IsValid() {
return fmt.Errorf("invalid TrustCenterOrderField value: %q", string(text)) return fmt.Errorf("invalid CompliancePortalOrderField value: %q", string(text))
} }
*v = val *v = val
@@ -75,6 +75,6 @@ func (v *TrustCenterOrderField) UnmarshalText(text []byte) error {
return nil return nil
} }
func (p TrustCenterOrderField) Column() string { func (p CompliancePortalOrderField) Column() string {
return string(p) return string(p)
} }

View File

@@ -36,10 +36,10 @@ import (
) )
type ( type (
TrustCenterReference struct { CompliancePortalReference struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
TrustCenterID gid.GID `db:"trust_center_id"` CompliancePortalID gid.GID `db:"trust_center_id"`
Name string `db:"name"` Name string `db:"name"`
Description *string `db:"description"` Description *string `db:"description"`
WebsiteURL string `db:"website_url"` WebsiteURL string `db:"website_url"`
@@ -49,25 +49,25 @@ type (
UpdatedAt time.Time `db:"updated_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 { switch orderBy {
case TrustCenterReferenceOrderFieldRank: case CompliancePortalReferenceOrderFieldRank:
return page.NewCursorKey(t.ID, t.Rank) return page.NewCursorKey(t.ID, t.Rank)
case TrustCenterReferenceOrderFieldName: case CompliancePortalReferenceOrderFieldName:
return page.NewCursorKey(t.ID, t.Name) return page.NewCursorKey(t.ID, t.Name)
case TrustCenterReferenceOrderFieldCreatedAt: case CompliancePortalReferenceOrderFieldCreatedAt:
return page.NewCursorKey(t.ID, t.CreatedAt) return page.NewCursorKey(t.ID, t.CreatedAt)
case TrustCenterReferenceOrderFieldUpdatedAt: case CompliancePortalReferenceOrderFieldUpdatedAt:
return page.NewCursorKey(t.ID, t.UpdatedAt) return page.NewCursorKey(t.ID, t.UpdatedAt)
} }
panic(fmt.Sprintf("unsupported order by: %s", orderBy)) panic(fmt.Sprintf("unsupported order by: %s", orderBy))
} }
func (t *TrustCenterReference) AuthorizationAttributes( func (t *CompliancePortalReference) AuthorizationAttributes(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
resourceIDs []gid.GID, resourceIDs []gid.GID,
@@ -106,11 +106,11 @@ func (t *TrustCenterReference) AuthorizationAttributes(
return attrsByID, nil return attrsByID, nil
} }
func (t *TrustCenterReference) LoadByID( func (t *CompliancePortalReference) LoadByID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterReferenceID gid.GID, compliancePortalReferenceID gid.GID,
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -133,7 +133,7 @@ LIMIT 1;
` `
q = fmt.Sprintf(q, scope.SQLFragment()) 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()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
@@ -141,9 +141,9 @@ LIMIT 1;
return fmt.Errorf("cannot query trust_center_references: %w", err) 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 { 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 *t = reference
@@ -151,7 +151,7 @@ LIMIT 1;
return nil return nil
} }
func (t *TrustCenterReference) Insert( func (t *CompliancePortalReference) Insert(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -191,7 +191,7 @@ RETURNING rank;
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"id": t.ID, "id": t.ID,
"organization_id": t.OrganizationID, "organization_id": t.OrganizationID,
"trust_center_id": t.TrustCenterID, "trust_center_id": t.CompliancePortalID,
"name": t.Name, "name": t.Name,
"description": t.Description, "description": t.Description,
"website_url": t.WebsiteURL, "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 return nil
} }
func (t *TrustCenterReference) Update( func (t *CompliancePortalReference) Update(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -246,7 +246,7 @@ WHERE
result, err := conn.Exec(ctx, q, args) result, err := conn.Exec(ctx, q, args)
if err != nil { 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 { if result.RowsAffected() == 0 {
@@ -256,7 +256,7 @@ WHERE
return nil return nil
} }
func (t *TrustCenterReference) UpdateRank( func (t *CompliancePortalReference) UpdateRank(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -293,20 +293,20 @@ WHERE %s
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"id": t.ID, "id": t.ID,
"new_rank": t.Rank, "new_rank": t.Rank,
"trust_center_id": t.TrustCenterID, "trust_center_id": t.CompliancePortalID,
"updated_at": t.UpdatedAt, "updated_at": t.UpdatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (t *TrustCenterReference) Delete( func (t *CompliancePortalReference) Delete(
ctx context.Context, ctx context.Context,
conn pg.Tx, conn pg.Tx,
scope Scoper, scope Scoper,
@@ -326,18 +326,18 @@ WHERE
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { 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 return nil
} }
func (t *TrustCenterReferences) LoadByTrustCenterID( func (t *CompliancePortalReferences) LoadByCompliancePortalID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
cursor *page.Cursor[TrustCenterReferenceOrderField], cursor *page.Cursor[CompliancePortalReferenceOrderField],
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -361,7 +361,7 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) 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, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())
@@ -370,9 +370,9 @@ WHERE
return fmt.Errorf("cannot query trust_center_references: %w", err) 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 { 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 *t = references
@@ -380,11 +380,11 @@ WHERE
return nil return nil
} }
func (t *TrustCenterReferences) CountByTrustCenterID( func (t *CompliancePortalReferences) CountByCompliancePortalID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
) (int, error) { ) (int, error) {
q := ` q := `
SELECT SELECT
@@ -398,14 +398,14 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment()) 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()) maps.Copy(args, scope.SQLArguments())
var count int var count int
err := conn.QueryRow(ctx, q, args).Scan(&count) err := conn.QueryRow(ctx, q, args).Scan(&count)
if err != nil { 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 return count, nil

View File

@@ -0,0 +1,102 @@
// Copyright (c) 2025-2026 Probo Inc <hello@probo.com>.
//
// 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)
}
}

View File

@@ -25,52 +25,52 @@ import (
"fmt" "fmt"
) )
type TrustCenterVisibility string type CompliancePortalVisibility string
const ( const (
TrustCenterVisibilityNone TrustCenterVisibility = "NONE" CompliancePortalVisibilityNone CompliancePortalVisibility = "NONE"
TrustCenterVisibilityPrivate TrustCenterVisibility = "PRIVATE" CompliancePortalVisibilityPrivate CompliancePortalVisibility = "PRIVATE"
TrustCenterVisibilityPublic TrustCenterVisibility = "PUBLIC" CompliancePortalVisibilityPublic CompliancePortalVisibility = "PUBLIC"
) )
var ( var (
_ fmt.Stringer = TrustCenterVisibility("") _ fmt.Stringer = CompliancePortalVisibility("")
_ encoding.TextMarshaler = TrustCenterVisibility("") _ encoding.TextMarshaler = CompliancePortalVisibility("")
_ encoding.TextUnmarshaler = (*TrustCenterVisibility)(nil) _ encoding.TextUnmarshaler = (*CompliancePortalVisibility)(nil)
) )
func TrustCenterVisibilities() []TrustCenterVisibility { func CompliancePortalVisibilities() []CompliancePortalVisibility {
return []TrustCenterVisibility{ return []CompliancePortalVisibility{
TrustCenterVisibilityNone, CompliancePortalVisibilityNone,
TrustCenterVisibilityPrivate, CompliancePortalVisibilityPrivate,
TrustCenterVisibilityPublic, CompliancePortalVisibilityPublic,
} }
} }
func (v TrustCenterVisibility) IsValid() bool { func (v CompliancePortalVisibility) IsValid() bool {
switch v { switch v {
case case
TrustCenterVisibilityNone, CompliancePortalVisibilityNone,
TrustCenterVisibilityPrivate, CompliancePortalVisibilityPrivate,
TrustCenterVisibilityPublic: CompliancePortalVisibilityPublic:
return true return true
} }
return false return false
} }
func (v TrustCenterVisibility) String() string { func (v CompliancePortalVisibility) String() string {
return string(v) return string(v)
} }
func (v TrustCenterVisibility) MarshalText() ([]byte, error) { func (v CompliancePortalVisibility) MarshalText() ([]byte, error) {
return []byte(v.String()), nil return []byte(v.String()), nil
} }
func (v *TrustCenterVisibility) UnmarshalText(text []byte) error { func (v *CompliancePortalVisibility) UnmarshalText(text []byte) error {
val := TrustCenterVisibility(text) val := CompliancePortalVisibility(text)
if !val.IsValid() { if !val.IsValid() {
return fmt.Errorf("invalid TrustCenterVisibility value: %q", string(text)) return fmt.Errorf("invalid CompliancePortalVisibility value: %q", string(text))
} }
*v = val *v = val

View File

@@ -41,7 +41,7 @@ type (
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
CurrentPublishedMajor *int `db:"current_published_major"` CurrentPublishedMajor *int `db:"current_published_major"`
CurrentPublishedMinor *int `db:"current_published_minor"` CurrentPublishedMinor *int `db:"current_published_minor"`
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"` CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"`
WriteMode DocumentWriteMode `db:"write_mode"` WriteMode DocumentWriteMode `db:"write_mode"`
Status DocumentStatus `db:"status"` Status DocumentStatus `db:"status"`
ArchivedAt *time.Time `db:"archived_at"` ArchivedAt *time.Time `db:"archived_at"`
@@ -505,7 +505,7 @@ VALUES (
"current_published_major": p.CurrentPublishedMajor, "current_published_major": p.CurrentPublishedMajor,
"current_published_minor": p.CurrentPublishedMinor, "current_published_minor": p.CurrentPublishedMinor,
"write_mode": p.WriteMode, "write_mode": p.WriteMode,
"trust_center_visibility": p.TrustCenterVisibility, "trust_center_visibility": p.CompliancePortalVisibility,
"status": p.Status, "status": p.Status,
"archived_at": p.ArchivedAt, "archived_at": p.ArchivedAt,
"created_at": p.CreatedAt, "created_at": p.CreatedAt,
@@ -582,7 +582,7 @@ WHERE
"updated_at": time.Now(), "updated_at": time.Now(),
"current_published_major": p.CurrentPublishedMajor, "current_published_major": p.CurrentPublishedMajor,
"current_published_minor": p.CurrentPublishedMinor, "current_published_minor": p.CurrentPublishedMinor,
"trust_center_visibility": p.TrustCenterVisibility, "trust_center_visibility": p.CompliancePortalVisibility,
"status": p.Status, "status": p.Status,
"archived_at": p.ArchivedAt, "archived_at": p.ArchivedAt,
} }

View File

@@ -28,7 +28,7 @@ import (
type ( type (
DocumentFilter struct { DocumentFilter struct {
query *string query *string
trustCenterVisibilities []TrustCenterVisibility compliancePortalVisibilities []CompliancePortalVisibility
published *bool published *bool
employeeIdentityID *gid.GID employeeIdentityID *gid.GID
employeeFilterModes []EmployeeFilterMode employeeFilterModes []EmployeeFilterMode
@@ -45,13 +45,13 @@ func NewDocumentFilter(query *string) *DocumentFilter {
} }
} }
func NewDocumentTrustCenterFilter() *DocumentFilter { func NewDocumentCompliancePortalFilter() *DocumentFilter {
published := true published := true
return &DocumentFilter{ return &DocumentFilter{
trustCenterVisibilities: []TrustCenterVisibility{ compliancePortalVisibilities: []CompliancePortalVisibility{
TrustCenterVisibilityPrivate, CompliancePortalVisibilityPrivate,
TrustCenterVisibilityPublic, CompliancePortalVisibilityPublic,
}, },
published: &published, published: &published,
status: []DocumentStatus{DocumentStatusActive}, status: []DocumentStatus{DocumentStatusActive},
@@ -63,8 +63,8 @@ func (f *DocumentFilter) WithPublished(published *bool) *DocumentFilter {
return f return f
} }
func (f *DocumentFilter) WithTrustCenterVisibilities(visibilities ...TrustCenterVisibility) *DocumentFilter { func (f *DocumentFilter) WithCompliancePortalVisibilities(visibilities ...CompliancePortalVisibility) *DocumentFilter {
f.trustCenterVisibilities = visibilities f.compliancePortalVisibilities = visibilities
return f return f
} }
@@ -97,9 +97,9 @@ func (f *DocumentFilter) WithStatus(status []DocumentStatus) *DocumentFilter {
func (f *DocumentFilter) SQLArguments() pgx.NamedArgs { func (f *DocumentFilter) SQLArguments() pgx.NamedArgs {
var visibilities []string var visibilities []string
if f.trustCenterVisibilities != nil { if f.compliancePortalVisibilities != nil {
visibilities = make([]string, len(f.trustCenterVisibilities)) visibilities = make([]string, len(f.compliancePortalVisibilities))
for i, v := range f.trustCenterVisibilities { for i, v := range f.compliancePortalVisibilities {
visibilities[i] = v.String() visibilities[i] = v.String()
} }
} }

View File

@@ -51,8 +51,8 @@ const (
DatumEntityType uint16 = 19 DatumEntityType uint16 = 19
AuditEntityType uint16 = 20 AuditEntityType uint16 = 20
_ uint16 = 21 // ReportEntityType - removed _ uint16 = 21 // ReportEntityType - removed
TrustCenterEntityType uint16 = 22 CompliancePortalEntityType uint16 = 22
TrustCenterAccessEntityType uint16 = 23 CompliancePortalAccessEntityType uint16 = 23
ThirdPartyBusinessAssociateAgreementEntityType uint16 = 24 ThirdPartyBusinessAssociateAgreementEntityType uint16 = 24
FileEntityType uint16 = 25 FileEntityType uint16 = 25
ThirdPartyContactEntityType uint16 = 26 ThirdPartyContactEntityType uint16 = 26
@@ -64,13 +64,13 @@ const (
_ uint16 = 32 // ContinualImprovementEntityType - removed _ uint16 = 32 // ContinualImprovementEntityType - removed
ProcessingActivityEntityType uint16 = 33 ProcessingActivityEntityType uint16 = 33
ExportJobEntityType uint16 = 34 ExportJobEntityType uint16 = 34
TrustCenterReferenceEntityType uint16 = 35 CompliancePortalReferenceEntityType uint16 = 35
TrustCenterDocumentAccessEntityType uint16 = 36 CompliancePortalDocumentAccessEntityType uint16 = 36
CustomDomainEntityType uint16 = 37 CustomDomainEntityType uint16 = 37
InvitationEntityType uint16 = 38 InvitationEntityType uint16 = 38
MembershipEntityType uint16 = 39 MembershipEntityType uint16 = 39
SlackMessageEntityType uint16 = 40 SlackMessageEntityType uint16 = 40
TrustCenterFileEntityType uint16 = 41 CompliancePortalFileEntityType uint16 = 41
SAMLConfigurationEntityType uint16 = 42 SAMLConfigurationEntityType uint16 = 42
PersonalAPIKeyEntityType uint16 = 43 PersonalAPIKeyEntityType uint16 = 43
_ uint16 = 44 // PersonalAPIKeyMembershipEntityType - removed _ uint16 = 44 // PersonalAPIKeyMembershipEntityType - removed
@@ -180,10 +180,10 @@ func NewEntityFromID(id gid.GID) (any, bool) {
return &Datum{ID: id}, true return &Datum{ID: id}, true
case AuditEntityType: case AuditEntityType:
return &Audit{ID: id}, true return &Audit{ID: id}, true
case TrustCenterEntityType: case CompliancePortalEntityType:
return &TrustCenter{ID: id}, true return &CompliancePortal{ID: id}, true
case TrustCenterAccessEntityType: case CompliancePortalAccessEntityType:
return &TrustCenterAccess{ID: id}, true return &CompliancePortalAccess{ID: id}, true
case ThirdPartyBusinessAssociateAgreementEntityType: case ThirdPartyBusinessAssociateAgreementEntityType:
return &ThirdPartyBusinessAssociateAgreement{ID: id}, true return &ThirdPartyBusinessAssociateAgreement{ID: id}, true
case FileEntityType: case FileEntityType:
@@ -202,10 +202,10 @@ func NewEntityFromID(id gid.GID) (any, bool) {
return &ProcessingActivity{ID: id}, true return &ProcessingActivity{ID: id}, true
case ExportJobEntityType: case ExportJobEntityType:
return &ExportJob{ID: id}, true return &ExportJob{ID: id}, true
case TrustCenterReferenceEntityType: case CompliancePortalReferenceEntityType:
return &TrustCenterReference{ID: id}, true return &CompliancePortalReference{ID: id}, true
case TrustCenterDocumentAccessEntityType: case CompliancePortalDocumentAccessEntityType:
return &TrustCenterDocumentAccess{ID: id}, true return &CompliancePortalDocumentAccess{ID: id}, true
case CustomDomainEntityType: case CustomDomainEntityType:
return &CustomDomain{ID: id}, true return &CustomDomain{ID: id}, true
case InvitationEntityType: case InvitationEntityType:
@@ -214,8 +214,8 @@ func NewEntityFromID(id gid.GID) (any, bool) {
return &Membership{ID: id}, true return &Membership{ID: id}, true
case SlackMessageEntityType: case SlackMessageEntityType:
return &SlackMessage{ID: id}, true return &SlackMessage{ID: id}, true
case TrustCenterFileEntityType: case CompliancePortalFileEntityType:
return &TrustCenterFile{ID: id}, true return &CompliancePortalFile{ID: id}, true
case SAMLConfigurationEntityType: case SAMLConfigurationEntityType:
return &SAMLConfiguration{ID: id}, true return &SAMLConfiguration{ID: id}, true
case PersonalAPIKeyEntityType: case PersonalAPIKeyEntityType:

View File

@@ -30,7 +30,7 @@ import (
type ( type (
MembershipProfileFilter struct { MembershipProfileFilter struct {
withMembership *bool withMembership *bool
withTrustCenterAccess *bool withCompliancePortalAccess *bool
contractEnded *bool contractEnded *bool
currentDate time.Time currentDate time.Time
email *mail.Addr email *mail.Addr
@@ -53,8 +53,8 @@ func (f *MembershipProfileFilter) WithMembership() *MembershipProfileFilter {
return f return f
} }
func (f *MembershipProfileFilter) WithTrustCenterAccess() *MembershipProfileFilter { func (f *MembershipProfileFilter) WithCompliancePortalAccess() *MembershipProfileFilter {
f.withTrustCenterAccess = new(true) f.withCompliancePortalAccess = new(true)
return f return f
} }
@@ -101,7 +101,7 @@ func (f *MembershipProfileFilter) SQLArguments() pgx.StrictNamedArgs {
"filter_user_name": f.userName, "filter_user_name": f.userName,
"filter_external_id": f.externalID, "filter_external_id": f.externalID,
"with_membership": f.withMembership, "with_membership": f.withMembership,
"with_trust_center_access": f.withTrustCenterAccess, "with_trust_center_access": f.withCompliancePortalAccess,
"contract_ended": f.contractEnded, "contract_ended": f.contractEnded,
"current_date": f.currentDate, "current_date": f.currentDate,
"filter_state": f.state, "filter_state": f.state,

View File

@@ -28,7 +28,7 @@ import (
type SlackMessageType string type SlackMessageType string
const ( const (
SlackMessageTypeTrustCenterAccessRequest SlackMessageType = "TRUST_CENTER_ACCESS_REQUEST" SlackMessageTypeCompliancePortalAccessRequest SlackMessageType = "TRUST_CENTER_ACCESS_REQUEST"
SlackMessageTypeWelcome SlackMessageType = "WELCOME" SlackMessageTypeWelcome SlackMessageType = "WELCOME"
) )
@@ -40,7 +40,7 @@ var (
func SlackMessageTypes() []SlackMessageType { func SlackMessageTypes() []SlackMessageType {
return []SlackMessageType{ return []SlackMessageType{
SlackMessageTypeTrustCenterAccessRequest, SlackMessageTypeCompliancePortalAccessRequest,
SlackMessageTypeWelcome, SlackMessageTypeWelcome,
} }
} }
@@ -48,7 +48,7 @@ func SlackMessageTypes() []SlackMessageType {
func (v SlackMessageType) IsValid() bool { func (v SlackMessageType) IsValid() bool {
switch v { switch v {
case case
SlackMessageTypeTrustCenterAccessRequest, SlackMessageTypeCompliancePortalAccessRequest,
SlackMessageTypeWelcome: SlackMessageTypeWelcome:
return true return true
} }

View File

@@ -172,7 +172,7 @@ type (
TermsOfServiceURL *string `db:"terms_of_service_url"` TermsOfServiceURL *string `db:"terms_of_service_url"`
SecurityPageURL *string `db:"security_page_url"` SecurityPageURL *string `db:"security_page_url"`
TrustPageURL *string `db:"trust_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"` Level int `db:"level"`
VettingStatus *ThirdPartyVettingStatus `db:"vetting_status"` VettingStatus *ThirdPartyVettingStatus `db:"vetting_status"`
VettingWebsiteURL *string `db:"vetting_website_url"` VettingWebsiteURL *string `db:"vetting_website_url"`
@@ -716,7 +716,7 @@ VALUES (
"terms_of_service_url": v.TermsOfServiceURL, "terms_of_service_url": v.TermsOfServiceURL,
"security_page_url": v.SecurityPageURL, "security_page_url": v.SecurityPageURL,
"trust_page_url": v.TrustPageURL, "trust_page_url": v.TrustPageURL,
"show_on_trust_center": v.ShowOnTrustCenter, "show_on_trust_center": v.ShowOnCompliancePortal,
"level": v.Level, "level": v.Level,
"vetting_status": v.VettingStatus, "vetting_status": v.VettingStatus,
"vetting_website_url": v.VettingWebsiteURL, "vetting_website_url": v.VettingWebsiteURL,
@@ -786,7 +786,7 @@ WHERE
return count, nil return count, nil
} }
func (v *ThirdParties) LoadDistinctTrustCenterCategoriesByOrganizationID( func (v *ThirdParties) LoadDistinctCompliancePortalCategoriesByOrganizationID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
@@ -822,7 +822,7 @@ ORDER BY
return categories, nil return categories, nil
} }
func (v *ThirdParties) LoadDistinctTrustCenterCountriesByOrganizationID( func (v *ThirdParties) LoadDistinctCompliancePortalCountriesByOrganizationID(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope Scoper, scope Scoper,
@@ -996,7 +996,7 @@ WHERE %s
"trust_page_url": v.TrustPageURL, "trust_page_url": v.TrustPageURL,
"business_owner_profile_id": v.BusinessOwnerID, "business_owner_profile_id": v.BusinessOwnerID,
"security_owner_profile_id": v.SecurityOwnerID, "security_owner_profile_id": v.SecurityOwnerID,
"show_on_trust_center": v.ShowOnTrustCenter, "show_on_trust_center": v.ShowOnCompliancePortal,
"level": v.Level, "level": v.Level,
"vetting_status": v.VettingStatus, "vetting_status": v.VettingStatus,
"vetting_website_url": v.VettingWebsiteURL, "vetting_website_url": v.VettingWebsiteURL,

View File

@@ -26,7 +26,7 @@ import (
type ( type (
ThirdPartyFilter struct { ThirdPartyFilter struct {
showOnTrustCenter *bool showOnCompliancePortal *bool
level *int level *int
query *string query *string
category *ThirdPartyCategory category *ThirdPartyCategory
@@ -35,14 +35,14 @@ type (
) )
func NewThirdPartyFilter( func NewThirdPartyFilter(
showOnTrustCenter *bool, showOnCompliancePortal *bool,
level *int, level *int,
query *string, query *string,
category *ThirdPartyCategory, category *ThirdPartyCategory,
country *CountryCode, country *CountryCode,
) *ThirdPartyFilter { ) *ThirdPartyFilter {
return &ThirdPartyFilter{ return &ThirdPartyFilter{
showOnTrustCenter: showOnTrustCenter, showOnCompliancePortal: showOnCompliancePortal,
level: level, level: level,
query: query, query: query,
category: category, category: category,
@@ -59,8 +59,8 @@ func (f *ThirdPartyFilter) SQLArguments() pgx.StrictNamedArgs {
"filter_country": nil, "filter_country": nil,
} }
if f.showOnTrustCenter != nil { if f.showOnCompliancePortal != nil {
args["show_on_trust_center"] = *f.showOnTrustCenter args["show_on_trust_center"] = *f.showOnCompliancePortal
} }
if f.query != nil && *f.query != "" { if f.query != nil && *f.query != "" {

View File

@@ -1,82 +0,0 @@
// Copyright (c) 2025-2026 Probo Inc <hello@probo.com>.
//
// 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
}

View File

@@ -1,97 +0,0 @@
// Copyright (c) 2025-2026 Probo Inc <hello@probo.com>.
//
// 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)
}
}