import * as _nuxt_schema from '@nuxt/schema';
import { R2HTTPMetadata, ReadableStream, D1Database as D1Database$1, Vectorize as Vectorize$1 } from '@cloudflare/workers-types/experimental';
import { MimeType } from '@uploadthing/mime-types';
import { Storage } from 'unstorage';

interface ModuleHooks {
    /**
     * Add directories to the database migrations.
     * @param dirs - The path of the migrations directories to add.
     * @returns void | Promise<void>
     */
    'hub:database:migrations:dirs': (dirs: string[]) => void | Promise<void>;
    /**
     * Add queries to run after the database migrations are applied but are not tracked in the _hub_migrations table.
     * @param queries - The path of the SQL queries paths to add.
     * @returns void | Promise<void>
     */
    'hub:database:queries:paths': (queries: string[]) => void | Promise<void>;
}
interface ModuleOptions {
    /**
     * Set `true` if the project type is Workers.
     *
     * If `nitro.experimental.websocket` is enabled, the preset will be set to `cloudflare_durable`, otherwise the preset will be `cloudflare_module`.
     *
     * @default false
     */
    workers?: boolean;
    /**
     * Set `true` to enable AI for the project.
     *
     * Requires running `npx nuxthub link` for local development.
     *
     * @default false
     * @see https://hub.nuxt.com/docs/features/ai
     */
    ai?: boolean;
    /**
     * Set `true` to enable the analytics for the project.
     *
     * @default false
     */
    analytics?: boolean;
    /**
     * Set `true` to enable the Blob storage for the project.
     *
     * @default false
     * @see https://hub.nuxt.com/docs/features/blob
     */
    blob?: boolean;
    /**
     * Set `true` to enable the Browser rendering for the project.
     *
     * @default false
     * @see https://hub.nuxt.com/docs/features/browser
     */
    browser?: boolean;
    /**
     * Set `true` to enable caching for the project.
     *
     * @default false
     * @see https://hub.nuxt.com/docs/features/cache
     */
    cache?: boolean;
    /**
     * Set `true` to enable the database for the project.
     *
     * @default false
     * @see https://hub.nuxt.com/docs/features/database
     */
    database?: boolean;
    /**
     * Set `true` to enable the Key-Value storage for the project.
     *
     * @default false
     * @see https://hub.nuxt.com/docs/features/kv
     */
    kv?: boolean;
    /**
     * Set Vectorize indexes for the project.
     *
     * Currently there is a limit of 10 metadata indexes per vectorize index.
     *
     * @default {}
     * @see https://hub.nuxt.com/docs/features/vectorize
     *
     * @example
     * ```ts
     * vectorize: {
     *   products: {
     *     metric: 'cosine',
     *     dimensions: '768',
     *     metadataIndexes: { name: 'string', price: 'number', isActive: 'boolean' }
     *   },
     *   reviews: {
     *     metric: 'cosine',
     *     dimensions: '768',
     *     metadataIndexes: { rating: 'number' }
     *   }
     * }
     * ```
     */
    vectorize: {
        [key: string]: {
            metric: 'cosine' | 'euclidean' | 'dot-product';
            dimensions: number;
            metadataIndexes?: Record<string, 'string' | 'number' | 'boolean'>;
        };
    };
    /**
     * Set to `true`, 'preview' or 'production' to use the remote storage.
     * Only set the value on a project you are deploying outside of NuxtHub or Cloudflare.
     * Or wrap it with $development to only use it in development mode.
     * @default process.env.NUXT_HUB_REMOTE or --remote option when running `nuxt dev`
     * @see https://hub.nuxt.com/docs/getting-started/remote-storage
     */
    remote?: boolean | 'production' | 'preview';
    /**
     * The URL of the NuxtHub Admin
     * @default 'https://admin.hub.nuxt.com'
     */
    url?: string;
    /**
     * The project's key on the NuxtHub platform, added with `npx nuxthub link`.
     * @default process.env.NUXT_HUB_PROJECT_KEY
     */
    projectKey?: string;
    /**
     * The user token to access the NuxtHub platform, added with `npx nuxthub login`
     * @default process.env.NUXT_HUB_USER_TOKEN
     */
    userToken?: string;
    /**
     * The URL of the deployed project, used to fetch the remote storage.
     * @default process.env.NUXT_HUB_PROJECT_URL
     */
    projectUrl?: string | (({ env, branch }: {
        env: 'production' | 'preview';
        branch: string;
    }) => string);
    /**
     * The secret key defined in the deployed project as env variable, used to fetch the remote storage from the projectUrl
     * @default process.env.NUXT_HUB_PROJECT_SECRET_KEY
     */
    projectSecretKey?: string;
    /**
     * The directory used for storage (D1, KV, R2, etc.) in development mode.
     * @default '.data/hub'
     */
    dir?: string;
    /**
     * The extra bindings for the project.
     * @default {}
     */
    bindings?: {
        /**
         * The compatibility date for the project.
         * @see https://developers.cloudflare.com/workers/configuration/compatibility-dates/
         */
        compatibilityDate?: string;
        /**
         * Extra compatibility flags for the project.
         * Note that NuxtHub will default to the Nitro compatibility flags for Cloudflare if not specified.
         * @see https://developers.cloudflare.com/workers/configuration/compatibility-dates/#compatibility-flags
         */
        compatibilityFlags?: string[];
        /**
         * The hyperdrive bindings for the project, used only when deployed on Cloudflare.
         * @see https://hub.nuxt.com/docs/features/hyperdrive
         * @default {}
         * @example
         * ```ts
         * bindings: {
         *   hyperdrive: {
         *     POSTGRES: '<your-hyperdrive-id>'
         *   }
         * }
         * ```
         */
        hyperdrive?: {
            /**
             * The key of the binding, accessible in the project as `process.env.<key>`.
             * The value is the ID of the hyperdrive instance.
             */
            [key: string]: string;
        };
    };
    /**
     * Cloudflare Access authentication for remote storage.
     * @see https://hub.nuxt.com/recipes/cloudflare-access
     */
    cloudflareAccess?: {
        /**
         * The client ID for Cloudflare Access.
         * @default process.env.NUXT_HUB_CLOUDFLARE_ACCESS_CLIENT_ID
         */
        clientId?: string;
        /**
         * The client secret for Cloudflare Access.
         * @default process.env.NUXT_HUB_CLOUDFLARE_ACCESS_CLIENT_SECRET
         */
        clientSecret?: string;
    };
}

type PowOf2 = 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 | 512 | 1024;
type SizeUnit = 'B' | 'KB' | 'MB' | 'GB';
type BlobSize = `${PowOf2}${SizeUnit}`;
type BlobType = 'image' | 'video' | 'audio' | 'pdf' | 'text' | 'blob' | MimeType;
type FileSizeUnit = 'B' | 'KB' | 'MB' | 'GB';
interface BlobObject {
    /**
     * The pathname of the blob, used to @see {@link HubBlob.serve} the blob.
     */
    pathname: string;
    /**
     * The content type of the blob.
     */
    contentType: string | undefined;
    /**
     * The size of the blob in bytes.
     */
    size: number;
    /**
     * The blob's etag, in quotes so as to be returned as a header.
     */
    httpEtag: string;
    /**
     * The date the blob was uploaded at.
     */
    uploadedAt: Date;
    /**
     * The HTTP metadata of the blob.
     */
    httpMetadata: R2HTTPMetadata;
    /**
     * The custom metadata of the blob.
     */
    customMetadata: Record<string, string>;
}
interface BlobUploadedPart {
    /**
     * The number of the part.
     */
    partNumber: number;
    /**
     * The etag of the part.
     */
    etag: string;
}
interface BlobMultipartUpload {
    /**
     * The pathname of the multipart upload.
     */
    readonly pathname: string;
    /**
     * The upload id of the multipart upload.
     */
    readonly uploadId: string;
    /**
     * Upload a single part to this multipart upload.
     */
    uploadPart(partNumber: number, value: string | ReadableStream<any> | ArrayBuffer | ArrayBufferView | Blob): Promise<BlobUploadedPart>;
    /**
     * Abort the multipart upload.
     */
    abort(): Promise<void>;
    /**
     * Completes the multipart upload.
     */
    complete(uploadedParts: BlobUploadedPart[]): Promise<BlobObject>;
}
interface BlobListOptions {
    /**
     * The maximum number of blobs to return per request.
     * @default 1000
     */
    limit?: number;
    /**
     * The prefix to filter the blobs by.
     */
    prefix?: string;
    /**
     * The cursor to list the blobs from (used for pagination).
     */
    cursor?: string;
    /**
     * View prefixes as directory.
     */
    folded?: boolean;
}
interface BlobPutOptions {
    /**
     * The content type of the blob.
     */
    contentType?: string;
    /**
     * The content length of the blob.
     */
    contentLength?: string;
    /**
     * If a random suffix is added to the blob pathname.
     * @default false
     */
    addRandomSuffix?: boolean;
    /**
     * The prefix to use for the blob pathname.
     */
    prefix?: string;
    /**
     * The custom metadata of the blob.
     */
    customMetadata?: Record<string, string>;
    /**
     * @deprecated Use customMetadata instead.
     */
    [key: string]: any;
}
interface BlobMultipartOptions {
    /**
     * The content type of the blob.
     */
    contentType?: string;
    /**
     * The content length of the blob.
     */
    contentLength?: string;
    /**
     * If a random suffix is added to the blob pathname.
     * @default false
     */
    addRandomSuffix?: boolean;
    /**
     * The prefix to use for the blob pathname.
     */
    prefix?: string;
    /**
     * The custom metadata of the blob.
     */
    customMetadata?: Record<string, string>;
    /**
     * @deprecated Use customMetadata instead.
     */
    [key: string]: any;
}
type HandleMPUResponse = {
    action: 'create';
    data: Pick<BlobMultipartUpload, 'pathname' | 'uploadId'>;
} | {
    action: 'upload';
    data: BlobUploadedPart;
} | {
    action: 'complete';
    data: BlobObject;
} | {
    action: 'abort';
};
interface BlobUploadOptions {
    /**
     * The key to get the file/files from the request form.
     * @default 'files'
     */
    formKey?: string;
    /**
     * Whether to allow multiple files to be uploaded.
     * @default true
     */
    multiple?: boolean;
    /**
     * Options used for the ensure() method.
     * @see https://hub.nuxt.com/docs/features/blob#ensureblob
     */
    ensure?: BlobEnsureOptions;
    /**
     * Options used for the put() method.
     * @see https://hub.nuxt.com/docs/features/blob#put
     */
    put?: BlobPutOptions;
}
interface BlobEnsureOptions {
    /**
     * The maximum size of the blob (e.g. '1MB')
     */
    maxSize?: BlobSize;
    /**
     * The allowed types of the blob (e.g. ['image/png', 'application/json', 'video'])
     */
    types?: BlobType[];
}
interface BlobListResult {
    /**
     * The list of blobs.
     */
    blobs: BlobObject[];
    /**
     * The Boolean indicating if there are more blobs to list.
     */
    hasMore: boolean;
    /**
     * The cursor to use for pagination.
     */
    cursor?: string;
    /**
     * The list of folders with `/` delimiter.
     */
    folders?: string[];
}
interface BlobCredentialsOptions {
    /**
     * The permission of the credentials.
     * @default 'admin-read-write'
     */
    permission?: 'admin-read-write' | 'admin-read-only' | 'object-read-write' | 'object-read-only';
    /**
     * The ttl of the credentials in seconds.
     * @default 900
     */
    ttl?: number;
    /**
     * The prefixes to scope the credentials to.
     */
    prefixes?: string[];
    /**
     * The pathnames to scope the credentials to.
     */
    pathnames?: string[];
}
interface BlobCredentials {
    /**
     * The Cloudflare account id
     */
    accountId: string;
    /**
     * The Cloudflare R2 bucket name
     */
    bucketName: string;
    /**
     * The access key id for the R2 bucket
     */
    accessKeyId: string;
    /**
     * The secret access key for the R2 bucket
     */
    secretAccessKey: string;
    /**
     * The session token for the R2 bucket
     */
    sessionToken: string;
}

type OmitDump<T> = Omit<T, 'dump'>;
type D1Database = OmitDump<D1Database$1>;

interface HubKV extends Storage {
    /**
     * Get all keys from the storage.
     *
     * @see https://hub.nuxt.com/docs/features/kv#list-all-keys
     */
    keys: Storage['getKeys'];
    /**
     * Get an item from the storage.
     *
     * @param key The key to get
     *
     * @see https://hub.nuxt.com/docs/features/kv#get-an-item
     */
    get: Storage['getItem'];
    /**
     * Set an item in the storage.
     *
     * @param key The key to set
     * @param value The value to set
     * @param options The options to set (optional)
     * @param options.ttl The time to live in seconds (optional)
     *
     * @see https://hub.nuxt.com/docs/features/kv#set-an-item
     */
    set: Storage['setItem'];
    /**
     * Check if an item exists in the storage.
     *
     * @param key The key to check
     *
     * @see https://hub.nuxt.com/docs/features/kv#has-an-item
     */
    has: Storage['hasItem'];
    /**
     * Delete an item from the storage.
     *
     * @param key The key to delete
     *
     * @see https://hub.nuxt.com/docs/features/kv#delete-an-item
     */
    del: Storage['removeItem'];
}

type Vectorize = Vectorize$1;

declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;

export { _default as default };
export type { BlobCredentials, BlobCredentialsOptions, BlobEnsureOptions, BlobListOptions, BlobListResult, BlobMultipartOptions, BlobMultipartUpload, BlobObject, BlobPutOptions, BlobSize, BlobType, BlobUploadOptions, BlobUploadedPart, D1Database, FileSizeUnit, HandleMPUResponse, HubKV, ModuleHooks, ModuleOptions, PowOf2, SizeUnit, Vectorize };
