feat(domains): enhance domain management with activation states and sync options

This commit is contained in:
2025-09-14 17:38:16 +00:00
parent bb313fd9dc
commit 6cc3700d29
6 changed files with 136 additions and 9 deletions

View File

@@ -69,12 +69,15 @@ export class DnsManager {
this.cloudlyRef.authManager.validIdentityGuard,
]);
// Validate domain exists if domainId is provided
// Validate domain exists and is activated if domainId is provided
if (reqArg.dnsEntryData.domainId) {
const domain = await this.cloudlyRef.domainManager.CDomain.getDomainById(reqArg.dnsEntryData.domainId);
if (!domain) {
throw new Error(`Domain with id ${reqArg.dnsEntryData.domainId} not found`);
}
if ((domain.data as any).activationState !== 'activated') {
throw new Error(`Domain ${domain.data.name} is not activated; DNS changes are not allowed.`);
}
// Set the zone from the domain name
reqArg.dnsEntryData.zone = domain.data.name;
}
@@ -97,12 +100,15 @@ export class DnsManager {
this.cloudlyRef.authManager.validIdentityGuard,
]);
// Validate domain exists if domainId is provided
// Validate domain exists and is activated if domainId is provided
if (reqArg.dnsEntryData.domainId) {
const domain = await this.cloudlyRef.domainManager.CDomain.getDomainById(reqArg.dnsEntryData.domainId);
if (!domain) {
throw new Error(`Domain with id ${reqArg.dnsEntryData.domainId} not found`);
}
if ((domain.data as any).activationState !== 'activated') {
throw new Error(`Domain ${domain.data.name} is not activated; DNS changes are not allowed.`);
}
// Set the zone from the domain name
reqArg.dnsEntryData.zone = domain.data.name;
}
@@ -258,4 +264,4 @@ export class DnsManager {
public async stop() {
console.log('DNS Manager stopped');
}
}
}