import { ObjectType, Validation, ValidationResult } from 'yaschva'; export declare type AuthenticationDefinition = (string | { createdBy: boolean; })[] | boolean; export declare type ManageableFields = { createdBy?: boolean; id?: boolean; }; export declare type HttpMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; export declare type SearchTypes = 'textSearch' | 'full' | 'idOnly' | ObjectType; export declare type AuthInput = { permissions?: string[]; sub?: string; }; export declare type KeyValueStoreTypes = 'memory' | 'workerKV' | { custom: string; }; export declare type BackEndTypes = 'manual' | 'elasticsearch' | 'key-value'; export declare namespace Implementations { /** Expect manual implementation, nothing is generated**/ type manual = { type: 'manual'; }; /** Generate generic elasticsearch backend **/ type elasticsearch = { type: 'elasticsearch'; index: string; maxResults?: number; }; /** Generate a generic key value store implementation use either: * - in memory : only for testing / dev, no persistance * - workerKV : using the HTTP API for cloudflare worker key value store. * requires ENV vars to be set * - custom : Use the implementation provided under global.customKV[custom] * **/ type keyValue = { type: 'key-value'; prefix: string; backend: KeyValueStoreTypes; allowGetAll?: true; }; } export declare type Implementation = { type: string; } & (Implementations.manual | Implementations.elasticsearch | Implementations.keyValue); export declare type ContractType = { name: string; type: METHOD; manageFields: ManageableFields; handle?: (input: IN, auth: AuthInput, contract: ContractType, id?: string) => Promise>; arguments: Validation; returns: Validation; authentication: AuthenticationDefinition; implementation: IMPL; }; export declare type AnyContract = ContractType; export declare type HandleErrorResponse = { errorType: string; data?: any; status: number; errors: ValidationResult | string[]; result?: void; }; export declare type HandleResultSuccess = { result: OUT; status?: number; cursor?: string; more?: boolean; errors?: void; errorType?: void; }; export declare type HandleResult = HandleErrorResponse | HandleResultSuccess; export declare const isContractInError: (tbd: HandleResult) => tbd is HandleErrorResponse;