@vite-hub/kv 0.3.1 → 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 +19 -13
- package/dist/{cli-DpPhz_Ek.d.ts → cli-CLomw9ml.d.ts} +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +24 -12
- package/dist/{cloudflare-env-lOtHHsgP.js → cloudflare-env-Dl349h_9.js} +2 -1
- package/dist/{cloudflare-kv-BIEUFzRT.js → cloudflare-kv-DQJhmGof.js} +22 -10
- package/dist/{cloudflare-kv-local-BBw3ZT1K.js → cloudflare-kv-local-COjgHweC.js} +3 -7
- package/dist/{config-BXEVoZE3.js → config-pfyPiPrI.js} +65 -28
- package/dist/{create-storage-BGsrQKw3.js → create-storage-DQ1BbFqH.js} +5 -5
- package/dist/{cursor-history-BqIQePNP.js → cursor-history-CAT4mpP1.js} +7 -3
- package/dist/{deno-kv-BM9mYdUp.js → deno-kv-Cf0ZveeN.js} +43 -7
- package/dist/driver-Du6Eh9p2.d.ts +47 -0
- package/dist/{error-diagnostics-BxqvtEIb.js → error-diagnostics-C4VTHInS.js} +16 -4
- package/dist/errors-BpiM-Vmh.js +125 -0
- package/dist/errors.d.ts +13 -1
- package/dist/errors.js +2 -2
- package/dist/{fs-lite-BLZId9_P.js → fs-lite-BTcBUP6B.js} +1 -1
- package/dist/fs-lite-C8yXCVDM.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +39 -52
- package/dist/{operation-definition-8gOe-ubD.d.ts → operation-definition-CI2PJGqu.d.ts} +13 -2
- package/dist/{operations-Ch-gKaey.js → operations-CqKs7Ykc.js} +24 -45
- package/dist/{operations-B-WZ7P1h.js → operations-nAaONxzh.js} +273 -231
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +4 -3
- package/dist/out-BbXG-yVX.js +21755 -0
- package/dist/{redis-shared-E5mahECF.js → redis-shared-1M0IaguQ.js} +1 -1
- package/dist/request-log-Dj9Vw7qG.js +105 -0
- package/dist/{results-p7nPCnaJ.js → results-D6jfPtCk.js} +0 -1
- package/dist/runtime/cloudflare-kv.d.ts +1 -1
- package/dist/runtime/cloudflare-kv.js +1 -1
- package/dist/runtime/cloudflare-request-env.js +1 -1
- package/dist/runtime/database.d.ts +2 -0
- package/dist/{database-72Jk3VVk.js → runtime/database.js} +68 -37
- package/dist/runtime/nitro-plugin.js +12 -5
- package/dist/runtime/redis-driver.d.ts +2 -2
- package/dist/runtime/redis-driver.js +2 -5
- package/dist/runtime/unstorage-driver.js +6 -2
- package/dist/runtime/upstash-driver.d.ts +2 -2
- package/dist/runtime/upstash-driver.js +2 -6
- package/dist/{types-DEiKew_3.d.ts → types-Cp6IBhSN.d.ts} +36 -37
- package/dist/{upstash-DDlqTttY.js → upstash-5sTbIR35.js} +2 -2
- package/dist/virtual-module.d.ts +1 -0
- package/dist/vite.d.ts +21 -6
- package/dist/vite.js +2738 -415
- package/package.json +10 -5
- package/dist/driver-BwxgaQ-f.d.ts +0 -15
- package/dist/errors-DbwufFZp.js +0 -60
- package/dist/fs-lite-RAoxu8L0.js +0 -2
- package/dist/main-F3Y22_uV.js +0 -2353
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/kv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Vite-first key-value storage primitives and integration for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,6 +46,11 @@
|
|
|
46
46
|
"import": "./dist/durability.js",
|
|
47
47
|
"default": "./dist/durability.js"
|
|
48
48
|
},
|
|
49
|
+
"./runtime/database": {
|
|
50
|
+
"types": "./dist/runtime/database.d.ts",
|
|
51
|
+
"import": "./dist/runtime/database.js",
|
|
52
|
+
"default": "./dist/runtime/database.js"
|
|
53
|
+
},
|
|
49
54
|
"./runtime/redis-driver": {
|
|
50
55
|
"types": "./dist/runtime/redis-driver.d.ts",
|
|
51
56
|
"import": "./dist/runtime/redis-driver.js",
|
|
@@ -70,7 +75,7 @@
|
|
|
70
75
|
},
|
|
71
76
|
"dependencies": {
|
|
72
77
|
"@valibot/to-json-schema": "^1.8.0",
|
|
73
|
-
"@vite-hub/runtime": "0.
|
|
78
|
+
"@vite-hub/runtime": "0.5.0",
|
|
74
79
|
"birpc": "^4.2.0",
|
|
75
80
|
"defu": "^6.1.7",
|
|
76
81
|
"destr": "^2.0.5",
|
|
@@ -83,7 +88,7 @@
|
|
|
83
88
|
"devDependencies": {
|
|
84
89
|
"@types/node": "^24.19.1",
|
|
85
90
|
"@libsql/client": "^0.18.0",
|
|
86
|
-
"@vite-hub/database": "0.
|
|
91
|
+
"@vite-hub/database": "0.5.0",
|
|
87
92
|
"@types/proper-lockfile": "4.1.4",
|
|
88
93
|
"@vite-hub/internal": "0.0.1",
|
|
89
94
|
"ofetch": "^1.5.1",
|
|
@@ -96,7 +101,7 @@
|
|
|
96
101
|
},
|
|
97
102
|
"peerDependencies": {
|
|
98
103
|
"@upstash/redis": "^1.39.0",
|
|
99
|
-
"@vite-hub/database": "0.
|
|
104
|
+
"@vite-hub/database": "0.5.0",
|
|
100
105
|
"vite": ">=8.0.0"
|
|
101
106
|
},
|
|
102
107
|
"peerDependenciesMeta": {
|
|
@@ -111,7 +116,7 @@
|
|
|
111
116
|
}
|
|
112
117
|
},
|
|
113
118
|
"engines": {
|
|
114
|
-
"node": ">=
|
|
119
|
+
"node": ">=24.15.0"
|
|
115
120
|
},
|
|
116
121
|
"scripts": {
|
|
117
122
|
"build": "vp pack",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { i as TransactionOptions, t as Driver } from "./types-Bj3EQoRg.js";
|
|
2
|
-
import { g as KVListPage, h as KVListOptions } from "./types-DEiKew_3.js";
|
|
3
|
-
//#region src/runtime/driver.d.ts
|
|
4
|
-
type KVRuntimeDriver = Driver & Record<string, unknown> & {
|
|
5
|
-
validateBatch?: (items: Parameters<NonNullable<Driver["setItems"]>>[0], removals: string[], options?: TransactionOptions) => void | Promise<void>;
|
|
6
|
-
/** Deletes the key when it holds the serialized `expected` value. Resolves `true` when this call deleted it. */
|
|
7
|
-
deleteIfEqualsItem?: (key: string, expected: string) => Promise<boolean>;
|
|
8
|
-
getAndDeleteItem?: <T = unknown>(key: string) => Promise<T | null>;
|
|
9
|
-
incrementItem?: (key: string, ttl: number) => Promise<number>;
|
|
10
|
-
listKeys: (options: KVListOptions) => Promise<KVListPage>;
|
|
11
|
-
/** Writes the serialized value only when the key is missing. Resolves `true` when this call wrote it. */
|
|
12
|
-
setIfAbsentItem?: (key: string, value: string, ttl?: number) => Promise<boolean>;
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { KVRuntimeDriver as t };
|
package/dist/errors-DbwufFZp.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { n as kvErrorDiagnostics, t as kvConfigErrorCodes } from "./error-diagnostics-BxqvtEIb.js";
|
|
2
|
-
import { isRuntimeDiagnostic, toResultError } from "@vite-hub/runtime";
|
|
3
|
-
//#region src/store-mode.ts
|
|
4
|
-
/**
|
|
5
|
-
* Returns the handle that `kv.store(name, options)` gives. An unknown mode throws, so a typo never gives a writable handle.
|
|
6
|
-
* The read-only handle has only the read methods; write methods are absent, not stubbed.
|
|
7
|
-
*/
|
|
8
|
-
function kvStoreWithMode(storage, options) {
|
|
9
|
-
const mode = options?.mode === void 0 ? "write" : options.mode;
|
|
10
|
-
if (mode !== "read" && mode !== "write") throw kvErrorDiagnostics.KV_INVALID_STORE_MODE({ mode: JSON.stringify(mode) });
|
|
11
|
-
if (mode === "write") return storage;
|
|
12
|
-
return {
|
|
13
|
-
get: storage.get,
|
|
14
|
-
getMany: storage.getMany,
|
|
15
|
-
has: storage.has,
|
|
16
|
-
keys: storage.keys,
|
|
17
|
-
list: storage.list
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/errors.ts
|
|
22
|
-
function hasCode(error, codes) {
|
|
23
|
-
return codes.some((code) => code === error.code);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Runs one KV operation and returns `[error, data]`.
|
|
27
|
-
* A KV error with one of `codes` is returned with Runtime's public serializer. A config error is thrown.
|
|
28
|
-
* Any other failure becomes `KV_OPERATION_FAILED` with the failure in `cause`.
|
|
29
|
-
*/
|
|
30
|
-
async function kvResult(operation, store, run, codes = []) {
|
|
31
|
-
try {
|
|
32
|
-
return [void 0, await run()];
|
|
33
|
-
} catch (cause) {
|
|
34
|
-
if (kvErrorDiagnostics.is(cause) && kvConfigErrorCodes.has(cause.code)) throw cause;
|
|
35
|
-
if (isRuntimeDiagnostic(cause) && hasCode(cause, codes)) return [toResultError(cause), void 0];
|
|
36
|
-
return [kvErrorDiagnostics.KV_OPERATION_FAILED({
|
|
37
|
-
cause,
|
|
38
|
-
operation,
|
|
39
|
-
store
|
|
40
|
-
}), void 0];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function kvStoreNotFoundError(store) {
|
|
44
|
-
return kvErrorDiagnostics.KV_STORE_NOT_FOUND({ store });
|
|
45
|
-
}
|
|
46
|
-
function kvUnsupportedOperationError(operation, store) {
|
|
47
|
-
return kvErrorDiagnostics.KV_UNSUPPORTED_OPERATION({
|
|
48
|
-
operation,
|
|
49
|
-
store
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function kvInvalidLimitError() {
|
|
53
|
-
return kvErrorDiagnostics.KV_INVALID_LIMIT();
|
|
54
|
-
}
|
|
55
|
-
/** Codes that a Cloudflare KV store returns for a key above the host limit. */
|
|
56
|
-
const kvKeyLimitCodes = ["KV_KEY_TOO_LONG"];
|
|
57
|
-
/** Codes that a Cloudflare KV store returns for a write above the host limits. */
|
|
58
|
-
const kvWriteLimitCodes = ["KV_KEY_TOO_LONG", "KV_VALUE_TOO_LARGE"];
|
|
59
|
-
//#endregion
|
|
60
|
-
export { kvUnsupportedOperationError as a, kvStoreNotFoundError as i, kvKeyLimitCodes as n, kvWriteLimitCodes as o, kvResult as r, kvStoreWithMode as s, kvInvalidLimitError as t };
|
package/dist/fs-lite-RAoxu8L0.js
DELETED