@vite-hub/kv 0.1.0 → 0.3.1
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 +86 -15
- package/dist/batch--v0ri69O.js +40 -0
- package/dist/cli-DpPhz_Ek.d.ts +163 -0
- package/dist/cli.d.ts +4 -2
- package/dist/cli.js +98 -77
- package/dist/cloudflare-env-lOtHHsgP.js +46 -0
- package/dist/cloudflare-env-lookup-Bs0VDpU5.js +42 -0
- package/dist/cloudflare-kv-BIEUFzRT.js +187 -0
- package/dist/cloudflare-kv-local-BBw3ZT1K.js +71 -0
- package/dist/config-BXEVoZE3.js +250 -0
- package/dist/{create-storage-29gMzf41.js → create-storage-BGsrQKw3.js} +206 -50
- package/dist/{cursor-history-dqYDlsaD.js → cursor-history-BqIQePNP.js} +31 -14
- package/dist/database-72Jk3VVk.js +250 -0
- package/dist/{deno-kv-CSYGvRx4.js → deno-kv-BM9mYdUp.js} +12 -4
- package/dist/dev-peer-CHafxbtj.js +238 -0
- package/dist/driver-BwxgaQ-f.d.ts +15 -0
- package/dist/durability.d.ts +17 -0
- package/dist/durability.js +53 -0
- package/dist/error-diagnostics-BxqvtEIb.js +147 -0
- package/dist/errors-DbwufFZp.js +60 -0
- package/dist/errors.d.ts +12 -1
- package/dist/errors.js +2 -2
- package/dist/fs-lite-BLZId9_P.js +386 -0
- package/dist/fs-lite-RAoxu8L0.js +2 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +302 -75
- package/dist/inspect-BIKQsqX4.js +118 -0
- package/dist/invariant-DolT9EEx.js +22 -0
- package/dist/main-F3Y22_uV.js +2353 -0
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/{operations-tNUdj3G4.d.ts → operation-definition-8gOe-ubD.d.ts} +37 -15
- package/dist/operations-B-WZ7P1h.js +1351 -0
- package/dist/{operations-pn8_eGob.js → operations-Ch-gKaey.js} +67 -58
- package/dist/operations.d.ts +15 -8
- package/dist/operations.js +55 -192
- package/dist/redis-shared-E5mahECF.js +94 -0
- package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
- package/dist/runtime/cloudflare-kv.d.ts +1 -1
- package/dist/runtime/cloudflare-kv.js +1 -99
- package/dist/runtime/cloudflare-request-env.d.ts +7 -0
- package/dist/runtime/cloudflare-request-env.js +11 -0
- package/dist/runtime/nitro-plugin.d.ts +12 -0
- package/dist/runtime/nitro-plugin.js +22 -0
- package/dist/runtime/redis-driver.d.ts +11 -0
- package/dist/runtime/redis-driver.js +113 -0
- package/dist/runtime/unstorage-driver.d.ts +14 -0
- package/dist/runtime/unstorage-driver.js +33 -0
- package/dist/runtime/upstash-driver.d.ts +2 -2
- package/dist/runtime/upstash-driver.js +58 -98
- package/dist/{driver-D9fI27jl.d.ts → types-Bj3EQoRg.d.ts} +16 -41
- package/dist/types-DEiKew_3.d.ts +312 -0
- package/dist/upstash-DDlqTttY.js +40 -0
- package/dist/{utils2-Dsb9P4_2.js → utils2-FozcTsmb.js} +5 -2
- package/dist/virtual-module.d.ts +2 -0
- package/dist/vite.d.ts +152 -11
- package/dist/vite.js +888 -2836
- package/package.json +30 -21
- package/dist/cli-Cniq99iX.d.ts +0 -85
- package/dist/cloudflare-env-C5rM7kUY.js +0 -74
- package/dist/config-DR6_5ZwI.js +0 -124
- package/dist/continuations-DPyH_vr1.js +0 -63
- package/dist/error-diagnostics-D_cQeZTi.js +0 -82
- package/dist/errors-Dc2oiW-Y.js +0 -38
- package/dist/fs-lite-CbLKxLut.js +0 -90
- package/dist/object-B1NW521B.js +0 -7
- package/dist/operations-ByuDE12r.js +0 -1442
- package/dist/types-CMDvN0Wr.d.ts +0 -81
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { defineErrors } from "@vite-hub/runtime";
|
|
2
|
+
//#region src/error-diagnostics.ts
|
|
3
|
+
const cursorProblems = {
|
|
4
|
+
"expired": "The list cursor has expired.",
|
|
5
|
+
"foreign": "The list cursor belongs to a different storage backend.",
|
|
6
|
+
"in-use": "The list cursor is already in use.",
|
|
7
|
+
"invalid": "The list cursor is invalid or exceeds the maximum size."
|
|
8
|
+
};
|
|
9
|
+
const kvErrorDiagnostics = /*#__PURE__*/ defineErrors({
|
|
10
|
+
docs: "https://vitehub.dev/docs/kv/diagnostics",
|
|
11
|
+
codes: {
|
|
12
|
+
KV_INVALID_CURSOR: {
|
|
13
|
+
why: ({ problem }) => cursorProblems[problem],
|
|
14
|
+
fix: "Pass the `cursor` of the previous page once, to the same store. If it fails, start again without `cursor`."
|
|
15
|
+
},
|
|
16
|
+
KV_INVALID_LIMIT: {
|
|
17
|
+
why: "`limit` must be a positive integer.",
|
|
18
|
+
fix: "Pass a positive integer, for example `kv.list({ limit: 100 })`."
|
|
19
|
+
},
|
|
20
|
+
KV_INVALID_OPTION: {
|
|
21
|
+
why: ({ operation, option }) => `kv.${operation}() does not accept the option \`${option}\`. It accepts only \`ttl\`.`,
|
|
22
|
+
fix: "Pass `{ ttl: seconds }` to expire the value, or no options to keep it. KV has no Cloudflare `expirationTtl`, `expiration`, or `metadata` option."
|
|
23
|
+
},
|
|
24
|
+
KV_INVALID_TTL: {
|
|
25
|
+
why: "`ttl` must be a positive number of seconds within the safe integer range.",
|
|
26
|
+
fix: "Pass the TTL in seconds, for example `kv.set('session', value, { ttl: 60 })`."
|
|
27
|
+
},
|
|
28
|
+
KV_INVALID_VALUE: {
|
|
29
|
+
why: ({ operation, problem }) => problem === "missing" ? `kv.${operation}() needs a value. Use kv.delete() to remove a key.` : "KV cannot serialize this value.",
|
|
30
|
+
fix: "Pass a string, a number, a boolean, `null`, an array, a plain object, or an object with `toJSON()` to `kv.setIfAbsent()` or `kv.deleteIfEquals()`. Use `kv.delete()` to remove a key."
|
|
31
|
+
},
|
|
32
|
+
KV_INVALID_WAIT: {
|
|
33
|
+
why: "`wait` must be zero or a positive number of seconds.",
|
|
34
|
+
fix: "Pass the wait in seconds, for example `kv.lock('jobs:report', { ttl: 60, wait: 5 })`, or omit `wait` to return at once."
|
|
35
|
+
},
|
|
36
|
+
KV_KEY_TOO_LONG: {
|
|
37
|
+
why: ({ bytes, limit }) => `The key is ${bytes} bytes in UTF-8. Cloudflare KV accepts keys of at most ${limit} bytes.`,
|
|
38
|
+
fix: "Use a shorter key. To keep a long identifier, store a hash of it as the key."
|
|
39
|
+
},
|
|
40
|
+
KV_VALUE_TOO_LARGE: {
|
|
41
|
+
why: ({ bytes, limit }) => `The value is ${bytes} bytes. Cloudflare KV accepts values of at most ${limit} bytes (25 MiB).`,
|
|
42
|
+
fix: "Store large files in Blob, and keep the Blob pathname in KV."
|
|
43
|
+
},
|
|
44
|
+
KV_OPERATION_FAILED: {
|
|
45
|
+
why: ({ operation, store }) => `kv.${operation}() failed on the "${store}" store.`,
|
|
46
|
+
fix: "Read `error.cause` for the provider error. Retry when the provider is available again."
|
|
47
|
+
},
|
|
48
|
+
KV_UNSUPPORTED_OPERATION: {
|
|
49
|
+
why: ({ operation, store }) => operation === "setIfAbsent" ? `kv.setIfAbsent() needs an atomic write, and the "${store}" store cannot give one. Cloudflare KV is eventually consistent, so two requests can both see a missing key.` : operation === "lock" ? `kv.lock() needs \`setIfAbsent()\` with a TTL and \`deleteIfEquals()\`, and the "${store}" store does not support both.` : `kv.${operation}() needs atomic operations, and the "${store}" store does not support them.`,
|
|
50
|
+
fix: ({ operation }) => operation === "setIfAbsent" ? "On Cloudflare, keep single-use tokens in D1 with `INSERT ... ON CONFLICT DO NOTHING`, or in a Durable Object. Otherwise use the `redis`, `database`, `upstash`, `deno-kv`, or `fs-lite` driver for this store." : operation === "lock" ? "Use the `redis`, `database`, or `upstash` driver for this store. On Cloudflare, use a Durable Object or a D1 row as the lock." : "Use the `redis`, `database`, or `upstash` driver for this store. For request budgets, use the Rate Limit primitive."
|
|
51
|
+
},
|
|
52
|
+
KV_INVALID_INPUT: {
|
|
53
|
+
why: ({ limit, operation, problem }) => ({
|
|
54
|
+
"key": `The ${operation} operation requires a key.`,
|
|
55
|
+
"key-length": "The key is too long.",
|
|
56
|
+
"limit": `limit must be at most ${limit}.`,
|
|
57
|
+
"prefix-length": "The prefix is too long.",
|
|
58
|
+
"ttl": "Upstash TTL must be at least 1 second.",
|
|
59
|
+
"value": "The set operation requires a value."
|
|
60
|
+
})[problem],
|
|
61
|
+
fix: "Pass a `key` and a `prefix` of at most 2,048 characters, a `limit` of at most 1,000, and, for `kv.set`, a `value`. On Upstash, pass a `ttl` of at least 1 second."
|
|
62
|
+
},
|
|
63
|
+
KV_RESERVED_KEY: {
|
|
64
|
+
why: ({ key, operation }) => `The ${operation} operation cannot change ${key}. ViteHub owns the keys that start with \`vitehub:\`.`,
|
|
65
|
+
fix: "Use another key. Read access (get, has, list) stays open."
|
|
66
|
+
},
|
|
67
|
+
KV_VALUE_UNSUPPORTED: {
|
|
68
|
+
why: "The stored value cannot be represented by the KV inspection protocol.",
|
|
69
|
+
fix: "Read the value in the app with `kv.get()`. The `kv.get` operation shows JSON values, bigint values, and bytes, without getters, symbols, or class instances."
|
|
70
|
+
},
|
|
71
|
+
KV_DATABASE_UNAVAILABLE: {
|
|
72
|
+
why: ({ database, problem }) => problem === "missing" ? `The KV \`database\` driver keeps keys in the Database "${database}", and the app has no Database with that name.` : `The KV \`database\` driver needs the Database "${database}" on Postgres or libSQL. It does not support D1.`,
|
|
73
|
+
fix: ({ problem }) => problem === "missing" ? "Add a Database Definition, for example `server/database.ts` with `defineDatabase({ dialect: 'postgresql', schema: {} })`, or select another KV driver." : "On Cloudflare, use the `cloudflare` driver. Elsewhere, point the Database at Postgres or libSQL."
|
|
74
|
+
},
|
|
75
|
+
KV_DENO_KV_UNAVAILABLE: {
|
|
76
|
+
why: "The `deno-kv` driver needs `Deno.openKv()`, and this runtime does not have it.",
|
|
77
|
+
fix: "Run on Deno with KV enabled, or select another KV driver."
|
|
78
|
+
},
|
|
79
|
+
KV_DISABLED: {
|
|
80
|
+
why: "KV is not configured in this runtime.",
|
|
81
|
+
fix: "Set `kv` in `vitehub()` to `true` or to a KV config. With `@vite-hub/kv` alone, add `hubKV()` to the Vite plugins and do not pass `false` to it."
|
|
82
|
+
},
|
|
83
|
+
KV_INVALID_CONFIG: {
|
|
84
|
+
why: ({ path }) => `\`${path}\` must be a plain object.`,
|
|
85
|
+
fix: "Pass an object, for example `kv: { driver: 'fs-lite' }`."
|
|
86
|
+
},
|
|
87
|
+
KV_INVALID_DRIVER: {
|
|
88
|
+
why: ({ driver, renamed }) => renamed ? `\`kv.driver\` is ${driver}. ViteHub renamed this driver to "${renamed}", and it does not read ${driver}.` : `\`kv.driver\` ${driver} is not a KV driver.`,
|
|
89
|
+
fix: ({ renamed }) => renamed ? `Set \`kv: { driver: "${renamed}" }\`, or run \`npx @vite-hub/codemods driver-key\` to rename it in every config file.` : "Set `kv.driver` to \"cloudflare\", \"database\", \"deno-kv\", \"fs-lite\", \"redis\", or \"upstash\"."
|
|
90
|
+
},
|
|
91
|
+
KV_INVALID_REMOTE: {
|
|
92
|
+
why: ({ store }) => `\`remote\` of the KV store "${store}" must be \`true\` or \`false\`.`,
|
|
93
|
+
fix: "Set `remote: true` to use the real store in `vite dev`, or remove `remote` to keep the store local."
|
|
94
|
+
},
|
|
95
|
+
KV_REMOTE_CONFLICT: {
|
|
96
|
+
why: ({ driver, remote, store }) => remote ? `The KV store "${store}" sets \`remote: true\`, but it uses the local \`${driver}\` driver in \`vite dev\`.` : `The KV store "${store}" sets \`remote: false\`, but the \`${driver}\` driver is always remote.`,
|
|
97
|
+
fix: ({ remote }) => remote ? "Remove `remote: true`, or select a remote store: the `upstash` or `cloudflare` driver, Upstash env, or the Vercel or Cloudflare host." : "Remove `remote: false`, or select a local driver such as `fs-lite` for `vite dev`."
|
|
98
|
+
},
|
|
99
|
+
KV_INVALID_BATCH: {
|
|
100
|
+
why: ({ operation }) => operation === "getMany" ? "`kv.getMany()` needs an array of keys." : "`kv.setMany()` needs an array of `{ key, value }` entries.",
|
|
101
|
+
fix: ({ operation }) => operation === "getMany" ? "Pass an array, for example `kv.getMany(['a', 'b'])`." : "Pass an array, for example `kv.setMany([{ key: 'a', value: 1 }])`."
|
|
102
|
+
},
|
|
103
|
+
KV_INVALID_STORE_MODE: {
|
|
104
|
+
why: ({ mode }) => `\`kv.store()\` mode ${mode} is not "read" or "write".`,
|
|
105
|
+
fix: "Pass `{ mode: 'read' }` for a read-only handle, or omit `mode` for a writable one."
|
|
106
|
+
},
|
|
107
|
+
KV_MISSING_DEFAULT_STORE: {
|
|
108
|
+
why: "`kv.stores.default` is missing.",
|
|
109
|
+
fix: "Add a `default` store when you configure named KV stores."
|
|
110
|
+
},
|
|
111
|
+
KV_MISSING_ENV: {
|
|
112
|
+
why: ({ driver, names }) => `${driver === "redis" ? "Redis" : "Upstash"} KV needs the runtime environment variable ${names}.`,
|
|
113
|
+
fix: ({ driver }) => driver === "redis" ? "Set the variable in the server environment, or set `url` in the KV config." : "Set the variable in the host environment, or set `url` and `token` in the KV config."
|
|
114
|
+
},
|
|
115
|
+
KV_STORE_NOT_FOUND: {
|
|
116
|
+
why: ({ store, stores }) => stores ? `KV store "${store}" was not found. Stores: ${stores}.` : `The KV store "${store}" is not configured.`,
|
|
117
|
+
fix: "Add the store under `kv.stores`, or use the name of a configured store."
|
|
118
|
+
},
|
|
119
|
+
KV_INVALID_COUNTER: {
|
|
120
|
+
why: "kv.increment() needs a stored integer below 9007199254740991. The value did not change.",
|
|
121
|
+
fix: "Delete the key or replace its value with a canonical integer below Number.MAX_SAFE_INTEGER, then retry kv.increment()."
|
|
122
|
+
},
|
|
123
|
+
KV_CLI_USAGE: {
|
|
124
|
+
why: ({ problem }) => problem,
|
|
125
|
+
fix: "Run `vitehub kv --help` to see the commands and options."
|
|
126
|
+
},
|
|
127
|
+
KV_PROVIDER_INVALID_RESPONSE: {
|
|
128
|
+
why: ({ problem }) => `The KV provider returned a response that ViteHub cannot use. ${problem}`,
|
|
129
|
+
fix: "Retry the operation. If it fails again, open a ViteHub issue with the driver name."
|
|
130
|
+
},
|
|
131
|
+
KV_PROVISION_FAILED: {
|
|
132
|
+
why: ({ problem }) => `Cloudflare KV provisioning failed. ${problem}`,
|
|
133
|
+
fix: "Run `vitehub provision run --host cloudflare --dry-run` and check the Cloudflare token permissions."
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
/** Codes that a KV operation throws because the code or the deployment must change. */
|
|
138
|
+
const kvConfigErrorCodes = /* @__PURE__ */ new Set([
|
|
139
|
+
"KV_DATABASE_UNAVAILABLE",
|
|
140
|
+
"KV_INVALID_BATCH",
|
|
141
|
+
"KV_DENO_KV_UNAVAILABLE",
|
|
142
|
+
"KV_DISABLED",
|
|
143
|
+
"KV_MISSING_ENV",
|
|
144
|
+
"KV_STORE_NOT_FOUND"
|
|
145
|
+
]);
|
|
146
|
+
//#endregion
|
|
147
|
+
export { kvErrorDiagnostics as n, kvConfigErrorCodes as t };
|
|
@@ -0,0 +1,60 @@
|
|
|
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/errors.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { O as KVStoreOptions, S as KVOperation, T as KVStorage, d as KVErrorCode, k as ReadonlyKVStorage } from "./types-DEiKew_3.js";
|
|
2
2
|
import { Result, ResultError } from "@vite-hub/runtime";
|
|
3
|
+
//#region src/store-mode.d.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
|
+
export declare function kvStoreWithMode(storage: KVStorage, options: KVStoreOptions | undefined): KVStorage | ReadonlyKVStorage;
|
|
9
|
+
//#endregion
|
|
3
10
|
//#region src/errors.d.ts
|
|
4
11
|
/**
|
|
5
12
|
* Runs one KV operation and returns `[error, data]`.
|
|
@@ -10,4 +17,8 @@ export declare function kvResult<TData, TCode extends KVErrorCode = never>(opera
|
|
|
10
17
|
export declare function kvStoreNotFoundError(store: string): ResultError<"KV_STORE_NOT_FOUND">;
|
|
11
18
|
export declare function kvUnsupportedOperationError(operation: KVOperation, store: string): ResultError<"KV_UNSUPPORTED_OPERATION">;
|
|
12
19
|
export declare function kvInvalidLimitError(): ResultError<"KV_INVALID_LIMIT">;
|
|
20
|
+
/** Codes that a Cloudflare KV store returns for a key above the host limit. */
|
|
21
|
+
export declare const kvKeyLimitCodes: readonly ["KV_KEY_TOO_LONG"];
|
|
22
|
+
/** Codes that a Cloudflare KV store returns for a write above the host limits. */
|
|
23
|
+
export declare const kvWriteLimitCodes: readonly ["KV_KEY_TOO_LONG", "KV_VALUE_TOO_LARGE"];
|
|
13
24
|
//#endregion
|
package/dist/errors.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { kvInvalidLimitError, kvResult, kvStoreNotFoundError, kvUnsupportedOperationError };
|
|
1
|
+
import { a as kvUnsupportedOperationError, i as kvStoreNotFoundError, n as kvKeyLimitCodes, o as kvWriteLimitCodes, r as kvResult, s as kvStoreWithMode, t as kvInvalidLimitError } from "./errors-DbwufFZp.js";
|
|
2
|
+
export { kvInvalidLimitError, kvKeyLimitCodes, kvResult, kvStoreNotFoundError, kvStoreWithMode, kvUnsupportedOperationError, kvWriteLimitCodes };
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-BxqvtEIb.js";
|
|
2
|
+
import { link, lstat, mkdir, mkdtemp, opendir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { basename, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import createDriver from "unstorage/drivers/fs-lite";
|
|
5
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
6
|
+
import { lock } from "proper-lockfile";
|
|
7
|
+
//#region src/runtime/continuations.ts
|
|
8
|
+
/** Owns process-local cursor retention. Taking a cursor transfers its resource to the caller. */
|
|
9
|
+
function createKVContinuations(options) {
|
|
10
|
+
const entries = /* @__PURE__ */ new Map();
|
|
11
|
+
const releases = /* @__PURE__ */ new Set();
|
|
12
|
+
const failures = [];
|
|
13
|
+
let bytes = 0;
|
|
14
|
+
let disposed = false;
|
|
15
|
+
function take(cursor) {
|
|
16
|
+
const entry = entries.get(cursor);
|
|
17
|
+
if (!entry) return void 0;
|
|
18
|
+
clearTimeout(entry.timeout);
|
|
19
|
+
entries.delete(cursor);
|
|
20
|
+
bytes -= entry.bytes;
|
|
21
|
+
return entry.value;
|
|
22
|
+
}
|
|
23
|
+
function release(value, surfaceFailure = false) {
|
|
24
|
+
const pending = Promise.resolve().then(() => options.release?.(value)).then(() => void 0).catch((error) => {
|
|
25
|
+
if (failures.length === 0) failures.push(error);
|
|
26
|
+
if (surfaceFailure) throw error;
|
|
27
|
+
}).finally(() => {
|
|
28
|
+
releases.delete(pending);
|
|
29
|
+
});
|
|
30
|
+
releases.add(pending);
|
|
31
|
+
return pending;
|
|
32
|
+
}
|
|
33
|
+
function evict(cursor) {
|
|
34
|
+
const value = take(cursor);
|
|
35
|
+
if (value !== void 0) release(value);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
take,
|
|
39
|
+
async retain(value, size = 0) {
|
|
40
|
+
if (disposed) {
|
|
41
|
+
await release(value, true);
|
|
42
|
+
throw options.expired();
|
|
43
|
+
}
|
|
44
|
+
while (entries.size >= 32 || bytes + size > (options.maximumBytes ?? Number.POSITIVE_INFINITY)) {
|
|
45
|
+
const oldest = entries.keys().next().value;
|
|
46
|
+
if (!oldest) break;
|
|
47
|
+
evict(oldest);
|
|
48
|
+
}
|
|
49
|
+
const cursor = globalThis.crypto.randomUUID();
|
|
50
|
+
const timeout = setTimeout(() => evict(cursor), 9e5);
|
|
51
|
+
timeout.unref?.();
|
|
52
|
+
entries.set(cursor, {
|
|
53
|
+
value,
|
|
54
|
+
bytes: size,
|
|
55
|
+
timeout
|
|
56
|
+
});
|
|
57
|
+
bytes += size;
|
|
58
|
+
return cursor;
|
|
59
|
+
},
|
|
60
|
+
async dispose() {
|
|
61
|
+
disposed = true;
|
|
62
|
+
for (const cursor of entries.keys()) evict(cursor);
|
|
63
|
+
await Promise.all(releases);
|
|
64
|
+
if (failures.length > 0) throw new AggregateError(failures.splice(0), "Failed to release KV listing continuations.");
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/runtime/fs-lite.ts
|
|
70
|
+
const temporaryFile = /^\.unstorage-tmp-[\da-z-]+$/;
|
|
71
|
+
const layoutRecord = /^\.unstorage-tmp-vitehub-layout-v1(?:-\d+)?$/;
|
|
72
|
+
const layoutRecordName = ".unstorage-tmp-vitehub-layout-v1";
|
|
73
|
+
const layoutMarkerName = ".unstorage-tmp-vitehub-record";
|
|
74
|
+
const keyPrefix = "key-";
|
|
75
|
+
function fileName(key) {
|
|
76
|
+
return keyPrefix + key.replace(/[%:]/g, encodeURIComponent);
|
|
77
|
+
}
|
|
78
|
+
function keyOf(name) {
|
|
79
|
+
if (!name.startsWith(keyPrefix)) return;
|
|
80
|
+
const key = name.slice(4).replace(/%(?:25|3A)/g, decodeURIComponent);
|
|
81
|
+
return fileName(key) === name ? key : void 0;
|
|
82
|
+
}
|
|
83
|
+
function hasCode(error, ...codes) {
|
|
84
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" && codes.includes(error.code);
|
|
85
|
+
}
|
|
86
|
+
async function exists(path) {
|
|
87
|
+
try {
|
|
88
|
+
await stat(path);
|
|
89
|
+
return true;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (hasCode(error, "ENOENT")) return false;
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function migrateKeys(root) {
|
|
96
|
+
await mkdir(root, { recursive: true });
|
|
97
|
+
let recordPath = "";
|
|
98
|
+
let layout = "";
|
|
99
|
+
const candidates = [];
|
|
100
|
+
while (!layout) {
|
|
101
|
+
const entries = await readdir(root, { withFileTypes: true });
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
if (!entry.isFile() || !layoutRecord.test(entry.name)) continue;
|
|
104
|
+
const path = join(root, entry.name);
|
|
105
|
+
const value = await readFile(path, "utf8").catch((error) => {
|
|
106
|
+
if (hasCode(error, "ENOENT")) return "";
|
|
107
|
+
throw error;
|
|
108
|
+
});
|
|
109
|
+
if (!/^\.unstorage-tmp-vitehub-migration-[a-z\d]{6}$/i.test(value)) continue;
|
|
110
|
+
const identity = await Promise.all([lstat(path), lstat(join(root, value, layoutMarkerName))]).catch((error) => {
|
|
111
|
+
if (hasCode(error, "ENOENT", "ENOTDIR")) return void 0;
|
|
112
|
+
throw error;
|
|
113
|
+
});
|
|
114
|
+
if (!identity) continue;
|
|
115
|
+
const [record, marker] = identity;
|
|
116
|
+
if (!record.isFile() || !marker.isFile() || record.dev !== marker.dev || record.ino !== marker.ino) continue;
|
|
117
|
+
recordPath = path;
|
|
118
|
+
layout = join(root, value);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
if (layout) break;
|
|
122
|
+
let name = layoutRecordName;
|
|
123
|
+
for (let suffix = 1; entries.some((entry) => entry.name === name); suffix++) name = `${layoutRecordName}-${suffix}`;
|
|
124
|
+
const candidate = await mkdtemp(join(root, ".unstorage-tmp-vitehub-migration-"));
|
|
125
|
+
candidates.push(candidate);
|
|
126
|
+
const temporary = join(root, `.unstorage-tmp-${randomUUID()}`);
|
|
127
|
+
try {
|
|
128
|
+
await writeFile(temporary, basename(candidate));
|
|
129
|
+
await link(temporary, join(candidate, layoutMarkerName));
|
|
130
|
+
await link(temporary, join(root, name));
|
|
131
|
+
layout = candidate;
|
|
132
|
+
recordPath = join(root, name);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
if (!hasCode(error, "EEXIST", "ENOENT")) throw error;
|
|
135
|
+
} finally {
|
|
136
|
+
await rm(temporary, { force: true });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const release = await lock(layout, {
|
|
140
|
+
lockfilePath: join(layout, "lock"),
|
|
141
|
+
retries: {
|
|
142
|
+
retries: 100,
|
|
143
|
+
minTimeout: 20,
|
|
144
|
+
maxTimeout: 100
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
try {
|
|
148
|
+
for (const candidate of candidates) if (candidate !== layout) await rm(candidate, {
|
|
149
|
+
force: true,
|
|
150
|
+
recursive: true
|
|
151
|
+
});
|
|
152
|
+
const complete = join(layout, "complete");
|
|
153
|
+
if (await exists(complete)) return layout;
|
|
154
|
+
const legacy = join(layout, "legacy");
|
|
155
|
+
await mkdir(legacy, { recursive: true });
|
|
156
|
+
const staged = join(layout, "staged");
|
|
157
|
+
if (!await exists(staged)) {
|
|
158
|
+
for (const entry of await readdir(root, { withFileTypes: true })) {
|
|
159
|
+
if (entry.name === basename(layout) || join(root, entry.name) === recordPath) continue;
|
|
160
|
+
if (!entry.isDirectory() && (!entry.isFile() || temporaryFile.test(entry.name) && !layoutRecord.test(entry.name))) continue;
|
|
161
|
+
await rename(join(root, entry.name), join(legacy, entry.name));
|
|
162
|
+
}
|
|
163
|
+
await writeFile(staged, "");
|
|
164
|
+
}
|
|
165
|
+
for (const file of await readdir(legacy, {
|
|
166
|
+
recursive: true,
|
|
167
|
+
withFileTypes: true
|
|
168
|
+
})) {
|
|
169
|
+
if (!file.isFile() || temporaryFile.test(file.name) && !layoutRecord.test(file.name)) continue;
|
|
170
|
+
const path = join(file.parentPath, file.name);
|
|
171
|
+
const destination = join(root, fileName(relative(legacy, path).split(sep).join(":")));
|
|
172
|
+
try {
|
|
173
|
+
await link(path, destination);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (!hasCode(error, "EEXIST")) throw error;
|
|
176
|
+
const source = await lstat(path);
|
|
177
|
+
const target = await lstat(destination);
|
|
178
|
+
if (!target.isFile() || target.dev !== source.dev || target.ino !== source.ino) throw error;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
await writeFile(complete, "");
|
|
182
|
+
await rm(legacy, {
|
|
183
|
+
force: true,
|
|
184
|
+
recursive: true
|
|
185
|
+
});
|
|
186
|
+
return layout;
|
|
187
|
+
} finally {
|
|
188
|
+
await release();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function ttlMilliseconds(ttl) {
|
|
192
|
+
if (!Number.isFinite(ttl) || ttl <= 0) throw kvErrorDiagnostics.KV_INVALID_TTL();
|
|
193
|
+
const ms = Math.ceil(ttl * 1e3);
|
|
194
|
+
if (!Number.isSafeInteger(ms)) throw kvErrorDiagnostics.KV_INVALID_TTL();
|
|
195
|
+
return ms;
|
|
196
|
+
}
|
|
197
|
+
function setExpiry(options) {
|
|
198
|
+
const ttl = options && typeof options === "object" ? Reflect.get(options, "ttl") : void 0;
|
|
199
|
+
if (ttl === void 0 || ttl === null || ttl === 0) return;
|
|
200
|
+
if (typeof ttl !== "number") throw kvErrorDiagnostics.KV_INVALID_TTL();
|
|
201
|
+
return Date.now() + ttlMilliseconds(ttl);
|
|
202
|
+
}
|
|
203
|
+
async function createFsLiteKVDriver(options) {
|
|
204
|
+
const root = resolve(options.base);
|
|
205
|
+
const layout = await migrateKeys(root);
|
|
206
|
+
const expiries = join(layout, "expires");
|
|
207
|
+
const expiryPath = (key) => join(expiries, createHash("sha256").update(key).digest("hex"));
|
|
208
|
+
async function readExpiry(key) {
|
|
209
|
+
const text = await readFile(expiryPath(key), "utf8").catch((error) => {
|
|
210
|
+
if (hasCode(error, "ENOENT", "ENOTDIR")) return void 0;
|
|
211
|
+
throw error;
|
|
212
|
+
});
|
|
213
|
+
const expiresAt = text === void 0 ? NaN : Number(text);
|
|
214
|
+
return Number.isSafeInteger(expiresAt) ? expiresAt : void 0;
|
|
215
|
+
}
|
|
216
|
+
async function synchronized(operation) {
|
|
217
|
+
const release = await lock(layout, {
|
|
218
|
+
lockfilePath: join(layout, "lock"),
|
|
219
|
+
retries: {
|
|
220
|
+
retries: 100,
|
|
221
|
+
minTimeout: 20,
|
|
222
|
+
maxTimeout: 100
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
try {
|
|
226
|
+
return await operation();
|
|
227
|
+
} finally {
|
|
228
|
+
await release();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function writeExpiry(key, expiresAt) {
|
|
232
|
+
if (expiresAt === void 0) {
|
|
233
|
+
await rm(expiryPath(key), { force: true });
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
await mkdir(expiries, { recursive: true });
|
|
237
|
+
const temporary = join(expiries, `.tmp-${randomUUID()}`);
|
|
238
|
+
await writeFile(temporary, String(expiresAt));
|
|
239
|
+
await rename(temporary, expiryPath(key));
|
|
240
|
+
}
|
|
241
|
+
async function live(key) {
|
|
242
|
+
const expiresAt = await readExpiry(key);
|
|
243
|
+
if (expiresAt === void 0 || expiresAt > Date.now()) return true;
|
|
244
|
+
await rm(join(root, fileName(key)), { force: true });
|
|
245
|
+
await rm(expiryPath(key), { force: true });
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
const driver = createDriver(options);
|
|
249
|
+
const { getItem, getItemRaw, getMeta, hasItem, removeItem, setItem, setItemRaw } = driver;
|
|
250
|
+
driver.getItem = async (key, operationOptions) => {
|
|
251
|
+
if (!await live(key)) return null;
|
|
252
|
+
const value = await getItem(fileName(key), operationOptions);
|
|
253
|
+
if (value instanceof Error) throw value;
|
|
254
|
+
return value;
|
|
255
|
+
};
|
|
256
|
+
driver.getItemRaw = async (key, operationOptions) => {
|
|
257
|
+
if (!await live(key)) return null;
|
|
258
|
+
const value = await getItemRaw?.(fileName(key), operationOptions);
|
|
259
|
+
if (value instanceof Error) throw value;
|
|
260
|
+
return value;
|
|
261
|
+
};
|
|
262
|
+
driver.getMeta = async (key, operationOptions) => await live(key) ? getMeta?.(fileName(key), operationOptions) ?? null : null;
|
|
263
|
+
driver.setItem = async (key, value, operationOptions) => {
|
|
264
|
+
await writeExpiry(key, setExpiry(operationOptions));
|
|
265
|
+
return setItem?.(fileName(key), value, operationOptions);
|
|
266
|
+
};
|
|
267
|
+
driver.setItemRaw = async (key, value, operationOptions) => {
|
|
268
|
+
await writeExpiry(key, setExpiry(operationOptions));
|
|
269
|
+
return setItemRaw?.(fileName(key), value, operationOptions);
|
|
270
|
+
};
|
|
271
|
+
driver.removeItem = async (key, operationOptions) => {
|
|
272
|
+
await rm(expiryPath(key), { force: true });
|
|
273
|
+
await removeItem?.(fileName(key), operationOptions);
|
|
274
|
+
};
|
|
275
|
+
driver.clear = async (base = "") => {
|
|
276
|
+
const entries = await readdir(root).catch((error) => {
|
|
277
|
+
if (hasCode(error, "ENOENT")) return [];
|
|
278
|
+
throw error;
|
|
279
|
+
});
|
|
280
|
+
for (const entry of entries) {
|
|
281
|
+
const key = keyOf(entry);
|
|
282
|
+
if (key !== void 0 && key.startsWith(base)) {
|
|
283
|
+
await rm(join(root, entry), {
|
|
284
|
+
force: true,
|
|
285
|
+
recursive: true
|
|
286
|
+
});
|
|
287
|
+
await rm(expiryPath(key), { force: true });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const hasLiveItem = async (key, operationOptions) => {
|
|
292
|
+
if (!await hasItem(fileName(key), operationOptions)) return false;
|
|
293
|
+
if (!await live(key)) return false;
|
|
294
|
+
try {
|
|
295
|
+
return (await stat(join(root, fileName(key)))).isFile();
|
|
296
|
+
} catch (error) {
|
|
297
|
+
if (hasCode(error, "ENOENT")) return false;
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
driver.hasItem = hasLiveItem;
|
|
302
|
+
driver.setIfAbsentItem = async (key, value, ttl) => {
|
|
303
|
+
const expiresAt = ttl === void 0 ? void 0 : Date.now() + ttlMilliseconds(ttl);
|
|
304
|
+
if (await hasLiveItem(key, {})) return false;
|
|
305
|
+
const path = join(root, fileName(key));
|
|
306
|
+
await mkdir(root, { recursive: true });
|
|
307
|
+
const temporary = join(root, `.unstorage-tmp-${randomUUID()}`);
|
|
308
|
+
await writeFile(temporary, value, "utf8");
|
|
309
|
+
try {
|
|
310
|
+
await link(temporary, path);
|
|
311
|
+
await writeExpiry(key, expiresAt);
|
|
312
|
+
return true;
|
|
313
|
+
} catch (error) {
|
|
314
|
+
if (hasCode(error, "EEXIST") && (await stat(path)).isFile()) return false;
|
|
315
|
+
throw error;
|
|
316
|
+
} finally {
|
|
317
|
+
await rm(temporary, { force: true });
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
async function* walk() {
|
|
321
|
+
let entries;
|
|
322
|
+
try {
|
|
323
|
+
entries = await opendir(root);
|
|
324
|
+
} catch (error) {
|
|
325
|
+
if (hasCode(error, "ENOENT")) return;
|
|
326
|
+
throw error;
|
|
327
|
+
}
|
|
328
|
+
for await (const entry of entries) {
|
|
329
|
+
if (entry.name === basename(layout) || layoutRecord.test(entry.name)) continue;
|
|
330
|
+
const key = entry.isFile() ? keyOf(entry.name) : void 0;
|
|
331
|
+
yield key !== void 0 && await synchronized(() => live(key)) ? key : void 0;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
driver.getKeys = async () => {
|
|
335
|
+
const keys = [];
|
|
336
|
+
for await (const key of walk()) if (key !== void 0) keys.push(key);
|
|
337
|
+
return keys;
|
|
338
|
+
};
|
|
339
|
+
const expired = () => kvErrorDiagnostics.KV_INVALID_CURSOR({ problem: "expired" });
|
|
340
|
+
const continuations = createKVContinuations({
|
|
341
|
+
expired,
|
|
342
|
+
release: (iterator) => iterator.return(void 0)
|
|
343
|
+
});
|
|
344
|
+
const dispose = driver.dispose;
|
|
345
|
+
driver.dispose = async () => {
|
|
346
|
+
try {
|
|
347
|
+
await continuations.dispose();
|
|
348
|
+
} finally {
|
|
349
|
+
await dispose?.call(driver);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
driver.listKeys = async ({ cursor, limit, prefix = "" }) => {
|
|
353
|
+
const keys = [];
|
|
354
|
+
const iterator = cursor ? continuations.take(cursor) : walk();
|
|
355
|
+
if (!iterator) throw expired();
|
|
356
|
+
let scanned = 0;
|
|
357
|
+
while (scanned < limit) {
|
|
358
|
+
const entry = await iterator.next();
|
|
359
|
+
if (entry.done) return { keys };
|
|
360
|
+
scanned++;
|
|
361
|
+
const key = entry.value;
|
|
362
|
+
if (key !== void 0 && key.startsWith(prefix)) keys.push(key);
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
keys,
|
|
366
|
+
cursor: await continuations.retain(iterator)
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
for (const name of [
|
|
370
|
+
"getItem",
|
|
371
|
+
"getItemRaw",
|
|
372
|
+
"getMeta",
|
|
373
|
+
"hasItem",
|
|
374
|
+
"setItem",
|
|
375
|
+
"setItemRaw",
|
|
376
|
+
"removeItem",
|
|
377
|
+
"clear",
|
|
378
|
+
"setIfAbsentItem"
|
|
379
|
+
]) {
|
|
380
|
+
const operation = driver[name];
|
|
381
|
+
if (operation) Reflect.set(driver, name, (...args) => synchronized(async () => Reflect.apply(operation, driver, args)));
|
|
382
|
+
}
|
|
383
|
+
return driver;
|
|
384
|
+
}
|
|
385
|
+
//#endregion
|
|
386
|
+
export { createFsLiteKVDriver as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as RedisKVStoreConfig, C as KVOptions, D as KVStoreName, E as KVStoreConfig, F as ResolvedKVModuleOptions, I as ResolvedKVStoreConfig, L as ResolvedRedisKVStoreConfig, M as ResolvedDatabaseKVStoreConfig, N as ResolvedDenoKVStoreConfig, O as KVStoreOptions, P as ResolvedFsLiteKVStoreConfig, R as ResolvedUpstashKVStoreConfig, S as KVOperation, T as KVStorage, _ as KVLock, a as InferredKVStoreConfig, b as KVLockOptions, c as KVDriverAtomicOperations, d as KVErrorCode, f as KVGetOptions, g as KVListPage, h as KVListOptions, i as FsLiteKVStoreConfig, j as ResolvedCloudflareKVStoreConfig, k as ReadonlyKVStorage, l as KVDriversWith, m as KVGetTypeMap, n as DatabaseKVStoreConfig, o as KVAtomicOperation, p as KVGetType, r as DenoKVStoreConfig, s as KVDriver, t as CloudflareKVStoreConfig, u as KVEntry, v as KVLockAcquisition, w as KVSetOptions, x as KVLockRunResult, y as KVLockErrorCode, z as UpstashKVStoreConfig } from "./types-DEiKew_3.js";
|
|
2
2
|
//#region src/runtime/storage.d.ts
|
|
3
3
|
/** Releases every cached store. Call from the application's shutdown hook after stopping new work. */
|
|
4
4
|
export declare function disposeKVStores(): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* The configured driver that a store uses in this server process. App tests return `fs-lite`.
|
|
7
|
+
* An unknown store throws. Reading the driver does not open a connection to the store.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getKVStoreDriver(name?: KVStoreName): Promise<KVDriver>;
|
|
5
10
|
export declare const kv: KVStorage;
|
|
6
11
|
//#endregion
|
|
7
|
-
export type { CloudflareKVStoreConfig, DenoKVStoreConfig, FsLiteKVStoreConfig, KVDriver, KVErrorCode, KVListOptions, KVListPage,
|
|
12
|
+
export type { CloudflareKVStoreConfig, DatabaseKVStoreConfig, DenoKVStoreConfig, FsLiteKVStoreConfig, InferredKVStoreConfig, KVAtomicOperation, KVDriver, KVDriverAtomicOperations, KVDriversWith, KVEntry, KVErrorCode, KVGetOptions, KVGetType, KVGetTypeMap, KVListOptions, KVListPage, KVLock, KVLockAcquisition, KVLockErrorCode, KVLockOptions, KVLockRunResult, KVOperation, KVOptions, KVSetOptions, KVStorage, KVStoreConfig, KVStoreOptions, ReadonlyKVStorage, RedisKVStoreConfig, ResolvedCloudflareKVStoreConfig, ResolvedDatabaseKVStoreConfig, ResolvedDenoKVStoreConfig, ResolvedFsLiteKVStoreConfig, ResolvedKVModuleOptions, ResolvedKVStoreConfig, ResolvedRedisKVStoreConfig, ResolvedUpstashKVStoreConfig, UpstashKVStoreConfig };
|