@isdk/proxy 0.1.2 → 0.1.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.
- package/README.cn.md +59 -1
- package/README.md +59 -1
- package/dist/index.d.mts +113 -22
- package/dist/index.d.ts +113 -22
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/README.md +59 -1
- package/docs/classes/OfflineCacheMissError.md +426 -0
- package/docs/classes/SmartCache.md +30 -10
- package/docs/functions/createCachedFetch.md +1 -1
- package/docs/functions/createFetchWithCache.md +1 -1
- package/docs/functions/extractData.md +1 -1
- package/docs/functions/fetchWithCache.md +14 -15
- package/docs/functions/generateCacheKey.md +1 -1
- package/docs/functions/getSiteConfig.md +1 -1
- package/docs/functions/isAllowed.md +1 -1
- package/docs/functions/isCacheable.md +27 -0
- package/docs/functions/isGlob.md +1 -1
- package/docs/functions/isMatch.md +1 -1
- package/docs/functions/prefetch.md +33 -0
- package/docs/globals.md +10 -0
- package/docs/interfaces/BodyFilterConfig.md +6 -6
- package/docs/interfaces/CacheEntry.md +9 -9
- package/docs/interfaces/CacheMetadata.md +8 -8
- package/docs/interfaces/CacheRule.md +6 -6
- package/docs/interfaces/FetchWithCacheContext.md +11 -13
- package/docs/interfaces/FetchWithCacheOptions.md +7 -9
- package/docs/interfaces/KeyFilterConfig.md +3 -3
- package/docs/interfaces/PrefetchOptions.md +107 -0
- package/docs/interfaces/PrefetchRequest.md +31 -0
- package/docs/interfaces/PrefetchResult.md +47 -0
- package/docs/interfaces/ProxyConfig.md +4 -4
- package/docs/interfaces/SiteCacheConfig.md +19 -9
- package/docs/interfaces/SmartCacheOptions.md +5 -5
- package/docs/variables/OfflineCacheMissErrorCode.md +18 -0
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **generateCacheKey**(`req`, `config`): `Promise`\<`string`\>
|
|
10
10
|
|
|
11
|
-
Defined in: [core/generateCacheKey.ts:36](https://github.com/isdk/proxy.js/blob/
|
|
11
|
+
Defined in: [packages/proxy/src/core/generateCacheKey.ts:36](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/generateCacheKey.ts#L36)
|
|
12
12
|
|
|
13
13
|
根据 Request 对象和站点配置生成唯一的缓存指纹 (异步)
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **getSiteConfig**(`urlString`, `proxyConfig`): [`SiteCacheConfig`](../interfaces/SiteCacheConfig.md)
|
|
10
10
|
|
|
11
|
-
Defined in: [utils/getSiteConfig.ts:17](https://github.com/isdk/proxy.js/blob/
|
|
11
|
+
Defined in: [packages/proxy/src/utils/getSiteConfig.ts:17](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/utils/getSiteConfig.ts#L17)
|
|
12
12
|
|
|
13
13
|
根据 URL 获取对应的站点缓存配置
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **isAllowed**(`key`, `config?`, `defaultAllowed?`): `boolean`
|
|
10
10
|
|
|
11
|
-
Defined in: [utils/isAllowed.ts:37](https://github.com/isdk/proxy.js/blob/
|
|
11
|
+
Defined in: [packages/proxy/src/utils/isAllowed.ts:37](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/utils/isAllowed.ts#L37)
|
|
12
12
|
|
|
13
13
|
判断给定的键是否允许参与缓存指纹计算。
|
|
14
14
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[**@isdk/proxy**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/proxy](../globals.md) / isCacheable
|
|
6
|
+
|
|
7
|
+
# Function: isCacheable()
|
|
8
|
+
|
|
9
|
+
> **isCacheable**(`request`, `config`): `Promise`\<`boolean`\>
|
|
10
|
+
|
|
11
|
+
Defined in: [packages/proxy/src/core/isCacheable.ts:56](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/isCacheable.ts#L56)
|
|
12
|
+
|
|
13
|
+
判断当前请求是否满足可缓存的基础条件
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
### request
|
|
18
|
+
|
|
19
|
+
`Request`
|
|
20
|
+
|
|
21
|
+
### config
|
|
22
|
+
|
|
23
|
+
[`SiteCacheConfig`](../interfaces/SiteCacheConfig.md)
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
`Promise`\<`boolean`\>
|
package/docs/functions/isGlob.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **isGlob**(`str`): `boolean`
|
|
10
10
|
|
|
11
|
-
Defined in: [utils/matcher.ts:7](https://github.com/isdk/proxy.js/blob/
|
|
11
|
+
Defined in: [packages/proxy/src/utils/matcher.ts:7](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/utils/matcher.ts#L7)
|
|
12
12
|
|
|
13
13
|
判断一个模式是否为 Glob 模式
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **isMatch**(`pattern`, `value`, `usePrefix`): `boolean`
|
|
10
10
|
|
|
11
|
-
Defined in: [utils/matcher.ts:25](https://github.com/isdk/proxy.js/blob/
|
|
11
|
+
Defined in: [packages/proxy/src/utils/matcher.ts:25](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/utils/matcher.ts#L25)
|
|
12
12
|
|
|
13
13
|
通用匹配函数
|
|
14
14
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[**@isdk/proxy**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/proxy](../globals.md) / prefetch
|
|
6
|
+
|
|
7
|
+
# Function: prefetch()
|
|
8
|
+
|
|
9
|
+
> **prefetch**(`options`): `Promise`\<[`PrefetchResult`](../interfaces/PrefetchResult.md)\>
|
|
10
|
+
|
|
11
|
+
Defined in: [packages/proxy/src/core/prefetch.ts:55](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/prefetch.ts#L55)
|
|
12
|
+
|
|
13
|
+
预缓存函数
|
|
14
|
+
|
|
15
|
+
提前将指定的 URL 列表内容存入缓存,支持并发控制和进度回调。
|
|
16
|
+
复用了 `createCachedFetch` 的完整逻辑,自动支持:
|
|
17
|
+
- GET/POST/PUT/PATCH/DELETE 等所有方法
|
|
18
|
+
- POST body 过滤和缓存键生成
|
|
19
|
+
- 站点级配置
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
### options
|
|
24
|
+
|
|
25
|
+
[`PrefetchOptions`](../interfaces/PrefetchOptions.md)
|
|
26
|
+
|
|
27
|
+
预缓存选项
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
`Promise`\<[`PrefetchResult`](../interfaces/PrefetchResult.md)\>
|
|
32
|
+
|
|
33
|
+
预缓存结果,包含成功/失败数量和错误详情
|
package/docs/globals.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## Classes
|
|
8
8
|
|
|
9
|
+
- [OfflineCacheMissError](classes/OfflineCacheMissError.md)
|
|
9
10
|
- [SmartCache](classes/SmartCache.md)
|
|
10
11
|
|
|
11
12
|
## Interfaces
|
|
@@ -17,10 +18,17 @@
|
|
|
17
18
|
- [FetchWithCacheContext](interfaces/FetchWithCacheContext.md)
|
|
18
19
|
- [FetchWithCacheOptions](interfaces/FetchWithCacheOptions.md)
|
|
19
20
|
- [KeyFilterConfig](interfaces/KeyFilterConfig.md)
|
|
21
|
+
- [PrefetchOptions](interfaces/PrefetchOptions.md)
|
|
22
|
+
- [PrefetchRequest](interfaces/PrefetchRequest.md)
|
|
23
|
+
- [PrefetchResult](interfaces/PrefetchResult.md)
|
|
20
24
|
- [ProxyConfig](interfaces/ProxyConfig.md)
|
|
21
25
|
- [SiteCacheConfig](interfaces/SiteCacheConfig.md)
|
|
22
26
|
- [SmartCacheOptions](interfaces/SmartCacheOptions.md)
|
|
23
27
|
|
|
28
|
+
## Variables
|
|
29
|
+
|
|
30
|
+
- [OfflineCacheMissErrorCode](variables/OfflineCacheMissErrorCode.md)
|
|
31
|
+
|
|
24
32
|
## Functions
|
|
25
33
|
|
|
26
34
|
- [createCachedFetch](functions/createCachedFetch.md)
|
|
@@ -30,5 +38,7 @@
|
|
|
30
38
|
- [generateCacheKey](functions/generateCacheKey.md)
|
|
31
39
|
- [getSiteConfig](functions/getSiteConfig.md)
|
|
32
40
|
- [isAllowed](functions/isAllowed.md)
|
|
41
|
+
- [isCacheable](functions/isCacheable.md)
|
|
33
42
|
- [isGlob](functions/isGlob.md)
|
|
34
43
|
- [isMatch](functions/isMatch.md)
|
|
44
|
+
- [prefetch](functions/prefetch.md)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: BodyFilterConfig
|
|
8
8
|
|
|
9
|
-
Defined in: [types.ts:13](https://github.com/isdk/proxy.js/blob/
|
|
9
|
+
Defined in: [packages/proxy/src/types.ts:13](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L13)
|
|
10
10
|
|
|
11
11
|
缓存键过滤配置
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ Defined in: [types.ts:13](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
22
22
|
|
|
23
23
|
> `optional` **exclude**: (`string` \| `RegExp`)[]
|
|
24
24
|
|
|
25
|
-
Defined in: [types.ts:10](https://github.com/isdk/proxy.js/blob/
|
|
25
|
+
Defined in: [packages/proxy/src/types.ts:10](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L10)
|
|
26
26
|
|
|
27
27
|
排除(黑名单):用于排除像 `timestamp`、`nonce` 等干扰缓存命中的动态字段。支持字符串、Glob 模式或正则表达式。
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@ Defined in: [types.ts:10](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
36
36
|
|
|
37
37
|
> `optional` **extract**: `string` \| `RegExp`
|
|
38
38
|
|
|
39
|
-
Defined in: [types.ts:18](https://github.com/isdk/proxy.js/blob/
|
|
39
|
+
Defined in: [packages/proxy/src/types.ts:18](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L18)
|
|
40
40
|
|
|
41
41
|
用于非 JSON (文本) Body 的提取正则表达式。
|
|
42
42
|
如果包含捕获组,则提取捕获组内容作为指纹;否则提取整个匹配部分。
|
|
@@ -47,7 +47,7 @@ Defined in: [types.ts:18](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
47
47
|
|
|
48
48
|
> `optional` **include**: (`string` \| `RegExp`)[]
|
|
49
49
|
|
|
50
|
-
Defined in: [types.ts:8](https://github.com/isdk/proxy.js/blob/
|
|
50
|
+
Defined in: [packages/proxy/src/types.ts:8](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L8)
|
|
51
51
|
|
|
52
52
|
仅包含(白名单):如果设置,只有这些字段会参与 Key 的计算。支持字符串、Glob 模式或正则表达式。
|
|
53
53
|
|
|
@@ -61,7 +61,7 @@ Defined in: [types.ts:8](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5bf
|
|
|
61
61
|
|
|
62
62
|
> `optional` **maxLength**: `number`
|
|
63
63
|
|
|
64
|
-
Defined in: [types.ts:25](https://github.com/isdk/proxy.js/blob/
|
|
64
|
+
Defined in: [packages/proxy/src/types.ts:25](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L25)
|
|
65
65
|
|
|
66
66
|
用于正则匹配/提取 Body 时的最大长度限制,默认 1024 (1KB)
|
|
67
67
|
|
|
@@ -71,7 +71,7 @@ Defined in: [types.ts:25](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
71
71
|
|
|
72
72
|
> `optional` **sort**: `boolean`
|
|
73
73
|
|
|
74
|
-
Defined in: [types.ts:23](https://github.com/isdk/proxy.js/blob/
|
|
74
|
+
Defined in: [packages/proxy/src/types.ts:23](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L23)
|
|
75
75
|
|
|
76
76
|
是否对提取出的捕获组进行排序。
|
|
77
77
|
开启后可解决 Body 中参数顺序不一致导致的指纹失效问题。
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: CacheEntry
|
|
8
8
|
|
|
9
|
-
Defined in: [types.ts:
|
|
9
|
+
Defined in: [packages/proxy/src/types.ts:139](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L139)
|
|
10
10
|
|
|
11
11
|
完整的缓存条目
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ Defined in: [types.ts:137](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
20
20
|
|
|
21
21
|
> **body**: `any`
|
|
22
22
|
|
|
23
|
-
Defined in: [types.ts:
|
|
23
|
+
Defined in: [packages/proxy/src/types.ts:141](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L141)
|
|
24
24
|
|
|
25
25
|
响应体数据:小文件为 Buffer,大文件为可读流
|
|
26
26
|
|
|
@@ -30,7 +30,7 @@ Defined in: [types.ts:139](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
30
30
|
|
|
31
31
|
> **headers**: `Record`\<`string`, `string`\>
|
|
32
32
|
|
|
33
|
-
Defined in: [types.ts:
|
|
33
|
+
Defined in: [packages/proxy/src/types.ts:123](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L123)
|
|
34
34
|
|
|
35
35
|
响应头对象
|
|
36
36
|
|
|
@@ -44,7 +44,7 @@ Defined in: [types.ts:121](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
44
44
|
|
|
45
45
|
> **method**: `string`
|
|
46
46
|
|
|
47
|
-
Defined in: [types.ts:
|
|
47
|
+
Defined in: [packages/proxy/src/types.ts:129](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L129)
|
|
48
48
|
|
|
49
49
|
原始请求方法
|
|
50
50
|
|
|
@@ -58,7 +58,7 @@ Defined in: [types.ts:127](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
58
58
|
|
|
59
59
|
> **policy**: `any`
|
|
60
60
|
|
|
61
|
-
Defined in: [types.ts:
|
|
61
|
+
Defined in: [packages/proxy/src/types.ts:125](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L125)
|
|
62
62
|
|
|
63
63
|
http-cache-semantics 策略对象,包含 TTL 和缓存指令
|
|
64
64
|
|
|
@@ -72,7 +72,7 @@ http-cache-semantics 策略对象,包含 TTL 和缓存指令
|
|
|
72
72
|
|
|
73
73
|
> **size**: `number`
|
|
74
74
|
|
|
75
|
-
Defined in: [types.ts:
|
|
75
|
+
Defined in: [packages/proxy/src/types.ts:133](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L133)
|
|
76
76
|
|
|
77
77
|
Body 的字节长度,用于精确区分“空响应”与“未入内存的大响应”
|
|
78
78
|
|
|
@@ -86,7 +86,7 @@ Body 的字节长度,用于精确区分“空响应”与“未入内存的大
|
|
|
86
86
|
|
|
87
87
|
> **status**: `number`
|
|
88
88
|
|
|
89
|
-
Defined in: [types.ts:
|
|
89
|
+
Defined in: [packages/proxy/src/types.ts:121](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L121)
|
|
90
90
|
|
|
91
91
|
HTTP 状态码
|
|
92
92
|
|
|
@@ -100,7 +100,7 @@ HTTP 状态码
|
|
|
100
100
|
|
|
101
101
|
> **timestamp**: `number`
|
|
102
102
|
|
|
103
|
-
Defined in: [types.ts:
|
|
103
|
+
Defined in: [packages/proxy/src/types.ts:131](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L131)
|
|
104
104
|
|
|
105
105
|
缓存写入时的时间戳
|
|
106
106
|
|
|
@@ -114,7 +114,7 @@ Defined in: [types.ts:129](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
114
114
|
|
|
115
115
|
> **url**: `string`
|
|
116
116
|
|
|
117
|
-
Defined in: [types.ts:
|
|
117
|
+
Defined in: [packages/proxy/src/types.ts:127](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L127)
|
|
118
118
|
|
|
119
119
|
原始请求 URL
|
|
120
120
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: CacheMetadata
|
|
8
8
|
|
|
9
|
-
Defined in: [types.ts:
|
|
9
|
+
Defined in: [packages/proxy/src/types.ts:119](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L119)
|
|
10
10
|
|
|
11
11
|
缓存元数据
|
|
12
12
|
|
|
@@ -23,7 +23,7 @@ Defined in: [types.ts:117](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
23
23
|
|
|
24
24
|
> **headers**: `Record`\<`string`, `string`\>
|
|
25
25
|
|
|
26
|
-
Defined in: [types.ts:
|
|
26
|
+
Defined in: [packages/proxy/src/types.ts:123](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L123)
|
|
27
27
|
|
|
28
28
|
响应头对象
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ Defined in: [types.ts:121](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
33
33
|
|
|
34
34
|
> **method**: `string`
|
|
35
35
|
|
|
36
|
-
Defined in: [types.ts:
|
|
36
|
+
Defined in: [packages/proxy/src/types.ts:129](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L129)
|
|
37
37
|
|
|
38
38
|
原始请求方法
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ Defined in: [types.ts:127](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
43
43
|
|
|
44
44
|
> **policy**: `any`
|
|
45
45
|
|
|
46
|
-
Defined in: [types.ts:
|
|
46
|
+
Defined in: [packages/proxy/src/types.ts:125](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L125)
|
|
47
47
|
|
|
48
48
|
http-cache-semantics 策略对象,包含 TTL 和缓存指令
|
|
49
49
|
|
|
@@ -53,7 +53,7 @@ http-cache-semantics 策略对象,包含 TTL 和缓存指令
|
|
|
53
53
|
|
|
54
54
|
> **size**: `number`
|
|
55
55
|
|
|
56
|
-
Defined in: [types.ts:
|
|
56
|
+
Defined in: [packages/proxy/src/types.ts:133](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L133)
|
|
57
57
|
|
|
58
58
|
Body 的字节长度,用于精确区分“空响应”与“未入内存的大响应”
|
|
59
59
|
|
|
@@ -63,7 +63,7 @@ Body 的字节长度,用于精确区分“空响应”与“未入内存的大
|
|
|
63
63
|
|
|
64
64
|
> **status**: `number`
|
|
65
65
|
|
|
66
|
-
Defined in: [types.ts:
|
|
66
|
+
Defined in: [packages/proxy/src/types.ts:121](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L121)
|
|
67
67
|
|
|
68
68
|
HTTP 状态码
|
|
69
69
|
|
|
@@ -73,7 +73,7 @@ HTTP 状态码
|
|
|
73
73
|
|
|
74
74
|
> **timestamp**: `number`
|
|
75
75
|
|
|
76
|
-
Defined in: [types.ts:
|
|
76
|
+
Defined in: [packages/proxy/src/types.ts:131](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L131)
|
|
77
77
|
|
|
78
78
|
缓存写入时的时间戳
|
|
79
79
|
|
|
@@ -83,6 +83,6 @@ Defined in: [types.ts:129](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5
|
|
|
83
83
|
|
|
84
84
|
> **url**: `string`
|
|
85
85
|
|
|
86
|
-
Defined in: [types.ts:
|
|
86
|
+
Defined in: [packages/proxy/src/types.ts:127](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L127)
|
|
87
87
|
|
|
88
88
|
原始请求 URL
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: CacheRule
|
|
8
8
|
|
|
9
|
-
Defined in: [types.ts:35](https://github.com/isdk/proxy.js/blob/
|
|
9
|
+
Defined in: [packages/proxy/src/types.ts:35](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L35)
|
|
10
10
|
|
|
11
11
|
精细化缓存匹配规则
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ Defined in: [types.ts:35](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
20
20
|
|
|
21
21
|
> `optional` **body**: `string` \| `RegExp` \| (`string` \| `RegExp`)[]
|
|
22
22
|
|
|
23
|
-
Defined in: [types.ts:75](https://github.com/isdk/proxy.js/blob/
|
|
23
|
+
Defined in: [packages/proxy/src/types.ts:75](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L75)
|
|
24
24
|
|
|
25
25
|
Body 内容匹配。
|
|
26
26
|
仅当 Body 为文本或 JSON 时有效。
|
|
@@ -34,7 +34,7 @@ Body 内容匹配。
|
|
|
34
34
|
|
|
35
35
|
> `optional` **bodyType**: `"json"` \| `"text"` \| `"binary"`
|
|
36
36
|
|
|
37
|
-
Defined in: [types.ts:67](https://github.com/isdk/proxy.js/blob/
|
|
37
|
+
Defined in: [packages/proxy/src/types.ts:67](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L67)
|
|
38
38
|
|
|
39
39
|
强制指定 Body 类型。
|
|
40
40
|
如果不指定,则根据 `Content-Type` 自动判断。
|
|
@@ -45,7 +45,7 @@ Defined in: [types.ts:67](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
45
45
|
|
|
46
46
|
> `optional` **method**: `string`
|
|
47
47
|
|
|
48
|
-
Defined in: [types.ts:40](https://github.com/isdk/proxy.js/blob/
|
|
48
|
+
Defined in: [packages/proxy/src/types.ts:40](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L40)
|
|
49
49
|
|
|
50
50
|
匹配的方法 (如 "POST")。
|
|
51
51
|
如果指定,则必须方法完全一致;如果不指定,则匹配所有 `methods` 中允许的方法。
|
|
@@ -56,7 +56,7 @@ Defined in: [types.ts:40](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
56
56
|
|
|
57
57
|
> `optional` **path**: `string` \| `RegExp` \| (`string` \| `RegExp`)[]
|
|
58
58
|
|
|
59
|
-
Defined in: [types.ts:52](https://github.com/isdk/proxy.js/blob/
|
|
59
|
+
Defined in: [packages/proxy/src/types.ts:52](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L52)
|
|
60
60
|
|
|
61
61
|
路径匹配。
|
|
62
62
|
- 字符串: 默认进行 Glob 模式匹配(支持 `!` 否定),若非 Glob 且非正则字符串则退化为前缀匹配。
|
|
@@ -69,7 +69,7 @@ Defined in: [types.ts:52](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
69
69
|
|
|
70
70
|
> `optional` **query**: `Record`\<`string`, `string` \| `boolean` \| `RegExp`\>
|
|
71
71
|
|
|
72
|
-
Defined in: [types.ts:62](https://github.com/isdk/proxy.js/blob/
|
|
72
|
+
Defined in: [packages/proxy/src/types.ts:62](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L62)
|
|
73
73
|
|
|
74
74
|
Query 参数匹配规则。
|
|
75
75
|
- 键名: 支持字符串、Glob 或正则。
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: FetchWithCacheContext
|
|
8
8
|
|
|
9
|
-
Defined in: [core/fetchWithCache.ts:
|
|
9
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:31](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L31)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
内部流水线上下文
|
|
12
12
|
|
|
13
13
|
## Extends
|
|
14
14
|
|
|
@@ -20,11 +20,9 @@ Defined in: [core/fetchWithCache.ts:32](https://github.com/isdk/proxy.js/blob/76
|
|
|
20
20
|
|
|
21
21
|
> **activeCacheWrites**: `Map`\<`string`, `Promise`\<`void`\>\>
|
|
22
22
|
|
|
23
|
-
Defined in: [core/fetchWithCache.ts:
|
|
23
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:35](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L35)
|
|
24
24
|
|
|
25
25
|
并发写入任务追踪器
|
|
26
|
-
传入一个外部维护的 Map,用于在跨请求、跨实例时防止针对同一文件的并发重复下载。
|
|
27
|
-
Map 的 Key 是缓存 Key,Value 是一个代表写入完成的 Promise。
|
|
28
26
|
|
|
29
27
|
#### Overrides
|
|
30
28
|
|
|
@@ -36,7 +34,7 @@ Map 的 Key 是缓存 Key,Value 是一个代表写入完成的 Promise。
|
|
|
36
34
|
|
|
37
35
|
> `optional` **backgroundUpdate**: `boolean`
|
|
38
36
|
|
|
39
|
-
Defined in: [core/fetchWithCache.ts:
|
|
37
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:19](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L19)
|
|
40
38
|
|
|
41
39
|
是否启用后台异步更新 (SWR)
|
|
42
40
|
|
|
@@ -50,7 +48,7 @@ Defined in: [core/fetchWithCache.ts:18](https://github.com/isdk/proxy.js/blob/76
|
|
|
50
48
|
|
|
51
49
|
> **cache**: [`SmartCache`](../classes/SmartCache.md)
|
|
52
50
|
|
|
53
|
-
Defined in: [core/fetchWithCache.ts:
|
|
51
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:15](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L15)
|
|
54
52
|
|
|
55
53
|
混合缓存实例
|
|
56
54
|
|
|
@@ -64,7 +62,7 @@ Defined in: [core/fetchWithCache.ts:14](https://github.com/isdk/proxy.js/blob/76
|
|
|
64
62
|
|
|
65
63
|
> **cacheKey**: `string`
|
|
66
64
|
|
|
67
|
-
Defined in: [core/fetchWithCache.ts:
|
|
65
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:34](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L34)
|
|
68
66
|
|
|
69
67
|
***
|
|
70
68
|
|
|
@@ -72,7 +70,7 @@ Defined in: [core/fetchWithCache.ts:35](https://github.com/isdk/proxy.js/blob/76
|
|
|
72
70
|
|
|
73
71
|
> **config**: [`SiteCacheConfig`](SiteCacheConfig.md)
|
|
74
72
|
|
|
75
|
-
Defined in: [core/fetchWithCache.ts:
|
|
73
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:17](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L17)
|
|
76
74
|
|
|
77
75
|
站点级缓存配置
|
|
78
76
|
|
|
@@ -86,7 +84,7 @@ Defined in: [core/fetchWithCache.ts:16](https://github.com/isdk/proxy.js/blob/76
|
|
|
86
84
|
|
|
87
85
|
> **fetcher**: (`req`) => `Promise`\<`Response`\>
|
|
88
86
|
|
|
89
|
-
Defined in: [core/fetchWithCache.ts:
|
|
87
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:33](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L33)
|
|
90
88
|
|
|
91
89
|
#### Parameters
|
|
92
90
|
|
|
@@ -104,7 +102,7 @@ Defined in: [core/fetchWithCache.ts:34](https://github.com/isdk/proxy.js/blob/76
|
|
|
104
102
|
|
|
105
103
|
> `optional` **generateKey**: (`req`, `config`) => `Promise`\<`string`\>
|
|
106
104
|
|
|
107
|
-
Defined in: [core/fetchWithCache.ts:
|
|
105
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:23](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L23)
|
|
108
106
|
|
|
109
107
|
自定义缓存键生成函数
|
|
110
108
|
|
|
@@ -164,7 +162,7 @@ const cacheKey = await generateCacheKey(request, {
|
|
|
164
162
|
|
|
165
163
|
> `optional` **onBackgroundUpdate**: (`promise`) => `void`
|
|
166
164
|
|
|
167
|
-
Defined in: [core/fetchWithCache.ts:
|
|
165
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:21](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L21)
|
|
168
166
|
|
|
169
167
|
后台更新 Promise 触发时的回调
|
|
170
168
|
|
|
@@ -188,4 +186,4 @@ Defined in: [core/fetchWithCache.ts:20](https://github.com/isdk/proxy.js/blob/76
|
|
|
188
186
|
|
|
189
187
|
> **request**: `Request`
|
|
190
188
|
|
|
191
|
-
Defined in: [core/fetchWithCache.ts:
|
|
189
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:32](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L32)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: FetchWithCacheOptions
|
|
8
8
|
|
|
9
|
-
Defined in: [core/fetchWithCache.ts:
|
|
9
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:13](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L13)
|
|
10
10
|
|
|
11
11
|
fetchWithCache 选项
|
|
12
12
|
|
|
@@ -20,11 +20,9 @@ fetchWithCache 选项
|
|
|
20
20
|
|
|
21
21
|
> `optional` **activeCacheWrites**: `Map`\<`string`, `Promise`\<`void`\>\>
|
|
22
22
|
|
|
23
|
-
Defined in: [core/fetchWithCache.ts:
|
|
23
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:27](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L27)
|
|
24
24
|
|
|
25
25
|
并发写入任务追踪器
|
|
26
|
-
传入一个外部维护的 Map,用于在跨请求、跨实例时防止针对同一文件的并发重复下载。
|
|
27
|
-
Map 的 Key 是缓存 Key,Value 是一个代表写入完成的 Promise。
|
|
28
26
|
|
|
29
27
|
***
|
|
30
28
|
|
|
@@ -32,7 +30,7 @@ Map 的 Key 是缓存 Key,Value 是一个代表写入完成的 Promise。
|
|
|
32
30
|
|
|
33
31
|
> `optional` **backgroundUpdate**: `boolean`
|
|
34
32
|
|
|
35
|
-
Defined in: [core/fetchWithCache.ts:
|
|
33
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:19](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L19)
|
|
36
34
|
|
|
37
35
|
是否启用后台异步更新 (SWR)
|
|
38
36
|
|
|
@@ -42,7 +40,7 @@ Defined in: [core/fetchWithCache.ts:18](https://github.com/isdk/proxy.js/blob/76
|
|
|
42
40
|
|
|
43
41
|
> **cache**: [`SmartCache`](../classes/SmartCache.md)
|
|
44
42
|
|
|
45
|
-
Defined in: [core/fetchWithCache.ts:
|
|
43
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:15](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L15)
|
|
46
44
|
|
|
47
45
|
混合缓存实例
|
|
48
46
|
|
|
@@ -52,7 +50,7 @@ Defined in: [core/fetchWithCache.ts:14](https://github.com/isdk/proxy.js/blob/76
|
|
|
52
50
|
|
|
53
51
|
> **config**: [`SiteCacheConfig`](SiteCacheConfig.md)
|
|
54
52
|
|
|
55
|
-
Defined in: [core/fetchWithCache.ts:
|
|
53
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:17](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L17)
|
|
56
54
|
|
|
57
55
|
站点级缓存配置
|
|
58
56
|
|
|
@@ -62,7 +60,7 @@ Defined in: [core/fetchWithCache.ts:16](https://github.com/isdk/proxy.js/blob/76
|
|
|
62
60
|
|
|
63
61
|
> `optional` **generateKey**: (`req`, `config`) => `Promise`\<`string`\>
|
|
64
62
|
|
|
65
|
-
Defined in: [core/fetchWithCache.ts:
|
|
63
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:23](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L23)
|
|
66
64
|
|
|
67
65
|
自定义缓存键生成函数
|
|
68
66
|
|
|
@@ -118,7 +116,7 @@ const cacheKey = await generateCacheKey(request, {
|
|
|
118
116
|
|
|
119
117
|
> `optional` **onBackgroundUpdate**: (`promise`) => `void`
|
|
120
118
|
|
|
121
|
-
Defined in: [core/fetchWithCache.ts:
|
|
119
|
+
Defined in: [packages/proxy/src/core/fetchWithCache.ts:21](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/fetchWithCache.ts#L21)
|
|
122
120
|
|
|
123
121
|
后台更新 Promise 触发时的回调
|
|
124
122
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: KeyFilterConfig
|
|
8
8
|
|
|
9
|
-
Defined in: [types.ts:6](https://github.com/isdk/proxy.js/blob/
|
|
9
|
+
Defined in: [packages/proxy/src/types.ts:6](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L6)
|
|
10
10
|
|
|
11
11
|
缓存键过滤配置
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ Defined in: [types.ts:6](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5bf
|
|
|
22
22
|
|
|
23
23
|
> `optional` **exclude**: (`string` \| `RegExp`)[]
|
|
24
24
|
|
|
25
|
-
Defined in: [types.ts:10](https://github.com/isdk/proxy.js/blob/
|
|
25
|
+
Defined in: [packages/proxy/src/types.ts:10](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L10)
|
|
26
26
|
|
|
27
27
|
排除(黑名单):用于排除像 `timestamp`、`nonce` 等干扰缓存命中的动态字段。支持字符串、Glob 模式或正则表达式。
|
|
28
28
|
|
|
@@ -32,6 +32,6 @@ Defined in: [types.ts:10](https://github.com/isdk/proxy.js/blob/76fee3a101f98e5b
|
|
|
32
32
|
|
|
33
33
|
> `optional` **include**: (`string` \| `RegExp`)[]
|
|
34
34
|
|
|
35
|
-
Defined in: [types.ts:8](https://github.com/isdk/proxy.js/blob/
|
|
35
|
+
Defined in: [packages/proxy/src/types.ts:8](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/types.ts#L8)
|
|
36
36
|
|
|
37
37
|
仅包含(白名单):如果设置,只有这些字段会参与 Key 的计算。支持字符串、Glob 模式或正则表达式。
|