Skip to main content

Overview

All types are exported from the cuey package. This page provides a complete reference of all available types.

Importing Types

import type {
  Cron,
  Event,
  HttpMethod,
  EventStatus,
  RetryConfig,
  CreateCronInput,
  UpdateCronInput,
  CreateEventInput,
  UpdateEventInput,
  CronsQueryParams,
  EventsQueryParams,
  CueyConfig,
} from "cuey";

Core Types

Cron

Represents a recurring cron job.
Cron
interface
Interface representing a cron job.

Event

Represents a scheduled event.
Event
interface
Interface representing a scheduled event.

HttpMethod

Supported HTTP methods for webhook requests.
HttpMethod
union
Union type of supported HTTP methods.

EventStatus

Status values for event execution.
EventStatus
union
Union type of event status values.

RetryConfig

Retry configuration for webhooks.
RetryConfig
interface
Interface for retry configuration.

Json

JSON type for API payloads.
Json
union
Recursive union type representing any JSON-serializable value.

Input Types

CreateCronInput

Input for creating a cron job.
CreateCronInput
interface
Interface for creating a cron job.

UpdateCronInput

Input for updating a cron job (same structure as CreateCronInput).
UpdateCronInput
interface
Interface for updating a cron job. Same structure as CreateCronInput.

CreateEventInput

Input for creating an event.
CreateEventInput
interface
Interface for creating an event.

UpdateEventInput

Input for updating an event (same structure as CreateEventInput).
UpdateEventInput
interface
Interface for updating an event. Same structure as CreateEventInput.

Query Parameter Types

CronsQueryParams

Query parameters for listing crons.
CronsQueryParams
interface
Interface for query parameters when listing crons.

EventsQueryParams

Query parameters for listing events.
EventsQueryParams
interface
Interface for query parameters when listing events.

Configuration Types

CueyConfig

Configuration options for the Cuey client.
CueyConfig
interface
Interface for Cuey client configuration.

API Response Types

ApiSuccess

Standard API success response.
ApiSuccess
interface
Generic interface for API success responses.

ApiSuccessWithPagination

Paginated API success response.
ApiSuccessWithPagination
interface
Generic interface for paginated API success responses.

Error Types

See the Error Handling page for complete error type documentation.
CueyError
class
Base error class for all Cuey API errors. Extends JavaScript’s Error.
CueyErrorCode
union
Union type of all possible error codes.

Type Guards and Utilities

Checking Event Status

function isPending(event: Event): boolean {
  return event.status === "pending";
}

function isSuccess(event: Event): boolean {
  return event.status === "success";
}

function isFailed(event: Event): boolean {
  return event.status === "failed";
}

Type Narrowing

function handleEvent(event: Event) {
  switch (event.status) {
    case "pending":
      // TypeScript knows event.status is "pending"
      console.log("Scheduled for:", event.scheduled_at);
      break;
    case "success":
      // TypeScript knows event.status is "success"
      console.log("Response:", event.response_status);
      break;
    case "failed":
      // TypeScript knows event.status is "failed"
      console.log("Error:", event.response_error);
      break;
  }
}

Type-Safe Payload Handling

interface MyPayload {
  action: string;
  userId: string;
  data: Record<string, unknown>;
}

const cron = await cuey.crons.create({
  webhook_url: "https://api.example.com/webhook",
  cron_expression: "0 0 * * *",
  payload: {
    action: "daily_report",
    userId: "123",
    data: {},
  } satisfies MyPayload,
});