import * as Joi from "joi";
import * as ts from "./interfaces";
/**
 * @description casts input as string. used as inputs are passed to validators.
 * @param {*} arg
 */
export declare const castString: (arg: any) => string;
/**
 * @description attempts to case value as Number. if NaN - casts as verbose string that will fail validation and get returned to the user. used as inputs are passed to validators.
 * @param {*} arg
 * @returns
 */
export declare const castNumber: (arg: any) => string | number;
/**
 * @description attempts to cast falsey values to Boolean False. used as inputs are passed to validators.
 * @param {*} arg
 */
export declare const castBoolean: (arg: any) => boolean;
/**
 * @description
 * @param {*} arg
 */
export declare const castOther: (arg: any) => any;
/**
 * @description Fn that takes string input of a data type, and returns a Fn that will convert an input into target type. Boolean defines some string inputs as falesy and returns false.
 * @param {string} type
 * @returns {(ts.ITypeCastString
 *   | ts.ITypeCastNumber
 *   | ts.ITypeCastBoolean
 *   | ts.IDefaultTypeCast
 *   | any)}
 */
export declare const typecastFn: (type: string) => ts.ITypeCastString | ts.ITypeCastNumber | ts.ITypeCastBoolean | ts.IDefaultTypeCast | any;
/**
 * @description Fn that takes a JOI validator as input and modifies fields (making required or totally removing) fields that are marked with appropriate SYMBOLS. This is useful so that validators that define records 1:1 with db resource DDLs (table, view, materialized view), dynamically get modified to support full CRUD operations.
 * @param {Joi.Schema} validator
 * @param {string} [operation='original']
 * @returns {Joi.Schema}
 */
export declare const modifyValidator: (validator: Joi.Schema, operation?: string) => Joi.Schema;
export declare const validate: {
    /**
     * @description
     * @param {Joi.Schema} validator
     * @returns {Joi.Schema}
     */
    create: (validator: Joi.Schema) => Joi.Schema;
    /**
     * @description
     * @param {Joi.Schema} validator
     * @returns {Joi.Schema}
     */
    read: (validator: Joi.Schema) => Joi.Schema;
    /**
     * @description
     * @param {Joi.Schema} validator
     * @returns {Joi.Schema}
     */
    update: (validator: Joi.Schema) => Joi.Schema;
    /**
     * @description
     * @param {Joi.Schema} validator
     * @returns {Joi.Schema}
     */
    delete: (validator: Joi.Schema) => Joi.Schema;
    /**
     * @description
     * @param {Joi.Schema} validator
     * @returns {Joi.Schema}
     */
    search: (validator: Joi.Schema) => Joi.Schema;
};
/**
 * @description Reducer Fn that inspects a given schema from fields/keys within a JOI validator object and reports meta information about the specific field. This information is used extensively in this framework for autogeneration of openapi docs, pks to use for unique records, dynamic enabling of geoquery interfaces, and typecasting of query string input before building SQL statements.
 * @param {object} accum
 * @param {*} { id, schema }
 * @returns {ts.IValidatorInspectorReport}
 */
export declare const reducerValidatorInspector: (accum: object, { id, schema }: {
    id: any;
    schema: any;
}) => ts.IValidatorInspectorReport;
/**
 * @description Used for swagger generation and for validating user queries. Real validator cannot be used as those are plain objects and may need to validate field multiple times (ex: sql where field <= 5 and >= 12 -- needs to validate high & low values against field level validator. `redactedFields` are omitted from this output as it powers openapi generation (which reads from resource.report[method]).
 * @param {Joi.Schema} validator
 * @param {string[]} redactedFields
 * @returns {ts.IValidatorInspectorReport}
 */
export declare const validatorInspector: (validator: Joi.Schema, redactedFields: string[]) => ts.IValidatorInspectorReport;
export declare const errorMessageInvalidValue: (field: string, message: string) => string;
/**
 * @description Fn that generates error message when GET query produces error for various reasons. Defined errors were generated via JOI validation checks. undefined types occur when trying to query a column that doesn't exist on the record. Final fallback is for when a query operation is called on a field that is not supported.
 * @param {ts.IParamsGenerateSearchQueryError} {error, field, type, operation}
 * @returns {string}
 */
export declare const generateSearchQueryError: ({ error, field, type, operation, }: ts.IParamsGenerateSearchQueryError) => string;
/**
 * @description Fn that generates verbose error message string when specific number of args not used with a given operation. Only a few operations have specific arg lengths.
 * @param {string} operation
 * @param {any[]} values
 * @returns {string}
 */
export declare const badArgsLengthError: (operation: string, values: any[]) => string;
/**
 * @description builds verbose string with multiple references specific to why a given request failed
 * @param {string} field
 */
export declare const defineValidationErrorMessage: (field: string) => (message: any, i: any) => string;
/**
 * @description Fn that checks to see if length of args meets the needs for a given operation. Only applies to a handful of operations, so majority default to true.
 * @param {string} operation
 * @param {any[]} values
 * @returns {boolean}
 */
export declare const validArgsforOperation: (operation: string, values: any[]) => boolean;
/**
 * @description Some operations on GET queries support operations via `field.operation`. A subset of these operations support multiple values seperated by commas. This `SUPPORTED_OPERATIONS` object holds a map with keys that represent all supported operations and values that define the support for multiple values. `undefined` responses to this function only occur of the operation isn't supported on the field at all.
 * @param {string} operation
 * @returns {(boolean)}
 */
export declare const supportMultipleValues: (operation: string) => boolean;
/**
 * @description Some operations on GET queries support operations via `field.operation`. This `SUPPORTED_OPERATIONS` object holds a map with keys that represent all supported operations.
 * @param {string} operation
 * @returns {boolean}
 */
export declare const supportedOperation: (operation: string) => boolean;
/**
 * @description Fn that parses all GET querystring keys into fields and operations. These are set by the caller via `field.operation` syntax on all GET query string keys for searching. If `.operation` is not provided -- defaults to `.equal`.
 * @param {string} key
 * @returns {ts.IFieldAndOperation}
 */
export declare const parseFieldAndOperation: (key: string) => ts.IFieldAndOperation;
/**
 * @description Used to transform context arguments sent in GraphQL and gRPC to REST standard -- so all requests can get processed by complex middleware.
 * @param {*} attribute
 * @param {*} input
 * @returns
 */
export declare const contextTransformer: (attribute: any, input: any) => any;
/**
 * @description The Heart of the entire system. This Fn takes in a JOI validator and a query object (`ctx.request.query`) and submits both for processing. Search interfaces, fields & operations, are derived from the JOI validators, values from query object are typecasted to data types (if possible) using the types of each field from the JOI validator. Some query operations support multiple values seperated by commas, and this value parsing to arrays is also done here. The `context` object returned is used to build the query -- but is more superficial than the `components` which are used within the `where` part of the query. Any errors with a give query against a validator produces an array of errors, so the request can be stopped before submitting to database.
 * @param {Joi.Schema} validator
 * @param {ts.IParamsSearchQueryParser} query
 * @returns {Promise<ts.ISearchQueryResponse>}
 * @promise searchQueryParserPromise
 * @fulfill {ts.ISearchQueryResponse}
 * @reject {ts.ISearchQueryResponse}
 * @returns searchQueryParserPromise
 */
export declare const searchQueryParser: (validator: Joi.Schema, query: ts.IParamsSearchQueryParser, apiType: string, seperator?: string) => Promise<ts.ISearchQueryResponse>;
/**
 * @description produces query context object. For REST calls, first parses query string to assemble base arguments. Then checks for things like return fields or ordering fields do not exist.
 * @param {Joi.Schema} validator
 * @param {ts.IParamsSearchQueryParser} query
 * @param {string} apiType
 * @returns {ts.IQueryContextResponse}
 */
export declare const queryContextParser: (validator: Joi.Schema, query: ts.IParamsSearchQueryParser, apiType: string) => ts.IQueryContextResponse;
/**
 * @description Accepts Validator Inspection Report as input and lists all softDeleteFields (designed to only support one)
 * @param {ts.IValidatorInspectorReport} report
 */
export declare const softDeleteFields: (report: ts.IValidatorInspectorReport) => any[];
/**
 * @description Accepts Validator Inspection Report as input and lists all fields that are components of primary key (designed to only support one)
 * @param {ts.IValidatorInspectorReport} report
 */
export declare const uniqueKeyComponents: (report: ts.IValidatorInspectorReport) => any[];
/**
 * @description conversion of meters to units used in spatial queries
 * @param {number} meters
 */
export declare const metersToDecimalDegrees: (meters: number) => number;
/**
 * @description A core component of entire system. Each DB resource gets a single validator built on first pass that checks for types and values. This fn derives CRUD & Search specific validators from that original -- and applies flags to keys used in delete, update and read. The REPORT object, reviews each generated validator and generates an object describing each that is used for various logic through the system. Is simplier to perform here a single time and produce a comprehensive report object than continualy checking various properties (often deeply nested and private) in the validator. `redactedFields` is used to withold fields from report -- as it powers openapi generation.
 * @param {Joi.Schema} validator
 * @param {string[]} redactedFields
 * @returns {ts.IValidationExpander}
 */
export declare const validationExpander: (validator: Joi.Schema, redactedFields: string[]) => ts.IValidationExpander;
/**
 * @description Used to standardize validation. Want to workwith single input and array of inputs as REST, GraphQL and gRPC can take 1 or many records.
 * @param {Joi.Schema} validator
 * @param {(any | any[])} payload
 */
export declare const validateOneOrMany: (validator: Joi.Schema, payload: any | any[]) => Promise<any>;
export declare const removeContextKeys: (context: any, payload: any) => any;
/**
 * @description Transforms input into object with `errorType` & `error` keys
 * @param {string} errorType
 * @param {*} error
 * @returns {ts.IRejectResource}
 */
export declare const rejectResource: (errorType: string, error: any) => ts.IRejectResource;
/**
 * @description Transforms input into object with `result` key set to the input value
 * @param {*} result
 * @returns {ts.IResolveResource}
 */
export declare const resolveResource: (result: any) => ts.IResolveResource;
/**
 * @description generates URL paths for each resource. Applies a specific prefix to each.
 * @param {string} resource
 * @param {string} [prefix="service"]
 */
export declare const nameRestEndpointGetRecords: (resource: string, prefix?: string) => {
    resourceEndpoint: string;
    uniqueEndpoint: string;
};
/**
 * @description Adds invalid `key` flag to any validator for a field that is used as a key
 * @param {Joi.Schema} joi
 * @param {boolean} keyComponent
 */
export declare const joiKeyComponent: (joi: Joi.Schema, keyComponent: boolean) => Joi.AnySchema;
/**
 * @description DISABLED FOR EVAL. Goal was to modify validator for required fields. would be used in `genDatabaseResourceValidators`
 * @param {Joi.Schema} joi
 * @param {boolean} required
 */
export declare const joiRequired: (joi: Joi.Schema, required: boolean) => Joi.AnySchema;
/**
 * @description Generates JOI validators for each resource reported in the dbSurveyQuery. Basis of entire system. Also generates dbResources Map -- which contains the survey results -- but in a better format for use through the system.
 * @param {ts.IDatabaseBootstrapRaw} {
 *   db,
 *   dbResourceRawRows,
 *   joiBase,
 * }
 * @returns
 */
export declare const genDatabaseResourceValidators: ({ db, dbResourceRawRows, joiBase, }: ts.IDatabaseBootstrapRaw) => Promise<{
    validators: {};
    dbResources: any;
}>;
/**
 * @description Builds two objects from one by matching on key prefixes
 * @param {*} payload
 * @param {string} prefix
 * @returns {[ts.IObjectStringByString, ts.IObjectStringByString]}
 */
export declare const seperateByKeyPrefix: (payload: any, prefix: string) => [ts.IObjectStringByString, ts.IObjectStringByString];
/**
 * @description Used for applying complex middleware to subqueries for all service calls and parsing subPayload from REST
 * @param {ts.IClassResourceMap} resourcesMap
 * @param {string} resourceName
 * @param {string} operation
 * @param {*} payload
 * @param {*} [subPayload]
 * @returns
 */
export declare const callComplexResource: (resourcesMap: ts.IClassResourceMap, resourceName: string, operation: string, payload: any, subPayload?: any) => Promise<any>;
/**
 * @description Used to normalize processing of simple and complex resources. if complex, the first resource is used as the interface, which is the result of the middleware that aggregates or otherwise modifies the subquery data structure.
 * @param {string} str
 * @param {string} [seperator=":"]
 */
export declare const getFirstIfSeperated: (str: string, seperator?: string) => string;
/**
 * @description Seemingly reducer that takes Object.entries and generates Object. Could probably be done with Object.fromEntries -- but the value here is likely typescript (IClassResourceMap). Could likely be culled with a small Pull Request
 * @param {*} Resources
 * @returns {ts.IClassResourceMap}
 */
export declare const genResourcesMap: (Resources: any) => ts.IClassResourceMap;
/**
 * @description used to namespace complex resources from natural ones. fn name needs attention.
 * @param {*} str
 */
export declare const transformNameforResolver: (str: any) => any;
/**
 * @description Transform WKT strings to GeoJSON
 * @param {*} wktString
 */
export declare const wktToGeoJSON: (wktString: any) => {};
/**
 * @description GraphQL calls naturally feature `fields`, however we must distinguish between meta keys and nested db fields. This supports that utility.
 * @param {*} information
 * @returns
 */
export declare const extractSelectedFields: (information: any) => {
    props: any[];
    fields: any[];
};
/**
 * @description Adds postProcessResponse fn for db dialects where knex returns TextRow objects
 * @param {*} knexConfig
 */
export declare const initPostProcessing: (knexConfig: any) => any;
/**
 * @description checks against whitelist to see if db named supports return on DML
 * @param {string} client
 */
export declare const supportsReturnOnCreateAndUpdate: (client: string) => boolean;
/**
 * @description
 * @returns {ts.IServicePermission}
 */
export declare const permit: () => ts.IServicePermission;
/**
 * @description Transforms permission object into bitwise flags
 * @param {ts.IObjectStringByGeneric<ts.IServicePermission>} permissions
 * @returns {ts.IObjectStringByNumber}
 */
export declare const extractPermissions: (permissions: ts.IObjectStringByGeneric<ts.IServicePermission>) => ts.IObjectStringByNumber;
/**
 * @description String to Ints for BitWise operations (permission flags)
 * @param {string} operation
 * @returns
 */
export declare const operationFlag: (operation: string) => 2 | 4 | 1 | 8 | 0;
/**
 * @description Used to determine if a given method is permitted on a resource.
 * @param {ts.IConfigServicePermission} permissions
 */
export declare const permitted: (permissions: ts.IConfigServicePermission) => (resource: string, operation: string) => boolean;
/**
 * @description Transforms nested object from REST, GraphQL, gRPC to simply entries. Used in validation and query building.
 * @param {string} sep
 */
export declare const stringValues: (sep: string) => (obj: object) => {
    [k: string]: any;
};
/**
 * @description adds message field index numbers to protobuff messages
 * @param {*} el
 * @param {*} i
 */
export declare const appendIndex: (el: any, i: any) => string;
/**
 * @description appends semicolon to given string
 * @param {*} el
 */
export declare const appendSemicolon: (el: any) => string;
/**
 * @description Transforms values in js object to protobuff struct scalars
 * @param {*} data
 * @param {*} key
 * @returns
 */
export declare const encodeStructField: (data: any, key: any) => any;
/**
 * @description Transforms entries in js object to protobuff struct scalars
 * @param {*} data
 */
export declare const encodeStructFields: (data: any) => any;
/**
 * @description Transforms js object to protobuff struct
 * @param {{ [key: string]: any }} data
 * @returns
 */
export declare const encodeStruct: (data: {
    [key: string]: any;
}) => {
    fields: any;
};
/**
 * @description generates migration script name needed for reading from sql & up/down directories
 * @param {*} {date, id, args}
 * @returns
 */
export declare const genNextMigrationName: ({ date, id, args }: {
    date: any;
    id: any;
    args: any;
}) => string;
/**
 * @description List all files in a directory in Node.js recursively in a synchronous fashion (taken from a gist)
 * @param {*} dir
 * @param {*} filelist
 * @returns
 */
export declare const surveyDirectory: (dir: any, filelist?: any[]) => any[];
/**
 * @description seperate files into up & down batches for knex
 * @param {*} accum
 * @param {*} curr
 * @returns
 */
export declare const reducerSqlContent: (accum: any, curr: any) => any;
/**
 * @description collects and sorts filenames for all content that make up a migration batch
 * @param {*} dir
 * @param {*} id
 * @returns
 */
export declare const gatherModularSQLContentByID: (dir: any, id: any) => any;
/**
 * @description generic knex up/down fns that intake file paths and process the content via knex.raw(file_content)
 * @param {*} files
 */
export declare const processModularSQL: (files: any) => (knex: any) => any;
/**
 * @description convenience fn that minimizes implementation code for utilizing these methods. Implemented in custom knex stub
 * @param {*} dirname
 * @param {*} filename
 * @returns
 */
export declare const modularMigration: (dirname: any, filename: any) => {
    up: (knex: any) => any;
    down: (knex: any) => any;
};
export declare const parseGraphQLInput: (field: any, op: any, value: any) => any[];
export declare const gqlParsePayload: (userQuery: object) => any;
