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:
@@ -36,17 +36,17 @@ import (
|
||||
|
||||
type (
|
||||
Audit struct {
|
||||
ID gid.GID `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
FrameworkID gid.GID `db:"framework_id"`
|
||||
ReportFileID *gid.GID `db:"report_file_id"`
|
||||
ValidFrom *time.Time `db:"valid_from"`
|
||||
ValidUntil *time.Time `db:"valid_until"`
|
||||
State AuditState `db:"state"`
|
||||
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
FrameworkID gid.GID `db:"framework_id"`
|
||||
ReportFileID *gid.GID `db:"report_file_id"`
|
||||
ValidFrom *time.Time `db:"valid_from"`
|
||||
ValidUntil *time.Time `db:"valid_until"`
|
||||
State AuditState `db:"state"`
|
||||
CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
Audits []*Audit
|
||||
@@ -288,7 +288,7 @@ INSERT INTO audits (
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"trust_center_visibility": a.TrustCenterVisibility,
|
||||
"trust_center_visibility": a.CompliancePortalVisibility,
|
||||
"created_at": a.CreatedAt,
|
||||
"updated_at": a.UpdatedAt,
|
||||
}
|
||||
@@ -330,7 +330,7 @@ WHERE
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"trust_center_visibility": a.TrustCenterVisibility,
|
||||
"trust_center_visibility": a.CompliancePortalVisibility,
|
||||
"updated_at": a.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
type (
|
||||
AuditFilter struct {
|
||||
trustCenterVisibilities []TrustCenterVisibility
|
||||
compliancePortalVisibilities []CompliancePortalVisibility
|
||||
}
|
||||
)
|
||||
|
||||
@@ -34,26 +34,26 @@ func NewAuditFilter() *AuditFilter {
|
||||
return &AuditFilter{}
|
||||
}
|
||||
|
||||
func NewAuditTrustCenterFilter() *AuditFilter {
|
||||
func NewAuditCompliancePortalFilter() *AuditFilter {
|
||||
return &AuditFilter{
|
||||
trustCenterVisibilities: []TrustCenterVisibility{
|
||||
TrustCenterVisibilityPrivate,
|
||||
TrustCenterVisibilityPublic,
|
||||
compliancePortalVisibilities: []CompliancePortalVisibility{
|
||||
CompliancePortalVisibilityPrivate,
|
||||
CompliancePortalVisibilityPublic,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *AuditFilter) WithTrustCenterVisibilities(visibilities ...TrustCenterVisibility) *AuditFilter {
|
||||
f.trustCenterVisibilities = visibilities
|
||||
func (f *AuditFilter) WithCompliancePortalVisibilities(visibilities ...CompliancePortalVisibility) *AuditFilter {
|
||||
f.compliancePortalVisibilities = visibilities
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *AuditFilter) SQLArguments() pgx.NamedArgs {
|
||||
args := pgx.NamedArgs{}
|
||||
|
||||
if f.trustCenterVisibilities != nil {
|
||||
visibilities := make([]string, len(f.trustCenterVisibilities))
|
||||
for i, v := range f.trustCenterVisibilities {
|
||||
if f.compliancePortalVisibilities != nil {
|
||||
visibilities := make([]string, len(f.compliancePortalVisibilities))
|
||||
for i, v := range f.compliancePortalVisibilities {
|
||||
visibilities[i] = v.String()
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (f *AuditFilter) SQLArguments() pgx.NamedArgs {
|
||||
}
|
||||
|
||||
func (f *AuditFilter) SQLFragment() string {
|
||||
if f.trustCenterVisibilities != nil {
|
||||
if f.compliancePortalVisibilities != nil {
|
||||
return "trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])"
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ func ResourceTypeName(entityType uint16) string {
|
||||
return "Datum"
|
||||
case AuditEntityType:
|
||||
return "Audit"
|
||||
case TrustCenterEntityType:
|
||||
return "TrustCenter"
|
||||
case TrustCenterAccessEntityType:
|
||||
return "TrustCenterAccess"
|
||||
case CompliancePortalEntityType:
|
||||
return "CompliancePortal"
|
||||
case CompliancePortalAccessEntityType:
|
||||
return "CompliancePortalAccess"
|
||||
case ThirdPartyBusinessAssociateAgreementEntityType:
|
||||
return "ThirdPartyBusinessAssociateAgreement"
|
||||
case FileEntityType:
|
||||
@@ -79,18 +79,18 @@ func ResourceTypeName(entityType uint16) string {
|
||||
return "ThirdPartyService"
|
||||
case ProcessingActivityEntityType:
|
||||
return "ProcessingActivity"
|
||||
case TrustCenterReferenceEntityType:
|
||||
return "TrustCenterReference"
|
||||
case TrustCenterDocumentAccessEntityType:
|
||||
return "TrustCenterDocumentAccess"
|
||||
case CompliancePortalReferenceEntityType:
|
||||
return "CompliancePortalReference"
|
||||
case CompliancePortalDocumentAccessEntityType:
|
||||
return "CompliancePortalDocumentAccess"
|
||||
case CustomDomainEntityType:
|
||||
return "CustomDomain"
|
||||
case InvitationEntityType:
|
||||
return "Invitation"
|
||||
case MembershipEntityType:
|
||||
return "Membership"
|
||||
case TrustCenterFileEntityType:
|
||||
return "TrustCenterFile"
|
||||
case CompliancePortalFileEntityType:
|
||||
return "CompliancePortalFile"
|
||||
case DataProtectionImpactAssessmentEntityType:
|
||||
return "DataProtectionImpactAssessment"
|
||||
case TransferImpactAssessmentEntityType:
|
||||
|
||||
@@ -36,14 +36,14 @@ import (
|
||||
|
||||
type (
|
||||
ComplianceCustomLink struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TrustCenterID gid.GID `db:"trust_center_id"`
|
||||
Name string `db:"name"`
|
||||
URL string `db:"url"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
CompliancePortalID gid.GID `db:"trust_center_id"`
|
||||
Name string `db:"name"`
|
||||
URL string `db:"url"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
ComplianceCustomLinks []*ComplianceCustomLink
|
||||
@@ -182,7 +182,7 @@ RETURNING rank;
|
||||
"id": c.ID,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": c.OrganizationID,
|
||||
"trust_center_id": c.TrustCenterID,
|
||||
"trust_center_id": c.CompliancePortalID,
|
||||
"name": c.Name,
|
||||
"url": c.URL,
|
||||
"created_at": c.CreatedAt,
|
||||
@@ -267,7 +267,7 @@ WHERE %s
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": c.ID,
|
||||
"new_rank": c.Rank,
|
||||
"trust_center_id": c.TrustCenterID,
|
||||
"trust_center_id": c.CompliancePortalID,
|
||||
"updated_at": c.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
@@ -305,11 +305,11 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ComplianceCustomLinks) LoadByTrustCenterID(
|
||||
func (c *ComplianceCustomLinks) LoadByCompliancePortalID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
cursor *page.Cursor[ComplianceCustomLinkOrderField],
|
||||
) error {
|
||||
q := `
|
||||
@@ -331,7 +331,7 @@ WHERE
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.NamedArgs{"trust_center_id": trustCenterID}
|
||||
args := pgx.NamedArgs{"trust_center_id": compliancePortalID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
|
||||
@@ -37,15 +37,15 @@ import (
|
||||
|
||||
type (
|
||||
ComplianceFramework struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TrustCenterID gid.GID `db:"trust_center_id"`
|
||||
FrameworkID gid.GID `db:"framework_id"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
CompliancePortalID gid.GID `db:"trust_center_id"`
|
||||
FrameworkID gid.GID `db:"framework_id"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
|
||||
// Visibility is a non-db field used to return all frameworks for a trust center, including hidden ones.
|
||||
// Visibility is a non-db field used to return all frameworks for a compliance portal, including hidden ones.
|
||||
Visibility ComplianceFrameworkVisibility `db:"visibility"`
|
||||
}
|
||||
|
||||
@@ -149,11 +149,11 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ComplianceFramework) LoadByTrustCenterIDAndFrameworkID(
|
||||
func (c *ComplianceFramework) LoadByCompliancePortalIDAndFrameworkID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
frameworkID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
@@ -177,7 +177,7 @@ LIMIT 1;
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_id": trustCenterID,
|
||||
"trust_center_id": compliancePortalID,
|
||||
"framework_id": frameworkID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
@@ -235,7 +235,7 @@ RETURNING rank;
|
||||
"id": c.ID,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": c.OrganizationID,
|
||||
"trust_center_id": c.TrustCenterID,
|
||||
"trust_center_id": c.CompliancePortalID,
|
||||
"framework_id": c.FrameworkID,
|
||||
"created_at": c.CreatedAt,
|
||||
"updated_at": c.UpdatedAt,
|
||||
@@ -292,7 +292,7 @@ WHERE %s
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": c.ID,
|
||||
"new_rank": c.Rank,
|
||||
"trust_center_id": c.TrustCenterID,
|
||||
"trust_center_id": c.CompliancePortalID,
|
||||
"updated_at": c.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
@@ -330,11 +330,11 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ComplianceFrameworks) LoadByTrustCenterID(
|
||||
func (c *ComplianceFrameworks) LoadByCompliancePortalID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
cursor *page.Cursor[ComplianceFrameworkOrderField],
|
||||
) error {
|
||||
q := `
|
||||
@@ -356,7 +356,7 @@ WHERE
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.NamedArgs{"trust_center_id": trustCenterID}
|
||||
args := pgx.NamedArgs{"trust_center_id": compliancePortalID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
@@ -375,11 +375,11 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ComplianceFrameworks) LoadWithHiddenByTrustCenterID(
|
||||
func (c *ComplianceFrameworks) LoadWithHiddenByCompliancePortalID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
cursor *page.Cursor[ComplianceFrameworkOrderField],
|
||||
) error {
|
||||
q := `
|
||||
@@ -413,7 +413,7 @@ WHERE %s
|
||||
`
|
||||
q = fmt.Sprintf(q, cursor.SQLFragment())
|
||||
|
||||
args := pgx.NamedArgs{"trust_center_id": trustCenterID}
|
||||
args := pgx.NamedArgs{"trust_center_id": compliancePortalID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
TrustCenter struct {
|
||||
CompliancePortal struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TenantID gid.TenantID `db:"tenant_id"`
|
||||
@@ -58,19 +58,19 @@ type (
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
TrustCenters []*TrustCenter
|
||||
CompliancePortals []*CompliancePortal
|
||||
)
|
||||
|
||||
func (tc *TrustCenter) CursorKey(orderBy TrustCenterOrderField) page.CursorKey {
|
||||
func (tc *CompliancePortal) CursorKey(orderBy CompliancePortalOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case TrustCenterOrderFieldCreatedAt:
|
||||
case CompliancePortalOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(tc.ID, tc.CreatedAt)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||
}
|
||||
|
||||
func (tc *TrustCenter) AuthorizationAttributes(
|
||||
func (tc *CompliancePortal) AuthorizationAttributes(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
resourceIDs []gid.GID,
|
||||
@@ -109,11 +109,11 @@ func (tc *TrustCenter) AuthorizationAttributes(
|
||||
return attrsByID, nil
|
||||
}
|
||||
|
||||
func (tc *TrustCenter) LoadByID(
|
||||
func (tc *CompliancePortal) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -146,29 +146,29 @@ LIMIT 1;
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID}
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal: %w", err)
|
||||
}
|
||||
|
||||
trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter])
|
||||
compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal: %w", err)
|
||||
}
|
||||
|
||||
*tc = trustCenter
|
||||
*tc = compliancePortal
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tc *TrustCenter) LoadByMailingListID(
|
||||
func (tc *CompliancePortal) LoadByMailingListID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
@@ -210,24 +210,24 @@ LIMIT 1;
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center by mailing list id: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal by mailing list id: %w", err)
|
||||
}
|
||||
|
||||
trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter])
|
||||
compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal: %w", err)
|
||||
}
|
||||
|
||||
*tc = trustCenter
|
||||
*tc = compliancePortal
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tc *TrustCenter) LoadByOrganizationID(
|
||||
func (tc *CompliancePortal) LoadByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
@@ -269,25 +269,25 @@ LIMIT 1;
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal: %w", err)
|
||||
}
|
||||
|
||||
trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter])
|
||||
compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal: %w", err)
|
||||
}
|
||||
|
||||
*tc = trustCenter
|
||||
*tc = compliancePortal
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Tenant id scope is not applied because we want to access trust centers by slug across all tenants for public access.
|
||||
func (tc *TrustCenter) LoadBySlug(
|
||||
// Tenant id scope is not applied because we want to access compliance portals by slug across all tenants for public access.
|
||||
func (tc *CompliancePortal) LoadBySlug(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
slug string,
|
||||
@@ -324,19 +324,19 @@ LIMIT 1;
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal: %w", err)
|
||||
}
|
||||
|
||||
trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter])
|
||||
compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal: %w", err)
|
||||
}
|
||||
|
||||
*tc = trustCenter
|
||||
*tc = compliancePortal
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -346,7 +346,7 @@ LIMIT 1;
|
||||
// reverse SNI lookup: a served host resolves to a custom domain, which resolves
|
||||
// back to its page. Tenant scope is not applied because SNI resolution happens
|
||||
// across all tenants for public access.
|
||||
func (tc *TrustCenter) LoadByDomainID(
|
||||
func (tc *CompliancePortal) LoadByDomainID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
domainID gid.GID,
|
||||
@@ -384,24 +384,24 @@ LIMIT 1;
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center by domain id: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal by domain id: %w", err)
|
||||
}
|
||||
|
||||
trustCenter, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenter])
|
||||
compliancePortal, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortal])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal: %w", err)
|
||||
}
|
||||
|
||||
*tc = trustCenter
|
||||
*tc = compliancePortal
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tc *TrustCenter) Insert(
|
||||
func (tc *CompliancePortal) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -480,13 +480,13 @@ INSERT INTO trust_centers (
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot insert trust center: %w", err)
|
||||
return fmt.Errorf("cannot insert compliance portal: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tc *TrustCenter) Update(
|
||||
func (tc *CompliancePortal) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -536,7 +536,7 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update trust center: %w", err)
|
||||
return fmt.Errorf("cannot update compliance portal: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -36,30 +36,30 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
TrustCenterAccess struct {
|
||||
CompliancePortalAccess struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TenantID gid.TenantID `db:"tenant_id"`
|
||||
IdentityID gid.GID `db:"identity_id"`
|
||||
TrustCenterID gid.GID `db:"trust_center_id"`
|
||||
CompliancePortalID gid.GID `db:"trust_center_id"`
|
||||
ElectronicSignatureID *gid.GID `db:"electronic_signature_id"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
TrustCenterAccesses []*TrustCenterAccess
|
||||
CompliancePortalAccesses []*CompliancePortalAccess
|
||||
)
|
||||
|
||||
func (tca *TrustCenterAccess) CursorKey(orderBy TrustCenterAccessOrderField) page.CursorKey {
|
||||
func (tca *CompliancePortalAccess) CursorKey(orderBy CompliancePortalAccessOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case TrustCenterAccessOrderFieldCreatedAt:
|
||||
case CompliancePortalAccessOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(tca.ID, tca.CreatedAt)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||
}
|
||||
|
||||
func (tca *TrustCenterAccess) AuthorizationAttributes(
|
||||
func (tca *CompliancePortalAccess) AuthorizationAttributes(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
resourceIDs []gid.GID,
|
||||
@@ -98,7 +98,7 @@ func (tca *TrustCenterAccess) AuthorizationAttributes(
|
||||
return attrsByID, nil
|
||||
}
|
||||
|
||||
func (tca *TrustCenterAccess) LoadByID(
|
||||
func (tca *CompliancePortalAccess) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
@@ -129,16 +129,16 @@ LIMIT 1;
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center access: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal access: %w", err)
|
||||
}
|
||||
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterAccess])
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalAccess])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center access: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal access: %w", err)
|
||||
}
|
||||
|
||||
*tca = access
|
||||
@@ -146,11 +146,11 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tca *TrustCenterAccess) LoadByTrustCenterIDAndIdentityID(
|
||||
func (tca *CompliancePortalAccess) LoadByCompliancePortalIDAndIdentityID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
identityID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
@@ -175,23 +175,23 @@ LIMIT 1;
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_id": trustCenterID,
|
||||
"trust_center_id": compliancePortalID,
|
||||
"identity_id": identityID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center access: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal access: %w", err)
|
||||
}
|
||||
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterAccess])
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalAccess])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center access: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal access: %w", err)
|
||||
}
|
||||
|
||||
*tca = access
|
||||
@@ -199,7 +199,7 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tca *TrustCenterAccess) Insert(
|
||||
func (tca *CompliancePortalAccess) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -231,7 +231,7 @@ INSERT INTO trust_center_accesses (
|
||||
"tenant_id": tca.TenantID,
|
||||
"organization_id": tca.OrganizationID,
|
||||
"identity_id": tca.IdentityID,
|
||||
"trust_center_id": tca.TrustCenterID,
|
||||
"trust_center_id": tca.CompliancePortalID,
|
||||
"electronic_signature_id": tca.ElectronicSignatureID,
|
||||
"created_at": tca.CreatedAt,
|
||||
"updated_at": tca.UpdatedAt,
|
||||
@@ -245,13 +245,13 @@ INSERT INTO trust_center_accesses (
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot insert trust center access: %w", err)
|
||||
return fmt.Errorf("cannot insert compliance portal access: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tca *TrustCenterAccess) Update(
|
||||
func (tca *CompliancePortalAccess) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -276,13 +276,13 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update trust center access: %w", err)
|
||||
return fmt.Errorf("cannot update compliance portal access: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tca *TrustCenterAccess) Delete(
|
||||
func (tca *CompliancePortalAccess) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -303,18 +303,18 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete trust center access: %w", err)
|
||||
return fmt.Errorf("cannot delete compliance portal access: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcas *TrustCenterAccesses) LoadByTrustCenterID(
|
||||
func (tcas *CompliancePortalAccesses) LoadByCompliancePortalID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
cursor *page.Cursor[TrustCenterAccessOrderField],
|
||||
compliancePortalID gid.GID,
|
||||
cursor *page.Cursor[CompliancePortalAccessOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -337,19 +337,19 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_id": trustCenterID,
|
||||
"trust_center_id": compliancePortalID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center accesses: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal accesses: %w", err)
|
||||
}
|
||||
|
||||
accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterAccess])
|
||||
accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalAccess])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect trust center accesses: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal accesses: %w", err)
|
||||
}
|
||||
|
||||
*tcas = accesses
|
||||
@@ -27,47 +27,47 @@ import (
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type TrustCenterAccessOrderField string
|
||||
type CompliancePortalAccessOrderField string
|
||||
|
||||
const (
|
||||
TrustCenterAccessOrderFieldCreatedAt TrustCenterAccessOrderField = "CREATED_AT"
|
||||
CompliancePortalAccessOrderFieldCreatedAt CompliancePortalAccessOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = TrustCenterAccessOrderField("")
|
||||
_ fmt.Stringer = TrustCenterAccessOrderField("")
|
||||
_ encoding.TextMarshaler = TrustCenterAccessOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*TrustCenterAccessOrderField)(nil)
|
||||
_ page.OrderField = CompliancePortalAccessOrderField("")
|
||||
_ fmt.Stringer = CompliancePortalAccessOrderField("")
|
||||
_ encoding.TextMarshaler = CompliancePortalAccessOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CompliancePortalAccessOrderField)(nil)
|
||||
)
|
||||
|
||||
func TrustCenterAccessOrderFields() []TrustCenterAccessOrderField {
|
||||
return []TrustCenterAccessOrderField{
|
||||
TrustCenterAccessOrderFieldCreatedAt,
|
||||
func CompliancePortalAccessOrderFields() []CompliancePortalAccessOrderField {
|
||||
return []CompliancePortalAccessOrderField{
|
||||
CompliancePortalAccessOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v TrustCenterAccessOrderField) IsValid() bool {
|
||||
func (v CompliancePortalAccessOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
TrustCenterAccessOrderFieldCreatedAt:
|
||||
CompliancePortalAccessOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v TrustCenterAccessOrderField) String() string {
|
||||
func (v CompliancePortalAccessOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v TrustCenterAccessOrderField) MarshalText() ([]byte, error) {
|
||||
func (v CompliancePortalAccessOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *TrustCenterAccessOrderField) UnmarshalText(text []byte) error {
|
||||
val := TrustCenterAccessOrderField(text)
|
||||
func (v *CompliancePortalAccessOrderField) UnmarshalText(text []byte) error {
|
||||
val := CompliancePortalAccessOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid TrustCenterAccessOrderField value: %q", string(text))
|
||||
return fmt.Errorf("invalid CompliancePortalAccessOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
@@ -75,9 +75,9 @@ func (v *TrustCenterAccessOrderField) UnmarshalText(text []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcaof TrustCenterAccessOrderField) Column() string {
|
||||
func (tcaof CompliancePortalAccessOrderField) Column() string {
|
||||
switch tcaof {
|
||||
case TrustCenterAccessOrderFieldCreatedAt:
|
||||
case CompliancePortalAccessOrderFieldCreatedAt:
|
||||
return "created_at"
|
||||
}
|
||||
|
||||
@@ -25,49 +25,49 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TrustCenterAccessState string
|
||||
type CompliancePortalAccessState string
|
||||
|
||||
const (
|
||||
TrustCenterAccessStateActive TrustCenterAccessState = "ACTIVE"
|
||||
TrustCenterAccessStateInactive TrustCenterAccessState = "INACTIVE"
|
||||
CompliancePortalAccessStateActive CompliancePortalAccessState = "ACTIVE"
|
||||
CompliancePortalAccessStateInactive CompliancePortalAccessState = "INACTIVE"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = TrustCenterAccessState("")
|
||||
_ encoding.TextMarshaler = TrustCenterAccessState("")
|
||||
_ encoding.TextUnmarshaler = (*TrustCenterAccessState)(nil)
|
||||
_ fmt.Stringer = CompliancePortalAccessState("")
|
||||
_ encoding.TextMarshaler = CompliancePortalAccessState("")
|
||||
_ encoding.TextUnmarshaler = (*CompliancePortalAccessState)(nil)
|
||||
)
|
||||
|
||||
func TrustCenterAccessStates() []TrustCenterAccessState {
|
||||
return []TrustCenterAccessState{
|
||||
TrustCenterAccessStateActive,
|
||||
TrustCenterAccessStateInactive,
|
||||
func CompliancePortalAccessStates() []CompliancePortalAccessState {
|
||||
return []CompliancePortalAccessState{
|
||||
CompliancePortalAccessStateActive,
|
||||
CompliancePortalAccessStateInactive,
|
||||
}
|
||||
}
|
||||
|
||||
func (v TrustCenterAccessState) IsValid() bool {
|
||||
func (v CompliancePortalAccessState) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
TrustCenterAccessStateActive,
|
||||
TrustCenterAccessStateInactive:
|
||||
CompliancePortalAccessStateActive,
|
||||
CompliancePortalAccessStateInactive:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v TrustCenterAccessState) String() string {
|
||||
func (v CompliancePortalAccessState) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v TrustCenterAccessState) MarshalText() ([]byte, error) {
|
||||
func (v CompliancePortalAccessState) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *TrustCenterAccessState) UnmarshalText(text []byte) error {
|
||||
val := TrustCenterAccessState(text)
|
||||
func (v *CompliancePortalAccessState) UnmarshalText(text []byte) error {
|
||||
val := CompliancePortalAccessState(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid TrustCenterAccessState value: %q", string(text))
|
||||
return fmt.Errorf("invalid CompliancePortalAccessState value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
@@ -37,17 +37,17 @@ import (
|
||||
|
||||
type (
|
||||
CompliancePortalCommitment struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TrustCenterID gid.GID `db:"trust_center_id"`
|
||||
GroupID gid.GID `db:"group_id"`
|
||||
Icon CompliancePortalCommitmentIcon `db:"icon"`
|
||||
Eyebrow string `db:"eyebrow"`
|
||||
Title string `db:"title"`
|
||||
Description string `db:"description"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
CompliancePortalID gid.GID `db:"trust_center_id"`
|
||||
GroupID gid.GID `db:"group_id"`
|
||||
Icon CompliancePortalCommitmentIcon `db:"icon"`
|
||||
Eyebrow string `db:"eyebrow"`
|
||||
Title string `db:"title"`
|
||||
Description string `db:"description"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
CompliancePortalCommitments []*CompliancePortalCommitment
|
||||
@@ -193,7 +193,7 @@ RETURNING rank;
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"id": t.ID,
|
||||
"organization_id": t.OrganizationID,
|
||||
"trust_center_id": t.TrustCenterID,
|
||||
"trust_center_id": t.CompliancePortalID,
|
||||
"group_id": t.GroupID,
|
||||
"icon": t.Icon,
|
||||
"eyebrow": t.Eyebrow,
|
||||
|
||||
@@ -37,14 +37,14 @@ import (
|
||||
|
||||
type (
|
||||
CompliancePortalCommitmentGroup struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TrustCenterID gid.GID `db:"trust_center_id"`
|
||||
Title string `db:"title"`
|
||||
Description string `db:"description"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
CompliancePortalID gid.GID `db:"trust_center_id"`
|
||||
Title string `db:"title"`
|
||||
Description string `db:"description"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
CompliancePortalCommitmentGroups []*CompliancePortalCommitmentGroup
|
||||
@@ -181,7 +181,7 @@ RETURNING rank;
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"id": t.ID,
|
||||
"organization_id": t.OrganizationID,
|
||||
"trust_center_id": t.TrustCenterID,
|
||||
"trust_center_id": t.CompliancePortalID,
|
||||
"title": t.Title,
|
||||
"description": t.Description,
|
||||
"created_at": t.CreatedAt,
|
||||
@@ -276,7 +276,7 @@ WHERE %s
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": t.ID,
|
||||
"new_rank": t.Rank,
|
||||
"trust_center_id": t.TrustCenterID,
|
||||
"trust_center_id": t.CompliancePortalID,
|
||||
"updated_at": t.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
@@ -315,11 +315,11 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *CompliancePortalCommitmentGroups) LoadByTrustCenterID(
|
||||
func (t *CompliancePortalCommitmentGroups) LoadByCompliancePortalID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
cursor *page.Cursor[CompliancePortalCommitmentGroupOrderField],
|
||||
) error {
|
||||
q := `
|
||||
@@ -342,7 +342,7 @@ WHERE
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID}
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
@@ -361,11 +361,11 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *CompliancePortalCommitmentGroups) CountByTrustCenterID(
|
||||
func (t *CompliancePortalCommitmentGroups) CountByCompliancePortalID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -379,7 +379,7 @@ WHERE
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID}
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
var count int
|
||||
|
||||
@@ -36,31 +36,31 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
TrustCenterDocumentAccess struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TrustCenterAccessID gid.GID `db:"trust_center_access_id"`
|
||||
DocumentID *gid.GID `db:"document_id"`
|
||||
ReportFileID *gid.GID `db:"report_file_id"`
|
||||
TrustCenterFileID *gid.GID `db:"trust_center_file_id"`
|
||||
Status TrustCenterDocumentAccessStatus `db:"status"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
CompliancePortalDocumentAccess struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
CompliancePortalAccessID gid.GID `db:"trust_center_access_id"`
|
||||
DocumentID *gid.GID `db:"document_id"`
|
||||
ReportFileID *gid.GID `db:"report_file_id"`
|
||||
CompliancePortalFileID *gid.GID `db:"trust_center_file_id"`
|
||||
Status CompliancePortalDocumentAccessStatus `db:"status"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
TrustCenterDocumentAccesses []*TrustCenterDocumentAccess
|
||||
CompliancePortalDocumentAccesses []*CompliancePortalDocumentAccess
|
||||
)
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) CursorKey(orderBy TrustCenterDocumentAccessOrderField) page.CursorKey {
|
||||
func (tcda *CompliancePortalDocumentAccess) CursorKey(orderBy CompliancePortalDocumentAccessOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case TrustCenterDocumentAccessOrderFieldCreatedAt:
|
||||
case CompliancePortalDocumentAccessOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(tcda.ID, tcda.CreatedAt)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||
}
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) AuthorizationAttributes(
|
||||
func (tcda *CompliancePortalDocumentAccess) AuthorizationAttributes(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
resourceIDs []gid.GID,
|
||||
@@ -99,7 +99,7 @@ func (tcda *TrustCenterDocumentAccess) AuthorizationAttributes(
|
||||
return attrsByID, nil
|
||||
}
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) LoadByID(
|
||||
func (tcda *CompliancePortalDocumentAccess) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
@@ -131,16 +131,16 @@ LIMIT 1;
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterDocumentAccess])
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalDocumentAccess])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
*tcda = access
|
||||
@@ -148,11 +148,11 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndDocumentID(
|
||||
func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndDocumentID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
documentID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
@@ -178,23 +178,23 @@ LIMIT 1;
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"document_id": documentID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterDocumentAccess])
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalDocumentAccess])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
*tcda = access
|
||||
@@ -202,11 +202,11 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndReportFileID(
|
||||
func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndReportFileID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
reportFileID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
@@ -232,23 +232,23 @@ LIMIT 1;
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"report_file_id": reportFileID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterDocumentAccess])
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalDocumentAccess])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
*tcda = access
|
||||
@@ -256,7 +256,7 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) Insert(
|
||||
func (tcda *CompliancePortalDocumentAccess) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -291,10 +291,10 @@ INSERT INTO trust_center_document_accesses (
|
||||
"id": tcda.ID,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": tcda.OrganizationID,
|
||||
"trust_center_access_id": tcda.TrustCenterAccessID,
|
||||
"trust_center_access_id": tcda.CompliancePortalAccessID,
|
||||
"document_id": tcda.DocumentID,
|
||||
"report_file_id": tcda.ReportFileID,
|
||||
"trust_center_file_id": tcda.TrustCenterFileID,
|
||||
"trust_center_file_id": tcda.CompliancePortalFileID,
|
||||
"status": tcda.Status,
|
||||
"created_at": tcda.CreatedAt,
|
||||
"updated_at": tcda.UpdatedAt,
|
||||
@@ -313,13 +313,13 @@ INSERT INTO trust_center_document_accesses (
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot insert trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot insert compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) Update(
|
||||
func (tcda *CompliancePortalDocumentAccess) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -344,13 +344,13 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot update compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) Delete(
|
||||
func (tcda *CompliancePortalDocumentAccess) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -371,17 +371,17 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot delete compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcdas *TrustCenterDocumentAccesses) CountByTrustCenterAccessID(
|
||||
func (tcdas *CompliancePortalDocumentAccesses) CountByCompliancePortalAccessID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -396,7 +396,7 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -410,11 +410,11 @@ WHERE
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (tcdas *TrustCenterDocumentAccesses) CountPendingRequestByTrustCenterAccessID(
|
||||
func (tcdas *CompliancePortalDocumentAccesses) CountPendingRequestByCompliancePortalAccessID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -430,7 +430,7 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -444,11 +444,11 @@ WHERE
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (tcdas *TrustCenterDocumentAccesses) CountActiveByTrustCenterAccessID(
|
||||
func (tcdas *CompliancePortalDocumentAccesses) CountActiveByCompliancePortalAccessID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -464,7 +464,7 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -478,12 +478,12 @@ WHERE
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (tcdas *TrustCenterDocumentAccesses) LoadAvailableByTrustCenterAccessID(
|
||||
func (tcdas *CompliancePortalDocumentAccesses) LoadAvailableByCompliancePortalAccessID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
cursor *page.Cursor[TrustCenterDocumentAccessOrderField],
|
||||
compliancePortalAccessID gid.GID,
|
||||
cursor *page.Cursor[CompliancePortalDocumentAccessOrderField],
|
||||
) error {
|
||||
q := `
|
||||
WITH organization AS (
|
||||
@@ -581,19 +581,19 @@ WHERE %s
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center document accesses: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal document accesses: %w", err)
|
||||
}
|
||||
|
||||
accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterDocumentAccess])
|
||||
accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalDocumentAccess])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect trust center document accesses: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal document accesses: %w", err)
|
||||
}
|
||||
|
||||
*tcdas = accesses
|
||||
@@ -601,12 +601,12 @@ WHERE %s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcdas *TrustCenterDocumentAccesses) LoadByTrustCenterAccessID(
|
||||
func (tcdas *CompliancePortalDocumentAccesses) LoadByCompliancePortalAccessID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
cursor *page.Cursor[TrustCenterDocumentAccessOrderField],
|
||||
compliancePortalAccessID gid.GID,
|
||||
cursor *page.Cursor[CompliancePortalDocumentAccessOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -630,19 +630,19 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center document accesses: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal document accesses: %w", err)
|
||||
}
|
||||
|
||||
accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterDocumentAccess])
|
||||
accesses, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalDocumentAccess])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect trust center document accesses: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal document accesses: %w", err)
|
||||
}
|
||||
|
||||
*tcdas = accesses
|
||||
@@ -654,7 +654,7 @@ func GrantByDocumentIDs(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
documentIDs []gid.GID,
|
||||
updatedAt time.Time,
|
||||
) error {
|
||||
@@ -670,7 +670,7 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"document_ids": documentIDs,
|
||||
"updated_at": updatedAt,
|
||||
}
|
||||
@@ -678,7 +678,7 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot grant trust center document accesses by document IDs: %w", err)
|
||||
return fmt.Errorf("cannot grant compliance portal document accesses by document IDs: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -688,7 +688,7 @@ func RejectOrRevokeByDocumentIDs(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
documentIDs []gid.GID,
|
||||
updatedAt time.Time,
|
||||
) error {
|
||||
@@ -709,7 +709,7 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"document_ids": documentIDs,
|
||||
"updated_at": updatedAt,
|
||||
}
|
||||
@@ -717,7 +717,7 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot reject trust center document accesses by document IDs: %w", err)
|
||||
return fmt.Errorf("cannot reject compliance portal document accesses by document IDs: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -727,7 +727,7 @@ func GrantByReportFileIDs(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
reportFileIDs []gid.GID,
|
||||
updatedAt time.Time,
|
||||
) error {
|
||||
@@ -743,7 +743,7 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"report_file_ids": reportFileIDs,
|
||||
"updated_at": updatedAt,
|
||||
}
|
||||
@@ -751,7 +751,7 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot grant trust center document accesses by report file IDs: %w", err)
|
||||
return fmt.Errorf("cannot grant compliance portal document accesses by report file IDs: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -761,7 +761,7 @@ func RejectOrRevokeByReportFileIDs(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
reportFileIDs []gid.GID,
|
||||
updatedAt time.Time,
|
||||
) error {
|
||||
@@ -782,7 +782,7 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"report_file_ids": reportFileIDs,
|
||||
"updated_at": updatedAt,
|
||||
}
|
||||
@@ -790,24 +790,24 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot reject trust center document accesses by report file IDs: %w", err)
|
||||
return fmt.Errorf("cannot reject compliance portal document accesses by report file IDs: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type MergeTrustCenterDocumentAccessesData struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Status TrustCenterDocumentAccessStatus `json:"status"`
|
||||
type MergeCompliancePortalDocumentAccessesData struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Status CompliancePortalDocumentAccessStatus `json:"status"`
|
||||
}
|
||||
|
||||
func (tcdas TrustCenterDocumentAccesses) MergeDocumentAccesses(
|
||||
func (tcdas CompliancePortalDocumentAccesses) MergeDocumentAccesses(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
trustCenterAccessID gid.GID,
|
||||
data []MergeTrustCenterDocumentAccessesData,
|
||||
compliancePortalAccessID gid.GID,
|
||||
data []MergeCompliancePortalDocumentAccessesData,
|
||||
) error {
|
||||
q := `
|
||||
WITH data AS (
|
||||
@@ -859,9 +859,9 @@ WHEN NOT MATCHED
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType,
|
||||
"trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"organization_id": organizationID,
|
||||
"now": time.Now(),
|
||||
"data": data,
|
||||
@@ -874,14 +874,14 @@ WHEN NOT MATCHED
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcdas TrustCenterDocumentAccesses) BulkInsertDocumentAccesses(
|
||||
func (tcdas CompliancePortalDocumentAccesses) BulkInsertDocumentAccesses(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
organizationID gid.GID,
|
||||
documentIDs []gid.GID,
|
||||
status TrustCenterDocumentAccessStatus,
|
||||
status CompliancePortalDocumentAccessStatus,
|
||||
createdAt time.Time,
|
||||
) error {
|
||||
if len(documentIDs) == 0 {
|
||||
@@ -921,28 +921,28 @@ ON CONFLICT DO NOTHING
|
||||
args := pgx.StrictNamedArgs{
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": organizationID,
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"document_ids": documentIDs,
|
||||
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType,
|
||||
"trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
|
||||
"status": status,
|
||||
"created_at": createdAt,
|
||||
"updated_at": createdAt,
|
||||
}
|
||||
|
||||
if _, err := conn.Exec(ctx, q, args); err != nil {
|
||||
return fmt.Errorf("cannot bulk insert trust center document accesses: %w", err)
|
||||
return fmt.Errorf("cannot bulk insert compliance portal document accesses: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcdas TrustCenterDocumentAccesses) MergeReportFileAccesses(
|
||||
func (tcdas CompliancePortalDocumentAccesses) MergeReportFileAccesses(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
trustCenterAccessID gid.GID,
|
||||
data []MergeTrustCenterDocumentAccessesData,
|
||||
compliancePortalAccessID gid.GID,
|
||||
data []MergeCompliancePortalDocumentAccessesData,
|
||||
) error {
|
||||
q := `
|
||||
WITH data AS (
|
||||
@@ -994,9 +994,9 @@ WHEN NOT MATCHED
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType,
|
||||
"trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"organization_id": organizationID,
|
||||
"now": time.Now(),
|
||||
"data": data,
|
||||
@@ -1009,14 +1009,14 @@ WHEN NOT MATCHED
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcdas TrustCenterDocumentAccesses) BulkInsertReportFileAccesses(
|
||||
func (tcdas CompliancePortalDocumentAccesses) BulkInsertReportFileAccesses(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
organizationID gid.GID,
|
||||
reportFileIDs []gid.GID,
|
||||
status TrustCenterDocumentAccessStatus,
|
||||
status CompliancePortalDocumentAccessStatus,
|
||||
createdAt time.Time,
|
||||
) error {
|
||||
if len(reportFileIDs) == 0 {
|
||||
@@ -1056,8 +1056,8 @@ ON CONFLICT DO NOTHING
|
||||
args := pgx.StrictNamedArgs{
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": organizationID,
|
||||
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType,
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"report_file_ids": reportFileIDs,
|
||||
"status": status,
|
||||
"created_at": createdAt,
|
||||
@@ -1065,18 +1065,18 @@ ON CONFLICT DO NOTHING
|
||||
}
|
||||
|
||||
if _, err := conn.Exec(ctx, q, args); err != nil {
|
||||
return fmt.Errorf("cannot bulk insert trust center report file accesses: %w", err)
|
||||
return fmt.Errorf("cannot bulk insert compliance portal report file accesses: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcda *TrustCenterDocumentAccess) LoadByTrustCenterAccessIDAndTrustCenterFileID(
|
||||
func (tcda *CompliancePortalDocumentAccess) LoadByCompliancePortalAccessIDAndCompliancePortalFileID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -1101,23 +1101,23 @@ LIMIT 1;
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_file_id": trustCenterFileID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"trust_center_file_id": compliancePortalFileID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot query compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterDocumentAccess])
|
||||
access, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalDocumentAccess])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect trust center document access: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal document access: %w", err)
|
||||
}
|
||||
|
||||
*tcda = access
|
||||
@@ -1125,12 +1125,12 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func GrantByTrustCenterFileIDs(
|
||||
func GrantByCompliancePortalFileIDs(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
trustCenterFileIDs []gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
compliancePortalFileIDs []gid.GID,
|
||||
updatedAt time.Time,
|
||||
) error {
|
||||
q := `
|
||||
@@ -1145,26 +1145,26 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_file_ids": trustCenterFileIDs,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"trust_center_file_ids": compliancePortalFileIDs,
|
||||
"updated_at": updatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot grant trust center document accesses by trust center file IDs: %w", err)
|
||||
return fmt.Errorf("cannot grant compliance portal document accesses by compliance portal file IDs: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func RejectOrRevokeByTrustCenterFileIDs(
|
||||
func RejectOrRevokeByCompliancePortalFileIDs(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
trustCenterFileIDs []gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
compliancePortalFileIDs []gid.GID,
|
||||
updatedAt time.Time,
|
||||
) error {
|
||||
q := `
|
||||
@@ -1184,27 +1184,27 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_file_ids": trustCenterFileIDs,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"trust_center_file_ids": compliancePortalFileIDs,
|
||||
"updated_at": updatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot reject trust center document accesses by trust center file IDs: %w", err)
|
||||
return fmt.Errorf("cannot reject compliance portal document accesses by compliance portal file IDs: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcdas TrustCenterDocumentAccesses) MergeTrustCenterFileAccesses(
|
||||
func (tcdas CompliancePortalDocumentAccesses) MergeCompliancePortalFileAccesses(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
trustCenterAccessID gid.GID,
|
||||
data []MergeTrustCenterDocumentAccessesData,
|
||||
compliancePortalAccessID gid.GID,
|
||||
data []MergeCompliancePortalDocumentAccessesData,
|
||||
) error {
|
||||
q := `
|
||||
WITH data AS (
|
||||
@@ -1256,9 +1256,9 @@ WHEN NOT MATCHED
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType,
|
||||
"trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"organization_id": organizationID,
|
||||
"now": time.Now(),
|
||||
"data": data,
|
||||
@@ -1271,14 +1271,14 @@ WHEN NOT MATCHED
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcdas TrustCenterDocumentAccesses) BulkInsertTrustCenterFileAccesses(
|
||||
func (tcdas CompliancePortalDocumentAccesses) BulkInsertCompliancePortalFileAccesses(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
organizationID gid.GID,
|
||||
trustCenterFileIDs []gid.GID,
|
||||
status TrustCenterDocumentAccessStatus,
|
||||
compliancePortalFileIDs []gid.GID,
|
||||
status CompliancePortalDocumentAccessStatus,
|
||||
createdAt time.Time,
|
||||
) error {
|
||||
q := `
|
||||
@@ -1314,16 +1314,16 @@ ON CONFLICT DO NOTHING
|
||||
args := pgx.StrictNamedArgs{
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": organizationID,
|
||||
"trust_center_document_access_entity_type": TrustCenterDocumentAccessEntityType,
|
||||
"trust_center_access_id": trustCenterAccessID,
|
||||
"trust_center_file_ids": trustCenterFileIDs,
|
||||
"trust_center_document_access_entity_type": CompliancePortalDocumentAccessEntityType,
|
||||
"trust_center_access_id": compliancePortalAccessID,
|
||||
"trust_center_file_ids": compliancePortalFileIDs,
|
||||
"status": status,
|
||||
"created_at": createdAt,
|
||||
"updated_at": createdAt,
|
||||
}
|
||||
|
||||
if _, err := conn.Exec(ctx, q, args); err != nil {
|
||||
return fmt.Errorf("cannot bulk insert trust center file accesses: %w", err)
|
||||
return fmt.Errorf("cannot bulk insert compliance portal file accesses: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -27,47 +27,47 @@ import (
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type TrustCenterDocumentAccessOrderField string
|
||||
type CompliancePortalDocumentAccessOrderField string
|
||||
|
||||
const (
|
||||
TrustCenterDocumentAccessOrderFieldCreatedAt TrustCenterDocumentAccessOrderField = "CREATED_AT"
|
||||
CompliancePortalDocumentAccessOrderFieldCreatedAt CompliancePortalDocumentAccessOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = TrustCenterDocumentAccessOrderField("")
|
||||
_ fmt.Stringer = TrustCenterDocumentAccessOrderField("")
|
||||
_ encoding.TextMarshaler = TrustCenterDocumentAccessOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*TrustCenterDocumentAccessOrderField)(nil)
|
||||
_ page.OrderField = CompliancePortalDocumentAccessOrderField("")
|
||||
_ fmt.Stringer = CompliancePortalDocumentAccessOrderField("")
|
||||
_ encoding.TextMarshaler = CompliancePortalDocumentAccessOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CompliancePortalDocumentAccessOrderField)(nil)
|
||||
)
|
||||
|
||||
func TrustCenterDocumentAccessOrderFields() []TrustCenterDocumentAccessOrderField {
|
||||
return []TrustCenterDocumentAccessOrderField{
|
||||
TrustCenterDocumentAccessOrderFieldCreatedAt,
|
||||
func CompliancePortalDocumentAccessOrderFields() []CompliancePortalDocumentAccessOrderField {
|
||||
return []CompliancePortalDocumentAccessOrderField{
|
||||
CompliancePortalDocumentAccessOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v TrustCenterDocumentAccessOrderField) IsValid() bool {
|
||||
func (v CompliancePortalDocumentAccessOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
TrustCenterDocumentAccessOrderFieldCreatedAt:
|
||||
CompliancePortalDocumentAccessOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v TrustCenterDocumentAccessOrderField) String() string {
|
||||
func (v CompliancePortalDocumentAccessOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v TrustCenterDocumentAccessOrderField) MarshalText() ([]byte, error) {
|
||||
func (v CompliancePortalDocumentAccessOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *TrustCenterDocumentAccessOrderField) UnmarshalText(text []byte) error {
|
||||
val := TrustCenterDocumentAccessOrderField(text)
|
||||
func (v *CompliancePortalDocumentAccessOrderField) UnmarshalText(text []byte) error {
|
||||
val := CompliancePortalDocumentAccessOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid TrustCenterDocumentAccessOrderField value: %q", string(text))
|
||||
return fmt.Errorf("invalid CompliancePortalDocumentAccessOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
@@ -75,6 +75,6 @@ func (v *TrustCenterDocumentAccessOrderField) UnmarshalText(text []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcdaof TrustCenterDocumentAccessOrderField) Column() string {
|
||||
func (tcdaof CompliancePortalDocumentAccessOrderField) Column() string {
|
||||
return string(tcdaof)
|
||||
}
|
||||
82
pkg/coredata/compliance_portal_document_access_status.go
Normal file
82
pkg/coredata/compliance_portal_document_access_status.go
Normal 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
|
||||
}
|
||||
@@ -34,34 +34,34 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
TrustCenterFile struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
Name string `db:"name"`
|
||||
Category string `db:"category"`
|
||||
FileID gid.GID `db:"file_id"`
|
||||
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
CompliancePortalFile struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
Name string `db:"name"`
|
||||
Category string `db:"category"`
|
||||
FileID gid.GID `db:"file_id"`
|
||||
CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
TrustCenterFiles []*TrustCenterFile
|
||||
CompliancePortalFiles []*CompliancePortalFile
|
||||
)
|
||||
|
||||
func (t TrustCenterFile) CursorKey(orderBy TrustCenterFileOrderField) page.CursorKey {
|
||||
func (t CompliancePortalFile) CursorKey(orderBy CompliancePortalFileOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case TrustCenterFileOrderFieldName:
|
||||
case CompliancePortalFileOrderFieldName:
|
||||
return page.NewCursorKey(t.ID, t.Name)
|
||||
case TrustCenterFileOrderFieldCreatedAt:
|
||||
case CompliancePortalFileOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(t.ID, t.CreatedAt)
|
||||
case TrustCenterFileOrderFieldUpdatedAt:
|
||||
case CompliancePortalFileOrderFieldUpdatedAt:
|
||||
return page.NewCursorKey(t.ID, t.UpdatedAt)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||
}
|
||||
|
||||
func (t *TrustCenterFile) AuthorizationAttributes(
|
||||
func (t *CompliancePortalFile) AuthorizationAttributes(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
resourceIDs []gid.GID,
|
||||
@@ -100,11 +100,11 @@ func (t *TrustCenterFile) AuthorizationAttributes(
|
||||
return attrsByID, nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterFile) LoadByID(
|
||||
func (t *CompliancePortalFile) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -125,7 +125,7 @@ LIMIT 1;
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"trust_center_file_id": trustCenterFileID}
|
||||
args := pgx.StrictNamedArgs{"trust_center_file_id": compliancePortalFileID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
@@ -133,9 +133,9 @@ LIMIT 1;
|
||||
return fmt.Errorf("cannot query trust_center_files: %w", err)
|
||||
}
|
||||
|
||||
file, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterFile])
|
||||
file, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalFile])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect trust center file: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal file: %w", err)
|
||||
}
|
||||
|
||||
*t = file
|
||||
@@ -143,11 +143,11 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *TrustCenterFiles) LoadByIDs(
|
||||
func (f *CompliancePortalFiles) LoadByIDs(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterFileIDs []gid.GID,
|
||||
compliancePortalFileIDs []gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -168,7 +168,7 @@ WHERE
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"ids": trustCenterFileIDs}
|
||||
args := pgx.StrictNamedArgs{"ids": compliancePortalFileIDs}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
@@ -177,21 +177,21 @@ WHERE
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterFile])
|
||||
files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalFile])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect file: %w", err)
|
||||
}
|
||||
|
||||
*f = files
|
||||
|
||||
if len(files) != len(gid.NewSet(trustCenterFileIDs...)) {
|
||||
if len(files) != len(gid.NewSet(compliancePortalFileIDs...)) {
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t TrustCenterFile) Insert(
|
||||
func (t CompliancePortalFile) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -229,20 +229,20 @@ VALUES (
|
||||
"name": t.Name,
|
||||
"category": t.Category,
|
||||
"file_id": t.FileID,
|
||||
"trust_center_visibility": t.TrustCenterVisibility,
|
||||
"trust_center_visibility": t.CompliancePortalVisibility,
|
||||
"created_at": t.CreatedAt,
|
||||
"updated_at": t.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert trust center file: %w", err)
|
||||
return fmt.Errorf("cannot insert compliance portal file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterFile) Update(
|
||||
func (t *CompliancePortalFile) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -274,19 +274,19 @@ RETURNING
|
||||
"id": t.ID,
|
||||
"name": t.Name,
|
||||
"category": t.Category,
|
||||
"trust_center_visibility": t.TrustCenterVisibility,
|
||||
"trust_center_visibility": t.CompliancePortalVisibility,
|
||||
"updated_at": t.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update trust center file: %w", err)
|
||||
return fmt.Errorf("cannot update compliance portal file: %w", err)
|
||||
}
|
||||
|
||||
file, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterFile])
|
||||
file, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalFile])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect updated trust center file: %w", err)
|
||||
return fmt.Errorf("cannot collect updated compliance portal file: %w", err)
|
||||
}
|
||||
|
||||
*t = file
|
||||
@@ -294,7 +294,7 @@ RETURNING
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterFile) Delete(
|
||||
func (t *CompliancePortalFile) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -314,19 +314,19 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete trust center file: %w", err)
|
||||
return fmt.Errorf("cannot delete compliance portal file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterFiles) LoadByOrganizationID(
|
||||
func (t *CompliancePortalFiles) LoadByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[TrustCenterFileOrderField],
|
||||
filter *TrustCenterFileFilter,
|
||||
cursor *page.Cursor[CompliancePortalFileOrderField],
|
||||
filter *CompliancePortalFileFilter,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -359,9 +359,9 @@ WHERE
|
||||
return fmt.Errorf("cannot query trust_center_files: %w", err)
|
||||
}
|
||||
|
||||
files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterFile])
|
||||
files, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalFile])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect trust center files: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal files: %w", err)
|
||||
}
|
||||
|
||||
*t = files
|
||||
@@ -369,7 +369,7 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterFiles) CountByOrganizationID(
|
||||
func (t *CompliancePortalFiles) CountByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
@@ -394,7 +394,7 @@ WHERE
|
||||
|
||||
err := conn.QueryRow(ctx, q, args).Scan(&count)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count trust center files: %w", err)
|
||||
return 0, fmt.Errorf("cannot count compliance portal files: %w", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
@@ -25,15 +25,15 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
TrustCenterFileFilter struct {
|
||||
trustCenterVisibilities []TrustCenterVisibility
|
||||
CompliancePortalFileFilter struct {
|
||||
compliancePortalVisibilities []CompliancePortalVisibility
|
||||
}
|
||||
)
|
||||
|
||||
type TrustCenterFileFilterOption func(f *TrustCenterFileFilter)
|
||||
type CompliancePortalFileFilterOption func(f *CompliancePortalFileFilter)
|
||||
|
||||
func NewTrustCenterFileFilter(opts ...TrustCenterFileFilterOption) *TrustCenterFileFilter {
|
||||
f := &TrustCenterFileFilter{}
|
||||
func NewCompliancePortalFileFilter(opts ...CompliancePortalFileFilterOption) *CompliancePortalFileFilter {
|
||||
f := &CompliancePortalFileFilter{}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(f)
|
||||
@@ -42,17 +42,17 @@ func NewTrustCenterFileFilter(opts ...TrustCenterFileFilterOption) *TrustCenterF
|
||||
return f
|
||||
}
|
||||
|
||||
func WithTrustCenterFileVisibilities(visibilities ...TrustCenterVisibility) TrustCenterFileFilterOption {
|
||||
return func(f *TrustCenterFileFilter) {
|
||||
f.trustCenterVisibilities = visibilities
|
||||
func WithCompliancePortalFileVisibilities(visibilities ...CompliancePortalVisibility) CompliancePortalFileFilterOption {
|
||||
return func(f *CompliancePortalFileFilter) {
|
||||
f.compliancePortalVisibilities = visibilities
|
||||
}
|
||||
}
|
||||
|
||||
func (f *TrustCenterFileFilter) SQLArguments() pgx.NamedArgs {
|
||||
func (f *CompliancePortalFileFilter) SQLArguments() pgx.NamedArgs {
|
||||
var visibilities []string
|
||||
if f.trustCenterVisibilities != nil {
|
||||
visibilities = make([]string, len(f.trustCenterVisibilities))
|
||||
for i, v := range f.trustCenterVisibilities {
|
||||
if f.compliancePortalVisibilities != nil {
|
||||
visibilities = make([]string, len(f.compliancePortalVisibilities))
|
||||
for i, v := range f.compliancePortalVisibilities {
|
||||
visibilities[i] = v.String()
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (f *TrustCenterFileFilter) SQLArguments() pgx.NamedArgs {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *TrustCenterFileFilter) SQLFragment() string {
|
||||
func (f *CompliancePortalFileFilter) SQLFragment() string {
|
||||
return `CASE
|
||||
WHEN @trust_center_visibilities::trust_center_visibility[] IS NOT NULL THEN
|
||||
trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])
|
||||
@@ -28,57 +28,54 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
TrustCenterReferenceOrderField string
|
||||
CompliancePortalFileOrderField string
|
||||
)
|
||||
|
||||
const (
|
||||
TrustCenterReferenceOrderFieldRank TrustCenterReferenceOrderField = "RANK"
|
||||
TrustCenterReferenceOrderFieldName TrustCenterReferenceOrderField = "NAME"
|
||||
TrustCenterReferenceOrderFieldCreatedAt TrustCenterReferenceOrderField = "CREATED_AT"
|
||||
TrustCenterReferenceOrderFieldUpdatedAt TrustCenterReferenceOrderField = "UPDATED_AT"
|
||||
CompliancePortalFileOrderFieldName CompliancePortalFileOrderField = "NAME"
|
||||
CompliancePortalFileOrderFieldCreatedAt CompliancePortalFileOrderField = "CREATED_AT"
|
||||
CompliancePortalFileOrderFieldUpdatedAt CompliancePortalFileOrderField = "UPDATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = TrustCenterReferenceOrderField("")
|
||||
_ fmt.Stringer = TrustCenterReferenceOrderField("")
|
||||
_ encoding.TextMarshaler = TrustCenterReferenceOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*TrustCenterReferenceOrderField)(nil)
|
||||
_ page.OrderField = CompliancePortalFileOrderField("")
|
||||
_ fmt.Stringer = CompliancePortalFileOrderField("")
|
||||
_ encoding.TextMarshaler = CompliancePortalFileOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CompliancePortalFileOrderField)(nil)
|
||||
)
|
||||
|
||||
func TrustCenterReferenceOrderFields() []TrustCenterReferenceOrderField {
|
||||
return []TrustCenterReferenceOrderField{
|
||||
TrustCenterReferenceOrderFieldRank,
|
||||
TrustCenterReferenceOrderFieldName,
|
||||
TrustCenterReferenceOrderFieldCreatedAt,
|
||||
TrustCenterReferenceOrderFieldUpdatedAt,
|
||||
func CompliancePortalFileOrderFields() []CompliancePortalFileOrderField {
|
||||
return []CompliancePortalFileOrderField{
|
||||
CompliancePortalFileOrderFieldName,
|
||||
CompliancePortalFileOrderFieldCreatedAt,
|
||||
CompliancePortalFileOrderFieldUpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v TrustCenterReferenceOrderField) IsValid() bool {
|
||||
func (v CompliancePortalFileOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
TrustCenterReferenceOrderFieldRank,
|
||||
TrustCenterReferenceOrderFieldName,
|
||||
TrustCenterReferenceOrderFieldCreatedAt,
|
||||
TrustCenterReferenceOrderFieldUpdatedAt:
|
||||
CompliancePortalFileOrderFieldName,
|
||||
CompliancePortalFileOrderFieldCreatedAt,
|
||||
CompliancePortalFileOrderFieldUpdatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v TrustCenterReferenceOrderField) String() string {
|
||||
func (v CompliancePortalFileOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v TrustCenterReferenceOrderField) MarshalText() ([]byte, error) {
|
||||
func (v CompliancePortalFileOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *TrustCenterReferenceOrderField) UnmarshalText(text []byte) error {
|
||||
val := TrustCenterReferenceOrderField(text)
|
||||
func (v *CompliancePortalFileOrderField) UnmarshalText(text []byte) error {
|
||||
val := CompliancePortalFileOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid TrustCenterReferenceOrderField value: %q", string(text))
|
||||
return fmt.Errorf("invalid CompliancePortalFileOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
@@ -86,15 +83,13 @@ func (v *TrustCenterReferenceOrderField) UnmarshalText(text []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p TrustCenterReferenceOrderField) Column() string {
|
||||
func (p CompliancePortalFileOrderField) Column() string {
|
||||
switch p {
|
||||
case TrustCenterReferenceOrderFieldRank:
|
||||
return "rank"
|
||||
case TrustCenterReferenceOrderFieldName:
|
||||
case CompliancePortalFileOrderFieldName:
|
||||
return "name"
|
||||
case TrustCenterReferenceOrderFieldCreatedAt:
|
||||
case CompliancePortalFileOrderFieldCreatedAt:
|
||||
return "created_at"
|
||||
case TrustCenterReferenceOrderFieldUpdatedAt:
|
||||
case CompliancePortalFileOrderFieldUpdatedAt:
|
||||
return "updated_at"
|
||||
default:
|
||||
return string(p)
|
||||
@@ -27,47 +27,47 @@ import (
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type TrustCenterOrderField string
|
||||
type CompliancePortalOrderField string
|
||||
|
||||
const (
|
||||
TrustCenterOrderFieldCreatedAt TrustCenterOrderField = "CREATED_AT"
|
||||
CompliancePortalOrderFieldCreatedAt CompliancePortalOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.OrderField = TrustCenterOrderField("")
|
||||
_ fmt.Stringer = TrustCenterOrderField("")
|
||||
_ encoding.TextMarshaler = TrustCenterOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*TrustCenterOrderField)(nil)
|
||||
_ page.OrderField = CompliancePortalOrderField("")
|
||||
_ fmt.Stringer = CompliancePortalOrderField("")
|
||||
_ encoding.TextMarshaler = CompliancePortalOrderField("")
|
||||
_ encoding.TextUnmarshaler = (*CompliancePortalOrderField)(nil)
|
||||
)
|
||||
|
||||
func TrustCenterOrderFields() []TrustCenterOrderField {
|
||||
return []TrustCenterOrderField{
|
||||
TrustCenterOrderFieldCreatedAt,
|
||||
func CompliancePortalOrderFields() []CompliancePortalOrderField {
|
||||
return []CompliancePortalOrderField{
|
||||
CompliancePortalOrderFieldCreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (v TrustCenterOrderField) IsValid() bool {
|
||||
func (v CompliancePortalOrderField) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
TrustCenterOrderFieldCreatedAt:
|
||||
CompliancePortalOrderFieldCreatedAt:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v TrustCenterOrderField) String() string {
|
||||
func (v CompliancePortalOrderField) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v TrustCenterOrderField) MarshalText() ([]byte, error) {
|
||||
func (v CompliancePortalOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *TrustCenterOrderField) UnmarshalText(text []byte) error {
|
||||
val := TrustCenterOrderField(text)
|
||||
func (v *CompliancePortalOrderField) UnmarshalText(text []byte) error {
|
||||
val := CompliancePortalOrderField(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid TrustCenterOrderField value: %q", string(text))
|
||||
return fmt.Errorf("invalid CompliancePortalOrderField value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
@@ -75,6 +75,6 @@ func (v *TrustCenterOrderField) UnmarshalText(text []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p TrustCenterOrderField) Column() string {
|
||||
func (p CompliancePortalOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
@@ -36,38 +36,38 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
TrustCenterReference struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
TrustCenterID gid.GID `db:"trust_center_id"`
|
||||
Name string `db:"name"`
|
||||
Description *string `db:"description"`
|
||||
WebsiteURL string `db:"website_url"`
|
||||
LogoFileID gid.GID `db:"logo_file_id"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
CompliancePortalReference struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
CompliancePortalID gid.GID `db:"trust_center_id"`
|
||||
Name string `db:"name"`
|
||||
Description *string `db:"description"`
|
||||
WebsiteURL string `db:"website_url"`
|
||||
LogoFileID gid.GID `db:"logo_file_id"`
|
||||
Rank int `db:"rank"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
TrustCenterReferences []*TrustCenterReference
|
||||
CompliancePortalReferences []*CompliancePortalReference
|
||||
)
|
||||
|
||||
func (t TrustCenterReference) CursorKey(orderBy TrustCenterReferenceOrderField) page.CursorKey {
|
||||
func (t CompliancePortalReference) CursorKey(orderBy CompliancePortalReferenceOrderField) page.CursorKey {
|
||||
switch orderBy {
|
||||
case TrustCenterReferenceOrderFieldRank:
|
||||
case CompliancePortalReferenceOrderFieldRank:
|
||||
return page.NewCursorKey(t.ID, t.Rank)
|
||||
case TrustCenterReferenceOrderFieldName:
|
||||
case CompliancePortalReferenceOrderFieldName:
|
||||
return page.NewCursorKey(t.ID, t.Name)
|
||||
case TrustCenterReferenceOrderFieldCreatedAt:
|
||||
case CompliancePortalReferenceOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(t.ID, t.CreatedAt)
|
||||
case TrustCenterReferenceOrderFieldUpdatedAt:
|
||||
case CompliancePortalReferenceOrderFieldUpdatedAt:
|
||||
return page.NewCursorKey(t.ID, t.UpdatedAt)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||
}
|
||||
|
||||
func (t *TrustCenterReference) AuthorizationAttributes(
|
||||
func (t *CompliancePortalReference) AuthorizationAttributes(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
resourceIDs []gid.GID,
|
||||
@@ -106,11 +106,11 @@ func (t *TrustCenterReference) AuthorizationAttributes(
|
||||
return attrsByID, nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterReference) LoadByID(
|
||||
func (t *CompliancePortalReference) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterReferenceID gid.GID,
|
||||
compliancePortalReferenceID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -133,7 +133,7 @@ LIMIT 1;
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"trust_center_reference_id": trustCenterReferenceID}
|
||||
args := pgx.StrictNamedArgs{"trust_center_reference_id": compliancePortalReferenceID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
@@ -141,9 +141,9 @@ LIMIT 1;
|
||||
return fmt.Errorf("cannot query trust_center_references: %w", err)
|
||||
}
|
||||
|
||||
reference, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TrustCenterReference])
|
||||
reference, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[CompliancePortalReference])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect trust center reference: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal reference: %w", err)
|
||||
}
|
||||
|
||||
*t = reference
|
||||
@@ -151,7 +151,7 @@ LIMIT 1;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterReference) Insert(
|
||||
func (t *CompliancePortalReference) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -191,7 +191,7 @@ RETURNING rank;
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"id": t.ID,
|
||||
"organization_id": t.OrganizationID,
|
||||
"trust_center_id": t.TrustCenterID,
|
||||
"trust_center_id": t.CompliancePortalID,
|
||||
"name": t.Name,
|
||||
"description": t.Description,
|
||||
"website_url": t.WebsiteURL,
|
||||
@@ -208,13 +208,13 @@ RETURNING rank;
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot insert trust center reference: %w", err)
|
||||
return fmt.Errorf("cannot insert compliance portal reference: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterReference) Update(
|
||||
func (t *CompliancePortalReference) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -246,7 +246,7 @@ WHERE
|
||||
|
||||
result, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update trust center reference: %w", err)
|
||||
return fmt.Errorf("cannot update compliance portal reference: %w", err)
|
||||
}
|
||||
|
||||
if result.RowsAffected() == 0 {
|
||||
@@ -256,7 +256,7 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterReference) UpdateRank(
|
||||
func (t *CompliancePortalReference) UpdateRank(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -293,20 +293,20 @@ WHERE %s
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": t.ID,
|
||||
"new_rank": t.Rank,
|
||||
"trust_center_id": t.TrustCenterID,
|
||||
"trust_center_id": t.CompliancePortalID,
|
||||
"updated_at": t.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update trust center reference rank: %w", err)
|
||||
return fmt.Errorf("cannot update compliance portal reference rank: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterReference) Delete(
|
||||
func (t *CompliancePortalReference) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Tx,
|
||||
scope Scoper,
|
||||
@@ -326,18 +326,18 @@ WHERE
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete trust center reference: %w", err)
|
||||
return fmt.Errorf("cannot delete compliance portal reference: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterReferences) LoadByTrustCenterID(
|
||||
func (t *CompliancePortalReferences) LoadByCompliancePortalID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
cursor *page.Cursor[TrustCenterReferenceOrderField],
|
||||
compliancePortalID gid.GID,
|
||||
cursor *page.Cursor[CompliancePortalReferenceOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -361,7 +361,7 @@ WHERE
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID}
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
@@ -370,9 +370,9 @@ WHERE
|
||||
return fmt.Errorf("cannot query trust_center_references: %w", err)
|
||||
}
|
||||
|
||||
references, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[TrustCenterReference])
|
||||
references, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[CompliancePortalReference])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect trust center references: %w", err)
|
||||
return fmt.Errorf("cannot collect compliance portal references: %w", err)
|
||||
}
|
||||
|
||||
*t = references
|
||||
@@ -380,11 +380,11 @@ WHERE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TrustCenterReferences) CountByTrustCenterID(
|
||||
func (t *CompliancePortalReferences) CountByCompliancePortalID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
@@ -398,14 +398,14 @@ WHERE
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": trustCenterID}
|
||||
args := pgx.StrictNamedArgs{"trust_center_id": compliancePortalID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
var count int
|
||||
|
||||
err := conn.QueryRow(ctx, q, args).Scan(&count)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count trust center references: %w", err)
|
||||
return 0, fmt.Errorf("cannot count compliance portal references: %w", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
102
pkg/coredata/compliance_portal_reference_order_field.go
Normal file
102
pkg/coredata/compliance_portal_reference_order_field.go
Normal 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)
|
||||
}
|
||||
}
|
||||
@@ -25,52 +25,52 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TrustCenterVisibility string
|
||||
type CompliancePortalVisibility string
|
||||
|
||||
const (
|
||||
TrustCenterVisibilityNone TrustCenterVisibility = "NONE"
|
||||
TrustCenterVisibilityPrivate TrustCenterVisibility = "PRIVATE"
|
||||
TrustCenterVisibilityPublic TrustCenterVisibility = "PUBLIC"
|
||||
CompliancePortalVisibilityNone CompliancePortalVisibility = "NONE"
|
||||
CompliancePortalVisibilityPrivate CompliancePortalVisibility = "PRIVATE"
|
||||
CompliancePortalVisibilityPublic CompliancePortalVisibility = "PUBLIC"
|
||||
)
|
||||
|
||||
var (
|
||||
_ fmt.Stringer = TrustCenterVisibility("")
|
||||
_ encoding.TextMarshaler = TrustCenterVisibility("")
|
||||
_ encoding.TextUnmarshaler = (*TrustCenterVisibility)(nil)
|
||||
_ fmt.Stringer = CompliancePortalVisibility("")
|
||||
_ encoding.TextMarshaler = CompliancePortalVisibility("")
|
||||
_ encoding.TextUnmarshaler = (*CompliancePortalVisibility)(nil)
|
||||
)
|
||||
|
||||
func TrustCenterVisibilities() []TrustCenterVisibility {
|
||||
return []TrustCenterVisibility{
|
||||
TrustCenterVisibilityNone,
|
||||
TrustCenterVisibilityPrivate,
|
||||
TrustCenterVisibilityPublic,
|
||||
func CompliancePortalVisibilities() []CompliancePortalVisibility {
|
||||
return []CompliancePortalVisibility{
|
||||
CompliancePortalVisibilityNone,
|
||||
CompliancePortalVisibilityPrivate,
|
||||
CompliancePortalVisibilityPublic,
|
||||
}
|
||||
}
|
||||
|
||||
func (v TrustCenterVisibility) IsValid() bool {
|
||||
func (v CompliancePortalVisibility) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
TrustCenterVisibilityNone,
|
||||
TrustCenterVisibilityPrivate,
|
||||
TrustCenterVisibilityPublic:
|
||||
CompliancePortalVisibilityNone,
|
||||
CompliancePortalVisibilityPrivate,
|
||||
CompliancePortalVisibilityPublic:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (v TrustCenterVisibility) String() string {
|
||||
func (v CompliancePortalVisibility) String() string {
|
||||
return string(v)
|
||||
}
|
||||
|
||||
func (v TrustCenterVisibility) MarshalText() ([]byte, error) {
|
||||
func (v CompliancePortalVisibility) MarshalText() ([]byte, error) {
|
||||
return []byte(v.String()), nil
|
||||
}
|
||||
|
||||
func (v *TrustCenterVisibility) UnmarshalText(text []byte) error {
|
||||
val := TrustCenterVisibility(text)
|
||||
func (v *CompliancePortalVisibility) UnmarshalText(text []byte) error {
|
||||
val := CompliancePortalVisibility(text)
|
||||
if !val.IsValid() {
|
||||
return fmt.Errorf("invalid TrustCenterVisibility value: %q", string(text))
|
||||
return fmt.Errorf("invalid CompliancePortalVisibility value: %q", string(text))
|
||||
}
|
||||
|
||||
*v = val
|
||||
@@ -37,16 +37,16 @@ import (
|
||||
|
||||
type (
|
||||
Document struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
CurrentPublishedMajor *int `db:"current_published_major"`
|
||||
CurrentPublishedMinor *int `db:"current_published_minor"`
|
||||
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"`
|
||||
WriteMode DocumentWriteMode `db:"write_mode"`
|
||||
Status DocumentStatus `db:"status"`
|
||||
ArchivedAt *time.Time `db:"archived_at"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
CurrentPublishedMajor *int `db:"current_published_major"`
|
||||
CurrentPublishedMinor *int `db:"current_published_minor"`
|
||||
CompliancePortalVisibility CompliancePortalVisibility `db:"trust_center_visibility"`
|
||||
WriteMode DocumentWriteMode `db:"write_mode"`
|
||||
Status DocumentStatus `db:"status"`
|
||||
ArchivedAt *time.Time `db:"archived_at"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
|
||||
// ordering only
|
||||
Title string `db:"title"`
|
||||
@@ -505,7 +505,7 @@ VALUES (
|
||||
"current_published_major": p.CurrentPublishedMajor,
|
||||
"current_published_minor": p.CurrentPublishedMinor,
|
||||
"write_mode": p.WriteMode,
|
||||
"trust_center_visibility": p.TrustCenterVisibility,
|
||||
"trust_center_visibility": p.CompliancePortalVisibility,
|
||||
"status": p.Status,
|
||||
"archived_at": p.ArchivedAt,
|
||||
"created_at": p.CreatedAt,
|
||||
@@ -582,7 +582,7 @@ WHERE
|
||||
"updated_at": time.Now(),
|
||||
"current_published_major": p.CurrentPublishedMajor,
|
||||
"current_published_minor": p.CurrentPublishedMinor,
|
||||
"trust_center_visibility": p.TrustCenterVisibility,
|
||||
"trust_center_visibility": p.CompliancePortalVisibility,
|
||||
"status": p.Status,
|
||||
"archived_at": p.ArchivedAt,
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ import (
|
||||
|
||||
type (
|
||||
DocumentFilter struct {
|
||||
query *string
|
||||
trustCenterVisibilities []TrustCenterVisibility
|
||||
published *bool
|
||||
employeeIdentityID *gid.GID
|
||||
employeeFilterModes []EmployeeFilterMode
|
||||
documentTypes []DocumentType
|
||||
classifications []DocumentClassification
|
||||
writeModes []DocumentWriteMode
|
||||
status []DocumentStatus
|
||||
query *string
|
||||
compliancePortalVisibilities []CompliancePortalVisibility
|
||||
published *bool
|
||||
employeeIdentityID *gid.GID
|
||||
employeeFilterModes []EmployeeFilterMode
|
||||
documentTypes []DocumentType
|
||||
classifications []DocumentClassification
|
||||
writeModes []DocumentWriteMode
|
||||
status []DocumentStatus
|
||||
}
|
||||
)
|
||||
|
||||
@@ -45,13 +45,13 @@ func NewDocumentFilter(query *string) *DocumentFilter {
|
||||
}
|
||||
}
|
||||
|
||||
func NewDocumentTrustCenterFilter() *DocumentFilter {
|
||||
func NewDocumentCompliancePortalFilter() *DocumentFilter {
|
||||
published := true
|
||||
|
||||
return &DocumentFilter{
|
||||
trustCenterVisibilities: []TrustCenterVisibility{
|
||||
TrustCenterVisibilityPrivate,
|
||||
TrustCenterVisibilityPublic,
|
||||
compliancePortalVisibilities: []CompliancePortalVisibility{
|
||||
CompliancePortalVisibilityPrivate,
|
||||
CompliancePortalVisibilityPublic,
|
||||
},
|
||||
published: &published,
|
||||
status: []DocumentStatus{DocumentStatusActive},
|
||||
@@ -63,8 +63,8 @@ func (f *DocumentFilter) WithPublished(published *bool) *DocumentFilter {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *DocumentFilter) WithTrustCenterVisibilities(visibilities ...TrustCenterVisibility) *DocumentFilter {
|
||||
f.trustCenterVisibilities = visibilities
|
||||
func (f *DocumentFilter) WithCompliancePortalVisibilities(visibilities ...CompliancePortalVisibility) *DocumentFilter {
|
||||
f.compliancePortalVisibilities = visibilities
|
||||
return f
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ func (f *DocumentFilter) WithStatus(status []DocumentStatus) *DocumentFilter {
|
||||
|
||||
func (f *DocumentFilter) SQLArguments() pgx.NamedArgs {
|
||||
var visibilities []string
|
||||
if f.trustCenterVisibilities != nil {
|
||||
visibilities = make([]string, len(f.trustCenterVisibilities))
|
||||
for i, v := range f.trustCenterVisibilities {
|
||||
if f.compliancePortalVisibilities != nil {
|
||||
visibilities = make([]string, len(f.compliancePortalVisibilities))
|
||||
for i, v := range f.compliancePortalVisibilities {
|
||||
visibilities[i] = v.String()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ const (
|
||||
DatumEntityType uint16 = 19
|
||||
AuditEntityType uint16 = 20
|
||||
_ uint16 = 21 // ReportEntityType - removed
|
||||
TrustCenterEntityType uint16 = 22
|
||||
TrustCenterAccessEntityType uint16 = 23
|
||||
CompliancePortalEntityType uint16 = 22
|
||||
CompliancePortalAccessEntityType uint16 = 23
|
||||
ThirdPartyBusinessAssociateAgreementEntityType uint16 = 24
|
||||
FileEntityType uint16 = 25
|
||||
ThirdPartyContactEntityType uint16 = 26
|
||||
@@ -64,13 +64,13 @@ const (
|
||||
_ uint16 = 32 // ContinualImprovementEntityType - removed
|
||||
ProcessingActivityEntityType uint16 = 33
|
||||
ExportJobEntityType uint16 = 34
|
||||
TrustCenterReferenceEntityType uint16 = 35
|
||||
TrustCenterDocumentAccessEntityType uint16 = 36
|
||||
CompliancePortalReferenceEntityType uint16 = 35
|
||||
CompliancePortalDocumentAccessEntityType uint16 = 36
|
||||
CustomDomainEntityType uint16 = 37
|
||||
InvitationEntityType uint16 = 38
|
||||
MembershipEntityType uint16 = 39
|
||||
SlackMessageEntityType uint16 = 40
|
||||
TrustCenterFileEntityType uint16 = 41
|
||||
CompliancePortalFileEntityType uint16 = 41
|
||||
SAMLConfigurationEntityType uint16 = 42
|
||||
PersonalAPIKeyEntityType uint16 = 43
|
||||
_ uint16 = 44 // PersonalAPIKeyMembershipEntityType - removed
|
||||
@@ -180,10 +180,10 @@ func NewEntityFromID(id gid.GID) (any, bool) {
|
||||
return &Datum{ID: id}, true
|
||||
case AuditEntityType:
|
||||
return &Audit{ID: id}, true
|
||||
case TrustCenterEntityType:
|
||||
return &TrustCenter{ID: id}, true
|
||||
case TrustCenterAccessEntityType:
|
||||
return &TrustCenterAccess{ID: id}, true
|
||||
case CompliancePortalEntityType:
|
||||
return &CompliancePortal{ID: id}, true
|
||||
case CompliancePortalAccessEntityType:
|
||||
return &CompliancePortalAccess{ID: id}, true
|
||||
case ThirdPartyBusinessAssociateAgreementEntityType:
|
||||
return &ThirdPartyBusinessAssociateAgreement{ID: id}, true
|
||||
case FileEntityType:
|
||||
@@ -202,10 +202,10 @@ func NewEntityFromID(id gid.GID) (any, bool) {
|
||||
return &ProcessingActivity{ID: id}, true
|
||||
case ExportJobEntityType:
|
||||
return &ExportJob{ID: id}, true
|
||||
case TrustCenterReferenceEntityType:
|
||||
return &TrustCenterReference{ID: id}, true
|
||||
case TrustCenterDocumentAccessEntityType:
|
||||
return &TrustCenterDocumentAccess{ID: id}, true
|
||||
case CompliancePortalReferenceEntityType:
|
||||
return &CompliancePortalReference{ID: id}, true
|
||||
case CompliancePortalDocumentAccessEntityType:
|
||||
return &CompliancePortalDocumentAccess{ID: id}, true
|
||||
case CustomDomainEntityType:
|
||||
return &CustomDomain{ID: id}, true
|
||||
case InvitationEntityType:
|
||||
@@ -214,8 +214,8 @@ func NewEntityFromID(id gid.GID) (any, bool) {
|
||||
return &Membership{ID: id}, true
|
||||
case SlackMessageEntityType:
|
||||
return &SlackMessage{ID: id}, true
|
||||
case TrustCenterFileEntityType:
|
||||
return &TrustCenterFile{ID: id}, true
|
||||
case CompliancePortalFileEntityType:
|
||||
return &CompliancePortalFile{ID: id}, true
|
||||
case SAMLConfigurationEntityType:
|
||||
return &SAMLConfiguration{ID: id}, true
|
||||
case PersonalAPIKeyEntityType:
|
||||
|
||||
@@ -29,15 +29,15 @@ import (
|
||||
|
||||
type (
|
||||
MembershipProfileFilter struct {
|
||||
withMembership *bool
|
||||
withTrustCenterAccess *bool
|
||||
contractEnded *bool
|
||||
currentDate time.Time
|
||||
email *mail.Addr
|
||||
userName *string
|
||||
externalID *string
|
||||
state *ProfileState
|
||||
source *ProfileSource
|
||||
withMembership *bool
|
||||
withCompliancePortalAccess *bool
|
||||
contractEnded *bool
|
||||
currentDate time.Time
|
||||
email *mail.Addr
|
||||
userName *string
|
||||
externalID *string
|
||||
state *ProfileState
|
||||
source *ProfileSource
|
||||
}
|
||||
)
|
||||
|
||||
@@ -53,8 +53,8 @@ func (f *MembershipProfileFilter) WithMembership() *MembershipProfileFilter {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *MembershipProfileFilter) WithTrustCenterAccess() *MembershipProfileFilter {
|
||||
f.withTrustCenterAccess = new(true)
|
||||
func (f *MembershipProfileFilter) WithCompliancePortalAccess() *MembershipProfileFilter {
|
||||
f.withCompliancePortalAccess = new(true)
|
||||
return f
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func (f *MembershipProfileFilter) SQLArguments() pgx.StrictNamedArgs {
|
||||
"filter_user_name": f.userName,
|
||||
"filter_external_id": f.externalID,
|
||||
"with_membership": f.withMembership,
|
||||
"with_trust_center_access": f.withTrustCenterAccess,
|
||||
"with_trust_center_access": f.withCompliancePortalAccess,
|
||||
"contract_ended": f.contractEnded,
|
||||
"current_date": f.currentDate,
|
||||
"filter_state": f.state,
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
type SlackMessageType string
|
||||
|
||||
const (
|
||||
SlackMessageTypeTrustCenterAccessRequest SlackMessageType = "TRUST_CENTER_ACCESS_REQUEST"
|
||||
SlackMessageTypeWelcome SlackMessageType = "WELCOME"
|
||||
SlackMessageTypeCompliancePortalAccessRequest SlackMessageType = "TRUST_CENTER_ACCESS_REQUEST"
|
||||
SlackMessageTypeWelcome SlackMessageType = "WELCOME"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -40,7 +40,7 @@ var (
|
||||
|
||||
func SlackMessageTypes() []SlackMessageType {
|
||||
return []SlackMessageType{
|
||||
SlackMessageTypeTrustCenterAccessRequest,
|
||||
SlackMessageTypeCompliancePortalAccessRequest,
|
||||
SlackMessageTypeWelcome,
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func SlackMessageTypes() []SlackMessageType {
|
||||
func (v SlackMessageType) IsValid() bool {
|
||||
switch v {
|
||||
case
|
||||
SlackMessageTypeTrustCenterAccessRequest,
|
||||
SlackMessageTypeCompliancePortalAccessRequest,
|
||||
SlackMessageTypeWelcome:
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ type (
|
||||
TermsOfServiceURL *string `db:"terms_of_service_url"`
|
||||
SecurityPageURL *string `db:"security_page_url"`
|
||||
TrustPageURL *string `db:"trust_page_url"`
|
||||
ShowOnTrustCenter bool `db:"show_on_trust_center"`
|
||||
ShowOnCompliancePortal bool `db:"show_on_trust_center"`
|
||||
Level int `db:"level"`
|
||||
VettingStatus *ThirdPartyVettingStatus `db:"vetting_status"`
|
||||
VettingWebsiteURL *string `db:"vetting_website_url"`
|
||||
@@ -716,7 +716,7 @@ VALUES (
|
||||
"terms_of_service_url": v.TermsOfServiceURL,
|
||||
"security_page_url": v.SecurityPageURL,
|
||||
"trust_page_url": v.TrustPageURL,
|
||||
"show_on_trust_center": v.ShowOnTrustCenter,
|
||||
"show_on_trust_center": v.ShowOnCompliancePortal,
|
||||
"level": v.Level,
|
||||
"vetting_status": v.VettingStatus,
|
||||
"vetting_website_url": v.VettingWebsiteURL,
|
||||
@@ -786,7 +786,7 @@ WHERE
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (v *ThirdParties) LoadDistinctTrustCenterCategoriesByOrganizationID(
|
||||
func (v *ThirdParties) LoadDistinctCompliancePortalCategoriesByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
@@ -822,7 +822,7 @@ ORDER BY
|
||||
return categories, nil
|
||||
}
|
||||
|
||||
func (v *ThirdParties) LoadDistinctTrustCenterCountriesByOrganizationID(
|
||||
func (v *ThirdParties) LoadDistinctCompliancePortalCountriesByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope Scoper,
|
||||
@@ -996,7 +996,7 @@ WHERE %s
|
||||
"trust_page_url": v.TrustPageURL,
|
||||
"business_owner_profile_id": v.BusinessOwnerID,
|
||||
"security_owner_profile_id": v.SecurityOwnerID,
|
||||
"show_on_trust_center": v.ShowOnTrustCenter,
|
||||
"show_on_trust_center": v.ShowOnCompliancePortal,
|
||||
"level": v.Level,
|
||||
"vetting_status": v.VettingStatus,
|
||||
"vetting_website_url": v.VettingWebsiteURL,
|
||||
|
||||
@@ -26,27 +26,27 @@ import (
|
||||
|
||||
type (
|
||||
ThirdPartyFilter struct {
|
||||
showOnTrustCenter *bool
|
||||
level *int
|
||||
query *string
|
||||
category *ThirdPartyCategory
|
||||
country *CountryCode
|
||||
showOnCompliancePortal *bool
|
||||
level *int
|
||||
query *string
|
||||
category *ThirdPartyCategory
|
||||
country *CountryCode
|
||||
}
|
||||
)
|
||||
|
||||
func NewThirdPartyFilter(
|
||||
showOnTrustCenter *bool,
|
||||
showOnCompliancePortal *bool,
|
||||
level *int,
|
||||
query *string,
|
||||
category *ThirdPartyCategory,
|
||||
country *CountryCode,
|
||||
) *ThirdPartyFilter {
|
||||
return &ThirdPartyFilter{
|
||||
showOnTrustCenter: showOnTrustCenter,
|
||||
level: level,
|
||||
query: query,
|
||||
category: category,
|
||||
country: country,
|
||||
showOnCompliancePortal: showOnCompliancePortal,
|
||||
level: level,
|
||||
query: query,
|
||||
category: category,
|
||||
country: country,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ func (f *ThirdPartyFilter) SQLArguments() pgx.StrictNamedArgs {
|
||||
"filter_country": nil,
|
||||
}
|
||||
|
||||
if f.showOnTrustCenter != nil {
|
||||
args["show_on_trust_center"] = *f.showOnTrustCenter
|
||||
if f.showOnCompliancePortal != nil {
|
||||
args["show_on_trust_center"] = *f.showOnCompliancePortal
|
||||
}
|
||||
|
||||
if f.query != nil && *f.query != "" {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user