@bounded-sh/core 0.0.39 → 0.0.41
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/client/operations.d.ts +3 -1
- package/dist/index.js +44 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5012,10 +5012,28 @@ async function getMany(paths, opts = {}) {
|
|
|
5012
5012
|
return results;
|
|
5013
5013
|
}
|
|
5014
5014
|
async function runQuery(absolutePath, queryName, queryArgs, opts) {
|
|
5015
|
-
|
|
5016
|
-
|
|
5015
|
+
var _a;
|
|
5016
|
+
const rows = await runQueryManyRows([{ absolutePath, queryName, queryArgs }], opts);
|
|
5017
|
+
const row = rows[0];
|
|
5018
|
+
// The worker disambiguates a computed null from a failed/undeclared query
|
|
5019
|
+
// with a per-row `error` string — surface it instead of returning undefined.
|
|
5020
|
+
if ((row === null || row === void 0 ? void 0 : row.error) != null) {
|
|
5021
|
+
const err = new Error(String(row.error));
|
|
5022
|
+
err.isQueryError = true;
|
|
5023
|
+
err.queryName = queryName;
|
|
5024
|
+
err.path = absolutePath;
|
|
5025
|
+
throw err;
|
|
5026
|
+
}
|
|
5027
|
+
return (_a = row === null || row === void 0 ? void 0 : row.result) !== null && _a !== void 0 ? _a : null;
|
|
5017
5028
|
}
|
|
5018
5029
|
async function runQueryMany(many, opts) {
|
|
5030
|
+
// Batch shape stays an array of result values (errored rows map to null) so
|
|
5031
|
+
// existing callers keep working; use runQuery for per-row error surfacing.
|
|
5032
|
+
const rows = await runQueryManyRows(many, opts);
|
|
5033
|
+
return rows.map((row) => { var _a; return (_a = row === null || row === void 0 ? void 0 : row.result) !== null && _a !== void 0 ? _a : null; });
|
|
5034
|
+
}
|
|
5035
|
+
async function runQueryManyRows(many, opts) {
|
|
5036
|
+
var _a, _b, _c, _d;
|
|
5019
5037
|
try {
|
|
5020
5038
|
let queries = [];
|
|
5021
5039
|
for (const { absolutePath, queryName, queryArgs } of many) {
|
|
@@ -5027,7 +5045,16 @@ async function runQueryMany(many, opts) {
|
|
|
5027
5045
|
queries.push({ path: normalizedPath, queryName, queryArgs });
|
|
5028
5046
|
}
|
|
5029
5047
|
const response = await makeApiRequest('POST', 'queries', { queries }, opts === null || opts === void 0 ? void 0 : opts._overrides);
|
|
5030
|
-
|
|
5048
|
+
// makeApiRequest returns `{ data: <httpBody> }`, and the worker's httpBody
|
|
5049
|
+
// is `{ data: { queries: [...] }, status }` — so the rows are double-nested
|
|
5050
|
+
// at response.data.data.queries. (Reading response.data.queries here is
|
|
5051
|
+
// undefined → "Cannot read properties of undefined".) Tolerate both shapes,
|
|
5052
|
+
// same as getMany does for items/batch.
|
|
5053
|
+
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;
|
|
5054
|
+
if (!Array.isArray(rows)) {
|
|
5055
|
+
throw new Error(`queries endpoint returned an unexpected response shape (status ${response.status})`);
|
|
5056
|
+
}
|
|
5057
|
+
return rows;
|
|
5031
5058
|
}
|
|
5032
5059
|
catch (error) {
|
|
5033
5060
|
throw error;
|
|
@@ -5039,6 +5066,7 @@ async function runExpression(expression, queryArgs, options) {
|
|
|
5039
5066
|
return results[0];
|
|
5040
5067
|
}
|
|
5041
5068
|
async function runExpressionMany(many) {
|
|
5069
|
+
var _a, _b, _c, _d;
|
|
5042
5070
|
try {
|
|
5043
5071
|
let queries = [];
|
|
5044
5072
|
let overrides = undefined;
|
|
@@ -5050,13 +5078,25 @@ async function runExpressionMany(many) {
|
|
|
5050
5078
|
queries.push({ queryArgs, expression, returnType });
|
|
5051
5079
|
}
|
|
5052
5080
|
const response = await makeApiRequest('POST', 'queries', { queries }, overrides);
|
|
5081
|
+
// Same double-nesting as runQueryMany: the worker's httpBody is
|
|
5082
|
+
// { data: { queries: [...] }, status } under makeApiRequest's own
|
|
5083
|
+
// { data: <httpBody> } wrapper. Tolerate both shapes.
|
|
5084
|
+
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;
|
|
5085
|
+
if (!Array.isArray(rows)) {
|
|
5086
|
+
throw new Error(`queries endpoint returned an unexpected response shape (status ${response.status})`);
|
|
5087
|
+
}
|
|
5053
5088
|
// Map results - trace is automatically included by server for non-mainnet networks
|
|
5054
|
-
return
|
|
5089
|
+
return rows.map((queryResult) => {
|
|
5055
5090
|
const result = { result: queryResult.result };
|
|
5056
5091
|
// Include trace if present (server includes it for non-mainnet networks)
|
|
5057
5092
|
if (queryResult.trace) {
|
|
5058
5093
|
result.trace = queryResult.trace;
|
|
5059
5094
|
}
|
|
5095
|
+
// Pass through the server's per-row failure so callers can distinguish
|
|
5096
|
+
// a computed null from a failed row.
|
|
5097
|
+
if (queryResult.error != null) {
|
|
5098
|
+
result.error = String(queryResult.error);
|
|
5099
|
+
}
|
|
5060
5100
|
return result;
|
|
5061
5101
|
});
|
|
5062
5102
|
}
|