@bounded-sh/core 0.0.40 → 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 +2 -0
- package/dist/index.js +25 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +65 -65
|
@@ -238,6 +238,8 @@ export type RunExpressionResult = {
|
|
|
238
238
|
operation?: string;
|
|
239
239
|
result?: any;
|
|
240
240
|
}[];
|
|
241
|
+
/** Server-reported failure for this row (e.g. undeclared query, execution error). */
|
|
242
|
+
error?: string;
|
|
241
243
|
};
|
|
242
244
|
export declare function runQuery(absolutePath: string, queryName: string, queryArgs: any, opts?: RunQueryOptions): Promise<any>;
|
|
243
245
|
export declare function runQueryMany(many: {
|
package/dist/index.js
CHANGED
|
@@ -5032,10 +5032,27 @@ async function getMany(paths, opts = {}) {
|
|
|
5032
5032
|
return results;
|
|
5033
5033
|
}
|
|
5034
5034
|
async function runQuery(absolutePath, queryName, queryArgs, opts) {
|
|
5035
|
-
|
|
5036
|
-
|
|
5035
|
+
var _a;
|
|
5036
|
+
const rows = await runQueryManyRows([{ absolutePath, queryName, queryArgs }], opts);
|
|
5037
|
+
const row = rows[0];
|
|
5038
|
+
// The worker disambiguates a computed null from a failed/undeclared query
|
|
5039
|
+
// with a per-row `error` string — surface it instead of returning undefined.
|
|
5040
|
+
if ((row === null || row === void 0 ? void 0 : row.error) != null) {
|
|
5041
|
+
const err = new Error(String(row.error));
|
|
5042
|
+
err.isQueryError = true;
|
|
5043
|
+
err.queryName = queryName;
|
|
5044
|
+
err.path = absolutePath;
|
|
5045
|
+
throw err;
|
|
5046
|
+
}
|
|
5047
|
+
return (_a = row === null || row === void 0 ? void 0 : row.result) !== null && _a !== void 0 ? _a : null;
|
|
5037
5048
|
}
|
|
5038
5049
|
async function runQueryMany(many, opts) {
|
|
5050
|
+
// Batch shape stays an array of result values (errored rows map to null) so
|
|
5051
|
+
// existing callers keep working; use runQuery for per-row error surfacing.
|
|
5052
|
+
const rows = await runQueryManyRows(many, opts);
|
|
5053
|
+
return rows.map((row) => { var _a; return (_a = row === null || row === void 0 ? void 0 : row.result) !== null && _a !== void 0 ? _a : null; });
|
|
5054
|
+
}
|
|
5055
|
+
async function runQueryManyRows(many, opts) {
|
|
5039
5056
|
var _a, _b, _c, _d;
|
|
5040
5057
|
try {
|
|
5041
5058
|
let queries = [];
|
|
@@ -5057,7 +5074,7 @@ async function runQueryMany(many, opts) {
|
|
|
5057
5074
|
if (!Array.isArray(rows)) {
|
|
5058
5075
|
throw new Error(`queries endpoint returned an unexpected response shape (status ${response.status})`);
|
|
5059
5076
|
}
|
|
5060
|
-
return rows
|
|
5077
|
+
return rows;
|
|
5061
5078
|
}
|
|
5062
5079
|
catch (error) {
|
|
5063
5080
|
throw error;
|
|
@@ -5095,6 +5112,11 @@ async function runExpressionMany(many) {
|
|
|
5095
5112
|
if (queryResult.trace) {
|
|
5096
5113
|
result.trace = queryResult.trace;
|
|
5097
5114
|
}
|
|
5115
|
+
// Pass through the server's per-row failure so callers can distinguish
|
|
5116
|
+
// a computed null from a failed row.
|
|
5117
|
+
if (queryResult.error != null) {
|
|
5118
|
+
result.error = String(queryResult.error);
|
|
5119
|
+
}
|
|
5098
5120
|
return result;
|
|
5099
5121
|
});
|
|
5100
5122
|
}
|