UNPKG

@mercnet/windmill

Version:

Windmill integration adapter for MercNet GraphQL API

107 lines (104 loc) 3.15 kB
import { createGraphQLClient } from '@mercnet/core'; export { MercNetError, createGraphQLClient } from '@mercnet/core'; // @mercnet/windmill - Windmill integration adapter for MercNet GraphQL API var DEFAULT_WINDMILL_CONFIG = { retries: 3, debug: false }; function createClient(config) { const mergedConfig = { ...DEFAULT_WINDMILL_CONFIG, ...config }; const headers = { "Content-Type": "application/json", ...mergedConfig.headers || {} }; if (mergedConfig.token) { headers["Authorization"] = `Bearer ${mergedConfig.token}`; } const graphqlConfig = { endpoint: mergedConfig.endpoint, headers, retries: mergedConfig.retries || 3, debug: mergedConfig.debug || false }; return createGraphQLClient(graphqlConfig); } function createMercNetClient(config) { return createClient({ endpoint: "https://graphql.rocketeer.trade/", ...config }); } var WindmillMercNetUtils = class { constructor(client) { this.client = client; } /** * Get active markets with basic filtering */ async getActiveMarkets() { const markets = await this.client.getAllMarkets(); return markets.filter((market) => market.status === "active").map((market) => ({ id: market.id, name: market.name || "Unknown", ticker: market.ticker, price: market.price || null, status: market.status || null })); } /** * Get market summary for reporting */ async getMarketSummary(marketId) { const market = await this.client.getMarketById(marketId); if (!market) { return null; } return { id: market.id, name: market.name || "Unknown", ticker: market.ticker, price: market.price || null, sentiment: market.sentiment || null, trend: market.trend_status || null, lastUpdate: market.last_update_at || null, activityScore1h: market.market_activity_score_1h || null, activityScore1d: market.market_activity_score_1d || null }; } /** * Search markets by ticker pattern */ async searchMarketsByTicker(tickerPattern) { const allMarkets = await this.client.getAllMarkets(); const pattern = tickerPattern.toLowerCase(); return allMarkets.filter((market) => market.ticker.toLowerCase().includes(pattern)).map((market) => ({ id: market.id, name: market.name || "Unknown", ticker: market.ticker, price: market.price || null })); } /** * Get markets with sentiment analysis */ async getMarketsSentiment() { const allMarkets = await this.client.getAllMarkets(); return allMarkets.filter((market) => market.sentiment !== null).map((market) => ({ id: market.id, ticker: market.ticker, sentiment: market.sentiment || null, sentimentUpdateAt: market.sentiment_update_at || null, trendStatus: market.trend_status || null })); } }; function createUtils(config) { const client = createClient(config); return new WindmillMercNetUtils(client); } export { WindmillMercNetUtils, createClient, createMercNetClient, createUtils }; //# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map