@vercel/functions 2.0.2 → 2.0.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/CHANGELOG.md +6 -0
- package/cache/in-memory-cache.d.ts +2 -2
- package/cache/index.d.ts +4 -4
- package/cache/index.js +3 -3
- package/cache/types.d.ts +2 -2
- package/docs/interfaces/{index.FunctionCache.md → index.RuntimeCache.md} +7 -7
- package/docs/modules/index.md +7 -7
- package/get-context.d.ts +2 -2
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class InMemoryCache implements
|
|
1
|
+
import { RuntimeCache } from './types';
|
|
2
|
+
export declare class InMemoryCache implements RuntimeCache {
|
|
3
3
|
private cache;
|
|
4
4
|
get(key: string, options?: {
|
|
5
5
|
tags?: string[];
|
package/cache/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CacheOptions,
|
|
1
|
+
import { CacheOptions, RuntimeCache } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Retrieves the Vercel
|
|
3
|
+
* Retrieves the Vercel Runtime Cache.
|
|
4
4
|
*
|
|
5
5
|
* Keys are hashed to ensure they are unique and consistent. The hashing function can be overridden by providing a custom
|
|
6
6
|
* `keyHashFunction` in the `cacheOptions` parameter.
|
|
@@ -10,7 +10,7 @@ import { CacheOptions, FunctionCache } from './types';
|
|
|
10
10
|
* namespaceSeparator can also be customized using the `namespaceSeparator` option.
|
|
11
11
|
*
|
|
12
12
|
* @param cacheOptions - Optional configuration for the cache.
|
|
13
|
-
* @returns An instance of the Vercel
|
|
13
|
+
* @returns An instance of the Vercel Runtime Cache.
|
|
14
14
|
* @throws {Error} If no cache is available in the context and `InMemoryCache` cannot be created.
|
|
15
15
|
*/
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const getRuntimeCache: (cacheOptions?: CacheOptions) => RuntimeCache;
|
package/cache/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var cache_exports = {};
|
|
20
20
|
__export(cache_exports, {
|
|
21
|
-
|
|
21
|
+
getRuntimeCache: () => getRuntimeCache
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(cache_exports);
|
|
24
24
|
var import_get_context = require("../get-context");
|
|
@@ -32,7 +32,7 @@ const defaultKeyHashFunction = (key) => {
|
|
|
32
32
|
};
|
|
33
33
|
const defaultNamespaceSeparator = "$";
|
|
34
34
|
let inMemoryCacheInstance = null;
|
|
35
|
-
const
|
|
35
|
+
const getRuntimeCache = (cacheOptions) => {
|
|
36
36
|
let cache;
|
|
37
37
|
if ((0, import_get_context.getContext)().cache) {
|
|
38
38
|
cache = (0, import_get_context.getContext)().cache;
|
|
@@ -68,5 +68,5 @@ const getFunctionCache = (cacheOptions) => {
|
|
|
68
68
|
};
|
|
69
69
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
70
|
0 && (module.exports = {
|
|
71
|
-
|
|
71
|
+
getRuntimeCache
|
|
72
72
|
});
|
package/cache/types.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# Interface:
|
|
1
|
+
# Interface: RuntimeCache
|
|
2
2
|
|
|
3
|
-
[index](../modules/index.md).
|
|
3
|
+
[index](../modules/index.md).RuntimeCache
|
|
4
4
|
|
|
5
|
-
Interface representing the
|
|
5
|
+
Interface representing the runtime cache.
|
|
6
6
|
|
|
7
7
|
## Table of contents
|
|
8
8
|
|
|
9
9
|
### Properties
|
|
10
10
|
|
|
11
|
-
- [delete](index.
|
|
12
|
-
- [expireTag](index.
|
|
13
|
-
- [get](index.
|
|
14
|
-
- [set](index.
|
|
11
|
+
- [delete](index.RuntimeCache.md#delete)
|
|
12
|
+
- [expireTag](index.RuntimeCache.md#expiretag)
|
|
13
|
+
- [get](index.RuntimeCache.md#get)
|
|
14
|
+
- [set](index.RuntimeCache.md#set)
|
|
15
15
|
|
|
16
16
|
## Properties
|
|
17
17
|
|
package/docs/modules/index.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
### Interfaces
|
|
6
6
|
|
|
7
|
-
- [FunctionCache](../interfaces/index.FunctionCache.md)
|
|
8
7
|
- [Geo](../interfaces/index.Geo.md)
|
|
9
8
|
- [Request](../interfaces/index.Request.md)
|
|
9
|
+
- [RuntimeCache](../interfaces/index.RuntimeCache.md)
|
|
10
10
|
|
|
11
11
|
### Functions
|
|
12
12
|
|
|
13
13
|
- [geolocation](index.md#geolocation)
|
|
14
14
|
- [getEnv](index.md#getenv)
|
|
15
|
-
- [
|
|
15
|
+
- [getRuntimeCache](index.md#getruntimecache)
|
|
16
16
|
- [ipAddress](index.md#ipaddress)
|
|
17
17
|
- [next](index.md#next)
|
|
18
18
|
- [rewrite](index.md#rewrite)
|
|
@@ -118,11 +118,11 @@ https://vercel.com/docs/projects/environment-variables/system-environment-variab
|
|
|
118
118
|
|
|
119
119
|
---
|
|
120
120
|
|
|
121
|
-
###
|
|
121
|
+
### getRuntimeCache
|
|
122
122
|
|
|
123
|
-
▸ **
|
|
123
|
+
▸ **getRuntimeCache**(`cacheOptions?`): [`RuntimeCache`](../interfaces/index.RuntimeCache.md)
|
|
124
124
|
|
|
125
|
-
Retrieves the Vercel
|
|
125
|
+
Retrieves the Vercel Runtime Cache.
|
|
126
126
|
|
|
127
127
|
Keys are hashed to ensure they are unique and consistent. The hashing function can be overridden by providing a custom
|
|
128
128
|
`keyHashFunction` in the `cacheOptions` parameter.
|
|
@@ -143,9 +143,9 @@ If no cache is available in the context and `InMemoryCache` cannot be created.
|
|
|
143
143
|
|
|
144
144
|
#### Returns
|
|
145
145
|
|
|
146
|
-
[`
|
|
146
|
+
[`RuntimeCache`](../interfaces/index.RuntimeCache.md)
|
|
147
147
|
|
|
148
|
-
An instance of the Vercel
|
|
148
|
+
An instance of the Vercel Runtime Cache.
|
|
149
149
|
|
|
150
150
|
#### Defined in
|
|
151
151
|
|
package/get-context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RuntimeCache } from './cache/types';
|
|
2
2
|
type Context = {
|
|
3
3
|
waitUntil?: (promise: Promise<unknown>) => void;
|
|
4
|
-
cache?:
|
|
4
|
+
cache?: RuntimeCache;
|
|
5
5
|
headers?: Record<string, string>;
|
|
6
6
|
};
|
|
7
7
|
export declare const SYMBOL_FOR_REQ_CONTEXT: unique symbol;
|
package/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { geolocation, ipAddress } from './headers';
|
|
|
3
3
|
export { getEnv } from './get-env';
|
|
4
4
|
export { waitUntil } from './wait-until';
|
|
5
5
|
export { rewrite, next } from './middleware';
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
6
|
+
export { getRuntimeCache } from './cache';
|
|
7
|
+
export type { RuntimeCache } from './cache/types';
|
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var src_exports = {};
|
|
|
20
20
|
__export(src_exports, {
|
|
21
21
|
geolocation: () => import_headers.geolocation,
|
|
22
22
|
getEnv: () => import_get_env.getEnv,
|
|
23
|
-
|
|
23
|
+
getRuntimeCache: () => import_cache.getRuntimeCache,
|
|
24
24
|
ipAddress: () => import_headers.ipAddress,
|
|
25
25
|
next: () => import_middleware.next,
|
|
26
26
|
rewrite: () => import_middleware.rewrite,
|
|
@@ -36,7 +36,7 @@ var import_cache = require("./cache");
|
|
|
36
36
|
0 && (module.exports = {
|
|
37
37
|
geolocation,
|
|
38
38
|
getEnv,
|
|
39
|
-
|
|
39
|
+
getRuntimeCache,
|
|
40
40
|
ipAddress,
|
|
41
41
|
next,
|
|
42
42
|
rewrite,
|