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

@capibox/bridge-interface

v0.1.43

Published

``` npm run generate-docs ```

Readme

Generate docs

npm run generate-docs

@capibox/bridge-interface

A shared library for DTO (Data Transfer Object) definitions between NestJS (backend) and React/NextJS (frontend) applications.

Installation

npm install @capibox/bridge-interface

Usage

In NestJS (Backend)

import { dto } from '@capibox/bridge-interface';

@Controller('mail')
export class MailController {
  @Post('support')
  async sendMailToSupport(@Body() mailData: dto.SendMailToSupportDto) {
    // Validate the request body against the schema
    const result = dto.sendMailToSupportSchema.safeParse(mailData);
    if (!result.success) {
      throw new BadRequestException(result.error);
    }

    return this.mailService.sendToSupport(mailData);
  }
}

In React/NextJS (Frontend)

import { dto } from '@capibox/bridge-interface';

// Create a type-safe object based on the DTO
const mailData: dto.SendMailToSupportDto = {
  subject: 'Important information about your account',
  htmlPart: '<p>Hello, this is an <strong>important</strong> message.</p>',
  textPart: 'Hello, this is an important message.',
};

// Validate the data with the schema (client-side validation)
const validationResult = dto.sendMailToSupportSchema.safeParse(mailData);
if (!validationResult.success) {
  console.error('Validation error:', validationResult.error);
} else {
  // Use in API calls
  const sendMailToSupport = async (data: dto.SendMailToSupportDto) => {
    const response = await fetch('/api/mail/support', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(data),
    });
    return response.json();
  };

  sendMailToSupport(mailData);
}

Available DTOs

CAPI

  • CapiPayloadDto: DTO for CAPI payload.
  • FacebookCapiDtoType: DTO for Facebook CAPI.
  • TiktokCapiDtoType: DTO for TikTok CAPI.

CRM Auth

  • SignInCrmUserDtoType: DTO for signing in a CRM user.
  • SignInCrmResponseDtoType: DTO for the response of a CRM user sign-in.
  • VerifyCrmUserDtoType: DTO for verifying a CRM user.
  • VerifyCrmResponseDtoType: DTO for the response of a CRM user verification.

Facebook Insights

  • CreateFacebookBusinessManagerDto: DTO for creating a new Facebook Business Manager.
  • CreateFacebookAdAccountDto: DTO for creating a new Facebook Ad Account.
  • FacebookBusinessManagerResponseDto: DTO for the response of a Facebook Business Manager.
  • FacebookAdAccountResponseDto: DTO for the response of a Facebook Ad Account.

Funnel

  • CreateFunnelDtoType: DTO for creating a new funnel.
  • UpdateFunnelDtoType: DTO for updating a funnel.
  • CreateFunnelBridgeDtoType: DTO for creating a new funnel bridge.
  • CreateFunnelEndpointDtoType: DTO for creating a new funnel endpoint.
  • FunnelResponseDtoType: DTO for the response of a funnel.

Integration

  • CreateIntegrationDtoType: DTO for creating a new integration.
  • UpdateIntegrationDtoType: DTO for updating an integration.
  • IntegrationResponseDtoType: DTO for the response of an integration.

Mail

  • SendMailToSupportDto: DTO for sending emails to support.
  • SendMailToRecipientDto: DTO for sending emails to a specific recipient.
  • SendMailResponseDto: DTO for email sending response.

Project

  • CreateProjectDtoType: DTO for creating a new project.
  • UpdateProjectDtoType: DTO for updating a project.
  • ProjectResponseDtoType: DTO for the response of a project.

Session

  • AppendSessionDtoType: DTO for appending a session.
  • AppendSessionBrowserPublicDtoType: DTO for appending a session from a public browser.
  • CreateSessionBridgeDtoType: DTO for creating a session bridge.
  • CreateSessionBrowserDtoType: DTO for creating a session from a browser.
  • CreateSessionBrowserPublicDtoType: DTO for creating a session from a public browser.
  • CreateSessionEndpointDtoType: DTO for creating a session endpoint.
  • SessionResponseDtoType: DTO for the response of a session.

Split

  • CreateSplitDtoType: DTO for creating a new split.
  • UpdateSplitDtoType: DTO for updating a split.
  • CreateSplitBridgeDtoType: DTO for creating a new split bridge.
  • CreateSplitEndpointDtoType: DTO for creating a new split endpoint.
  • SplitResponseDtoType: DTO for the response of a split.

Webhook

  • CreateWebhookBridgeDtoType: DTO for creating a new webhook bridge.
  • CreateWebhookEndpointDtoType: DTO for creating a new webhook endpoint.
  • UpdateWebhookDtoType: DTO for updating a webhook.
  • WebhookResponseDtoType: DTO for the response of a webhook.

Schema Validation and Documentation

This library uses zod for schema validation and documentation. Each DTO has a corresponding zod schema that can be used for validation:

  • sendMailToSupportSchema: Schema for validating support email data
  • sendMailToRecipientSchema: Schema for validating recipient email data
  • sendMailResponseSchema: Schema for validating email response data

DTO Documentation

The library includes a script to generate a table of contents for all DTOs. To generate the documentation, run:

npm run generate-docs

This will create a markdown file in the docs/dto directory with a table of contents for all DTOs. The documentation includes:

  • A categorized list of all DTOs organized by directory
  • Links to the source files for each DTO

The table of contents provides a quick overview of all available DTOs in the library and makes it easy to navigate to their source files.

NestJS Swagger Integration

For NestJS applications that use Swagger for API documentation, the library provides class-based DTOs that can be used with the @nestjs/swagger decorators:

import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { dto } from '@capibox/bridge-interface';

@ApiTags('mail')
@Controller('mail')
export class MailController {
  @Post('recipient')
  @ApiOperation({ summary: 'Send email to a recipient' })
  @ApiResponse({
    status: 200,
    description: 'Email sent successfully',
    type: dto.SendMailResponseDto,
  })
  async sendMailToRecipient(@Body() mailData: dto.SendMailToRecipientDto) {
    // Validate with zod schema
    const result = dto.sendMailToRecipientSchema.safeParse(mailData);
    if (!result.success) {
      throw new BadRequestException(result.error);
    }

    return this.mailService.sendToRecipient(mailData);
  }
}

The class-based DTOs have the same properties as their zod schema counterparts, making them compatible for both validation and documentation. They also include Swagger-compatible decorators that match the metadata in the zod schemas, ensuring that descriptions and examples are properly displayed in the Swagger UI.

For example, the SendMailToRecipientDto class includes decorators like:

export class SendMailToRecipientDto {
  @ApiProperty({
    description: 'Email recipient address',
    example: '[email protected]',
    type: String,
  })
  to!: string;

  // ... other properties
}

These decorators are automatically generated from the metadata in the zod schemas, ensuring consistency between validation and documentation.

Utility Functions

The library provides utility functions for creating zod schemas with metadata:

import { utils } from '@capibox/bridge-interface';

// Create a string schema with metadata
const nameSchema = utils.createStringSchema({
  description: 'User name',
  example: 'John Doe',
  required: true,
});

// Create an optional schema
const bioSchema = utils.createOptionalSchema(
  utils.createStringSchema({
    description: 'User biography',
    example: 'Software developer with 5 years of experience',
  })
);

// Create a boolean schema
const activeSchema = utils.createBooleanSchema({
  description: 'User active status',
  example: true,
});

// Add metadata to any zod schema
const customSchema = utils.addMetadata(z.number().min(0).max(100), {
  description: 'Score percentage',
  example: 85,
});

Development

Building the library

npm run build

This will generate CommonJS, ESM, and TypeScript declaration files in the dist directory.