import Joi from 'joi'; import { CancelTokenSource } from 'axios'; import Comms from '.'; interface VersionedAnySchemaFunction { (apiVersion: number): Joi.AnySchema; } interface ControllerGeneratorOptions { description?: string; method: 'get' | 'post' | 'put' | 'delete' | 'all'; path: string; params?: Joi.ObjectSchema; query?: Joi.AnySchema; body?: Joi.AnySchema | VersionedAnySchemaFunction; response?: Joi.AnySchema | VersionedAnySchemaFunction; right: { supplier?: string; environment?: string; }; } type ControllerGeneratorOptionsWithoutClientOrSupplier = ControllerGeneratorOptions & { right: Record; }; type ENVIRONMENT_ADMIN = 'ENVIRONMENT_ADMIN'; type EnvironmentRights = 'READ' | 'STATIC' | 'ISSUES' | 'AUDIT_TRAIL' | 'USERS' | 'EXPORT' | 'SENSORS' | 'REPORTS' | 'THRESHOLDS' | 'IMPORT' | ENVIRONMENT_ADMIN; type SupplierRights = ENVIRONMENT_ADMIN; type ControllerGeneratorOptionsWithClient = ControllerGeneratorOptions & { right: { environment: EnvironmentRights; }; }; type ControllerGeneratorOptionsWithSupplier = ControllerGeneratorOptions & { right: { supplier: SupplierRights; }; }; type ControllerGeneratorOptionsWithClientAndSupplier = ControllerGeneratorOptions & { right: { environment: EnvironmentRights; supplier: SupplierRights; }; }; type RequestParams = Record; type RequestQuery = Record; interface Request { params?: RequestParams; query?: RequestQuery; body?: any; options?: { /** * If provided AND false, response will not be validated against Joi schema. * This will save quite some time, but will cause Date objects to still be strings * Note: defaults are already filled server side, so that's not an issue */ validateResponse: boolean; }; } interface Result { request: EffectiveRequestImplementation; response: Promise; cancelToken: CancelTokenSource; } declare const _default: (options: ControllerGeneratorOptions, routerPath: string, auth: boolean, comms: Comms) => (parameters: RequestImplementation) => Result; export default _default; export { RequestQuery, RequestParams, Request, Result, ControllerGeneratorOptions, ControllerGeneratorOptionsWithoutClientOrSupplier, ControllerGeneratorOptionsWithClient, ControllerGeneratorOptionsWithSupplier, ControllerGeneratorOptionsWithClientAndSupplier, };