@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 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
- const parsed = leafCfg.outputSchema ? (0, import_rrroutes_contract.lowProfileParse)(leafCfg.outputSchema, out) : void 0;
351
- emit(
352
- decorateDebugEvent(
353
- {
354
- type: "fetch",
355
- stage: "parsed",
356
- method,
357
- url,
358
- leaf: leafLabel,
359
- durationMs: Date.now() - startedAt
360
- },
361
- isVerboseDebug ? {
362
- params: normalizedParams,
363
- query: normalizedQuery,
364
- output: parsed
365
- } : void 0
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) {