From abab1b357b6f15fd28b6ba24de750293dbadfe90 Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 10 May 2024 01:47:59 -0500 Subject: [PATCH] Make proper, cohesive TargetType/SimplifiedTargetType types why didn't I do this before? maybe i'll find out soon --- src/schema.ts | 11 +++++++---- src/types.ts | 11 ++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/schema.ts b/src/schema.ts index edcb65a..e7a2e80 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -1,15 +1,17 @@ import { z } from "zod"; -export const ObjectTypeEnum = z.enum([ - "ip", +export const TargetTypeEnum = z.enum([ "autnum", + "domain", + "ip4", + "ip6", "entity", "url", "tld", "registrar", "json", - "domain", ]); + export const RootRegistryEnum = z.enum([ "autnum", "domain", @@ -17,6 +19,7 @@ export const RootRegistryEnum = z.enum([ "ip6", "entity", ]); + export const StatusEnum = z.enum([ "validated", "renew prohibited", @@ -63,7 +66,7 @@ export const LinkSchema = z.object({ export const EntitySchema = z.object({ objectClassName: z.literal("entity"), - handle: z.string(), + handle: z.string().optional(), roles: z.array(z.string()), publicIds: z .array( diff --git a/src/types.ts b/src/types.ts index 53545d7..5535735 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,15 +7,20 @@ import type { IpNetworkSchema, LinkSchema, NameserverSchema, - ObjectTypeEnum, + TargetTypeEnum, RegisterSchema, StatusEnum, RootRegistryEnum, } from "@/schema"; -export type ObjectType = z.infer; +// All precise target types that can be placed in the search bar. +export type TargetType = z.infer; + +// Target types that can be selected by the user; IPv4 and IPv6 are combined into a single type for simplicity (IP/CIDR) +export type SimplifiedTargetType = Exclude | "ip"; + +// Root registry types that associate with a bootstrap file provided by the RDAP registry. export type RootRegistryType = z.infer; -export type TargetType = Exclude | "ip4" | "ip6"; export type RdapStatusType = z.infer; export type Link = z.infer;