From 611074b5463ea884d919007b3c779cded9c5b142 Mon Sep 17 00:00:00 2001 From: Xevion Date: Wed, 22 Oct 2025 11:02:50 -0500 Subject: [PATCH] feat: implement Entity and Nameserver cards with type safety improvements - Add EntityCard component to display entity information with handle, roles, and public IDs - Add NameserverCard component to display nameserver details - Integrate new cards into Generic component for proper object rendering - Remove unused dependencies (immutability-helper, type-fest) - Enhance type safety in LookupInput with Zod validation - Replace console.log statements with appropriate comments - Initialize registryDataRef with proper typed default values - Remove unused code and debug logging from rdap.ts and useLookup hook - Update Object.entries type definition without external dependency --- package.json | 2 - pnpm-lock.yaml | 25 - src/components/common/AbstractCard.tsx | 2 +- src/components/form/LookupInput.tsx | 7 +- src/components/lookup/EntityCard.tsx | 50 ++ src/components/lookup/Generic.tsx | 10 +- src/components/lookup/NameserverCard.tsx | 34 ++ src/helpers.ts | 3 +- src/hooks/useLookup.tsx | 18 +- src/rdap.ts | 740 ----------------------- 10 files changed, 106 insertions(+), 785 deletions(-) create mode 100644 src/components/lookup/EntityCard.tsx create mode 100644 src/components/lookup/NameserverCard.tsx diff --git a/package.json b/package.json index f96c30a..dc94e23 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "@swc/helpers": "^0.5.11", "clsx": "^2.1.1", "date-fns": "^4.1.0", - "immutability-helper": "^3.1.1", "next": "^15.5.6", "react": "19.2.0", "react-dom": "19.2.0", @@ -64,7 +63,6 @@ "prettier-plugin-tailwindcss": "^0.7.1", "semantic-release": "^24.0.0", "tailwindcss": "^4.1.15", - "type-fest": "^5.1.0", "typescript": "^5.9.3", "vitest": "^3.2.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43c3f6b..d8b9c6b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,9 +29,6 @@ importers: date-fns: specifier: ^4.1.0 version: 4.1.0 - immutability-helper: - specifier: ^3.1.1 - version: 3.1.1 next: specifier: ^15.5.6 version: 15.5.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0)(sass@1.93.2) @@ -135,9 +132,6 @@ importers: tailwindcss: specifier: ^4.1.15 version: 4.1.15 - type-fest: - specifier: ^5.1.0 - version: 5.1.0 typescript: specifier: ^5.9.3 version: 5.9.3 @@ -2372,9 +2366,6 @@ packages: resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} engines: {node: '>= 4'} - immutability-helper@3.1.1: - resolution: {integrity: sha512-Q0QaXjPjwIju/28TsugCHNEASwoCcJSyJV3uO1sOIQGI0jKgm9f41Lvz0DZj3n46cNCyAZTsEYoY4C2bVRUzyQ==} - immutable@5.1.4: resolution: {integrity: sha512-p6u1bG3YSnINT5RQmx/yRZBpenIl30kVxkTLDyHLIMk0gict704Q9n+thfDI7lTRm9vXdDYutVzXhzcThxTnXA==} @@ -3712,10 +3703,6 @@ packages: tabbable@6.2.0: resolution: {integrity: sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==} - tagged-tag@1.0.0: - resolution: {integrity: sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==} - engines: {node: '>=20'} - tailwind-merge@3.3.1: resolution: {integrity: sha512-gBXpgUm/3rp1lMZZrM/w7D8GKqshif0zAymAhbCyIt8KMe+0v9DQ7cdYLR4FHH/cKpdTXb+A/tKKU3eolfsI+g==} @@ -3824,10 +3811,6 @@ packages: resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==} engines: {node: '>=16'} - type-fest@5.1.0: - resolution: {integrity: sha512-wQ531tuWvB6oK+pchHIu5lHe5f5wpSCqB8Kf4dWQRbOYc9HTge7JL0G4Qd44bh6QuJCccIzL3bugb8GI0MwHrg==} - engines: {node: '>=20'} - typed-array-buffer@1.0.3: resolution: {integrity: sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==} engines: {node: '>= 0.4'} @@ -6413,8 +6396,6 @@ snapshots: ignore@7.0.5: {} - immutability-helper@3.1.1: {} - immutable@5.1.4: {} import-fresh@3.3.1: @@ -7674,8 +7655,6 @@ snapshots: tabbable@6.2.0: {} - tagged-tag@1.0.0: {} - tailwind-merge@3.3.1: {} tailwindcss@4.1.15: {} @@ -7762,10 +7741,6 @@ snapshots: type-fest@4.41.0: {} - type-fest@5.1.0: - dependencies: - tagged-tag: 1.0.0 - typed-array-buffer@1.0.3: dependencies: call-bound: 1.0.4 diff --git a/src/components/common/AbstractCard.tsx b/src/components/common/AbstractCard.tsx index 2db294b..2443a1e 100644 --- a/src/components/common/AbstractCard.tsx +++ b/src/components/common/AbstractCard.tsx @@ -47,7 +47,7 @@ const AbstractCard: FunctionComponent = ({ .writeText(JSON.stringify(data, null, 4)) .then( () => { - console.log("Copied to clipboard."); + // Successfully copied to clipboard }, (err) => { if (err instanceof Error) diff --git a/src/components/form/LookupInput.tsx b/src/components/form/LookupInput.tsx index 5503e96..f0a58ce 100644 --- a/src/components/form/LookupInput.tsx +++ b/src/components/form/LookupInput.tsx @@ -3,6 +3,7 @@ import type { FunctionComponent } from "react"; import { Fragment, useState } from "react"; import { onPromise, preventDefault } from "@/helpers"; import type { SimplifiedTargetType, SubmitProps, TargetType } from "@/types"; +import { TargetTypeEnum } from "@/schema"; import { CheckIcon, ChevronUpDownIcon, @@ -109,7 +110,9 @@ const LookupInput: FunctionComponent = ({ // 'auto' means 'do whatever' so we return null. if (value == "auto") return null; - return value as TargetType; + // Validate the value is a valid TargetType + const result = TargetTypeEnum.safeParse(value); + return result.success ? result.data : null; } const searchIcon = ( @@ -250,7 +253,7 @@ const LookupInput: FunctionComponent = ({