@vite-hub/kv 0.6.0 → 0.7.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 +7 -7
- package/dist/{cli-BvVInMht.d.ts → cli-C-uep33j.d.ts} +15 -0
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +3 -2
- package/dist/{cloudflare-kv-Cp8HPUlJ.js → cloudflare-kv-hMdZQZz1.js} +3 -3
- package/dist/{cloudflare-kv-local-COoOI34K.js → cloudflare-kv-local-DO1g7PrA.js} +2 -2
- package/dist/{config-_1oBDv2R.js → config-Dr4GKknB.js} +1 -1
- package/dist/{create-storage-DbWVAY9l.js → create-storage-DrhV0F4S.js} +1 -1
- package/dist/{cursor-history-CMcEEnTO.js → cursor-history-MzSrXXXX.js} +1 -1
- package/dist/{database-4iAg2GoV.js → database-DJp7XHhu.js} +64 -18
- package/dist/{deno-kv-CatE7zSS.js → deno-kv-DwcTL95B.js} +2 -2
- package/dist/{driver-BruahGvT.d.ts → driver-Cvu4k8t4.d.ts} +1 -1
- package/dist/{error-diagnostics-CuVl1nvE.js → error-diagnostics-DAi25E6F.js} +10 -5
- package/dist/{errors-CJoAP4Bu.js → errors-kZRpu7Wa.js} +15 -2
- package/dist/errors.d.ts +6 -1
- package/dist/errors.js +1 -1
- package/dist/{fs-lite-DzTTR6R3.js → fs-lite-4ccAiYae.js} +106 -26
- package/dist/fs-lite-BMY853UK.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -20
- package/dist/{operation-definition-CqZkx1Rm.d.ts → operations-BAlr2zUj.d.ts} +1 -0
- package/dist/{operations-BkVt17cd.js → operations-BKAO0rkO.js} +73 -10
- package/dist/{operations-DSOTGwST.js → operations-UeAgPdtY.js} +6 -6
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +2 -2
- package/dist/{redis-shared-CR3ANc_N.js → redis-shared-DEwmedD5.js} +1 -1
- package/dist/runtime/cloudflare-kv.d.ts +1 -1
- package/dist/runtime/cloudflare-kv.js +1 -1
- package/dist/runtime/nitro-plugin.js +1 -1
- package/dist/runtime/redis-driver.d.ts +2 -2
- package/dist/runtime/redis-driver.js +2 -2
- package/dist/runtime/upstash-driver.d.ts +2 -2
- package/dist/runtime/upstash-driver.js +2 -2
- package/dist/{types-CPDL9enF.d.ts → types-BLxnI_rU.d.ts} +14 -14
- package/dist/{upstash-DeM3_U5H.js → upstash-BKkqGQGE.js} +2 -2
- package/dist/vite.d.ts +8 -5
- package/dist/vite.js +178 -44
- package/package.json +8 -4
- package/dist/fs-lite-DwbPkc-C.js +0 -1
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-
|
|
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-BLxnI_rU.js";
|
|
2
2
|
/** Releases every cached store. Call from the application's shutdown hook after stopping new work. */
|
|
3
3
|
export declare function disposeKVStores(): Promise<void>;
|
|
4
4
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { r as normalizeKVOptions, s as readEnv } from "./config-
|
|
1
|
+
import { r as normalizeKVOptions, s as readEnv } from "./config-Dr4GKknB.js";
|
|
2
2
|
import { n as getActiveCloudflareEnv } from "./cloudflare-env-lookup-Dgq5n1Aq.js";
|
|
3
|
-
import { a as
|
|
3
|
+
import { a as kvListLimitInvalid, c as kvSetTTL, f as listKVKeys, i as kvKeyLimitCodes, m as ttlSeconds, n as kvInvalidKeyError, o as kvResult, p as kvStoreWithMode, s as kvSetCodes, t as kvClearOptionsError } from "./errors-kZRpu7Wa.js";
|
|
4
4
|
import { o as normalizeKey } from "./utils2-By8eee1x.js";
|
|
5
|
-
import { n as kvErrorDiagnostics } from "./error-diagnostics-
|
|
6
|
-
import { t as resolveRuntimeKVOptions } from "./upstash-
|
|
5
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
|
|
6
|
+
import { t as resolveRuntimeKVOptions } from "./upstash-BKkqGQGE.js";
|
|
7
7
|
import { i as setItemsOneByOne, n as getItemsOneByOne } from "./batch-D-ib5_0P.js";
|
|
8
|
-
import { n as normalizeKVListPrefix, t as createKVStorage$1 } from "./create-storage-
|
|
8
|
+
import { n as normalizeKVListPrefix, t as createKVStorage$1 } from "./create-storage-DrhV0F4S.js";
|
|
9
9
|
import { t as logFailure } from "./request-log-DllKQXj7.js";
|
|
10
10
|
import { getViteHubTestMode } from "@vite-hub/runtime/internal/test-mode";
|
|
11
11
|
import { destr } from "destr";
|
|
@@ -34,7 +34,12 @@ const driverAtomicOperations = {
|
|
|
34
34
|
setIfAbsent: true
|
|
35
35
|
},
|
|
36
36
|
"deno-kv": { setIfAbsent: true },
|
|
37
|
-
"fs-lite": {
|
|
37
|
+
"fs-lite": {
|
|
38
|
+
deleteIfEquals: true,
|
|
39
|
+
getAndDelete: true,
|
|
40
|
+
increment: true,
|
|
41
|
+
setIfAbsent: true
|
|
42
|
+
},
|
|
38
43
|
"redis": {
|
|
39
44
|
deleteIfEquals: true,
|
|
40
45
|
getAndDelete: true,
|
|
@@ -59,7 +64,7 @@ const otherOptionalDriverMethods = {
|
|
|
59
64
|
const batchDriverMethods = /* @__PURE__ */ new Set(["getItems", "setItems"]);
|
|
60
65
|
const lazyOptionalDriverMethods = Object.fromEntries(Object.entries(driverAtomicOperations).map(([driver, operations]) => [driver, /* @__PURE__ */ new Set([...Object.keys(operations).map((operation) => atomicDriverMethods[operation]), ...otherOptionalDriverMethods[driver] ?? []])]));
|
|
61
66
|
async function createDatabaseDriver(store, loadDatabases) {
|
|
62
|
-
const { default: factory, kvSqlClientFromDatabase } = await import("./database-
|
|
67
|
+
const { default: factory, kvSqlClientFromDatabase } = await import("./database-DJp7XHhu.js");
|
|
63
68
|
return factory(store, async () => {
|
|
64
69
|
const entry = loadDatabases ? (await loadDatabases())[store.database] : void 0;
|
|
65
70
|
if (!entry) throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
|
|
@@ -74,7 +79,7 @@ async function createRuntimeDriver(store, loadDatabases) {
|
|
|
74
79
|
case "cloudflare": {
|
|
75
80
|
const { localBase } = store;
|
|
76
81
|
if (localBase) {
|
|
77
|
-
const { default: factory } = await import("./cloudflare-kv-local-
|
|
82
|
+
const { default: factory } = await import("./cloudflare-kv-local-DO1g7PrA.js");
|
|
78
83
|
return factory({
|
|
79
84
|
...store,
|
|
80
85
|
localBase
|
|
@@ -85,11 +90,11 @@ async function createRuntimeDriver(store, loadDatabases) {
|
|
|
85
90
|
}
|
|
86
91
|
case "database": return createDatabaseDriver(store, loadDatabases);
|
|
87
92
|
case "deno-kv": {
|
|
88
|
-
const { default: factory } = await import("./deno-kv-
|
|
93
|
+
const { default: factory } = await import("./deno-kv-DwcTL95B.js");
|
|
89
94
|
return factory(store);
|
|
90
95
|
}
|
|
91
96
|
case "fs-lite": {
|
|
92
|
-
const { default: factory } = await import("./fs-lite-
|
|
97
|
+
const { default: factory } = await import("./fs-lite-BMY853UK.js");
|
|
93
98
|
return factory(store);
|
|
94
99
|
}
|
|
95
100
|
case "redis": {
|
|
@@ -243,6 +248,8 @@ function createKVLock(store, resolveStorage, key, options) {
|
|
|
243
248
|
async function acquire() {
|
|
244
249
|
const ttl = ttlSeconds(options.ttl);
|
|
245
250
|
const wait = options.wait ?? 0;
|
|
251
|
+
const keyError = kvInvalidKeyError([key]);
|
|
252
|
+
if (keyError) return [keyError, void 0];
|
|
246
253
|
if (ttl === void 0) return [kvErrorDiagnostics.KV_INVALID_TTL(), void 0];
|
|
247
254
|
if (!Number.isFinite(wait) || wait < 0) return [kvErrorDiagnostics.KV_INVALID_WAIT(), void 0];
|
|
248
255
|
const storage = await resolveStorage();
|
|
@@ -385,6 +392,11 @@ async function runKVOperation(operation, name, run, codes = []) {
|
|
|
385
392
|
const storage = await resolveStorage(name);
|
|
386
393
|
return kvResult(operation, name, () => run(storage), codes);
|
|
387
394
|
}
|
|
395
|
+
async function runKeyedKVOperation(operation, name, keys, run, codes = []) {
|
|
396
|
+
const error = kvInvalidKeyError(keys);
|
|
397
|
+
if (error) return [error, void 0];
|
|
398
|
+
return runKVOperation(operation, name, run, codes);
|
|
399
|
+
}
|
|
388
400
|
function createKVStorage(name = "default") {
|
|
389
401
|
return {
|
|
390
402
|
async clear(options) {
|
|
@@ -393,10 +405,10 @@ function createKVStorage(name = "default") {
|
|
|
393
405
|
return runKVOperation("clear", name, async (storage) => storage.clear(options?.prefix));
|
|
394
406
|
},
|
|
395
407
|
async delete(key, options) {
|
|
396
|
-
return
|
|
408
|
+
return runKeyedKVOperation("delete", name, [key], async (storage) => storage.removeItem(key, options), kvKeyLimitCodes);
|
|
397
409
|
},
|
|
398
410
|
async deleteIfEquals(key, expected) {
|
|
399
|
-
return
|
|
411
|
+
return runKeyedKVOperation("deleteIfEquals", name, [key], async (storage) => {
|
|
400
412
|
if (!storage.deleteIfEqualsItem) throw kvErrorDiagnostics.KV_UNSUPPORTED_OPERATION({
|
|
401
413
|
operation: "deleteIfEquals",
|
|
402
414
|
store: name
|
|
@@ -405,10 +417,10 @@ function createKVStorage(name = "default") {
|
|
|
405
417
|
}, ["KV_INVALID_VALUE", "KV_UNSUPPORTED_OPERATION"]);
|
|
406
418
|
},
|
|
407
419
|
async get(key, options) {
|
|
408
|
-
return
|
|
420
|
+
return runKeyedKVOperation("get", name, [key], (storage) => storage.getItem(key, options), kvKeyLimitCodes);
|
|
409
421
|
},
|
|
410
422
|
async getAndDelete(key, options) {
|
|
411
|
-
return
|
|
423
|
+
return runKeyedKVOperation("getAndDelete", name, [key], async (storage) => {
|
|
412
424
|
if (!storage.getAndDeleteItem) throw kvErrorDiagnostics.KV_UNSUPPORTED_OPERATION({
|
|
413
425
|
operation: "getAndDelete",
|
|
414
426
|
store: name
|
|
@@ -417,13 +429,13 @@ function createKVStorage(name = "default") {
|
|
|
417
429
|
}, ["KV_UNSUPPORTED_OPERATION"]);
|
|
418
430
|
},
|
|
419
431
|
async getMany(keys, options) {
|
|
420
|
-
return
|
|
432
|
+
return runKeyedKVOperation("getMany", name, keys, (storage) => storage.getMany(keys, options), kvKeyLimitCodes);
|
|
421
433
|
},
|
|
422
434
|
async has(key, options) {
|
|
423
|
-
return
|
|
435
|
+
return runKeyedKVOperation("has", name, [key], (storage) => storage.hasItem(key, options), kvKeyLimitCodes);
|
|
424
436
|
},
|
|
425
437
|
async increment(key, ttl) {
|
|
426
|
-
return
|
|
438
|
+
return runKeyedKVOperation("increment", name, [key], async (storage) => {
|
|
427
439
|
if (!storage.incrementItem) throw kvErrorDiagnostics.KV_UNSUPPORTED_OPERATION({
|
|
428
440
|
operation: "increment",
|
|
429
441
|
store: name
|
|
@@ -441,19 +453,19 @@ function createKVStorage(name = "default") {
|
|
|
441
453
|
return runKVOperation("list", name, (storage) => listKVKeys((page) => storage.listKeys(page), options), ["KV_INVALID_CURSOR"]);
|
|
442
454
|
},
|
|
443
455
|
async set(key, value, options) {
|
|
444
|
-
return
|
|
456
|
+
return runKeyedKVOperation("set", name, [key], async (storage) => {
|
|
445
457
|
const ttl = kvSetTTL("set", options);
|
|
446
458
|
return storage.setItem(key, value, ttl === void 0 ? void 0 : { ttl });
|
|
447
459
|
}, kvSetCodes);
|
|
448
460
|
},
|
|
449
461
|
async setMany(entries, options) {
|
|
450
|
-
return
|
|
462
|
+
return runKeyedKVOperation("setMany", name, Array.isArray(entries) ? entries.map((entry) => Reflect.get(Object(entry), "key")) : entries, async (storage) => {
|
|
451
463
|
const ttl = kvSetTTL("setMany", options);
|
|
452
464
|
return storage.setMany(entries, ttl === void 0 ? void 0 : { ttl });
|
|
453
465
|
}, kvSetCodes);
|
|
454
466
|
},
|
|
455
467
|
async setIfAbsent(key, value, options) {
|
|
456
|
-
return
|
|
468
|
+
return runKeyedKVOperation("setIfAbsent", name, [key], async (storage) => {
|
|
457
469
|
if (!storage.setIfAbsentItem) throw kvErrorDiagnostics.KV_UNSUPPORTED_OPERATION({
|
|
458
470
|
operation: "setIfAbsent",
|
|
459
471
|
store: name
|
|
@@ -39,7 +39,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
39
39
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
40
40
|
},
|
|
41
41
|
INTERNAL_R0024: {
|
|
42
|
-
fix: "Start the dev server
|
|
42
|
+
fix: "Start the dev server (`nuxt dev` or `vite dev`), or pass `--url <origin>` of a deployed app and set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key whose public key the app has in VITEHUB_CONSOLE_KEY_<NAME>.",
|
|
43
43
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
44
44
|
},
|
|
45
45
|
INTERNAL_R0023: {
|
|
@@ -155,7 +155,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
155
155
|
fix: "Give a switch column `format: \"switch\"` and `switch: { operation, input }` with a registered operation name, or remove both."
|
|
156
156
|
},
|
|
157
157
|
INTERNAL_R0025: {
|
|
158
|
-
fix: "Start `vite dev` in the project that you run the command from, or pass `--url` of that server.",
|
|
158
|
+
fix: "Start the dev server (`nuxt dev` or `vite dev`) in the project that you run the command from, or pass `--url` of that server.",
|
|
159
159
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
160
160
|
},
|
|
161
161
|
INTERNAL_R0026: {
|
|
@@ -176,7 +176,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
176
176
|
},
|
|
177
177
|
INTERNAL_R0002: {
|
|
178
178
|
...dynamicError,
|
|
179
|
-
fix:
|
|
179
|
+
fix: ({ fix }) => fix ?? "Build for a host that provides this capability, or set the option named in the message to `false`."
|
|
180
180
|
},
|
|
181
181
|
INTERNAL_R0004: {
|
|
182
182
|
...dynamicError,
|
|
@@ -456,6 +456,56 @@ function isServerEnvironment(name, config) {
|
|
|
456
456
|
const VITEHUB_NITRO_CONFIG_CONTEXT = "__vitehubNitroConfigContext";
|
|
457
457
|
const VITEHUB_PROJECT_ROOT = "__vitehubProjectRoot";
|
|
458
458
|
/**
|
|
459
|
+
* Server Env declarations that ViteHub features add before `hubEnv()` builds the registry, such as the Server Env of
|
|
460
|
+
* discovered Channels. The application's `env.server` wins field by field.
|
|
461
|
+
*/
|
|
462
|
+
const VITEHUB_ENV_SERVER = "__vitehubEnvServer";
|
|
463
|
+
function isPackageServerEnvField(value) {
|
|
464
|
+
return Array.isArray(value.names);
|
|
465
|
+
}
|
|
466
|
+
/** The kind of a contributed field. `hubEnv()` declares it as an optional `env()` with a non-canonical source. */
|
|
467
|
+
const PACKAGE_SERVER_ENV_FIELD = "vitehub-package-env-field";
|
|
468
|
+
function packageServerEnvDeclarations(fields) {
|
|
469
|
+
return Object.fromEntries(Object.entries(fields).flatMap(([key, field]) => {
|
|
470
|
+
if (!isPackageServerEnvField(field)) {
|
|
471
|
+
const group = packageServerEnvDeclarations(field);
|
|
472
|
+
return Object.keys(group).length ? [[key, group]] : [];
|
|
473
|
+
}
|
|
474
|
+
return [[key, {
|
|
475
|
+
kind: PACKAGE_SERVER_ENV_FIELD,
|
|
476
|
+
names: [...field.names],
|
|
477
|
+
description: field.description,
|
|
478
|
+
secret: field.secret,
|
|
479
|
+
sourcePatterns: field.sourcePatterns
|
|
480
|
+
}]];
|
|
481
|
+
}));
|
|
482
|
+
}
|
|
483
|
+
function isServerEnvGroup(value) {
|
|
484
|
+
return isRecord(value) && value.kind !== "env-variable" && value.kind !== "vitehub-package-env-field";
|
|
485
|
+
}
|
|
486
|
+
function mergeServerEnvGroups(base, added) {
|
|
487
|
+
const merged = { ...base };
|
|
488
|
+
for (const [key, value] of Object.entries(added)) {
|
|
489
|
+
const current = merged[key];
|
|
490
|
+
merged[key] = isServerEnvGroup(current) && isServerEnvGroup(value) ? mergeServerEnvGroups(current, value) : current ?? value;
|
|
491
|
+
}
|
|
492
|
+
return merged;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Declare in Server Env the host variables that a package reads for its configured provider, under
|
|
496
|
+
* `env.server.<group>`, so `inspectServerEnv()` and Setup pages list them with a description. Each value is optional:
|
|
497
|
+
* the package reports a missing value when it uses the provider, and `deployment.json` keeps the deploy rule. The
|
|
498
|
+
* source claims no canonical name, so the application can also read the variable under its own key. Declarations
|
|
499
|
+
* that another feature already added at the same path stay, and the application's `env.server` wins field by field.
|
|
500
|
+
*/
|
|
501
|
+
function contributeServerEnv(config, group, fields) {
|
|
502
|
+
const declarations = packageServerEnvDeclarations(fields);
|
|
503
|
+
if (!Object.keys(declarations).length) return;
|
|
504
|
+
const contributed = Reflect.get(config, VITEHUB_ENV_SERVER);
|
|
505
|
+
const server = isRecord(contributed) ? contributed : {};
|
|
506
|
+
Reflect.set(config, VITEHUB_ENV_SERVER, mergeServerEnvGroups(server, { [group]: declarations }));
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
459
509
|
* Set by `vite-hub/nuxt` when it replays Vite config hooks for `nuxt prepare`. Prepare uses `command: "build"` to write
|
|
460
510
|
* the same types as the build, but it builds nothing.
|
|
461
511
|
*/
|
|
@@ -1130,7 +1180,6 @@ function operationSection(operation, input) {
|
|
|
1130
1180
|
function isSectionScope(scope) {
|
|
1131
1181
|
return isSectionId(scope) && scope !== "read";
|
|
1132
1182
|
}
|
|
1133
|
-
/** `"blob:media"` → `["blob:media", "blob"]`: a grant of the section covers each of its scopes. */
|
|
1134
1183
|
function grantsFor(section) {
|
|
1135
1184
|
const separator = section.indexOf(":");
|
|
1136
1185
|
return separator === -1 ? [section] : [section, section.slice(0, separator)];
|
|
@@ -1362,14 +1411,15 @@ async function callOperation(target, name, input) {
|
|
|
1362
1411
|
};
|
|
1363
1412
|
}
|
|
1364
1413
|
if (response.status === 401 || response.status >= 300 && response.status < 400) return unreachable(`${url.origin} asked for authentication (HTTP ${response.status}).`, 401);
|
|
1365
|
-
return unreachable(`${url.origin} did not answer as a ViteHub app (HTTP ${response.status}). Pass the origin of an app that runs ViteHub
|
|
1414
|
+
return unreachable(`${url.origin} did not answer as a ViteHub app (HTTP ${response.status}). ${response.status === 404 && !target.roots?.length ? "A production build answers ViteHub operations only when `vitehub()` sets `console`. Set it, deploy again, and pass the origin of that app." : "Pass the origin of an app that runs ViteHub."}`, response.status);
|
|
1366
1415
|
} catch (error) {
|
|
1367
1416
|
return unreachable(`The request to ${origin} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1368
1417
|
}
|
|
1369
1418
|
}
|
|
1370
1419
|
/**
|
|
1371
1420
|
* Call one operation from a `vitehub` command: on `--url` when it is set, else on the dev server that the project
|
|
1372
|
-
* started.
|
|
1421
|
+
* started. A call on `--url` goes through the Console when `consoleRoute` finds the app there. Never throws. Without a
|
|
1422
|
+
* dev server the result is an `INTERNAL_R0024` failure that says to start one.
|
|
1373
1423
|
*/
|
|
1374
1424
|
async function callOperationFromCli(call, name, input) {
|
|
1375
1425
|
let roots;
|
|
@@ -1378,15 +1428,28 @@ async function callOperationFromCli(call, name, input) {
|
|
|
1378
1428
|
} catch {
|
|
1379
1429
|
roots = [call.rootDir];
|
|
1380
1430
|
}
|
|
1431
|
+
const target = {
|
|
1432
|
+
...call.confirmed !== void 0 ? { confirmed: call.confirmed } : {},
|
|
1433
|
+
env: call.env,
|
|
1434
|
+
...call.fetch ? { fetch: call.fetch } : {}
|
|
1435
|
+
};
|
|
1436
|
+
if (call.url && call.consoleRoute && !hasCredentials(call.env)) {
|
|
1437
|
+
const signal = AbortSignal.timeout(call.timeout ?? 3e4);
|
|
1438
|
+
const route = await call.consoleRoute(call.url, signal);
|
|
1439
|
+
return await callOperation({
|
|
1440
|
+
...target,
|
|
1441
|
+
...route ? { authorization: route.authorization } : {},
|
|
1442
|
+
signal,
|
|
1443
|
+
url: route?.target ?? call.url
|
|
1444
|
+
}, name, input);
|
|
1445
|
+
}
|
|
1381
1446
|
const url = call.url ?? findViteHubDevServerUrl(roots, call.env);
|
|
1382
1447
|
if (!url) return unreachable(`No dev server is running for ${roots.at(-1)}.`);
|
|
1383
1448
|
return await callOperation({
|
|
1384
|
-
...
|
|
1385
|
-
env: call.env,
|
|
1386
|
-
...call.fetch ? { fetch: call.fetch } : {},
|
|
1449
|
+
...target,
|
|
1387
1450
|
...call.url ? {} : { roots },
|
|
1388
1451
|
...call.timeout ? { timeout: call.timeout } : {},
|
|
1389
1452
|
url
|
|
1390
1453
|
}, name, input);
|
|
1391
1454
|
}
|
|
1392
|
-
export {
|
|
1455
|
+
export { readViteHubDevServerFile as A, markViteConfigPlugin as C, listSeedFiles as D, askOnTerminal as E, internalErrorDiagnostics as F, removeViteHubDevServerFile as M, writeCliFailure as N, parseCliPositiveInteger as O, writeViteHubDevServerFile as P, isServerEnvironment as S, shouldSkipViteProviderBuild as T, VITEHUB_PREPARE as _, operationRootHeader as a, createNoExternalAddition as b, projectRootHash as c, defineOperation as d, answerOperationRpc as f, VITEHUB_NITRO_CONFIG_CONTEXT as g, readOperationRpcCall as h, createOperationRegistry as i, readViteHubDevTargetOption as j, readCliOptionValue as k, runOperation as l, operationRpcRefusal as m, callOperationFromCli as n, operationRpcHeader as o, operationRpcPath as p, collectOperationContributions as r, operationsOf as s, assertOperationProject as t, toOperationFailure as u, VITEHUB_PROJECT_ROOT as v, resolveViteHubProjectRoot as w, hasNitroConfigContext as x, contributeServerEnv as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as normalizeKey } from "./utils2-By8eee1x.js";
|
|
2
2
|
import { t as redactInspectionText } from "./inspect-BWMcVWD8.js";
|
|
3
|
-
import { n as kvErrorDiagnostics } from "./error-diagnostics-
|
|
3
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
|
|
4
4
|
import { t as kvDevMaximumListLimit } from "./results-emgN7uDS.js";
|
|
5
5
|
import { kv } from "@vite-hub/kv";
|
|
6
6
|
// src/runtime/inspect-value.ts
|
|
@@ -257,6 +257,7 @@ const maximumKeyLength = 2048;
|
|
|
257
257
|
function unwrap(result) {
|
|
258
258
|
const [error, value] = result;
|
|
259
259
|
if (!error) return value;
|
|
260
|
+
if (error.status !== void 0) throw error;
|
|
260
261
|
throw Object.assign(error, { status: kvOperationStatus[error.code] ?? 502 });
|
|
261
262
|
}
|
|
262
263
|
function resolvedStores(config) {
|
|
@@ -316,13 +317,12 @@ async function runKVOperation(operation, input, stores = listKVDevStores()) {
|
|
|
316
317
|
return await runOperation(operation, input, stores);
|
|
317
318
|
} catch (error) {
|
|
318
319
|
const code = Reflect.get(Object(error), "code");
|
|
319
|
-
const
|
|
320
|
+
const existingStatus = Reflect.get(Object(error), "status");
|
|
321
|
+
const status = existingStatus ?? (typeof code === "string" ? kvOperationStatus[code] : void 0);
|
|
320
322
|
if (typeof status !== "number" || !(error instanceof Error)) throw error;
|
|
321
323
|
const cause = code === "KV_OPERATION_FAILED" && error.cause instanceof Error ? ` ${error.cause.message}` : "";
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
statusMessage: redactInspectionText(`${error.message}${cause}`)
|
|
325
|
-
});
|
|
324
|
+
if (existingStatus === void 0 || existingStatus === null) Object.assign(error, { status });
|
|
325
|
+
throw Object.assign(error, { statusMessage: redactInspectionText(`${error.message}${cause}`) });
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
async function runOperation(operation, input, stores) {
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as AnyOperation } from "./
|
|
2
|
-
import { c as KVDriver } from "./types-
|
|
1
|
+
import { t as AnyOperation } from "./operations-BAlr2zUj.js";
|
|
2
|
+
import { c as KVDriver } from "./types-BLxnI_rU.js";
|
|
3
3
|
interface KVDevListResult {
|
|
4
4
|
/** Present when more keys exist. Pass it as `--cursor` to read the next page. */
|
|
5
5
|
cursor?: string;
|
package/dist/operations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as internalErrorDiagnostics, a as operationRootHeader, c as projectRootHash, d as defineOperation, f as answerOperationRpc, h as readOperationRpcCall, i as createOperationRegistry, l as runOperation, m as operationRpcRefusal, o as operationRpcHeader, s as operationsOf, t as assertOperationProject, u as toOperationFailure } from "./operations-BKAO0rkO.js";
|
|
2
2
|
import { t as kvDevMaximumListLimit } from "./results-emgN7uDS.js";
|
|
3
3
|
import { n as isViteHubLoopbackPeer } from "./dev-peer-D0vOxmrD.js";
|
|
4
4
|
import * as v from "valibot";
|
|
@@ -235,7 +235,7 @@ function createStandaloneOperationHandler(sources, root) {
|
|
|
235
235
|
} };
|
|
236
236
|
}
|
|
237
237
|
// src/operations.ts
|
|
238
|
-
const runtime = () => import("./operations-
|
|
238
|
+
const runtime = () => import("./operations-UeAgPdtY.js");
|
|
239
239
|
const store = v.optional(v.pipe(v.string(), v.check((name) => name.trim() !== "", "Name a store.")));
|
|
240
240
|
const key = v.string();
|
|
241
241
|
function defineKVOperation(definition) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as KVRuntimeDriver } from "../driver-
|
|
1
|
+
import { t as KVRuntimeDriver } from "../driver-Cvu4k8t4.js";
|
|
2
2
|
declare function createCloudflareDriver(options: Record<string, unknown>): KVRuntimeDriver;
|
|
3
3
|
export declare function createCloudflareKVStorage(options: Record<string, unknown>): unknown;
|
|
4
4
|
export { createCloudflareDriver as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as createCloudflareKVStorage, t as default } from "../cloudflare-kv-
|
|
1
|
+
export { n as createCloudflareKVStorage, t as default } from "../cloudflare-kv-hMdZQZz1.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as logFailure } from "../request-log-DllKQXj7.js";
|
|
2
|
-
import { t as kvInferredStoreNotice } from "../config-
|
|
2
|
+
import { t as kvInferredStoreNotice } from "../config-Dr4GKknB.js";
|
|
3
3
|
import { disposeKVStores } from "@vite-hub/kv";
|
|
4
4
|
// src/runtime/nitro-plugin.ts
|
|
5
5
|
async function logInferredStores() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z as ResolvedRedisKVStoreConfig } from "../types-
|
|
2
|
-
import { t as KVRuntimeDriver } from "../driver-
|
|
1
|
+
import { z as ResolvedRedisKVStoreConfig } from "../types-BLxnI_rU.js";
|
|
2
|
+
import { t as KVRuntimeDriver } from "../driver-Cvu4k8t4.js";
|
|
3
3
|
/** The URL of a store: `env:<NAME>` reads the variable now, so a build never holds the URL of its server. */
|
|
4
4
|
export declare function resolveRedisUrl(url: string, env?: Record<string, string | undefined>): string;
|
|
5
5
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as invariant } from "../invariant-Dj2R1eMr.js";
|
|
2
2
|
import { o as normalizeKey } from "../utils2-By8eee1x.js";
|
|
3
|
-
import { n as kvErrorDiagnostics } from "../error-diagnostics-
|
|
3
|
+
import { n as kvErrorDiagnostics } from "../error-diagnostics-DAi25E6F.js";
|
|
4
4
|
import { t as chunks } from "../batch-D-ib5_0P.js";
|
|
5
|
-
import { a as redisIncrementScript, i as redisIncrementResult, n as escapeRedisGlob, o as redisTTLSeconds, r as redisDeleteIfEqualsScript, t as createPortableRedisKeyLister } from "../redis-shared-
|
|
5
|
+
import { a as redisIncrementScript, i as redisIncrementResult, n as escapeRedisGlob, o as redisTTLSeconds, r as redisDeleteIfEqualsScript, t as createPortableRedisKeyLister } from "../redis-shared-DEwmedD5.js";
|
|
6
6
|
import { Redis } from "ioredis";
|
|
7
7
|
// src/runtime/redis-driver.ts
|
|
8
8
|
/** The URL of a store: `env:<NAME>` reads the variable now, so a build never holds the URL of its server. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { B as ResolvedUpstashKVStoreConfig } from "../types-
|
|
2
|
-
import { t as KVRuntimeDriver } from "../driver-
|
|
1
|
+
import { B as ResolvedUpstashKVStoreConfig } from "../types-BLxnI_rU.js";
|
|
2
|
+
import { t as KVRuntimeDriver } from "../driver-Cvu4k8t4.js";
|
|
3
3
|
export default function createUpstashKVDriver(options: ResolvedUpstashKVStoreConfig): KVRuntimeDriver;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as invariant } from "../invariant-Dj2R1eMr.js";
|
|
2
2
|
import { o as normalizeKey } from "../utils2-By8eee1x.js";
|
|
3
|
-
import { n as kvErrorDiagnostics } from "../error-diagnostics-
|
|
3
|
+
import { n as kvErrorDiagnostics } from "../error-diagnostics-DAi25E6F.js";
|
|
4
4
|
import { t as chunks } from "../batch-D-ib5_0P.js";
|
|
5
|
-
import { a as redisIncrementScript, i as redisIncrementResult, n as escapeRedisGlob, o as redisTTLSeconds, r as redisDeleteIfEqualsScript, t as createPortableRedisKeyLister } from "../redis-shared-
|
|
5
|
+
import { a as redisIncrementScript, i as redisIncrementResult, n as escapeRedisGlob, o as redisTTLSeconds, r as redisDeleteIfEqualsScript, t as createPortableRedisKeyLister } from "../redis-shared-DEwmedD5.js";
|
|
6
6
|
import createDriver from "unstorage/drivers/upstash";
|
|
7
7
|
// src/runtime/upstash-driver.ts
|
|
8
8
|
const keyBatchSize = 1e3;
|
|
@@ -9,7 +9,7 @@ interface KVDriverAtomicOperations {
|
|
|
9
9
|
"cloudflare": never;
|
|
10
10
|
"database": "deleteIfEquals" | "getAndDelete" | "increment" | "setIfAbsent";
|
|
11
11
|
"deno-kv": "setIfAbsent";
|
|
12
|
-
"fs-lite": "setIfAbsent";
|
|
12
|
+
"fs-lite": "deleteIfEquals" | "getAndDelete" | "increment" | "setIfAbsent";
|
|
13
13
|
"redis": "deleteIfEquals" | "getAndDelete" | "increment" | "setIfAbsent";
|
|
14
14
|
"upstash": "deleteIfEquals" | "getAndDelete" | "increment" | "setIfAbsent";
|
|
15
15
|
}
|
|
@@ -64,7 +64,7 @@ interface DatabaseKVStoreConfig {
|
|
|
64
64
|
driver: "database";
|
|
65
65
|
/**
|
|
66
66
|
* The Database that keeps the keys, in the table `vitehub_kv`. Default `"default"`. The store creates the table when
|
|
67
|
-
* it is missing. Postgres and
|
|
67
|
+
* it is missing. Supports Postgres, libSQL, and native D1 bindings or sessions, not D1 over HTTP.
|
|
68
68
|
*/
|
|
69
69
|
database?: string;
|
|
70
70
|
/** A Database store uses the Database of the app, in `vite dev` too. */
|
|
@@ -138,7 +138,7 @@ interface ResolvedKVModuleOptions {
|
|
|
138
138
|
}
|
|
139
139
|
type KVOperation = "clear" | "delete" | "deleteIfEquals" | "get" | "getAndDelete" | "getMany" | "has" | "increment" | "list" | "lock" | "set" | "setIfAbsent" | "setMany";
|
|
140
140
|
/** Codes that KV operations return in the `[error, data]` tuple. Config errors throw instead. */
|
|
141
|
-
type KVErrorCode = "KV_INVALID_CURSOR" | "KV_INVALID_CLEAR_OPTIONS" | "KV_INVALID_LIMIT" | "KV_INVALID_OPTION" | "KV_INVALID_TTL" | "KV_INVALID_VALUE" | "KV_INVALID_WAIT" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION" | "KV_VALUE_TOO_LARGE";
|
|
141
|
+
type KVErrorCode = "KV_INVALID_CURSOR" | "KV_INVALID_CLEAR_OPTIONS" | "KV_INVALID_KEY" | "KV_INVALID_LIMIT" | "KV_INVALID_OPTION" | "KV_INVALID_TTL" | "KV_INVALID_VALUE" | "KV_INVALID_WAIT" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION" | "KV_VALUE_TOO_LARGE";
|
|
142
142
|
interface KVListOptions {
|
|
143
143
|
/** Opaque continuation cursor returned by a previous page. */
|
|
144
144
|
cursor?: string;
|
|
@@ -184,7 +184,7 @@ interface KVLockOptions {
|
|
|
184
184
|
wait?: number;
|
|
185
185
|
}
|
|
186
186
|
/** Codes that `kv.lock().run()` and `kv.lock().acquire()` return. */
|
|
187
|
-
type KVLockErrorCode = "KV_INVALID_TTL" | "KV_INVALID_WAIT" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION";
|
|
187
|
+
type KVLockErrorCode = "KV_INVALID_KEY" | "KV_INVALID_TTL" | "KV_INVALID_WAIT" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION";
|
|
188
188
|
/** The data of `kv.lock().run()`: the callback's value, or `acquired: false` when another runner held the lock. */
|
|
189
189
|
type KVLockRunResult<T> = {
|
|
190
190
|
acquired: true;
|
|
@@ -232,26 +232,26 @@ interface KVListPage {
|
|
|
232
232
|
*/
|
|
233
233
|
interface KVStorage {
|
|
234
234
|
clear(options?: KVClearOptions): Promise<Result<void, "KV_INVALID_CLEAR_OPTIONS" | "KV_OPERATION_FAILED">>;
|
|
235
|
-
delete(key: string, options?: unknown): Promise<Result<void, "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED">>;
|
|
235
|
+
delete(key: string, options?: unknown): Promise<Result<void, "KV_INVALID_KEY" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED">>;
|
|
236
236
|
/**
|
|
237
237
|
* Deletes the key only when its value equals `expected`, in one atomic step. Returns `true` when this call deleted it.
|
|
238
238
|
* KV compares the stored text with `expected` serialized as `set()` stores it, so `{ a: 1, b: 2 }` and
|
|
239
239
|
* `{ b: 2, a: 1 }` are different values. Use it to free a token that only its owner may free.
|
|
240
240
|
* The drivers in {@link KVDriversWith}`<"deleteIfEquals">` support it. The others return `KV_UNSUPPORTED_OPERATION`.
|
|
241
241
|
*/
|
|
242
|
-
deleteIfEquals<T = unknown>(key: string, expected: T): Promise<Result<boolean, "KV_INVALID_VALUE" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION">>;
|
|
243
|
-
get<T = unknown, K extends KVGetType | undefined = undefined>(key: string, options?: KVGetOptions<K>): Promise<Result<KVValue<T, K> | null, "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED">>;
|
|
244
|
-
getMany<T = unknown, K extends KVGetType | undefined = undefined>(keys: readonly string[], options?: KVGetOptions<K>): Promise<Result<Array<KVValue<T, K> | null>, "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED">>;
|
|
242
|
+
deleteIfEquals<T = unknown>(key: string, expected: T): Promise<Result<boolean, "KV_INVALID_KEY" | "KV_INVALID_VALUE" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION">>;
|
|
243
|
+
get<T = unknown, K extends KVGetType | undefined = undefined>(key: string, options?: KVGetOptions<K>): Promise<Result<KVValue<T, K> | null, "KV_INVALID_KEY" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED">>;
|
|
244
|
+
getMany<T = unknown, K extends KVGetType | undefined = undefined>(keys: readonly string[], options?: KVGetOptions<K>): Promise<Result<Array<KVValue<T, K> | null>, "KV_INVALID_KEY" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED">>;
|
|
245
245
|
getAndDelete<T = unknown, K extends "text" | undefined = undefined>(key: string, options?: {
|
|
246
246
|
type?: K;
|
|
247
|
-
}): Promise<Result<KVValue<T, K> | null, "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION">>;
|
|
248
|
-
has(key: string, options?: unknown): Promise<Result<boolean, "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED">>;
|
|
247
|
+
}): Promise<Result<KVValue<T, K> | null, "KV_INVALID_KEY" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION">>;
|
|
248
|
+
has(key: string, options?: unknown): Promise<Result<boolean, "KV_INVALID_KEY" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED">>;
|
|
249
249
|
/**
|
|
250
250
|
* Atomically increments a counter. The TTL, a number of seconds or a duration such as `"1m"`, is applied only when
|
|
251
251
|
* the counter is created.
|
|
252
252
|
* The drivers in {@link KVDriversWith}`<"increment">` support it. The others return `KV_UNSUPPORTED_OPERATION`.
|
|
253
253
|
*/
|
|
254
|
-
increment(key: string, ttl: number | Duration): Promise<Result<number, "KV_INVALID_TTL" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION">>;
|
|
254
|
+
increment(key: string, ttl: number | Duration): Promise<Result<number, "KV_INVALID_KEY" | "KV_INVALID_TTL" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION">>;
|
|
255
255
|
list(options?: KVListOptions): Promise<Result<KVListPage, "KV_INVALID_CURSOR" | "KV_INVALID_LIMIT" | "KV_OPERATION_FAILED">>;
|
|
256
256
|
/**
|
|
257
257
|
* A lock on `key` that one runner holds at a time, across server processes that share the store. It writes a random
|
|
@@ -265,7 +265,7 @@ interface KVStorage {
|
|
|
265
265
|
* value stays until you delete or replace it.
|
|
266
266
|
* Cloudflare KV stores return `KV_KEY_TOO_LONG` and `KV_VALUE_TOO_LARGE` before a write that Cloudflare rejects.
|
|
267
267
|
*/
|
|
268
|
-
set<T = unknown>(key: string, value: T, options?: KVSetOptions): Promise<Result<void, "KV_INVALID_OPTION" | "KV_INVALID_TTL" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED" | "KV_VALUE_TOO_LARGE">>;
|
|
268
|
+
set<T = unknown>(key: string, value: T, options?: KVSetOptions): Promise<Result<void, "KV_INVALID_KEY" | "KV_INVALID_OPTION" | "KV_INVALID_TTL" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED" | "KV_VALUE_TOO_LARGE">>;
|
|
269
269
|
/**
|
|
270
270
|
* Writes many keys in one call. `options` works as in `set()` and applies to every entry. When a key is in `entries`
|
|
271
271
|
* more than once, the last entry wins. A `value` of `undefined` deletes the key, as `set()` does. The writes are not
|
|
@@ -273,14 +273,14 @@ interface KVStorage {
|
|
|
273
273
|
* statement. Other stores write the entries one by one, 16 at a time. A Cloudflare KV store checks every entry against
|
|
274
274
|
* the Workers KV limits before it writes any.
|
|
275
275
|
*/
|
|
276
|
-
setMany<T = unknown>(entries: readonly KVEntry<T>[], options?: KVSetOptions): Promise<Result<void, "KV_INVALID_OPTION" | "KV_INVALID_TTL" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED" | "KV_VALUE_TOO_LARGE">>;
|
|
276
|
+
setMany<T = unknown>(entries: readonly KVEntry<T>[], options?: KVSetOptions): Promise<Result<void, "KV_INVALID_KEY" | "KV_INVALID_OPTION" | "KV_INVALID_TTL" | "KV_KEY_TOO_LONG" | "KV_OPERATION_FAILED" | "KV_VALUE_TOO_LARGE">>;
|
|
277
277
|
/**
|
|
278
278
|
* Writes the value only when the key has no value, in one atomic step.
|
|
279
279
|
* Returns `true` when this call wrote the value and `false` when the key already had one.
|
|
280
280
|
* The drivers in {@link KVDriversWith}`<"setIfAbsent">` support it. Cloudflare KV is eventually consistent and returns
|
|
281
281
|
* `KV_UNSUPPORTED_OPERATION`.
|
|
282
282
|
*/
|
|
283
|
-
setIfAbsent<T = unknown>(key: string, value: T, options?: KVSetOptions): Promise<Result<boolean, "KV_INVALID_OPTION" | "KV_INVALID_TTL" | "KV_INVALID_VALUE" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION">>;
|
|
283
|
+
setIfAbsent<T = unknown>(key: string, value: T, options?: KVSetOptions): Promise<Result<boolean, "KV_INVALID_KEY" | "KV_INVALID_OPTION" | "KV_INVALID_TTL" | "KV_INVALID_VALUE" | "KV_OPERATION_FAILED" | "KV_UNSUPPORTED_OPERATION">>;
|
|
284
284
|
/** Selects a named KV store. `{ mode: "read" }` returns a handle without write methods. */
|
|
285
285
|
store(name: KVStoreName, options?: {
|
|
286
286
|
mode?: "write";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as upstashUrlEnvNames, i as upstashTokenEnvNames, s as readEnv } from "./config-
|
|
2
|
-
import { n as kvErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { a as upstashUrlEnvNames, i as upstashTokenEnvNames, s as readEnv } from "./config-Dr4GKknB.js";
|
|
2
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
|
|
3
3
|
// src/runtime/upstash.ts
|
|
4
4
|
function isMaskedValue(value) {
|
|
5
5
|
return !value || /^\*+$/.test(value);
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as ResolvedKVModuleOptions, w as KVOptions } from "./types-
|
|
2
|
-
import { r as ViteHubCliPluginMetadata } from "./cli-
|
|
3
|
-
import { n as OperationContributionEntry } from "./
|
|
1
|
+
import { L as ResolvedKVModuleOptions, w as KVOptions } from "./types-BLxnI_rU.js";
|
|
2
|
+
import { r as ViteHubCliPluginMetadata } from "./cli-C-uep33j.js";
|
|
3
|
+
import { n as OperationContributionEntry } from "./operations-BAlr2zUj.js";
|
|
4
4
|
import "nostics";
|
|
5
5
|
import { Plugin } from "vite";
|
|
6
6
|
interface KVResolutionInput {
|
|
@@ -168,7 +168,10 @@ interface KVNitroBuild {
|
|
|
168
168
|
hooks?: {
|
|
169
169
|
hook: (name: "prerender:config", callback: (config: KVPrerenderConfig) => void) => unknown;
|
|
170
170
|
};
|
|
171
|
-
options: NitroCloudflareKVTarget
|
|
171
|
+
options: NitroCloudflareKVTarget & {
|
|
172
|
+
dev?: boolean;
|
|
173
|
+
preset?: string;
|
|
174
|
+
};
|
|
172
175
|
}
|
|
173
176
|
interface NitroCloudflareKVTarget {
|
|
174
177
|
deps?: {
|
|
@@ -191,6 +194,6 @@ export interface KVViteInput extends Pick<KVResolutionInput, "hosting"> {
|
|
|
191
194
|
/** The module that exports the app's `databases`, for the `database` driver. Default `@vite-hub/database/runtime/registry`. */
|
|
192
195
|
databaseImport?: string;
|
|
193
196
|
}
|
|
194
|
-
/**
|
|
197
|
+
/** KV infers its driver from Nitro's preset, the supplied host, or the host environment. */
|
|
195
198
|
export declare function hubKV(options?: KVOptions, input?: KVViteInput): KVVitePlugin;
|
|
196
199
|
export type { KVViteRuntimeConfig };
|