import type { Context } from "../context.ts";
import type { Secret } from "../secret.ts";
import { CloudflareApi, type CloudflareApiOptions } from "./api.ts";
/**
 * Properties for creating an AI Search Token
 */
export interface AiSearchTokenProps extends CloudflareApiOptions {
    /**
     * Name of the token
     * @default Uses the resource ID
     */
    name?: string;
    /**
     * Whether to adopt an existing token if one with the same name exists
     * @default false
     */
    adopt?: boolean;
    /**
     * Whether to delete the token when removed from Alchemy
     * @default true
     */
    delete?: boolean;
}
/**
 * AI Search Token output
 */
export type AiSearchToken = {
    /**
     * Resource type identifier for binding
     * @internal
     */
    type: "ai_search_token";
    /**
     * The AI Search token ID (UUID)
     */
    tokenId: string;
    /**
     * The underlying account API token ID (for lifecycle management)
     */
    accountTokenId: string;
    /**
     * The account ID
     */
    accountId: string;
    /**
     * The account tag
     */
    accountTag: string;
    /**
     * Name of the token
     */
    name: string;
    /**
     * The CF API ID for this token
     */
    cfApiId: string;
    /**
     * The CF API key for this token (stored as Secret)
     */
    cfApiKey: Secret;
    /**
     * Whether the token is enabled
     */
    enabled: boolean;
    /**
     * When the token was created
     */
    createdAt: string;
    /**
     * When the token was last modified
     */
    modifiedAt: string;
};
/**
 * API response for AI Search token
 * @internal
 */
interface AiSearchTokenApiResponse {
    id: string;
    account_id: string;
    account_tag: string;
    name: string;
    cf_api_id: string;
    cf_api_key: string;
    enabled: boolean;
    legacy: boolean;
    created_at: string;
    modified_at: string;
}
/**
 * Type guard for AiSearchToken
 */
export declare function isAiSearchToken(resource: unknown): resource is AiSearchToken;
/**
 * Creates an AI Search token for accessing AI Search instances.
 *
 * AI Search tokens are used to authenticate with the AI Search API and provide
 * access to R2 buckets or other data sources for indexing.
 *
 * This resource automatically:
 * 1. Creates an account API token with AI Search Index Engine and R2 Storage Write permissions
 * 2. Registers that token with the AI Search service
 *
 * @example
 * // Create an AI Search token
 * const token = await AiSearchToken("my-token", {
 *   name: "docs-search-token",
 * });
 *
 * // Use the token with an AI Search instance
 * const search = await AiSearch("docs-search", {
 *   source: {
 *     type: "r2",
 *     bucket: myBucket,
 *     token: token,
 *   },
 * });
 *
 * @example
 * // Let AiSearch auto-create a token (recommended)
 * const search = await AiSearch("docs-search", {
 *   source: {
 *     type: "r2",
 *     bucket: myBucket,
 *   },
 * });
 */
export declare const AiSearchToken: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<AiSearchToken>, id: string, props: AiSearchTokenProps) => Promise<AiSearchToken>);
/**
 * Create an AI Search token
 */
export declare function createAiSearchToken(api: CloudflareApi, payload: {
    name: string;
    cf_api_id: string;
    cf_api_key: string;
}): Promise<AiSearchTokenApiResponse>;
/**
 * List all AI Search tokens in an account
 */
export declare function listAiSearchTokens(api: CloudflareApi): Promise<AiSearchTokenApiResponse[]>;
/**
 * Delete an AI Search token.
 *
 * Retries briefly on `7076 token_in_use_by_instances` to cover residual
 * cross-colo lag (CF's server retries the guard internally once after
 * 500ms; the spurious-409 window is typically sub-second). We layer two
 * client-side retries with 1s + 2s delays on top.
 *
 * A persistent 409 after the short retry window means the token is
 * genuinely still referenced by another AI Search instance. We throw an
 * actionable error rather than silently leaking the token — shared tokens
 * should be modeled explicitly via an `AiSearchToken` resource.
 */
export declare function deleteAiSearchToken(api: CloudflareApi, tokenId: string): Promise<void>;
/**
 * Get an AI Search token
 */
export declare function getAiSearchToken(api: CloudflareApi, tokenId: string): Promise<AiSearchTokenApiResponse>;
export {};
//# sourceMappingURL=ai-search-token.d.ts.map