@npora/request 0.4.0 → 1.0.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 +22 -3
- package/dist/index.cjs +0 -17
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -286,6 +286,22 @@ docs
|
|
|
286
286
|
|
|
287
287
|
---
|
|
288
288
|
|
|
289
|
+
# Versioning
|
|
290
|
+
|
|
291
|
+
Starting with 1.0, `@npora/request` follows Semantic Versioning.
|
|
292
|
+
|
|
293
|
+
The stable public contract includes:
|
|
294
|
+
|
|
295
|
+
- Package exports and their TypeScript declarations.
|
|
296
|
+
- Documented client methods, configuration and response shapes.
|
|
297
|
+
- Stable `RequestError` and `PluginError` codes.
|
|
298
|
+
- Plugin lifecycle and extension configuration behavior.
|
|
299
|
+
|
|
300
|
+
Breaking changes to this contract require a new major version. Internal modules
|
|
301
|
+
that are not exported from the package root are not part of the public API.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
289
305
|
# Browser Support
|
|
290
306
|
|
|
291
307
|
Supported runtimes:
|
|
@@ -336,9 +352,12 @@ Business
|
|
|
336
352
|
|
|
337
353
|
## v1.0
|
|
338
354
|
|
|
339
|
-
Stable API
|
|
340
|
-
|
|
341
|
-
|
|
355
|
+
- Stable SemVer API contract
|
|
356
|
+
- Exact runtime and type export gates
|
|
357
|
+
- Package-level behavior compatibility suite
|
|
358
|
+
- Node.js 22, 24 and 26 verification
|
|
359
|
+
- Chromium and WebKit verification
|
|
360
|
+
- Automated npm, Git tag and GitHub Release publishing
|
|
342
361
|
|
|
343
362
|
---
|
|
344
363
|
|
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,
|
|
@@ -1513,7 +1512,6 @@ var DEFAULT_VARY_HEADERS = [
|
|
|
1513
1512
|
"accept",
|
|
1514
1513
|
"accept-language"
|
|
1515
1514
|
];
|
|
1516
|
-
var cacheGeneration = 0;
|
|
1517
1515
|
function cachePlugin(options = {}) {
|
|
1518
1516
|
const cacheStore = /* @__PURE__ */ new Map();
|
|
1519
1517
|
const cacheHits = /* @__PURE__ */ new WeakSet();
|
|
@@ -1521,16 +1519,13 @@ function cachePlugin(options = {}) {
|
|
|
1521
1519
|
options.methods ?? DEFAULT_CACHE_METHODS
|
|
1522
1520
|
);
|
|
1523
1521
|
const varyHeaders = options.varyHeaders ?? DEFAULT_VARY_HEADERS;
|
|
1524
|
-
let localGeneration = cacheGeneration;
|
|
1525
1522
|
const plugin = {
|
|
1526
1523
|
name: "cache",
|
|
1527
1524
|
clear() {
|
|
1528
1525
|
cacheStore.clear();
|
|
1529
|
-
localGeneration = cacheGeneration;
|
|
1530
1526
|
},
|
|
1531
1527
|
install(context) {
|
|
1532
1528
|
context.hooks.onRequest((requestContext) => {
|
|
1533
|
-
syncGeneration();
|
|
1534
1529
|
const cache = resolveExtensionConfig(
|
|
1535
1530
|
requestContext.config,
|
|
1536
1531
|
"cache"
|
|
@@ -1562,7 +1557,6 @@ function cachePlugin(options = {}) {
|
|
|
1562
1557
|
cacheHits.add(requestContext);
|
|
1563
1558
|
});
|
|
1564
1559
|
context.hooks.onResponse((requestContext) => {
|
|
1565
|
-
syncGeneration();
|
|
1566
1560
|
if (cacheHits.has(requestContext)) {
|
|
1567
1561
|
return;
|
|
1568
1562
|
}
|
|
@@ -1595,16 +1589,6 @@ function cachePlugin(options = {}) {
|
|
|
1595
1589
|
}
|
|
1596
1590
|
};
|
|
1597
1591
|
return plugin;
|
|
1598
|
-
function syncGeneration() {
|
|
1599
|
-
if (localGeneration === cacheGeneration) {
|
|
1600
|
-
return;
|
|
1601
|
-
}
|
|
1602
|
-
cacheStore.clear();
|
|
1603
|
-
localGeneration = cacheGeneration;
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
function clearCache() {
|
|
1607
|
-
cacheGeneration += 1;
|
|
1608
1592
|
}
|
|
1609
1593
|
function isCacheableRequest(config, methods) {
|
|
1610
1594
|
return methods.has(config.method ?? "GET") && config.responseType !== "stream";
|
|
@@ -2442,7 +2426,6 @@ function uploadPlugin() {
|
|
|
2442
2426
|
RequestError,
|
|
2443
2427
|
authPlugin,
|
|
2444
2428
|
cachePlugin,
|
|
2445
|
-
clearCache,
|
|
2446
2429
|
createClient,
|
|
2447
2430
|
downloadPlugin,
|
|
2448
2431
|
loggerPlugin,
|
package/dist/index.d.cts
CHANGED
|
@@ -466,7 +466,6 @@ interface CachePlugin extends Plugin {
|
|
|
466
466
|
clear(): void;
|
|
467
467
|
}
|
|
468
468
|
declare function cachePlugin(options?: CachePluginOptions): CachePlugin;
|
|
469
|
-
declare function clearCache(): void;
|
|
470
469
|
|
|
471
470
|
type DownloadTransport = 'auto' | 'fetch' | 'xhr';
|
|
472
471
|
interface DownloadPluginOptions {
|
|
@@ -488,4 +487,4 @@ declare function retryPlugin(defaultOptions?: RetryOptions): Plugin;
|
|
|
488
487
|
|
|
489
488
|
declare function uploadPlugin(): Plugin;
|
|
490
489
|
|
|
491
|
-
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,
|
|
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
|
@@ -466,7 +466,6 @@ interface CachePlugin extends Plugin {
|
|
|
466
466
|
clear(): void;
|
|
467
467
|
}
|
|
468
468
|
declare function cachePlugin(options?: CachePluginOptions): CachePlugin;
|
|
469
|
-
declare function clearCache(): void;
|
|
470
469
|
|
|
471
470
|
type DownloadTransport = 'auto' | 'fetch' | 'xhr';
|
|
472
471
|
interface DownloadPluginOptions {
|
|
@@ -488,4 +487,4 @@ declare function retryPlugin(defaultOptions?: RetryOptions): Plugin;
|
|
|
488
487
|
|
|
489
488
|
declare function uploadPlugin(): Plugin;
|
|
490
489
|
|
|
491
|
-
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,
|
|
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
|
@@ -1474,7 +1474,6 @@ var DEFAULT_VARY_HEADERS = [
|
|
|
1474
1474
|
"accept",
|
|
1475
1475
|
"accept-language"
|
|
1476
1476
|
];
|
|
1477
|
-
var cacheGeneration = 0;
|
|
1478
1477
|
function cachePlugin(options = {}) {
|
|
1479
1478
|
const cacheStore = /* @__PURE__ */ new Map();
|
|
1480
1479
|
const cacheHits = /* @__PURE__ */ new WeakSet();
|
|
@@ -1482,16 +1481,13 @@ function cachePlugin(options = {}) {
|
|
|
1482
1481
|
options.methods ?? DEFAULT_CACHE_METHODS
|
|
1483
1482
|
);
|
|
1484
1483
|
const varyHeaders = options.varyHeaders ?? DEFAULT_VARY_HEADERS;
|
|
1485
|
-
let localGeneration = cacheGeneration;
|
|
1486
1484
|
const plugin = {
|
|
1487
1485
|
name: "cache",
|
|
1488
1486
|
clear() {
|
|
1489
1487
|
cacheStore.clear();
|
|
1490
|
-
localGeneration = cacheGeneration;
|
|
1491
1488
|
},
|
|
1492
1489
|
install(context) {
|
|
1493
1490
|
context.hooks.onRequest((requestContext) => {
|
|
1494
|
-
syncGeneration();
|
|
1495
1491
|
const cache = resolveExtensionConfig(
|
|
1496
1492
|
requestContext.config,
|
|
1497
1493
|
"cache"
|
|
@@ -1523,7 +1519,6 @@ function cachePlugin(options = {}) {
|
|
|
1523
1519
|
cacheHits.add(requestContext);
|
|
1524
1520
|
});
|
|
1525
1521
|
context.hooks.onResponse((requestContext) => {
|
|
1526
|
-
syncGeneration();
|
|
1527
1522
|
if (cacheHits.has(requestContext)) {
|
|
1528
1523
|
return;
|
|
1529
1524
|
}
|
|
@@ -1556,16 +1551,6 @@ function cachePlugin(options = {}) {
|
|
|
1556
1551
|
}
|
|
1557
1552
|
};
|
|
1558
1553
|
return plugin;
|
|
1559
|
-
function syncGeneration() {
|
|
1560
|
-
if (localGeneration === cacheGeneration) {
|
|
1561
|
-
return;
|
|
1562
|
-
}
|
|
1563
|
-
cacheStore.clear();
|
|
1564
|
-
localGeneration = cacheGeneration;
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
function clearCache() {
|
|
1568
|
-
cacheGeneration += 1;
|
|
1569
1554
|
}
|
|
1570
1555
|
function isCacheableRequest(config, methods) {
|
|
1571
1556
|
return methods.has(config.method ?? "GET") && config.responseType !== "stream";
|
|
@@ -2402,7 +2387,6 @@ export {
|
|
|
2402
2387
|
RequestError,
|
|
2403
2388
|
authPlugin,
|
|
2404
2389
|
cachePlugin,
|
|
2405
|
-
clearCache,
|
|
2406
2390
|
createClient,
|
|
2407
2391
|
downloadPlugin,
|
|
2408
2392
|
loggerPlugin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npora/request",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.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/api-contract.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",
|