@vite-hub/kv 0.7.0 → 0.9.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 -0
- package/dist/cli.js +2 -2
- package/dist/{cloudflare-env-Cpy3Bqdn.js → cloudflare-env-JD7uO5-i.js} +0 -4
- package/dist/{cloudflare-kv-hMdZQZz1.js → cloudflare-kv-CkrnHHnv.js} +4 -4
- package/dist/{cloudflare-kv-local-DO1g7PrA.js → cloudflare-kv-local-qb92SO8d.js} +3 -3
- package/dist/{config-Dr4GKknB.js → config-CZ4CZy9h.js} +4 -4
- package/dist/{create-storage-DrhV0F4S.js → create-storage-DeGjkDl8.js} +1 -1
- package/dist/{cursor-history-MzSrXXXX.js → cursor-history-KSuS5xrH.js} +1 -1
- package/dist/{database-DJp7XHhu.js → database-CtQO7n6H.js} +6 -6
- package/dist/{deno-kv-DwcTL95B.js → deno-kv-ClGWU3yO.js} +2 -2
- package/dist/{dev-peer-D0vOxmrD.js → dev-peer-CpFxuBAP.js} +0 -24
- package/dist/{driver-Cvu4k8t4.d.ts → driver-CZTAQ_07.d.ts} +1 -1
- package/dist/{error-diagnostics-DAi25E6F.js → error-diagnostics-C7c-Bfrl.js} +2 -2
- package/dist/{errors-kZRpu7Wa.js → errors-BV0MKLrD.js} +1 -1
- package/dist/errors.js +1 -1
- package/dist/{fs-lite-4ccAiYae.js → fs-lite-Bmcw5tUV.js} +124 -140
- package/dist/fs-lite-D33j4kWD.js +1 -0
- package/dist/index.js +56 -58
- package/dist/{operations-UeAgPdtY.js → operations-CbpFdf91.js} +17 -24
- package/dist/{operations-BKAO0rkO.js → operations-mNN-HppH.js} +2 -3
- package/dist/operations.js +3 -10
- package/dist/{redis-shared-DEwmedD5.js → redis-shared-DIUSIQAC.js} +1 -1
- package/dist/runtime/cloudflare-kv.d.ts +1 -1
- package/dist/runtime/cloudflare-kv.js +1 -1
- package/dist/runtime/cloudflare-request-env.js +1 -1
- package/dist/runtime/nitro-plugin.js +1 -1
- package/dist/runtime/redis-driver.d.ts +1 -1
- package/dist/runtime/redis-driver.js +3 -5
- package/dist/runtime/upstash-driver.d.ts +1 -1
- package/dist/runtime/upstash-driver.js +2 -2
- package/dist/{upstash-BKkqGQGE.js → upstash-CiqFI55W.js} +2 -2
- package/dist/vite.d.ts +1 -0
- package/dist/vite.js +40 -55
- package/package.json +4 -4
- package/dist/fs-lite-BMY853UK.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import { r as normalizeKVOptions, s as readEnv } from "./config-
|
|
1
|
+
import { r as normalizeKVOptions, s as readEnv } from "./config-CZ4CZy9h.js";
|
|
2
2
|
import { n as getActiveCloudflareEnv } from "./cloudflare-env-lookup-Dgq5n1Aq.js";
|
|
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-
|
|
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-BV0MKLrD.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-C7c-Bfrl.js";
|
|
6
|
+
import { t as resolveRuntimeKVOptions } from "./upstash-CiqFI55W.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-DeGjkDl8.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";
|
|
12
12
|
// src/runtime/driver.ts
|
|
13
|
-
const lazyDriverMethods = /* @__PURE__ */ new Set([
|
|
14
|
-
"clear",
|
|
15
|
-
"getItem",
|
|
16
|
-
"getKeys",
|
|
17
|
-
"hasItem",
|
|
18
|
-
"listKeys",
|
|
19
|
-
"removeItem",
|
|
20
|
-
"setItem"
|
|
21
|
-
]);
|
|
22
13
|
const atomicDriverMethods = {
|
|
23
14
|
deleteIfEquals: "deleteIfEqualsItem",
|
|
24
15
|
getAndDelete: "getAndDeleteItem",
|
|
@@ -61,10 +52,9 @@ const otherOptionalDriverMethods = {
|
|
|
61
52
|
"setItemRaw"
|
|
62
53
|
]
|
|
63
54
|
};
|
|
64
|
-
const batchDriverMethods = /* @__PURE__ */ new Set(["getItems", "setItems"]);
|
|
65
55
|
const lazyOptionalDriverMethods = Object.fromEntries(Object.entries(driverAtomicOperations).map(([driver, operations]) => [driver, /* @__PURE__ */ new Set([...Object.keys(operations).map((operation) => atomicDriverMethods[operation]), ...otherOptionalDriverMethods[driver] ?? []])]));
|
|
66
56
|
async function createDatabaseDriver(store, loadDatabases) {
|
|
67
|
-
const { default: factory, kvSqlClientFromDatabase } = await import("./database-
|
|
57
|
+
const { default: factory, kvSqlClientFromDatabase } = await import("./database-CtQO7n6H.js");
|
|
68
58
|
return factory(store, async () => {
|
|
69
59
|
const entry = loadDatabases ? (await loadDatabases())[store.database] : void 0;
|
|
70
60
|
if (!entry) throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
|
|
@@ -79,7 +69,7 @@ async function createRuntimeDriver(store, loadDatabases) {
|
|
|
79
69
|
case "cloudflare": {
|
|
80
70
|
const { localBase } = store;
|
|
81
71
|
if (localBase) {
|
|
82
|
-
const { default: factory } = await import("./cloudflare-kv-local-
|
|
72
|
+
const { default: factory } = await import("./cloudflare-kv-local-qb92SO8d.js");
|
|
83
73
|
return factory({
|
|
84
74
|
...store,
|
|
85
75
|
localBase
|
|
@@ -90,11 +80,11 @@ async function createRuntimeDriver(store, loadDatabases) {
|
|
|
90
80
|
}
|
|
91
81
|
case "database": return createDatabaseDriver(store, loadDatabases);
|
|
92
82
|
case "deno-kv": {
|
|
93
|
-
const { default: factory } = await import("./deno-kv-
|
|
83
|
+
const { default: factory } = await import("./deno-kv-ClGWU3yO.js");
|
|
94
84
|
return factory(store);
|
|
95
85
|
}
|
|
96
86
|
case "fs-lite": {
|
|
97
|
-
const { default: factory } = await import("./fs-lite-
|
|
87
|
+
const { default: factory } = await import("./fs-lite-D33j4kWD.js");
|
|
98
88
|
return factory(store);
|
|
99
89
|
}
|
|
100
90
|
case "redis": {
|
|
@@ -124,30 +114,38 @@ function createLazyKVRuntimeDriver(config, loadDatabases) {
|
|
|
124
114
|
});
|
|
125
115
|
return pending;
|
|
126
116
|
}
|
|
127
|
-
const
|
|
117
|
+
const optionalMethods = lazyOptionalDriverMethods[config.store.driver];
|
|
118
|
+
return {
|
|
128
119
|
name: `lazy:${config.store.driver}`,
|
|
129
|
-
options: config.store
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
120
|
+
options: config.store,
|
|
121
|
+
clear: async (base, options) => (await resolve()).clear?.(base, options),
|
|
122
|
+
getItem: async (key, options) => (await resolve()).getItem(key, options),
|
|
123
|
+
getItems: async (items, options) => {
|
|
124
|
+
const resolved = await resolve();
|
|
125
|
+
return (resolved.getItems ?? getItemsOneByOne(resolved))(items, options);
|
|
126
|
+
},
|
|
127
|
+
getKeys: async (base, options) => (await resolve()).getKeys(base, options),
|
|
128
|
+
hasItem: async (key, options) => (await resolve()).hasItem(key, options),
|
|
129
|
+
listKeys: async (options) => (await resolve()).listKeys(options),
|
|
130
|
+
removeItem: async (key, options) => (await resolve()).removeItem?.(key, options),
|
|
131
|
+
setItem: async (key, value, options) => (await resolve()).setItem?.(key, value, options),
|
|
132
|
+
setItems: async (items, options) => {
|
|
133
|
+
const resolved = await resolve();
|
|
134
|
+
return (resolved.setItems ?? setItemsOneByOne(resolved))(items, options);
|
|
135
|
+
},
|
|
136
|
+
dispose: async () => {
|
|
135
137
|
disposed = true;
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const driver = await resolve();
|
|
148
|
-
return driver[prop]?.apply(driver, args);
|
|
149
|
-
};
|
|
150
|
-
} });
|
|
138
|
+
if (driverPromise) await (await driverPromise).dispose?.();
|
|
139
|
+
},
|
|
140
|
+
getItemRaw: optionalMethods.has("getItemRaw") ? async (key, options) => (await resolve()).getItemRaw?.(key, options) : void 0,
|
|
141
|
+
getMeta: optionalMethods.has("getMeta") ? async (key, options) => (await resolve()).getMeta?.(key, options) ?? null : void 0,
|
|
142
|
+
setItemRaw: optionalMethods.has("setItemRaw") ? async (key, value, options) => (await resolve()).setItemRaw?.(key, value, options) : void 0,
|
|
143
|
+
validateBatch: optionalMethods.has("validateBatch") ? async (items, removals, options) => (await resolve()).validateBatch(items, removals, options) : void 0,
|
|
144
|
+
deleteIfEqualsItem: optionalMethods.has("deleteIfEqualsItem") ? async (key, expected) => (await resolve()).deleteIfEqualsItem(key, expected) : void 0,
|
|
145
|
+
getAndDeleteItem: optionalMethods.has("getAndDeleteItem") ? async (key) => (await resolve()).getAndDeleteItem(key) : void 0,
|
|
146
|
+
incrementItem: optionalMethods.has("incrementItem") ? async (key, ttl) => (await resolve()).incrementItem(key, ttl) : void 0,
|
|
147
|
+
setIfAbsentItem: optionalMethods.has("setIfAbsentItem") ? async (key, value, ttl) => (await resolve()).setIfAbsentItem(key, value, ttl) : void 0
|
|
148
|
+
};
|
|
151
149
|
}
|
|
152
150
|
// src/runtime/hosted-storage.ts
|
|
153
151
|
function assertHostedConfig(config) {
|
|
@@ -171,7 +169,7 @@ function serializeValue(value, operation = "setIfAbsent") {
|
|
|
171
169
|
if (value && typeof value === "object") {
|
|
172
170
|
const prototype = Object.getPrototypeOf(value);
|
|
173
171
|
if (prototype === null || prototype === Object.prototype) return serializeJSONValue(value, operation);
|
|
174
|
-
const toJSON =
|
|
172
|
+
const toJSON = "toJSON" in value ? value.toJSON : void 0;
|
|
175
173
|
if (typeof toJSON === "function") return serializeValue(toJSON.call(value), operation);
|
|
176
174
|
}
|
|
177
175
|
throw kvErrorDiagnostics.KV_INVALID_VALUE({
|
|
@@ -218,23 +216,23 @@ function createHostedKVStorage(config, name = "default", loadDatabases) {
|
|
|
218
216
|
[name]: store
|
|
219
217
|
}
|
|
220
218
|
}, loadDatabases);
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
219
|
+
const base = createKVStorage$1(driver);
|
|
220
|
+
const { getAndDeleteItem, incrementItem, setIfAbsentItem, deleteIfEqualsItem } = driver;
|
|
221
|
+
return {
|
|
222
|
+
...base,
|
|
223
|
+
getMany: base.getMany,
|
|
224
|
+
listKeys: (options) => driver.listKeys({
|
|
225
|
+
...options,
|
|
226
|
+
prefix: normalizeKVListPrefix(options.prefix)
|
|
227
|
+
}),
|
|
228
|
+
getAndDeleteItem: getAndDeleteItem && (async (key, options) => {
|
|
229
|
+
const value = await getAndDeleteItem(normalizeKey(key));
|
|
230
|
+
return options?.type === "text" ? value : deserializeValue(value);
|
|
231
|
+
}),
|
|
232
|
+
incrementItem: incrementItem && ((key, ttl) => incrementItem(normalizeKey(key), ttl)),
|
|
233
|
+
setIfAbsentItem: setIfAbsentItem && (async (key, value, ttl) => setIfAbsentItem(normalizeKey(key), serializeValue(value), ttl)),
|
|
234
|
+
deleteIfEqualsItem: deleteIfEqualsItem && (async (key, expected) => deleteIfEqualsItem(normalizeKey(key), serializeValue(expected, "deleteIfEquals")))
|
|
231
235
|
};
|
|
232
|
-
if (incrementItem) storage.incrementItem = (key, ttl) => incrementItem(normalizeKey(key), ttl);
|
|
233
|
-
const setIfAbsentItem = driver.setIfAbsentItem;
|
|
234
|
-
if (setIfAbsentItem) storage.setIfAbsentItem = async (key, value, ttl) => setIfAbsentItem(normalizeKey(key), serializeValue(value), ttl);
|
|
235
|
-
const deleteIfEqualsItem = driver.deleteIfEqualsItem;
|
|
236
|
-
if (deleteIfEqualsItem) storage.deleteIfEqualsItem = async (key, expected) => deleteIfEqualsItem(normalizeKey(key), serializeValue(expected, "deleteIfEquals"));
|
|
237
|
-
return storage;
|
|
238
236
|
}
|
|
239
237
|
// src/runtime/lock.ts
|
|
240
238
|
const firstRetryMs = 25;
|
|
@@ -1,18 +1,12 @@
|
|
|
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-C7c-Bfrl.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
|
|
7
7
|
const unsupported = () => kvErrorDiagnostics.KV_VALUE_UNSUPPORTED();
|
|
8
8
|
function isUint8Array(value) {
|
|
9
|
-
|
|
10
|
-
if (!ArrayBuffer.isView(value)) return false;
|
|
11
|
-
const tagGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag)?.get;
|
|
12
|
-
return Boolean(tagGetter && Reflect.apply(tagGetter, value, []) === "Uint8Array");
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
9
|
+
return ArrayBuffer.isView(value) && Object.prototype.toString.call(value) === "[object Uint8Array]";
|
|
16
10
|
}
|
|
17
11
|
function kvValueType(value) {
|
|
18
12
|
if (value === null) return "null";
|
|
@@ -32,21 +26,20 @@ function inspectValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
32
26
|
if (typeof value !== "object" && typeof value !== "function" || seen.has(value)) throw unsupported();
|
|
33
27
|
seen.add(value);
|
|
34
28
|
try {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
if (dataKeys.map((key) => Object.getOwnPropertyDescriptor(value, key)).some((descriptor) => !descriptor?.enumerable || !("value" in descriptor))) throw unsupported();
|
|
29
|
+
const keys = Object.keys(value);
|
|
30
|
+
if (Object.getOwnPropertyNames(value).length - keys.length - (Array.isArray(value) ? 1 : 0) !== 0 || Object.getOwnPropertySymbols(value).length) throw unsupported();
|
|
38
31
|
if (Array.isArray(value)) {
|
|
39
|
-
if (
|
|
40
|
-
return
|
|
32
|
+
if (keys.length !== value.length || keys.some((key, index) => key !== String(index))) throw unsupported();
|
|
33
|
+
return value.map((item) => inspectValue(item, seen));
|
|
41
34
|
}
|
|
42
35
|
const prototype = Object.getPrototypeOf(value);
|
|
43
|
-
if (prototype !== Object.prototype && prototype !== null
|
|
44
|
-
return Object.fromEntries(
|
|
36
|
+
if (prototype !== Object.prototype && prototype !== null) throw unsupported();
|
|
37
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, inspectValue(item, seen)]));
|
|
45
38
|
} finally {
|
|
46
39
|
seen.delete(value);
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
|
-
/** Encodes
|
|
42
|
+
/** Encodes a stored value as JSON data or Base64 bytes for inspection. */
|
|
50
43
|
function inspectKVValue(value) {
|
|
51
44
|
try {
|
|
52
45
|
if (isUint8Array(value)) return {
|
|
@@ -59,7 +52,7 @@ function inspectKVValue(value) {
|
|
|
59
52
|
value: inspectValue(value)
|
|
60
53
|
};
|
|
61
54
|
} catch (error) {
|
|
62
|
-
if (
|
|
55
|
+
if (error instanceof Error && "code" in error && error.code === "KV_VALUE_UNSUPPORTED") return;
|
|
63
56
|
throw error;
|
|
64
57
|
}
|
|
65
58
|
}
|
|
@@ -123,7 +116,7 @@ function boundedJSONStringify(value) {
|
|
|
123
116
|
}
|
|
124
117
|
if (typeof input === "bigint") {
|
|
125
118
|
editable = false;
|
|
126
|
-
const toJSON =
|
|
119
|
+
const toJSON = Object(input).toJSON;
|
|
127
120
|
if (applyToJSON && typeof toJSON === "function") return serialize(toJSON.call(input, key), depth, arrayValue, key, false);
|
|
128
121
|
unsupported = true;
|
|
129
122
|
return false;
|
|
@@ -131,16 +124,16 @@ function boundedJSONStringify(value) {
|
|
|
131
124
|
const object = Object(input);
|
|
132
125
|
const prototype = Object.getPrototypeOf(object);
|
|
133
126
|
if (Array.isArray(object) ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) editable = false;
|
|
134
|
-
const keys =
|
|
135
|
-
if (
|
|
127
|
+
const keys = Object.keys(object);
|
|
128
|
+
if (Object.getOwnPropertySymbols(object).length || Object.getOwnPropertyNames(object).length !== keys.length + (Array.isArray(object) ? 1 : 0)) editable = false;
|
|
136
129
|
if (Array.isArray(object) && keys.length !== object.length) editable = false;
|
|
137
|
-
const toJSON =
|
|
130
|
+
const toJSON = object.toJSON;
|
|
138
131
|
if (applyToJSON && typeof toJSON === "function") {
|
|
139
132
|
editable = false;
|
|
140
133
|
const replacement = toJSON.call(input, key);
|
|
141
134
|
if (replacement !== input) return serialize(replacement, depth, arrayValue, key, false);
|
|
142
135
|
}
|
|
143
|
-
const boxed = input instanceof Number || input instanceof String || input instanceof Boolean || Object.prototype.toString.call(input) === "[object BigInt]" ?
|
|
136
|
+
const boxed = input instanceof Number || input instanceof String || input instanceof Boolean || Object.prototype.toString.call(input) === "[object BigInt]" ? object.valueOf() : input;
|
|
144
137
|
if (boxed !== input) {
|
|
145
138
|
editable = false;
|
|
146
139
|
return serialize(boxed, depth, arrayValue, key);
|
|
@@ -166,9 +159,9 @@ function boundedJSONStringify(value) {
|
|
|
166
159
|
let count = 0;
|
|
167
160
|
for (const key in object) {
|
|
168
161
|
if (!Object.prototype.hasOwnProperty.call(object, key)) continue;
|
|
169
|
-
let item =
|
|
162
|
+
let item = object[key];
|
|
170
163
|
if (item !== null && (typeof item === "object" || typeof item === "bigint")) {
|
|
171
|
-
const toJSON =
|
|
164
|
+
const toJSON = Object(item).toJSON;
|
|
172
165
|
if (typeof toJSON === "function") {
|
|
173
166
|
editable = false;
|
|
174
167
|
item = toJSON.call(item, key);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
|
|
2
2
|
import { t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
3
|
+
import "node:module";
|
|
3
4
|
import { readdir } from "node:fs/promises";
|
|
4
5
|
import { basename, dirname, join, parse, relative, resolve } from "node:path";
|
|
5
6
|
import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
7
|
import { createInterface } from "node:readline/promises";
|
|
8
|
+
import "node:url";
|
|
7
9
|
import { defineDiagnostics } from "nostics";
|
|
8
10
|
import { tmpdir } from "node:os";
|
|
9
|
-
import "node:url";
|
|
10
11
|
import { createBirpc } from "birpc";
|
|
11
12
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
12
13
|
// ../internal/src/error-diagnostics.ts
|
|
@@ -761,7 +762,6 @@ function base64url(bytes) {
|
|
|
761
762
|
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
762
763
|
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
763
764
|
}
|
|
764
|
-
/** The bytes of a base64url value, or `undefined` when it is not canonical base64url without padding. */
|
|
765
765
|
function fromBase64url(value) {
|
|
766
766
|
if (!/^[\w-]*$/.test(value) || value.length % 4 === 1) return void 0;
|
|
767
767
|
const bytes = Uint8Array.from(atob(value.replace(/-/g, "+").replace(/_/g, "/")), (character) => character.charCodeAt(0));
|
|
@@ -788,7 +788,6 @@ function consoleSignedText(fields) {
|
|
|
788
788
|
fields.caller
|
|
789
789
|
].join("\n");
|
|
790
790
|
}
|
|
791
|
-
/** The path and query of a URL, the part of the request target that the signature covers. */
|
|
792
791
|
function requestTarget(url) {
|
|
793
792
|
return `${url.pathname}${url.search}`;
|
|
794
793
|
}
|
package/dist/operations.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-mNN-HppH.js";
|
|
2
2
|
import { t as kvDevMaximumListLimit } from "./results-emgN7uDS.js";
|
|
3
|
-
import { n as isViteHubLoopbackPeer } from "./dev-peer-
|
|
3
|
+
import { n as isViteHubLoopbackPeer } from "./dev-peer-CpFxuBAP.js";
|
|
4
4
|
import * as v from "valibot";
|
|
5
5
|
// ../internal/src/secret.ts
|
|
6
6
|
const secretEncoder = new TextEncoder();
|
|
@@ -34,11 +34,6 @@ function rejectDevRequest(rejection) {
|
|
|
34
34
|
const fileOrExtensionProtocol = /^(?:file|.+-extension):/i;
|
|
35
35
|
const ipv4Octet = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)";
|
|
36
36
|
const ipv4Literal = new RegExp(`^${ipv4Octet}(?:\\.${ipv4Octet}){3}$`);
|
|
37
|
-
/**
|
|
38
|
-
* Tests IP literals like `node:net` `isIP`, without a Node import, so the Nitro-side check also runs in Worker
|
|
39
|
-
* runtimes. IPv4 uses the Node pattern (dotted decimal, no leading zeros). IPv6 uses the WHATWG URL parser, which
|
|
40
|
-
* rejects zone IDs. Browsers do not send zone IDs in `Host`.
|
|
41
|
-
*/
|
|
42
37
|
function isIPv4Literal(value) {
|
|
43
38
|
return ipv4Literal.test(value);
|
|
44
39
|
}
|
|
@@ -102,12 +97,10 @@ function readPath(value, ...path) {
|
|
|
102
97
|
for (const key of path) value = value !== null && typeof value === "object" ? Reflect.get(value, key) : void 0;
|
|
103
98
|
return value;
|
|
104
99
|
}
|
|
105
|
-
/** The Cloudflare bindings of a Request: from the Standard Context that Nitro sets, else where srvx puts them. */
|
|
106
100
|
function requestEnv(request) {
|
|
107
101
|
const env = readPath(request, "~standard", "runtime", "cloudflare", "env") ?? readPath(request, "runtime", "cloudflare", "env");
|
|
108
102
|
return env !== null && typeof env === "object" ? env : void 0;
|
|
109
103
|
}
|
|
110
|
-
/** The `waitUntil` of a Request: from its Standard Context, else from the Request or its Worker ExecutionContext. */
|
|
111
104
|
function requestWaitUntil(request) {
|
|
112
105
|
for (const owner of [
|
|
113
106
|
readPath(request, "~standard"),
|
|
@@ -235,7 +228,7 @@ function createStandaloneOperationHandler(sources, root) {
|
|
|
235
228
|
} };
|
|
236
229
|
}
|
|
237
230
|
// src/operations.ts
|
|
238
|
-
const runtime = () => import("./operations-
|
|
231
|
+
const runtime = () => import("./operations-CbpFdf91.js");
|
|
239
232
|
const store = v.optional(v.pipe(v.string(), v.check((name) => name.trim() !== "", "Name a store.")));
|
|
240
233
|
const key = v.string();
|
|
241
234
|
function defineKVOperation(definition) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as KVRuntimeDriver } from "../driver-
|
|
1
|
+
import { t as KVRuntimeDriver } from "../driver-CZTAQ_07.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-CkrnHHnv.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as installCloudflareRequestEnv } from "../cloudflare-env-
|
|
1
|
+
import { n as installCloudflareRequestEnv } from "../cloudflare-env-JD7uO5-i.js";
|
|
2
2
|
// src/runtime/cloudflare-request-env.ts
|
|
3
3
|
/**
|
|
4
4
|
* Nitro middleware for Cloudflare KV. A Cloudflare KV store reads its binding from the active env, and only the request
|
|
@@ -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-CZ4CZy9h.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
1
|
import { z as ResolvedRedisKVStoreConfig } from "../types-BLxnI_rU.js";
|
|
2
|
-
import { t as KVRuntimeDriver } from "../driver-
|
|
2
|
+
import { t as KVRuntimeDriver } from "../driver-CZTAQ_07.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-C7c-Bfrl.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-DIUSIQAC.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. */
|
|
@@ -92,9 +92,7 @@ function createRedisKVDriver(options) {
|
|
|
92
92
|
async setIfAbsentItem(key, value, ttl) {
|
|
93
93
|
return (ttl === void 0 ? await client.set(prefixed(key), value, "NX") : await client.set(prefixed(key), value, "PX", ttlMilliseconds(ttl), "NX")) === "OK";
|
|
94
94
|
},
|
|
95
|
-
async
|
|
96
|
-
return await client.getdel(prefixed(key));
|
|
97
|
-
},
|
|
95
|
+
getAndDeleteItem: async (key) => await client.getdel(prefixed(key)),
|
|
98
96
|
incrementItem: async (key, ttl) => redisIncrementResult(await client.eval(redisIncrementScript, 1, prefixed(key), redisTTLSeconds(ttl))),
|
|
99
97
|
deleteIfEqualsItem: async (key, expected) => Number(await client.eval(redisDeleteIfEqualsScript, 1, prefixed(key), expected)) === 1,
|
|
100
98
|
listKeys: createPortableRedisKeyLister("Redis KV", async (cursor, match, count) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { B as ResolvedUpstashKVStoreConfig } from "../types-BLxnI_rU.js";
|
|
2
|
-
import { t as KVRuntimeDriver } from "../driver-
|
|
2
|
+
import { t as KVRuntimeDriver } from "../driver-CZTAQ_07.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-C7c-Bfrl.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-DIUSIQAC.js";
|
|
6
6
|
import createDriver from "unstorage/drivers/upstash";
|
|
7
7
|
// src/runtime/upstash-driver.ts
|
|
8
8
|
const keyBatchSize = 1e3;
|
|
@@ -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-CZ4CZy9h.js";
|
|
2
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-C7c-Bfrl.js";
|
|
3
3
|
// src/runtime/upstash.ts
|
|
4
4
|
function isMaskedValue(value) {
|
|
5
5
|
return !value || /^\*+$/.test(value);
|
package/dist/vite.d.ts
CHANGED
|
@@ -149,6 +149,7 @@ export interface KVVitePluginAPI {
|
|
|
149
149
|
deploymentEnv: DeploymentEnvContribution;
|
|
150
150
|
getConfig: () => KVViteRuntimeConfig;
|
|
151
151
|
getBuildConfig: () => KVViteRuntimeConfig;
|
|
152
|
+
whenConfigResolved: () => Promise<void> | undefined;
|
|
152
153
|
}
|
|
153
154
|
export type KVVitePlugin = Plugin & {
|
|
154
155
|
api: KVVitePluginAPI;
|