feat(dns): Implement DNS management functionality

- Added DnsManager and DnsEntry classes to handle DNS entries.
- Introduced new interfaces for DNS entry requests and data structures.
- Updated Cloudly class to include DnsManager instance.
- Enhanced app state to manage DNS entries and actions for creating, updating, and deleting DNS records.
- Created UI components for DNS management, including forms for adding and editing DNS entries.
- Updated overview and services views to reflect DNS entries.
- Added validation and formatting methods for DNS entries.
This commit is contained in:
2025-09-09 15:08:28 +00:00
parent 38e8b4086d
commit 766191899c
19 changed files with 2174 additions and 99 deletions

81
ts_interfaces/data/dns.ts Normal file
View File

@@ -0,0 +1,81 @@
export type TDnsRecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SOA' | 'SRV' | 'CAA' | 'PTR';
export interface IDnsEntry {
id: string;
data: {
/**
* The DNS record type
*/
type: TDnsRecordType;
/**
* The DNS record name (e.g., www, @, mail)
* @ represents the root domain
*/
name: string;
/**
* The value of the DNS record
* - For A/AAAA: IP address
* - For CNAME: Target domain
* - For MX: Mail server hostname
* - For TXT: Text value
* - For NS: Nameserver hostname
* - For SRV: Target hostname
* - For CAA: CAA record value
* - For PTR: Domain name
*/
value: string;
/**
* Time to live in seconds
* Default: 3600 (1 hour)
*/
ttl: number;
/**
* Priority (used for MX and SRV records)
* Lower values have higher priority
*/
priority?: number;
/**
* The DNS zone this entry belongs to
* e.g., example.com
* @deprecated Use domainId instead
*/
zone: string;
/**
* The domain ID this DNS entry belongs to
* Links to the Domain entity
*/
domainId?: string;
/**
* Additional fields for SRV records
*/
weight?: number;
port?: number;
/**
* Whether this DNS entry is active
*/
active: boolean;
/**
* Optional description for documentation
*/
description?: string;
/**
* Timestamp when the entry was created
*/
createdAt?: number;
/**
* Timestamp when the entry was last updated
*/
updatedAt?: number;
};
}

View File

@@ -0,0 +1,110 @@
export type TDomainStatus = 'active' | 'pending' | 'expired' | 'suspended' | 'transferred';
export type TDomainVerificationStatus = 'verified' | 'pending' | 'failed' | 'not_required';
export interface IDomain {
id: string;
data: {
/**
* The domain name (e.g., example.com)
*/
name: string;
/**
* Description or notes about the domain
*/
description?: string;
/**
* Current status of the domain
*/
status: TDomainStatus;
/**
* Domain verification status
*/
verificationStatus: TDomainVerificationStatus;
/**
* Nameservers for the domain
*/
nameservers: string[];
/**
* Domain registrar information
*/
registrar?: {
name: string;
url?: string;
};
/**
* Domain registration date (timestamp)
*/
registeredAt?: number;
/**
* Domain expiration date (timestamp)
*/
expiresAt?: number;
/**
* Whether auto-renewal is enabled
*/
autoRenew: boolean;
/**
* DNSSEC enabled
*/
dnssecEnabled?: boolean;
/**
* Tags for categorization
*/
tags?: string[];
/**
* Whether this domain is primary for the organization
*/
isPrimary?: boolean;
/**
* SSL certificate status
*/
sslStatus?: 'active' | 'pending' | 'expired' | 'none';
/**
* Last verification attempt timestamp
*/
lastVerificationAt?: number;
/**
* Verification method used
*/
verificationMethod?: 'dns' | 'http' | 'email' | 'manual';
/**
* Verification token (for DNS/HTTP verification)
*/
verificationToken?: string;
/**
* Cloudflare zone ID if managed by Cloudflare
*/
cloudflareZoneId?: string;
/**
* Whether domain is managed externally
*/
isExternal?: boolean;
/**
* Creation timestamp
*/
createdAt?: number;
/**
* Last update timestamp
*/
updatedAt?: number;
};
}

View File

@@ -2,7 +2,9 @@ export * from './cloudlyconfig.js';
export * from './cluster.js';
export * from './config.js';
export * from './deployment.js';
export * from './dns.js';
export * from './docker.js';
export * from './domain.js';
export * from './event.js';
export * from './externalregistry.js';
export * from './image.js';

View File

@@ -0,0 +1,93 @@
import * as plugins from '../plugins.js';
import type { IDnsEntry } from '../data/dns.js';
import type { IIdentity } from '../data/user.js';
export interface IRequest_Any_Cloudly_GetDnsEntries
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_GetDnsEntries
> {
method: 'getDnsEntries';
request: {
identity: IIdentity;
zone?: string; // Optional filter by zone
};
response: {
dnsEntries: IDnsEntry[];
};
}
export interface IRequest_Any_Cloudly_GetDnsEntryById
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_GetDnsEntryById
> {
method: 'getDnsEntryById';
request: {
identity: IIdentity;
dnsEntryId: string;
};
response: {
dnsEntry: IDnsEntry;
};
}
export interface IRequest_Any_Cloudly_CreateDnsEntry
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_CreateDnsEntry
> {
method: 'createDnsEntry';
request: {
identity: IIdentity;
dnsEntryData: IDnsEntry['data'];
};
response: {
dnsEntry: IDnsEntry;
};
}
export interface IRequest_Any_Cloudly_UpdateDnsEntry
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_UpdateDnsEntry
> {
method: 'updateDnsEntry';
request: {
identity: IIdentity;
dnsEntryId: string;
dnsEntryData: IDnsEntry['data'];
};
response: {
dnsEntry: IDnsEntry;
};
}
export interface IRequest_Any_Cloudly_DeleteDnsEntry
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_DeleteDnsEntry
> {
method: 'deleteDnsEntry';
request: {
identity: IIdentity;
dnsEntryId: string;
};
response: {
success: boolean;
};
}
export interface IRequest_Any_Cloudly_GetDnsZones
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_GetDnsZones
> {
method: 'getDnsZones';
request: {
identity: IIdentity;
};
response: {
zones: string[];
};
}

View File

@@ -0,0 +1,99 @@
import * as plugins from '../plugins.js';
import type { IDomain } from '../data/domain.js';
import type { IIdentity } from '../data/user.js';
export interface IRequest_Any_Cloudly_GetDomains
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_GetDomains
> {
method: 'getDomains';
request: {
identity: IIdentity;
};
response: {
domains: IDomain[];
};
}
export interface IRequest_Any_Cloudly_GetDomainById
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_GetDomainById
> {
method: 'getDomainById';
request: {
identity: IIdentity;
domainId: string;
};
response: {
domain: IDomain;
};
}
export interface IRequest_Any_Cloudly_CreateDomain
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_CreateDomain
> {
method: 'createDomain';
request: {
identity: IIdentity;
domainData: IDomain['data'];
};
response: {
domain: IDomain;
};
}
export interface IRequest_Any_Cloudly_UpdateDomain
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_UpdateDomain
> {
method: 'updateDomain';
request: {
identity: IIdentity;
domainId: string;
domainData: IDomain['data'];
};
response: {
domain: IDomain;
};
}
export interface IRequest_Any_Cloudly_DeleteDomain
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_DeleteDomain
> {
method: 'deleteDomain';
request: {
identity: IIdentity;
domainId: string;
};
response: {
success: boolean;
};
}
export interface IRequest_Any_Cloudly_VerifyDomain
extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IRequest_Any_Cloudly_VerifyDomain
> {
method: 'verifyDomain';
request: {
identity: IIdentity;
domainId: string;
verificationMethod?: 'dns' | 'http' | 'email' | 'manual';
};
response: {
domain: IDomain;
verificationResult: {
success: boolean;
message?: string;
details?: any;
};
};
}

View File

@@ -6,6 +6,8 @@ import * as certificateRequests from './certificate.js';
import * as clusterRequests from './cluster.js';
import * as configRequests from './config.js';
import * as deploymentRequests from './deployment.js';
import * as dnsRequests from './dns.js';
import * as domainRequests from './domain.js';
import * as externalRegistryRequests from './externalregistry.js';
import * as identityRequests from './identity.js';
import * as imageRequests from './image.js';
@@ -29,6 +31,8 @@ export {
clusterRequests as cluster,
configRequests as config,
deploymentRequests as deployment,
dnsRequests as dns,
domainRequests as domain,
externalRegistryRequests as externalRegistry,
identityRequests as identity,
imageRequests as image,