@vite-hub/kv 0.4.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.
Files changed (47) hide show
  1. package/README.md +6 -2
  2. package/dist/{cli-DpPhz_Ek.d.ts → cli-CLomw9ml.d.ts} +1 -0
  3. package/dist/cli.d.ts +1 -1
  4. package/dist/cli.js +22 -11
  5. package/dist/{cloudflare-env-lOtHHsgP.js → cloudflare-env-Dl349h_9.js} +2 -1
  6. package/dist/{cloudflare-kv-C3NO4C21.js → cloudflare-kv-DQJhmGof.js} +8 -10
  7. package/dist/{cloudflare-kv-local-C2sbIrFy.js → cloudflare-kv-local-COjgHweC.js} +3 -7
  8. package/dist/{config-LfpUj9hs.js → config-pfyPiPrI.js} +47 -12
  9. package/dist/{create-storage-BORQm2a8.js → create-storage-DQ1BbFqH.js} +1 -1
  10. package/dist/{cursor-history-DRHh5bO5.js → cursor-history-CAT4mpP1.js} +7 -3
  11. package/dist/{deno-kv-D_VtffFv.js → deno-kv-Cf0ZveeN.js} +43 -7
  12. package/dist/driver-Du6Eh9p2.d.ts +47 -0
  13. package/dist/{error-diagnostics-C54QQEhN.js → error-diagnostics-C4VTHInS.js} +6 -2
  14. package/dist/{errors-DzD6YNEH.js → errors-BpiM-Vmh.js} +41 -4
  15. package/dist/errors.d.ts +8 -1
  16. package/dist/errors.js +2 -2
  17. package/dist/{fs-lite-BaklCLuV.js → fs-lite-BTcBUP6B.js} +1 -1
  18. package/dist/fs-lite-C8yXCVDM.js +2 -0
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +27 -55
  21. package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CI2PJGqu.d.ts} +8 -2
  22. package/dist/{operations-CtrWLmPK.js → operations-CqKs7Ykc.js} +22 -37
  23. package/dist/{operations-D2iI9oN4.js → operations-nAaONxzh.js} +38 -8
  24. package/dist/operations.d.ts +2 -2
  25. package/dist/operations.js +3 -3
  26. package/dist/out-BbXG-yVX.js +21755 -0
  27. package/dist/{redis-shared-5ogRd3-Y.js → redis-shared-1M0IaguQ.js} +1 -1
  28. package/dist/request-log-Dj9Vw7qG.js +105 -0
  29. package/dist/{results-p7nPCnaJ.js → results-D6jfPtCk.js} +0 -1
  30. package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
  31. package/dist/runtime/cloudflare-kv.d.ts +1 -1
  32. package/dist/runtime/cloudflare-kv.js +1 -1
  33. package/dist/runtime/cloudflare-request-env.js +1 -1
  34. package/dist/runtime/database.d.ts +2 -0
  35. package/dist/{database-oJdy0ZVX.js → runtime/database.js} +68 -37
  36. package/dist/runtime/nitro-plugin.js +10 -6
  37. package/dist/runtime/redis-driver.d.ts +2 -2
  38. package/dist/runtime/redis-driver.js +2 -5
  39. package/dist/runtime/upstash-driver.d.ts +2 -2
  40. package/dist/runtime/upstash-driver.js +2 -6
  41. package/dist/{types-Dv-OSXZC.d.ts → types-Cp6IBhSN.d.ts} +3 -17
  42. package/dist/{upstash-B-vaUYqO.js → upstash-5sTbIR35.js} +2 -2
  43. package/dist/vite.d.ts +8 -5
  44. package/dist/vite.js +2102 -46
  45. package/package.json +9 -4
  46. package/dist/driver-R4Z5Z5fl.d.ts +0 -15
  47. package/dist/fs-lite-BAgpmNAF.js +0 -2
package/README.md CHANGED
@@ -66,7 +66,7 @@ Several Node processes share keys only through a shared store. Without a `driver
66
66
 
67
67
  `{ driver: "upstash", url?, token?, base? }` uses the same `base` rule as `redis`: every key gets the prefix `vitehub:kv:<store>` unless `base` sets another one, so `kv.clear()` and `kv.list()` stay inside the store. Upstash takes whole seconds, so `set()` rounds a TTL up. Its listing cursor also holds its whole state, so the next page works in another serverless invocation.
68
68
 
69
- `{ driver: "database", database? }` keeps keys in the table `vitehub_kv` of the Database `database` (default `"default"`), with one `namespace` per store. The store creates the table when it is missing; on Postgres, an advisory lock lets several servers start at once. Every atomic operation is one SQL statement, and expiry uses the clock of the Database. Writes start background cleanup of at most 1000 expired rows in their namespace. A full batch lets the next write start another batch; once a batch is not full, cleanup waits a minute. Postgres sweeps skip rows locked by another process. It works on Postgres and libSQL, not on D1.
69
+ `{ driver: "database", database? }` keeps keys in the table `vitehub_kv` of the Database `database` (default `"default"`), with one `namespace` per store. The store creates the table when it is missing; on Postgres, an advisory lock lets several servers start at once. Every atomic operation is one SQL statement, and expiry uses the clock of the Database. Writes start background cleanup of at most 1000 expired rows in their namespace. A full batch lets the next write start another batch; once a batch is not full, cleanup waits a minute. Postgres sweeps skip rows locked by another process. It works on Postgres, libSQL, and Cloudflare D1, by binding or over HTTP. On D1, one statement binds at most 100 values, so a large `setMany()` or `getMany()` uses more statements.
70
70
 
71
71
  The driver is selected at build time. Redis requires `kv: { driver: "redis" }`; every process must supply its URL, and a missing URL fails. An unrelated `REDIS_URL` never changes the selected driver. A build without a `driver` that has `REDIS_URL`, or a `KV_URL` that starts with `rediss://`, reports the hint `KV_REDIS_URL_UNUSED` in the build output and in `.vitehub/hints.json`, with the fix `kv: { driver: "redis" }`. On Vercel without Upstash variables, the same hint says that the inferred Upstash store fails at runtime. The `kv.list` operation (`vitehub kv list`, the Console) reports that driver.
72
72
 
@@ -98,7 +98,7 @@ With `vitehub()`, `cache: { driver: "kv" }` mounts the same driver at Nitro's `c
98
98
 
99
99
  ## Listing keys
100
100
 
101
- `kv.list({ prefix })` returns every key that starts with `prefix`. Add `limit` when the caller needs bounded work: `kv.list({ prefix, limit, cursor })` reads one page. `limit` must be a positive integer. A page returns `{ keys, cursor? }`; an omitted cursor means the listing is complete. `kv.clear({ prefix })` deletes the keys that `kv.list({ prefix })` lists.
101
+ `kv.list({ prefix })` returns every key that starts with `prefix`. Add `limit` when the caller needs bounded work: `kv.list({ prefix, limit, cursor })` reads one page. `limit` must be a positive integer. A page returns `{ keys, cursor? }`; an omitted cursor means the listing is complete. On Cloudflare KV, each binding request returns at most 1,000 keys: with `limit` above 1,000, `kv.list()` caps the request at 1,000 keys and returns a `cursor` only when more keys remain; without `limit`, it reads every page and returns no cursor. `kv.clear({ prefix })` deletes the keys that `kv.list({ prefix })` lists.
102
102
 
103
103
  Prefixes match text, and use the same key normalization as reads and writes. For example, `users/al` matches the stored key `users:alice`, and `user` matches `users:alice` and `user-old:1`. A trailing separator, such as `users/` or `users:`, limits the prefix to children and does not match `users-other`.
104
104
 
@@ -154,6 +154,10 @@ export default defineNitroPlugin((nitroApp) => {
154
154
  })
155
155
  ```
156
156
 
157
+ ## Failures in logs
158
+
159
+ A failed delete of expired rows in a `database` store does not fail the write. With the evlog Nitro module registered, KV logs each streak of failures once, as its own evlog event with `kv: { op: "expiry-sweep", driver, namespace, code }`. Without evlog, it goes to the console. See [Limits and errors](https://vitehub.dev/docs/kv/limits-and-errors#see-expiry-failures-in-logs).
160
+
157
161
  ## CLI
158
162
 
159
163
  `hubKV()` contributes the `vitehub kv` CLI namespace: `list [--prefix] [--limit] [--cursor]`, `get <key>`, `has <key>`, `set <key> <value|@file> [--ttl <seconds>] [--json-value]`, and `delete <key>`. Each command accepts `--store <name>` and `--json`. `get` writes stored strings unchanged, without adding a newline. JSON input rejects underflow and decimal values that change magnitude during parsing; use strings to preserve them. Write commands print what they changed. There is no `clear` command.
@@ -3,6 +3,7 @@ import "nostics";
3
3
  interface HostCliRunResult {
4
4
  exitCode: number | null;
5
5
  stdout: string;
6
+ stderr?: string;
6
7
  }
7
8
  /** Runs a host CLI with an argument array and no shell, and returns its stdout. */
8
9
  type HostCliRun = (command: string, args: readonly string[], options: {
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as ViteHubCliStreams, n as ViteHubCliContributor, t as ViteHubCliContext } from "./cli-DpPhz_Ek.js";
1
+ import { i as ViteHubCliStreams, n as ViteHubCliContributor, t as ViteHubCliContext } from "./cli-CLomw9ml.js";
2
2
  //#region src/cli.d.ts
3
3
  export type KVCliContext = Pick<ViteHubCliContext, "cwd" | "env" | "fetch" | "rootDir"> & ViteHubCliStreams;
4
4
  export interface KVCliOptions {
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
- import { A as writeCliFailure, C as askOnTerminal, E as readCliOptionValue, O as readViteHubDevTargetOption, T as parseCliPositiveInteger, n as callOperationFromCli, w as listSeedFiles } from "./operations-D2iI9oN4.js";
1
+ import { A as readViteHubDevTargetOption, D as parseCliPositiveInteger, E as listSeedFiles, M as writeCliFailure, O as readCliOptionValue, T as askOnTerminal, n as callOperationFromCli } from "./operations-nAaONxzh.js";
2
2
  import { t as isRecord } from "./object-Da1zyPCR.js";
3
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C54QQEhN.js";
4
- import { t as kvDevMaximumListLimit } from "./results-p7nPCnaJ.js";
3
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
4
+ import { t as kvDevMaximumListLimit } from "./results-D6jfPtCk.js";
5
5
  import { readFile } from "node:fs/promises";
6
6
  import { extname, join, relative, resolve } from "node:path";
7
7
  import * as v from "valibot";
@@ -185,9 +185,16 @@ function normalizedDecimal(source) {
185
185
  const scale = BigInt(exponent) - BigInt(fraction.length) + BigInt(digits.length - significant.length);
186
186
  return `${negative ? "-" : ""}${significant}e${scale}`;
187
187
  }
188
+ async function readValueFile(path, cwd) {
189
+ try {
190
+ return await readFile(resolve(cwd, path), "utf8");
191
+ } catch (error) {
192
+ throw kvErrorDiagnostics.KV_CLI_USAGE({ problem: `Could not read the file ${path}: ${error instanceof Error ? error.message : String(error)}` });
193
+ }
194
+ }
188
195
  async function readValue(parsed, cwd) {
189
196
  const raw = parsed.value;
190
- const text = raw.startsWith("@") ? await readFile(resolve(cwd, raw.slice(1)), "utf8") : raw;
197
+ const text = raw.startsWith("@") ? await readValueFile(raw.slice(1), cwd) : raw;
191
198
  if (!parsed.jsonValue) return text;
192
199
  try {
193
200
  const value = JSON.parse(text, (_key, value, context) => {
@@ -207,6 +214,10 @@ function formatValue(result) {
207
214
  if (v.is(v.string(), result.value)) return result.value;
208
215
  return `${JSON.stringify(result.value, null, 2)}\n`;
209
216
  }
217
+ const codedError = v.object({
218
+ code: v.string(),
219
+ fix: v.optional(v.string())
220
+ });
210
221
  const targetFields = {
211
222
  key: v.string(),
212
223
  store: v.string()
@@ -346,7 +357,13 @@ async function runKVCommand(command, args, context, options) {
346
357
  if (command.value && !parsed.help) value = await readValue(parsed, context.cwd);
347
358
  } catch (error) {
348
359
  const terminator = args.indexOf("--");
349
- if (args.slice(0, terminator < 0 ? args.length : terminator).includes("--json")) return writeCliFailure(true, context, { message: error instanceof Error ? error.message : String(error) });
360
+ if (args.slice(0, terminator < 0 ? args.length : terminator).includes("--json")) {
361
+ const coded = v.safeParse(codedError, error);
362
+ return writeCliFailure(true, context, {
363
+ ...coded.success ? coded.output : {},
364
+ message: error instanceof Error ? error.message : String(error)
365
+ });
366
+ }
350
367
  context.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
351
368
  writeUsage(command, context.stderr);
352
369
  return 1;
@@ -405,13 +422,7 @@ async function runKVCli(args, context, options = {}) {
405
422
  }
406
423
  return await runKVCommand(command, rest, context, options);
407
424
  }
408
- /** The folder of the KV seed files, relative to the project root. */
409
425
  const kvSeedDir = "server/seed/kv";
410
- /**
411
- * Writes each file in `server/seed/kv/` to the default KV store with `kv set`. The key is the path without its
412
- * extension, so `server/seed/kv/settings/theme.json` is the key `settings/theme`. A `.json` file is a JSON value, and
413
- * any other file is a string.
414
- */
415
426
  async function runKVSeed(seed, context, options) {
416
427
  const dir = resolve(options.projectRoot?.() ?? context.rootDir, kvSeedDir);
417
428
  const files = await listSeedFiles(dir);
@@ -1,6 +1,7 @@
1
1
  import { i as setInstalledCloudflareEnv, n as getActiveCloudflareEnv, r as getCloudflareEnv, t as activeEnvStorageKey } from "./cloudflare-env-lookup-Bs0VDpU5.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region ../internal/src/runtime/cloudflare-env.ts
4
+ const d1PrimaryClient = Symbol.for("vitehub.database.d1-primary-client");
4
5
  const runtimeGlobal = globalThis;
5
6
  const activeEnvStorage = runtimeGlobal[activeEnvStorageKey] ||= new AsyncLocalStorage();
6
7
  const globalEnvProbe = Symbol("vitehub.cloudflare.global-env-probe");
@@ -43,4 +44,4 @@ function installCloudflareRequestEnv(event, fallback) {
43
44
  if (env) setActiveCloudflareEnv(env);
44
45
  }
45
46
  //#endregion
46
- export { installCloudflareRequestEnv as n, getActiveCloudflareBinding as t };
47
+ export { getActiveCloudflareBinding as n, installCloudflareRequestEnv as r, d1PrimaryClient as t };
@@ -1,9 +1,9 @@
1
1
  import { t as invariant } from "./invariant-DolT9EEx.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C54QQEhN.js";
3
- import { t as getActiveCloudflareBinding } from "./cloudflare-env-lOtHHsgP.js";
4
- import { n as normalizeKVListPrefix, t as createKVStorage } from "./create-storage-BORQm2a8.js";
2
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
3
+ import { n as getActiveCloudflareBinding } from "./cloudflare-env-Dl349h_9.js";
4
+ import { n as normalizeKVListPrefix, t as createKVStorage } from "./create-storage-DQ1BbFqH.js";
5
5
  import { i as setItemsOneByOne, t as chunks } from "./batch--v0ri69O.js";
6
- import { n as recordCursor, t as createCursorHistory } from "./cursor-history-DRHh5bO5.js";
6
+ import { n as recordCursor, t as createCursorHistory } from "./cursor-history-CAT4mpP1.js";
7
7
  import createDriver from "unstorage/drivers/cloudflare-kv-binding";
8
8
  //#region src/runtime/cloudflare-kv-limits.ts
9
9
  const cloudflareKVLimits = {
@@ -12,7 +12,6 @@ const cloudflareKVLimits = {
12
12
  valueBytes: 26214400
13
13
  };
14
14
  const encoder = /*#__PURE__*/ new TextEncoder();
15
- /** Returns the UTF-8 size of `value` when it is above `limit`. */
16
15
  function bytesAbove(value, limit) {
17
16
  if (value.length * 3 <= limit) return;
18
17
  const bytes = encoder.encode(value).byteLength;
@@ -34,7 +33,6 @@ function assertCloudflareKVWrite(key, value) {
34
33
  limit: cloudflareKVLimits.valueBytes
35
34
  });
36
35
  }
37
- /** Cloudflare KV rejects an expiration below 60 seconds, so a shorter `ttl` becomes 60 seconds, also on the local store of `vite dev`. */
38
36
  function cloudflareKVSetOptions(options) {
39
37
  const ttl = options?.ttl;
40
38
  return typeof ttl === "number" ? { ttl: Math.max(cloudflareKVLimits.minExpirationTtl, ttl) } : options;
@@ -79,8 +77,8 @@ function isCloudflareKVListPage(value) {
79
77
  })) return false;
80
78
  return page.list_complete || isCloudflareKVString(page.cursor) && page.cursor.length > 0;
81
79
  }
82
- /** Cloudflare reads at most 100 keys in one bulk `get()`. */
83
80
  const cloudflareKVBulkGetKeys = 100;
81
+ const cloudflareKVMaximumListLimit = 1e3;
84
82
  const cloudflareBindingIdentities = /* @__PURE__ */ new WeakMap();
85
83
  let nextCloudflareBindingIdentity = 0;
86
84
  function cloudflareBindingNamespace(bindingName, namespaceId, binding) {
@@ -143,7 +141,7 @@ function createCloudflareDriver(options) {
143
141
  };
144
142
  driver.listKeys = async ({ cursor, limit, prefix = "" }) => {
145
143
  invariant(!disposed, "a KV store is open while the app runs, because Nitro disposes it only when it closes");
146
- const listOptions = { limit };
144
+ const listOptions = { limit: Math.min(limit, cloudflareKVMaximumListLimit) };
147
145
  if (cursor) listOptions.cursor = cursor;
148
146
  if (prefix) listOptions.prefix = prefix;
149
147
  const activeBinding = typeof bindingName === "string" ? getActiveCloudflareBinding(bindingName) : void 0;
@@ -162,7 +160,7 @@ function createCloudflareDriver(options) {
162
160
  if (!page.list_complete) {
163
161
  invariant(!disposed, "a KV store is open while the app runs, because Nitro disposes it only when it closes");
164
162
  if (cursors.has(page.cursor)) throw kvErrorDiagnostics.KV_PROVIDER_INVALID_RESPONSE({ problem: "ViteHub rejected a repeated pagination cursor." });
165
- if (!recordCursor(cursors, page.cursor)) throw kvErrorDiagnostics.KV_PROVIDER_INVALID_RESPONSE({ problem: "ViteHub rejected pagination after the cursor history limit was reached." });
163
+ if (!recordCursor(cursors, page.cursor)) throw kvErrorDiagnostics.KV_PROVIDER_INVALID_RESPONSE({ problem: "ViteHub rejected a pagination cursor longer than 8 KiB." });
166
164
  result.cursor = cursorHistories.store(page.cursor, cursors, requestNamespace);
167
165
  }
168
166
  cursorHistories.complete(cursor);
@@ -178,7 +176,7 @@ function createCloudflareDriver(options) {
178
176
  do {
179
177
  const page = await driver.listKeys({
180
178
  cursor,
181
- limit: 1e3,
179
+ limit: cloudflareKVMaximumListLimit,
182
180
  prefix
183
181
  });
184
182
  keys.push(...page.keys);
@@ -1,12 +1,8 @@
1
- import { t as getActiveCloudflareBinding } from "./cloudflare-env-lOtHHsgP.js";
1
+ import { n as getActiveCloudflareBinding } from "./cloudflare-env-Dl349h_9.js";
2
2
  import { i as setItemsOneByOne, n as getItemsOneByOne } from "./batch--v0ri69O.js";
3
- import { a as validateCloudflareKVBatch, i as installCloudflareKVLimits, r as assertCloudflareKVWrite, t as createCloudflareDriver } from "./cloudflare-kv-C3NO4C21.js";
4
- import { t as createFsLiteKVDriver } from "./fs-lite-BaklCLuV.js";
3
+ import { a as validateCloudflareKVBatch, i as installCloudflareKVLimits, r as assertCloudflareKVWrite, t as createCloudflareDriver } from "./cloudflare-kv-DQJhmGof.js";
4
+ import { t as createFsLiteKVDriver } from "./fs-lite-BTcBUP6B.js";
5
5
  //#region src/runtime/cloudflare-kv-local.ts
6
- /**
7
- * Seconds until the key expires, as the binding computes them from unstorage's options: `ttl` becomes an
8
- * `expirationTtl` of at least 60 seconds, and a relative expiration wins over the absolute `expiration`.
9
- */
10
6
  function cloudflareExpirationSeconds(options) {
11
7
  if (!options || typeof options !== "object") return;
12
8
  const ttl = Reflect.get(options, "ttl");
@@ -1,5 +1,5 @@
1
1
  import { t as isRecord } from "./object-Da1zyPCR.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C54QQEhN.js";
2
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
3
3
  import { o as normalizeKey } from "./utils2-FozcTsmb.js";
4
4
  import { defu } from "defu";
5
5
  //#region ../internal/src/env.ts
@@ -82,11 +82,6 @@ function resolveStoreMode(store, remote, input) {
82
82
  localBase: cloudflareKVLocalBase(store.binding)
83
83
  };
84
84
  }
85
- /**
86
- * The folder of an `fs-lite` store without `base`. The default store keeps `.vitehub/data/kv`. Each named store gets its
87
- * own folder next to it, so stores never share keys. It is not inside `.vitehub/data/kv`, because the default store
88
- * treats folders there as keys from the old layout.
89
- */
90
85
  function fsLiteStoreBase(name) {
91
86
  if (name === "default") return ".vitehub/data/kv";
92
87
  return `.vitehub/data/kv-stores/${encodeURIComponent(name).replace(/\./g, "%2E") || "%"}`;
@@ -101,7 +96,6 @@ function resolveFsLiteStore(config = {}, name = "default") {
101
96
  function redisStorePrefix(name) {
102
97
  return `vitehub:kv:${name.replace(/[%:/\\?]/g, (character) => encodeURIComponent(character)) || "%"}`;
103
98
  }
104
- /** An empty prefix would let `kv.clear()` and `kv.list()` reach every key of the Redis or Upstash database. */
105
99
  function resolveStoreBase(base, name) {
106
100
  return normalizeKey(trimmed(base)) || redisStorePrefix(name);
107
101
  }
@@ -136,7 +130,7 @@ function resolveDenoStore(config = {}) {
136
130
  path
137
131
  } : { driver: "deno-kv" };
138
132
  }
139
- function resolveExplicitStore(store, env, name, input) {
133
+ function resolveExplicitStore(store, env, name, input, path) {
140
134
  const remote = readRemote(store, name);
141
135
  const { driver } = store;
142
136
  if (input.dev && (remote === true && (driver === "fs-lite" || driver === "deno-kv") || remote === false && driver === "upstash")) throw kvErrorDiagnostics.KV_REMOTE_CONFLICT({
@@ -144,7 +138,9 @@ function resolveExplicitStore(store, env, name, input) {
144
138
  remote,
145
139
  store: name
146
140
  });
147
- return resolveStoreMode(resolveStoreDriver(store, env, name), remote, input);
141
+ const resolved = resolveStoreDriver(store, env, name);
142
+ assertKnownKVStoreKeys(store, store.driver, path);
143
+ return resolveStoreMode(resolved, remote, input);
148
144
  }
149
145
  function resolveStoreDriver(store, env, name) {
150
146
  switch (store.driver) {
@@ -163,7 +159,38 @@ function resolveStoreDriver(store, env, name) {
163
159
  }
164
160
  }
165
161
  }
166
- /** Driver names that ViteHub renamed to the host name. `npx @vite-hub/codemods driver-key` moves them. */
162
+ const kvDriverOptions = {
163
+ "cloudflare": [
164
+ "binding",
165
+ "namespaceId",
166
+ "namespaceName"
167
+ ],
168
+ "database": ["database"],
169
+ "deno-kv": ["path"],
170
+ "fs-lite": ["base"],
171
+ "redis": ["base", "url"],
172
+ "upstash": [
173
+ "base",
174
+ "token",
175
+ "url"
176
+ ]
177
+ };
178
+ function assertKnownKVStoreKeys(store, driver, path) {
179
+ const known = /* @__PURE__ */ new Set([
180
+ "driver",
181
+ "remote",
182
+ ...driver ? kvDriverOptions[driver] : []
183
+ ]);
184
+ const key = Object.keys(store).find((name) => !known.has(name) && Reflect.get(store, name) !== void 0);
185
+ if (key === void 0) return;
186
+ const drivers = Object.keys(kvDriverOptions).filter((name) => kvDriverOptions[name].includes(key));
187
+ throw kvErrorDiagnostics.KV_UNKNOWN_STORE_OPTION({
188
+ drivers,
189
+ driver,
190
+ key,
191
+ path
192
+ });
193
+ }
167
194
  const renamedKVDrivers = /* @__PURE__ */ new Map([["cloudflare-kv-binding", "cloudflare"]]);
168
195
  function createResolvedConfig(store, stores) {
169
196
  return stores ? {
@@ -187,12 +214,20 @@ function normalizeKVOptions(options, input = {}) {
187
214
  const stores = hasOwnStores ? Reflect.get(options, "stores", options) : void 0;
188
215
  if (hasOwnStores && !isRecord(stores)) throw kvErrorDiagnostics.KV_INVALID_CONFIG({ path: "kv.stores" });
189
216
  if (hasStoresConfig(options, stores)) {
190
- const resolvedStores = Object.fromEntries(Object.entries(stores).map(([name, store]) => [name, resolveExplicitStore(store, env, name, input)]));
217
+ const extra = Object.entries(options ?? {}).find(([key, value]) => key !== "stores" && value !== void 0)?.[0];
218
+ if (extra !== void 0) throw kvErrorDiagnostics.KV_UNKNOWN_STORE_OPTION({
219
+ drivers: [],
220
+ key: extra,
221
+ path: "kv",
222
+ stores: true
223
+ });
224
+ const resolvedStores = Object.fromEntries(Object.entries(stores).map(([name, store]) => [name, resolveExplicitStore(store, env, name, input, `kv.stores.${name}`)]));
191
225
  const defaultStore = resolvedStores.default;
192
226
  if (!defaultStore) throw kvErrorDiagnostics.KV_MISSING_DEFAULT_STORE();
193
227
  return createResolvedConfig(defaultStore, resolvedStores);
194
228
  }
195
- if (explicit?.driver) return createResolvedConfig(resolveExplicitStore(explicit, env, "default", input));
229
+ if (explicit?.driver) return createResolvedConfig(resolveExplicitStore(explicit, env, "default", input, "kv"));
230
+ if (explicit) assertKnownKVStoreKeys(explicit, void 0, "kv");
196
231
  const remote = explicit ? readRemote(explicit, "default") : void 0;
197
232
  const inferred = (store) => createResolvedConfig(resolveStoreMode(store, remote, input));
198
233
  const hosted = !input.prerender && (!input.dev || remote === true);
@@ -1,4 +1,4 @@
1
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C54QQEhN.js";
1
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
2
2
  import { a as normalizeBaseKey, i as joinKeys, n as filterKeyByDepth, o as normalizeKey, r as hasDotSegment, t as filterKeyByBase } from "./utils2-FozcTsmb.js";
3
3
  import { r as mapWithLimit } from "./batch--v0ri69O.js";
4
4
  //#region ../../node_modules/.pnpm/unstorage@2.0.0-beta.0/node_modules/unstorage/dist/_chunks/libs/destr.mjs
@@ -1,5 +1,5 @@
1
1
  import { t as invariant } from "./invariant-DolT9EEx.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C54QQEhN.js";
2
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
3
3
  //#region src/runtime/cursor-history.ts
4
4
  const MAX_CURSOR_HISTORIES = 1024;
5
5
  const MAX_CURSORS_PER_HISTORY = 1024;
@@ -155,9 +155,13 @@ function createCursorHistory(namespace = "default") {
155
155
  clear
156
156
  };
157
157
  }
158
- /** Records a provider cursor, refusing to weaken repeat detection at the bound. */
158
+ /** Records a provider cursor. At the bound it forgets the oldest cursor, so a long listing continues and a recent repeat is still caught. */
159
159
  function recordCursor(history, cursor) {
160
- if (cursor.length > MAX_CURSOR_LENGTH || history.size >= MAX_CURSORS_PER_HISTORY) return false;
160
+ if (cursor.length > MAX_CURSOR_LENGTH) return false;
161
+ if (history.size >= MAX_CURSORS_PER_HISTORY) {
162
+ const oldest = history.values().next();
163
+ if (!oldest.done) history.delete(oldest.value);
164
+ }
161
165
  history.add(cursor);
162
166
  return true;
163
167
  }
@@ -1,7 +1,8 @@
1
1
  import { t as invariant } from "./invariant-DolT9EEx.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C54QQEhN.js";
3
- import { n as recordCursor, t as createCursorHistory } from "./cursor-history-DRHh5bO5.js";
2
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
3
+ import { n as recordCursor, t as createCursorHistory } from "./cursor-history-CAT4mpP1.js";
4
4
  //#region src/runtime/deno-kv.ts
5
+ const MAX_DENO_KEY_BYTES = 2048;
5
6
  function getDenoRuntime() {
6
7
  return globalThis.Deno;
7
8
  }
@@ -11,6 +12,21 @@ function toDenoKey(key) {
11
12
  function fromDenoKey(key) {
12
13
  return key.length === 1 && typeof key[0] === "string" ? key[0] : void 0;
13
14
  }
15
+ function canMatchStoredKey(prefix) {
16
+ const nulBytes = prefix.split("\0").length - 1;
17
+ return 2 + new TextEncoder().encode(prefix).length + nulBytes <= MAX_DENO_KEY_BYTES;
18
+ }
19
+ function sortsAfterPrefix(key, prefix) {
20
+ const [part] = key;
21
+ if (typeof part !== "string") return !(part instanceof Uint8Array);
22
+ if (part.startsWith(prefix)) return false;
23
+ const prefixCodePoints = prefix[Symbol.iterator]();
24
+ for (const character of part) {
25
+ const prefixCharacter = prefixCodePoints.next().value;
26
+ if (prefixCharacter === void 0 || character !== prefixCharacter) return (character.codePointAt(0) ?? 0) > (prefixCharacter?.codePointAt(0) ?? -1);
27
+ }
28
+ return false;
29
+ }
14
30
  function toDenoExpireIn(ttl) {
15
31
  if (typeof ttl !== "number" || !Number.isFinite(ttl) || ttl <= 0) return void 0;
16
32
  const expireIn = Math.max(1, Math.ceil(ttl * 1e3));
@@ -39,7 +55,14 @@ function createDenoKVDriver(options = { driver: "deno-kv" }) {
39
55
  async function matchingKeys(base = "") {
40
56
  const kv = await open();
41
57
  const keys = [];
42
- for await (const entry of kv.list({ prefix: [] })) if (fromDenoKey(entry.key)?.startsWith(base)) keys.push(entry.key);
58
+ if (!canMatchStoredKey(base)) return keys;
59
+ for await (const entry of kv.list(base ? {
60
+ prefix: [],
61
+ start: [base]
62
+ } : { prefix: [] })) {
63
+ if (sortsAfterPrefix(entry.key, base)) break;
64
+ if (fromDenoKey(entry.key)?.startsWith(base)) keys.push(entry.key);
65
+ }
43
66
  return keys;
44
67
  }
45
68
  return {
@@ -79,22 +102,35 @@ function createDenoKVDriver(options = { driver: "deno-kv" }) {
79
102
  };
80
103
  try {
81
104
  const cursors = continuation.history;
82
- const iterator = (await open()).list({ prefix: [] }, {
105
+ const keys = [];
106
+ if (!canMatchStoredKey(prefix)) {
107
+ cursorHistories.complete(cursor);
108
+ return { keys };
109
+ }
110
+ const selector = prefix && !continuation.providerCursor ? {
111
+ prefix: [],
112
+ start: [prefix]
113
+ } : { prefix: [] };
114
+ const iterator = (await open()).list(selector, {
83
115
  cursor: continuation.providerCursor,
84
116
  limit
85
117
  });
86
- const keys = [];
118
+ let pastPrefix = false;
87
119
  for await (const entry of iterator) {
120
+ if (sortsAfterPrefix(entry.key, prefix)) {
121
+ pastPrefix = true;
122
+ break;
123
+ }
88
124
  const key = fromDenoKey(entry.key);
89
125
  if (key?.startsWith(prefix)) keys.push(key);
90
126
  }
91
- if (!iterator.cursor) {
127
+ if (pastPrefix || !iterator.cursor) {
92
128
  cursorHistories.complete(cursor);
93
129
  return { keys };
94
130
  }
95
131
  invariant(!disposed, "a KV store is open while the app runs, because Nitro disposes it only when it closes");
96
132
  if (cursors.has(iterator.cursor)) throw kvErrorDiagnostics.KV_PROVIDER_INVALID_RESPONSE({ problem: "Deno KV list returned a repeated pagination cursor." });
97
- if (!recordCursor(cursors, iterator.cursor)) throw kvErrorDiagnostics.KV_PROVIDER_INVALID_RESPONSE({ problem: "Deno KV rejected pagination after the cursor history limit was reached." });
133
+ if (!recordCursor(cursors, iterator.cursor)) throw kvErrorDiagnostics.KV_PROVIDER_INVALID_RESPONSE({ problem: "Deno KV returned a pagination cursor longer than 8 KiB." });
98
134
  const nextCursor = cursorHistories.store(iterator.cursor, cursors);
99
135
  cursorHistories.complete(cursor);
100
136
  return {
@@ -0,0 +1,47 @@
1
+ import { i as TransactionOptions, t as Driver } from "./types-Bj3EQoRg.js";
2
+ import { P as ResolvedDatabaseKVStoreConfig, T as KVPageOptions, _ as KVListPage } from "./types-Cp6IBhSN.js";
3
+ //#region src/runtime/database.d.ts
4
+ /** The table that keeps the keys of every `database` store. Each store has its rows under its own `namespace`. */
5
+ declare const kvTable = "vitehub_kv";
6
+ type KVSqlParam = string | number | null;
7
+ /**
8
+ * Runs one statement and resolves its rows as objects keyed by column name. `postgresql` SQL uses `$1`, `$2`, ... and
9
+ * `sqlite` SQL uses `?`.
10
+ */
11
+ interface KVSqlClient {
12
+ dialect: "postgresql" | "sqlite";
13
+ /** The most values that one statement may bind, such as 100 on Cloudflare D1. */
14
+ maxParameters?: number;
15
+ query(sql: string, params: KVSqlParam[]): Promise<readonly Record<string, unknown>[]>;
16
+ }
17
+ /** The databases of the app, as `@vite-hub/database/runtime/registry` exports them. */
18
+ type KVDatabases = Record<string, {
19
+ db: object;
20
+ } | undefined>;
21
+ /**
22
+ * A SQL client over the Drizzle database of the app: postgres.js, libSQL, primary Cloudflare D1, or D1 over HTTP. It resolves
23
+ * the client on each query because the Database connection can belong to the request.
24
+ */
25
+ declare function kvSqlClientFromDatabase(db: object, database: string): KVSqlClient;
26
+ type DatabaseKVDriver = KVRuntimeDriver & Required<Pick<KVRuntimeDriver, "getItems">>;
27
+ /**
28
+ * KV in a table of the app's Database. Each atomic operation is one statement, so two servers that write one key at
29
+ * the same time get one winner. Expiry uses the clock of the Database. Works on Postgres and on SQLite 3.35 or later,
30
+ * such as libSQL and Cloudflare D1. `table` defaults to `vitehub_kv`. A caller that passes another table keeps its rows
31
+ * out of reach of every KV store.
32
+ */
33
+ declare function createDatabaseKVDriver(options: ResolvedDatabaseKVStoreConfig, connect: () => Promise<KVSqlClient>, table?: string): DatabaseKVDriver;
34
+ //#endregion
35
+ //#region src/runtime/driver.d.ts
36
+ type KVRuntimeDriver = Driver & Record<string, unknown> & {
37
+ validateBatch?: (items: Parameters<NonNullable<Driver["setItems"]>>[0], removals: string[], options?: TransactionOptions) => void | Promise<void>;
38
+ /** Deletes the key when it holds the serialized `expected` value. Resolves `true` when this call deleted it. */
39
+ deleteIfEqualsItem?: (key: string, expected: string) => Promise<boolean>;
40
+ getAndDeleteItem?: <T = unknown>(key: string) => Promise<T | null>;
41
+ incrementItem?: (key: string, ttl: number) => Promise<number>;
42
+ listKeys: (options: KVPageOptions) => Promise<KVListPage>;
43
+ /** Writes the serialized value only when the key is missing. Resolves `true` when this call wrote it. */
44
+ setIfAbsentItem?: (key: string, value: string, ttl?: number) => Promise<boolean>;
45
+ };
46
+ //#endregion
47
+ export { createDatabaseKVDriver as a, KVSqlParam as i, KVDatabases as n, kvSqlClientFromDatabase as o, KVSqlClient as r, kvTable as s, KVRuntimeDriver as t };
@@ -73,8 +73,8 @@ const kvErrorDiagnostics = /*#__PURE__*/ defineErrors({
73
73
  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."
74
74
  },
75
75
  KV_DATABASE_UNAVAILABLE: {
76
- 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.`,
77
- 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."
76
+ 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.js, libSQL, or Cloudflare D1.`,
77
+ fix: ({ problem }) => problem === "missing" ? "Add a Database Definition, for example `server/database.ts` with `defineDatabase({ dialect: 'postgresql', schema: {} })`, or select another KV driver." : "Point the Database at postgres.js, libSQL, or Cloudflare D1 by binding or over HTTP, or select another KV driver."
78
78
  },
79
79
  KV_DENO_KV_UNAVAILABLE: {
80
80
  why: "The `deno-kv` driver needs `Deno.openKv()`, and this runtime does not have it.",
@@ -120,6 +120,10 @@ const kvErrorDiagnostics = /*#__PURE__*/ defineErrors({
120
120
  why: ({ store, stores }) => stores ? `KV store "${store}" was not found. Stores: ${stores}.` : `The KV store "${store}" is not configured.`,
121
121
  fix: "Add the store under `kv.stores`, or use the name of a configured store."
122
122
  },
123
+ KV_UNKNOWN_STORE_OPTION: {
124
+ why: ({ driver, key, path, stores }) => stores ? `\`${path}\` has \`stores\`, so it takes no other key, and it has \`${key}\`.` : driver ? `\`${path}.${key}\` is not an option of the \`${driver}\` KV driver.` : `\`${path}.${key}\` is not an option of a KV store without \`driver\`. ViteHub picks the driver from the host and would ignore it.`,
125
+ fix: ({ drivers, driver, key, stores }) => stores ? `Move \`${key}\` into a store under \`stores\`, for example \`stores: { default: { driver: "fs-lite" } }\`.` : drivers.length && !driver ? `Set \`driver\` to ${drivers.map((name) => `"${name}"`).join(" or ")}, which reads \`${key}\`. ViteHub renamed some drivers, so run \`npx @vite-hub/codemods driver-key\` when the config had an old driver name.` : drivers.length ? `Remove \`${key}\`, or set \`driver\` to ${drivers.map((name) => `"${name}"`).join(" or ")}, which reads it.` : `Remove \`${key}\`. A KV store takes \`driver\`, \`remote\`, and the options of its driver.`
126
+ },
123
127
  KV_INVALID_COUNTER: {
124
128
  why: "kv.increment() needs a stored integer below 9007199254740991. The value did not change.",
125
129
  fix: "Delete the key or replace its value with a canonical integer below Number.MAX_SAFE_INTEGER, then retry kv.increment()."
@@ -1,5 +1,22 @@
1
- import { n as kvErrorDiagnostics, t as kvConfigErrorCodes } from "./error-diagnostics-C54QQEhN.js";
2
- import { isRuntimeDiagnostic, toResultError } from "@vite-hub/runtime";
1
+ import { n as kvErrorDiagnostics, t as kvConfigErrorCodes } from "./error-diagnostics-C4VTHInS.js";
2
+ import { isRuntimeDiagnostic, parseDuration, toResultError } from "@vite-hub/runtime";
3
+ //#region src/runtime/ttl.ts
4
+ /**
5
+ * The seconds of a KV `ttl`: a number of seconds, or a duration such as `"1h"`. `undefined` when it is not a positive
6
+ * time, so the caller returns `KV_INVALID_TTL`.
7
+ */
8
+ function ttlSeconds(ttl) {
9
+ let seconds;
10
+ if (typeof ttl === "number") seconds = ttl;
11
+ else if (typeof ttl !== "string") return;
12
+ else try {
13
+ seconds = parseDuration(ttl) / 1e3;
14
+ } catch {
15
+ return;
16
+ }
17
+ return Number.isFinite(seconds) && seconds > 0 && Number.isSafeInteger(Math.ceil(seconds * 1e3)) ? seconds : void 0;
18
+ }
19
+ //#endregion
3
20
  //#region src/store-mode.ts
4
21
  /**
5
22
  * Returns the handle that `kv.store(name, options)` gives. An unknown mode throws, so a typo never gives a writable handle.
@@ -59,7 +76,6 @@ function kvInvalidLimitError() {
59
76
  function kvListLimitInvalid(options) {
60
77
  return options.limit !== void 0 && (!Number.isInteger(options.limit) || options.limit <= 0);
61
78
  }
62
- /** The page size when `list()` reads every key. Every driver accepts it. */
63
79
  const listAllPageSize = 1e3;
64
80
  /** One page with `limit`. Without it, every key from `cursor` on, in one page without a cursor. */
65
81
  async function listKVKeys(listKeys, options) {
@@ -84,5 +100,26 @@ async function listKVKeys(listKeys, options) {
84
100
  const kvKeyLimitCodes = ["KV_KEY_TOO_LONG"];
85
101
  /** Codes that a Cloudflare KV store returns for a write above the host limits. */
86
102
  const kvWriteLimitCodes = ["KV_KEY_TOO_LONG", "KV_VALUE_TOO_LARGE"];
103
+ /** The codes that `set()` and `setMany()` return: the write limits and an invalid option or `ttl`. */
104
+ const kvSetCodes = [
105
+ ...kvWriteLimitCodes,
106
+ "KV_INVALID_OPTION",
107
+ "KV_INVALID_TTL"
108
+ ];
109
+ /**
110
+ * The `ttl` of a write in seconds, or `undefined` when the caller sets none.
111
+ * Throws `KV_INVALID_OPTION` for any option other than `ttl`, and `KV_INVALID_TTL` for a `ttl` that is not a positive time.
112
+ */
113
+ function kvSetTTL(operation, options) {
114
+ if (options === void 0) return;
115
+ for (const option of Object.keys(options)) if (option !== "ttl") throw kvErrorDiagnostics.KV_INVALID_OPTION({
116
+ operation,
117
+ option
118
+ });
119
+ if (options.ttl === void 0) return;
120
+ const ttl = ttlSeconds(options.ttl);
121
+ if (ttl === void 0) throw kvErrorDiagnostics.KV_INVALID_TTL();
122
+ return ttl;
123
+ }
87
124
  //#endregion
88
- export { kvResult as a, kvWriteLimitCodes as c, kvListLimitInvalid as i, listKVKeys as l, kvInvalidLimitError as n, kvStoreNotFoundError as o, kvKeyLimitCodes as r, kvUnsupportedOperationError as s, kvClearOptionsError as t, kvStoreWithMode as u };
125
+ export { kvResult as a, kvStoreNotFoundError as c, listKVKeys as d, kvStoreWithMode as f, kvListLimitInvalid as i, kvUnsupportedOperationError as l, kvInvalidLimitError as n, kvSetCodes as o, ttlSeconds as p, kvKeyLimitCodes as r, kvSetTTL as s, kvClearOptionsError as t, kvWriteLimitCodes as u };
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as KVStoreOptions, C as KVOperation, D as KVStorage, T as KVPageOptions, _ as KVListPage, f as KVErrorCode, g as KVListOptions, j as ReadonlyKVStorage } from "./types-Dv-OSXZC.js";
1
+ import { A as KVStoreOptions, C as KVOperation, D as KVStorage, E as KVSetOptions, T as KVPageOptions, _ as KVListPage, f as KVErrorCode, g as KVListOptions, j as ReadonlyKVStorage } from "./types-Cp6IBhSN.js";
2
2
  import { Result, ResultError } from "@vite-hub/runtime";
3
3
  //#region src/store-mode.d.ts
4
4
  /**
@@ -26,4 +26,11 @@ export declare function listKVKeys(listKeys: (options: KVPageOptions) => Promise
26
26
  export declare const kvKeyLimitCodes: readonly ["KV_KEY_TOO_LONG"];
27
27
  /** Codes that a Cloudflare KV store returns for a write above the host limits. */
28
28
  export declare const kvWriteLimitCodes: readonly ["KV_KEY_TOO_LONG", "KV_VALUE_TOO_LARGE"];
29
+ /** The codes that `set()` and `setMany()` return: the write limits and an invalid option or `ttl`. */
30
+ export declare const kvSetCodes: readonly ["KV_KEY_TOO_LONG", "KV_VALUE_TOO_LARGE", "KV_INVALID_OPTION", "KV_INVALID_TTL"];
31
+ /**
32
+ * The `ttl` of a write in seconds, or `undefined` when the caller sets none.
33
+ * Throws `KV_INVALID_OPTION` for any option other than `ttl`, and `KV_INVALID_TTL` for a `ttl` that is not a positive time.
34
+ */
35
+ export declare function kvSetTTL(operation: "set" | "setIfAbsent" | "setMany", options: KVSetOptions | undefined): number | undefined;
29
36
  //#endregion
package/dist/errors.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as kvResult, c as kvWriteLimitCodes, i as kvListLimitInvalid, l as listKVKeys, n as kvInvalidLimitError, o as kvStoreNotFoundError, r as kvKeyLimitCodes, s as kvUnsupportedOperationError, t as kvClearOptionsError, u as kvStoreWithMode } from "./errors-DzD6YNEH.js";
2
- export { kvClearOptionsError, kvInvalidLimitError, kvKeyLimitCodes, kvListLimitInvalid, kvResult, kvStoreNotFoundError, kvStoreWithMode, kvUnsupportedOperationError, kvWriteLimitCodes, listKVKeys };
1
+ import { a as kvResult, c as kvStoreNotFoundError, d as listKVKeys, f as kvStoreWithMode, i as kvListLimitInvalid, l as kvUnsupportedOperationError, n as kvInvalidLimitError, o as kvSetCodes, r as kvKeyLimitCodes, s as kvSetTTL, t as kvClearOptionsError, u as kvWriteLimitCodes } from "./errors-BpiM-Vmh.js";
2
+ export { kvClearOptionsError, kvInvalidLimitError, kvKeyLimitCodes, kvListLimitInvalid, kvResult, kvSetCodes, kvSetTTL, kvStoreNotFoundError, kvStoreWithMode, kvUnsupportedOperationError, kvWriteLimitCodes, listKVKeys };
@@ -1,4 +1,4 @@
1
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C54QQEhN.js";
1
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
2
2
  import { link, lstat, mkdir, mkdtemp, opendir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
3
3
  import { basename, join, relative, resolve, sep } from "node:path";
4
4
  import createDriver from "unstorage/drivers/fs-lite";
@@ -0,0 +1,2 @@
1
+ import { t as createFsLiteKVDriver } from "./fs-lite-BTcBUP6B.js";
2
+ export { createFsLiteKVDriver as default };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as KVStoreOptions, B as ResolvedUpstashKVStoreConfig, C as KVOperation, D as KVStorage, E as KVSetOptions, F as ResolvedDenoKVStoreConfig, I as ResolvedFsLiteKVStoreConfig, L as ResolvedKVModuleOptions, M as RedisKVStoreConfig, N as ResolvedCloudflareKVStoreConfig, O as KVStoreConfig, P as ResolvedDatabaseKVStoreConfig, R as ResolvedKVStoreConfig, S as KVLockRunResult, V as UpstashKVStoreConfig, _ as KVListPage, a as InferredKVStoreConfig, b as KVLockErrorCode, c as KVDriver, d as KVEntry, f as KVErrorCode, g as KVListOptions, h as KVGetTypeMap, i as FsLiteKVStoreConfig, j as ReadonlyKVStorage, k as KVStoreName, l as KVDriverAtomicOperations, m as KVGetType, n as DatabaseKVStoreConfig, o as KVAtomicOperation, p as KVGetOptions, r as DenoKVStoreConfig, s as KVClearOptions, t as CloudflareKVStoreConfig, u as KVDriversWith, v as KVLock, w as KVOptions, x as KVLockOptions, y as KVLockAcquisition, z as ResolvedRedisKVStoreConfig } from "./types-Dv-OSXZC.js";
1
+ import { A as KVStoreOptions, B as ResolvedUpstashKVStoreConfig, C as KVOperation, D as KVStorage, E as KVSetOptions, F as ResolvedDenoKVStoreConfig, I as ResolvedFsLiteKVStoreConfig, L as ResolvedKVModuleOptions, M as RedisKVStoreConfig, N as ResolvedCloudflareKVStoreConfig, O as KVStoreConfig, P as ResolvedDatabaseKVStoreConfig, R as ResolvedKVStoreConfig, S as KVLockRunResult, V as UpstashKVStoreConfig, _ as KVListPage, a as InferredKVStoreConfig, b as KVLockErrorCode, c as KVDriver, d as KVEntry, f as KVErrorCode, g as KVListOptions, h as KVGetTypeMap, i as FsLiteKVStoreConfig, j as ReadonlyKVStorage, k as KVStoreName, l as KVDriverAtomicOperations, m as KVGetType, n as DatabaseKVStoreConfig, o as KVAtomicOperation, p as KVGetOptions, r as DenoKVStoreConfig, s as KVClearOptions, t as CloudflareKVStoreConfig, u as KVDriversWith, v as KVLock, w as KVOptions, x as KVLockOptions, y as KVLockAcquisition, z as ResolvedRedisKVStoreConfig } from "./types-Cp6IBhSN.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>;