mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-08 08:08:13 -06:00
Make proper, cohesive TargetType/SimplifiedTargetType types
why didn't I do this before? maybe i'll find out soon
This commit is contained in:
@@ -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(
|
||||
|
||||
11
src/types.ts
11
src/types.ts
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user