@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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as kvErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
|
|
2
2
|
import { link, lstat, mkdir, mkdtemp, opendir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import { basename, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import createDriver from "unstorage/drivers/fs-lite";
|
|
5
5
|
import { createHash, randomUUID } from "node:crypto";
|
|
6
6
|
import { lock } from "proper-lockfile";
|
|
7
|
-
|
|
7
|
+
// src/runtime/continuations.ts
|
|
8
8
|
/** Owns process-local cursor retention. Taking a cursor transfers its resource to the caller. */
|
|
9
9
|
function createKVContinuations(options) {
|
|
10
10
|
const entries = /* @__PURE__ */ new Map();
|
|
@@ -65,8 +65,7 @@ function createKVContinuations(options) {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
//#region src/runtime/fs-lite.ts
|
|
68
|
+
// src/runtime/fs-lite.ts
|
|
70
69
|
const temporaryFile = /^\.unstorage-tmp-[\da-z-]+$/;
|
|
71
70
|
const layoutRecord = /^\.unstorage-tmp-vitehub-layout-v1(?:-\d+)?$/;
|
|
72
71
|
const layoutRecordName = ".unstorage-tmp-vitehub-layout-v1";
|
|
@@ -382,5 +381,4 @@ async function createFsLiteKVDriver(options) {
|
|
|
382
381
|
}
|
|
383
382
|
return driver;
|
|
384
383
|
}
|
|
385
|
-
//#endregion
|
|
386
384
|
export { createFsLiteKVDriver as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +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-
|
|
2
|
-
//#region src/runtime/storage.d.ts
|
|
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-CPDL9enF.js";
|
|
3
2
|
/** Releases every cached store. Call from the application's shutdown hook after stopping new work. */
|
|
4
3
|
export declare function disposeKVStores(): Promise<void>;
|
|
5
4
|
/**
|
|
@@ -8,5 +7,4 @@ export declare function disposeKVStores(): Promise<void>;
|
|
|
8
7
|
*/
|
|
9
8
|
export declare function getKVStoreDriver(name?: KVStoreName): Promise<KVDriver>;
|
|
10
9
|
export declare const kv: KVStorage;
|
|
11
|
-
//#endregion
|
|
12
10
|
export type { CloudflareKVStoreConfig, DatabaseKVStoreConfig, DenoKVStoreConfig, FsLiteKVStoreConfig, InferredKVStoreConfig, KVAtomicOperation, KVClearOptions, KVDriver, KVDriverAtomicOperations, KVDriversWith, KVEntry, KVErrorCode, KVGetOptions, KVGetType, KVGetTypeMap, KVListOptions, KVListPage, KVLock, KVLockAcquisition, KVLockErrorCode, KVLockOptions, KVLockRunResult, KVOperation, KVOptions, KVSetOptions, KVStorage, KVStoreConfig, KVStoreOptions, ReadonlyKVStorage, RedisKVStoreConfig, ResolvedCloudflareKVStoreConfig, ResolvedDatabaseKVStoreConfig, ResolvedDenoKVStoreConfig, ResolvedFsLiteKVStoreConfig, ResolvedKVModuleOptions, ResolvedKVStoreConfig, ResolvedRedisKVStoreConfig, ResolvedUpstashKVStoreConfig, UpstashKVStoreConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { r as
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { t as logFailure } from "./request-log-
|
|
1
|
+
import { r as normalizeKVOptions, s as readEnv } from "./config-_1oBDv2R.js";
|
|
2
|
+
import { n as getActiveCloudflareEnv } from "./cloudflare-env-lookup-Dgq5n1Aq.js";
|
|
3
|
+
import { a as kvResult, d as listKVKeys, f as kvStoreWithMode, i as kvListLimitInvalid, o as kvSetCodes, p as ttlSeconds, r as kvKeyLimitCodes, s as kvSetTTL, t as kvClearOptionsError } from "./errors-CJoAP4Bu.js";
|
|
4
|
+
import { o as normalizeKey } from "./utils2-By8eee1x.js";
|
|
5
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
|
|
6
|
+
import { t as resolveRuntimeKVOptions } from "./upstash-DeM3_U5H.js";
|
|
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-DbWVAY9l.js";
|
|
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
13
|
const lazyDriverMethods = /* @__PURE__ */ new Set([
|
|
14
14
|
"clear",
|
|
15
15
|
"getItem",
|
|
@@ -59,7 +59,7 @@ const otherOptionalDriverMethods = {
|
|
|
59
59
|
const batchDriverMethods = /* @__PURE__ */ new Set(["getItems", "setItems"]);
|
|
60
60
|
const lazyOptionalDriverMethods = Object.fromEntries(Object.entries(driverAtomicOperations).map(([driver, operations]) => [driver, /* @__PURE__ */ new Set([...Object.keys(operations).map((operation) => atomicDriverMethods[operation]), ...otherOptionalDriverMethods[driver] ?? []])]));
|
|
61
61
|
async function createDatabaseDriver(store, loadDatabases) {
|
|
62
|
-
const { default: factory, kvSqlClientFromDatabase } = await import("./
|
|
62
|
+
const { default: factory, kvSqlClientFromDatabase } = await import("./database-4iAg2GoV.js");
|
|
63
63
|
return factory(store, async () => {
|
|
64
64
|
const entry = loadDatabases ? (await loadDatabases())[store.database] : void 0;
|
|
65
65
|
if (!entry) throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
|
|
@@ -74,7 +74,7 @@ async function createRuntimeDriver(store, loadDatabases) {
|
|
|
74
74
|
case "cloudflare": {
|
|
75
75
|
const { localBase } = store;
|
|
76
76
|
if (localBase) {
|
|
77
|
-
const { default: factory } = await import("./cloudflare-kv-local-
|
|
77
|
+
const { default: factory } = await import("./cloudflare-kv-local-COoOI34K.js");
|
|
78
78
|
return factory({
|
|
79
79
|
...store,
|
|
80
80
|
localBase
|
|
@@ -85,11 +85,11 @@ async function createRuntimeDriver(store, loadDatabases) {
|
|
|
85
85
|
}
|
|
86
86
|
case "database": return createDatabaseDriver(store, loadDatabases);
|
|
87
87
|
case "deno-kv": {
|
|
88
|
-
const { default: factory } = await import("./deno-kv-
|
|
88
|
+
const { default: factory } = await import("./deno-kv-CatE7zSS.js");
|
|
89
89
|
return factory(store);
|
|
90
90
|
}
|
|
91
91
|
case "fs-lite": {
|
|
92
|
-
const { default: factory } = await import("./fs-lite-
|
|
92
|
+
const { default: factory } = await import("./fs-lite-DwbPkc-C.js");
|
|
93
93
|
return factory(store);
|
|
94
94
|
}
|
|
95
95
|
case "redis": {
|
|
@@ -144,8 +144,7 @@ function createLazyKVRuntimeDriver(config, loadDatabases) {
|
|
|
144
144
|
};
|
|
145
145
|
} });
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
//#region src/runtime/hosted-storage.ts
|
|
147
|
+
// src/runtime/hosted-storage.ts
|
|
149
148
|
function assertHostedConfig(config) {
|
|
150
149
|
if (!config) throw kvErrorDiagnostics.KV_DISABLED();
|
|
151
150
|
return config;
|
|
@@ -232,8 +231,7 @@ function createHostedKVStorage(config, name = "default", loadDatabases) {
|
|
|
232
231
|
if (deleteIfEqualsItem) storage.deleteIfEqualsItem = async (key, expected) => deleteIfEqualsItem(normalizeKey(key), serializeValue(expected, "deleteIfEquals"));
|
|
233
232
|
return storage;
|
|
234
233
|
}
|
|
235
|
-
|
|
236
|
-
//#region src/runtime/lock.ts
|
|
234
|
+
// src/runtime/lock.ts
|
|
237
235
|
const firstRetryMs = 25;
|
|
238
236
|
const maxRetryMs = 500;
|
|
239
237
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -308,8 +306,7 @@ function createKVLock(store, resolveStorage, key, options) {
|
|
|
308
306
|
}
|
|
309
307
|
};
|
|
310
308
|
}
|
|
311
|
-
|
|
312
|
-
//#region src/runtime/storage.ts
|
|
309
|
+
// src/runtime/storage.ts
|
|
313
310
|
const storagePromises = /* @__PURE__ */ new Map();
|
|
314
311
|
let disposal;
|
|
315
312
|
/** Releases every cached store. Call from the application's shutdown hook after stopping new work. */
|
|
@@ -476,5 +473,4 @@ function selectKVStore(name, options) {
|
|
|
476
473
|
return kvStoreWithMode(createKVStorage(name), options);
|
|
477
474
|
}
|
|
478
475
|
const kv = createKVStorage();
|
|
479
|
-
//#endregion
|
|
480
476
|
export { disposeKVStores, getKVStoreDriver, kv };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
2
2
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
3
3
|
function normalizeWindowsPath(input = "") {
|
|
4
4
|
if (!input) return input;
|
|
@@ -95,8 +95,7 @@ const dirname = function(p) {
|
|
|
95
95
|
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
96
96
|
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
97
97
|
};
|
|
98
|
-
|
|
99
|
-
//#region ../internal/src/inspect.ts
|
|
98
|
+
// ../internal/src/inspect.ts
|
|
100
99
|
function relativeDefinitionFile(projectRoot, file) {
|
|
101
100
|
return relative(projectRoot, file).replaceAll("\\", "/");
|
|
102
101
|
}
|
|
@@ -114,5 +113,4 @@ const embeddedSecretAssignmentPattern = new RegExp(String.raw`\b([\w-]*(?:${secr
|
|
|
114
113
|
function redactInspectionText(value) {
|
|
115
114
|
return value.replace(embeddedUrlCredentialPattern, `$1${redactedInspectionValue}@`).replace(embeddedAuthorizationPattern, `$1${redactedInspectionValue}`).replace(embeddedCookiePattern, `$1${redactedInspectionValue}`).replace(embeddedBearerPattern, `Bearer ${redactedInspectionValue}`).replace(embeddedSecretAssignmentPattern, `$1${redactedInspectionValue}`);
|
|
116
115
|
}
|
|
117
|
-
//#endregion
|
|
118
116
|
export { resolve as a, relative as i, relativeDefinitionFile as n, dirname as r, redactInspectionText as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// ../internal/src/invariant.ts
|
|
3
3
|
const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
4
4
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
5
5
|
codes: { INTERNAL_INVARIANT_FAILED: {
|
|
@@ -18,5 +18,4 @@ function invariantError(what) {
|
|
|
18
18
|
function invariant(condition, what) {
|
|
19
19
|
if (!condition) throw invariantError(what);
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { invariantError as n, invariant as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../internal/src/object.ts
|
|
2
2
|
/** A non-null object that is not an array. Functions do not pass. */
|
|
3
3
|
function isRecord(value) {
|
|
4
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -7,5 +7,4 @@ function isRecord(value) {
|
|
|
7
7
|
function isRecordOrFunction(value) {
|
|
8
8
|
return Object(value) === value && !Array.isArray(value);
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { isRecordOrFunction as n, isRecord as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
2
1
|
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
3
2
|
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
4
3
|
/** The Standard properties. */
|
|
@@ -74,8 +73,6 @@ declare namespace StandardSchemaV1 {
|
|
|
74
73
|
/** Infers the output type of a Standard. */
|
|
75
74
|
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
75
|
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region ../internal/src/operation-definition.d.ts
|
|
79
76
|
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
|
|
80
77
|
type OperationKind = "read" | "write" | "destructive";
|
|
81
78
|
/** The signed-in user of a call. */
|
|
@@ -241,5 +238,4 @@ interface OperationContributionEntry {
|
|
|
241
238
|
/** `false`: the app already has these operations at runtime. Only tools such as the CLI and `vitehub inspect` read the entry. */
|
|
242
239
|
runtime?: false;
|
|
243
240
|
}
|
|
244
|
-
//#endregion
|
|
245
241
|
export { OperationContributionEntry as n, AnyOperation as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as isRecordOrFunction, t as isRecord } from "./object-
|
|
2
|
-
import { t as invariant } from "./invariant-
|
|
1
|
+
import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
|
|
2
|
+
import { t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
3
3
|
import { readdir } from "node:fs/promises";
|
|
4
4
|
import { basename, dirname, join, parse, relative, resolve } from "node:path";
|
|
5
5
|
import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -9,7 +9,7 @@ import { tmpdir } from "node:os";
|
|
|
9
9
|
import "node:url";
|
|
10
10
|
import { createBirpc } from "birpc";
|
|
11
11
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
12
|
-
|
|
12
|
+
// ../internal/src/error-diagnostics.ts
|
|
13
13
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
14
14
|
const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
15
15
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
@@ -266,6 +266,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
266
266
|
why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
|
|
267
267
|
fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
|
|
268
268
|
},
|
|
269
|
+
INTERNAL_SITE_TOKEN_TOO_LONG: {
|
|
270
|
+
why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
|
|
271
|
+
fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
|
|
272
|
+
},
|
|
269
273
|
INTERNAL_SQLITE_ARGUMENT_INVALID: {
|
|
270
274
|
why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
|
|
271
275
|
fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
|
|
@@ -280,8 +284,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
286
|
});
|
|
283
|
-
|
|
284
|
-
//#region ../internal/src/cli.ts
|
|
287
|
+
// ../internal/src/cli.ts
|
|
285
288
|
/**
|
|
286
289
|
* The seed files in `dir` and its subfolders, as sorted paths relative to `dir` with `/`. Files and folders whose name
|
|
287
290
|
* starts with `.`, such as `.gitkeep`, are not seed files. Returns `undefined` when `dir` does not exist.
|
|
@@ -418,8 +421,7 @@ function findViteHubDevServerUrl(roots, env) {
|
|
|
418
421
|
}
|
|
419
422
|
return env["VITEHUB_DEV_SERVER_URL"] || void 0;
|
|
420
423
|
}
|
|
421
|
-
|
|
422
|
-
//#region ../internal/src/build/vite.ts
|
|
424
|
+
// ../internal/src/build/vite.ts
|
|
423
425
|
const projectRootDirectoryMarkers = [
|
|
424
426
|
["server", "agents"],
|
|
425
427
|
["server", "channels"],
|
|
@@ -519,8 +521,7 @@ function isMissingProjectMarker(error) {
|
|
|
519
521
|
const code = error.code;
|
|
520
522
|
return code === "ENOENT" || code === "ENOTDIR";
|
|
521
523
|
}
|
|
522
|
-
|
|
523
|
-
//#region ../internal/src/operation-rpc.ts
|
|
524
|
+
// ../internal/src/operation-rpc.ts
|
|
524
525
|
/** Path of the operation RPC under the app. Dev servers and deployed apps serve it the same way, one birpc call per POST. */
|
|
525
526
|
const operationRpcPath = "/_vitehub/rpc";
|
|
526
527
|
const maximumIdLength = 128;
|
|
@@ -673,8 +674,7 @@ async function callOperationRpc(name, input, send) {
|
|
|
673
674
|
};
|
|
674
675
|
}
|
|
675
676
|
}
|
|
676
|
-
|
|
677
|
-
//#region ../internal/src/console-signature.ts
|
|
677
|
+
// ../internal/src/console-signature.ts
|
|
678
678
|
/**
|
|
679
679
|
* Signed requests to the Console endpoint of an app, `POST /_vitehub/rpc`. Each caller, such as one Console link or one
|
|
680
680
|
* CI job, has an Ed25519 key pair. The app keeps only the public keys, in `VITEHUB_CONSOLE_KEY_<NAME>`, so a copy of
|
|
@@ -803,8 +803,7 @@ function readConsoleSigningKey(env) {
|
|
|
803
803
|
privateKey
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
|
-
|
|
807
|
-
//#region ../internal/src/standard-schema.ts
|
|
806
|
+
// ../internal/src/standard-schema.ts
|
|
808
807
|
function readOwn(value, key) {
|
|
809
808
|
if (value === null || Object(value) !== value) return;
|
|
810
809
|
try {
|
|
@@ -833,8 +832,7 @@ function standardJsonSchema(schema, direction, target = "draft-2020-12", library
|
|
|
833
832
|
return;
|
|
834
833
|
}
|
|
835
834
|
}
|
|
836
|
-
|
|
837
|
-
//#region ../internal/src/valibot.ts
|
|
835
|
+
// ../internal/src/valibot.ts
|
|
838
836
|
const valibotTargets = /* @__PURE__ */ new Set([
|
|
839
837
|
"draft-07",
|
|
840
838
|
"draft-2020-12",
|
|
@@ -875,8 +873,7 @@ function withValibotJsonSchema(schema, options = {}) {
|
|
|
875
873
|
}
|
|
876
874
|
};
|
|
877
875
|
}
|
|
878
|
-
|
|
879
|
-
//#region ../internal/src/operation-definition.ts
|
|
876
|
+
// ../internal/src/operation-definition.ts
|
|
880
877
|
const nameFormat = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/;
|
|
881
878
|
const kinds = /* @__PURE__ */ new Set([
|
|
882
879
|
"read",
|
|
@@ -925,7 +922,8 @@ const reservedOperationNamespaces = [
|
|
|
925
922
|
"login",
|
|
926
923
|
"logout",
|
|
927
924
|
"update",
|
|
928
|
-
"whoami"
|
|
925
|
+
"whoami",
|
|
926
|
+
"apps"
|
|
929
927
|
]
|
|
930
928
|
];
|
|
931
929
|
/** Input keys that the generated CLI commands read themselves. */
|
|
@@ -966,8 +964,7 @@ function isSectionId(section) {
|
|
|
966
964
|
function operationInputJsonSchema(operation) {
|
|
967
965
|
return standardJsonSchema(operation.input, "input") ?? { type: "object" };
|
|
968
966
|
}
|
|
969
|
-
|
|
970
|
-
//#region ../internal/src/operations.ts
|
|
967
|
+
// ../internal/src/operations.ts
|
|
971
968
|
/** Header that proves the caller is not a browser page. A foreign page cannot send it without a CORS preflight. */
|
|
972
969
|
const operationRpcHeader = "x-vitehub-console";
|
|
973
970
|
/** Response header of the local dev RPC. Its value is {@link projectRootHash} of the project that the server runs. */
|
|
@@ -1298,7 +1295,7 @@ async function callOperation(target, name, input) {
|
|
|
1298
1295
|
const url = new URL(operationRpcPath.slice(1), base);
|
|
1299
1296
|
origin = url.origin;
|
|
1300
1297
|
const env = target.roots?.length ? {} : target.env;
|
|
1301
|
-
try {
|
|
1298
|
+
if (!target.authorization) try {
|
|
1302
1299
|
readConsoleSigningKey(env);
|
|
1303
1300
|
} catch (error) {
|
|
1304
1301
|
return {
|
|
@@ -1310,15 +1307,18 @@ async function callOperation(target, name, input) {
|
|
|
1310
1307
|
};
|
|
1311
1308
|
}
|
|
1312
1309
|
const outcome = await callOperationRpc(name, input ?? {}, async (body) => {
|
|
1313
|
-
const
|
|
1310
|
+
const signal = target.signal ?? AbortSignal.timeout(target.timeout ?? 3e4);
|
|
1311
|
+
const headers = target.authorization ? operationHeaders() : await signedOperationHeaders(env, url, body);
|
|
1312
|
+
if (target.authorization) headers.set("authorization", target.authorization);
|
|
1314
1313
|
if (target.confirmed !== void 0) headers.set(operationConfirmationHeader, target.confirmed ? "confirmed" : "required");
|
|
1315
1314
|
if (target.roots?.length) headers.set(operationExpectedRootsHeader, target.roots.map(projectRootHash).join(","));
|
|
1315
|
+
signal.throwIfAborted();
|
|
1316
1316
|
const response = await (target.fetch ?? fetch)(url.href, {
|
|
1317
1317
|
body,
|
|
1318
1318
|
headers,
|
|
1319
1319
|
method: "POST",
|
|
1320
1320
|
redirect: "manual",
|
|
1321
|
-
signal
|
|
1321
|
+
signal
|
|
1322
1322
|
});
|
|
1323
1323
|
const text = await response.text();
|
|
1324
1324
|
let json;
|
|
@@ -1355,7 +1355,7 @@ async function callOperation(target, name, input) {
|
|
|
1355
1355
|
} : void 0);
|
|
1356
1356
|
if (failure) {
|
|
1357
1357
|
if (target.roots?.length && failure.status === 401) failure.fix = `Pass --url ${base.href.slice(0, -1)} to send credentials. A command sends none to the dev server that it finds. ${failure.fix ?? "Set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key that `vitehub secret console-key` printed, and its public key in VITEHUB_CONSOLE_KEY_<NAME> on the app."}`;
|
|
1358
|
-
if ((failure.status === 401 || failure.status === 403) && !hasCredentials(env) && !failure.fix) failure.fix = target.roots?.length ? `Pass --url <origin> to send deployment credentials. ${operationCredentialHint}` : operationCredentialHint;
|
|
1358
|
+
if ((failure.status === 401 || failure.status === 403) && !target.authorization && !hasCredentials(env) && !failure.fix) failure.fix = target.roots?.length ? `Pass --url <origin> to send deployment credentials. ${operationCredentialHint}` : operationCredentialHint;
|
|
1359
1359
|
return {
|
|
1360
1360
|
ok: false,
|
|
1361
1361
|
...failure
|
|
@@ -1389,5 +1389,4 @@ async function callOperationFromCli(call, name, input) {
|
|
|
1389
1389
|
url
|
|
1390
1390
|
}, name, input);
|
|
1391
1391
|
}
|
|
1392
|
-
//#endregion
|
|
1393
1392
|
export { readViteHubDevTargetOption as A, resolveViteHubProjectRoot as C, parseCliPositiveInteger as D, listSeedFiles as E, writeCliFailure as M, writeViteHubDevServerFile as N, readCliOptionValue as O, internalErrorDiagnostics as P, markViteConfigPlugin as S, askOnTerminal as T, VITEHUB_PREPARE as _, operationRootHeader as a, hasNitroConfigContext as b, projectRootHash as c, defineOperation as d, answerOperationRpc as f, VITEHUB_NITRO_CONFIG_CONTEXT as g, readOperationRpcCall as h, createOperationRegistry as i, removeViteHubDevServerFile as j, readViteHubDevServerFile 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, shouldSkipViteProviderBuild as w, isServerEnvironment as x, createNoExternalAddition as y };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { o as normalizeKey } from "./utils2-By8eee1x.js";
|
|
2
|
+
import { t as redactInspectionText } from "./inspect-BWMcVWD8.js";
|
|
3
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
|
|
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
9
|
try {
|
|
@@ -63,8 +63,7 @@ function inspectKVValue(value) {
|
|
|
63
63
|
throw error;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
//#region src/runtime/preview.ts
|
|
66
|
+
// src/runtime/preview.ts
|
|
68
67
|
const maximumValueBytes = 262144;
|
|
69
68
|
function truncateValue(value) {
|
|
70
69
|
const encoder = new TextEncoder();
|
|
@@ -232,8 +231,7 @@ function previewKVValue(value) {
|
|
|
232
231
|
if (truncated || result.truncated) formatted.truncated = true;
|
|
233
232
|
return formatted;
|
|
234
233
|
}
|
|
235
|
-
|
|
236
|
-
//#region src/runtime/operations.ts
|
|
234
|
+
// src/runtime/operations.ts
|
|
237
235
|
function isMissingKVConfig(error) {
|
|
238
236
|
const code = error instanceof Error && "code" in error ? error.code : void 0;
|
|
239
237
|
const message = error instanceof Error ? error.message : "";
|
|
@@ -416,5 +414,4 @@ async function runOperation(operation, input, stores) {
|
|
|
416
414
|
}
|
|
417
415
|
}
|
|
418
416
|
}
|
|
419
|
-
//#endregion
|
|
420
417
|
export { listKVDevStores, runKVOperation };
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
//#region src/runtime/operations.d.ts
|
|
1
|
+
import { t as AnyOperation } from "./operation-definition-CqZkx1Rm.js";
|
|
2
|
+
import { c as KVDriver } from "./types-CPDL9enF.js";
|
|
4
3
|
interface KVDevListResult {
|
|
5
4
|
/** Present when more keys exist. Pass it as `--cursor` to read the next page. */
|
|
6
5
|
cursor?: string;
|
|
@@ -55,8 +54,6 @@ interface KVDevDeleteResult {
|
|
|
55
54
|
key: string;
|
|
56
55
|
store: string;
|
|
57
56
|
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region ../internal/src/operations-dev.d.ts
|
|
60
57
|
/**
|
|
61
58
|
* Bundled into owner packages and used only by their serve-only generated Nitro route. Operations get the Request as
|
|
62
59
|
* `context.event`, so owner hooks such as `identify` of Comments read its Standard Context.
|
|
@@ -67,9 +64,6 @@ export declare function createStandaloneOperationHandler(sources: {
|
|
|
67
64
|
}[], root: string): {
|
|
68
65
|
fetch(request: Request): Promise<Response>;
|
|
69
66
|
};
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/operations.d.ts
|
|
72
67
|
/** The `kv.*` operations: list, get, has, set, and delete. The Console, `vitehub kv`, and agents run them. */
|
|
73
68
|
export declare const kvOperations: readonly AnyOperation[];
|
|
74
|
-
//#endregion
|
|
75
69
|
export type { KVDevDeleteResult, KVDevGetResult, KVDevHasResult, KVDevListResult, KVDevSetResult };
|
package/dist/operations.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P 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-
|
|
2
|
-
import { t as kvDevMaximumListLimit } from "./results-
|
|
3
|
-
import { n as isViteHubLoopbackPeer } from "./dev-peer-
|
|
1
|
+
import { P 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-BkVt17cd.js";
|
|
2
|
+
import { t as kvDevMaximumListLimit } from "./results-emgN7uDS.js";
|
|
3
|
+
import { n as isViteHubLoopbackPeer } from "./dev-peer-D0vOxmrD.js";
|
|
4
4
|
import * as v from "valibot";
|
|
5
|
-
|
|
5
|
+
// ../internal/src/secret.ts
|
|
6
6
|
const secretEncoder = new TextEncoder();
|
|
7
7
|
/**
|
|
8
8
|
* Compares a request value with an expected secret in constant time for the length of `expected`. Returns `false`
|
|
@@ -17,8 +17,7 @@ function isViteHubSecretEqual(actual, expected) {
|
|
|
17
17
|
return difference === 0;
|
|
18
18
|
}
|
|
19
19
|
Object.freeze({ prefix: "sha256=" });
|
|
20
|
-
|
|
21
|
-
//#region ../internal/src/dev-endpoint.ts
|
|
20
|
+
// ../internal/src/dev-endpoint.ts
|
|
22
21
|
const viteHubDevRequestGrantBrand = Symbol("vitehub.devRequestGrant");
|
|
23
22
|
const devRequestGrants = /* @__PURE__ */ new WeakMap();
|
|
24
23
|
function grantDevRequest(request, label) {
|
|
@@ -98,8 +97,7 @@ async function validateViteHubNitroDevRequest(request, guard) {
|
|
|
98
97
|
const rejection = await guard.authorize?.(request);
|
|
99
98
|
return rejection ? rejectDevRequest(rejection) : grantDevRequest(request, guard.label);
|
|
100
99
|
}
|
|
101
|
-
|
|
102
|
-
//#region ../internal/src/operations-dev.ts
|
|
100
|
+
// ../internal/src/operations-dev.ts
|
|
103
101
|
function readPath(value, ...path) {
|
|
104
102
|
for (const key of path) value = value !== null && typeof value === "object" ? Reflect.get(value, key) : void 0;
|
|
105
103
|
return value;
|
|
@@ -236,9 +234,8 @@ function createStandaloneOperationHandler(sources, root) {
|
|
|
236
234
|
}
|
|
237
235
|
} };
|
|
238
236
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const runtime = () => import("./operations-CqKs7Ykc.js");
|
|
237
|
+
// src/operations.ts
|
|
238
|
+
const runtime = () => import("./operations-DSOTGwST.js");
|
|
242
239
|
const store = v.optional(v.pipe(v.string(), v.check((name) => name.trim() !== "", "Name a store.")));
|
|
243
240
|
const key = v.string();
|
|
244
241
|
function defineKVOperation(definition) {
|
|
@@ -315,5 +312,4 @@ const kvOperations = [
|
|
|
315
312
|
run: async (input) => await (await runtime()).runKVOperation("delete", input)
|
|
316
313
|
})
|
|
317
314
|
];
|
|
318
|
-
//#endregion
|
|
319
315
|
export { createStandaloneOperationHandler, kvOperations };
|