@bounded-sh/core 0.0.39 → 0.0.40

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.
@@ -244,7 +244,7 @@ export declare function runQueryMany(many: {
244
244
  absolutePath: string;
245
245
  queryName: string;
246
246
  queryArgs: any;
247
- }[], opts?: RunQueryOptions): Promise<any>;
247
+ }[], opts?: RunQueryOptions): Promise<any[]>;
248
248
  export declare function runExpression(expression: string, queryArgs: any, options?: RunExpressionOptions): Promise<RunExpressionResult>;
249
249
  export declare function runExpressionMany(many: {
250
250
  expression: string;
package/dist/index.js CHANGED
@@ -5036,6 +5036,7 @@ async function runQuery(absolutePath, queryName, queryArgs, opts) {
5036
5036
  return result[0];
5037
5037
  }
5038
5038
  async function runQueryMany(many, opts) {
5039
+ var _a, _b, _c, _d;
5039
5040
  try {
5040
5041
  let queries = [];
5041
5042
  for (const { absolutePath, queryName, queryArgs } of many) {
@@ -5047,7 +5048,16 @@ async function runQueryMany(many, opts) {
5047
5048
  queries.push({ path: normalizedPath, queryName, queryArgs });
5048
5049
  }
5049
5050
  const response = await makeApiRequest('POST', 'queries', { queries }, opts === null || opts === void 0 ? void 0 : opts._overrides);
5050
- return response.data.queries.map((result) => result.result);
5051
+ // makeApiRequest returns `{ data: <httpBody> }`, and the worker's httpBody
5052
+ // is `{ data: { queries: [...] }, status }` — so the rows are double-nested
5053
+ // at response.data.data.queries. (Reading response.data.queries here is
5054
+ // undefined → "Cannot read properties of undefined".) Tolerate both shapes,
5055
+ // same as getMany does for items/batch.
5056
+ const rows = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.queries) !== null && _c !== void 0 ? _c : (_d = response.data) === null || _d === void 0 ? void 0 : _d.queries;
5057
+ if (!Array.isArray(rows)) {
5058
+ throw new Error(`queries endpoint returned an unexpected response shape (status ${response.status})`);
5059
+ }
5060
+ return rows.map((result) => result.result);
5051
5061
  }
5052
5062
  catch (error) {
5053
5063
  throw error;
@@ -5059,6 +5069,7 @@ async function runExpression(expression, queryArgs, options) {
5059
5069
  return results[0];
5060
5070
  }
5061
5071
  async function runExpressionMany(many) {
5072
+ var _a, _b, _c, _d;
5062
5073
  try {
5063
5074
  let queries = [];
5064
5075
  let overrides = undefined;
@@ -5070,8 +5081,15 @@ async function runExpressionMany(many) {
5070
5081
  queries.push({ queryArgs, expression, returnType });
5071
5082
  }
5072
5083
  const response = await makeApiRequest('POST', 'queries', { queries }, overrides);
5084
+ // Same double-nesting as runQueryMany: the worker's httpBody is
5085
+ // { data: { queries: [...] }, status } under makeApiRequest's own
5086
+ // { data: <httpBody> } wrapper. Tolerate both shapes.
5087
+ const rows = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.queries) !== null && _c !== void 0 ? _c : (_d = response.data) === null || _d === void 0 ? void 0 : _d.queries;
5088
+ if (!Array.isArray(rows)) {
5089
+ throw new Error(`queries endpoint returned an unexpected response shape (status ${response.status})`);
5090
+ }
5073
5091
  // Map results - trace is automatically included by server for non-mainnet networks
5074
- return response.data.queries.map((queryResult) => {
5092
+ return rows.map((queryResult) => {
5075
5093
  const result = { result: queryResult.result };
5076
5094
  // Include trace if present (server includes it for non-mainnet networks)
5077
5095
  if (queryResult.trace) {