forked from cerc-io/snowballtools-base
Set types for fetched registry records
This commit is contained in:
parent
6f32ea4da8
commit
32001b3d5a
@ -661,7 +661,7 @@ export class Database {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (deployment === null) {
|
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;
|
return deployment.dnsRecordData;
|
||||||
|
@ -16,7 +16,7 @@ import {
|
|||||||
ApplicationDeploymentRequest,
|
ApplicationDeploymentRequest,
|
||||||
ApplicationDeploymentRemovalRequest
|
ApplicationDeploymentRemovalRequest
|
||||||
} from './entity/Deployment';
|
} 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';
|
import { getConfig, getRepoDetails, registryTransactionWithRetry, sleep } from './utils';
|
||||||
|
|
||||||
const log = debug('snowball:registry');
|
const log = debug('snowball:registry');
|
||||||
@ -444,8 +444,13 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Fetch record by Id
|
* Fetch record by Id
|
||||||
*/
|
*/
|
||||||
async getRecordById(id: string): Promise<any[]> {
|
async getRecordById(id: string): Promise<RegistryRecord | null> {
|
||||||
return this.registry.getRecordsByIds([id]);
|
const record = await this.registry.getRecordsByIds([id]);
|
||||||
|
if (record.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return record[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async createApplicationDeploymentRemovalRequest(data: {
|
async createApplicationDeploymentRemovalRequest(data: {
|
||||||
|
@ -203,7 +203,14 @@ export class Service {
|
|||||||
return;
|
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 = {
|
const dnsRecordData: DNSRecordAttributes = {
|
||||||
name: dnsRecord.attributes.name,
|
name: dnsRecord.attributes.name,
|
||||||
|
@ -55,7 +55,7 @@ export interface AppDeploymentRemovalRecordAttributes {
|
|||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RegistryRecord {
|
export interface RegistryRecord {
|
||||||
id: string;
|
id: string;
|
||||||
names: string[] | null;
|
names: string[] | null;
|
||||||
owners: string[];
|
owners: string[];
|
||||||
|
Loading…
Reference in New Issue
Block a user