@npora/request 0.3.0 → 0.5.0

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/README.md CHANGED
@@ -187,8 +187,8 @@ const user = await request.get<User>('/users/1', {
187
187
  })
188
188
  ```
189
189
 
190
- Plugin configuration belongs under `extensions`. Legacy top-level plugin
191
- fields remain available during v0.x but are deprecated.
190
+ Plugin configuration belongs under `extensions`. Top-level plugin fields are
191
+ not part of `RequestConfig`.
192
192
 
193
193
  ---
194
194
 
package/dist/index.cjs CHANGED
@@ -28,7 +28,6 @@ __export(index_exports, {
28
28
  RequestError: () => RequestError,
29
29
  authPlugin: () => authPlugin,
30
30
  cachePlugin: () => cachePlugin,
31
- clearCache: () => clearCache,
32
31
  createClient: () => createClient,
33
32
  downloadPlugin: () => downloadPlugin,
34
33
  loggerPlugin: () => loggerPlugin,
@@ -542,42 +541,6 @@ var ConfigMerger = class {
542
541
  config.extensions
543
542
  );
544
543
  }
545
- if (defaults.retry !== void 0 || config.retry !== void 0) {
546
- result.retry = this.mergeRetry(
547
- defaults.retry,
548
- config.retry
549
- );
550
- }
551
- if (defaults.cache || config.cache) {
552
- result.cache = this.mergeObject(
553
- defaults.cache,
554
- config.cache
555
- );
556
- }
557
- if (defaults.auth || config.auth) {
558
- result.auth = this.mergeObject(
559
- defaults.auth,
560
- config.auth
561
- );
562
- }
563
- if (defaults.logger || config.logger) {
564
- result.logger = this.mergeObject(
565
- defaults.logger,
566
- config.logger
567
- );
568
- }
569
- if (defaults.upload || config.upload) {
570
- result.upload = this.mergeObject(
571
- defaults.upload,
572
- config.upload
573
- );
574
- }
575
- if (defaults.download || config.download) {
576
- result.download = this.mergeObject(
577
- defaults.download,
578
- config.download
579
- );
580
- }
581
544
  if (this.hasBodyConfig(defaults) || this.hasBodyConfig(config)) {
582
545
  Object.assign(
583
546
  result,
@@ -646,21 +609,6 @@ var ConfigMerger = class {
646
609
  ...value
647
610
  };
648
611
  }
649
- static mergeRetry(defaults, retry) {
650
- if (retry === void 0) {
651
- return defaults;
652
- }
653
- if (typeof retry === "number") {
654
- return retry;
655
- }
656
- const normalizedDefaults = typeof defaults === "number" ? {
657
- retries: defaults
658
- } : defaults;
659
- return {
660
- ...normalizedDefaults,
661
- ...retry
662
- };
663
- }
664
612
  static mergeExtensions(defaults, extensions) {
665
613
  if (!defaults && !extensions) {
666
614
  return void 0;
@@ -1438,8 +1386,8 @@ function createClient(options = {}) {
1438
1386
  }
1439
1387
 
1440
1388
  // src/plugins/resolveExtensionConfig.ts
1441
- function resolveExtensionConfig(config, key, legacy) {
1442
- return config.extensions?.[key] ?? legacy;
1389
+ function resolveExtensionConfig(config, key) {
1390
+ return config.extensions?.[key];
1443
1391
  }
1444
1392
 
1445
1393
  // src/plugins/authPlugin.ts
@@ -1519,8 +1467,7 @@ async function applyAuthorization(config, options) {
1519
1467
  async function resolveAuthorization(config, options, tokenOverride) {
1520
1468
  const requestAuth = resolveExtensionConfig(
1521
1469
  config,
1522
- "auth",
1523
- config.auth
1470
+ "auth"
1524
1471
  );
1525
1472
  const token = tokenOverride ?? (requestAuth?.token ? await resolveToken(requestAuth.token) : await resolvePluginToken(options));
1526
1473
  return {
@@ -1565,7 +1512,6 @@ var DEFAULT_VARY_HEADERS = [
1565
1512
  "accept",
1566
1513
  "accept-language"
1567
1514
  ];
1568
- var cacheGeneration = 0;
1569
1515
  function cachePlugin(options = {}) {
1570
1516
  const cacheStore = /* @__PURE__ */ new Map();
1571
1517
  const cacheHits = /* @__PURE__ */ new WeakSet();
@@ -1573,20 +1519,16 @@ function cachePlugin(options = {}) {
1573
1519
  options.methods ?? DEFAULT_CACHE_METHODS
1574
1520
  );
1575
1521
  const varyHeaders = options.varyHeaders ?? DEFAULT_VARY_HEADERS;
1576
- let localGeneration = cacheGeneration;
1577
1522
  const plugin = {
1578
1523
  name: "cache",
1579
1524
  clear() {
1580
1525
  cacheStore.clear();
1581
- localGeneration = cacheGeneration;
1582
1526
  },
1583
1527
  install(context) {
1584
1528
  context.hooks.onRequest((requestContext) => {
1585
- syncGeneration();
1586
1529
  const cache = resolveExtensionConfig(
1587
1530
  requestContext.config,
1588
- "cache",
1589
- requestContext.config.cache
1531
+ "cache"
1590
1532
  );
1591
1533
  if (!cache?.enabled || !isCacheableRequest(requestContext.config, methods)) {
1592
1534
  return;
@@ -1615,14 +1557,12 @@ function cachePlugin(options = {}) {
1615
1557
  cacheHits.add(requestContext);
1616
1558
  });
1617
1559
  context.hooks.onResponse((requestContext) => {
1618
- syncGeneration();
1619
1560
  if (cacheHits.has(requestContext)) {
1620
1561
  return;
1621
1562
  }
1622
1563
  const cache = resolveExtensionConfig(
1623
1564
  requestContext.config,
1624
- "cache",
1625
- requestContext.config.cache
1565
+ "cache"
1626
1566
  );
1627
1567
  if (!cache?.enabled || !requestContext.response || !isCacheableRequest(requestContext.config, methods)) {
1628
1568
  return;
@@ -1649,16 +1589,6 @@ function cachePlugin(options = {}) {
1649
1589
  }
1650
1590
  };
1651
1591
  return plugin;
1652
- function syncGeneration() {
1653
- if (localGeneration === cacheGeneration) {
1654
- return;
1655
- }
1656
- cacheStore.clear();
1657
- localGeneration = cacheGeneration;
1658
- }
1659
- }
1660
- function clearCache() {
1661
- cacheGeneration += 1;
1662
1592
  }
1663
1593
  function isCacheableRequest(config, methods) {
1664
1594
  return methods.has(config.method ?? "GET") && config.responseType !== "stream";
@@ -2004,8 +1934,7 @@ function downloadPlugin(options = {}) {
2004
1934
  context.interceptors.request.use((config) => {
2005
1935
  const download = resolveExtensionConfig(
2006
1936
  config,
2007
- "download",
2008
- config.download
1937
+ "download"
2009
1938
  );
2010
1939
  if (!download) {
2011
1940
  return config;
@@ -2022,8 +1951,7 @@ function downloadPlugin(options = {}) {
2022
1951
  }
2023
1952
  const download = resolveExtensionConfig(
2024
1953
  requestContext.config,
2025
- "download",
2026
- requestContext.config.download
1954
+ "download"
2027
1955
  );
2028
1956
  const onProgress = download?.onProgress;
2029
1957
  if (!onProgress || !shouldUseXHR(options.transport)) {
@@ -2056,8 +1984,7 @@ function downloadPlugin(options = {}) {
2056
1984
  }
2057
1985
  const download = resolveExtensionConfig(
2058
1986
  response.config,
2059
- "download",
2060
- response.config.download
1987
+ "download"
2061
1988
  );
2062
1989
  const onProgress = download?.onProgress;
2063
1990
  if (!download || !onProgress) {
@@ -2176,8 +2103,7 @@ function loggerPlugin(defaultOptions = {}) {
2176
2103
  context.interceptors.request.use((config) => {
2177
2104
  const logger = resolveExtensionConfig(
2178
2105
  config,
2179
- "logger",
2180
- config.logger
2106
+ "logger"
2181
2107
  ) ?? defaultOptions;
2182
2108
  if (logger.enabled === false) {
2183
2109
  return config;
@@ -2192,8 +2118,7 @@ function loggerPlugin(defaultOptions = {}) {
2192
2118
  context.interceptors.response.use((response) => {
2193
2119
  const logger = resolveExtensionConfig(
2194
2120
  response.config,
2195
- "logger",
2196
- response.config.logger
2121
+ "logger"
2197
2122
  ) ?? defaultOptions;
2198
2123
  if (logger.enabled === false) {
2199
2124
  return response;
@@ -2210,8 +2135,7 @@ function loggerPlugin(defaultOptions = {}) {
2210
2135
  const config = error instanceof RequestError ? error.config : void 0;
2211
2136
  const logger = config ? resolveExtensionConfig(
2212
2137
  config,
2213
- "logger",
2214
- config.logger
2138
+ "logger"
2215
2139
  ) ?? defaultOptions : defaultOptions;
2216
2140
  if (logger.enabled === false) {
2217
2141
  return error;
@@ -2304,8 +2228,7 @@ function retryPlugin(defaultOptions = {}) {
2304
2228
  const retryOptions = normalizeRetryOptions(
2305
2229
  resolveExtensionConfig(
2306
2230
  requestContext.config,
2307
- "retry",
2308
- requestContext.config.retry
2231
+ "retry"
2309
2232
  ),
2310
2233
  defaultOptions
2311
2234
  );
@@ -2452,8 +2375,7 @@ function uploadPlugin() {
2452
2375
  context.interceptors.request.use((config) => {
2453
2376
  const upload = resolveExtensionConfig(
2454
2377
  config,
2455
- "upload",
2456
- config.upload
2378
+ "upload"
2457
2379
  );
2458
2380
  if (!upload) {
2459
2381
  return config;
@@ -2470,8 +2392,7 @@ function uploadPlugin() {
2470
2392
  }
2471
2393
  const upload = resolveExtensionConfig(
2472
2394
  requestContext.config,
2473
- "upload",
2474
- requestContext.config.upload
2395
+ "upload"
2475
2396
  );
2476
2397
  if (!upload?.onProgress) {
2477
2398
  return;
@@ -2505,7 +2426,6 @@ function uploadPlugin() {
2505
2426
  RequestError,
2506
2427
  authPlugin,
2507
2428
  cachePlugin,
2508
- clearCache,
2509
2429
  createClient,
2510
2430
  downloadPlugin,
2511
2431
  loggerPlugin,
package/dist/index.d.cts CHANGED
@@ -130,30 +130,6 @@ interface RequestConfig {
130
130
  responseType?: ResponseType;
131
131
  validateStatus?: (status: number) => boolean;
132
132
  extensions?: RequestExtensions;
133
- /**
134
- * @deprecated Use extensions.retry instead.
135
- */
136
- retry?: number | RetryOptions;
137
- /**
138
- * @deprecated Use extensions.cache instead.
139
- */
140
- cache?: CacheOptions;
141
- /**
142
- * @deprecated Use extensions.auth instead.
143
- */
144
- auth?: AuthOptions;
145
- /**
146
- * @deprecated Use extensions.logger instead.
147
- */
148
- logger?: LoggerOptions;
149
- /**
150
- * @deprecated Use extensions.upload instead.
151
- */
152
- upload?: UploadOptions;
153
- /**
154
- * @deprecated Use extensions.download instead.
155
- */
156
- download?: DownloadOptions;
157
133
  }
158
134
 
159
135
  /**
@@ -490,7 +466,6 @@ interface CachePlugin extends Plugin {
490
466
  clear(): void;
491
467
  }
492
468
  declare function cachePlugin(options?: CachePluginOptions): CachePlugin;
493
- declare function clearCache(): void;
494
469
 
495
470
  type DownloadTransport = 'auto' | 'fetch' | 'xhr';
496
471
  interface DownloadPluginOptions {
@@ -512,4 +487,4 @@ declare function retryPlugin(defaultOptions?: RetryOptions): Plugin;
512
487
 
513
488
  declare function uploadPlugin(): Plugin;
514
489
 
515
- export { type Adapter, type AuthOptions, type AuthPluginOptions, type AuthTokenStorage, type CacheOptions, type CachePlugin, type CachePluginOptions, Client, type ClientOptions, type DownloadOptions, type DownloadPluginOptions, type DownloadProgress, type DownloadTransport, FetchAdapter, type FetchOptions, type HttpMethod, type Interceptor, InterceptorManager, type InterceptorOptions, type LoggerOptions, MockAdapter, type MockAdapterOptions, type MockHandler, type NporaResponse, type Plugin, type PluginCleanup, type PluginContext, PluginError, type PluginErrorCode, type PluginErrorOptions, type PluginHookManager, type PluginInterceptorManager, type QueryParams, type QueryValue, type RequestConfig, RequestError, type RequestErrorCode, type RequestErrorOptions, type RequestExtensions, type ResponseType, type RetryOptions, type UploadData, type UploadOptions, type UploadProgress, authPlugin, cachePlugin, clearCache, createClient, downloadPlugin, loggerPlugin, retryPlugin, uploadPlugin };
490
+ export { type Adapter, type AuthOptions, type AuthPluginOptions, type AuthTokenStorage, type CacheOptions, type CachePlugin, type CachePluginOptions, Client, type ClientOptions, type DownloadOptions, type DownloadPluginOptions, type DownloadProgress, type DownloadTransport, FetchAdapter, type FetchOptions, type HttpMethod, type Interceptor, InterceptorManager, type InterceptorOptions, type LoggerOptions, MockAdapter, type MockAdapterOptions, type MockHandler, type NporaResponse, type Plugin, type PluginCleanup, type PluginContext, PluginError, type PluginErrorCode, type PluginErrorOptions, type PluginHookManager, type PluginInterceptorManager, type QueryParams, type QueryValue, type RequestConfig, RequestError, type RequestErrorCode, type RequestErrorOptions, type RequestExtensions, type ResponseType, type RetryOptions, type UploadData, type UploadOptions, type UploadProgress, authPlugin, cachePlugin, createClient, downloadPlugin, loggerPlugin, retryPlugin, uploadPlugin };
package/dist/index.d.ts CHANGED
@@ -130,30 +130,6 @@ interface RequestConfig {
130
130
  responseType?: ResponseType;
131
131
  validateStatus?: (status: number) => boolean;
132
132
  extensions?: RequestExtensions;
133
- /**
134
- * @deprecated Use extensions.retry instead.
135
- */
136
- retry?: number | RetryOptions;
137
- /**
138
- * @deprecated Use extensions.cache instead.
139
- */
140
- cache?: CacheOptions;
141
- /**
142
- * @deprecated Use extensions.auth instead.
143
- */
144
- auth?: AuthOptions;
145
- /**
146
- * @deprecated Use extensions.logger instead.
147
- */
148
- logger?: LoggerOptions;
149
- /**
150
- * @deprecated Use extensions.upload instead.
151
- */
152
- upload?: UploadOptions;
153
- /**
154
- * @deprecated Use extensions.download instead.
155
- */
156
- download?: DownloadOptions;
157
133
  }
158
134
 
159
135
  /**
@@ -490,7 +466,6 @@ interface CachePlugin extends Plugin {
490
466
  clear(): void;
491
467
  }
492
468
  declare function cachePlugin(options?: CachePluginOptions): CachePlugin;
493
- declare function clearCache(): void;
494
469
 
495
470
  type DownloadTransport = 'auto' | 'fetch' | 'xhr';
496
471
  interface DownloadPluginOptions {
@@ -512,4 +487,4 @@ declare function retryPlugin(defaultOptions?: RetryOptions): Plugin;
512
487
 
513
488
  declare function uploadPlugin(): Plugin;
514
489
 
515
- export { type Adapter, type AuthOptions, type AuthPluginOptions, type AuthTokenStorage, type CacheOptions, type CachePlugin, type CachePluginOptions, Client, type ClientOptions, type DownloadOptions, type DownloadPluginOptions, type DownloadProgress, type DownloadTransport, FetchAdapter, type FetchOptions, type HttpMethod, type Interceptor, InterceptorManager, type InterceptorOptions, type LoggerOptions, MockAdapter, type MockAdapterOptions, type MockHandler, type NporaResponse, type Plugin, type PluginCleanup, type PluginContext, PluginError, type PluginErrorCode, type PluginErrorOptions, type PluginHookManager, type PluginInterceptorManager, type QueryParams, type QueryValue, type RequestConfig, RequestError, type RequestErrorCode, type RequestErrorOptions, type RequestExtensions, type ResponseType, type RetryOptions, type UploadData, type UploadOptions, type UploadProgress, authPlugin, cachePlugin, clearCache, createClient, downloadPlugin, loggerPlugin, retryPlugin, uploadPlugin };
490
+ export { type Adapter, type AuthOptions, type AuthPluginOptions, type AuthTokenStorage, type CacheOptions, type CachePlugin, type CachePluginOptions, Client, type ClientOptions, type DownloadOptions, type DownloadPluginOptions, type DownloadProgress, type DownloadTransport, FetchAdapter, type FetchOptions, type HttpMethod, type Interceptor, InterceptorManager, type InterceptorOptions, type LoggerOptions, MockAdapter, type MockAdapterOptions, type MockHandler, type NporaResponse, type Plugin, type PluginCleanup, type PluginContext, PluginError, type PluginErrorCode, type PluginErrorOptions, type PluginHookManager, type PluginInterceptorManager, type QueryParams, type QueryValue, type RequestConfig, RequestError, type RequestErrorCode, type RequestErrorOptions, type RequestExtensions, type ResponseType, type RetryOptions, type UploadData, type UploadOptions, type UploadProgress, authPlugin, cachePlugin, createClient, downloadPlugin, loggerPlugin, retryPlugin, uploadPlugin };
package/dist/index.js CHANGED
@@ -503,42 +503,6 @@ var ConfigMerger = class {
503
503
  config.extensions
504
504
  );
505
505
  }
506
- if (defaults.retry !== void 0 || config.retry !== void 0) {
507
- result.retry = this.mergeRetry(
508
- defaults.retry,
509
- config.retry
510
- );
511
- }
512
- if (defaults.cache || config.cache) {
513
- result.cache = this.mergeObject(
514
- defaults.cache,
515
- config.cache
516
- );
517
- }
518
- if (defaults.auth || config.auth) {
519
- result.auth = this.mergeObject(
520
- defaults.auth,
521
- config.auth
522
- );
523
- }
524
- if (defaults.logger || config.logger) {
525
- result.logger = this.mergeObject(
526
- defaults.logger,
527
- config.logger
528
- );
529
- }
530
- if (defaults.upload || config.upload) {
531
- result.upload = this.mergeObject(
532
- defaults.upload,
533
- config.upload
534
- );
535
- }
536
- if (defaults.download || config.download) {
537
- result.download = this.mergeObject(
538
- defaults.download,
539
- config.download
540
- );
541
- }
542
506
  if (this.hasBodyConfig(defaults) || this.hasBodyConfig(config)) {
543
507
  Object.assign(
544
508
  result,
@@ -607,21 +571,6 @@ var ConfigMerger = class {
607
571
  ...value
608
572
  };
609
573
  }
610
- static mergeRetry(defaults, retry) {
611
- if (retry === void 0) {
612
- return defaults;
613
- }
614
- if (typeof retry === "number") {
615
- return retry;
616
- }
617
- const normalizedDefaults = typeof defaults === "number" ? {
618
- retries: defaults
619
- } : defaults;
620
- return {
621
- ...normalizedDefaults,
622
- ...retry
623
- };
624
- }
625
574
  static mergeExtensions(defaults, extensions) {
626
575
  if (!defaults && !extensions) {
627
576
  return void 0;
@@ -1399,8 +1348,8 @@ function createClient(options = {}) {
1399
1348
  }
1400
1349
 
1401
1350
  // src/plugins/resolveExtensionConfig.ts
1402
- function resolveExtensionConfig(config, key, legacy) {
1403
- return config.extensions?.[key] ?? legacy;
1351
+ function resolveExtensionConfig(config, key) {
1352
+ return config.extensions?.[key];
1404
1353
  }
1405
1354
 
1406
1355
  // src/plugins/authPlugin.ts
@@ -1480,8 +1429,7 @@ async function applyAuthorization(config, options) {
1480
1429
  async function resolveAuthorization(config, options, tokenOverride) {
1481
1430
  const requestAuth = resolveExtensionConfig(
1482
1431
  config,
1483
- "auth",
1484
- config.auth
1432
+ "auth"
1485
1433
  );
1486
1434
  const token = tokenOverride ?? (requestAuth?.token ? await resolveToken(requestAuth.token) : await resolvePluginToken(options));
1487
1435
  return {
@@ -1526,7 +1474,6 @@ var DEFAULT_VARY_HEADERS = [
1526
1474
  "accept",
1527
1475
  "accept-language"
1528
1476
  ];
1529
- var cacheGeneration = 0;
1530
1477
  function cachePlugin(options = {}) {
1531
1478
  const cacheStore = /* @__PURE__ */ new Map();
1532
1479
  const cacheHits = /* @__PURE__ */ new WeakSet();
@@ -1534,20 +1481,16 @@ function cachePlugin(options = {}) {
1534
1481
  options.methods ?? DEFAULT_CACHE_METHODS
1535
1482
  );
1536
1483
  const varyHeaders = options.varyHeaders ?? DEFAULT_VARY_HEADERS;
1537
- let localGeneration = cacheGeneration;
1538
1484
  const plugin = {
1539
1485
  name: "cache",
1540
1486
  clear() {
1541
1487
  cacheStore.clear();
1542
- localGeneration = cacheGeneration;
1543
1488
  },
1544
1489
  install(context) {
1545
1490
  context.hooks.onRequest((requestContext) => {
1546
- syncGeneration();
1547
1491
  const cache = resolveExtensionConfig(
1548
1492
  requestContext.config,
1549
- "cache",
1550
- requestContext.config.cache
1493
+ "cache"
1551
1494
  );
1552
1495
  if (!cache?.enabled || !isCacheableRequest(requestContext.config, methods)) {
1553
1496
  return;
@@ -1576,14 +1519,12 @@ function cachePlugin(options = {}) {
1576
1519
  cacheHits.add(requestContext);
1577
1520
  });
1578
1521
  context.hooks.onResponse((requestContext) => {
1579
- syncGeneration();
1580
1522
  if (cacheHits.has(requestContext)) {
1581
1523
  return;
1582
1524
  }
1583
1525
  const cache = resolveExtensionConfig(
1584
1526
  requestContext.config,
1585
- "cache",
1586
- requestContext.config.cache
1527
+ "cache"
1587
1528
  );
1588
1529
  if (!cache?.enabled || !requestContext.response || !isCacheableRequest(requestContext.config, methods)) {
1589
1530
  return;
@@ -1610,16 +1551,6 @@ function cachePlugin(options = {}) {
1610
1551
  }
1611
1552
  };
1612
1553
  return plugin;
1613
- function syncGeneration() {
1614
- if (localGeneration === cacheGeneration) {
1615
- return;
1616
- }
1617
- cacheStore.clear();
1618
- localGeneration = cacheGeneration;
1619
- }
1620
- }
1621
- function clearCache() {
1622
- cacheGeneration += 1;
1623
1554
  }
1624
1555
  function isCacheableRequest(config, methods) {
1625
1556
  return methods.has(config.method ?? "GET") && config.responseType !== "stream";
@@ -1965,8 +1896,7 @@ function downloadPlugin(options = {}) {
1965
1896
  context.interceptors.request.use((config) => {
1966
1897
  const download = resolveExtensionConfig(
1967
1898
  config,
1968
- "download",
1969
- config.download
1899
+ "download"
1970
1900
  );
1971
1901
  if (!download) {
1972
1902
  return config;
@@ -1983,8 +1913,7 @@ function downloadPlugin(options = {}) {
1983
1913
  }
1984
1914
  const download = resolveExtensionConfig(
1985
1915
  requestContext.config,
1986
- "download",
1987
- requestContext.config.download
1916
+ "download"
1988
1917
  );
1989
1918
  const onProgress = download?.onProgress;
1990
1919
  if (!onProgress || !shouldUseXHR(options.transport)) {
@@ -2017,8 +1946,7 @@ function downloadPlugin(options = {}) {
2017
1946
  }
2018
1947
  const download = resolveExtensionConfig(
2019
1948
  response.config,
2020
- "download",
2021
- response.config.download
1949
+ "download"
2022
1950
  );
2023
1951
  const onProgress = download?.onProgress;
2024
1952
  if (!download || !onProgress) {
@@ -2137,8 +2065,7 @@ function loggerPlugin(defaultOptions = {}) {
2137
2065
  context.interceptors.request.use((config) => {
2138
2066
  const logger = resolveExtensionConfig(
2139
2067
  config,
2140
- "logger",
2141
- config.logger
2068
+ "logger"
2142
2069
  ) ?? defaultOptions;
2143
2070
  if (logger.enabled === false) {
2144
2071
  return config;
@@ -2153,8 +2080,7 @@ function loggerPlugin(defaultOptions = {}) {
2153
2080
  context.interceptors.response.use((response) => {
2154
2081
  const logger = resolveExtensionConfig(
2155
2082
  response.config,
2156
- "logger",
2157
- response.config.logger
2083
+ "logger"
2158
2084
  ) ?? defaultOptions;
2159
2085
  if (logger.enabled === false) {
2160
2086
  return response;
@@ -2171,8 +2097,7 @@ function loggerPlugin(defaultOptions = {}) {
2171
2097
  const config = error instanceof RequestError ? error.config : void 0;
2172
2098
  const logger = config ? resolveExtensionConfig(
2173
2099
  config,
2174
- "logger",
2175
- config.logger
2100
+ "logger"
2176
2101
  ) ?? defaultOptions : defaultOptions;
2177
2102
  if (logger.enabled === false) {
2178
2103
  return error;
@@ -2265,8 +2190,7 @@ function retryPlugin(defaultOptions = {}) {
2265
2190
  const retryOptions = normalizeRetryOptions(
2266
2191
  resolveExtensionConfig(
2267
2192
  requestContext.config,
2268
- "retry",
2269
- requestContext.config.retry
2193
+ "retry"
2270
2194
  ),
2271
2195
  defaultOptions
2272
2196
  );
@@ -2413,8 +2337,7 @@ function uploadPlugin() {
2413
2337
  context.interceptors.request.use((config) => {
2414
2338
  const upload = resolveExtensionConfig(
2415
2339
  config,
2416
- "upload",
2417
- config.upload
2340
+ "upload"
2418
2341
  );
2419
2342
  if (!upload) {
2420
2343
  return config;
@@ -2431,8 +2354,7 @@ function uploadPlugin() {
2431
2354
  }
2432
2355
  const upload = resolveExtensionConfig(
2433
2356
  requestContext.config,
2434
- "upload",
2435
- requestContext.config.upload
2357
+ "upload"
2436
2358
  );
2437
2359
  if (!upload?.onProgress) {
2438
2360
  return;
@@ -2465,7 +2387,6 @@ export {
2465
2387
  RequestError,
2466
2388
  authPlugin,
2467
2389
  cachePlugin,
2468
- clearCache,
2469
2390
  createClient,
2470
2391
  downloadPlugin,
2471
2392
  loggerPlugin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npora/request",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "A modern, TypeScript-first HTTP client powered by the Fetch API.",
5
5
  "keywords": [
6
6
  "npora",
@@ -66,7 +66,7 @@
66
66
  "test:run": "vitest run",
67
67
  "test:types": "pnpm build && tsc -p test/types/tsconfig.json",
68
68
  "test:examples": "tsc -p examples/tsconfig.json",
69
- "test:package": "node test/package/esm.mjs && node test/package/cjs.cjs && node test/package/npm-pack-result.test.mjs && node test/package/manifest.mjs && pnpm test:size",
69
+ "test:package": "node test/package/esm.mjs && node test/package/cjs.cjs && node test/package/api-exports.mjs && node test/package/npm-pack-result.test.mjs && node test/package/manifest.mjs && pnpm test:size",
70
70
  "test:size": "node test/package/size.mjs",
71
71
  "test:browser": "playwright test --config=browser/playwright.config.ts",
72
72
  "test:browser:ui": "playwright test --config=browser/playwright.config.ts --ui",