mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Fix records query
This commit is contained in:
@@ -21,7 +21,8 @@ interface DNSMadeEasyApiResponse {
|
|||||||
data: Array<{
|
data: Array<{
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
[key: string]: unknown;
|
type: string;
|
||||||
|
value: string;
|
||||||
}>;
|
}>;
|
||||||
page: number;
|
page: number;
|
||||||
}
|
}
|
||||||
@@ -124,7 +125,6 @@ export const listDNSMadeEasyRecords = async (
|
|||||||
if (appConnection.method !== DNSMadeEasyConnectionMethod.APIKeySecret) {
|
if (appConnection.method !== DNSMadeEasyConnectionMethod.APIKeySecret) {
|
||||||
throw new Error("Unsupported DNS Made Easy connection method");
|
throw new Error("Unsupported DNS Made Easy connection method");
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
credentials: { apiKey, secretKey }
|
credentials: { apiKey, secretKey }
|
||||||
} = appConnection;
|
} = appConnection;
|
||||||
@@ -138,14 +138,14 @@ export const listDNSMadeEasyRecords = async (
|
|||||||
// Fetch all pages of records
|
// Fetch all pages of records
|
||||||
while (currentPage < totalPages) {
|
while (currentPage < totalPages) {
|
||||||
// Build query parameters
|
// Build query parameters
|
||||||
const queryParams: Array<[string, string | number]> = [];
|
const queryParams: Record<string, string | number> = {};
|
||||||
if (type) {
|
if (type) {
|
||||||
queryParams.push(["type", type]);
|
queryParams.type = type;
|
||||||
}
|
}
|
||||||
if (name) {
|
if (name) {
|
||||||
queryParams.push(["recordName", name]);
|
queryParams.recordName = name;
|
||||||
}
|
}
|
||||||
queryParams.push(["page", currentPage]);
|
queryParams.page = currentPage;
|
||||||
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
const resp = await request.get<DNSMadeEasyApiResponse>(
|
const resp = await request.get<DNSMadeEasyApiResponse>(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { request } from "@app/lib/config/request";
|
|||||||
import { logger } from "@app/lib/logger";
|
import { logger } from "@app/lib/logger";
|
||||||
import {
|
import {
|
||||||
getDNSMadeEasyUrl,
|
getDNSMadeEasyUrl,
|
||||||
|
listDNSMadeEasyRecords,
|
||||||
makeDNSMadeEasyAuthHeaders
|
makeDNSMadeEasyAuthHeaders
|
||||||
} from "@app/services/app-connection/dns-made-easy/dns-made-easy-connection-fns";
|
} from "@app/services/app-connection/dns-made-easy/dns-made-easy-connection-fns";
|
||||||
import { TDNSMadeEasyConnection } from "@app/services/app-connection/dns-made-easy/dns-made-easy-connection-types";
|
import { TDNSMadeEasyConnection } from "@app/services/app-connection/dns-made-easy/dns-made-easy-connection-types";
|
||||||
@@ -67,21 +68,7 @@ export const dnsMadeEasyDeleteTxtRecord = async (
|
|||||||
|
|
||||||
logger.info({ hostedZoneId, domain }, "Deleting TXT record for DNS Made Easy");
|
logger.info({ hostedZoneId, domain }, "Deleting TXT record for DNS Made Easy");
|
||||||
try {
|
try {
|
||||||
// First, list records to find the record ID
|
const dnsRecords = await listDNSMadeEasyRecords(connection, { zoneId: hostedZoneId, type: "TXT", name: domain });
|
||||||
const listRecordsResponse = await request.get<{
|
|
||||||
data: Array<{ id: number; type: string; name: string; value: string }>;
|
|
||||||
}>(getDNSMadeEasyUrl(`/V2.0/dns/managed/${encodeURIComponent(hostedZoneId)}/records`), {
|
|
||||||
headers: {
|
|
||||||
...makeDNSMadeEasyAuthHeaders(apiKey, secretKey),
|
|
||||||
Accept: "application/json"
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
type: "TXT",
|
|
||||||
recordName: domain
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const dnsRecords = listRecordsResponse.data?.data;
|
|
||||||
|
|
||||||
if (Array.isArray(dnsRecords) && dnsRecords.length > 0) {
|
if (Array.isArray(dnsRecords) && dnsRecords.length > 0) {
|
||||||
const recordToDelete = dnsRecords.find(
|
const recordToDelete = dnsRecords.find(
|
||||||
|
|||||||
Reference in New Issue
Block a user