@emeryld/rrroutes-client 2.3.6 → 2.3.8
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.cjs +27 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +27 -18
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -246,6 +246,7 @@ function createRouteClient(opts) {
|
|
|
246
246
|
const isGet = leaf.method === "get";
|
|
247
247
|
const isFeed = !!leaf.cfg.feed;
|
|
248
248
|
const leafCfg = leaf.cfg;
|
|
249
|
+
const validateResponses = opts.validateResponses ?? true;
|
|
249
250
|
const method = toUpper(leaf.method);
|
|
250
251
|
const expectsArgs = Boolean(leafCfg.paramsSchema || leafCfg.querySchema);
|
|
251
252
|
const leafLabel = `${leaf.method.toUpperCase()} ${String(leaf.path)}`;
|
|
@@ -347,24 +348,32 @@ function createRouteClient(opts) {
|
|
|
347
348
|
} : void 0
|
|
348
349
|
)
|
|
349
350
|
);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
351
|
+
let parsed = out;
|
|
352
|
+
if (validateResponses) {
|
|
353
|
+
if (!leafCfg.outputSchema) {
|
|
354
|
+
throw new Error(
|
|
355
|
+
`No output schema defined for leaf ${leafLabel}, cannot validate response.`
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
parsed = (0, import_rrroutes_contract.lowProfileParse)(leafCfg.outputSchema, out);
|
|
359
|
+
emit(
|
|
360
|
+
decorateDebugEvent(
|
|
361
|
+
{
|
|
362
|
+
type: "fetch",
|
|
363
|
+
stage: "parsed",
|
|
364
|
+
method,
|
|
365
|
+
url,
|
|
366
|
+
leaf: leafLabel,
|
|
367
|
+
durationMs: Date.now() - startedAt
|
|
368
|
+
},
|
|
369
|
+
isVerboseDebug ? {
|
|
370
|
+
params: normalizedParams,
|
|
371
|
+
query: normalizedQuery,
|
|
372
|
+
output: parsed
|
|
373
|
+
} : void 0
|
|
374
|
+
)
|
|
375
|
+
);
|
|
376
|
+
}
|
|
368
377
|
options?.onReceive?.(parsed);
|
|
369
378
|
return parsed;
|
|
370
379
|
} catch (error) {
|