API Types

API request and response type definitions

Type definitions for API requests and responses.

User API Types

Authentication

interface LoginUserParams {
  email?: string;
  password?: string;
  provider: 'EMAIL' | 'GOOGLE' | 'APPLE' | 'GUEST';
  code?: string;  // OAuth code
}

interface RegisterUserParams {
  email: string;
  password: string;
  provider: 'EMAIL';
  firstName?: string;
  lastName?: string;
}

interface ConfirmUserParams {
  token: string;
}

interface GetLoginUrlParams {
  provider: 'GOOGLE' | 'APPLE';
  redirectUrl: string;
}

Profile Management

interface UpdateUserProfileParams {
  firstName?: string;
  lastName?: string;
  avatar?: string;
}

interface AddPhoneNumberParams {
  phoneNumber: string;
}

interface PhoneNumberConfirmParams {
  code: string;
}

Password Management

interface ForgotPasswordParams {
  email: string;
}

interface ResetForgotPasswordParams {
  token: string;
  newPassword: string;
}

interface ResetPasswordParams {
  oldPassword: string;
  newPassword: string;
}

Business API Types

interface CreateBusinessParams {
  name: string;
  slug?: string;
  description?: string;
  settings?: Partial<BusinessSettings>;
  parentId?: string;
}

interface UpdateBusinessParams {
  id: string;
  name?: string;
  slug?: string;
  description?: string;
  logo?: string;
  settings?: Partial<BusinessSettings>;
}

interface GetBusinessParams {
  businessId: string;
}

interface GetBusinessesParams extends PaginationParams {
  search?: string;
}

interface InviteUserParams {
  businessId: string;
  email: string;
  roleId: string;
}

interface HandleInvitationParams {
  businessId: string;
  token: string;
  accept: boolean;
}

E-shop API Types

Products

interface CreateProductParams {
  businessId: string;
  name: string;
  slug?: string;
  description?: string;
  price: number;
  compareAtPrice?: number;
  sku?: string;
  inventory?: number;
  status?: ResourceStatus;
  images?: string[];
  categories?: string[];
  metadata?: Record<string, unknown>;
}

interface UpdateProductParams extends Partial<CreateProductParams> {
  id: string;
}

interface GetProductParams {
  businessId: string;
  id?: string;
  slug?: string;
}

interface GetProductsParams extends PaginationParams {
  businessId: string;
  status?: ResourceStatus;
  category?: string;
  search?: string;
  sortBy?: 'createdAt' | 'name' | 'price';
  sortOrder?: 'asc' | 'desc';
}

Orders

interface CreateOrderParams {
  businessId: string;
  items: OrderItem[];
  customer: Customer;
  shippingAddress?: Address;
  billingAddress?: Address;
  promoCode?: string;
  notes?: string;
}

interface OrderItem {
  productId: string;
  quantity: number;
}

interface GetQuoteParams {
  businessId: string;
  items: OrderItem[];
  promoCode?: string;
  shippingAddress?: Partial<Address>;
}

interface OrderCheckoutParams {
  businessId: string;
  orderId: string;
  paymentMethod: 'stripe';
  paymentMethodId: string;
  returnUrl?: string;
}

CMS API Types

interface CreateNodeParams {
  businessId: string;
  type: string;
  title: string;
  slug?: string;
  key?: string;
  status?: PublishStatus;
  blocks?: Block[];
  metadata?: Record<string, unknown>;
  parentId?: string;
  scheduledAt?: number;
}

interface UpdateNodeParams extends Partial<CreateNodeParams> {
  id: string;
}

interface GetNodeParams {
  businessId: string;
  id?: string;
  slug?: string;
  key?: string;
}

interface GetNodesParams extends PaginationParams {
  businessId: string;
  type?: string;
  status?: PublishStatus;
  parentId?: string;
  tag?: string;
  search?: string;
  sortBy?: 'createdAt' | 'title';
  sortOrder?: 'asc' | 'desc';
}

Reservation API Types

Services

interface CreateServiceParams {
  businessId: string;
  name: string;
  slug?: string;
  description?: string;
  duration: number;
  price: number;
  bufferBefore?: number;
  bufferAfter?: number;
  maxParticipants?: number;
  status?: ResourceStatus;
  images?: string[];
}

interface GetServiceParams {
  businessId: string;
  id?: string;
  slug?: string;
}

Providers

interface CreateProviderParams {
  businessId: string;
  name: string;
  slug?: string;
  email?: string;
  bio?: string;
  services?: string[];
  image?: string;
}

interface GetProviderWorkingTimeParams {
  businessId: string;
  providerId: string;
  from: string;  // YYYY-MM-DD
  to: string;    // YYYY-MM-DD
}

Reservations

interface CreateReservationParams {
  businessId: string;
  slots: ReservationSlot[];
  customer: Customer;
  notes?: string;
  promoCode?: string;
}

interface ReservationSlot {
  serviceId: string;
  providerId?: string;
  startTime: number;
  endTime: number;
}

interface ReservationCheckoutParams {
  businessId: string;
  reservationId: string;
  paymentMethod: 'stripe';
  paymentMethodId: string;
}

Database API Types

interface PutDataParams {
  key: string;
  value: unknown;
  ttl?: number;
}

interface ScanDataParams {
  key?: string;
  prefix?: string;
  cursor?: string;
  limit?: number;
}

interface DeleteDataParams {
  key: string;
}

interface RunScriptParams {
  script: string;
  input?: Record<string, unknown>;
}