Files
publisher-dashboard/packages/api-contract
RevIQ 5eeef44850 Fix TypeScript compilation issues in packages
- Add explicit type annotations for isolatedDeclarations
- Export Database type alias from db-schema
- Fix import paths and add proper type exports
- Update common schemas with better exports

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:46:11 +08:00
..

@reviq/api-contract

Contract-first API definitions using oRPC and Zod for the Publisher Dashboard authentication system.

Overview

This package defines the complete API contract for all RPC procedures served at /api/v1/rpc. It uses:

  • @orpc/contract - Contract-first RPC framework
  • Zod - Runtime type validation and schema definitions
  • libphonenumber-js - Phone number validation and formatting

Structure

src/
├── index.ts              # Main exports
├── contract.ts           # oRPC contract with all procedure signatures
└── schemas/
    ├── common.ts         # Shared schemas (email, slug, phone)
    ├── auth.ts           # Authentication schemas
    ├── user.ts           # User profile and settings schemas
    ├── org.ts            # Organization schemas
    └── admin.ts          # Admin operation schemas

Usage

import { contract } from "@reviq/api-contract";
import type { loginRequestInputSchema, loginRequestOutputSchema } from "@reviq/api-contract";

// Use the contract to implement server handlers
// Use the schemas for validation and type inference
type LoginRequestInput = z.infer<typeof loginRequestInputSchema>;

API Procedures

Auth (auth.*)

  • Signup, login, logout flows
  • Email verification
  • Password reset
  • WebAuthn (passkey) support

User (me.*)

  • Profile management
  • Password and passkey management
  • Session and device management

Organizations (orgs.*)

  • Org CRUD operations
  • Member management
  • Invitations
  • Site management

Admin (admin.*)

  • Superuser-only operations
  • User and org management
  • Site assignments

Development

# Build the package
bun run build

# Watch mode
bun run dev

# Type checking
bun run typecheck

Notes

  • All emails are automatically transformed to lowercase
  • Phone numbers are stored in E.164 format
  • Slugs follow domain name rules (2-63 chars, lowercase alphanumeric with hyphens)