@@ -1664,12 +1664,7 @@ type Organization implements Node {
|
||||
|
||||
trustCenter: TrustCenter @goField(forceResolver: true)
|
||||
|
||||
customDomains(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
): CustomDomainConnection! @goField(forceResolver: true)
|
||||
customDomain: CustomDomain @goField(forceResolver: true)
|
||||
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
@@ -4459,7 +4454,6 @@ type CustomDomain implements Node {
|
||||
domain: String!
|
||||
sslStatus: SSLStatus!
|
||||
sslExpiresAt: Datetime
|
||||
isActive: Boolean!
|
||||
dnsRecords: [DNSRecordInstruction!]!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
@@ -4474,28 +4468,17 @@ type DNSRecordInstruction {
|
||||
purpose: String!
|
||||
}
|
||||
|
||||
type CustomDomainConnection {
|
||||
edges: [CustomDomainEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
totalCount: Int!
|
||||
}
|
||||
|
||||
type CustomDomainEdge {
|
||||
cursor: CursorKey!
|
||||
node: CustomDomain!
|
||||
}
|
||||
|
||||
input CreateCustomDomainInput {
|
||||
organizationId: ID!
|
||||
domain: String!
|
||||
}
|
||||
|
||||
input DeleteCustomDomainInput {
|
||||
domainId: ID!
|
||||
organizationId: ID!
|
||||
}
|
||||
|
||||
type CreateCustomDomainPayload {
|
||||
customDomainEdge: CustomDomainEdge!
|
||||
customDomain: CustomDomain!
|
||||
}
|
||||
|
||||
type DeleteCustomDomainPayload {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,45 +16,12 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
)
|
||||
|
||||
func NewCustomDomainConnection(
|
||||
p *page.Page[*coredata.CustomDomain, coredata.CustomDomainOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
cnameTarget string,
|
||||
) *CustomDomainConnection {
|
||||
var edges = make([]*CustomDomainEdge, len(p.Data))
|
||||
|
||||
for i := range edges {
|
||||
edges[i] = NewCustomDomainEdge(p.Data[i], p.Cursor.OrderBy.Field, cnameTarget)
|
||||
}
|
||||
|
||||
return &CustomDomainConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(p),
|
||||
TotalCount: len(p.Data),
|
||||
}
|
||||
}
|
||||
|
||||
func NewCustomDomainEdge(
|
||||
d *coredata.CustomDomain,
|
||||
orderBy coredata.CustomDomainOrderField,
|
||||
cnameTarget string,
|
||||
) *CustomDomainEdge {
|
||||
return &CustomDomainEdge{
|
||||
Cursor: d.CursorKey(orderBy),
|
||||
Node: NewCustomDomain(d, cnameTarget),
|
||||
}
|
||||
}
|
||||
|
||||
func NewCustomDomain(d *coredata.CustomDomain, cnameTarget string) *CustomDomain {
|
||||
result := &CustomDomain{
|
||||
ID: d.ID,
|
||||
Domain: d.Domain,
|
||||
IsActive: d.IsActive,
|
||||
SslStatus: d.SSLStatus,
|
||||
CreatedAt: d.CreatedAt,
|
||||
UpdatedAt: d.UpdatedAt,
|
||||
|
||||
@@ -324,7 +324,7 @@ type CreateCustomDomainInput struct {
|
||||
}
|
||||
|
||||
type CreateCustomDomainPayload struct {
|
||||
CustomDomainEdge *CustomDomainEdge `json:"customDomainEdge"`
|
||||
CustomDomain *CustomDomain `json:"customDomain"`
|
||||
}
|
||||
|
||||
type CreateDatumInput struct {
|
||||
@@ -641,7 +641,6 @@ type CustomDomain struct {
|
||||
Domain string `json:"domain"`
|
||||
SslStatus coredata.CustomDomainSSLStatus `json:"sslStatus"`
|
||||
SslExpiresAt *time.Time `json:"sslExpiresAt,omitempty"`
|
||||
IsActive bool `json:"isActive"`
|
||||
DNSRecords []*DNSRecordInstruction `json:"dnsRecords"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
@@ -651,17 +650,6 @@ type CustomDomain struct {
|
||||
func (CustomDomain) IsNode() {}
|
||||
func (this CustomDomain) GetID() gid.GID { return this.ID }
|
||||
|
||||
type CustomDomainConnection struct {
|
||||
Edges []*CustomDomainEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
TotalCount int `json:"totalCount"`
|
||||
}
|
||||
|
||||
type CustomDomainEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *CustomDomain `json:"node"`
|
||||
}
|
||||
|
||||
type DNSRecordInstruction struct {
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
@@ -775,7 +763,7 @@ type DeleteControlSnapshotMappingPayload struct {
|
||||
}
|
||||
|
||||
type DeleteCustomDomainInput struct {
|
||||
DomainID gid.GID `json:"domainId"`
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
}
|
||||
|
||||
type DeleteCustomDomainPayload struct {
|
||||
@@ -1325,7 +1313,7 @@ type Organization struct {
|
||||
ProcessingActivities *ProcessingActivityConnection `json:"processingActivities"`
|
||||
Snapshots *SnapshotConnection `json:"snapshots"`
|
||||
TrustCenter *TrustCenter `json:"trustCenter,omitempty"`
|
||||
CustomDomains *CustomDomainConnection `json:"customDomains"`
|
||||
CustomDomain *CustomDomain `json:"customDomain,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
@@ -3324,26 +3324,33 @@ func (r *mutationResolver) CreateCustomDomain(ctx context.Context, input types.C
|
||||
return nil, fmt.Errorf("failed to create custom domain: %w", err)
|
||||
}
|
||||
|
||||
edge := &types.CustomDomainEdge{
|
||||
Node: types.NewCustomDomain(domain, r.customDomainCname),
|
||||
Cursor: page.NewCursorKey(domain.ID, domain.CreatedAt),
|
||||
}
|
||||
|
||||
return &types.CreateCustomDomainPayload{
|
||||
CustomDomainEdge: edge,
|
||||
CustomDomain: types.NewCustomDomain(domain, r.customDomainCname),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteCustomDomain is the resolver for the deleteCustomDomain field.
|
||||
func (r *mutationResolver) DeleteCustomDomain(ctx context.Context, input types.DeleteCustomDomainInput) (*types.DeleteCustomDomainPayload, error) {
|
||||
prb := r.ProboService(ctx, input.DomainID.TenantID())
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
if err := prb.CustomDomains.DeleteCustomDomain(ctx, input.DomainID); err != nil {
|
||||
// Get the current custom domain ID before deleting
|
||||
domain, err := prb.CustomDomains.GetOrganizationCustomDomain(ctx, input.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get custom domain: %w", err)
|
||||
}
|
||||
|
||||
if domain == nil {
|
||||
return nil, fmt.Errorf("organization has no custom domain")
|
||||
}
|
||||
|
||||
deletedDomainID := domain.ID
|
||||
|
||||
if err := prb.CustomDomains.DeleteCustomDomain(ctx, input.OrganizationID); err != nil {
|
||||
return nil, fmt.Errorf("failed to delete custom domain: %w", err)
|
||||
}
|
||||
|
||||
return &types.DeleteCustomDomainPayload{
|
||||
DeletedCustomDomainID: input.DomainID,
|
||||
DeletedCustomDomainID: deletedDomainID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -4016,23 +4023,20 @@ func (r *organizationResolver) TrustCenter(ctx context.Context, obj *types.Organ
|
||||
return types.NewTrustCenter(trustCenter, file), nil
|
||||
}
|
||||
|
||||
// CustomDomains is the resolver for the customDomains field.
|
||||
func (r *organizationResolver) CustomDomains(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.CustomDomainConnection, error) {
|
||||
// CustomDomain is the resolver for the customDomain field.
|
||||
func (r *organizationResolver) CustomDomain(ctx context.Context, obj *types.Organization) (*types.CustomDomain, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.CustomDomainOrderField]{
|
||||
Field: coredata.CustomDomainOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.CustomDomains.ListOrganizationDomains(ctx, obj.ID, cursor)
|
||||
domain, err := prb.CustomDomains.GetOrganizationCustomDomain(ctx, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to list custom domains: %w", err)
|
||||
return nil, fmt.Errorf("failed to get custom domain: %w", err)
|
||||
}
|
||||
|
||||
return types.NewCustomDomainConnection(page, r, obj.ID, r.customDomainCname), nil
|
||||
if domain == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return types.NewCustomDomain(domain, r.customDomainCname), nil
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
|
||||
Reference in New Issue
Block a user