This document outlines the design for a TypeScript client SDK for Qhronos, intended for distribution via npm and usable in both Node.js and browser environments. The SDK provides a full-featured, type-safe, and developer-friendly interface to the Qhronos REST API.
createEvent(data: CreateEventRequest): Promise<Event>getEvent(id: string): Promise<Event>listEvents(params?: ListEventsParams): Promise<Event[]>updateEvent(id: string, data: UpdateEventRequest): Promise<Event>deleteEvent(id: string): Promise<void>listOccurrences(eventId: string, params?: ListOccurrencesParams): Promise<Occurrence[]>getOccurrence(occurrenceId: string): Promise<Occurrence>
setAuthToken(token: string): voidlogout(): void
(client-side only, clears token)
getStatus(): Promise<SystemStatus>
getEventsByTag(tag: string): Promise<Event[]>
waitForEventStatus(id: string, status: string, timeoutMs?: number): Promise<Event>
- All request/response types for the above methods will be defined for type safety and developer experience.
- Framework Agnostic: Uses the Fetch API (polyfilled for Node.js if needed).
- Auth Handling: Supports JWT/master token, with methods to set/update tokens.
- Type Safety: All request/response payloads are strongly typed.
- Helper Methods: For common workflows (e.g., polling for event status).
- Distribution: To be published as
qhronos-clienton npm, supporting both ESM and CJS.
import { QhronosClient } from 'qhronos-client';
const qhronos = new QhronosClient({
baseUrl: 'https://api.qhronos.example.com',
authToken: 'your-jwt-or-master-token',
});
const event = await qhronos.createEvent({
name: 'Daily Report',
start_time: '2024-06-01T09:00:00Z',
webhook: 'https://yourapp.com/webhook',
schedule: { frequency: 'daily' },
tags: ['report'],
});