UNPKG

@mercnet/windmill

Version:

Windmill integration adapter for MercNet GraphQL API

119 lines (115 loc) 3.44 kB
'use strict'; var core = require('@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 core.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); } Object.defineProperty(exports, "MercNetError", { enumerable: true, get: function () { return core.MercNetError; } }); Object.defineProperty(exports, "createGraphQLClient", { enumerable: true, get: function () { return core.createGraphQLClient; } }); exports.WindmillMercNetUtils = WindmillMercNetUtils; exports.createClient = createClient; exports.createMercNetClient = createMercNetClient; exports.createUtils = createUtils; //# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map