@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 +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2036,7 +2036,7 @@ function stableStringify(value) {
|
|
|
2036
2036
|
const keys = Object.keys(value).sort();
|
|
2037
2037
|
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(value[k])).join(",") + "}";
|
|
2038
2038
|
}
|
|
2039
|
-
function getCacheKey(collection, op, params) {
|
|
2039
|
+
function getCacheKey(collection, op, params, tools) {
|
|
2040
2040
|
if (collection === "database" && op === "execute" && params?.sql) {
|
|
2041
2041
|
return getQueryCacheKey(params.sql);
|
|
2042
2042
|
}
|
|
@@ -2047,6 +2047,8 @@ function getCacheKey(collection, op, params) {
|
|
|
2047
2047
|
return sqlKey ? `et:${toolId}:${sqlKey}:${paramsKey}` : "";
|
|
2048
2048
|
}
|
|
2049
2049
|
if (collection === "external-tools" && op === "execute" && params?.toolId && !params?.sql) {
|
|
2050
|
+
const tool = tools?.find((t) => t.id === params.toolId);
|
|
2051
|
+
if (tool?.cache === false) return "";
|
|
2050
2052
|
const { toolId, toolName, ...rest } = params;
|
|
2051
2053
|
const paramsKey = stableStringify(rest);
|
|
2052
2054
|
return `et-direct:${toolId}:${paramsKey}`;
|
|
@@ -2059,7 +2061,7 @@ function getCacheKey(collection, op, params) {
|
|
|
2059
2061
|
}
|
|
2060
2062
|
return "";
|
|
2061
2063
|
}
|
|
2062
|
-
async function handleDataRequest(data, collections, sendMessage) {
|
|
2064
|
+
async function handleDataRequest(data, collections, sendMessage, tools) {
|
|
2063
2065
|
let requestId;
|
|
2064
2066
|
let collection;
|
|
2065
2067
|
let op;
|
|
@@ -2085,7 +2087,7 @@ async function handleDataRequest(data, collections, sendMessage) {
|
|
|
2085
2087
|
const startTime = performance.now();
|
|
2086
2088
|
let result;
|
|
2087
2089
|
let fromCache = false;
|
|
2088
|
-
const cacheKey = getCacheKey(collection, op, params);
|
|
2090
|
+
const cacheKey = getCacheKey(collection, op, params, tools);
|
|
2089
2091
|
if (cacheKey) {
|
|
2090
2092
|
const cachedResult = queryCache.get(cacheKey);
|
|
2091
2093
|
if (cachedResult !== null) {
|
|
@@ -17189,7 +17191,7 @@ var SuperatomSDK = class {
|
|
|
17189
17191
|
this.handlePong();
|
|
17190
17192
|
break;
|
|
17191
17193
|
case "DATA_REQ":
|
|
17192
|
-
handleDataRequest(parsed, this.collections, (msg) => this.send(msg)).catch((error) => {
|
|
17194
|
+
handleDataRequest(parsed, this.collections, (msg) => this.send(msg), this.tools).catch((error) => {
|
|
17193
17195
|
logger.error("Failed to handle data request:", error);
|
|
17194
17196
|
});
|
|
17195
17197
|
break;
|