Adjust how multi record items are stored

This commit is contained in:
Owen
2026-10-28 13:42:59 -04:00
parent a44e1c927d
commit c64fd9cce6
12 changed files with 459 additions and 183 deletions
+22 -5
View File
@@ -10,13 +10,16 @@ export const CUSTOM_DNS_RECORD_TYPES = [
export type CustomDnsRecordType = (typeof CUSTOM_DNS_RECORD_TYPES)[number];
// One record as the user sees it: a name, type and settings with one or more
// values (e.g. both nameservers of an NS record). The DNS server answers with
// one resource record per value.
export type CustomDnsRecordRow = {
customDnsRecordId: number;
domainId: string;
name: string;
fullDomain: string;
type: CustomDnsRecordType;
value: string;
values: string[];
ttl: number;
priority: number | null;
weight: number | null;
@@ -30,8 +33,22 @@ export type ListCustomDnsRecordsResponse = {
records: CustomDnsRecordRow[];
};
export type CreateCustomDnsRecordsResponse = {
records: CustomDnsRecordRow[];
};
export type CreateOrUpdateCustomDnsRecordResponse = CustomDnsRecordRow;
export type UpdateCustomDnsRecordResponse = CustomDnsRecordRow;
// The values column holds a JSON-encoded string array
export function parseCustomDnsRecordValues(raw: string): string[] {
try {
const parsed = JSON.parse(raw);
return Array.isArray(parsed)
? parsed.filter((v): v is string => typeof v === "string")
: [];
} catch {
return [];
}
}
export function toCustomDnsRecordRow(
row: Omit<CustomDnsRecordRow, "values"> & { values: string }
): CustomDnsRecordRow {
return { ...row, values: parseCustomDnsRecordValues(row.values) };
}