import * as _alepha_cache0 from "alepha/cache";
import { CacheDescriptorOptions } from "alepha/cache";
import * as _alepha_core1 from "alepha";
import * as _alepha_core0 from "alepha";
import { Alepha } from "alepha";
import { DateTimeProvider, DurationLike } from "alepha/datetime";
import { RequestConfigSchema, ServerRequest, ServerRoute } from "alepha/server";

//#region src/providers/ServerCacheProvider.d.ts
declare module "alepha/server" {
  interface ServerRoute {
    cache?: ServerRouteCache;
  }
  interface ActionDescriptor<TConfig extends RequestConfigSchema> {
    invalidate: () => Promise<void>;
  }
}
declare class ServerCacheProvider {
  protected readonly log: _alepha_core1.Logger;
  protected readonly alepha: Alepha;
  protected readonly time: DateTimeProvider;
  protected readonly cache: _alepha_cache0.CacheDescriptorFn<RouteCacheEntry, any[]>;
  generateETag(content: string): string;
  invalidate(route: ServerRoute): Promise<void>;
  protected readonly onActionRequest: _alepha_core1.HookDescriptor<"action:onRequest">;
  protected readonly onActionResponse: _alepha_core1.HookDescriptor<"action:onResponse">;
  protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
  protected readonly onResponse: _alepha_core1.HookDescriptor<"server:onResponse">;
  protected getCacheOptions(cache: ServerRouteCache): {
    provider?: (_alepha_core1.InstantiableClass<_alepha_cache0.CacheProvider> | "memory") | undefined;
    name?: string | undefined;
    ttl?: DurationLike | undefined;
    disabled?: boolean | undefined;
  };
  protected createCacheKey(route: ServerRoute, config?: ServerRequest): string;
}
type ServerRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
interface RouteCacheEntry {
  contentType?: string;
  body: any;
  status?: number;
  lastModified: string;
  hash: string;
}
//#endregion
//#region src/index.d.ts
/**
 * Plugin for Alepha Server that provides server-side caching capabilities.
 * It uses the Alepha Cache module to cache responses from server actions ($action).
 * It also provides a ETag-based cache invalidation mechanism.
 *
 * @example
 * ```ts
 * import { Alepha } from "alepha";
 * import { $action } from "alepha/server";
 * import { AlephaServerCache } from "alepha/server/cache";
 *
 * class ApiServer {
 *   hello = $action({
 *     cache: true,
 *     handler: () => "Hello, World!",
 *   });
 * }
 *
 * const alepha = Alepha.create()
 *   .with(AlephaServerCache)
 *   .with(ApiServer);
 *
 * run(alepha);
 * ```
 *
 * @see {@link ServerCacheProvider}
 * @module alepha.server.cache
 */
declare const AlephaServerCache: _alepha_core0.Service<_alepha_core0.Module>;
//# sourceMappingURL=index.d.ts.map

//#endregion
export { AlephaServerCache, ServerCacheProvider, ServerRouteCache };
//# sourceMappingURL=index.d.ts.map