@tclinic/shared

v1.0.4

Published

Shared utilities & schemas for Clinic projects

Readme

@tclinic/shared

Shared utilities, schemas, and types for Clinic projects (NestJS backend & Next.js frontend).

Installation

npm install @tclinic/shared
# or
pnpm add @tclinic/shared
# or
yarn add @tclinic/shared

Usage

Auth Schemas

import { LoginSchema, RegisterSchema, AuthResponseSchema, UserResponseSchema } from '@tclinic/shared';

// Validate login data
const loginData = LoginSchema.parse({
  email: '[email protected]',
  password: 'password123'
});

// Validate register data
const registerData = RegisterSchema.parse({
  email: '[email protected]',
  password: 'password123',
  name: 'John Doe' // optional
});

User Schemas

import { CreateUserSchema, UserResponseSchema, RoleEnum } from '@tclinic/shared';

// Create user
const userData = CreateUserSchema.parse({
  email: '[email protected]',
  password: 'password123',
  name: 'John Doe',
  avatar: 'https://example.com/avatar.jpg', // optional
  role: 'PATIENT' // optional
});

// User response type
type User = z.infer<typeof UserResponseSchema>;

Appointment Schemas

import { CreateAppointmentSchema, AppointmentResponseSchema, AppointmentStatusEnum } from '@tclinic/shared';

// Create appointment
const appointmentData = CreateAppointmentSchema.parse({
  doctorId: 'uuid-here',
  startAt: '2024-01-01T10:00:00Z',
  endAt: '2024-01-01T11:00:00Z',
  service: 'General Checkup'
});

Exports

Auth Schemas

  • LoginSchema - Zod schema for login
  • RegisterSchema - Zod schema for registration
  • AuthResponseSchema - Zod schema for auth response (JWT token)
  • RegisterResponseSchema - Zod schema for register response
  • Types: LoginDto, RegisterDto, AuthResponse, RegisterResponse

User Schemas

  • CreateUserSchema - Zod schema for creating a user
  • UserResponseSchema - Zod schema for user response
  • RoleEnum - Enum for user roles (ADMIN, DOCTOR, NURSE, RECEPTIONIST, PATIENT)
  • Types: CreateUserDto, UserResponse

Appointment Schemas

  • CreateAppointmentSchema - Zod schema for creating an appointment
  • AppointmentResponseSchema - Zod schema for appointment response
  • AppointmentStatusEnum - Enum for appointment status (PENDING, CONFIRMED, CANCELLED, COMPLETED, NO_SHOW)
  • Types: CreateAppointment, AppointmentResponse, AppointmentStatus

License

MIT