mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-06 01:16:00 -06:00
refactor: reorganize project structure and consolidate test files
Consolidate test files into centralized __tests__ directory with clearer naming. Rename utility modules for improved clarity and consistency. Rename Generic component to RdapObjectRouter to better reflect purpose.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { serializeQueryToUrl, deserializeUrlToQuery, buildShareableUrl } from "@/lib/url-utils";
|
||||
import { serializeQueryToUrl, deserializeUrlToQuery, buildShareableUrl } from "@/lib/urls";
|
||||
|
||||
describe("URL Utilities", () => {
|
||||
describe("serializeQueryToUrl", () => {
|
||||
@@ -4,8 +4,8 @@ import { useBoolean } from "usehooks-ts";
|
||||
import { Link2Icon, CodeIcon, DownloadIcon } from "@radix-ui/react-icons";
|
||||
import { Card, Flex, Box, IconButton, Code, Tooltip } from "@radix-ui/themes";
|
||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-react";
|
||||
import type { ParsedGeneric } from "@/rdap/components/Generic";
|
||||
import { generateDownloadFilename } from "@/utils/generateFilename";
|
||||
import type { ParsedGeneric } from "@/rdap/components/RdapObjectRouter";
|
||||
import { generateDownloadFilename } from "@/lib/filename";
|
||||
import CopyButton from "@/components/CopyButton";
|
||||
|
||||
type AbstractCardProps = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ParsedGeneric } from "@/rdap/components/Generic";
|
||||
import type { ParsedGeneric } from "@/rdap/components/RdapObjectRouter";
|
||||
|
||||
/**
|
||||
* Attempts to convert an IP range to CIDR notation
|
||||
@@ -2,7 +2,7 @@ import { type NextPage } from "next";
|
||||
import Head from "next/head";
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import Generic from "@/rdap/components/Generic";
|
||||
import RdapObjectRouter from "@/rdap/components/RdapObjectRouter";
|
||||
import type { MetaParsedGeneric } from "@/rdap/hooks/useLookup";
|
||||
import useLookup from "@/rdap/hooks/useLookup";
|
||||
import LookupInput from "@/rdap/components/LookupInput";
|
||||
@@ -12,7 +12,7 @@ import { Maybe } from "true-myth";
|
||||
import { Flex, Container, Section, Text, Link, IconButton } from "@radix-ui/themes";
|
||||
import { GitHubLogoIcon } from "@radix-ui/react-icons";
|
||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-react";
|
||||
import { serializeQueryToUrl, deserializeUrlToQuery, buildShareableUrl } from "@/lib/url-utils";
|
||||
import { serializeQueryToUrl, deserializeUrlToQuery, buildShareableUrl } from "@/lib/urls";
|
||||
import type { TargetType } from "@/rdap/schemas";
|
||||
|
||||
const Index: NextPage = () => {
|
||||
@@ -172,7 +172,7 @@ const Index: NextPage = () => {
|
||||
/>
|
||||
) : null}
|
||||
{response.isJust ? (
|
||||
<Generic
|
||||
<RdapObjectRouter
|
||||
url={response.value.url}
|
||||
data={response.value.data}
|
||||
queryTimestamp={response.value.completeTime}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useForm } from "react-hook-form";
|
||||
import type { FunctionComponent } from "react";
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { onPromise, preventDefault } from "@/lib/utils";
|
||||
import { onPromise, preventDefault } from "@/lib/misc";
|
||||
import type { SimplifiedTargetType, SubmitProps, TargetType } from "@/rdap/schemas";
|
||||
import { TargetTypeEnum } from "@/rdap/schemas";
|
||||
import { MagnifyingGlassIcon, ReloadIcon, LockClosedIcon } from "@radix-ui/react-icons";
|
||||
|
||||
@@ -15,7 +15,11 @@ export type ObjectProps = {
|
||||
queryTimestamp?: Date;
|
||||
};
|
||||
|
||||
const Generic: FunctionComponent<ObjectProps> = ({ data, url, queryTimestamp }: ObjectProps) => {
|
||||
const RdapObjectRouter: FunctionComponent<ObjectProps> = ({
|
||||
data,
|
||||
url,
|
||||
queryTimestamp,
|
||||
}: ObjectProps) => {
|
||||
const objectClassName = data.objectClassName;
|
||||
|
||||
switch (objectClassName) {
|
||||
@@ -38,4 +42,4 @@ const Generic: FunctionComponent<ObjectProps> = ({ data, url, queryTimestamp }:
|
||||
}
|
||||
};
|
||||
|
||||
export default Generic;
|
||||
export default RdapObjectRouter;
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useDebouncedValue } from "@mantine/hooks";
|
||||
import type { SubmitProps, TargetType } from "@/rdap/schemas";
|
||||
import { RootRegistryEnum } from "@/rdap/schemas";
|
||||
import type { ParsedGeneric } from "@/rdap/components/Generic";
|
||||
import type { ParsedGeneric } from "@/rdap/components/RdapObjectRouter";
|
||||
import { Maybe, Result } from "true-myth";
|
||||
import { loadBootstrap, getRegistry } from "@/rdap/services/registry";
|
||||
import {
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
generateValidationWarning,
|
||||
generateBootstrapWarning,
|
||||
} from "@/rdap/services/type-detection";
|
||||
import { executeRdapQuery, HttpSecurityError } from "@/rdap/services/rdap-query";
|
||||
import { executeRdapQuery, HttpSecurityError } from "@/rdap/services/query";
|
||||
|
||||
export type WarningHandler = (warning: { message: string }) => void;
|
||||
export type UrlUpdateHandler = (target: string, manuallySelectedType: TargetType | null) => void;
|
||||
|
||||
@@ -7,9 +7,9 @@ import {
|
||||
} from "@/rdap/schemas";
|
||||
import { Result } from "true-myth";
|
||||
import { loadBootstrap } from "@/rdap/services/registry";
|
||||
import { getRegistryURL } from "@/rdap/services/url-resolver";
|
||||
import { getAndParse } from "@/rdap/services/rdap-api";
|
||||
import type { ParsedGeneric } from "@/rdap/components/Generic";
|
||||
import { getRegistryURL } from "@/rdap/services/resolver";
|
||||
import { getAndParse } from "@/rdap/services/api";
|
||||
import type { ParsedGeneric } from "@/rdap/components/RdapObjectRouter";
|
||||
|
||||
// An array of schemas to try and parse unknown JSON data with.
|
||||
const schemas = [DomainSchema, AutonomousNumberSchema, IpNetworkSchema, EntitySchema];
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Register, RootRegistryType, TargetType } from "@/rdap/schemas";
|
||||
import { getType, validateInputForType } from "@/rdap/utils";
|
||||
import type { Result } from "true-myth";
|
||||
import { truncated } from "@/lib/utils";
|
||||
import { truncated } from "@/lib/misc";
|
||||
|
||||
/**
|
||||
* Detect the target type for a given input string.
|
||||
|
||||
Reference in New Issue
Block a user