@superatomai/sdk-node 0.0.40-mds → 0.0.41-mds

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.js CHANGED
@@ -2096,7 +2096,7 @@ function stableStringify(value) {
2096
2096
  const keys = Object.keys(value).sort();
2097
2097
  return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(value[k])).join(",") + "}";
2098
2098
  }
2099
- function getCacheKey(collection, op, params) {
2099
+ function getCacheKey(collection, op, params, tools) {
2100
2100
  if (collection === "database" && op === "execute" && params?.sql) {
2101
2101
  return getQueryCacheKey(params.sql);
2102
2102
  }
@@ -2107,6 +2107,8 @@ function getCacheKey(collection, op, params) {
2107
2107
  return sqlKey ? `et:${toolId}:${sqlKey}:${paramsKey}` : "";
2108
2108
  }
2109
2109
  if (collection === "external-tools" && op === "execute" && params?.toolId && !params?.sql) {
2110
+ const tool = tools?.find((t) => t.id === params.toolId);
2111
+ if (tool?.cache === false) return "";
2110
2112
  const { toolId, toolName, ...rest } = params;
2111
2113
  const paramsKey = stableStringify(rest);
2112
2114
  return `et-direct:${toolId}:${paramsKey}`;
@@ -2119,7 +2121,7 @@ function getCacheKey(collection, op, params) {
2119
2121
  }
2120
2122
  return "";
2121
2123
  }
2122
- async function handleDataRequest(data, collections, sendMessage) {
2124
+ async function handleDataRequest(data, collections, sendMessage, tools) {
2123
2125
  let requestId;
2124
2126
  let collection;
2125
2127
  let op;
@@ -2145,7 +2147,7 @@ async function handleDataRequest(data, collections, sendMessage) {
2145
2147
  const startTime = performance.now();
2146
2148
  let result;
2147
2149
  let fromCache = false;
2148
- const cacheKey = getCacheKey(collection, op, params);
2150
+ const cacheKey = getCacheKey(collection, op, params, tools);
2149
2151
  if (cacheKey) {
2150
2152
  const cachedResult = queryCache.get(cacheKey);
2151
2153
  if (cachedResult !== null) {
@@ -17249,7 +17251,7 @@ var SuperatomSDK = class {
17249
17251
  this.handlePong();
17250
17252
  break;
17251
17253
  case "DATA_REQ":
17252
- handleDataRequest(parsed, this.collections, (msg) => this.send(msg)).catch((error) => {
17254
+ handleDataRequest(parsed, this.collections, (msg) => this.send(msg), this.tools).catch((error) => {
17253
17255
  logger.error("Failed to handle data request:", error);
17254
17256
  });
17255
17257
  break;