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