@vercel/kv2 0.0.15 → 0.0.17
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 +4 -7
- package/SKILL.md +15 -4
- package/dist/blob-format.d.ts.map +1 -1
- package/dist/blob-format.js +1 -0
- package/dist/blob-format.js.map +1 -1
- package/dist/blob-store.d.ts.map +1 -1
- package/dist/blob-store.js +2 -0
- package/dist/blob-store.js.map +1 -1
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +3 -0
- package/dist/cache.js.map +1 -1
- package/dist/cached-kv.d.ts +1 -0
- package/dist/cached-kv.d.ts.map +1 -1
- package/dist/cached-kv.js +28 -2
- package/dist/cached-kv.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/memory-cache.d.ts.map +1 -1
- package/dist/memory-cache.js +1 -0
- package/dist/memory-cache.js.map +1 -1
- package/dist/proxy-cache.d.ts.map +1 -1
- package/dist/proxy-cache.js +4 -0
- package/dist/proxy-cache.js.map +1 -1
- package/dist/readme.test.js +2 -0
- package/dist/readme.test.js.map +1 -1
- package/dist/testing/test-index.d.ts +5 -0
- package/dist/testing/test-index.d.ts.map +1 -1
- package/dist/testing/test-index.js +6 -0
- package/dist/testing/test-index.js.map +1 -1
- package/dist/typed-kv.d.ts +26 -0
- package/dist/typed-kv.d.ts.map +1 -1
- package/dist/typed-kv.js +31 -0
- package/dist/typed-kv.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/upstream-kv.d.ts +1 -0
- package/dist/upstream-kv.d.ts.map +1 -1
- package/dist/upstream-kv.js +30 -46
- package/dist/upstream-kv.js.map +1 -1
- package/docs/api-reference.md +31 -0
- package/docs/getting-started.md +4 -0
- package/docs/indexes.md +7 -3
- package/docs/typed-stores.md +4 -0
- package/package.json +3 -1
package/docs/getting-started.md
CHANGED
|
@@ -32,6 +32,10 @@ const result = await users.get("alice");
|
|
|
32
32
|
if (result.exists) {
|
|
33
33
|
console.log((await result.value).name); // "Alice"
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
// Or use getValue() for a simpler read
|
|
37
|
+
const user = await users.getValue("alice"); // User | undefined
|
|
38
|
+
console.log(user?.name); // "Alice"
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
## Prerequisites
|
package/docs/indexes.md
CHANGED
|
@@ -6,9 +6,13 @@ Secondary indexes allow you to look up entries by attributes other than the prim
|
|
|
6
6
|
|
|
7
7
|
## Defining Indexes
|
|
8
8
|
|
|
9
|
-
Pass an `indexes` record to `getStore()`. Each index defines a `key` function that extracts the index key from the value
|
|
9
|
+
Pass an `indexes` record to `getStore()`. Each index defines a `key` function that extracts the index key from the value.
|
|
10
|
+
|
|
11
|
+
Use `defineIndexes<V>()` to let TypeScript infer the index names automatically instead of spelling them out as a type parameter:
|
|
10
12
|
|
|
11
13
|
```typescript
|
|
14
|
+
import { defineIndexes } from "@vercel/kv2";
|
|
15
|
+
|
|
12
16
|
interface Doc {
|
|
13
17
|
slug: string;
|
|
14
18
|
status: string;
|
|
@@ -18,7 +22,7 @@ interface Doc {
|
|
|
18
22
|
authorId: string;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
const docs = kv.getStore
|
|
25
|
+
const docs = kv.getStore("docs/", defineIndexes<Doc>()({
|
|
22
26
|
bySlug: {
|
|
23
27
|
key: (doc) => doc.slug,
|
|
24
28
|
unique: true,
|
|
@@ -26,7 +30,7 @@ const docs = kv.getStore<Doc, undefined, "bySlug" | "byStatus">("docs/", {
|
|
|
26
30
|
byStatus: {
|
|
27
31
|
key: (doc) => doc.status,
|
|
28
32
|
},
|
|
29
|
-
});
|
|
33
|
+
}));
|
|
30
34
|
```
|
|
31
35
|
|
|
32
36
|
## Unique Indexes
|
package/docs/typed-stores.md
CHANGED
|
@@ -31,6 +31,10 @@ if (result.exists) {
|
|
|
31
31
|
const post = await result.value; // Post
|
|
32
32
|
console.log(post.title);
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
// Or use getValue() for a simpler read
|
|
36
|
+
const found = await posts.getValue("hello-world"); // Post | undefined
|
|
37
|
+
console.log(found?.title);
|
|
34
38
|
```
|
|
35
39
|
|
|
36
40
|
## Key Prefixing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/kv2",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "KV2 - A type-safe KV store backed by Vercel private blobs with regional caching",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@biomejs/biome": "^1.9.0",
|
|
49
49
|
"@types/node": "^22.0.0",
|
|
50
|
+
"c8": "^10.1.3",
|
|
50
51
|
"dotenv": "^17.2.3",
|
|
51
52
|
"knip": "^5.0.0",
|
|
52
53
|
"typescript": "^5.7.0"
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"lint": "biome lint .",
|
|
60
61
|
"lint:fix": "biome lint --write .",
|
|
61
62
|
"test": "tsc && node dist/testing/run-tests.js",
|
|
63
|
+
"test:coverage": "tsc && c8 node dist/testing/run-tests.js",
|
|
62
64
|
"test:integration": "INTEGRATION_TEST=1 sh -c 'tsc && node dist/testing/run-tests.js'",
|
|
63
65
|
"knip": "knip",
|
|
64
66
|
"validate": "pnpm run knip && pnpm run lint && pnpm run typecheck && pnpm run test"
|