Add IpNetwork, update schema after battle testing, add inferred types

This commit is contained in:
Xevion
2023-01-15 00:04:57 -06:00
parent 34819bd195
commit 65cf8ba83c
+56 -8
View File
@@ -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 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({ export const LinkSchema = z.object({
value: z.string(), value: z.string().optional(),
rel: z.string(), rel: z.string(),
href: z.string(), href: z.string(),
type: z.string() type: z.string()
}) })
export type Link = z.infer<typeof LinkSchema>;
export const EntitySchema = z.object({ export const EntitySchema = z.object({
objectClassName: z.literal('entity'), objectClassName: z.literal('entity'),
@@ -17,36 +19,82 @@ export const EntitySchema = z.object({
publicIds: z.array(z.object({ publicIds: z.array(z.object({
type: z.string(), type: z.string(),
identifier: z.string(), identifier: z.string(),
})) })).optional()
}) })
export type Entity = z.infer<typeof EntitySchema>;
export const NameserverSchema = z.object({ export const NameserverSchema = z.object({
objectClassName: z.literal('nameserver'), objectClassName: z.literal('nameserver'),
ldhName: z.string() ldhName: z.string()
}) })
export type Nameserver = z.infer<typeof NameserverSchema>;
export const EventSchema = z.object({ export const EventSchema = z.object({
eventAction: z.string(), eventAction: z.string(),
eventDate: z.date() eventActor: z.string().optional(),
eventDate: z.string()
}) })
export type Event = z.infer<typeof EventSchema>;
export const NoticeSchema = z.object({ export const NoticeSchema = z.object({
title: z.string(), title: z.string().optional(),
description: z.string().array(), description: z.string().array(),
links: z.array(z.object({ links: z.array(z.object({
href: z.string(), href: z.string(),
tpye: z.string() type: z.string()
})) })).optional()
}) })
export type Notice = z.infer<typeof NoticeSchema>;
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<typeof IpNetworkSchema>;
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<typeof AutonomousNumberSchema>;
export const DomainSchema = z.object({ export const DomainSchema = z.object({
objectClassName: z.literal('domain'), objectClassName: z.literal('domain'),
handle: z.string(), handle: z.string(),
ldhName: z.string(), ldhName: z.string(),
links: z.array(LinkSchema), unicodeName: z.string().optional(),
links: z.array(LinkSchema).optional(),
status: z.array(StatusEnum), status: z.array(StatusEnum),
entities: z.array(EntitySchema), entities: z.array(EntitySchema),
events: z.array(EventSchema), events: z.array(EventSchema),
secureDNS: z.any(), // TODO: Complete secureDNS: z.any(), // TODO: Complete schema
nameservers: z.array(NameserverSchema), nameservers: z.array(NameserverSchema),
rdapConformance: z.string().array(), // TODO: Complete rdapConformance: z.string().array(), // TODO: Complete
notices: z.array(NoticeSchema), notices: z.array(NoticeSchema),
network: IpNetworkSchema.optional(),
}) })
export type Domain = z.infer<typeof DomainSchema>;