BREAKING CHANGE(core): Introduce RecordManager and ConvenientDnsProvider; rename list/get methods for consistent API and deprecate convenience namespace
This commit is contained in:
@@ -5,6 +5,8 @@ import * as interfaces from './interfaces/index.js';
|
||||
// interfaces
|
||||
import { WorkerManager } from './cloudflare.classes.workermanager.js';
|
||||
import { ZoneManager } from './cloudflare.classes.zonemanager.js';
|
||||
import { RecordManager } from './cloudflare.classes.recordmanager.js';
|
||||
import { ConvenientDnsProvider } from './cloudflare.classes.convenientdnsprovider.js';
|
||||
|
||||
export class CloudflareAccount implements plugins.tsclass.network.IConvenientDnsProvider {
|
||||
private authToken: string;
|
||||
@@ -12,6 +14,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
|
||||
public workerManager = new WorkerManager(this);
|
||||
public zoneManager = new ZoneManager(this);
|
||||
public recordManager = new RecordManager(this);
|
||||
|
||||
public apiAccount: plugins.cloudflare.Cloudflare;
|
||||
|
||||
@@ -133,6 +136,16 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ConvenientDnsProvider instance that implements IConvenientDnsProvider
|
||||
* This allows third-party modules to use the standard DNS provider interface
|
||||
* while internally delegating to the clean RecordManager and ZoneManager structure
|
||||
* @returns ConvenientDnsProvider instance
|
||||
*/
|
||||
public getConvenientDnsProvider(): ConvenientDnsProvider {
|
||||
return new ConvenientDnsProvider(this);
|
||||
}
|
||||
|
||||
public convenience = {
|
||||
/**
|
||||
* Lists all accounts accessible with the current API token
|
||||
@@ -157,6 +170,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
/**
|
||||
* gets a zone id of a domain from cloudflare
|
||||
* @param domainName
|
||||
* @deprecated Use zoneManager.getZoneId() instead
|
||||
*/
|
||||
getZoneId: async (domainName: string) => {
|
||||
const domain = new plugins.smartstring.Domain(domainName);
|
||||
@@ -175,6 +189,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
* gets a record
|
||||
* @param domainNameArg
|
||||
* @param typeArg
|
||||
* @deprecated Use recordManager.getRecord() or getConvenientDnsProvider().getRecord() instead
|
||||
*/
|
||||
getRecord: async (
|
||||
domainNameArg: string,
|
||||
@@ -204,6 +219,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
},
|
||||
/**
|
||||
* creates a record
|
||||
* @deprecated Use recordManager.createRecord() or getConvenientDnsProvider().createRecord() instead
|
||||
*/
|
||||
createRecord: async (
|
||||
domainNameArg: string,
|
||||
@@ -226,6 +242,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
* removes a record from Cloudflare
|
||||
* @param domainNameArg
|
||||
* @param typeArg
|
||||
* @deprecated Use recordManager.deleteRecord() or getConvenientDnsProvider().removeRecord() instead
|
||||
*/
|
||||
removeRecord: async (
|
||||
domainNameArg: string,
|
||||
@@ -251,6 +268,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
|
||||
/**
|
||||
* cleanrecord allows the cleaning of any previous records to avoid unwanted sideeffects
|
||||
* @deprecated Use recordManager.cleanRecords() or getConvenientDnsProvider().cleanRecord() instead
|
||||
*/
|
||||
cleanRecord: async (domainNameArg: string, typeArg: plugins.tsclass.network.TDnsRecordType) => {
|
||||
try {
|
||||
@@ -312,6 +330,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
* @param contentArg New content for the record
|
||||
* @param ttlArg Time to live in seconds (optional)
|
||||
* @returns Updated record
|
||||
* @deprecated Use recordManager.updateRecord() or getConvenientDnsProvider().updateRecord() instead
|
||||
*/
|
||||
updateRecord: async (
|
||||
domainNameArg: string,
|
||||
@@ -348,6 +367,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
/**
|
||||
* list all records of a specified domain name
|
||||
* @param domainNameArg - the domain name that you want to get the records from
|
||||
* @deprecated Use recordManager.listRecords() or getConvenientDnsProvider().listRecords() instead
|
||||
*/
|
||||
listRecords: async (domainNameArg: string) => {
|
||||
try {
|
||||
@@ -372,6 +392,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
/**
|
||||
* list all zones in the associated authenticated account
|
||||
* @param domainName optional filter by domain name
|
||||
* @deprecated Use zoneManager.listZones() instead
|
||||
*/
|
||||
listZones: async (domainName?: string) => {
|
||||
try {
|
||||
@@ -401,6 +422,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
* Determines whether the given domain can be managed by this account
|
||||
* @param domainName Full domain name to check (e.g., "sub.example.com")
|
||||
* @returns True if the zone for the domain exists in the account, false otherwise
|
||||
* @deprecated Use getConvenientDnsProvider().isDomainSupported() instead
|
||||
*/
|
||||
isDomainSupported: async (domainName: string): Promise<boolean> => {
|
||||
try {
|
||||
@@ -417,6 +439,7 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
},
|
||||
/**
|
||||
* purges a zone
|
||||
* @deprecated Use zoneManager.purgeZone() instead
|
||||
*/
|
||||
purgeZone: async (domainName: string): Promise<void> => {
|
||||
const domain = new plugins.smartstring.Domain(domainName);
|
||||
@@ -428,6 +451,9 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
},
|
||||
|
||||
// acme convenience functions
|
||||
/**
|
||||
* @deprecated Use getConvenientDnsProvider().acmeSetDnsChallenge() instead
|
||||
*/
|
||||
acmeSetDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => {
|
||||
await this.convenience.cleanRecord(dnsChallenge.hostName, 'TXT');
|
||||
await this.convenience.createRecord(
|
||||
@@ -437,6 +463,9 @@ export class CloudflareAccount implements plugins.tsclass.network.IConvenientDns
|
||||
120,
|
||||
);
|
||||
},
|
||||
/**
|
||||
* @deprecated Use getConvenientDnsProvider().acmeRemoveDnsChallenge() instead
|
||||
*/
|
||||
acmeRemoveDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => {
|
||||
await this.convenience.removeRecord(dnsChallenge.hostName, 'TXT');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user