UNPKG

@adpt/core

Version:
44 lines 1.69 kB
/// <reference types="node" /> import { CustomError } from "ts-custom-error"; import { URL } from "url"; import { HistoryStore } from "./history"; export declare const $serverLock: unique symbol; export interface ServerLock { [$serverLock]: true; } export interface AdaptServer { init(): Promise<void>; destroy(): Promise<void>; set(dataPath: string, val: any, options?: SetOptions): Promise<void>; get(dataPath: string, options?: GetOptions): Promise<any>; delete(dataPath: string, options?: DeleteOptions): Promise<void>; lock(): Promise<ServerLock>; unlock(lock: ServerLock): Promise<void>; historyStore(dataPath: string, init: boolean): Promise<HistoryStore>; } export interface OptionsWithLock { lock?: ServerLock; } export interface SetOptions extends OptionsWithLock { mustCreate?: boolean; } export interface GetOptions extends OptionsWithLock { } export interface DeleteOptions extends OptionsWithLock { } export interface ServerOptions { } export interface AdaptServerType { urlMatch: RegExp; new (url: URL, options: ServerOptions): AdaptServer; } export declare function mockServerTypes_(sTypes?: AdaptServerType[]): AdaptServerType[]; export declare function register(serverType: AdaptServerType): void; export declare function adaptServer(url: string, options: ServerOptions): Promise<AdaptServer>; export declare function withLock<T>(server: AdaptServer, f: (l: ServerLock) => Promise<T>): Promise<T>; export declare class ServerPathExists extends CustomError { path: string; constructor(path: string); } export declare function isServerPathExists(val: any): val is ServerPathExists; //# sourceMappingURL=server.d.ts.map