/** * This file is part of the @egodigital/egoose distribution. * Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/) * * @egodigital/egoose is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, version 3. * * @egodigital/egoose is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import * as Enumerable from 'node-enumerable'; import * as moment from 'moment-timezone'; import * as yargs from 'yargs-parser'; /** * Stores version information about the app. */ export interface AppVersion { /** * The last commit date. Contains (false), if failed. */ date?: moment.Moment | false; /** * The last commit hash. Contains (false), if failed. */ hash?: string | false; } /** * Describes a simple 'completed' action. * * @param {any} err The occurred error. * @param {TResult} [result] The result. */ export declare type CompletedAction = (err: any, result?: TResult) => void; /** * Result of 'exec()' function. */ export interface ExecResult { /** * The error stream. */ stderr: string; /** * The standard stream. */ stdout: string; } /** * An action for an async 'forEach'. * * @param {T} item The current item. * @param {number} index The zero-based index. */ export declare type ForEachAsyncAction = (item: T, index: number) => void | Promise; /** * Options for 'getAppVersion()' function(s). */ export interface GetAppVersionOptions { /** * The custom working directory. */ cwd?: string; } /** * A result of 'parseCommandLine()' function. */ export interface ParsedCommandLine { /** * The arguments. */ arguments: yargs.Arguments; /** * The command. */ command?: string; } /** * A predciate. * * @param {TValue} value The value to check. * * @return {boolean} Value matches predicate or not. */ export declare type Predicate = (value: TValue) => boolean; /** * Applies an object or value to a function. * * @param {TFunc} func The function to apply 'thisArg' to. * @param {any} thisArg The object or value to apply to 'func'. * * @return {TFunc} The new function. */ export declare function applyFuncFor(func: TFunc, thisArg: any): TFunc; /** * Returns an input value as array. * * @param {T|T[]} val The input value. * @param {boolean} [noEmpty] Remove values, which are (null) or (undefined). * * @return {T[]} The input value as array. */ export declare function asArray(val: T | T[], noEmpty?: boolean): T[]; /** * Keeps sure that a value is a Moment instance (local timezone). * * @param {any} time The input value. * * @return {moment.Moment} The Moment instance. */ export declare function asLocal(time: any): moment.Moment; /** * Keeps sure that a value is a Moment instance. * * @param {any} val The input value. * * @return {moment.Moment} The Moment instance. */ export declare function asMoment(val: any): moment.Moment; /** * Keeps sure that a value is a Moment instance (UTC timezone). * * @param {any} time The input value. * * @return {moment.Moment} The Moment instance. */ export declare function asUTC(time: any): moment.Moment; /** * Clones an object / value. * * @param {T} obj The value to clone. * * @return {T} The cloned value. */ export declare function cloneObj(obj: T): T; /** * Compare to values for sorting. * * @param {any} x The "left" value. * @param {any} y The "right" value. * * @return {number} The sort value. */ export declare function compareValues(x: T, y: T): number; /** * Compare to values for sorting by using a selector. * * @param {any} x The "left" value. * @param {any} y The "right" value. * @param {Function} selector The selector. * * @return {number} The sort value. */ export declare function compareValuesBy(x: T, y: T, selector: (val: T) => U): number; /** * Creates a simple 'completed' callback for a promise. * * @param {Function} resolve The 'succeeded' callback. * @param {Function} reject The 'error' callback. * * @return {CompletedAction} The created action. */ export declare function createCompletedAction(resolve: (value?: TResult | PromiseLike) => void, reject?: (reason: any) => void): CompletedAction; /** * Promise version of `child_process.exec()` function. * * @param {string} command The command to execute. * * @return {Promise} The promise with the result. */ export declare function exec(command: string): Promise; /** * An async 'forEach'. * * @param {Enumerable.Sequence} seq The sequence or array to iterate. * @param {ForEachAsyncAction} action The action to invoke. */ export declare function forEachAsync(seq: Enumerable.Sequence, action: ForEachAsyncAction): Promise; /** * Detects version information about the current app via Git (synchronous). * * @param {GetAppVersionOptions} [opts] Custom options. * * @return {AppVersion} Version information. */ export declare function getAppVersionSync(opts?: GetAppVersionOptions): AppVersion; /** * Alias of 'uuid()' function. */ export declare function guid(version?: string): string; /** * Checks if the string representation of a value is an empty string or not. * * @param {any} val The value to check. * * @return {boolean} If empty string or not. */ export declare function isEmptyString(val: any): boolean; /** * Normalizes a value to a string, which is comparable. * * @param {any} val The value to normalize. * * @return {string} The normalized string. */ export declare function normalizeString(val: any): string; /** * Returns the current time. * * @param {string} [timezone] The custom timezone to use. * * @return {Moment.Moment} The current time. */ export declare function now(timezone?: string): moment.Moment; /** * Parses a value as string of a command line input. * * @param {any} cmd The command line input. * * @return {ParsedCommandLine} The parsed data. */ export declare function parseCommandLine(cmd: any): ParsedCommandLine; /** * Generates a random string. * * @param {number} size The size of the result string. * @param {string} [chars] The custom list of characters. * * @return {Promise} The promise with the random string. */ export declare function randChars(size: number, chars?: string): Promise; /** * Generates a random string. * * @param {number} size The size of the result string. * @param {string} [chars] The custom list of characters. * * @return {string} The random string. */ export declare function randCharsSync(size: number, chars?: string): string; /** * Returns a value as "real" boolean. * * @param {any} val The input value. * @param {boolean} [defaultValue] The value to return if 'val' is (null) or (undefined). * * @return {boolean} The output value. */ export declare function toBooleanSafe(val: any, defaultValue?: boolean): boolean; /** * Converts a value to a string (if needed), which is not (null) and not (undefined). * * @param {any} val The value to convert. * @param {string} [defaultValue] The custom default value if 'val' is (null) or (undefined). * * @return {string} 'val' as string. */ export declare function toStringSafe(val: any, defaultValue?: string): string; /** * Returns the current time in UTC. * * @return {moment.Moment} The current UTC time. */ export declare function utc(): moment.Moment; /** * Generates an unique ID. * * @param {string} [version] The custom version to use. Default: 4 * @param {any[]} [] * * @return {string} The new GUID / unique ID. */ export declare function uuid(version?: string, ...args: any[]): string; export * from './apis/host'; export * from './apis/index'; export * from './apis/statistics'; export * from './apis/validation'; export * from './azure/storage'; export * from './cache'; export * from './cache/redis'; export * from './dev'; export * from './diagnostics/logger'; export * from './diagnostics/stopwatch'; export * from './env'; export * from './events'; export * from './fs'; export * from './geo'; export * from './http'; export * from './http/websockets'; export * from './mail'; export * from './mongo/index'; export * from './mongo/statistics'; export * from './oauth/microsoft'; export * from './queues/index'; export * from './schemas'; export * from './statistics'; export * from './streams'; export * from './strings'; export * from './system'; export * from './zip/builder'; export { asEnumerable, from, isEnumerable, isSequence, popFrom, random, range, repeat, shiftFrom } from 'node-enumerable'; export { setupSwaggerUIFromSourceFiles } from 'swagger-jsdoc-express';