/** * Reusable HTTP storage services for FileTree-style backends. * @packageDocumentation */ import { Converter } from '@fgv/ts-utils'; import { Hono } from 'hono'; import type { Logging } from '@fgv/ts-utils'; import { Result } from '@fgv/ts-utils'; /** * Builds storage routes for a Hono app. * @public */ export declare function createStorageRoutes(options: ICreateStorageRoutesOptions): Hono; /** * Filesystem-backed implementation of {@link IHttpStorageProvider}. * @public */ export declare class FsStorageProvider implements IHttpStorageProvider { private readonly _rootPath; constructor(rootPath: string); getItem(itemPath: string): Promise>; getChildren(itemPath: string): Promise>>; getFile(itemPath: string): Promise>; saveFile(itemPath: string, contents: string, contentType?: string): Promise>; deleteFile(itemPath: string): Promise>; createDirectory(itemPath: string): Promise>; sync(): Promise>; private _resolveAbsolutePath; private _toTreeItem; } /** * Namespace-aware provider factory backed by filesystem directories. * @public */ export declare class FsStorageProviderFactory implements IHttpStorageProviderFactory { private readonly _rootPath; constructor(options: IFsStorageProviderFactoryOptions); forNamespace(namespace?: string): Result; } /** * Service layer for storage API operations. * @public */ export declare class HttpStorageService { private readonly _providers; constructor(providers: IHttpStorageProviderFactory); getItem(request: IStoragePathRequest): Promise>; getChildren(request: IStoragePathRequest): Promise>; getFile(request: IStoragePathRequest): Promise>; saveFile(request: IStorageWriteFileRequest): Promise>; deleteFile(request: IStoragePathRequest): Promise>; createDirectory(request: IStoragePathRequest): Promise>; sync(request: IStorageSyncRequest): Promise>; private _getProvider; } /** * Options for creating storage routes. * @public */ export declare interface ICreateStorageRoutesOptions { readonly providers: IHttpStorageProviderFactory; readonly logger?: Logging.ILogger; } /** * Options for creating filesystem-backed storage providers. * @public */ export declare interface IFsStorageProviderFactoryOptions { readonly rootPath: string; } /** * Provider contract for storage backends. * All methods are async to support both filesystem and database backends. * @public */ export declare interface IHttpStorageProvider { getItem(path: string): Promise>; getChildren(path: string): Promise>>; getFile(path: string): Promise>; saveFile(path: string, contents: string, contentType?: string): Promise>; deleteFile(path: string): Promise>; createDirectory(path: string): Promise>; sync(): Promise>; } /** * Factory for creating namespace-scoped storage providers. * @public */ export declare interface IHttpStorageProviderFactory { forNamespace(namespace?: StorageNamespace): Result; } /** * Response for reading a file. * @public */ export declare interface IStorageFileResponse { readonly path: string; readonly contents: string; readonly contentType?: string; } /** * Request for path-based operations. * @public */ export declare interface IStoragePathRequest { readonly path: string; readonly namespace?: StorageNamespace; } /** * Request for sync operation. * @public */ export declare interface IStorageSyncRequest { readonly namespace?: StorageNamespace; } /** * Sync response metadata. * @public */ export declare interface IStorageSyncResponse { readonly synced: number; } /** * Response for listing children. * @public */ export declare interface IStorageTreeChildrenResponse { readonly path: string; readonly children: ReadonlyArray; } /** * Storage tree item metadata. * @public */ export declare interface IStorageTreeItem { readonly path: string; readonly name: string; readonly type: StorageItemType; } /** * Request for writing file contents. * @public */ export declare interface IStorageWriteFileRequest extends IStoragePathRequest { readonly contents: string; readonly contentType?: string; } /** * Normalizes a request path to a consistent POSIX format. * @public */ export declare function normalizeRequestPath(requestPath: string): string; /** * Sanitize namespace path segment. * @public */ export declare function sanitizeNamespace(namespace?: string): Result; /** * Converter for file responses. * @public */ export declare const storageFileResponse: Converter; /** * Storage item type. * @public */ export declare type StorageItemType = 'file' | 'directory'; /** * Namespace identifier for scoped storage. * @public */ export declare type StorageNamespace = string; /** * Converter for path-based requests. * @public */ export declare const storagePathRequest: Converter; /** * Converter for sync requests. * @public */ export declare const storageSyncRequest: Converter; /** * Converter for children list responses. * @public */ export declare const storageTreeChildrenResponse: Converter; /** * Converter for {@link IStorageTreeItem}. * @public */ export declare const storageTreeItem: Converter; /** * Converter for write-file requests. * @public */ export declare const storageWriteFileRequest: Converter; export { }