package api:todos@1.0.0; // Common types used across the API interface types { // Authentication types derived from OpenAPI security schemes record bearer-token { token: string, } // Core resource type record todo { id: string, title: string, description: option, completed: bool, due-date: option, user-id: string, created-at: string, updated-at: string, } variant error { unauthorized, not-found, validation-error(list), rate-limited { retry-after: u32 }, server-error, } } interface todos-collection { use types.{todo, bearer-token, error}; // Request/response types with domain-appropriate fields record list-request { auth: bearer-token, user-id: string, status: option, limit: option, %offset: option, } record list-response { items: list, total: u32, limit: u32, %offset: u32, version: string, // From ETag last-updated: option, // From Last-Modified } record create-request { auth: bearer-token, title: string, description: option, due-date: option, user-id: string, } // Note: Response includes versioning info directly in return type list: func(request: list-request) -> result; create: func(request: create-request) -> result; } interface todos-resource { use types.{todo, bearer-token, error}; record update-request { auth: bearer-token, title: option, description: option, completed: option, due-date: option, expected-version: option, // If-Match header } get: func(id: string, auth: bearer-token) -> result; update: func(id: string, request: update-request) -> result; delete: func(id: string, auth: bearer-token) -> result; } world todos-api { export todos-collection; export todos-resource; }