@vite-hub/kv 0.0.1 → 0.0.3

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/dist/nuxt.js DELETED
@@ -1,32 +0,0 @@
1
- import { n as assertNoVitePlugin, t as assertNoNitroModule } from "./nitro-B8aUYcjq.js";
2
- import { defineNuxtModule } from "@nuxt/kit";
3
- //#region src/nuxt/module.ts
4
- const NITRO_MODULE_ID = "@vite-hub/kv/nitro";
5
- const NITRO_MODULE_NAME = "@vite-hub/kv";
6
- const NUXT_MODULE_ID = "@vite-hub/kv/nuxt";
7
- const VITE_PLUGIN_NAME = "@vite-hub/kv/vite";
8
- const installedNitroConfigs = /* @__PURE__ */ new WeakSet();
9
- function installKVNitroModule(nitro, kv) {
10
- nitro.modules ||= [];
11
- if (!nitro.modules.includes(NITRO_MODULE_ID)) nitro.modules.push(NITRO_MODULE_ID);
12
- if (kv !== void 0) nitro.kv = kv;
13
- installedNitroConfigs.add(nitro);
14
- }
15
- const kvNuxtModule = defineNuxtModule({
16
- meta: {
17
- configKey: "kv",
18
- name: NUXT_MODULE_ID
19
- },
20
- async setup(inlineOptions, nuxt) {
21
- const topLevel = nuxt.options.kv;
22
- if (topLevel === false) return;
23
- const kv = topLevel ?? inlineOptions;
24
- nuxt.options.nitro ||= {};
25
- await assertNoVitePlugin(nuxt.options.vite, VITE_PLUGIN_NAME, NUXT_MODULE_ID);
26
- if (!installedNitroConfigs.has(nuxt.options.nitro)) assertNoNitroModule(nuxt.options.nitro, NITRO_MODULE_ID, NITRO_MODULE_NAME, NUXT_MODULE_ID);
27
- installKVNitroModule(nuxt.options.nitro, kv);
28
- nuxt.hook("nitro:config", (config) => installKVNitroModule(config, kv));
29
- }
30
- });
31
- //#endregion
32
- export { kvNuxtModule as default };
@@ -1,6 +0,0 @@
1
- import { definePlugin } from "nitro";
2
-
3
- //#region src/runtime/nitro-plugin.d.ts
4
- declare const kvNitroPlugin: ReturnType<typeof definePlugin>;
5
- //#endregion
6
- export { kvNitroPlugin as default };
@@ -1,26 +0,0 @@
1
- import { t as createLazyKVRuntimeDriver } from "../driver-CPgLtkh4.js";
2
- import { definePlugin } from "nitro";
3
- import { useRuntimeConfig } from "nitro/runtime-config";
4
- import { useStorage } from "nitro/storage";
5
- //#region src/runtime/nitro-plugin.ts
6
- const kvNitroPlugin = definePlugin(async () => {
7
- const runtimeConfig = useRuntimeConfig();
8
- if (!runtimeConfig.kv) return;
9
- const storage = useStorage();
10
- await storage.unmount("kv");
11
- storage.mount("kv", createLazyKVRuntimeDriver(runtimeConfig.kv));
12
- const stores = runtimeConfig.kv.stores || { default: runtimeConfig.kv.store };
13
- for (const [name, store] of Object.entries(stores)) {
14
- if (name === "default") continue;
15
- await storage.unmount(`kv:${name}`);
16
- storage.mount(`kv:${name}`, createLazyKVRuntimeDriver({
17
- store,
18
- stores: {
19
- default: store,
20
- [name]: store
21
- }
22
- }));
23
- }
24
- });
25
- //#endregion
26
- export { kvNitroPlugin as default };
@@ -1,45 +0,0 @@
1
- //#region src/types.d.ts
2
- type KVDriver = "cloudflare-kv-binding" | "upstash" | "fs-lite";
3
- interface CloudflareKVStoreConfig {
4
- driver: "cloudflare-kv-binding";
5
- binding?: string;
6
- namespaceId?: string;
7
- }
8
- interface UpstashKVStoreConfig {
9
- driver: "upstash";
10
- token?: string;
11
- url?: string;
12
- }
13
- interface FsLiteKVStoreConfig {
14
- driver: "fs-lite";
15
- base?: string;
16
- }
17
- type KVStoreConfig = CloudflareKVStoreConfig | UpstashKVStoreConfig | FsLiteKVStoreConfig;
18
- interface ResolvedCloudflareKVStoreConfig extends CloudflareKVStoreConfig {
19
- binding: string;
20
- }
21
- type ResolvedUpstashKVStoreConfig = Required<UpstashKVStoreConfig>;
22
- interface ResolvedFsLiteKVStoreConfig extends FsLiteKVStoreConfig {
23
- base: string;
24
- }
25
- type ResolvedKVStoreConfig = ResolvedCloudflareKVStoreConfig | ResolvedUpstashKVStoreConfig | ResolvedFsLiteKVStoreConfig;
26
- type KVStoreName = "default" | (string & {});
27
- interface KVStoresConfig {
28
- stores: Record<string, KVStoreConfig>;
29
- }
30
- type KVModuleOptions = KVStoreConfig | KVStoresConfig | false;
31
- interface ResolvedKVModuleOptions {
32
- store: ResolvedKVStoreConfig;
33
- stores?: Record<string, ResolvedKVStoreConfig>;
34
- }
35
- interface KVStorage {
36
- clear(base?: string, options?: unknown): Promise<void>;
37
- del(key: string, options?: unknown): Promise<void>;
38
- get<T = unknown>(key: string, options?: unknown): Promise<T | null>;
39
- has(key: string, options?: unknown): Promise<boolean>;
40
- keys(base?: string, options?: unknown): Promise<string[]>;
41
- set<T = unknown>(key: string, value: T, options?: unknown): Promise<void>;
42
- store(name: KVStoreName): KVStorage;
43
- }
44
- //#endregion
45
- export { KVStorage as a, ResolvedFsLiteKVStoreConfig as c, ResolvedUpstashKVStoreConfig as d, UpstashKVStoreConfig as f, KVModuleOptions as i, ResolvedKVModuleOptions as l, FsLiteKVStoreConfig as n, KVStoreConfig as o, KVDriver as r, ResolvedCloudflareKVStoreConfig as s, CloudflareKVStoreConfig as t, ResolvedKVStoreConfig as u };