@vite-hub/kv 0.6.1 → 0.8.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 (39) hide show
  1. package/README.md +9 -7
  2. package/dist/{cli-BvVInMht.d.ts → cli-C-uep33j.d.ts} +15 -0
  3. package/dist/cli.d.ts +2 -2
  4. package/dist/cli.js +3 -2
  5. package/dist/{cloudflare-kv-Cp8HPUlJ.js → cloudflare-kv-hMdZQZz1.js} +3 -3
  6. package/dist/{cloudflare-kv-local-COoOI34K.js → cloudflare-kv-local-BpPaDG49.js} +2 -2
  7. package/dist/{config-_1oBDv2R.js → config-x_Nru3R5.js} +4 -4
  8. package/dist/{create-storage-DbWVAY9l.js → create-storage-DrhV0F4S.js} +1 -1
  9. package/dist/{cursor-history-CMcEEnTO.js → cursor-history-MzSrXXXX.js} +1 -1
  10. package/dist/{database-4iAg2GoV.js → database-D0NvYrhk.js} +66 -20
  11. package/dist/{deno-kv-CatE7zSS.js → deno-kv-DwcTL95B.js} +2 -2
  12. package/dist/{driver-BruahGvT.d.ts → driver-CZTAQ_07.d.ts} +2 -2
  13. package/dist/{error-diagnostics-CuVl1nvE.js → error-diagnostics-DAi25E6F.js} +10 -5
  14. package/dist/{errors-CJoAP4Bu.js → errors-kZRpu7Wa.js} +15 -2
  15. package/dist/errors.d.ts +6 -1
  16. package/dist/errors.js +1 -1
  17. package/dist/{fs-lite-DzTTR6R3.js → fs-lite-1n_Dvy4p.js} +195 -131
  18. package/dist/fs-lite-Co1NzxYo.js +1 -0
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +79 -69
  21. package/dist/{operation-definition-CqZkx1Rm.d.ts → operations-BAlr2zUj.d.ts} +1 -0
  22. package/dist/{operations-DSOTGwST.js → operations-Cj_0pSSA.js} +22 -29
  23. package/dist/{operations-BkVt17cd.js → operations-DP8iWjQK.js} +75 -11
  24. package/dist/operations.d.ts +2 -2
  25. package/dist/operations.js +2 -2
  26. package/dist/{redis-shared-CR3ANc_N.js → redis-shared-DEwmedD5.js} +1 -1
  27. package/dist/runtime/cloudflare-kv.d.ts +1 -1
  28. package/dist/runtime/cloudflare-kv.js +1 -1
  29. package/dist/runtime/nitro-plugin.js +1 -1
  30. package/dist/runtime/redis-driver.d.ts +2 -2
  31. package/dist/runtime/redis-driver.js +3 -5
  32. package/dist/runtime/upstash-driver.d.ts +2 -2
  33. package/dist/runtime/upstash-driver.js +2 -2
  34. package/dist/{types-CPDL9enF.d.ts → types-BLxnI_rU.d.ts} +14 -14
  35. package/dist/{upstash-DeM3_U5H.js → upstash-DINRYhXI.js} +2 -2
  36. package/dist/vite.d.ts +9 -5
  37. package/dist/vite.js +211 -75
  38. package/package.json +8 -4
  39. package/dist/fs-lite-DwbPkc-C.js +0 -1
package/README.md CHANGED
@@ -19,6 +19,8 @@ Add `@upstash/redis` when you use the Upstash driver. The `redis` driver uses `i
19
19
 
20
20
  ## Minimal API
21
21
 
22
+ Install H3 2 for the route below: `pnpm add h3@^2.0.8`.
23
+
22
24
  ```ts
23
25
  // server/api/settings.put.ts
24
26
  import { kv } from "@vite-hub/kv"
@@ -66,13 +68,13 @@ Several Node processes share keys only through a shared store. Without a `driver
66
68
 
67
69
  `{ 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
70
 
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.
71
+ `{ 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 with Postgres (postgres.js, node-postgres, or PGlite), libSQL, and native D1 bindings or sessions, not D1 over HTTP. On D1, a statement binds at most 100 values, so batches are smaller.
70
72
 
71
73
  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
74
 
73
75
  This changes the default of a Node build with a Postgres Database from `fs-lite` to `database`. Keys in `.vitehub/data/kv` are not copied. Set `kv: { driver: "fs-lite" }` to keep the old store.
74
76
 
75
- `fs-lite` writes each key as one file in `base`. The file name starts with `key-`, followed by the key with `%` and `:` escaped as in a URL, so `signups` and `signups:reset-at` are the files `key-signups` and `key-signups%3Areset-at`. This prefix keeps application keys separate from migration metadata and temporary files. Most file systems limit a file name to 255 bytes, so an escaped key longer than 251 bytes fails with `KV_OPERATION_FAILED`. Earlier versions wrote `a:b` as the file `a/b`. The store moves those files to their new names when it opens the folder and preserves literal `%` characters in old key names. It keeps a hidden layout record and metadata folder in `base`. The migration lock stays in that folder, so only `base` needs write access. Stop all processes that use the store before moving it. Copies and backups must preserve hidden files and hard links. Use GNU `cp -a` and verify the copied layout record before opening the copy; see [Move an fs-lite store](https://vitehub.dev/docs/kv/configure#move-an-fs-lite-store). Ordinary `cp -R` breaks the layout identity and can make existing keys inaccessible.
77
+ `fs-lite` writes each key as one file in `base`. The file name starts with `key-`, followed by the key with `%` and `:` escaped as in a URL, so `signups` and `signups:reset-at` are the files `key-signups` and `key-signups%3Areset-at`. This prefix keeps application keys separate from migration metadata and temporary files. Most file systems limit a file name to 255 bytes, so an escaped key longer than 251 bytes fails with `KV_OPERATION_FAILED`. Earlier versions wrote `a:b` as the file `a/b`. The store moves those files to their new names when it opens the folder and preserves literal `%` characters in old key names. It keeps a hidden layout record and metadata folder in `base`. The file lock that guards the migration and the atomic operations stays in that folder, so only `base` needs write access. Stop all processes that use the store before moving it. Copies and backups must preserve hidden files and hard links. Use GNU `cp -a` and verify the copied layout record before opening the copy; see [Move an fs-lite store](https://vitehub.dev/docs/kv/configure#move-an-fs-lite-store). Ordinary `cp -R` breaks the layout identity and can make existing keys inaccessible.
76
78
 
77
79
  `kv.set(key, value, { ttl })` expires a value on every driver. `ttl` is a duration such as `"1h"`, or a number of seconds. Omitting `ttl` keeps the value until it is deleted or replaced. `ttl` is the only option; other options return `KV_INVALID_OPTION`. Cloudflare KV keeps a value at least 60 seconds. `fs-lite` keeps the expiry time of each key in its metadata folder and treats an expired key as missing. Initialization failures do not disable a store for the life of the process. The next operation can retry initialization.
78
80
 
@@ -104,13 +106,13 @@ Prefixes match text, and use the same key normalization as reads and writes. For
104
106
 
105
107
  Cursors are opaque and provider-specific. Pass a returned cursor back to the same store with the same prefix. Cloudflare KV, Upstash, Deno KV, and `fs-lite` stop enumeration when the requested page is full. Cloudflare KV and Deno KV cursors carry the provider cursor, so a request in another isolate can continue the listing. An `fs-lite` cursor retains a directory iterator in the current process for up to 15 minutes. Upstash uses the same retention window when the provider returns more keys than requested. These process-local cursors can expire sooner when more than 32 listings are left unfinished. Calling `disposeKVStores()` from the application shutdown hook releases these process-local cursors, closes retained directory iterators, and clears their expiry timers. A pending listing cannot retain a new cursor after disposal. Callers must restart listing without a cursor when continuation fails.
106
108
 
107
- KV operations return `[error, value]`. `error.code` is one of the codes of the method, for example `KV_INVALID_CURSOR` for `list()`, and `error.why`, `error.fix`, and `error.docs` explain it. Provider failures use the code `KV_OPERATION_FAILED` and keep the provider failure in `cause`. A Cloudflare KV store checks the [Workers KV limits](https://developers.cloudflare.com/kv/platform/limits/) before it calls the binding, in production and in `vite dev`: a key above 512 bytes returns `KV_KEY_TOO_LONG`, a value above 25 MiB returns `KV_VALUE_TOO_LARGE`, and a `ttl` below 60 seconds becomes 60 seconds. See [KV limits and errors](https://vitehub.dev/docs/kv/limits-and-errors). Configuration errors, for example an unknown named store, throw.
109
+ KV operations return `[error, value]`. `error.code` is one of the codes of the method, for example `KV_INVALID_CURSOR` for `list()`, and `error.why`, `error.fix`, and `error.docs` explain it. Provider failures use the code `KV_OPERATION_FAILED` and keep the provider failure in `cause`. A key that is empty or has a `.` or `..` segment, such as `a/../b`, returns `KV_INVALID_KEY` before any provider call. A Cloudflare KV store checks the [Workers KV limits](https://developers.cloudflare.com/kv/platform/limits/) before it calls the binding, in production and in `vite dev`: a key above 512 bytes returns `KV_KEY_TOO_LONG`, a value above 25 MiB returns `KV_VALUE_TOO_LARGE`, and a `ttl` below 60 seconds becomes 60 seconds. See [KV limits and errors](https://vitehub.dev/docs/kv/limits-and-errors). Configuration errors, for example an unknown named store, throw.
108
110
 
109
- `kv.getMany(keys)` reads many keys in one call and returns one value or `null` per key, in the order of `keys`. `kv.setMany([{ key, value }], options)` writes many keys; the last entry of a key wins, and it is not atomic. Redis uses `MGET` and one pipeline, the `database` driver one statement per 200 keys, Upstash `MGET`, and Cloudflare KV one bulk `get()` per 100 keys. Other reads and writes run one key at a time, 16 at once. Cloudflare KV checks every entry against the Workers KV limits before it writes any.
111
+ `kv.getMany(keys)` reads many keys in one call and returns one value or `null` per key, in the order of `keys`. `kv.setMany([{ key, value }], options)` writes many keys; the last entry of a key wins, and it is not atomic. Redis uses `MGET` and one pipeline, the `database` driver one statement per 200 keys (fewer on D1), Upstash `MGET`, and Cloudflare KV one bulk `get()` per 100 keys. Other reads and writes run one key at a time, 16 at once. Cloudflare KV checks every entry against the Workers KV limits before it writes any.
110
112
 
111
- `kv.setIfAbsent(key, value, { ttl })` writes the value only when the key has no value, in one atomic step. Its value is `true` for the one call that wrote it and `false` for the others. Use it for upload tickets, invite codes, and nonces instead of `get()` then `set()`, which two requests can race. Redis runs `SET NX` with `PX`, the `database` driver one `INSERT ... ON CONFLICT` that also replaces an expired key, and Upstash `SET NX`. Deno KV commits an atomic check that the key is missing; it deletes expired keys some time after the TTL. `fs-lite` creates the file exclusively, which is atomic on one disk, and expires keys with `ttl` on time. Cloudflare KV returns `KV_UNSUPPORTED_OPERATION`, because Workers KV is eventually consistent; use D1 or a Durable Object there.
113
+ `kv.setIfAbsent(key, value, { ttl })` writes the value only when the key has no value, in one atomic step. Its value is `true` for the one call that wrote it and `false` for the others. Use it for upload tickets, invite codes, and nonces instead of `get()` then `set()`, which two requests can race. Redis runs `SET NX` with `PX`, the `database` driver one `INSERT ... ON CONFLICT` that also replaces an expired key, and Upstash `SET NX`. Deno KV commits an atomic check that the key is missing; it deletes expired keys some time after the TTL. `fs-lite` creates the file exclusively, which is atomic on one disk, and expires keys with `ttl` on time. Cloudflare KV returns `KV_UNSUPPORTED_OPERATION`, because Workers KV is eventually consistent. On Cloudflare Workers, [add a store on a D1 binding](https://vitehub.dev/docs/kv/limits-and-errors#kv_unsupported_operation).
112
114
 
113
- `redis`, `database`, and Upstash also support `kv.getAndDelete(key)`, `kv.increment(key, ttl)`, and `kv.deleteIfEquals(key, expected)`. These operations are atomic in the provider. `deleteIfEquals()` deletes the key only when its stored text equals `expected` serialized as `set()` stores it, and returns `true` when this call deleted it. Deno KV, Cloudflare KV, and `fs-lite` return `KV_UNSUPPORTED_OPERATION` because they cannot provide the same contract without extra storage or non-atomic calls. The type `KVDriverAtomicOperations` lists the atomic operations of each driver, and `KVDriversWith<"deleteIfEquals">` the drivers of one operation.
115
+ `redis`, `database`, Upstash, and `fs-lite` also support `kv.getAndDelete(key)`, `kv.increment(key, ttl)`, and `kv.deleteIfEquals(key, expected)`. These operations are atomic in the provider. `fs-lite` runs each one under a file lock in its folder, so it is atomic for the processes of one host only: two hosts that mount the same folder over a network do not share the lock. `deleteIfEquals()` deletes the key only when its stored text equals `expected` serialized as `set()` stores it, and returns `true` when this call deleted it. Deno KV and Cloudflare KV return `KV_UNSUPPORTED_OPERATION` because they cannot provide the same contract without extra storage or non-atomic calls. The type `KVDriverAtomicOperations` lists the atomic operations of each driver, and `KVDriversWith<"deleteIfEquals">` the drivers of one operation.
114
116
 
115
117
  ## Locks
116
118
 
@@ -124,7 +126,7 @@ if (!result.acquired) return // Another runner holds the lock.
124
126
 
125
127
  `ttl` (a duration or seconds) is required, so a crashed runner never keeps the lock. `wait` (seconds) polls with backoff until the lock is free. Each lock writes a random owner token with `setIfAbsent()` and frees it with `deleteIfEquals()`, so a runner whose lock expired cannot delete the next runner's lock. `acquire()` returns a `release()` function for code that does not fit in one callback. KV does not renew a lock: when the work runs longer than `ttl`, another runner can take it.
126
128
 
127
- Only the drivers in `KVDriversWith<"deleteIfEquals">` (`redis`, `database`, `upstash`) support locks. Deno KV, Cloudflare KV, and `fs-lite` return `KV_UNSUPPORTED_OPERATION` without calling `fn`. App tests use `fs-lite`, so they return this code too.
129
+ Only the drivers in `KVDriversWith<"deleteIfEquals">` (`redis`, `database`, `upstash`, `fs-lite`) support locks. An `fs-lite` lock holds across the processes of one host only, so use it in development, app tests, and a single-server deployment. Deno KV and Cloudflare KV return `KV_UNSUPPORTED_OPERATION` without calling `fn`.
128
130
 
129
131
  ## Read-only handles
130
132
 
@@ -58,6 +58,7 @@ interface ProvisionStep {
58
58
  id: string;
59
59
  provider: ProvisionProvider;
60
60
  plan: (context: ProvisionContext) => Promise<ProvisionAction[]>;
61
+ hasResources?: (context: Pick<ProvisionContext, "env">) => boolean;
61
62
  /** Describes the Provision State this step records. Runs without network access, also without credentials. */
62
63
  recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
63
64
  }
@@ -74,10 +75,13 @@ interface ViteHubCliSpawnResult {
74
75
  signal?: NodeJS.Signals | null;
75
76
  /** The output of the child when `stdout` is `pipe`. */
76
77
  stdout?: string;
78
+ /** The error output of the child when `stderr` is `pipe`. */
79
+ stderr?: string;
77
80
  }
78
81
  interface ViteHubCliSpawnOptions {
79
82
  cwd?: string;
80
83
  env?: NodeJS.ProcessEnv;
84
+ onOutput?: (text: string, stream: "stdout" | "stderr") => void;
81
85
  stderr?: "inherit" | "pipe";
82
86
  /** `ignore` gives the child no terminal input, so a tool that asks questions on a terminal does not ask. */
83
87
  stdin?: "ignore" | "inherit";
@@ -85,7 +89,17 @@ interface ViteHubCliSpawnOptions {
85
89
  stdout?: "inherit" | "pipe" | "stderr";
86
90
  }
87
91
  type ViteHubCliSpawn = (command: string, args: string[], options?: ViteHubCliSpawnOptions) => Promise<ViteHubCliSpawnResult>;
92
+ /** Where a call to an app goes through the Console: the operation endpoint of the app's Console project, and the token of `vitehub login`. */
93
+ interface ViteHubCliConsoleRoute {
94
+ authorization: string;
95
+ target: string;
96
+ }
88
97
  interface ViteHubCliContext extends ViteHubCliStreams {
98
+ /**
99
+ * Finds the app at `url` in the Console of `vitehub login` and returns the route that lets the Console sign the call.
100
+ * Returns nothing when the command must call the app directly, such as when a `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` is set.
101
+ */
102
+ consoleRoute?: (url: string, signal: AbortSignal) => Promise<ViteHubCliConsoleRoute | undefined>;
89
103
  cwd: string;
90
104
  env: NodeJS.ProcessEnv;
91
105
  /** Replaces `fetch` for commands that call a running app, so tests need no server. */
@@ -104,6 +118,7 @@ interface ViteHubCliContext extends ViteHubCliStreams {
104
118
  spawn: ViteHubCliSpawn;
105
119
  }
106
120
  interface ViteHubCliProvision {
121
+ env?: NodeJS.ProcessEnv;
107
122
  rootDir: string;
108
123
  steps: readonly ProvisionStep[];
109
124
  }
package/dist/cli.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { i as ViteHubCliStreams, n as ViteHubCliContributor, t as ViteHubCliContext } from "./cli-BvVInMht.js";
2
- export type KVCliContext = Pick<ViteHubCliContext, "cwd" | "env" | "fetch" | "rootDir"> & ViteHubCliStreams;
1
+ import { i as ViteHubCliStreams, n as ViteHubCliContributor, t as ViteHubCliContext } from "./cli-C-uep33j.js";
2
+ export type KVCliContext = Pick<ViteHubCliContext, "consoleRoute" | "cwd" | "env" | "fetch" | "rootDir"> & ViteHubCliStreams;
3
3
  export interface KVCliOptions {
4
4
  /** Asks whether `delete` may delete a key. Defaults to a prompt on a terminal, and refuses without one. */
5
5
  confirm?: (question: string) => boolean | Promise<boolean>;
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
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-BkVt17cd.js";
1
+ import { D as listSeedFiles, E as askOnTerminal, N as writeCliFailure, O as parseCliPositiveInteger, j as readViteHubDevTargetOption, k as readCliOptionValue, n as callOperationFromCli } from "./operations-DP8iWjQK.js";
2
2
  import { t as isRecord } from "./object-CAK6UYR5.js";
3
- import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
3
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
4
4
  import { t as kvDevMaximumListLimit } from "./results-emgN7uDS.js";
5
5
  import { readFile } from "node:fs/promises";
6
6
  import { extname, join, relative, resolve } from "node:path";
@@ -390,6 +390,7 @@ async function runKVCommand(command, args, context, options) {
390
390
  if (command.value) input.value = value;
391
391
  const called = await callOperationFromCli({
392
392
  ...command.name === "delete" ? { confirmed: true } : {},
393
+ consoleRoute: context.consoleRoute,
393
394
  env: context.env,
394
395
  fetch: context.fetch ?? options.fetch ?? globalThis.fetch,
395
396
  rootDir: context.rootDir,
@@ -1,8 +1,8 @@
1
1
  import { t as invariant } from "./invariant-Dj2R1eMr.js";
2
2
  import { t as getActiveCloudflareBinding } from "./cloudflare-env-Cpy3Bqdn.js";
3
- import { n as normalizeKVListPrefix, t as createKVStorage } from "./create-storage-DbWVAY9l.js";
4
- import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
5
- import { n as recordCursor, t as createCursorHistory } from "./cursor-history-CMcEEnTO.js";
3
+ import { n as normalizeKVListPrefix, t as createKVStorage } from "./create-storage-DrhV0F4S.js";
4
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
5
+ import { n as recordCursor, t as createCursorHistory } from "./cursor-history-MzSrXXXX.js";
6
6
  import { i as setItemsOneByOne, t as chunks } from "./batch-D-ib5_0P.js";
7
7
  import createDriver from "unstorage/drivers/cloudflare-kv-binding";
8
8
  // src/runtime/cloudflare-kv-limits.ts
@@ -1,6 +1,6 @@
1
1
  import { t as getActiveCloudflareBinding } from "./cloudflare-env-Cpy3Bqdn.js";
2
- import { a as validateCloudflareKVBatch, i as installCloudflareKVLimits, r as assertCloudflareKVWrite, t as createCloudflareDriver } from "./cloudflare-kv-Cp8HPUlJ.js";
3
- import { t as createFsLiteKVDriver } from "./fs-lite-DzTTR6R3.js";
2
+ import { a as validateCloudflareKVBatch, i as installCloudflareKVLimits, r as assertCloudflareKVWrite, t as createCloudflareDriver } from "./cloudflare-kv-hMdZQZz1.js";
3
+ import { t as createFsLiteKVDriver } from "./fs-lite-1n_Dvy4p.js";
4
4
  import { i as setItemsOneByOne, n as getItemsOneByOne } from "./batch-D-ib5_0P.js";
5
5
  // src/runtime/cloudflare-kv-local.ts
6
6
  function cloudflareExpirationSeconds(options) {
@@ -1,6 +1,6 @@
1
1
  import { o as normalizeKey } from "./utils2-By8eee1x.js";
2
2
  import { t as isRecord } from "./object-CAK6UYR5.js";
3
- import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
3
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
4
4
  import { defu } from "defu";
5
5
  // ../internal/src/env.ts
6
6
  function trimmed(value) {
@@ -61,7 +61,7 @@ function cloudflareKVLocalBase(binding) {
61
61
  return `.vitehub/data/kv-cloudflare/${binding}`;
62
62
  }
63
63
  function readRemote(config, store) {
64
- const remote = Reflect.get(config, "remote");
64
+ const remote = config.remote;
65
65
  if (remote === void 0 || typeof remote === "boolean") return remote;
66
66
  throw kvErrorDiagnostics.KV_INVALID_REMOTE({ store });
67
67
  }
@@ -178,7 +178,7 @@ function assertKnownKVStoreKeys(store, driver, path) {
178
178
  "remote",
179
179
  ...driver ? kvDriverOptions[driver] : []
180
180
  ]);
181
- const key = Object.keys(store).find((name) => !known.has(name) && Reflect.get(store, name) !== void 0);
181
+ const key = Object.entries(store).find(([name, value]) => !known.has(name) && value !== void 0)?.[0];
182
182
  if (key === void 0) return;
183
183
  const drivers = Object.keys(kvDriverOptions).filter((name) => kvDriverOptions[name].includes(key));
184
184
  throw kvErrorDiagnostics.KV_UNKNOWN_STORE_OPTION({
@@ -208,7 +208,7 @@ function normalizeKVOptions(options, input = {}) {
208
208
  const hosting = normalizeHosting(input.hosting);
209
209
  const explicit = options;
210
210
  const hasOwnStores = options !== void 0 && Object.hasOwn(options, "stores");
211
- const stores = hasOwnStores ? Reflect.get(options, "stores", options) : void 0;
211
+ const stores = hasOwnStores && "stores" in options ? options.stores : void 0;
212
212
  if (hasOwnStores && !isRecord(stores)) throw kvErrorDiagnostics.KV_INVALID_CONFIG({ path: "kv.stores" });
213
213
  if (hasStoresConfig(options, stores)) {
214
214
  const extra = Object.entries(options ?? {}).find(([key, value]) => key !== "stores" && value !== void 0)?.[0];
@@ -1,5 +1,5 @@
1
1
  import { a as normalizeBaseKey, i as joinKeys, n as filterKeyByDepth, o as normalizeKey, r as hasDotSegment, t as filterKeyByBase } from "./utils2-By8eee1x.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
2
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
3
3
  import { r as mapWithLimit } from "./batch-D-ib5_0P.js";
4
4
  // ../../node_modules/.pnpm/unstorage@2.0.0-beta.0/node_modules/unstorage/dist/_chunks/libs/destr.mjs
5
5
  const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
@@ -1,5 +1,5 @@
1
1
  import { t as invariant } from "./invariant-Dj2R1eMr.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
2
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
3
3
  // src/runtime/cursor-history.ts
4
4
  const MAX_CURSOR_HISTORIES = 1024;
5
5
  const MAX_CURSORS_PER_HISTORY = 1024;
@@ -1,34 +1,77 @@
1
1
  import { t as logFailure } from "./request-log-DllKQXj7.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
2
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
3
3
  import { t as chunks } from "./batch-D-ib5_0P.js";
4
4
  // src/runtime/database.ts
5
5
  /** The table that keeps the keys of every `database` store. Each store has its rows under its own `namespace`. */
6
6
  const kvTable = "vitehub_kv";
7
+ const d1MaxParams = 100;
8
+ const postgresConnectionUrl = Symbol.for("vitehub.database.postgres.connection-url");
7
9
  function hasMethod(value, name) {
8
10
  if ((typeof value !== "object" || value === null) && typeof value !== "function") return false;
9
11
  return typeof Reflect.get(value, name) === "function";
10
12
  }
13
+ function isPostgresJsClient(value) {
14
+ return hasMethod(value, "unsafe");
15
+ }
16
+ function isD1Client(value) {
17
+ return hasMethod(value, "prepare") && hasMethod(value, "batch");
18
+ }
19
+ function isLibsqlClient(value) {
20
+ return hasMethod(value, "execute");
21
+ }
22
+ function isNodePostgresOrPgliteClient(value) {
23
+ return hasMethod(value, "query") && (hasMethod(value, "connect") || hasMethod(value, "exec") && hasMethod(value, "transaction"));
24
+ }
25
+ function sqlClient(value) {
26
+ if (isPostgresJsClient(value)) return {
27
+ kind: "postgres.js",
28
+ client: value
29
+ };
30
+ if (isD1Client(value)) return {
31
+ kind: "d1",
32
+ client: value
33
+ };
34
+ if (isLibsqlClient(value)) return {
35
+ kind: "libsql",
36
+ client: value
37
+ };
38
+ if (isNodePostgresOrPgliteClient(value)) return {
39
+ kind: "node-postgres-or-pglite",
40
+ client: value
41
+ };
42
+ }
43
+ async function runStatement(value, database, sql, params) {
44
+ const target = sqlClient(value);
45
+ switch (target?.kind) {
46
+ case "postgres.js": return await target.client.unsafe(sql, params);
47
+ case "d1": return (await target.client.prepare(sql).bind(...params).all()).results ?? [];
48
+ case "libsql": return (await target.client.execute({
49
+ sql,
50
+ args: params
51
+ })).rows;
52
+ case "node-postgres-or-pglite": return (await target.client.query(sql, params)).rows;
53
+ case void 0: throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
54
+ database,
55
+ problem: "unsupported"
56
+ });
57
+ }
58
+ }
11
59
  /**
12
- * A SQL client over the Drizzle database of the app. It reads `$client` on each query, because a Postgres Database on
13
- * Cloudflare has a client per request.
60
+ * A SQL client over the Drizzle database of the app: postgres.js, node-postgres, PGlite, libSQL, or a D1 binding. The
61
+ * Database adapters can expose these properties only on read. Read `$client` on each query because a Postgres Database
62
+ * on Cloudflare has a client per request.
14
63
  */
15
64
  function kvSqlClientFromDatabase(db, database) {
16
- const client = () => Reflect.get(db, "$client");
17
- const first = client();
18
- const dialect = hasMethod(first, "unsafe") ? "postgresql" : hasMethod(first, "execute") ? "sqlite" : void 0;
19
- if (!dialect) throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
65
+ const client = () => db.$client;
66
+ const kind = sqlClient(client())?.kind;
67
+ if (!kind) throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
20
68
  database,
21
69
  problem: "unsupported"
22
70
  });
23
71
  return {
24
- dialect,
25
- async query(sql, params) {
26
- if (dialect === "postgresql") return await client().unsafe(sql, params);
27
- return (await client().execute({
28
- sql,
29
- args: params
30
- })).rows;
31
- }
72
+ dialect: typeof db[postgresConnectionUrl] === "function" || kind === "postgres.js" || kind === "node-postgres-or-pglite" ? "postgresql" : "sqlite",
73
+ ...kind === "d1" ? { maxParams: d1MaxParams } : {},
74
+ query: (sql, params) => runStatement(client(), database, sql, params)
32
75
  };
33
76
  }
34
77
  const sweepIntervalMs = 6e4;
@@ -44,15 +87,15 @@ function decodeCursor(cursor) {
44
87
  if (!cursor) return void 0;
45
88
  try {
46
89
  const value = JSON.parse(decodeURIComponent(cursor));
47
- const after = typeof value === "object" && value !== null ? Reflect.get(value, "after") : void 0;
90
+ const after = typeof value === "object" && value !== null && "after" in value ? value.after : void 0;
48
91
  if (typeof after === "string") return after;
49
92
  } catch {}
50
93
  throw kvErrorDiagnostics.KV_INVALID_CURSOR({ problem: "invalid" });
51
94
  }
52
95
  /**
53
96
  * KV in a table of the app's Database. Each atomic operation is one statement, so two servers that write one key at
54
- * the same time get one winner. Expiry uses the clock of the Database. Works on Postgres and on SQLite 3.35 or later,
55
- * such as libSQL.
97
+ * the same time get one winner. Expiry uses the clock of the Database. Works on Postgres (postgres.js, node-postgres,
98
+ * and PGlite) and on SQLite 3.35 or later, such as libSQL.
56
99
  */
57
100
  function createDatabaseKVDriver(options, connect) {
58
101
  const table = kvTable;
@@ -133,7 +176,9 @@ function createDatabaseKVDriver(options, connect) {
133
176
  if (ttl !== void 0 && ttl !== null && ttl !== 0 && typeof ttl !== "number") throw kvErrorDiagnostics.KV_INVALID_TTL();
134
177
  const ms = typeof ttl === "number" && ttl !== 0 ? ttlMilliseconds(ttl) : void 0;
135
178
  const row = `(?, ?, ?, ${ms === void 0 ? "null" : "{now} + cast(? as bigint)"})`;
136
- for (const batch of chunks(items, batchRows)) await query(`insert into ${table} (namespace, "key", value, expires_at) values ${batch.map(() => row).join(", ")}
179
+ const { maxParams } = await ready();
180
+ const perRow = ms === void 0 ? 3 : 4;
181
+ for (const batch of chunks(items, maxParams === void 0 ? batchRows : Math.floor(maxParams / perRow))) await query(`insert into ${table} (namespace, "key", value, expires_at) values ${batch.map(() => row).join(", ")}
137
182
  on conflict (namespace, "key") do update set value = excluded.value, expires_at = excluded.expires_at`, batch.flatMap((item) => ms === void 0 ? [
138
183
  namespace,
139
184
  item.key,
@@ -157,7 +202,8 @@ function createDatabaseKVDriver(options, connect) {
157
202
  },
158
203
  async getItems(items) {
159
204
  const values = /* @__PURE__ */ new Map();
160
- for (const batch of chunks([...new Set(items.map((item) => item.key))], batchRows)) {
205
+ const { maxParams } = await ready();
206
+ for (const batch of chunks([...new Set(items.map((item) => item.key))], maxParams === void 0 ? batchRows : maxParams - 1)) {
161
207
  const rows = await query(`select "key", value from ${table} where namespace = ? and "key" in (${batch.map(() => "?").join(", ")}) and ${live}`, [namespace, ...batch]);
162
208
  for (const row of rows) values.set(String(row.key), String(row.value));
163
209
  }
@@ -1,6 +1,6 @@
1
1
  import { t as invariant } from "./invariant-Dj2R1eMr.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
3
- import { n as recordCursor, t as createCursorHistory } from "./cursor-history-CMcEEnTO.js";
2
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
3
+ import { n as recordCursor, t as createCursorHistory } from "./cursor-history-MzSrXXXX.js";
4
4
  // src/runtime/deno-kv.ts
5
5
  const MAX_DENO_KEY_BYTES = 2048;
6
6
  function getDenoRuntime() {
@@ -1,10 +1,10 @@
1
1
  import { i as TransactionOptions, t as Driver } from "./types-BUb0FcjM.js";
2
- import { T as KVPageOptions, _ as KVListPage } from "./types-CPDL9enF.js";
2
+ import { T as KVPageOptions, _ as KVListPage } from "./types-BLxnI_rU.js";
3
3
  type KVRuntimeDriver = Driver & Record<string, unknown> & {
4
4
  validateBatch?: (items: Parameters<NonNullable<Driver["setItems"]>>[0], removals: string[], options?: TransactionOptions) => void | Promise<void>;
5
5
  /** Deletes the key when it holds the serialized `expected` value. Resolves `true` when this call deleted it. */
6
6
  deleteIfEqualsItem?: (key: string, expected: string) => Promise<boolean>;
7
- getAndDeleteItem?: <T = unknown>(key: string) => Promise<T | null>;
7
+ getAndDeleteItem?: (key: string) => Promise<string | null>;
8
8
  incrementItem?: (key: string, ttl: number) => Promise<number>;
9
9
  listKeys: (options: KVPageOptions) => Promise<KVListPage>;
10
10
  /** Writes the serialized value only when the key is missing. Resolves `true` when this call wrote it. */
@@ -17,6 +17,11 @@ const kvErrorDiagnostics = /*#__PURE__*/ defineErrors({
17
17
  why: ({ problem }) => cursorProblems[problem],
18
18
  fix: "Pass the `cursor` of the previous page once, to the same store. If it fails, start again without `cursor`."
19
19
  },
20
+ KV_INVALID_KEY: {
21
+ why: ({ key }) => `The key ${JSON.stringify(key)} is empty, or has a "." or ".." segment. Both "/" and ":" separate segments.`,
22
+ fix: "Use a key with at least one segment and no `.` or `..` segment, such as `users:alice`. For request text, use `` `users:id-${encodeURIComponent(text)}` ``.",
23
+ status: 400
24
+ },
20
25
  KV_INVALID_LIMIT: {
21
26
  why: "`limit` must be a positive integer.",
22
27
  fix: "Pass a positive integer, for example `kv.list({ limit: 100 })`."
@@ -51,7 +56,7 @@ const kvErrorDiagnostics = /*#__PURE__*/ defineErrors({
51
56
  },
52
57
  KV_UNSUPPORTED_OPERATION: {
53
58
  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.`,
54
- 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."
59
+ fix: ({ operation }) => operation === "setIfAbsent" ? "On Cloudflare Workers, install `@vite-hub/database`, set `database: true`, and configure a native D1 binding in `server/databases/default.ts`. Add `claims: { driver: 'database' }` to `kv.stores` and call `kv.store('claims').setIfAbsent()`. A Durable Object also works. Elsewhere, 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, or `fs-lite` on one host. On Cloudflare Workers, install `@vite-hub/database`, set `database: true`, and configure a native D1 binding in `server/databases/default.ts`. Add `locks: { driver: 'database' }` to `kv.stores` and call `kv.store('locks').lock()`." : "Use the `redis`, `database`, or `upstash` driver for this store. For request budgets, use the Rate Limit primitive."
55
60
  },
56
61
  KV_INVALID_INPUT: {
57
62
  why: ({ limit, operation, problem }) => ({
@@ -73,8 +78,8 @@ const kvErrorDiagnostics = /*#__PURE__*/ defineErrors({
73
78
  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
79
  },
75
80
  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."
81
+ why: ({ database, problem }) => problem === "missing" ? `The KV \`database\` driver keeps keys in the Database "${database}", and the app has no Database with that name.` : problem === "driver" ? `The KV \`database\` driver keeps keys in the Database "${database}", which sets \`driver: "drizzle-postgres"\`. KV cannot query through Drizzle's own Postgres driver yet.` : `The KV \`database\` driver needs the Database "${database}" to use Postgres, libSQL, or a native D1 binding or session. D1 over HTTP is not supported.`,
82
+ fix: ({ problem }) => problem === "missing" ? "Add a Database Definition for this name, such as `server/databases/default.ts` for the default Database, or select another KV driver." : problem === "driver" ? "Remove `driver: \"drizzle-postgres\"` from the Database to use postgres.js, or select another KV driver." : "Point the Database at Postgres, libSQL, or a D1 binding, or select another KV driver."
78
83
  },
79
84
  KV_DENO_KV_UNAVAILABLE: {
80
85
  why: "The `deno-kv` driver needs `Deno.openKv()`, and this runtime does not have it.",
@@ -85,8 +90,8 @@ const kvErrorDiagnostics = /*#__PURE__*/ defineErrors({
85
90
  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."
86
91
  },
87
92
  KV_INVALID_CONFIG: {
88
- why: ({ path }) => `\`${path}\` must be a plain object.`,
89
- fix: "Pass an object, for example `kv: { driver: 'fs-lite' }`."
93
+ why: ({ path }) => path === "kv" ? "KV options must be a plain object or `false`. Only `vitehub()` accepts `kv: true`." : "`kv.stores` must be a plain object.",
94
+ fix: ({ path }) => path === "kv" ? "In `vitehub()`, set `kv: true` for the default store, `kv: { driver: 'redis' }` to choose a driver, or `kv: false` to turn KV off. Call `hubKV()` for the default store in a standalone app, pass a plain object to choose a driver, or pass `false` to turn KV off." : "Set `kv.stores` to an object of named stores, such as `kv: { stores: { default: { driver: 'redis' } } }`."
90
95
  },
91
96
  KV_INVALID_DRIVER: {
92
97
  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.`,
@@ -1,4 +1,5 @@
1
- import { n as kvErrorDiagnostics, t as kvConfigErrorCodes } from "./error-diagnostics-CuVl1nvE.js";
1
+ import { o as normalizeKey } from "./utils2-By8eee1x.js";
2
+ import { n as kvErrorDiagnostics, t as kvConfigErrorCodes } from "./error-diagnostics-DAi25E6F.js";
2
3
  import { isRuntimeDiagnostic, parseDuration, toResultError } from "@vite-hub/runtime";
3
4
  // src/runtime/ttl.ts
4
5
  /**
@@ -37,6 +38,18 @@ function kvClearOptionsError(options) {
37
38
  if (options === void 0) return;
38
39
  if (typeof options !== "object" || options === null || Array.isArray(options) || Object.keys(options).some((key) => key !== "prefix") || "prefix" in options && options.prefix !== void 0 && typeof options.prefix !== "string") return kvErrorDiagnostics.KV_INVALID_CLEAR_OPTIONS();
39
40
  }
41
+ /**
42
+ * `KV_INVALID_KEY` for the first string key that is empty or has a `.` or `..` segment, which every store rejects.
43
+ * A value that is not a list of keys passes, so the store reports its own batch error.
44
+ */
45
+ function kvInvalidKeyError(keys) {
46
+ if (!Array.isArray(keys)) return;
47
+ for (const key of keys) {
48
+ if (typeof key !== "string") continue;
49
+ const normalized = normalizeKey(key);
50
+ if (!normalized || normalized.split(":").some((segment) => segment === "." || segment === "..")) return kvErrorDiagnostics.KV_INVALID_KEY({ key });
51
+ }
52
+ }
40
53
  function hasCode(error, codes) {
41
54
  return codes.some((code) => code === error.code);
42
55
  }
@@ -119,4 +132,4 @@ function kvSetTTL(operation, options) {
119
132
  if (ttl === void 0) throw kvErrorDiagnostics.KV_INVALID_TTL();
120
133
  return ttl;
121
134
  }
122
- 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 };
135
+ export { kvListLimitInvalid as a, kvSetTTL as c, kvWriteLimitCodes as d, listKVKeys as f, kvKeyLimitCodes as i, kvStoreNotFoundError as l, ttlSeconds as m, kvInvalidKeyError as n, kvResult as o, kvStoreWithMode as p, kvInvalidLimitError as r, kvSetCodes as s, kvClearOptionsError as t, kvUnsupportedOperationError as u };
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
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-CPDL9enF.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-BLxnI_rU.js";
2
2
  import { Result, ResultError } from "@vite-hub/runtime";
3
3
  /**
4
4
  * Returns the handle that `kv.store(name, options)` gives. An unknown mode throws, so a typo never gives a writable handle.
@@ -6,6 +6,11 @@ import { Result, ResultError } from "@vite-hub/runtime";
6
6
  */
7
7
  export declare function kvStoreWithMode(storage: KVStorage, options: KVStoreOptions | undefined): KVStorage | ReadonlyKVStorage;
8
8
  export declare function kvClearOptionsError(options: unknown): ResultError<"KV_INVALID_CLEAR_OPTIONS"> | undefined;
9
+ /**
10
+ * `KV_INVALID_KEY` for the first string key that is empty or has a `.` or `..` segment, which every store rejects.
11
+ * A value that is not a list of keys passes, so the store reports its own batch error.
12
+ */
13
+ export declare function kvInvalidKeyError(keys: unknown): ResultError<"KV_INVALID_KEY"> | undefined;
9
14
  /**
10
15
  * Runs one KV operation and returns `[error, data]`.
11
16
  * A KV error with one of `codes` is returned with Runtime's public serializer. A config error is thrown.
package/dist/errors.js CHANGED
@@ -1 +1 @@
1
- export { t as kvClearOptionsError, n as kvInvalidLimitError, r as kvKeyLimitCodes, i as kvListLimitInvalid, a as kvResult, o as kvSetCodes, s as kvSetTTL, c as kvStoreNotFoundError, f as kvStoreWithMode, l as kvUnsupportedOperationError, u as kvWriteLimitCodes, d as listKVKeys } from "./errors-CJoAP4Bu.js";
1
+ export { t as kvClearOptionsError, n as kvInvalidKeyError, r as kvInvalidLimitError, i as kvKeyLimitCodes, a as kvListLimitInvalid, o as kvResult, s as kvSetCodes, c as kvSetTTL, l as kvStoreNotFoundError, p as kvStoreWithMode, u as kvUnsupportedOperationError, d as kvWriteLimitCodes, f as listKVKeys } from "./errors-kZRpu7Wa.js";