@naturalcycles/js-lib 14.153.1 → 14.153.3

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.
@@ -9,6 +9,7 @@ const number_util_1 = require("../number/number.util");
9
9
  const object_util_1 = require("../object/object.util");
10
10
  const pDelay_1 = require("../promise/pDelay");
11
11
  const json_util_1 = require("../string/json.util");
12
+ const stringifyAny_1 = require("../string/stringifyAny");
12
13
  const time_util_1 = require("../time/time.util");
13
14
  const http_model_1 = require("./http.model");
14
15
  const defRetryOptions = {
@@ -315,7 +316,9 @@ class Fetcher {
315
316
  (0, time_util_1._since)(res.req.started),
316
317
  ]
317
318
  .filter(Boolean)
318
- .join(' '), res.err.cause || res.err);
319
+ .join(' ') + '\n',
320
+ // We're stringifying the error here, otherwise Sentry shows it as [object Object]
321
+ (0, stringifyAny_1._stringifyAny)(res.err.cause || res.err));
319
322
  }
320
323
  if (retryStatus.retryStopped)
321
324
  return;
@@ -444,9 +447,10 @@ class Fetcher {
444
447
  method: cfg.method || 'GET',
445
448
  headers: cfg.headers || {},
446
449
  credentials: cfg.credentials,
450
+ redirect: cfg.redirect,
447
451
  },
448
452
  hooks: {},
449
- }, (0, object_util_1._omit)(cfg, ['method', 'credentials', 'headers', 'logger']));
453
+ }, (0, object_util_1._omit)(cfg, ['method', 'credentials', 'headers', 'redirect', 'logger']));
450
454
  norm.init.headers = (0, object_util_1._mapKeys)(norm.init.headers, k => k.toLowerCase());
451
455
  return norm;
452
456
  }
@@ -477,7 +481,7 @@ class Fetcher {
477
481
  ...this.cfg.init,
478
482
  method: opt.method || this.cfg.init.method,
479
483
  credentials: opt.credentials || this.cfg.init.credentials,
480
- redirect: opt.redirect || 'follow',
484
+ redirect: opt.redirect || this.cfg.init.redirect || 'follow',
481
485
  }, {
482
486
  headers: (0, object_util_1._mapKeys)(opt.headers || {}, k => k.toLowerCase()),
483
487
  }),
@@ -2,7 +2,7 @@ import type { CommonLogger } from '../log/commonLogger';
2
2
  import type { Promisable } from '../typeFest';
3
3
  import type { Reviver, UnixTimestampMillisNumber } from '../types';
4
4
  import type { HttpMethod, HttpStatusFamily } from './http.model';
5
- export interface FetcherNormalizedCfg extends Required<FetcherCfg>, Omit<FetcherRequest, 'started' | 'fullUrl' | 'logRequest' | 'logRequestBody' | 'logResponse' | 'logResponseBody'> {
5
+ export interface FetcherNormalizedCfg extends Required<FetcherCfg>, Omit<FetcherRequest, 'started' | 'fullUrl' | 'logRequest' | 'logRequestBody' | 'logResponse' | 'logResponseBody' | 'redirect' | 'credentials'> {
6
6
  logger: CommonLogger;
7
7
  searchParams: Record<string, any>;
8
8
  }
@@ -6,6 +6,7 @@ import { _clamp } from '../number/number.util';
6
6
  import { _filterNullishValues, _filterUndefinedValues, _mapKeys, _merge, _omit, _pick, } from '../object/object.util';
7
7
  import { pDelay } from '../promise/pDelay';
8
8
  import { _jsonParse, _jsonParseIfPossible } from '../string/json.util';
9
+ import { _stringifyAny } from '../string/stringifyAny';
9
10
  import { _since } from '../time/time.util';
10
11
  import { HTTP_METHODS } from './http.model';
11
12
  const defRetryOptions = {
@@ -302,7 +303,9 @@ export class Fetcher {
302
303
  _since(res.req.started),
303
304
  ]
304
305
  .filter(Boolean)
305
- .join(' '), res.err.cause || res.err);
306
+ .join(' ') + '\n',
307
+ // We're stringifying the error here, otherwise Sentry shows it as [object Object]
308
+ _stringifyAny(res.err.cause || res.err));
306
309
  }
307
310
  if (retryStatus.retryStopped)
308
311
  return;
@@ -434,9 +437,10 @@ export class Fetcher {
434
437
  method: cfg.method || 'GET',
435
438
  headers: cfg.headers || {},
436
439
  credentials: cfg.credentials,
440
+ redirect: cfg.redirect,
437
441
  },
438
442
  hooks: {},
439
- }, _omit(cfg, ['method', 'credentials', 'headers', 'logger']));
443
+ }, _omit(cfg, ['method', 'credentials', 'headers', 'redirect', 'logger']));
440
444
  norm.init.headers = _mapKeys(norm.init.headers, k => k.toLowerCase());
441
445
  return norm;
442
446
  }
@@ -453,7 +457,7 @@ export class Fetcher {
453
457
  'logRequestBody',
454
458
  'logResponse',
455
459
  'logResponseBody',
456
- ])), { started: Date.now() }), _omit(opt, ['method', 'headers', 'credentials'])), { inputUrl: opt.url || '', fullUrl: opt.url || '', retry: Object.assign(Object.assign({}, this.cfg.retry), _filterUndefinedValues(opt.retry || {})), init: _merge(Object.assign(Object.assign({}, this.cfg.init), { method: opt.method || this.cfg.init.method, credentials: opt.credentials || this.cfg.init.credentials, redirect: opt.redirect || 'follow' }), {
460
+ ])), { started: Date.now() }), _omit(opt, ['method', 'headers', 'credentials'])), { inputUrl: opt.url || '', fullUrl: opt.url || '', retry: Object.assign(Object.assign({}, this.cfg.retry), _filterUndefinedValues(opt.retry || {})), init: _merge(Object.assign(Object.assign({}, this.cfg.init), { method: opt.method || this.cfg.init.method, credentials: opt.credentials || this.cfg.init.credentials, redirect: opt.redirect || this.cfg.init.redirect || 'follow' }), {
457
461
  headers: _mapKeys(opt.headers || {}, k => k.toLowerCase()),
458
462
  }) });
459
463
  // setup url
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.153.1",
3
+ "version": "14.153.3",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -7,7 +7,14 @@ export interface FetcherNormalizedCfg
7
7
  extends Required<FetcherCfg>,
8
8
  Omit<
9
9
  FetcherRequest,
10
- 'started' | 'fullUrl' | 'logRequest' | 'logRequestBody' | 'logResponse' | 'logResponseBody'
10
+ | 'started'
11
+ | 'fullUrl'
12
+ | 'logRequest'
13
+ | 'logRequestBody'
14
+ | 'logResponse'
15
+ | 'logResponseBody'
16
+ | 'redirect'
17
+ | 'credentials'
11
18
  > {
12
19
  logger: CommonLogger
13
20
  searchParams: Record<string, any>
@@ -15,6 +15,7 @@ import {
15
15
  } from '../object/object.util'
16
16
  import { pDelay } from '../promise/pDelay'
17
17
  import { _jsonParse, _jsonParseIfPossible } from '../string/json.util'
18
+ import { _stringifyAny } from '../string/stringifyAny'
18
19
  import { _since } from '../time/time.util'
19
20
  import { NumberOfMilliseconds } from '../types'
20
21
  import type {
@@ -405,8 +406,9 @@ export class Fetcher {
405
406
  _since(res.req.started),
406
407
  ]
407
408
  .filter(Boolean)
408
- .join(' '),
409
- res.err.cause || res.err,
409
+ .join(' ') + '\n',
410
+ // We're stringifying the error here, otherwise Sentry shows it as [object Object]
411
+ _stringifyAny(res.err.cause || res.err),
410
412
  )
411
413
  }
412
414
 
@@ -546,10 +548,11 @@ export class Fetcher {
546
548
  method: cfg.method || 'GET',
547
549
  headers: cfg.headers || {},
548
550
  credentials: cfg.credentials,
551
+ redirect: cfg.redirect,
549
552
  },
550
553
  hooks: {},
551
554
  },
552
- _omit(cfg, ['method', 'credentials', 'headers', 'logger']),
555
+ _omit(cfg, ['method', 'credentials', 'headers', 'redirect', 'logger']),
553
556
  )
554
557
 
555
558
  norm.init.headers = _mapKeys(norm.init.headers, k => k.toLowerCase())
@@ -585,7 +588,7 @@ export class Fetcher {
585
588
  ...this.cfg.init,
586
589
  method: opt.method || this.cfg.init.method,
587
590
  credentials: opt.credentials || this.cfg.init.credentials,
588
- redirect: opt.redirect || 'follow',
591
+ redirect: opt.redirect || this.cfg.init.redirect || 'follow',
589
592
  },
590
593
  {
591
594
  headers: _mapKeys(opt.headers || {}, k => k.toLowerCase()),