@superatomai/sdk-node 0.0.1-mds → 0.0.2-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.mjs CHANGED
@@ -1878,10 +1878,16 @@ function getQueryCacheKey(query) {
1878
1878
  return "";
1879
1879
  }
1880
1880
  async function handleDataRequest(data, collections, sendMessage) {
1881
+ let requestId;
1882
+ let collection;
1883
+ let op;
1881
1884
  try {
1882
1885
  const dataRequest = DataRequestMessageSchema.parse(data);
1883
1886
  const { id, payload } = dataRequest;
1884
- const { collection, op, params, SA_RUNTIME } = payload;
1887
+ requestId = id;
1888
+ const { collection: col, op: operation, params, SA_RUNTIME } = payload;
1889
+ collection = col;
1890
+ op = operation;
1885
1891
  if (!collections[collection]) {
1886
1892
  sendDataResponse(id, collection, op, null, {
1887
1893
  error: `Collection '${collection}' not found`
@@ -1970,7 +1976,13 @@ async function handleDataRequest(data, collections, sendMessage) {
1970
1976
  }
1971
1977
  sendDataResponse(id, collection, op, result, { executionMs }, sendMessage);
1972
1978
  } catch (error) {
1979
+ const errorMsg = error instanceof Error ? error.message : String(error);
1973
1980
  logger.error("Failed to handle data request:", error);
1981
+ if (requestId) {
1982
+ sendDataResponse(requestId, collection || "unknown", op || "unknown", null, {
1983
+ error: errorMsg
1984
+ }, sendMessage);
1985
+ }
1974
1986
  }
1975
1987
  }
1976
1988
  function sendDataResponse(id, collection, op, data, meta, sendMessage) {