Make proper, cohesive TargetType/SimplifiedTargetType types

why didn't I do this before? maybe i'll find out soon
This commit is contained in:
2024-05-10 01:47:59 -05:00
parent d819920f8a
commit abab1b357b
2 changed files with 15 additions and 7 deletions

View File

@@ -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(

View File

@@ -7,15 +7,20 @@ import type {
IpNetworkSchema,
LinkSchema,
NameserverSchema,
ObjectTypeEnum,
TargetTypeEnum,
RegisterSchema,
StatusEnum,
RootRegistryEnum,
} from "@/schema";
export type ObjectType = z.infer<typeof ObjectTypeEnum>;
// All precise target types that can be placed in the search bar.
export type TargetType = z.infer<typeof TargetTypeEnum>;
// 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<TargetType, "ip4" | "ip6"> | "ip";
// Root registry types that associate with a bootstrap file provided by the RDAP registry.
export type RootRegistryType = z.infer<typeof RootRegistryEnum>;
export type TargetType = Exclude<ObjectType, "ip"> | "ip4" | "ip6";
export type RdapStatusType = z.infer<typeof StatusEnum>;
export type Link = z.infer<typeof LinkSchema>;