@adaptic/utils 0.0.904 → 0.0.905

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -212,7 +212,7 @@ const isAuthConfigured = () => {
212
212
  * Returns a shared Apollo client instance with connection pooling.
213
213
  * This should be used for all @adaptic/backend-legacy operations.
214
214
  *
215
- * @returns {Promise<ApolloClientType>} The shared Apollo client instance.
215
+ * @returns {Promise<ApolloClientInstance>} The shared Apollo client instance.
216
216
  */
217
217
  const getSharedApolloClient = async () => {
218
218
  if (!apolloClientInstance) {
@@ -53811,7 +53811,6 @@ async function getPortfolioHistory(client, params) {
53811
53811
  log$i(`Fetching portfolio history with period: ${params.period || "default"}, timeframe: ${params.timeframe || "default"}`);
53812
53812
  try {
53813
53813
  const sdk = client.getSDK();
53814
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
53815
53814
  const history = await sdk.getPortfolioHistory(params);
53816
53815
  log$i(`Portfolio history fetched successfully with ${history.equity?.length || 0} data points`);
53817
53816
  return history;
@@ -55551,7 +55550,6 @@ async function getOpenTrailingStops(client, symbol) {
55551
55550
  if (symbol) {
55552
55551
  queryParams.symbols = symbol.toUpperCase();
55553
55552
  }
55554
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
55555
55553
  const orders = (await sdk.getOrders(queryParams));
55556
55554
  // Filter to only trailing stop orders
55557
55555
  const trailingStops = orders.filter((order) => order.type === "trailing_stop");
@@ -55789,12 +55787,11 @@ async function createOCOOrder(client, params) {
55789
55787
  limit_price: roundPriceForAlpaca$2(takeProfit.limitPrice).toString(),
55790
55788
  stop_loss: {
55791
55789
  stop_price: roundPriceForAlpaca$2(stopLoss.stopPrice).toString(),
55790
+ ...(stopLoss.limitPrice !== undefined
55791
+ ? { limit_price: roundPriceForAlpaca$2(stopLoss.limitPrice).toString() }
55792
+ : {}),
55792
55793
  },
55793
55794
  };
55794
- // Add stop-limit price if provided
55795
- if (stopLoss.limitPrice !== undefined) {
55796
- orderRequest.stop_loss.limit_price = roundPriceForAlpaca$2(stopLoss.limitPrice).toString();
55797
- }
55798
55795
  log$f(`Submitting OCO order request: ${JSON.stringify(orderRequest)}`, {
55799
55796
  symbol,
55800
55797
  type: "debug",
@@ -56209,14 +56206,14 @@ async function createOTOOrder(client, params) {
56209
56206
  }
56210
56207
  else if (dependent.type === "trailing_stop") {
56211
56208
  // Trailing stop order
56212
- orderRequest.stop_loss = {};
56209
+ const trailingStop = {};
56213
56210
  if (dependent.trailPercent !== undefined) {
56214
- orderRequest.stop_loss.trail_percent =
56215
- dependent.trailPercent.toString();
56211
+ trailingStop.trail_percent = dependent.trailPercent.toString();
56216
56212
  }
56217
56213
  if (dependent.trailPrice !== undefined) {
56218
- orderRequest.stop_loss.trail_price = roundPriceForAlpaca$1(dependent.trailPrice).toString();
56214
+ trailingStop.trail_price = roundPriceForAlpaca$1(dependent.trailPrice).toString();
56219
56215
  }
56216
+ orderRequest.stop_loss = trailingStop;
56220
56217
  }
56221
56218
  log$e(`Submitting OTO order request: ${JSON.stringify(orderRequest)}`, {
56222
56219
  symbol,
@@ -56637,7 +56634,6 @@ async function getLatestQuote(client, symbol, feed) {
56637
56634
  const config = client.getConfig();
56638
56635
  const dataFeed = feed || config.dataFeed || "iex";
56639
56636
  // Use SDK's getLatestQuote method
56640
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56641
56637
  const response = await sdk.getLatestQuote(normalizedSymbol, {
56642
56638
  feed: dataFeed,
56643
56639
  });
@@ -56695,7 +56691,6 @@ async function getLatestQuotes(client, symbols, feed) {
56695
56691
  const config = client.getConfig();
56696
56692
  const dataFeed = feed || config.dataFeed || "iex";
56697
56693
  // Use SDK's getLatestQuotes method
56698
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56699
56694
  const response = await sdk.getLatestQuotes(normalizedSymbols, {
56700
56695
  feed: dataFeed,
56701
56696
  });
@@ -56951,7 +56946,6 @@ async function getLatestBars(client, symbols) {
56951
56946
  const sdk = client.getSDK();
56952
56947
  const config = client.getConfig();
56953
56948
  const dataFeed = config.dataFeed || "iex";
56954
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56955
56949
  const response = await sdk.getLatestBars(normalizedSymbols, {
56956
56950
  feed: dataFeed,
56957
56951
  });
@@ -57242,7 +57236,6 @@ async function getLatestTrade(client, symbol, feed) {
57242
57236
  const config = client.getConfig();
57243
57237
  const dataFeed = feed || config.dataFeed || "iex";
57244
57238
  // Use SDK's getLatestTrade method
57245
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
57246
57239
  const response = await sdk.getLatestTrade(normalizedSymbol, {
57247
57240
  feed: dataFeed,
57248
57241
  });
@@ -57298,7 +57291,6 @@ async function getLatestTrades(client, symbols, feed) {
57298
57291
  const config = client.getConfig();
57299
57292
  const dataFeed = feed || config.dataFeed || "iex";
57300
57293
  // Use SDK's getLatestTrades method
57301
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
57302
57294
  const response = await sdk.getLatestTrades(normalizedSymbols, {
57303
57295
  feed: dataFeed,
57304
57296
  });
@@ -57413,7 +57405,6 @@ async function getCurrentPrice(client, symbol, feed) {
57413
57405
  const dataFeed = feed || config.dataFeed || "iex";
57414
57406
  // Try to get quote first for mid-point price
57415
57407
  try {
57416
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
57417
57408
  const quote = await sdk.getLatestQuote(normalizedSymbol, {
57418
57409
  feed: dataFeed,
57419
57410
  });
@@ -57848,7 +57839,6 @@ async function getNews(client, params = {}) {
57848
57839
  // The SDK returns a slightly different structure, so we map the fields
57849
57840
  const articles = response.map((article) => {
57850
57841
  // SDK returns properties in different format
57851
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
57852
57842
  const sdkArticle = article;
57853
57843
  // Normalize to our expected format
57854
57844
  const normalizedArticle = {
@@ -61514,7 +61504,6 @@ async function getOpenCryptoOrders(client, symbols) {
61514
61504
  ? symbols.map(normalizeCryptoSymbol$1).join(",")
61515
61505
  : undefined,
61516
61506
  };
61517
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61518
61507
  const orders = (await sdk.getOrders(queryParams));
61519
61508
  // Filter to only crypto orders (asset_class === 'crypto')
61520
61509
  const cryptoOrders = orders.filter((order) => order.asset_class === "crypto");
@@ -61716,9 +61705,7 @@ async function getCryptoBars(client, params) {
61716
61705
  result.set(symbol, []);
61717
61706
  }
61718
61707
  // Use SDK's getCryptoBars method
61719
- // The SDK may return an async iterator or a Promise depending on the version;
61720
- // cast to any so TypeScript does not constrain the runtime duck-typing below.
61721
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61708
+ // The SDK may return an async iterator or a Promise depending on the version
61722
61709
  const barsResponse = sdk.getCryptoBars(normalizedSymbols, options);
61723
61710
  // Handle both async iterator and direct response formats
61724
61711
  if (barsResponse &&
@@ -61739,8 +61726,8 @@ async function getCryptoBars(client, params) {
61739
61726
  result.set(symbol, existingBars);
61740
61727
  }
61741
61728
  }
61742
- else if (barsResponse && barsResponse.then) {
61743
- // Handle Promise response
61729
+ else if (barsResponse && "then" in barsResponse) {
61730
+ // Handle Promise response (SDK returns thenable in some versions)
61744
61731
  const response = await barsResponse;
61745
61732
  if (response && response.bars) {
61746
61733
  for (const [symbol, bars] of Object.entries(response.bars)) {
@@ -62054,9 +62041,7 @@ async function getCryptoTrades(client, symbol, start, end, limit) {
62054
62041
  options.limit = limit;
62055
62042
  }
62056
62043
  const trades = [];
62057
- // The SDK may return an async iterator or a Promise depending on the version;
62058
- // cast to any so TypeScript does not constrain the runtime duck-typing below.
62059
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
62044
+ // The SDK may return an async iterator or a Promise depending on the version
62060
62045
  const tradesResponse = sdk.getCryptoTrades(normalizedSymbol, options);
62061
62046
  // Handle both async iterator and direct response formats
62062
62047
  if (tradesResponse &&
@@ -62075,8 +62060,8 @@ async function getCryptoTrades(client, symbol, start, end, limit) {
62075
62060
  }
62076
62061
  }
62077
62062
  }
62078
- else if (tradesResponse && tradesResponse.then) {
62079
- // Handle Promise response
62063
+ else if (tradesResponse && "then" in tradesResponse) {
62064
+ // Handle Promise response (SDK returns thenable in some versions)
62080
62065
  const response = await tradesResponse;
62081
62066
  if (response && response.trades) {
62082
62067
  const tradeArray = response.trades;