diff --git a/src/responses.ts b/src/responses.ts index 3181004..44c1c5d 100644 --- a/src/responses.ts +++ b/src/responses.ts @@ -4,11 +4,13 @@ export const ObjectTypeEnum = z.enum(['ip', 'autnum', 'entity', 'url', 'tld', 'r export const StatusEnum = z.enum(["validated", "renew prohibited", "update prohibited", "transfer prohibited", "delete prohibited", "proxy", "private", "removed", "obscured", "associated", "active", "inactive", "locked", "pending create", "pending renew", "pending transfer", "pending update", "pending delete", "add period", "auto renew period", "client delete prohibited", "client hold", "client renew prohibited", "client transfer prohibited", "client update prohibited", "pending restore", "redemption period", "renew period", "server delete prohibited", "server renew prohibited", "server transfer prohibited", "server update prohibited", "server hold", "transfer period"]) export const LinkSchema = z.object({ - value: z.string(), + value: z.string().optional(), rel: z.string(), href: z.string(), type: z.string() }) +export type Link = z.infer; + export const EntitySchema = z.object({ objectClassName: z.literal('entity'), @@ -17,36 +19,82 @@ export const EntitySchema = z.object({ publicIds: z.array(z.object({ type: z.string(), identifier: z.string(), - })) + })).optional() }) +export type Entity = z.infer; export const NameserverSchema = z.object({ objectClassName: z.literal('nameserver'), ldhName: z.string() }) +export type Nameserver = z.infer; + export const EventSchema = z.object({ eventAction: z.string(), - eventDate: z.date() + eventActor: z.string().optional(), + eventDate: z.string() }) +export type Event = z.infer; + export const NoticeSchema = z.object({ - title: z.string(), + title: z.string().optional(), description: z.string().array(), links: z.array(z.object({ href: z.string(), - tpye: z.string() - })) + type: z.string() + })).optional() }) +export type Notice = z.infer; + +export const IpNetworkSchema = z.object({ + objectClassName: z.literal('ip network'), + handle: z.string(), + startAddress: z.string(), + endAddress: z.string(), + ipVersion: z.enum(['v4', 'v6']), + name: z.string(), + type: z.string(), + country: z.string(), + parentHandle: z.string(), + status: z.string().array(), + entities: z.array(EntitySchema), + remarks: z.any(), + links: z.any(), + port43: z.any().optional(), + events: z.array(EventSchema) +}) +export type IpNetwork = z.infer; + + +export const AutonomousNumberSchema = z.object({ + objectClassName: z.literal('autnum'), + handle: z.string(), + startAutnum: z.number().positive(), // TODO: 32bit + endAutnum: z.number().positive(), // TODO: 32bit + name: z.string(), + type: z.string(), + status: z.array(z.string()), + country: z.string().length(2), + events: z.array(EventSchema), + entities: z.array(EntitySchema), + roles: z.array(z.string()), + links: z.array(LinkSchema) +}) +export type AutonomousNumber = z.infer; export const DomainSchema = z.object({ objectClassName: z.literal('domain'), handle: z.string(), ldhName: z.string(), - links: z.array(LinkSchema), + unicodeName: z.string().optional(), + links: z.array(LinkSchema).optional(), status: z.array(StatusEnum), entities: z.array(EntitySchema), events: z.array(EventSchema), - secureDNS: z.any(), // TODO: Complete + secureDNS: z.any(), // TODO: Complete schema nameservers: z.array(NameserverSchema), rdapConformance: z.string().array(), // TODO: Complete notices: z.array(NoticeSchema), -}) \ No newline at end of file + network: IpNetworkSchema.optional(), +}) +export type Domain = z.infer; \ No newline at end of file