@vite-hub/kv 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -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-BpPaDG49.js} +2 -2
- package/dist/{config-_1oBDv2R.js → config-x_Nru3R5.js} +4 -4
- 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-D0NvYrhk.js} +66 -20
- package/dist/{deno-kv-CatE7zSS.js → deno-kv-DwcTL95B.js} +2 -2
- package/dist/{driver-BruahGvT.d.ts → driver-CZTAQ_07.d.ts} +2 -2
- 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-1n_Dvy4p.js} +195 -131
- package/dist/fs-lite-Co1NzxYo.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +79 -69
- package/dist/{operation-definition-CqZkx1Rm.d.ts → operations-BAlr2zUj.d.ts} +1 -0
- package/dist/{operations-DSOTGwST.js → operations-Cj_0pSSA.js} +22 -29
- package/dist/{operations-BkVt17cd.js → operations-DP8iWjQK.js} +75 -11
- 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 +3 -5
- 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-DINRYhXI.js} +2 -2
- package/dist/vite.d.ts +9 -5
- package/dist/vite.js +211 -75
- package/package.json +8 -4
- package/dist/fs-lite-DwbPkc-C.js +0 -1
package/dist/vite.js
CHANGED
|
@@ -3,17 +3,17 @@ import { n as invariantError, t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
|
3
3
|
import { a as resolve$1, i as relative$1, n as relativeDefinitionFile, r as dirname$1 } from "./inspect-BWMcVWD8.js";
|
|
4
4
|
import { t as addViteHubDevPeerDevHandler } from "./dev-peer-D0vOxmrD.js";
|
|
5
5
|
import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
|
|
6
|
-
import {
|
|
7
|
-
import { a as upstashUrlEnvNames, i as upstashTokenEnvNames, n as kvRedisEnvHint, o as resolveHostPreset, r as normalizeKVOptions } from "./config-
|
|
8
|
-
import { n as kvErrorDiagnostics } from "./error-diagnostics-
|
|
9
|
-
import { n as resolveUpstashRuntimeValues } from "./upstash-
|
|
6
|
+
import { A as readViteHubDevServerFile, C as markViteConfigPlugin, F as internalErrorDiagnostics, M as removeViteHubDevServerFile, P as writeViteHubDevServerFile, S as isServerEnvironment, T as shouldSkipViteProviderBuild, b as createNoExternalAddition, p as operationRpcPath, r as collectOperationContributions, v as VITEHUB_PROJECT_ROOT, w as resolveViteHubProjectRoot, x as hasNitroConfigContext, y as contributeServerEnv } from "./operations-DP8iWjQK.js";
|
|
7
|
+
import { a as upstashUrlEnvNames, i as upstashTokenEnvNames, n as kvRedisEnvHint, o as resolveHostPreset, r as normalizeKVOptions } from "./config-x_Nru3R5.js";
|
|
8
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-DAi25E6F.js";
|
|
9
|
+
import { n as resolveUpstashRuntimeValues } from "./upstash-DINRYhXI.js";
|
|
10
10
|
import { createRequire, isBuiltin } from "node:module";
|
|
11
11
|
import { access, copyFile, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
12
12
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
13
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
15
|
import { formatDiagnostic } from "nostics";
|
|
15
16
|
import { tmpdir } from "node:os";
|
|
16
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
17
17
|
import { createHash } from "node:crypto";
|
|
18
18
|
// ../internal/src/build/paths.ts
|
|
19
19
|
function resolveRuntimeModule(packageDir, modulePath) {
|
|
@@ -326,12 +326,32 @@ function mergeOwnedArrays(existing, value, arrays) {
|
|
|
326
326
|
const next = { ...value };
|
|
327
327
|
for (const [field, ownership] of Object.entries(arrays ?? {})) {
|
|
328
328
|
const incoming = Array.isArray(value[field]) ? value[field] : [];
|
|
329
|
-
const
|
|
329
|
+
const unowned = preserveUnownedKeyedArrayEntries(existing[field], ownership, incoming);
|
|
330
|
+
const merged = ownership.key !== void 0 && ownership.preserveOrder && Array.isArray(existing[field]) ? mergeOrderedEntries(existing[field], unowned, incoming, ownership.key) : [...unowned, ...incoming];
|
|
330
331
|
if (merged.length) next[field] = merged;
|
|
331
332
|
else delete next[field];
|
|
332
333
|
}
|
|
333
334
|
return next;
|
|
334
335
|
}
|
|
336
|
+
function mergeOrderedEntries(current, unowned, incoming, key) {
|
|
337
|
+
const preserved = new Set(unowned);
|
|
338
|
+
const replacements = new Map(incoming.flatMap((entry) => {
|
|
339
|
+
const identity = getKeyedArrayEntryValue(entry, key);
|
|
340
|
+
return identity === void 0 ? [] : [[identity, entry]];
|
|
341
|
+
}));
|
|
342
|
+
return [...current.flatMap((entry) => {
|
|
343
|
+
if (preserved.has(entry)) return [entry];
|
|
344
|
+
const identity = getKeyedArrayEntryValue(entry, key);
|
|
345
|
+
if (identity === void 0) return [];
|
|
346
|
+
const replacement = replacements.get(identity);
|
|
347
|
+
if (replacement === void 0) return [];
|
|
348
|
+
replacements.delete(identity);
|
|
349
|
+
return [replacement];
|
|
350
|
+
}), ...incoming.filter((entry) => {
|
|
351
|
+
const identity = getKeyedArrayEntryValue(entry, key);
|
|
352
|
+
return identity === void 0 || replacements.has(identity);
|
|
353
|
+
})];
|
|
354
|
+
}
|
|
335
355
|
async function persistProviderJsonRecord(file, value, removeIfEmpty) {
|
|
336
356
|
if (removeIfEmpty && !Object.keys(value).length) {
|
|
337
357
|
await rm(file, { force: true });
|
|
@@ -351,19 +371,31 @@ async function writeProviderOutputConfig(file, value, ownership = {}, options =
|
|
|
351
371
|
function mergeProviderOutputConfig(existing, value, ownership = {}) {
|
|
352
372
|
assertProviderJsonRecord(existing);
|
|
353
373
|
assertProviderJsonRecord(value);
|
|
354
|
-
|
|
374
|
+
const next = {
|
|
355
375
|
...deleteOwnedFields(existing, ownership),
|
|
356
376
|
...mergeOwnedArrays(existing, value, ownership.arrays)
|
|
357
377
|
};
|
|
378
|
+
for (const [field, childOwnership] of Object.entries(ownership.objects ?? {})) {
|
|
379
|
+
const current = existing[field];
|
|
380
|
+
const incoming = value[field];
|
|
381
|
+
const merged = mergeProviderOutputConfig(isProviderJsonRecord(current) ? current : {}, isProviderJsonRecord(incoming) ? incoming : {}, childOwnership);
|
|
382
|
+
if (Object.keys(merged).length) next[field] = merged;
|
|
383
|
+
else delete next[field];
|
|
384
|
+
}
|
|
385
|
+
return next;
|
|
358
386
|
}
|
|
359
387
|
function stringifyProviderOutputConfig(value) {
|
|
360
388
|
assertProviderJsonRecord(value);
|
|
361
389
|
return JSON.stringify(value, null, 2);
|
|
362
390
|
}
|
|
363
391
|
async function cleanProviderOutputConfig(file, ownership) {
|
|
364
|
-
if (!ownership.keys?.length && !Object.keys(ownership.arrays ?? {}).length) return;
|
|
392
|
+
if (!ownership.keys?.length && !Object.keys(ownership.arrays ?? {}).length && !Object.keys(ownership.objects ?? {}).length) return;
|
|
365
393
|
const existing = await readProviderJsonRecord(file);
|
|
366
394
|
if (!existing) return;
|
|
395
|
+
const next = cleanOwnedFields(existing, ownership);
|
|
396
|
+
if (next) await persistProviderJsonRecord(file, next, true);
|
|
397
|
+
}
|
|
398
|
+
function cleanOwnedFields(existing, ownership) {
|
|
367
399
|
const next = deleteOwnedFields(existing, ownership, true);
|
|
368
400
|
let changed = (ownership.keys ?? []).some((key) => key in existing);
|
|
369
401
|
for (const [field, arrayOwnership] of Object.entries(ownership.arrays ?? {})) {
|
|
@@ -375,8 +407,16 @@ async function cleanProviderOutputConfig(file, ownership) {
|
|
|
375
407
|
changed ||= retained.length > 0 || !Array.isArray(current) || preserved.length !== current.length || preserved.length === 0;
|
|
376
408
|
if (preserved.length) next[field] = preserved;
|
|
377
409
|
}
|
|
378
|
-
|
|
379
|
-
|
|
410
|
+
for (const [field, childOwnership] of Object.entries(ownership.objects ?? {})) {
|
|
411
|
+
const current = existing[field];
|
|
412
|
+
if (!isProviderJsonRecord(current)) continue;
|
|
413
|
+
const cleaned = cleanOwnedFields(current, childOwnership);
|
|
414
|
+
if (!cleaned) continue;
|
|
415
|
+
changed = true;
|
|
416
|
+
if (Object.keys(cleaned).length) next[field] = cleaned;
|
|
417
|
+
else delete next[field];
|
|
418
|
+
}
|
|
419
|
+
if (changed) return next;
|
|
380
420
|
}
|
|
381
421
|
// ../internal/src/build/user-entry.ts
|
|
382
422
|
function toSafeAppName(rootDir) {
|
|
@@ -3293,8 +3333,26 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
|
|
|
3293
3333
|
}
|
|
3294
3334
|
}
|
|
3295
3335
|
// ../internal/src/build/provider-output-sources.ts
|
|
3296
|
-
|
|
3297
|
-
|
|
3336
|
+
const keptFailedProviderOutputArtifactDirs = /* @__PURE__ */ new Set();
|
|
3337
|
+
function failureText(failure) {
|
|
3338
|
+
return failure instanceof Error ? `${failure.message}\n${failure.stack ?? ""}` : String(failure);
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3341
|
+
* Removes retained provider output after readers release it, tolerating transient filesystem contention. Pass the
|
|
3342
|
+
* build failure when a failed build discards its generation: with `VITEHUB_KEEP_FAILED_BUILD=1` the folder stays
|
|
3343
|
+
* for inspection.
|
|
3344
|
+
*/
|
|
3345
|
+
async function removeProviderOutputArtifactDir(path, failure) {
|
|
3346
|
+
if (failure !== void 0) {
|
|
3347
|
+
const shown = relative(process.cwd(), path) || path;
|
|
3348
|
+
if (/^(?:1|true)$/i.test(process.env.VITEHUB_KEEP_FAILED_BUILD ?? "")) {
|
|
3349
|
+
if (!existsSync(path)) return;
|
|
3350
|
+
if (!keptFailedProviderOutputArtifactDirs.has(path)) console.warn(`[vitehub] The build failed. ViteHub kept its provider sources in ${shown} so you can inspect them. Remove the folder when you are done.`);
|
|
3351
|
+
keptFailedProviderOutputArtifactDirs.add(path);
|
|
3352
|
+
return;
|
|
3353
|
+
}
|
|
3354
|
+
if (failureText(failure).includes(basename(path))) console.warn(`[vitehub] The build error names files in ${shown}, which ViteHub removes after a failed build. Set VITEHUB_KEEP_FAILED_BUILD=1 to keep them.`);
|
|
3355
|
+
}
|
|
3298
3356
|
await rm(path, {
|
|
3299
3357
|
force: true,
|
|
3300
3358
|
maxRetries: 5,
|
|
@@ -3706,17 +3764,17 @@ var ProviderOutputCatalog = class {
|
|
|
3706
3764
|
}
|
|
3707
3765
|
this.#restoreDeploymentContribution(entry);
|
|
3708
3766
|
}
|
|
3709
|
-
resetDeploymentContributions(generation) {
|
|
3767
|
+
resetDeploymentContributions(generation, failure) {
|
|
3710
3768
|
if (!generation) {
|
|
3711
3769
|
for (const reference of this.#deploymentGenerations) {
|
|
3712
3770
|
const current = reference.deref();
|
|
3713
3771
|
if (current) current.valid = false;
|
|
3714
3772
|
}
|
|
3715
3773
|
this.#deploymentGenerations.clear();
|
|
3716
|
-
for (const entries of this.#deploymentContributions.values()) for (const entry of entries) this.#queueDeploymentDiscard(entry);
|
|
3774
|
+
for (const entries of this.#deploymentContributions.values()) for (const entry of entries) this.#queueDeploymentDiscard(entry, failure);
|
|
3717
3775
|
for (const taken of this.#takenDeploymentContributions.values()) {
|
|
3718
|
-
if (!taken.entryDiscarded) this.#queueDeploymentDiscard(taken.entry);
|
|
3719
|
-
for (const fallback of taken.fallbacks) this.#queueDeploymentDiscard(fallback);
|
|
3776
|
+
if (!taken.entryDiscarded) this.#queueDeploymentDiscard(taken.entry, failure);
|
|
3777
|
+
for (const fallback of taken.fallbacks) this.#queueDeploymentDiscard(fallback, failure);
|
|
3720
3778
|
}
|
|
3721
3779
|
this.#deploymentContributions.clear();
|
|
3722
3780
|
this.#takenDeploymentContributions.clear();
|
|
@@ -3725,7 +3783,7 @@ var ProviderOutputCatalog = class {
|
|
|
3725
3783
|
generation.valid = false;
|
|
3726
3784
|
this.#deleteDeploymentGeneration(generation);
|
|
3727
3785
|
for (const [owner, entries] of this.#deploymentContributions) {
|
|
3728
|
-
for (const entry of entries) if (entry.generation === generation) this.#queueDeploymentDiscard(entry);
|
|
3786
|
+
for (const entry of entries) if (entry.generation === generation) this.#queueDeploymentDiscard(entry, failure);
|
|
3729
3787
|
const remaining = entries.filter((entry) => entry.generation !== generation);
|
|
3730
3788
|
if (remaining.length) this.#deploymentContributions.set(owner, remaining);
|
|
3731
3789
|
else this.#deploymentContributions.delete(owner);
|
|
@@ -3733,10 +3791,10 @@ var ProviderOutputCatalog = class {
|
|
|
3733
3791
|
for (const [contribution, taken] of this.#takenDeploymentContributions) {
|
|
3734
3792
|
const invalidatedFallbacks = taken.fallbacks.filter((entry) => entry.generation === generation);
|
|
3735
3793
|
taken.fallbacks = taken.fallbacks.filter((entry) => entry.generation !== generation);
|
|
3736
|
-
for (const fallback of invalidatedFallbacks) this.#queueDeploymentDiscard(fallback);
|
|
3794
|
+
for (const fallback of invalidatedFallbacks) this.#queueDeploymentDiscard(fallback, failure);
|
|
3737
3795
|
if (taken.entry.generation !== generation) continue;
|
|
3738
3796
|
this.#takenDeploymentContributions.delete(contribution);
|
|
3739
|
-
if (!taken.entryDiscarded) this.#queueDeploymentDiscard(taken.entry);
|
|
3797
|
+
if (!taken.entryDiscarded) this.#queueDeploymentDiscard(taken.entry, failure);
|
|
3740
3798
|
for (const fallback of taken.fallbacks) if (taken.committed) this.#queueDeploymentDiscard(fallback);
|
|
3741
3799
|
else this.#restoreDeploymentContribution(fallback);
|
|
3742
3800
|
}
|
|
@@ -3779,7 +3837,7 @@ var ProviderOutputCatalog = class {
|
|
|
3779
3837
|
const failure = (await Promise.allSettled(discarded)).find((result) => result.status === "rejected");
|
|
3780
3838
|
if (failure) throw failure.reason;
|
|
3781
3839
|
}
|
|
3782
|
-
async completeDeploymentContributions(contributions) {
|
|
3840
|
+
async completeDeploymentContributions(contributions, buildFailure) {
|
|
3783
3841
|
const discarded = this.#pendingDeploymentDiscards.splice(0);
|
|
3784
3842
|
const completedGenerations = /* @__PURE__ */ new Set();
|
|
3785
3843
|
for (const contribution of contributions) {
|
|
@@ -3789,7 +3847,7 @@ var ProviderOutputCatalog = class {
|
|
|
3789
3847
|
const entries = taken.entryDiscarded ? taken.fallbacks : [...taken.fallbacks, taken.entry];
|
|
3790
3848
|
for (const entry of entries) {
|
|
3791
3849
|
if (entry.generation) completedGenerations.add(entry.generation);
|
|
3792
|
-
if (entry.contribution.discard) discarded.push(entry.contribution.discard());
|
|
3850
|
+
if (entry.contribution.discard) discarded.push(entry.contribution.discard(entry === taken.entry ? buildFailure : void 0));
|
|
3793
3851
|
}
|
|
3794
3852
|
}
|
|
3795
3853
|
for (const generation of completedGenerations) this.#retireDeploymentGeneration(generation);
|
|
@@ -3833,9 +3891,9 @@ var ProviderOutputCatalog = class {
|
|
|
3833
3891
|
if (reference) this.#deploymentGenerations.delete(reference);
|
|
3834
3892
|
this.#deploymentGenerationRefs.delete(generation);
|
|
3835
3893
|
}
|
|
3836
|
-
#queueDeploymentDiscard(entry) {
|
|
3894
|
+
#queueDeploymentDiscard(entry, failure) {
|
|
3837
3895
|
if (!entry.contribution.discard) return;
|
|
3838
|
-
const discard = Promise.resolve().then(entry.contribution.discard);
|
|
3896
|
+
const discard = Promise.resolve().then(async () => await entry.contribution.discard?.(failure));
|
|
3839
3897
|
discard.catch(() => {});
|
|
3840
3898
|
this.#pendingDeploymentDiscards.push(discard);
|
|
3841
3899
|
}
|
|
@@ -4680,23 +4738,23 @@ async function resetProviderDeploymentOutputs(catalog, failure, generation) {
|
|
|
4680
4738
|
if (!catalog) return;
|
|
4681
4739
|
const completedReset = providerDeploymentOutputCompletedResets.get(catalog);
|
|
4682
4740
|
if (completedReset && failure !== void 0 && completedReset.failures.has(failure)) {
|
|
4683
|
-
if (generation) catalog.resetDeploymentContributions(generation);
|
|
4741
|
+
if (generation) catalog.resetDeploymentContributions(generation, failure);
|
|
4684
4742
|
await completedReset.promise;
|
|
4685
4743
|
return;
|
|
4686
4744
|
}
|
|
4687
4745
|
if (completedReset) providerDeploymentOutputCompletedResets.delete(catalog);
|
|
4688
|
-
if (generation) catalog.resetDeploymentContributions(generation);
|
|
4746
|
+
if (generation) catalog.resetDeploymentContributions(generation, failure);
|
|
4689
4747
|
const active = providerDeploymentOutputFinalizations.get(catalog);
|
|
4690
4748
|
if (active?.reset) {
|
|
4691
4749
|
if (failure !== void 0 && !active.reset.failures.has(failure)) {
|
|
4692
4750
|
active.reset.failures.add(failure);
|
|
4693
|
-
if (!generation) catalog.resetDeploymentContributions();
|
|
4751
|
+
if (!generation) catalog.resetDeploymentContributions(void 0, failure);
|
|
4694
4752
|
}
|
|
4695
4753
|
providerDeploymentOutputCompletedResets.set(catalog, active.reset);
|
|
4696
4754
|
await active.reset.promise;
|
|
4697
4755
|
return;
|
|
4698
4756
|
}
|
|
4699
|
-
if (!generation) catalog.resetDeploymentContributions();
|
|
4757
|
+
if (!generation) catalog.resetDeploymentContributions(void 0, failure);
|
|
4700
4758
|
if (active && (!generation || active.state.generations.has(generation))) {
|
|
4701
4759
|
active.state.rollback = true;
|
|
4702
4760
|
active.controller.abort(internalErrorDiagnostics.INTERNAL_B0039({ message: "Provider Output finalization reset" }));
|
|
@@ -4845,7 +4903,7 @@ async function finalizeProviderDeploymentOutputs(catalog, options = {}) {
|
|
|
4845
4903
|
await catalog.completeDeploymentContributions(contributions);
|
|
4846
4904
|
} catch (error) {
|
|
4847
4905
|
if (state.rollback) catalog.rollbackDeploymentContributions(contributions);
|
|
4848
|
-
else await catalog.completeDeploymentContributions(contributions);
|
|
4906
|
+
else await catalog.completeDeploymentContributions(contributions, error);
|
|
4849
4907
|
throw error;
|
|
4850
4908
|
} finally {
|
|
4851
4909
|
state.generations.clear();
|
|
@@ -5245,6 +5303,13 @@ function readProviderErrorCodes(body) {
|
|
|
5245
5303
|
function isShellSafeProvisionValue(value) {
|
|
5246
5304
|
return /^[A-Za-z0-9][\w.-]*$/.test(value);
|
|
5247
5305
|
}
|
|
5306
|
+
/**
|
|
5307
|
+
* The warning of a Cloudflare Provision Step that skips without credentials. `vitehub provision` and `vitehub deploy`
|
|
5308
|
+
* read a `wrangler login` of the Wrangler installed in the project, so the warning names it.
|
|
5309
|
+
*/
|
|
5310
|
+
function cloudflareProvisionSkipWarning(skipping) {
|
|
5311
|
+
return `${skipping}, missing CLOUDFLARE_ACCOUNT_ID/CLOUDFLARE_API_TOKEN. Install Wrangler in the project and run \`npx wrangler login\`, or set both variables. With more than one Cloudflare account, also set CLOUDFLARE_ACCOUNT_ID.`;
|
|
5312
|
+
}
|
|
5248
5313
|
function resolveCloudflareProvisionConfig(env) {
|
|
5249
5314
|
const credentials = readHostCredentialsFromEnv("cloudflare", env);
|
|
5250
5315
|
if (!credentials?.accountId) return;
|
|
@@ -5439,7 +5504,7 @@ function createKVCloudflareProvisionStep(resolveOptions) {
|
|
|
5439
5504
|
if (!storesByNamespace.size) return [];
|
|
5440
5505
|
const config = resolveCloudflareProvisionConfig(context.env);
|
|
5441
5506
|
if (!config) {
|
|
5442
|
-
context.logger.warn("kv: skipping Cloudflare KV
|
|
5507
|
+
context.logger.warn(cloudflareProvisionSkipWarning("kv: skipping Cloudflare KV"));
|
|
5443
5508
|
context.markPlanUnchecked?.();
|
|
5444
5509
|
return [];
|
|
5445
5510
|
}
|
|
@@ -5460,7 +5525,7 @@ function createKVCloudflareProvisionStep(resolveOptions) {
|
|
|
5460
5525
|
}
|
|
5461
5526
|
// src/deployment-env.ts
|
|
5462
5527
|
const owners = ["kv"];
|
|
5463
|
-
const maskedRuntimeValue = "********";
|
|
5528
|
+
const maskedRuntimeValue$1 = "********";
|
|
5464
5529
|
function entry(names) {
|
|
5465
5530
|
return {
|
|
5466
5531
|
names,
|
|
@@ -5471,7 +5536,7 @@ function entry(names) {
|
|
|
5471
5536
|
};
|
|
5472
5537
|
}
|
|
5473
5538
|
function storeEntries(store) {
|
|
5474
|
-
if (store.driver === "upstash") return [...store.url === maskedRuntimeValue ? [entry(upstashUrlEnvNames)] : [], ...store.token === maskedRuntimeValue ? [entry(upstashTokenEnvNames)] : []];
|
|
5539
|
+
if (store.driver === "upstash") return [...store.url === maskedRuntimeValue$1 ? [entry(upstashUrlEnvNames)] : [], ...store.token === maskedRuntimeValue$1 ? [entry(upstashTokenEnvNames)] : []];
|
|
5475
5540
|
if (store.driver === "redis" && store.url.startsWith("env:")) return [entry([store.url.slice(4)])];
|
|
5476
5541
|
return [];
|
|
5477
5542
|
}
|
|
@@ -5483,6 +5548,39 @@ function kvDeploymentEnv(config) {
|
|
|
5483
5548
|
if (!config) return [];
|
|
5484
5549
|
return Object.values(config.stores ?? { default: config.store }).flatMap(storeEntries);
|
|
5485
5550
|
}
|
|
5551
|
+
// src/server-env.ts
|
|
5552
|
+
const maskedRuntimeValue = "********";
|
|
5553
|
+
function storeFields(name, store) {
|
|
5554
|
+
const label = name === "default" ? "the default KV store" : `the ${name} KV store`;
|
|
5555
|
+
if (store.driver === "upstash") return {
|
|
5556
|
+
...store.url === maskedRuntimeValue ? { url: {
|
|
5557
|
+
names: upstashUrlEnvNames,
|
|
5558
|
+
secret: true,
|
|
5559
|
+
description: `The Upstash REST URL of ${label}.`
|
|
5560
|
+
} } : {},
|
|
5561
|
+
...store.token === maskedRuntimeValue ? { token: {
|
|
5562
|
+
names: upstashTokenEnvNames,
|
|
5563
|
+
secret: true,
|
|
5564
|
+
description: `The Upstash REST token of ${label}.`
|
|
5565
|
+
} } : {}
|
|
5566
|
+
};
|
|
5567
|
+
if (store.driver === "redis" && store.url.startsWith("env:")) return { url: {
|
|
5568
|
+
names: [store.url.slice(4)],
|
|
5569
|
+
secret: true,
|
|
5570
|
+
description: `The Redis URL of ${label}.`
|
|
5571
|
+
} };
|
|
5572
|
+
return {};
|
|
5573
|
+
}
|
|
5574
|
+
/** The Server Env fields of the KV stores, by store name, so Setup pages show them. The same variables as `kvDeploymentEnv()`. */
|
|
5575
|
+
function kvServerEnv(config) {
|
|
5576
|
+
if (!config) return {};
|
|
5577
|
+
const fields = {};
|
|
5578
|
+
for (const [name, store] of Object.entries(config.stores ?? { default: config.store })) {
|
|
5579
|
+
const group = storeFields(name, store);
|
|
5580
|
+
if (Object.keys(group).length) fields[name] = group;
|
|
5581
|
+
}
|
|
5582
|
+
return fields;
|
|
5583
|
+
}
|
|
5486
5584
|
// src/vite.ts
|
|
5487
5585
|
const operationsModule = ownModule(import.meta.url, "operations");
|
|
5488
5586
|
const RESOLVED_KV_VIRTUAL_CONFIG_ID = `\0${KV_VIRTUAL_CONFIG_ID}`;
|
|
@@ -5615,7 +5713,7 @@ function createCloudflareKVWranglerConfig(kv, provisionState) {
|
|
|
5615
5713
|
function serializeCloudflareRuntime(config) {
|
|
5616
5714
|
return [
|
|
5617
5715
|
`import { createCloudflareKVStorage } from ${JSON.stringify(CLOUDFLARE_KV_RUNTIME_IMPORT_ID)};`,
|
|
5618
|
-
`import { kvClearOptionsError, kvInvalidLimitError, kvKeyLimitCodes, kvListLimitInvalid, kvResult, kvSetCodes, kvSetTTL, kvStoreNotFoundError, kvStoreWithMode, kvUnsupportedOperationError, listKVKeys } from ${JSON.stringify(KV_ERRORS_IMPORT_ID)};`,
|
|
5716
|
+
`import { kvClearOptionsError, kvInvalidKeyError, kvInvalidLimitError, kvKeyLimitCodes, kvListLimitInvalid, kvResult, kvSetCodes, kvSetTTL, kvStoreNotFoundError, kvStoreWithMode, kvUnsupportedOperationError, listKVKeys } from ${JSON.stringify(KV_ERRORS_IMPORT_ID)};`,
|
|
5619
5717
|
"",
|
|
5620
5718
|
`const kvConfig = ${JSON.stringify(config, null, 2)}`,
|
|
5621
5719
|
"const storages = new Map();",
|
|
@@ -5641,6 +5739,12 @@ function serializeCloudflareRuntime(config) {
|
|
|
5641
5739
|
" return storage;",
|
|
5642
5740
|
"}",
|
|
5643
5741
|
"",
|
|
5742
|
+
"async function keyedKVResult(operation, name, keys, run, codes) {",
|
|
5743
|
+
" const error = kvInvalidKeyError(keys);",
|
|
5744
|
+
" if (error) return [error, undefined];",
|
|
5745
|
+
" return kvResult(operation, name, run, codes);",
|
|
5746
|
+
"}",
|
|
5747
|
+
"",
|
|
5644
5748
|
"function unsupported(operation, name) {",
|
|
5645
5749
|
" resolveStoreConfig(name);",
|
|
5646
5750
|
" return [kvUnsupportedOperationError(operation, name), undefined];",
|
|
@@ -5654,17 +5758,17 @@ function serializeCloudflareRuntime(config) {
|
|
|
5654
5758
|
" if (error) return [error, undefined];",
|
|
5655
5759
|
" return kvResult(\"clear\", name, async () => { await resolveStorage(name).clear(options?.prefix); });",
|
|
5656
5760
|
" },",
|
|
5657
|
-
" async delete(key, options) { return
|
|
5761
|
+
" async delete(key, options) { return keyedKVResult(\"delete\", name, [key], async () => { await resolveStorage(name).removeItem(key, options); }, kvKeyLimitCodes); },",
|
|
5658
5762
|
" async deleteIfEquals() { return unsupported(\"deleteIfEquals\", name); },",
|
|
5659
|
-
" async get(key, options) { return
|
|
5763
|
+
" async get(key, options) { return keyedKVResult(\"get\", name, [key], () => resolveStorage(name).getItem(key, options), kvKeyLimitCodes); },",
|
|
5660
5764
|
" async getAndDelete() { return unsupported(\"getAndDelete\", name); },",
|
|
5661
|
-
" async getMany(keys, options) { return
|
|
5662
|
-
" async has(key, options) { return
|
|
5765
|
+
" async getMany(keys, options) { return keyedKVResult(\"getMany\", name, keys, () => resolveStorage(name).getMany(keys, options), kvKeyLimitCodes); },",
|
|
5766
|
+
" async has(key, options) { return keyedKVResult(\"has\", name, [key], () => resolveStorage(name).hasItem(key, options), kvKeyLimitCodes); },",
|
|
5663
5767
|
" async increment() { return unsupported(\"increment\", name); },",
|
|
5664
5768
|
" lock() { return { async acquire() { return unsupported(\"lock\", name); }, async run() { return unsupported(\"lock\", name); } }; },",
|
|
5665
5769
|
" async list(options = {}) { if (kvListLimitInvalid(options)) return [kvInvalidLimitError(), undefined]; return kvResult(\"list\", name, () => listKVKeys(page => resolveStorage(name).listKeys(page), options), [\"KV_INVALID_CURSOR\"]); },",
|
|
5666
|
-
" async set(key, value, options) { return
|
|
5667
|
-
" async setMany(entries, options) { return
|
|
5770
|
+
" async set(key, value, options) { return keyedKVResult(\"set\", name, [key], async () => { const storage = resolveStorage(name); const ttl = kvSetTTL(\"set\", options); await storage.setItem(key, value, ttl === undefined ? undefined : { ttl }); }, kvSetCodes); },",
|
|
5771
|
+
" async setMany(entries, options) { return keyedKVResult(\"setMany\", name, Array.isArray(entries) ? entries.map(entry => Reflect.get(Object(entry), \"key\")) : entries, async () => { const storage = resolveStorage(name); const ttl = kvSetTTL(\"setMany\", options); await storage.setMany(entries, ttl === undefined ? undefined : { ttl }); }, kvSetCodes); },",
|
|
5668
5772
|
" async setIfAbsent() { return unsupported(\"setIfAbsent\", name); },",
|
|
5669
5773
|
" store(storeName, options) { return kvStoreWithMode(createKVStorage(storeName), options); },",
|
|
5670
5774
|
" };",
|
|
@@ -5676,11 +5780,11 @@ function serializeCloudflareRuntime(config) {
|
|
|
5676
5780
|
}
|
|
5677
5781
|
function getNitroCloudflareKVNamespaces(target) {
|
|
5678
5782
|
if (!isRecord(target)) return [];
|
|
5679
|
-
const cloudflare =
|
|
5783
|
+
const cloudflare = target.cloudflare;
|
|
5680
5784
|
if (!isRecord(cloudflare)) return [];
|
|
5681
|
-
const wrangler =
|
|
5785
|
+
const wrangler = cloudflare.wrangler;
|
|
5682
5786
|
if (!isRecord(wrangler)) return [];
|
|
5683
|
-
const namespaces =
|
|
5787
|
+
const namespaces = wrangler.kv_namespaces;
|
|
5684
5788
|
if (!Array.isArray(namespaces)) return [];
|
|
5685
5789
|
return namespaces.flatMap((namespace) => {
|
|
5686
5790
|
let normalized;
|
|
@@ -5690,11 +5794,7 @@ function getNitroCloudflareKVNamespaces(target) {
|
|
|
5690
5794
|
return [];
|
|
5691
5795
|
}
|
|
5692
5796
|
if (!isProviderJsonRecord(normalized)) return [];
|
|
5693
|
-
const binding =
|
|
5694
|
-
const id = Reflect.get(normalized, "id");
|
|
5695
|
-
const previewId = Reflect.get(normalized, "preview_id");
|
|
5696
|
-
const experimentalRemote = Reflect.get(normalized, "experimental_remote");
|
|
5697
|
-
const remote = Reflect.get(normalized, "remote");
|
|
5797
|
+
const { binding, id, preview_id: previewId, experimental_remote: experimentalRemote, remote } = normalized;
|
|
5698
5798
|
if (typeof binding !== "string") return [];
|
|
5699
5799
|
if (id !== void 0 && typeof id !== "string") return [];
|
|
5700
5800
|
if (previewId !== void 0 && typeof previewId !== "string") return [];
|
|
@@ -5704,7 +5804,7 @@ function getNitroCloudflareKVNamespaces(target) {
|
|
|
5704
5804
|
});
|
|
5705
5805
|
}
|
|
5706
5806
|
function getResolvedNitroConfig(config) {
|
|
5707
|
-
return
|
|
5807
|
+
return "nitro" in config ? config.nitro : void 0;
|
|
5708
5808
|
}
|
|
5709
5809
|
function reconcileNitroCloudflareKV(target, kv, ownedNamespaces, provisionState) {
|
|
5710
5810
|
configureNitroCloudflareRequestEnv(target, kv);
|
|
@@ -5718,7 +5818,7 @@ function reconcileNitroCloudflareKV(target, kv, ownedNamespaces, provisionState)
|
|
|
5718
5818
|
if (kv) configureCloudflareKV(target, kv, provisionState);
|
|
5719
5819
|
}
|
|
5720
5820
|
function configureNitroCloudflareKV(config, options, input, ownedNamespaces, provisionState) {
|
|
5721
|
-
const nitro =
|
|
5821
|
+
const nitro = "nitro" in config ? config.nitro : void 0;
|
|
5722
5822
|
if (!isRecord(nitro)) return false;
|
|
5723
5823
|
const target = nitro;
|
|
5724
5824
|
const namespaces = target.cloudflare?.wrangler?.kv_namespaces;
|
|
@@ -5727,7 +5827,7 @@ function configureNitroCloudflareKV(config, options, input, ownedNamespaces, pro
|
|
|
5727
5827
|
const kv = resolveKVViteConfig(options, input).kv;
|
|
5728
5828
|
configureNitroCloudflareRequestEnv(target, kv);
|
|
5729
5829
|
configureNitroPlugin(target, kv);
|
|
5730
|
-
if (
|
|
5830
|
+
if ("__vitehubNitroConfigContext" in config && config["__vitehubNitroConfigContext"] === true) configureNitroStorage(target, kv);
|
|
5731
5831
|
if (kv) {
|
|
5732
5832
|
const existingNamespaces = new Set(target.cloudflare?.wrangler?.kv_namespaces);
|
|
5733
5833
|
configureCloudflareKV(target, kv, provisionState);
|
|
@@ -5735,26 +5835,31 @@ function configureNitroCloudflareKV(config, options, input, ownedNamespaces, pro
|
|
|
5735
5835
|
}
|
|
5736
5836
|
return true;
|
|
5737
5837
|
}
|
|
5738
|
-
/**
|
|
5838
|
+
/** KV infers its driver from Nitro's preset, the supplied host, or the host environment. */
|
|
5739
5839
|
function hubKV(options, input = {}) {
|
|
5740
5840
|
let command = "build";
|
|
5741
5841
|
let mode = "development";
|
|
5742
5842
|
let viteEnv;
|
|
5743
5843
|
let databasePlugin;
|
|
5744
5844
|
const databaseImport = input.databaseImport ?? "@vite-hub/database/runtime/registry";
|
|
5745
|
-
const
|
|
5845
|
+
const databaseConfig = (name) => databasePlugin?.api?.getConfig?.()?.databases[name];
|
|
5846
|
+
const postgresDatabase = () => databaseConfig("default")?.dialect === "postgresql" && databaseConfig("default")?.driver !== "drizzle-postgres";
|
|
5847
|
+
let configuredHosting = input.hosting;
|
|
5848
|
+
const hosting = () => resolvedNitroPreset ?? configuredHosting;
|
|
5746
5849
|
const resolutionInput = () => ({
|
|
5747
5850
|
dev: command === "serve",
|
|
5748
5851
|
env: command === "serve" ? viteEnv : void 0,
|
|
5749
|
-
hosting:
|
|
5852
|
+
hosting: hosting(),
|
|
5750
5853
|
postgresDatabase: postgresDatabase()
|
|
5751
5854
|
});
|
|
5752
5855
|
let nitroOwned = false;
|
|
5856
|
+
let resolvedNitroPreset;
|
|
5753
5857
|
let nitroOptions;
|
|
5754
5858
|
const ownedNitroNamespaces = /* @__PURE__ */ new Set();
|
|
5755
5859
|
let resolved;
|
|
5756
5860
|
let providerOutput;
|
|
5757
5861
|
let runtimeConfig;
|
|
5862
|
+
let configReady;
|
|
5758
5863
|
let projectRoot = process.cwd();
|
|
5759
5864
|
const getConfig = () => runtimeConfig ??= resolveKVViteConfig(options, resolutionInput());
|
|
5760
5865
|
const providerOutputGenerations = createProviderDeploymentOutputGenerationState();
|
|
@@ -5769,26 +5874,57 @@ function hubKV(options, input = {}) {
|
|
|
5769
5874
|
});
|
|
5770
5875
|
if (hint) reportViteHubHint(config, hint);
|
|
5771
5876
|
}
|
|
5877
|
+
async function resolveRuntimeConfig(config) {
|
|
5878
|
+
resolved = config;
|
|
5879
|
+
startViteHubHints(config);
|
|
5880
|
+
if (config.command) command = config.command;
|
|
5881
|
+
mode = config.mode ?? mode;
|
|
5882
|
+
projectRoot = resolveViteHubProjectRoot(config.root || process.cwd());
|
|
5883
|
+
viteEnv = loadAllEnv((await import("vite")).loadEnv, mode, config.envDir === false ? false : resolve(config.root || process.cwd(), config.envDir ?? "."));
|
|
5884
|
+
databasePlugin = findDatabasePlugin(config.plugins);
|
|
5885
|
+
await databasePlugin?.api?.whenConfigResolved?.();
|
|
5886
|
+
providerOutput = useProviderOutputCatalog(config);
|
|
5887
|
+
runtimeConfig = resolveKVViteConfig(options, resolutionInput());
|
|
5888
|
+
const provisionState = readProvisionStateSync(projectRoot);
|
|
5889
|
+
if (nitroOptions) reconcileNitroCloudflareKV(nitroOptions, runtimeConfig.kv, ownedNitroNamespaces, provisionState);
|
|
5890
|
+
if (hasNitroConfigContext(config) || isRecord(getResolvedNitroConfig(config))) nitroOwned = configureNitroCloudflareKV(config, options, resolutionInput(), ownedNitroNamespaces, provisionState);
|
|
5891
|
+
if (!config.command && command === "build" && Reflect.get(config, "__vitehubNuxtHints")) reportRedisEnvHint({
|
|
5892
|
+
...config,
|
|
5893
|
+
command
|
|
5894
|
+
});
|
|
5895
|
+
}
|
|
5772
5896
|
return {
|
|
5773
5897
|
name: KV_VITE_PLUGIN_NAME,
|
|
5774
5898
|
enforce: "post",
|
|
5775
5899
|
api: {
|
|
5776
5900
|
deploymentEnv: () => kvDeploymentEnv(getConfig().kv),
|
|
5777
5901
|
getBuildConfig: () => resolveKVViteConfig(options, {
|
|
5778
|
-
hosting:
|
|
5902
|
+
hosting: hosting(),
|
|
5779
5903
|
postgresDatabase: postgresDatabase()
|
|
5780
5904
|
}),
|
|
5781
|
-
getConfig
|
|
5905
|
+
getConfig,
|
|
5906
|
+
whenConfigResolved: () => configReady
|
|
5782
5907
|
},
|
|
5783
5908
|
nitro: {
|
|
5784
5909
|
name: "@vite-hub/kv/cloudflare-bindings",
|
|
5785
5910
|
setup(nitro) {
|
|
5911
|
+
if (nitro.options.preset === "nitro-prerender") {
|
|
5912
|
+
configureNitroStorage(nitro.options, resolveKVViteConfig(options, {
|
|
5913
|
+
hosting: hosting(),
|
|
5914
|
+
prerender: true
|
|
5915
|
+
}).kv);
|
|
5916
|
+
return;
|
|
5917
|
+
}
|
|
5786
5918
|
nitroOptions = nitro.options;
|
|
5919
|
+
if (!nitro.options.dev && nitro.options.preset !== resolvedNitroPreset) {
|
|
5920
|
+
resolvedNitroPreset = nitro.options.preset;
|
|
5921
|
+
runtimeConfig = void 0;
|
|
5922
|
+
}
|
|
5787
5923
|
if (runtimeConfig) reconcileNitroCloudflareKV(nitroOptions, runtimeConfig.kv, ownedNitroNamespaces, readProvisionStateSync(projectRoot));
|
|
5788
5924
|
else configureNitroStorage(nitroOptions, resolveKVViteConfig(options, resolutionInput()).kv);
|
|
5789
5925
|
nitro.hooks?.hook("prerender:config", (config) => {
|
|
5790
5926
|
const prerender = resolveKVViteConfig(options, {
|
|
5791
|
-
hosting:
|
|
5927
|
+
hosting: hosting(),
|
|
5792
5928
|
prerender: true
|
|
5793
5929
|
});
|
|
5794
5930
|
if (prerender.kv && Object.values({
|
|
@@ -5812,7 +5948,7 @@ function hubKV(options, input = {}) {
|
|
|
5812
5948
|
default: kv.store,
|
|
5813
5949
|
...kv.stores
|
|
5814
5950
|
}).map(([name, store]) => {
|
|
5815
|
-
const database =
|
|
5951
|
+
const database = "database" in store ? store.database : void 0;
|
|
5816
5952
|
return [name, {
|
|
5817
5953
|
driver: store.driver,
|
|
5818
5954
|
..."base" in store && store.base ? { base: store.base } : {},
|
|
@@ -5825,13 +5961,13 @@ function hubKV(options, input = {}) {
|
|
|
5825
5961
|
},
|
|
5826
5962
|
inspect: () => {
|
|
5827
5963
|
const build = resolveKVViteConfig(options, {
|
|
5828
|
-
hosting:
|
|
5964
|
+
hosting: hosting(),
|
|
5829
5965
|
postgresDatabase: postgresDatabase()
|
|
5830
5966
|
}).kv;
|
|
5831
5967
|
const dev = resolveKVViteConfig(options, {
|
|
5832
5968
|
dev: true,
|
|
5833
5969
|
env: viteEnv,
|
|
5834
|
-
hosting:
|
|
5970
|
+
hosting: hosting()
|
|
5835
5971
|
}).kv;
|
|
5836
5972
|
if (!build || !dev) return;
|
|
5837
5973
|
const file = resolved?.configFile ? relativeDefinitionFile(projectRoot, resolved.configFile) : "vite.config.ts";
|
|
@@ -5865,33 +6001,29 @@ function hubKV(options, input = {}) {
|
|
|
5865
6001
|
async handler(config, env) {
|
|
5866
6002
|
if (env) markViteConfigPlugin(env, KV_VITE_PLUGIN_NAME);
|
|
5867
6003
|
command = env?.command ?? "build";
|
|
6004
|
+
configuredHosting = resolveHostPreset({
|
|
6005
|
+
hosting: input.hosting,
|
|
6006
|
+
nitro: "nitro" in config ? config.nitro : void 0,
|
|
6007
|
+
env: {}
|
|
6008
|
+
});
|
|
6009
|
+
resolvedNitroPreset = void 0;
|
|
5868
6010
|
mode = env?.mode ?? config.mode ?? (command === "serve" ? "development" : "production");
|
|
5869
6011
|
runtimeConfig = void 0;
|
|
5870
6012
|
projectRoot = resolveViteHubProjectRoot(config.root || process.cwd());
|
|
5871
6013
|
viteEnv = loadAllEnv((await import("vite")).loadEnv, mode, config.envDir === false ? false : resolve(config.root || process.cwd(), config.envDir ?? "."));
|
|
5872
6014
|
nitroOwned = configureNitroCloudflareKV(config, options, resolutionInput(), ownedNitroNamespaces, readProvisionStateSync(projectRoot));
|
|
6015
|
+
const inspectedKV = "vitehubCliDiscovery" in config && config.vitehubCliDiscovery === true && mode !== "development" ? resolveKVViteConfig(options, {
|
|
6016
|
+
hosting: hosting(),
|
|
6017
|
+
postgresDatabase: postgresDatabase()
|
|
6018
|
+
}).kv : getConfig().kv;
|
|
6019
|
+
contributeServerEnv(config, "kv", kvServerEnv(inspectedKV));
|
|
5873
6020
|
return installStandaloneOperationRpc(config, env?.command ?? "build", operationsModule);
|
|
5874
6021
|
}
|
|
5875
6022
|
},
|
|
5876
6023
|
configResolved: {
|
|
5877
6024
|
order: "pre",
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
startViteHubHints(config);
|
|
5881
|
-
if (config.command) command = config.command;
|
|
5882
|
-
mode = config.mode ?? mode;
|
|
5883
|
-
projectRoot = resolveViteHubProjectRoot(config.root || process.cwd());
|
|
5884
|
-
viteEnv = loadAllEnv((await import("vite")).loadEnv, mode, config.envDir === false ? false : resolve(config.root || process.cwd(), config.envDir ?? "."));
|
|
5885
|
-
databasePlugin = findDatabasePlugin(config.plugins);
|
|
5886
|
-
providerOutput = useProviderOutputCatalog(config);
|
|
5887
|
-
runtimeConfig = resolveKVViteConfig(options, resolutionInput());
|
|
5888
|
-
const provisionState = readProvisionStateSync(projectRoot);
|
|
5889
|
-
if (nitroOptions) reconcileNitroCloudflareKV(nitroOptions, runtimeConfig.kv, ownedNitroNamespaces, provisionState);
|
|
5890
|
-
if (hasNitroConfigContext(config) || isRecord(getResolvedNitroConfig(config))) nitroOwned = configureNitroCloudflareKV(config, options, resolutionInput(), ownedNitroNamespaces, provisionState);
|
|
5891
|
-
if (!config.command && command === "build" && Reflect.get(config, "__vitehubNuxtHints")) reportRedisEnvHint({
|
|
5892
|
-
...config,
|
|
5893
|
-
command
|
|
5894
|
-
});
|
|
6025
|
+
handler(config) {
|
|
6026
|
+
return configReady = resolveRuntimeConfig(config);
|
|
5895
6027
|
}
|
|
5896
6028
|
},
|
|
5897
6029
|
configureServer(server) {
|
|
@@ -5944,6 +6076,10 @@ function hubKV(options, input = {}) {
|
|
|
5944
6076
|
runtimeConfig = void 0;
|
|
5945
6077
|
providerOutputGenerations.capture(this, providerOutput);
|
|
5946
6078
|
if (command !== "build" || !resolved) return;
|
|
6079
|
+
for (const store of kvStores(getConfig().kv)) if (store.driver === "database" && databaseConfig(store.database)?.driver === "drizzle-postgres") throw kvErrorDiagnostics.KV_DATABASE_UNAVAILABLE({
|
|
6080
|
+
database: store.database,
|
|
6081
|
+
problem: "driver"
|
|
6082
|
+
});
|
|
5947
6083
|
reportRedisEnvHint(resolved);
|
|
5948
6084
|
}
|
|
5949
6085
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/kv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Vite-first key-value storage primitives and integration for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@valibot/to-json-schema": "^1.8.0",
|
|
73
|
-
"@vite-hub/runtime": "0.
|
|
73
|
+
"@vite-hub/runtime": "0.8.0",
|
|
74
74
|
"birpc": "^4.2.0",
|
|
75
75
|
"defu": "^6.1.7",
|
|
76
76
|
"destr": "^2.0.5",
|
|
@@ -82,11 +82,15 @@
|
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@types/node": "^24.19.2",
|
|
85
|
+
"@electric-sql/pglite": "^0.5.17",
|
|
85
86
|
"@libsql/client": "^0.18.0",
|
|
86
|
-
"@vite-hub/database": "0.
|
|
87
|
+
"@vite-hub/database": "0.8.0",
|
|
88
|
+
"@types/pg": "^8.23.1",
|
|
87
89
|
"@types/proper-lockfile": "4.1.4",
|
|
88
90
|
"@vite-hub/internal": "0.0.1",
|
|
91
|
+
"miniflare": "4.20260730.0",
|
|
89
92
|
"ofetch": "^1.5.1",
|
|
93
|
+
"pg": "^8.23.1",
|
|
90
94
|
"postgres": "^3.4.9",
|
|
91
95
|
"publint": "^0.3.25",
|
|
92
96
|
"typescript": "^6.0.3",
|
|
@@ -96,7 +100,7 @@
|
|
|
96
100
|
},
|
|
97
101
|
"peerDependencies": {
|
|
98
102
|
"@upstash/redis": "^1.41.0",
|
|
99
|
-
"@vite-hub/database": "0.
|
|
103
|
+
"@vite-hub/database": "0.8.0",
|
|
100
104
|
"vite": ">=8.0.0"
|
|
101
105
|
},
|
|
102
106
|
"peerDependenciesMeta": {
|
package/dist/fs-lite-DwbPkc-C.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { t as default } from "./fs-lite-DzTTR6R3.js";
|