@emeryld/rrroutes-client 2.3.5 → 2.3.7

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)}`;
@@ -330,12 +331,11 @@ function createRouteClient(opts) {
330
331
  const out = await fetcher(
331
332
  payload === void 0 ? { url, method } : { url, method, body: payload }
332
333
  );
333
- const parsed = leafCfg.outputSchema ? (0, import_rrroutes_contract.lowProfileParse)(leafCfg.outputSchema, out) : void 0;
334
334
  emit(
335
335
  decorateDebugEvent(
336
336
  {
337
337
  type: "fetch",
338
- stage: "success",
338
+ stage: "fetched",
339
339
  method,
340
340
  url,
341
341
  leaf: leafLabel,
@@ -344,10 +344,30 @@ function createRouteClient(opts) {
344
344
  isVerboseDebug ? {
345
345
  params: normalizedParams,
346
346
  query: normalizedQuery,
347
- output: parsed
347
+ output: out
348
348
  } : void 0
349
349
  )
350
350
  );
351
+ const parsed = validateResponses && leafCfg.outputSchema ? (0, import_rrroutes_contract.lowProfileParse)(leafCfg.outputSchema, out) : void 0;
352
+ if (validateResponses) {
353
+ emit(
354
+ decorateDebugEvent(
355
+ {
356
+ type: "fetch",
357
+ stage: "parsed",
358
+ method,
359
+ url,
360
+ leaf: leafLabel,
361
+ durationMs: Date.now() - startedAt
362
+ },
363
+ isVerboseDebug ? {
364
+ params: normalizedParams,
365
+ query: normalizedQuery,
366
+ output: parsed
367
+ } : void 0
368
+ )
369
+ );
370
+ }
351
371
  options?.onReceive?.(parsed);
352
372
  return parsed;
353
373
  } catch (error) {
@@ -579,7 +599,7 @@ function createRouteClient(opts) {
579
599
  decorateDebugEvent(
580
600
  {
581
601
  type: "fetch",
582
- stage: "success",
602
+ stage: "fetched",
583
603
  method: methodUpper,
584
604
  url,
585
605
  leaf: leafLabel,