@vite-hub/kv 0.0.4 → 0.3.1
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 +110 -14
- package/dist/batch--v0ri69O.js +40 -0
- package/dist/cli-DpPhz_Ek.d.ts +163 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.js +469 -0
- package/dist/cloudflare-env-lOtHHsgP.js +46 -0
- package/dist/cloudflare-env-lookup-Bs0VDpU5.js +42 -0
- package/dist/cloudflare-kv-BIEUFzRT.js +187 -0
- package/dist/cloudflare-kv-local-BBw3ZT1K.js +71 -0
- package/dist/config-BXEVoZE3.js +250 -0
- package/dist/{dist-DDW1iC5f.js → create-storage-BGsrQKw3.js} +266 -115
- package/dist/cursor-history-BqIQePNP.js +165 -0
- package/dist/database-72Jk3VVk.js +250 -0
- package/dist/deno-kv-BM9mYdUp.js +128 -0
- package/dist/dev-peer-CHafxbtj.js +238 -0
- package/dist/driver-BwxgaQ-f.d.ts +15 -0
- package/dist/durability.d.ts +17 -0
- package/dist/durability.js +53 -0
- package/dist/error-diagnostics-BxqvtEIb.js +147 -0
- package/dist/errors-DbwufFZp.js +60 -0
- package/dist/errors.d.ts +23 -7
- package/dist/errors.js +2 -20
- package/dist/fs-lite-BLZId9_P.js +386 -0
- package/dist/fs-lite-RAoxu8L0.js +2 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +364 -109
- package/dist/inspect-BIKQsqX4.js +118 -0
- package/dist/invariant-DolT9EEx.js +22 -0
- package/dist/main-F3Y22_uV.js +2353 -0
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
- package/dist/operations-B-WZ7P1h.js +1351 -0
- package/dist/operations-Ch-gKaey.js +441 -0
- package/dist/operations.d.ts +75 -0
- package/dist/operations.js +318 -0
- package/dist/redis-shared-E5mahECF.js +94 -0
- package/dist/results-p7nPCnaJ.js +6 -0
- package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
- package/dist/runtime/cloudflare-kv.d.ts +3 -4
- package/dist/runtime/cloudflare-kv.js +1 -23
- package/dist/runtime/cloudflare-request-env.d.ts +7 -0
- package/dist/runtime/cloudflare-request-env.js +11 -0
- package/dist/runtime/nitro-plugin.d.ts +12 -0
- package/dist/runtime/nitro-plugin.js +22 -0
- package/dist/runtime/redis-driver.d.ts +11 -0
- package/dist/runtime/redis-driver.js +113 -0
- package/dist/runtime/unstorage-driver.d.ts +14 -0
- package/dist/runtime/unstorage-driver.js +33 -0
- package/dist/runtime/upstash-driver.d.ts +4 -6
- package/dist/runtime/upstash-driver.js +60 -110
- package/dist/{driver-BT9WefKi.d.ts → types-Bj3EQoRg.d.ts} +16 -11
- package/dist/types-DEiKew_3.d.ts +312 -0
- package/dist/upstash-DDlqTttY.js +40 -0
- package/dist/utils2-FozcTsmb.js +31 -0
- package/dist/virtual-module.d.ts +2 -0
- package/dist/virtual.d.ts +1 -1
- package/dist/vite.d.ts +159 -14
- package/dist/vite.js +1329 -2898
- package/package.json +68 -19
- package/dist/config-aM9Ae7tH.js +0 -110
- package/dist/deno-kv-cJx3jU10.js +0 -69
- package/dist/fs-lite-BxzdiJSi.js +0 -79
- package/dist/types-CO0DRjJa.d.ts +0 -78
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
2
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
3
|
+
function normalizeWindowsPath(input = "") {
|
|
4
|
+
if (!input) return input;
|
|
5
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
6
|
+
}
|
|
7
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
8
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
9
|
+
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
10
|
+
function cwd() {
|
|
11
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
12
|
+
return "/";
|
|
13
|
+
}
|
|
14
|
+
const resolve = function(...arguments_) {
|
|
15
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
16
|
+
let resolvedPath = "";
|
|
17
|
+
let resolvedAbsolute = false;
|
|
18
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
19
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
20
|
+
if (!path || path.length === 0) continue;
|
|
21
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
22
|
+
resolvedAbsolute = isAbsolute(path);
|
|
23
|
+
}
|
|
24
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
25
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
|
26
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
27
|
+
};
|
|
28
|
+
function normalizeString(path, allowAboveRoot) {
|
|
29
|
+
let res = "";
|
|
30
|
+
let lastSegmentLength = 0;
|
|
31
|
+
let lastSlash = -1;
|
|
32
|
+
let dots = 0;
|
|
33
|
+
let char = null;
|
|
34
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
35
|
+
if (index < path.length) char = path[index];
|
|
36
|
+
else if (char === "/") break;
|
|
37
|
+
else char = "/";
|
|
38
|
+
if (char === "/") {
|
|
39
|
+
if (lastSlash === index - 1 || dots === 1);
|
|
40
|
+
else if (dots === 2) {
|
|
41
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
42
|
+
if (res.length > 2) {
|
|
43
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
44
|
+
if (lastSlashIndex === -1) {
|
|
45
|
+
res = "";
|
|
46
|
+
lastSegmentLength = 0;
|
|
47
|
+
} else {
|
|
48
|
+
res = res.slice(0, lastSlashIndex);
|
|
49
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
50
|
+
}
|
|
51
|
+
lastSlash = index;
|
|
52
|
+
dots = 0;
|
|
53
|
+
continue;
|
|
54
|
+
} else if (res.length > 0) {
|
|
55
|
+
res = "";
|
|
56
|
+
lastSegmentLength = 0;
|
|
57
|
+
lastSlash = index;
|
|
58
|
+
dots = 0;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (allowAboveRoot) {
|
|
63
|
+
res += res.length > 0 ? "/.." : "..";
|
|
64
|
+
lastSegmentLength = 2;
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
68
|
+
else res = path.slice(lastSlash + 1, index);
|
|
69
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
70
|
+
}
|
|
71
|
+
lastSlash = index;
|
|
72
|
+
dots = 0;
|
|
73
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
74
|
+
else dots = -1;
|
|
75
|
+
}
|
|
76
|
+
return res;
|
|
77
|
+
}
|
|
78
|
+
const isAbsolute = function(p) {
|
|
79
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
80
|
+
};
|
|
81
|
+
const relative = function(from, to) {
|
|
82
|
+
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
83
|
+
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
84
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
|
|
85
|
+
const _fromCopy = [..._from];
|
|
86
|
+
for (const segment of _fromCopy) {
|
|
87
|
+
if (_to[0] !== segment) break;
|
|
88
|
+
_from.shift();
|
|
89
|
+
_to.shift();
|
|
90
|
+
}
|
|
91
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
92
|
+
};
|
|
93
|
+
const dirname = function(p) {
|
|
94
|
+
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
95
|
+
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
96
|
+
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region ../internal/src/inspect.ts
|
|
100
|
+
function relativeDefinitionFile(projectRoot, file) {
|
|
101
|
+
return relative(projectRoot, file).replaceAll("\\", "/");
|
|
102
|
+
}
|
|
103
|
+
const redactedInspectionValue = "[redacted]";
|
|
104
|
+
const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
|
|
105
|
+
const embeddedUrlCredentialPattern = /\b([a-z][a-z0-9+.-]*:\/\/)[^/\s?#]*@/gi;
|
|
106
|
+
const embeddedCookiePattern = /\b([\w-]*cookie[\w-]*["']?\s*[:=]\s*)(?:"(?:\\[^\r\n]|[^"\\\r\n])*"(?:\s*;\s*[\w.-]+\s*=[^;\r\n]*)*|'(?:\\[^\r\n]|[^'\\\r\n])*'(?:\s*;\s*[\w.-]+\s*=[^;\r\n]*)*|[^\r\n]+?(?=\s*(?:;\s*[^;=\r\n/]+\s*(?:\r?\n|$)|&|\r?\n|$)))/gi;
|
|
107
|
+
const embeddedBearerPattern = /\bbearer\s+[^\s,;]+/gi;
|
|
108
|
+
const embeddedAuthorizationPattern = new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
|
|
109
|
+
const embeddedSecretAssignmentPattern = new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
|
|
110
|
+
/**
|
|
111
|
+
* Removes credentials inside free text, for example an error message. URL credentials, bearer tokens, and
|
|
112
|
+
* `name=value` pairs with a secret name are replaced with `[redacted]`.
|
|
113
|
+
*/
|
|
114
|
+
function redactInspectionText(value) {
|
|
115
|
+
return value.replace(embeddedUrlCredentialPattern, `$1${redactedInspectionValue}@`).replace(embeddedAuthorizationPattern, `$1${redactedInspectionValue}`).replace(embeddedCookiePattern, `$1${redactedInspectionValue}`).replace(embeddedBearerPattern, `Bearer ${redactedInspectionValue}`).replace(embeddedSecretAssignmentPattern, `$1${redactedInspectionValue}`);
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { resolve as a, relative as i, relativeDefinitionFile as n, dirname as r, redactInspectionText as t };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineDiagnostics } from "nostics";
|
|
2
|
+
//#region ../internal/src/invariant.ts
|
|
3
|
+
const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
4
|
+
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
5
|
+
codes: { INTERNAL_INVARIANT_FAILED: {
|
|
6
|
+
why: ({ what }) => `ViteHub reached a state that it does not expect: ${what}`,
|
|
7
|
+
fix: "This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace."
|
|
8
|
+
} }
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* The error for a state that only a ViteHub bug can reach, such as an impossible branch. `what` says which rule broke.
|
|
12
|
+
* Use a code from the package catalog when a developer can cause the error or fix it.
|
|
13
|
+
*/
|
|
14
|
+
function invariantError(what) {
|
|
15
|
+
return invariantDiagnostics.INTERNAL_INVARIANT_FAILED({ what });
|
|
16
|
+
}
|
|
17
|
+
/** Throws `INTERNAL_INVARIANT_FAILED` when `condition` is falsy. */
|
|
18
|
+
function invariant(condition, what) {
|
|
19
|
+
if (!condition) throw invariantError(what);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { invariantError as n, invariant as t };
|