Set types for fetched registry records

This commit is contained in:
IshaVenikar 2025-02-03 10:47:45 +05:30
parent 6f32ea4da8
commit 32001b3d5a
4 changed files with 18 additions and 6 deletions

View File

@ -661,7 +661,7 @@ export class Database {
});
if (deployment === null) {
throw new Error(`Error finding DNS data for project with id ${projectId}`);
throw new Error(`DNS deployment not found for project ${projectId}`);
}
return deployment.dnsRecordData;

View File

@ -16,7 +16,7 @@ import {
ApplicationDeploymentRequest,
ApplicationDeploymentRemovalRequest
} from './entity/Deployment';
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord, DNSRecord } from './types';
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord, DNSRecord, RegistryRecord } from './types';
import { getConfig, getRepoDetails, registryTransactionWithRetry, sleep } from './utils';
const log = debug('snowball:registry');
@ -444,8 +444,13 @@ export class Registry {
/**
* Fetch record by Id
*/
async getRecordById(id: string): Promise<any[]> {
return this.registry.getRecordsByIds([id]);
async getRecordById(id: string): Promise<RegistryRecord | null> {
const record = await this.registry.getRecordsByIds([id]);
if (record.length === 0) {
return null;
}
return record[0];
}
async createApplicationDeploymentRemovalRequest(data: {

View File

@ -203,7 +203,14 @@ export class Service {
return;
}
const dnsRecord: DNSRecord = (await this.laconicRegistry.getRecordById(record.attributes.dns))[0];
const registryRecord = await this.laconicRegistry.getRecordById(record.attributes.dns);
if (!registryRecord) {
log(`DNS record not found for deployment ${deployment.id}`);
return;
}
const dnsRecord = registryRecord as DNSRecord;
const dnsRecordData: DNSRecordAttributes = {
name: dnsRecord.attributes.name,

View File

@ -55,7 +55,7 @@ export interface AppDeploymentRemovalRecordAttributes {
version: string;
}
interface RegistryRecord {
export interface RegistryRecord {
id: string;
names: string[] | null;
owners: string[];