@vite-hub/kv 0.5.0 → 0.5.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.
Files changed (60) hide show
  1. package/README.md +1 -1
  2. package/dist/{batch--v0ri69O.js → batch-D-ib5_0P.js} +0 -1
  3. package/dist/{cli-CLomw9ml.d.ts → cli-BvVInMht.d.ts} +0 -6
  4. package/dist/cli.d.ts +2 -4
  5. package/dist/cli.js +5 -6
  6. package/dist/{cloudflare-env-Dl349h_9.js → cloudflare-env-Bm6huR35.js} +2 -3
  7. package/dist/{cloudflare-env-lookup-Bs0VDpU5.js → cloudflare-env-lookup-Dgq5n1Aq.js} +1 -2
  8. package/dist/{cloudflare-kv-DQJhmGof.js → cloudflare-kv-K2MzfP6D.js} +8 -10
  9. package/dist/{cloudflare-kv-local-COjgHweC.js → cloudflare-kv-local-lov9LLhU.js} +5 -6
  10. package/dist/{config-pfyPiPrI.js → config-B8FRGmX_.js} +7 -11
  11. package/dist/{create-storage-DQ1BbFqH.js → create-storage-BMvkkYdM.js} +9 -15
  12. package/dist/{cursor-history-CAT4mpP1.js → cursor-history-C6oG12QO.js} +3 -4
  13. package/dist/{deno-kv-Cf0ZveeN.js → deno-kv-MnqlNH1e.js} +4 -5
  14. package/dist/{dev-peer-CHafxbtj.js → dev-peer-D0vOxmrD.js} +1 -2
  15. package/dist/{driver-Du6Eh9p2.d.ts → driver-bLMl-wMO.d.ts} +2 -6
  16. package/dist/durability.d.ts +1 -3
  17. package/dist/durability.js +1 -2
  18. package/dist/{error-diagnostics-C4VTHInS.js → error-diagnostics-DUIp6FhO.js} +1 -2
  19. package/dist/{errors-BpiM-Vmh.js → errors-IaVOqzAs.js} +4 -7
  20. package/dist/errors.d.ts +2 -6
  21. package/dist/errors.js +1 -2
  22. package/dist/fs-lite-DhXLUL-H.js +1 -0
  23. package/dist/{fs-lite-BTcBUP6B.js → fs-lite-fvNdBEr9.js} +3 -5
  24. package/dist/index.d.ts +1 -3
  25. package/dist/index.js +16 -20
  26. package/dist/{inspect-BIKQsqX4.js → inspect-BWMcVWD8.js} +2 -4
  27. package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
  28. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  29. package/dist/{operation-definition-CI2PJGqu.d.ts → operation-definition-CqZkx1Rm.d.ts} +0 -4
  30. package/dist/{operations-nAaONxzh.js → operations-CGAX5ASA.js} +15 -20
  31. package/dist/{operations-CqKs7Ykc.js → operations-FgS_sJ3M.js} +7 -10
  32. package/dist/operations.d.ts +2 -8
  33. package/dist/operations.js +8 -12
  34. package/dist/{out-BbXG-yVX.js → out-By90R-Bo.js} +3345 -2394
  35. package/dist/{redis-shared-1M0IaguQ.js → redis-shared-DO7Ib1Sz.js} +2 -3
  36. package/dist/{request-log-Dj9Vw7qG.js → request-log-DllKQXj7.js} +1 -2
  37. package/dist/{results-D6jfPtCk.js → results-emgN7uDS.js} +1 -2
  38. package/dist/{rolldown-runtime-CMFfr-1z.js → rolldown-runtime-DegdyBIC.js} +2 -3
  39. package/dist/runtime/cloudflare-kv.d.ts +1 -3
  40. package/dist/runtime/cloudflare-kv.js +1 -2
  41. package/dist/runtime/cloudflare-request-env.d.ts +1 -3
  42. package/dist/runtime/cloudflare-request-env.js +2 -3
  43. package/dist/runtime/database.d.ts +1 -1
  44. package/dist/runtime/database.js +5 -6
  45. package/dist/runtime/nitro-plugin.d.ts +1 -2
  46. package/dist/runtime/nitro-plugin.js +3 -4
  47. package/dist/runtime/redis-driver.d.ts +3 -5
  48. package/dist/runtime/redis-driver.js +6 -7
  49. package/dist/runtime/unstorage-driver.d.ts +2 -4
  50. package/dist/runtime/unstorage-driver.js +2 -3
  51. package/dist/runtime/upstash-driver.d.ts +3 -5
  52. package/dist/runtime/upstash-driver.js +6 -7
  53. package/dist/{types-Bj3EQoRg.d.ts → types-BUb0FcjM.d.ts} +0 -2
  54. package/dist/{types-Cp6IBhSN.d.ts → types-C397WKyf.d.ts} +1 -3
  55. package/dist/{upstash-5sTbIR35.js → upstash-DQVo1zbz.js} +3 -4
  56. package/dist/{utils2-FozcTsmb.js → utils2-By8eee1x.js} +1 -2
  57. package/dist/vite.d.ts +3 -17
  58. package/dist/vite.js +1429 -913
  59. package/package.json +10 -10
  60. package/dist/fs-lite-C8yXCVDM.js +0 -2
@@ -1,5 +1,5 @@
1
1
  import { defineDiagnostics } from "nostics";
2
- //#region ../internal/src/invariant.ts
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
- //#region ../internal/src/object.ts
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-Da1zyPCR.js";
2
- import { t as invariant } from "./invariant-DolT9EEx.js";
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
- //#region ../internal/src/error-diagnostics.ts
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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",
@@ -966,8 +963,7 @@ function isSectionId(section) {
966
963
  function operationInputJsonSchema(operation) {
967
964
  return standardJsonSchema(operation.input, "input") ?? { type: "object" };
968
965
  }
969
- //#endregion
970
- //#region ../internal/src/operations.ts
966
+ // ../internal/src/operations.ts
971
967
  /** Header that proves the caller is not a browser page. A foreign page cannot send it without a CORS preflight. */
972
968
  const operationRpcHeader = "x-vitehub-console";
973
969
  /** Response header of the local dev RPC. Its value is {@link projectRootHash} of the project that the server runs. */
@@ -1389,5 +1385,4 @@ async function callOperationFromCli(call, name, input) {
1389
1385
  url
1390
1386
  }, name, input);
1391
1387
  }
1392
- //#endregion
1393
1388
  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 { t as redactInspectionText } from "./inspect-BIKQsqX4.js";
2
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
3
- import { t as kvDevMaximumListLimit } from "./results-D6jfPtCk.js";
4
- import { o as normalizeKey } from "./utils2-FozcTsmb.js";
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-DUIp6FhO.js";
4
+ import { t as kvDevMaximumListLimit } from "./results-emgN7uDS.js";
5
5
  import { kv } from "@vite-hub/kv";
6
- //#region src/runtime/inspect-value.ts
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
- //#endregion
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
- //#endregion
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 };
@@ -1,6 +1,5 @@
1
- import { c as KVDriver } from "./types-Cp6IBhSN.js";
2
- import { t as AnyOperation } from "./operation-definition-CI2PJGqu.js";
3
- //#region src/runtime/operations.d.ts
1
+ import { t as AnyOperation } from "./operation-definition-CqZkx1Rm.js";
2
+ import { c as KVDriver } from "./types-C397WKyf.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 };
@@ -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-nAaONxzh.js";
2
- import { t as kvDevMaximumListLimit } from "./results-D6jfPtCk.js";
3
- import { n as isViteHubLoopbackPeer } from "./dev-peer-CHafxbtj.js";
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-CGAX5ASA.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
- //#region ../internal/src/secret.ts
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
- //#endregion
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
- //#endregion
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
- //#endregion
240
- //#region src/operations.ts
241
- const runtime = () => import("./operations-CqKs7Ykc.js");
237
+ // src/operations.ts
238
+ const runtime = () => import("./operations-FgS_sJ3M.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 };