@vite-hub/kv 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{batch--v0ri69O.js → batch-D-ib5_0P.js} +0 -1
- package/dist/{cli-CLomw9ml.d.ts → cli-BvVInMht.d.ts} +0 -6
- package/dist/cli.d.ts +2 -4
- package/dist/cli.js +5 -6
- package/dist/{cloudflare-env-Dl349h_9.js → cloudflare-env-Cpy3Bqdn.js} +3 -5
- package/dist/{cloudflare-env-lookup-Bs0VDpU5.js → cloudflare-env-lookup-Dgq5n1Aq.js} +1 -2
- package/dist/{cloudflare-kv-DQJhmGof.js → cloudflare-kv-Cp8HPUlJ.js} +8 -10
- package/dist/{cloudflare-kv-local-COjgHweC.js → cloudflare-kv-local-COoOI34K.js} +5 -6
- package/dist/{config-pfyPiPrI.js → config-_1oBDv2R.js} +7 -11
- package/dist/{create-storage-DQ1BbFqH.js → create-storage-DbWVAY9l.js} +9 -15
- package/dist/{cursor-history-CAT4mpP1.js → cursor-history-CMcEEnTO.js} +3 -4
- package/dist/{runtime/database.js → database-4iAg2GoV.js} +25 -52
- package/dist/{deno-kv-Cf0ZveeN.js → deno-kv-CatE7zSS.js} +4 -5
- package/dist/{dev-peer-CHafxbtj.js → dev-peer-D0vOxmrD.js} +1 -2
- package/dist/driver-BruahGvT.d.ts +13 -0
- package/dist/durability.d.ts +1 -3
- package/dist/durability.js +1 -2
- package/dist/{error-diagnostics-C4VTHInS.js → error-diagnostics-CuVl1nvE.js} +3 -4
- package/dist/{errors-BpiM-Vmh.js → errors-CJoAP4Bu.js} +4 -7
- package/dist/errors.d.ts +2 -6
- package/dist/errors.js +1 -2
- package/dist/fs-lite-DwbPkc-C.js +1 -0
- package/dist/{fs-lite-BTcBUP6B.js → fs-lite-DzTTR6R3.js} +3 -5
- package/dist/index.d.ts +1 -3
- package/dist/index.js +17 -21
- package/dist/{inspect-BIKQsqX4.js → inspect-BWMcVWD8.js} +2 -4
- package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/{operation-definition-CI2PJGqu.d.ts → operation-definition-CqZkx1Rm.d.ts} +0 -4
- package/dist/{operations-nAaONxzh.js → operations-BkVt17cd.js} +24 -25
- package/dist/{operations-CqKs7Ykc.js → operations-DSOTGwST.js} +7 -10
- package/dist/operations.d.ts +2 -8
- package/dist/operations.js +8 -12
- package/dist/{out-BbXG-yVX.js → out-By90R-Bo.js} +3345 -2394
- package/dist/{redis-shared-1M0IaguQ.js → redis-shared-CR3ANc_N.js} +2 -3
- package/dist/{request-log-Dj9Vw7qG.js → request-log-DllKQXj7.js} +1 -2
- package/dist/{results-D6jfPtCk.js → results-emgN7uDS.js} +1 -2
- package/dist/{rolldown-runtime-CMFfr-1z.js → rolldown-runtime-DegdyBIC.js} +2 -3
- package/dist/runtime/cloudflare-kv.d.ts +1 -3
- package/dist/runtime/cloudflare-kv.js +1 -2
- package/dist/runtime/cloudflare-request-env.d.ts +1 -3
- package/dist/runtime/cloudflare-request-env.js +2 -3
- package/dist/runtime/nitro-plugin.d.ts +1 -2
- package/dist/runtime/nitro-plugin.js +3 -4
- package/dist/runtime/redis-driver.d.ts +3 -5
- package/dist/runtime/redis-driver.js +6 -7
- package/dist/runtime/unstorage-driver.d.ts +2 -4
- package/dist/runtime/unstorage-driver.js +2 -3
- package/dist/runtime/upstash-driver.d.ts +3 -5
- package/dist/runtime/upstash-driver.js +6 -7
- package/dist/{types-Bj3EQoRg.d.ts → types-BUb0FcjM.d.ts} +0 -2
- package/dist/{types-Cp6IBhSN.d.ts → types-CPDL9enF.d.ts} +2 -4
- package/dist/{upstash-5sTbIR35.js → upstash-DeM3_U5H.js} +3 -4
- package/dist/{utils2-FozcTsmb.js → utils2-By8eee1x.js} +1 -2
- package/dist/vite.d.ts +3 -17
- package/dist/vite.js +1444 -923
- package/package.json +10 -15
- package/dist/driver-Du6Eh9p2.d.ts +0 -47
- package/dist/fs-lite-C8yXCVDM.js +0 -2
- package/dist/runtime/database.d.ts +0 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
pnpm add @vite-hub/kv
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Add `@upstash/redis` when you use the Upstash driver. The `redis` driver uses `ioredis`, which KV installs.
|
|
18
|
+
Add `@upstash/redis` when you use the Upstash driver. The `redis` driver uses `ioredis`, which KV installs, and needs Redis 6 or later.
|
|
19
19
|
|
|
20
20
|
## Minimal API
|
|
21
21
|
|
|
@@ -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
|
|
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.
|
|
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
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "nostics";
|
|
2
|
-
//#region ../internal/src/host-credentials.d.ts
|
|
3
2
|
interface HostCliRunResult {
|
|
4
3
|
exitCode: number | null;
|
|
5
4
|
stdout: string;
|
|
@@ -11,8 +10,6 @@ type HostCliRun = (command: string, args: readonly string[], options: {
|
|
|
11
10
|
env: NodeJS.ProcessEnv;
|
|
12
11
|
signal?: AbortSignal;
|
|
13
12
|
}) => Promise<HostCliRunResult>;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region ../internal/src/provision.d.ts
|
|
16
13
|
type ProvisionProvider = "cloudflare" | "vercel";
|
|
17
14
|
interface ProvisionLogger {
|
|
18
15
|
log: (message: string) => void;
|
|
@@ -64,8 +61,6 @@ interface ProvisionStep {
|
|
|
64
61
|
/** Describes the Provision State this step records. Runs without network access, also without credentials. */
|
|
65
62
|
recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
|
|
66
63
|
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region ../internal/src/cli.d.ts
|
|
69
64
|
interface ViteHubCliStreams {
|
|
70
65
|
stderr: {
|
|
71
66
|
write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown;
|
|
@@ -160,5 +155,4 @@ interface ViteHubCliPluginMetadata {
|
|
|
160
155
|
cli?: ViteHubCliContributor | ViteHubCliContributorFactory;
|
|
161
156
|
}
|
|
162
157
|
type StdoutWriteCallback = (error?: Error | null) => void;
|
|
163
|
-
//#endregion
|
|
164
158
|
export { ViteHubCliStreams as i, ViteHubCliContributor as n, ViteHubCliPluginMetadata as r, ViteHubCliContext as t };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { i as ViteHubCliStreams, n as ViteHubCliContributor, t as ViteHubCliContext } from "./cli-
|
|
2
|
-
//#region src/cli.d.ts
|
|
1
|
+
import { i as ViteHubCliStreams, n as ViteHubCliContributor, t as ViteHubCliContext } from "./cli-BvVInMht.js";
|
|
3
2
|
export type KVCliContext = Pick<ViteHubCliContext, "cwd" | "env" | "fetch" | "rootDir"> & ViteHubCliStreams;
|
|
4
3
|
export interface KVCliOptions {
|
|
5
4
|
/** Asks whether `delete` may delete a key. Defaults to a prompt on a terminal, and refuses without one. */
|
|
@@ -13,5 +12,4 @@ export interface KVCliOptions {
|
|
|
13
12
|
* `args[0]` is the command name, for example `list` or `set`.
|
|
14
13
|
*/
|
|
15
14
|
export declare function runKVCli(args: string[], context: KVCliContext, options?: KVCliOptions): Promise<number>;
|
|
16
|
-
export declare function createKVCliContributor(options?: KVCliOptions): ViteHubCliContributor;
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare function createKVCliContributor(options?: KVCliOptions): ViteHubCliContributor;
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
2
|
-
import { t as isRecord } from "./object-
|
|
3
|
-
import { n as kvErrorDiagnostics } from "./error-diagnostics-
|
|
4
|
-
import { t as kvDevMaximumListLimit } from "./results-
|
|
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";
|
|
2
|
+
import { t as isRecord } from "./object-CAK6UYR5.js";
|
|
3
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
|
|
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";
|
|
7
7
|
import * as v from "valibot";
|
|
8
|
-
|
|
8
|
+
// src/cli.ts
|
|
9
9
|
const usageError = (problem) => kvErrorDiagnostics.KV_CLI_USAGE({ problem });
|
|
10
10
|
const kvDevTargetErrors = {
|
|
11
11
|
invalidInlineTimeout: usageError,
|
|
@@ -477,5 +477,4 @@ function createKVCliContributor(options = {}) {
|
|
|
477
477
|
}]
|
|
478
478
|
};
|
|
479
479
|
}
|
|
480
|
-
//#endregion
|
|
481
480
|
export { createKVCliContributor, runKVCli };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { i as setInstalledCloudflareEnv, n as getActiveCloudflareEnv, r as getCloudflareEnv, t as activeEnvStorageKey } from "./cloudflare-env-lookup-
|
|
1
|
+
import { i as setInstalledCloudflareEnv, n as getActiveCloudflareEnv, r as getCloudflareEnv, t as activeEnvStorageKey } from "./cloudflare-env-lookup-Dgq5n1Aq.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
-
|
|
4
|
-
const d1PrimaryClient = Symbol.for("vitehub.database.d1-primary-client");
|
|
3
|
+
// ../internal/src/runtime/cloudflare-env.ts
|
|
5
4
|
const runtimeGlobal = globalThis;
|
|
6
5
|
const activeEnvStorage = runtimeGlobal[activeEnvStorageKey] ||= new AsyncLocalStorage();
|
|
7
6
|
const globalEnvProbe = Symbol("vitehub.cloudflare.global-env-probe");
|
|
@@ -43,5 +42,4 @@ function installCloudflareRequestEnv(event, fallback) {
|
|
|
43
42
|
const env = getCloudflareEnv(event, { fallback: false }) ?? fallback;
|
|
44
43
|
if (env) setActiveCloudflareEnv(env);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
export { getActiveCloudflareBinding as n, installCloudflareRequestEnv as r, d1PrimaryClient as t };
|
|
45
|
+
export { installCloudflareRequestEnv as n, getActiveCloudflareBinding as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../internal/src/runtime/cloudflare-env-lookup.ts
|
|
2
2
|
/** The key of the AsyncLocalStorage store on `globalThis`. Every bundled copy of this module shares the store. */
|
|
3
3
|
const activeEnvStorageKey = Symbol.for("vitehub.cloudflare.env-storage");
|
|
4
4
|
let activeEnv;
|
|
@@ -38,5 +38,4 @@ function getCloudflareEnv(event, options = {}) {
|
|
|
38
38
|
for (const candidate of [ownValue(target, "env"), ...cloudflareOwners(target).map((owner) => ownValue(owner, "env"))]) if (candidate) return candidate;
|
|
39
39
|
return options.fallback === false ? void 0 : getActiveCloudflareEnv();
|
|
40
40
|
}
|
|
41
|
-
//#endregion
|
|
42
41
|
export { setInstalledCloudflareEnv as i, getActiveCloudflareEnv as n, getCloudflareEnv as r, activeEnvStorageKey as t };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as invariant } from "./invariant-
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
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";
|
|
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
|
|
9
9
|
const cloudflareKVLimits = {
|
|
10
10
|
keyBytes: 512,
|
|
11
11
|
minExpirationTtl: 60,
|
|
@@ -62,8 +62,7 @@ function validateCloudflareKVBatch(items, removals) {
|
|
|
62
62
|
for (const key of removals) assertCloudflareKVKey(key);
|
|
63
63
|
for (const item of items) assertCloudflareKVWrite(item.key, item.value);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
//#region src/runtime/cloudflare-kv.ts
|
|
65
|
+
// src/runtime/cloudflare-kv.ts
|
|
67
66
|
function isCloudflareKVString(value) {
|
|
68
67
|
return typeof value === "string";
|
|
69
68
|
}
|
|
@@ -195,5 +194,4 @@ function createCloudflareKVStorage(options) {
|
|
|
195
194
|
});
|
|
196
195
|
return storage;
|
|
197
196
|
}
|
|
198
|
-
//#endregion
|
|
199
197
|
export { validateCloudflareKVBatch as a, installCloudflareKVLimits as i, createCloudflareKVStorage as n, assertCloudflareKVWrite as r, createCloudflareDriver as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
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";
|
|
4
|
+
import { i as setItemsOneByOne, n as getItemsOneByOne } from "./batch-D-ib5_0P.js";
|
|
5
|
+
// src/runtime/cloudflare-kv-local.ts
|
|
6
6
|
function cloudflareExpirationSeconds(options) {
|
|
7
7
|
if (!options || typeof options !== "object") return;
|
|
8
8
|
const ttl = Reflect.get(options, "ttl");
|
|
@@ -63,5 +63,4 @@ function createCloudflareKVLocalDriver(store) {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
//#endregion
|
|
67
66
|
export { createCloudflareKVLocalDriver as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { o as normalizeKey } from "./utils2-By8eee1x.js";
|
|
2
|
+
import { t as isRecord } from "./object-CAK6UYR5.js";
|
|
3
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
|
|
4
4
|
import { defu } from "defu";
|
|
5
|
-
|
|
5
|
+
// ../internal/src/env.ts
|
|
6
6
|
function trimmed(value) {
|
|
7
7
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
8
8
|
}
|
|
@@ -12,8 +12,7 @@ function readEnv(env, ...names) {
|
|
|
12
12
|
if (value) return value;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
//#region ../internal/src/hosting.ts
|
|
15
|
+
// ../internal/src/hosting.ts
|
|
17
16
|
/**
|
|
18
17
|
* Returns the Nitro preset name that this build targets, as the developer wrote it.
|
|
19
18
|
* The order is `nitro.preset`, `hosting`, `NITRO_PRESET`, `SERVER_PRESET`, then `VITEHUB_HOST`.
|
|
@@ -35,8 +34,7 @@ function normalizeHosting(hosting) {
|
|
|
35
34
|
if (normalized === "cloudflare") return "cloudflare-module";
|
|
36
35
|
return normalized;
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
//#region src/integrations/upstash.ts
|
|
37
|
+
// src/integrations/upstash.ts
|
|
40
38
|
const maskedUpstashRuntimeValue = "********";
|
|
41
39
|
/** Vercel names first, then the names that the Upstash console and NuxtHub use. */
|
|
42
40
|
const upstashUrlEnvNames = ["KV_REST_API_URL", "UPSTASH_REDIS_REST_URL"];
|
|
@@ -55,8 +53,7 @@ function resolveUpstashStore(config, base) {
|
|
|
55
53
|
url: trimmed(config.url) ?? maskedUpstashRuntimeValue
|
|
56
54
|
};
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
//#region src/config.ts
|
|
56
|
+
// src/config.ts
|
|
60
57
|
/** The variable that a `redis` store reads at runtime when it sets no `url`. */
|
|
61
58
|
const redisUrlEnvName = "REDIS_URL";
|
|
62
59
|
/** Where a Cloudflare KV store keeps its keys in `vite dev` when the runtime has no binding. */
|
|
@@ -283,5 +280,4 @@ function kvRedisEnvHint(options, input = {}) {
|
|
|
283
280
|
store: selected
|
|
284
281
|
});
|
|
285
282
|
}
|
|
286
|
-
//#endregion
|
|
287
283
|
export { upstashUrlEnvNames as a, upstashTokenEnvNames as i, kvRedisEnvHint as n, resolveHostPreset as o, normalizeKVOptions as r, readEnv as s, kvInferredStoreNotice as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import { r as mapWithLimit } from "./batch
|
|
4
|
-
|
|
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";
|
|
3
|
+
import { r as mapWithLimit } from "./batch-D-ib5_0P.js";
|
|
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*:/;
|
|
6
6
|
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
7
7
|
const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
@@ -43,8 +43,7 @@ function destr(value, options = {}) {
|
|
|
43
43
|
return value;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
//#region ../../node_modules/.pnpm/unstorage@2.0.0-beta.0/node_modules/unstorage/dist/drivers/memory.mjs
|
|
46
|
+
// ../../node_modules/.pnpm/unstorage@2.0.0-beta.0/node_modules/unstorage/dist/drivers/memory.mjs
|
|
48
47
|
const DRIVER_NAME = "memory";
|
|
49
48
|
const driver = () => {
|
|
50
49
|
const data = /* @__PURE__ */ new Map();
|
|
@@ -117,8 +116,7 @@ function _scheduleExpiry(data, timers, key, ttl) {
|
|
|
117
116
|
};
|
|
118
117
|
schedule();
|
|
119
118
|
}
|
|
120
|
-
|
|
121
|
-
//#region ../../node_modules/.pnpm/unstorage@2.0.0-beta.0/node_modules/unstorage/dist/_chunks/_utils.mjs
|
|
119
|
+
// ../../node_modules/.pnpm/unstorage@2.0.0-beta.0/node_modules/unstorage/dist/_chunks/_utils.mjs
|
|
122
120
|
function wrapToPromise(value) {
|
|
123
121
|
if (!value || typeof value.then !== "function") return Promise.resolve(value);
|
|
124
122
|
return value;
|
|
@@ -220,8 +218,7 @@ function concatBytes(chunks) {
|
|
|
220
218
|
function typeName(value) {
|
|
221
219
|
return value?.constructor?.name || typeof value;
|
|
222
220
|
}
|
|
223
|
-
|
|
224
|
-
//#region ../../node_modules/.pnpm/unstorage@2.0.0-beta.0/node_modules/unstorage/dist/index.mjs
|
|
221
|
+
// ../../node_modules/.pnpm/unstorage@2.0.0-beta.0/node_modules/unstorage/dist/index.mjs
|
|
225
222
|
function isRawType$1(type) {
|
|
226
223
|
return type === "bytes" || type === "blob" || type === "stream";
|
|
227
224
|
}
|
|
@@ -534,15 +531,13 @@ function watch(driver, onChange, base) {
|
|
|
534
531
|
async function dispose(driver) {
|
|
535
532
|
if (typeof driver.dispose === "function") await asyncCall(driver.dispose);
|
|
536
533
|
}
|
|
537
|
-
|
|
538
|
-
//#region src/runtime/list-prefix.ts
|
|
534
|
+
// src/runtime/list-prefix.ts
|
|
539
535
|
function normalizeKVListPrefix(prefix = "") {
|
|
540
536
|
const normalized = normalizeKey(prefix);
|
|
541
537
|
const path = prefix.split("?")[0] ?? "";
|
|
542
538
|
return normalized && /[:/\\]$/.test(path) ? `${normalized}:` : normalized;
|
|
543
539
|
}
|
|
544
|
-
|
|
545
|
-
//#region src/runtime/create-storage.ts
|
|
540
|
+
// src/runtime/create-storage.ts
|
|
546
541
|
function isRawType(type) {
|
|
547
542
|
return type === "bytes" || type === "blob" || type === "stream";
|
|
548
543
|
}
|
|
@@ -594,5 +589,4 @@ function createKVStorage(driver) {
|
|
|
594
589
|
}
|
|
595
590
|
});
|
|
596
591
|
}
|
|
597
|
-
//#endregion
|
|
598
592
|
export { normalizeKVListPrefix as n, createKVStorage as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as invariant } from "./invariant-
|
|
2
|
-
import { n as kvErrorDiagnostics } from "./error-diagnostics-
|
|
3
|
-
|
|
1
|
+
import { t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
2
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
|
|
3
|
+
// src/runtime/cursor-history.ts
|
|
4
4
|
const MAX_CURSOR_HISTORIES = 1024;
|
|
5
5
|
const MAX_CURSORS_PER_HISTORY = 1024;
|
|
6
6
|
const MAX_CURSOR_LENGTH = 8192;
|
|
@@ -165,5 +165,4 @@ function recordCursor(history, cursor) {
|
|
|
165
165
|
history.add(cursor);
|
|
166
166
|
return true;
|
|
167
167
|
}
|
|
168
|
-
//#endregion
|
|
169
168
|
export { recordCursor as n, createCursorHistory as t };
|
|
@@ -1,57 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as chunks } from "
|
|
4
|
-
|
|
5
|
-
//#region src/runtime/database.ts
|
|
1
|
+
import { t as logFailure } from "./request-log-DllKQXj7.js";
|
|
2
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
|
|
3
|
+
import { t as chunks } from "./batch-D-ib5_0P.js";
|
|
4
|
+
// src/runtime/database.ts
|
|
6
5
|
/** The table that keeps the keys of every `database` store. Each store has its rows under its own `namespace`. */
|
|
7
6
|
const kvTable = "vitehub_kv";
|
|
8
|
-
function isD1HttpClient(value) {
|
|
9
|
-
return typeof value === "object" && value !== null && Reflect.get(value, "protocol") === "d1-http" && hasMethod(value, "query");
|
|
10
|
-
}
|
|
11
|
-
function isRow(value) {
|
|
12
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
-
}
|
|
14
|
-
function objectRows(rows) {
|
|
15
|
-
if (rows.every(isRow)) return rows;
|
|
16
|
-
throw kvErrorDiagnostics.KV_PROVIDER_INVALID_RESPONSE({ problem: "Cloudflare D1 returned rows without column names." });
|
|
17
|
-
}
|
|
18
|
-
const d1MaxParameters = 100;
|
|
19
7
|
function hasMethod(value, name) {
|
|
20
8
|
if ((typeof value !== "object" || value === null) && typeof value !== "function") return false;
|
|
21
9
|
return typeof Reflect.get(value, name) === "function";
|
|
22
10
|
}
|
|
23
11
|
/**
|
|
24
|
-
* A SQL client over the Drizzle database of the app
|
|
25
|
-
*
|
|
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.
|
|
26
14
|
*/
|
|
27
15
|
function kvSqlClientFromDatabase(db, database) {
|
|
28
|
-
const client = () => Reflect.get(db,
|
|
16
|
+
const client = () => Reflect.get(db, "$client");
|
|
29
17
|
const first = client();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
query: async (sql, params) => await client().unsafe(sql, params)
|
|
33
|
-
};
|
|
34
|
-
if (hasMethod(first, "execute")) return {
|
|
35
|
-
dialect: "sqlite",
|
|
36
|
-
query: async (sql, params) => (await client().execute({
|
|
37
|
-
sql,
|
|
38
|
-
args: params
|
|
39
|
-
})).rows
|
|
40
|
-
};
|
|
41
|
-
if (hasMethod(first, "prepare") && hasMethod(first, "batch")) return {
|
|
42
|
-
dialect: "sqlite",
|
|
43
|
-
maxParameters: d1MaxParameters,
|
|
44
|
-
query: async (sql, params) => (await client().prepare(sql).bind(...params).all()).results
|
|
45
|
-
};
|
|
46
|
-
if (isD1HttpClient(first)) return {
|
|
47
|
-
dialect: "sqlite",
|
|
48
|
-
maxParameters: d1MaxParameters,
|
|
49
|
-
query: async (sql, params) => objectRows(await client().query(sql, params, "write"))
|
|
50
|
-
};
|
|
51
|
-
throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
|
|
18
|
+
const dialect = hasMethod(first, "unsafe") ? "postgresql" : hasMethod(first, "execute") ? "sqlite" : void 0;
|
|
19
|
+
if (!dialect) throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
|
|
52
20
|
database,
|
|
53
21
|
problem: "unsupported"
|
|
54
22
|
});
|
|
23
|
+
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
|
+
}
|
|
32
|
+
};
|
|
55
33
|
}
|
|
56
34
|
const sweepIntervalMs = 6e4;
|
|
57
35
|
const sweepBatchSize = 1e3;
|
|
@@ -74,10 +52,10 @@ function decodeCursor(cursor) {
|
|
|
74
52
|
/**
|
|
75
53
|
* KV in a table of the app's Database. Each atomic operation is one statement, so two servers that write one key at
|
|
76
54
|
* the same time get one winner. Expiry uses the clock of the Database. Works on Postgres and on SQLite 3.35 or later,
|
|
77
|
-
* such as libSQL
|
|
78
|
-
* out of reach of every KV store.
|
|
55
|
+
* such as libSQL.
|
|
79
56
|
*/
|
|
80
|
-
function createDatabaseKVDriver(options, connect
|
|
57
|
+
function createDatabaseKVDriver(options, connect) {
|
|
58
|
+
const table = kvTable;
|
|
81
59
|
const namespace = options.namespace;
|
|
82
60
|
let pending;
|
|
83
61
|
let sweptAt = 0;
|
|
@@ -149,17 +127,13 @@ function createDatabaseKVDriver(options, connect, table = kvTable) {
|
|
|
149
127
|
const [filter, params] = prefixFilter(prefix);
|
|
150
128
|
return (await query(`select "key" from ${table} where namespace = ? and ${live}${filter} order by "key"`, [namespace, ...params])).map((row) => String(row.key));
|
|
151
129
|
}
|
|
152
|
-
async function rowsPerStatement(parametersPerRow, fixedParameters = 0) {
|
|
153
|
-
const { maxParameters } = await ready();
|
|
154
|
-
return maxParameters === void 0 ? batchRows : Math.min(batchRows, Math.floor((maxParameters - fixedParameters) / parametersPerRow));
|
|
155
|
-
}
|
|
156
130
|
async function upsert(items, setOptions) {
|
|
157
131
|
sweep();
|
|
158
132
|
const ttl = setOptions?.ttl;
|
|
159
133
|
if (ttl !== void 0 && ttl !== null && ttl !== 0 && typeof ttl !== "number") throw kvErrorDiagnostics.KV_INVALID_TTL();
|
|
160
134
|
const ms = typeof ttl === "number" && ttl !== 0 ? ttlMilliseconds(ttl) : void 0;
|
|
161
135
|
const row = `(?, ?, ?, ${ms === void 0 ? "null" : "{now} + cast(? as bigint)"})`;
|
|
162
|
-
for (const batch of chunks(items,
|
|
136
|
+
for (const batch of chunks(items, batchRows)) await query(`insert into ${table} (namespace, "key", value, expires_at) values ${batch.map(() => row).join(", ")}
|
|
163
137
|
on conflict (namespace, "key") do update set value = excluded.value, expires_at = excluded.expires_at`, batch.flatMap((item) => ms === void 0 ? [
|
|
164
138
|
namespace,
|
|
165
139
|
item.key,
|
|
@@ -183,7 +157,7 @@ function createDatabaseKVDriver(options, connect, table = kvTable) {
|
|
|
183
157
|
},
|
|
184
158
|
async getItems(items) {
|
|
185
159
|
const values = /* @__PURE__ */ new Map();
|
|
186
|
-
for (const batch of chunks([...new Set(items.map((item) => item.key))],
|
|
160
|
+
for (const batch of chunks([...new Set(items.map((item) => item.key))], batchRows)) {
|
|
187
161
|
const rows = await query(`select "key", value from ${table} where namespace = ? and "key" in (${batch.map(() => "?").join(", ")}) and ${live}`, [namespace, ...batch]);
|
|
188
162
|
for (const row of rows) values.set(String(row.key), String(row.value));
|
|
189
163
|
}
|
|
@@ -277,5 +251,4 @@ function createDatabaseKVDriver(options, connect, table = kvTable) {
|
|
|
277
251
|
}
|
|
278
252
|
};
|
|
279
253
|
}
|
|
280
|
-
|
|
281
|
-
export { createDatabaseKVDriver as default, kvSqlClientFromDatabase, kvTable };
|
|
254
|
+
export { createDatabaseKVDriver as default, kvSqlClientFromDatabase };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as invariant } from "./invariant-
|
|
2
|
-
import { n as kvErrorDiagnostics } from "./error-diagnostics-
|
|
3
|
-
import { n as recordCursor, t as createCursorHistory } from "./cursor-history-
|
|
4
|
-
|
|
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";
|
|
4
|
+
// src/runtime/deno-kv.ts
|
|
5
5
|
const MAX_DENO_KEY_BYTES = 2048;
|
|
6
6
|
function getDenoRuntime() {
|
|
7
7
|
return globalThis.Deno;
|
|
@@ -160,5 +160,4 @@ function createDenoKVDriver(options = { driver: "deno-kv" }) {
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
-
//#endregion
|
|
164
163
|
export { createDenoKVDriver as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../internal/src/dev-peer.ts
|
|
2
2
|
/**
|
|
3
3
|
* Proof that a development request came from this machine, for dev servers that run the app behind a proxy.
|
|
4
4
|
*
|
|
@@ -234,5 +234,4 @@ function addViteHubDevPeerDevHandler(devHandlers) {
|
|
|
234
234
|
devHandlers.unshift({ handler: devHandler });
|
|
235
235
|
}
|
|
236
236
|
readViteHubDevPeerKey();
|
|
237
|
-
//#endregion
|
|
238
237
|
export { isViteHubLoopbackPeer as n, addViteHubDevPeerDevHandler as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { i as TransactionOptions, t as Driver } from "./types-BUb0FcjM.js";
|
|
2
|
+
import { T as KVPageOptions, _ as KVListPage } from "./types-CPDL9enF.js";
|
|
3
|
+
type KVRuntimeDriver = Driver & Record<string, unknown> & {
|
|
4
|
+
validateBatch?: (items: Parameters<NonNullable<Driver["setItems"]>>[0], removals: string[], options?: TransactionOptions) => void | Promise<void>;
|
|
5
|
+
/** Deletes the key when it holds the serialized `expected` value. Resolves `true` when this call deleted it. */
|
|
6
|
+
deleteIfEqualsItem?: (key: string, expected: string) => Promise<boolean>;
|
|
7
|
+
getAndDeleteItem?: <T = unknown>(key: string) => Promise<T | null>;
|
|
8
|
+
incrementItem?: (key: string, ttl: number) => Promise<number>;
|
|
9
|
+
listKeys: (options: KVPageOptions) => Promise<KVListPage>;
|
|
10
|
+
/** Writes the serialized value only when the key is missing. Resolves `true` when this call wrote it. */
|
|
11
|
+
setIfAbsentItem?: (key: string, value: string, ttl?: number) => Promise<boolean>;
|
|
12
|
+
};
|
|
13
|
+
export { KVRuntimeDriver as t };
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Durability, DurabilityContext } from "@vite-hub/runtime/durability";
|
|
2
|
-
//#region src/durability.d.ts
|
|
3
2
|
/** One KV store as the build resolves it, without credentials. */
|
|
4
3
|
export interface KVDurabilityStore {
|
|
5
4
|
/** The folder of a file store. */
|
|
@@ -13,5 +12,4 @@ export interface KVDurabilityInput {
|
|
|
13
12
|
stores: Record<string, KVDurabilityStore>;
|
|
14
13
|
}
|
|
15
14
|
/** The durability of each KV store, from its driver. A `database` store follows the Database that holds its rows. */
|
|
16
|
-
export declare function kvDurability(input: KVDurabilityInput, context: DurabilityContext): Durability[];
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare function kvDurability(input: KVDurabilityInput, context: DurabilityContext): Durability[];
|
package/dist/durability.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/durability.ts
|
|
2
2
|
const sharedStores = {
|
|
3
3
|
"cloudflare": "A Cloudflare KV namespace that every Worker reads.",
|
|
4
4
|
"deno-kv": "Deno KV, which Deno Deploy shares between isolates.",
|
|
@@ -49,5 +49,4 @@ function kvDurability(input, context) {
|
|
|
49
49
|
...classify(store, context)
|
|
50
50
|
}));
|
|
51
51
|
}
|
|
52
|
-
//#endregion
|
|
53
52
|
export { kvDurability };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrors } from "@vite-hub/runtime";
|
|
2
|
-
|
|
2
|
+
// src/error-diagnostics.ts
|
|
3
3
|
const cursorProblems = {
|
|
4
4
|
"expired": "The list cursor has expired.",
|
|
5
5
|
"foreign": "The list cursor belongs to a different storage backend.",
|
|
@@ -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
|
|
77
|
-
fix: ({ problem }) => problem === "missing" ? "Add a Database Definition, for example `server/database.ts` with `defineDatabase({ dialect: 'postgresql', schema: {} })`, or select another KV driver." : "
|
|
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."
|
|
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.",
|
|
@@ -155,5 +155,4 @@ const kvConfigErrorCodes = /* @__PURE__ */ new Set([
|
|
|
155
155
|
"KV_MISSING_ENV",
|
|
156
156
|
"KV_STORE_NOT_FOUND"
|
|
157
157
|
]);
|
|
158
|
-
//#endregion
|
|
159
158
|
export { kvErrorDiagnostics as n, kvConfigErrorCodes as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as kvErrorDiagnostics, t as kvConfigErrorCodes } from "./error-diagnostics-
|
|
1
|
+
import { n as kvErrorDiagnostics, t as kvConfigErrorCodes } from "./error-diagnostics-CuVl1nvE.js";
|
|
2
2
|
import { isRuntimeDiagnostic, parseDuration, toResultError } from "@vite-hub/runtime";
|
|
3
|
-
|
|
3
|
+
// src/runtime/ttl.ts
|
|
4
4
|
/**
|
|
5
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
6
|
* time, so the caller returns `KV_INVALID_TTL`.
|
|
@@ -16,8 +16,7 @@ function ttlSeconds(ttl) {
|
|
|
16
16
|
}
|
|
17
17
|
return Number.isFinite(seconds) && seconds > 0 && Number.isSafeInteger(Math.ceil(seconds * 1e3)) ? seconds : void 0;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
//#region src/store-mode.ts
|
|
19
|
+
// src/store-mode.ts
|
|
21
20
|
/**
|
|
22
21
|
* Returns the handle that `kv.store(name, options)` gives. An unknown mode throws, so a typo never gives a writable handle.
|
|
23
22
|
* The read-only handle has only the read methods; write methods are absent, not stubbed.
|
|
@@ -33,8 +32,7 @@ function kvStoreWithMode(storage, options) {
|
|
|
33
32
|
list: storage.list
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
//#region src/errors.ts
|
|
35
|
+
// src/errors.ts
|
|
38
36
|
function kvClearOptionsError(options) {
|
|
39
37
|
if (options === void 0) return;
|
|
40
38
|
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();
|
|
@@ -121,5 +119,4 @@ function kvSetTTL(operation, options) {
|
|
|
121
119
|
if (ttl === void 0) throw kvErrorDiagnostics.KV_INVALID_TTL();
|
|
122
120
|
return ttl;
|
|
123
121
|
}
|
|
124
|
-
//#endregion
|
|
125
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 };
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
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-
|
|
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";
|
|
2
2
|
import { Result, ResultError } from "@vite-hub/runtime";
|
|
3
|
-
//#region src/store-mode.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Returns the handle that `kv.store(name, options)` gives. An unknown mode throws, so a typo never gives a writable handle.
|
|
6
5
|
* The read-only handle has only the read methods; write methods are absent, not stubbed.
|
|
7
6
|
*/
|
|
8
7
|
export declare function kvStoreWithMode(storage: KVStorage, options: KVStoreOptions | undefined): KVStorage | ReadonlyKVStorage;
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/errors.d.ts
|
|
11
8
|
export declare function kvClearOptionsError(options: unknown): ResultError<"KV_INVALID_CLEAR_OPTIONS"> | undefined;
|
|
12
9
|
/**
|
|
13
10
|
* Runs one KV operation and returns `[error, data]`.
|
|
@@ -32,5 +29,4 @@ export declare const kvSetCodes: readonly ["KV_KEY_TOO_LONG", "KV_VALUE_TOO_LARG
|
|
|
32
29
|
* The `ttl` of a write in seconds, or `undefined` when the caller sets none.
|
|
33
30
|
* Throws `KV_INVALID_OPTION` for any option other than `ttl`, and `KV_INVALID_TTL` for a `ttl` that is not a positive time.
|
|
34
31
|
*/
|
|
35
|
-
export declare function kvSetTTL(operation: "set" | "setIfAbsent" | "setMany", options: KVSetOptions | undefined): number | undefined;
|
|
36
|
-
//#endregion
|
|
32
|
+
export declare function kvSetTTL(operation: "set" | "setIfAbsent" | "setMany", options: KVSetOptions | undefined): number | undefined;
|
package/dist/errors.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { kvClearOptionsError, kvInvalidLimitError, kvKeyLimitCodes, kvListLimitInvalid, kvResult, kvSetCodes, kvSetTTL, kvStoreNotFoundError, kvStoreWithMode, kvUnsupportedOperationError, kvWriteLimitCodes, listKVKeys };
|
|
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";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as default } from "./fs-lite-DzTTR6R3.js";
|