import { EventSource } from "eventsource"; import { z } from "zod"; import { schemas } from "./zodSchemas.js"; export type AssetType = z.infer; export type BinaryPriceUpdate = z.infer; export type EncodingType = z.infer; export type PriceFeedMetadata = z.infer; export type PriceIdInput = z.infer; export type PriceUpdate = z.infer; export type PublisherCaps = z.infer; export type UnixTimestamp = number; export type DurationInSeconds = number; export type HexString = string; export type DurationInMs = number; export type HermesClientConfig = { timeout?: DurationInMs; /** * Number of times a HTTP request will be retried before the API returns a failure. Default: 3. * * The connection uses exponential back-off for the delay between retries. However, * it will timeout regardless of the retries at the configured `timeout` time. */ httpRetries?: number; /** * Optional headers to be included in every request. */ headers?: HeadersInit; /** * Optional API access token for authentication. * When provided, this token will be included in all requests either: * - As a Bearer token in the Authorization header (for HTTP requests) * - As an ACCESS_TOKEN query parameter (for WebSocket/SSE connections) */ accessToken?: string; }; export declare class HermesClient { private baseURL; private timeout; private httpRetries; private headers; private accessToken; /** * Constructs a new Connection. * * @param endpoint - endpoint URL to the price service. Example: https://website/example/ * @param config - Optional HermesClientConfig for custom configurations. */ constructor(endpoint: string, config?: HermesClientConfig); private httpRequest; /** * Fetch the set of available price feeds. * This endpoint can be filtered by asset type and query string. * This will throw an error if there is a network problem or the price service returns a non-ok response. * * @param options - Optional parameters: * - query: String to filter the price feeds. If provided, the results will be filtered to all price feeds whose symbol contains the query string. Query string is case insensitive. Example: "bitcoin". * - assetType: String to filter the price feeds by asset type. Possible values are "crypto", "equity", "fx", "metal", "rates", "crypto_redemption_rate". Filter string is case insensitive. * * @returns Array of PriceFeedMetadata objects. */ getPriceFeeds({ fetchOptions, ...options }?: { query?: string; assetType?: AssetType; fetchOptions?: RequestInit; }): Promise; /** * Fetch the latest publisher stake caps. * This endpoint can be customized by specifying the encoding type and whether the results should also return the parsed publisher caps. * This will throw an error if there is a network problem or the price service returns a non-ok response. * * @param options - Optional parameters: * - encoding: Encoding type. If specified, return the publisher caps in the encoding specified by the encoding parameter. Default is hex. * - parsed: Boolean to specify if the parsed publisher caps should be included in the response. Default is false. * * @returns PublisherCaps object containing the latest publisher stake caps. */ getLatestPublisherCaps({ fetchOptions, ...options }?: { encoding?: EncodingType; parsed?: boolean; fetchOptions?: RequestInit; }): Promise; /** * Fetch the latest price updates for a set of price feed IDs. * This endpoint can be customized by specifying the encoding type and whether the results should also return the parsed price update using the options object. * This will throw an error if there is a network problem or the price service returns a non-ok response. * * @param ids - Array of hex-encoded price feed IDs for which updates are requested. * @param options - Optional parameters: * - encoding: Encoding type. If specified, return the price update in the encoding specified by the encoding parameter. Default is hex. * - parsed: Boolean to specify if the parsed price update should be included in the response. Default is false. * - ignoreInvalidPriceIds: Boolean to specify if invalid price IDs should be ignored instead of returning an error. Default is false. * * @returns PriceUpdate object containing the latest updates. */ getLatestPriceUpdates(ids: HexString[], options?: { encoding?: EncodingType; parsed?: boolean; ignoreInvalidPriceIds?: boolean; }, fetchOptions?: RequestInit): Promise; /** * Fetch the price updates for a set of price feed IDs at a given timestamp. * This endpoint can be customized by specifying the encoding type and whether the results should also return the parsed price update. * This will throw an error if there is a network problem or the price service returns a non-ok response. * * @param publishTime - Unix timestamp in seconds. * @param ids - Array of hex-encoded price feed IDs for which updates are requested. * @param options - Optional parameters: * - encoding: Encoding type. If specified, return the price update in the encoding specified by the encoding parameter. Default is hex. * - parsed: Boolean to specify if the parsed price update should be included in the response. Default is false. * - ignoreInvalidPriceIds: Boolean to specify if invalid price IDs should be ignored instead of returning an error. Default is false. * * @returns PriceUpdate object containing the updates at the specified timestamp. */ getPriceUpdatesAtTimestamp(publishTime: UnixTimestamp, ids: HexString[], options?: { encoding?: EncodingType; parsed?: boolean; ignoreInvalidPriceIds?: boolean; }, fetchOptions?: RequestInit): Promise; /** * Fetch streaming price updates for a set of price feed IDs. * This endpoint can be customized by specifying the encoding type, whether the results should include parsed updates, * and if unordered updates or only benchmark updates are allowed. * This will return an EventSource that can be used to listen to streaming updates. * If an invalid hex-encoded ID is passed, it will throw an error. * * @param ids - Array of hex-encoded price feed IDs for which streaming updates are requested. * @param options - Optional parameters: * - encoding: Encoding type. If specified, updates are returned in the specified encoding. Default is hex. * - parsed: Boolean to specify if the parsed price update should be included in the response. Default is false. * - allowUnordered: Boolean to specify if unordered updates are allowed to be included in the stream. Default is false. * - benchmarksOnly: Boolean to specify if only benchmark prices should be returned. Default is false. * - ignoreInvalidPriceIds: Boolean to specify if invalid price IDs should be ignored instead of returning an error. Default is false. * * @returns An EventSource instance for receiving streaming updates. */ getPriceUpdatesStream(ids: HexString[], options?: { encoding?: EncodingType; parsed?: boolean; allowUnordered?: boolean; benchmarksOnly?: boolean; ignoreInvalidPriceIds?: boolean; }): Promise; private appendUrlSearchParams; private buildURL; }