npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adland/data

v0.13.0

Published

TypeScript types and Zod schemas for AdLand ad types. Perfect for building forms with react-hook-form, validating data, and type-safe ad handling.

Downloads

1,315

Readme

@adland/data

TypeScript types and Zod schemas for AdLand ad types. Perfect for building forms with react-hook-form, validating data, and type-safe ad handling.

Installation

npm install @adland/data
# or
pnpm add @adland/data
# or
yarn add @adland/data

Usage

TypeScript Types

Types are automatically derived from Zod schemas, ensuring type safety:

import type { AdData, LinkAd, SwapAd } from "@adland/data";

// Use the types
const linkAd: LinkAd = {
  type: "link",
  url: "https://example.com",
};

const swapAd: SwapAd = {
  type: "swap",
  fromToken: "USDC",
  toToken: "ETH",
  amount: "100",
};

Zod Schemas

Use Zod schemas for validation and form integration:

import { linkAdSchema, swapAdSchema, validateAdData } from "@adland/data";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";

// With react-hook-form
function MyForm() {
  const form = useForm({
    resolver: zodResolver(swapAdSchema),
  });
  
  // ... rest of form
}

// Direct validation
const result = validateAdData(someData);
if (result.success) {
  console.log("Valid ad data:", result.data);
} else {
  console.error("Validation errors:", result.error);
}

Combining Schemas

Zod makes it easy to extend and combine schemas:

import { linkAdSchema } from "@adland/data";
import { z } from "zod";

// Extend a schema
const customLinkSchema = linkAdSchema.extend({
  title: z.string(),
  description: z.string().optional(),
});

// Combine schemas
const adWithMetadata = z.intersection(
  linkAdSchema,
  z.object({ metadata: z.record(z.unknown()) })
);

Ad Types

Link Ad

Basic link ad type.

type LinkAd = {
  type: "link";
  url: string;
}

Cast Ad

Farcaster cast link ad type.

type CastAd = {
  type: "cast";
  url: string;
}

MiniApp Ad

Farcaster mini app link ad type.

type MiniAppAd = {
  type: "miniapp";
  url: string;
}

Token Ad

Token information ad type.

type TokenAd = {
  type: "token";
  token: string; // Token address or symbol
}

Swap Ad

Token swap ad type.

type SwapAd = {
  type: "swap";
  fromToken: string; // Token address or symbol
  toToken: string; // Token address or symbol
  amount?: string; // Optional amount
}

API

Types

  • AdType - Union type of all ad type strings
  • AdData - Union type of all ad data objects (discriminated union)
  • LinkAd - Link ad type
  • CastAd - Cast ad type
  • MiniAppAd - MiniApp ad type
  • TokenAd - Token ad type
  • SwapAd - Swap ad type

Schemas

  • linkAdSchema - Zod schema for link ads
  • castAdSchema - Zod schema for cast ads
  • miniappAdSchema - Zod schema for mini app ads
  • tokenAdSchema - Zod schema for token ads
  • swapAdSchema - Zod schema for swap ads
  • adDataSchema - Discriminated union schema for all ad types
  • adSchemas - Object containing all schemas
  • getAdSchema(type) - Get schema for a specific ad type
  • getAllAdSchemas() - Get all ad schemas
  • validateAdData(data) - Validate ad data and return result

Integration Examples

React Hook Form

import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { swapAdSchema, type SwapAd } from "@adland/data";

function SwapForm() {
  const form = useForm<SwapAd>({
    resolver: zodResolver(swapAdSchema),
    defaultValues: {
      type: "swap",
      fromToken: "",
      toToken: "",
    },
  });
  
  return (
    <form onSubmit={form.handleSubmit(onSubmit)}>
      {/* form fields */}
    </form>
  );
}

Formik

import { Formik } from "formik";
import { swapAdSchema } from "@adland/data";
import { toFormikValidationSchema } from "zod-formik-adapter";

function SwapForm() {
  return (
    <Formik
      validationSchema={toFormikValidationSchema(swapAdSchema)}
      initialValues={{
        type: "swap" as const,
        fromToken: "",
        toToken: "",
      }}
      onSubmit={handleSubmit}
    >
      {/* form */}
    </Formik>
  );
}

License

MIT