@botbotgo/better-call 0.1.44 → 0.1.45
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/package.json +1 -1
- package/scripts/demo.mjs +11 -4
package/package.json
CHANGED
package/scripts/demo.mjs
CHANGED
|
@@ -101,8 +101,14 @@ const stockQuote = {
|
|
|
101
101
|
const intentionallyMalformedArgs = { symbol: "Apple", market: "NASDAQ" };
|
|
102
102
|
|
|
103
103
|
function repairDemoStockCall(repairInput = {}) {
|
|
104
|
+
const hasUsableArgsShape = (value) =>
|
|
105
|
+
typeof value === "object" &&
|
|
106
|
+
value != null &&
|
|
107
|
+
!Array.isArray(value) &&
|
|
108
|
+
("ticker" in value || "symbol" in value || "market" in value);
|
|
109
|
+
|
|
104
110
|
const attemptedArgs =
|
|
105
|
-
Array.isArray(repairInput?.calls) && repairInput.calls[0]?.args
|
|
111
|
+
Array.isArray(repairInput?.calls) && hasUsableArgsShape(repairInput.calls[0]?.args)
|
|
106
112
|
? repairInput.calls[0].args
|
|
107
113
|
: intentionallyMalformedArgs;
|
|
108
114
|
|
|
@@ -112,7 +118,8 @@ function repairDemoStockCall(repairInput = {}) {
|
|
|
112
118
|
: typeof attemptedArgs.symbol === "string"
|
|
113
119
|
? attemptedArgs.symbol
|
|
114
120
|
: "AAPL";
|
|
115
|
-
const normalizedTicker =
|
|
121
|
+
const normalizedTicker =
|
|
122
|
+
typeof attemptedTicker === "string" ? attemptedTicker.trim().toLowerCase() : "aapl";
|
|
116
123
|
// This demo falls back to AAPL when no ticker-like value is available.
|
|
117
124
|
const ticker =
|
|
118
125
|
normalizedTicker === ""
|
|
@@ -202,7 +209,7 @@ try {
|
|
|
202
209
|
);
|
|
203
210
|
}
|
|
204
211
|
|
|
205
|
-
const
|
|
212
|
+
const gatewayRepairResult =
|
|
206
213
|
gatewayResult != null && typeof gatewayResult === "object"
|
|
207
214
|
? gatewayResult
|
|
208
215
|
: createGatewayErrorResult(
|
|
@@ -228,7 +235,7 @@ const report = {
|
|
|
228
235
|
repaired: repairedCall,
|
|
229
236
|
diagnostics: reliableResult?.diagnostics ?? null,
|
|
230
237
|
},
|
|
231
|
-
gatewayRepair,
|
|
238
|
+
gatewayRepair: gatewayRepairResult,
|
|
232
239
|
};
|
|
233
240
|
|
|
234
241
|
if (json) {
|