@mercnet/windmill
Version:
Windmill integration adapter for MercNet GraphQL API
133 lines (129 loc) • 3.83 kB
text/typescript
import { MercNetGraphQLClient } from '@mercnet/core';
export { GraphQLClientConfig, GraphQLError, GraphQLResponse, Market, MercNetError, MercNetGraphQLClient, createGraphQLClient } from '@mercnet/core';
/**
* @mercnet/windmill - Windmill integration adapter for MercNet GraphQL API
*
* This package provides a simplified interface for Windmill workflows to interact
* with the MercNet GraphQL API through a pre-configured client.
*/
/**
* Configuration options for the Windmill MercNet client
*/
interface WindmillClientConfig {
/** GraphQL endpoint URL */
endpoint: string;
/** Authentication token for API access */
token?: string;
/** Additional headers to include in requests */
headers?: Record<string, string>;
/** Number of retry attempts for failed requests */
retries?: number;
/** Enable debug logging */
debug?: boolean;
}
/**
* Creates a pre-configured MercNet GraphQL client for use in Windmill workflows
*
* @param config - Configuration options for the client
* @returns Configured MercNetGraphQLClient instance
*
* @example
* ```typescript
* // Basic usage
* const client = createClient({
* endpoint: 'https://graphql.rocketeer.trade/',
* token: 'your-auth-token'
* })
*
* // Get all markets
* const markets = await client.getAllMarkets()
*
* // Get specific market
* const market = await client.getMarketById(1)
* ```
*/
declare function createClient(config: WindmillClientConfig): MercNetGraphQLClient;
/**
* Convenience function to create a client with default MercNet endpoint
*
* @param config - Partial configuration (endpoint is pre-filled)
* @returns Configured MercNetGraphQLClient instance
*
* @example
* ```typescript
* const client = createMercNetClient({
* token: 'your-auth-token'
* })
* ```
*/
declare function createMercNetClient(config: Omit<WindmillClientConfig, 'endpoint'> & {
endpoint?: string;
}): MercNetGraphQLClient;
/**
* Windmill-specific utilities for common trading operations
*/
declare class WindmillMercNetUtils {
private client;
constructor(client: MercNetGraphQLClient);
/**
* Get active markets with basic filtering
*/
getActiveMarkets(): Promise<Array<{
id: number;
name: string;
ticker: string;
price: string | null;
status: string | null;
}>>;
/**
* Get market summary for reporting
*/
getMarketSummary(marketId: number): Promise<{
id: number;
name: string;
ticker: string;
price: string | null;
sentiment: string | null;
trend: string | null;
lastUpdate: string | null;
activityScore1h: string | null;
activityScore1d: string | null;
} | null>;
/**
* Search markets by ticker pattern
*/
searchMarketsByTicker(tickerPattern: string): Promise<Array<{
id: number;
name: string;
ticker: string;
price: string | null;
}>>;
/**
* Get markets with sentiment analysis
*/
getMarketsSentiment(): Promise<Array<{
id: number;
ticker: string;
sentiment: string | null;
sentimentUpdateAt: string | null;
trendStatus: string | null;
}>>;
}
/**
* Create a WindmillMercNetUtils instance with a pre-configured client
*
* @param config - Configuration for the client
* @returns WindmillMercNetUtils instance
*
* @example
* ```typescript
* const utils = createUtils({
* endpoint: 'https://graphql.rocketeer.trade/',
* token: 'your-token'
* })
*
* const activeMarkets = await utils.getActiveMarkets()
* ```
*/
declare function createUtils(config: WindmillClientConfig): WindmillMercNetUtils;
export { type WindmillClientConfig, WindmillMercNetUtils, createClient, createMercNetClient, createUtils };