Replaced tsconfig.build.json with tsdown configuration for simplified builds.

This commit is contained in:
2025-09-28 21:30:57 -04:00
parent d09d8e4ffd
commit c76da2bf5c
20 changed files with 826 additions and 868 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
/** biome-ignore-all lint/style/noNonNullAssertion: this is fine for tests */
import { expect, test } from "vitest";
import { isAvailable, isRegistered, lookupDomain } from "./index.js";
import { isAvailable, isRegistered, lookupDomain } from ".";
// Run only when SMOKE=1 to avoid flakiness and network in CI by default
const shouldRun = process.env.SMOKE === "1";
+6 -6
View File
@@ -37,12 +37,12 @@ vi.mock("./lib/domain.js", async () => {
};
});
import { lookupDomain } from "./index.js";
import * as domain from "./lib/domain.js";
import * as rdapClient from "./rdap/client.js";
import type { WhoisQueryResult } from "./whois/client.js";
import * as whoisClient from "./whois/client.js";
import * as discovery from "./whois/discovery.js";
import { lookupDomain } from ".";
import * as domain from "./lib/domain";
import * as rdapClient from "./rdap/client";
import type { WhoisQueryResult } from "./whois/client";
import * as whoisClient from "./whois/client";
import * as discovery from "./whois/discovery";
// 1) Orchestration tests (RDAP path, fallback, whoisOnly)
describe("lookupDomain orchestration", () => {
+13 -15
View File
@@ -1,18 +1,18 @@
import { toISO } from "./lib/dates.js";
import { getDomainParts, isLikelyDomain } from "./lib/domain.js";
import { getRdapBaseUrlsForTld } from "./rdap/bootstrap.js";
import { fetchRdapDomain } from "./rdap/client.js";
import { normalizeRdap } from "./rdap/normalize.js";
import type { DomainRecord, LookupOptions, LookupResult } from "./types.js";
import { whoisQuery } from "./whois/client.js";
import { toISO } from "./lib/dates";
import { getDomainParts, isLikelyDomain } from "./lib/domain";
import { getRdapBaseUrlsForTld } from "./rdap/bootstrap";
import { fetchRdapDomain } from "./rdap/client";
import { normalizeRdap } from "./rdap/normalize";
import type { DomainRecord, LookupOptions, LookupResult } from "./types";
import { whoisQuery } from "./whois/client";
import {
extractWhoisReferral,
ianaWhoisServerForTld,
getIanaWhoisTextForTld,
ianaWhoisServerForTld,
parseIanaRegistrationInfoUrl,
} from "./whois/discovery.js";
import { normalizeWhois } from "./whois/normalize.js";
import { WHOIS_TLD_EXCEPTIONS } from "./whois/servers.js";
} from "./whois/discovery";
import { normalizeWhois } from "./whois/normalize";
import { WHOIS_TLD_EXCEPTIONS } from "./whois/servers";
/**
* High-level lookup that prefers RDAP and falls back to WHOIS.
@@ -69,9 +69,7 @@ export async function lookupDomain(
const regUrl = ianaText
? parseIanaRegistrationInfoUrl(ianaText)
: undefined;
const hint = regUrl
? ` See registration info at ${regUrl}.`
: "";
const hint = regUrl ? ` See registration info at ${regUrl}.` : "";
return {
ok: false,
error: `No WHOIS server discovered for TLD '${tld}'. This registry may not publish public WHOIS over port 43.${hint}`,
@@ -150,4 +148,4 @@ export async function isRegistered(
return res.record.isRegistered === true;
}
export type * from "./types.js";
export type * from "./types";
+1 -1
View File
@@ -1,7 +1,7 @@
/** biome-ignore-all lint/style/noNonNullAssertion: this is fine for tests */
import { expect, test } from "vitest";
import { toISO } from "./dates.js";
import { toISO } from "./dates";
test("toISO parses ISO and common whois formats", () => {
const iso = toISO("2023-01-02T03:04:05Z");
+1 -1
View File
@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { extractTld, isLikelyDomain } from "./domain.js";
import { extractTld, isLikelyDomain } from "./domain";
test("extractTld basic", () => {
expect(extractTld("example.com")).toBe("com");
+3 -3
View File
@@ -1,6 +1,6 @@
import { withTimeout } from "../lib/async.js";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
import type { LookupOptions } from "../types.js";
import { withTimeout } from "../lib/async";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
import type { LookupOptions } from "../types";
// Use global fetch (Node 18+). For large JSON we keep it simple.
+3 -3
View File
@@ -1,6 +1,6 @@
import { withTimeout } from "../lib/async.js";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
import type { LookupOptions } from "../types.js";
import { withTimeout } from "../lib/async";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
import type { LookupOptions } from "../types";
// Use global fetch (Node 18+). For large JSON we keep it simple.
+1 -1
View File
@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { normalizeRdap } from "./normalize.js";
import { normalizeRdap } from "./normalize";
test("normalizeRdap maps registrar, contacts, nameservers, events, dnssec", () => {
const rdap = {
+3 -10
View File
@@ -1,11 +1,11 @@
import { toISO } from "../lib/dates.js";
import { asDateLike, asString, asStringArray, uniq } from "../lib/text.js";
import { toISO } from "../lib/dates";
import { asDateLike, asString, asStringArray, uniq } from "../lib/text";
import type {
Contact,
DomainRecord,
Nameserver,
RegistrarInfo,
} from "../types.js";
} from "../types";
type RdapDoc = Record<string, unknown>;
@@ -22,12 +22,6 @@ export function normalizeRdap(
includeRaw = false,
): DomainRecord {
const doc = (rdap ?? {}) as RdapDoc;
// Safe helpers for optional fields
const _get = (obj: unknown, path: string[]): unknown =>
path.reduce<unknown>(
(o, k) => ((o as RdapDoc)?.[k] as unknown) ?? undefined,
obj,
);
// Prefer ldhName (punycode) and unicodeName if provided
const ldhName: string | undefined =
@@ -254,7 +248,6 @@ function parseVcard(vcardArray: unknown): ParsedVCard {
const out: ParsedVCard = {};
for (const e of entries) {
const key = e?.[0];
const _valueType = e?.[2];
const value = e?.[3];
if (!key) continue;
switch (String(key).toLowerCase()) {
+3 -3
View File
@@ -1,7 +1,7 @@
import { createConnection } from "node:net";
import { withTimeout } from "../lib/async.js";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
import type { LookupOptions } from "../types.js";
import { withTimeout } from "../lib/async";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
import type { LookupOptions } from "../types";
export interface WhoisQueryResult {
serverQueried: string;
+4 -6
View File
@@ -1,6 +1,6 @@
import type { LookupOptions } from "../types.js";
import { whoisQuery } from "./client.js";
import { WHOIS_TLD_EXCEPTIONS } from "./servers.js";
import type { LookupOptions } from "../types";
import { whoisQuery } from "./client";
import { WHOIS_TLD_EXCEPTIONS } from "./servers";
/**
* Parse the IANA WHOIS response for a TLD and extract the WHOIS server
@@ -32,9 +32,7 @@ export function parseIanaWhoisServer(text: string): string | undefined {
* remarks: Registration information: http://example.tld
* url: https://registry.example
*/
export function parseIanaRegistrationInfoUrl(
text: string,
): string | undefined {
export function parseIanaRegistrationInfoUrl(text: string): string | undefined {
const lines = String(text).split(/\r?\n/);
for (const raw of lines) {
const line = raw.trim();
+1 -1
View File
@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { normalizeWhois } from "./normalize.js";
import { normalizeWhois } from "./normalize";
test("WHOIS .de (DENIC-like) nserver lines", () => {
const text = `
+4 -4
View File
@@ -1,12 +1,12 @@
import { toISO } from "../lib/dates.js";
import { isWhoisAvailable } from "../lib/domain.js";
import { parseKeyValueLines, uniq } from "../lib/text.js";
import { toISO } from "../lib/dates";
import { isWhoisAvailable } from "../lib/domain";
import { parseKeyValueLines, uniq } from "../lib/text";
import type {
Contact,
DomainRecord,
Nameserver,
RegistrarInfo,
} from "../types.js";
} from "../types";
/**
* Convert raw WHOIS text into our normalized DomainRecord.