import { GlobbyOptions } from 'globby'; import { AnyEntity, Dictionary, EntityMetadata, EntityName, EntityProperty, Primary, IMetadataStorage } from '../typings'; import { ReferenceType } from '../enums'; import { Collection } from '../entity'; import { Platform } from '../platforms'; export declare const ObjectBindingPattern: unique symbol; export declare class Utils { /** * Checks if the argument is not undefined */ static isDefined>(data: any, considerNullUndefined?: boolean): data is T; /** * Checks if the argument is instance of `Object`. Returns false for arrays. * `not` argument allows to blacklist classes that should be considered as not object. */ static isObject(o: any, not?: any[]): o is T; /** * Checks if the argument is string */ static isString(s: any): s is string; /** * Checks if the argument is number */ static isNumber(s: any): s is T; /** * Checks if arguments are deeply (but not strictly) equal. */ static equals(a: any, b: any): boolean; /** * Gets array without duplicates. */ static unique(items: T[]): T[]; /** * Merges all sources into the target recursively. */ static merge(target: any, ...sources: any[]): any; static getRootEntity(metadata: IMetadataStorage, meta: EntityMetadata): EntityMetadata; /** * Computes difference between two objects, ignoring items missing in `b`. */ static diff(a: Dictionary, b: Dictionary): Record; /** * Creates deep copy of given entity. */ static copy(entity: T): T; /** * Normalize the argument to always be an array. */ static asArray(data?: T | T[], strict?: boolean): T[]; /** * Renames object key, keeps order of properties. */ static renameKey(payload: T, from: string | keyof T, to: string): void; /** * Returns array of functions argument names. Uses `escaya` for source code analysis. */ static getParamNames(func: { toString(): string; } | string, methodName?: string): string[]; private static walkNode; /** * Checks whether the argument looks like primary key (string, number or ObjectId). */ static isPrimaryKey(key: any, allowComposite?: boolean): key is Primary; /** * Extracts primary key from `data`. Accepts objects or primary keys directly. */ static extractPK>(data: any, meta?: EntityMetadata, strict?: boolean): Primary | null; static getCompositeKeyHash>(entity: T, meta: EntityMetadata): string; static getPrimaryKeyHash(pks: string[]): string; static splitPrimaryKeys(key: string): string[]; static getPrimaryKeyValue>(entity: T, primaryKeys: string[]): any; static getPrimaryKeyValues>(entity: T, primaryKeys: string[], allowScalar?: boolean): any; static getPrimaryKeyCond>(entity: T, primaryKeys: string[]): Record> | null; static getPrimaryKeyCondFromArray>(pks: Primary[], primaryKeys: string[]): Record>; static getOrderedPrimaryKeys>(id: Primary | Record>, meta: EntityMetadata, platform: Platform, convertCustomTypes?: boolean): Primary[]; /** * Checks whether given object is an entity instance. */ static isEntity(data: any, allowReference?: boolean): data is T; /** * Checks whether the argument is ObjectId instance */ static isObjectID(key: any): boolean; /** * Checks whether the argument is empty (array without items, object without keys or falsy value). */ static isEmpty(data: any): boolean; /** * Gets string name of given class. */ static className(classOrName: EntityName): string; /** * Tries to detect `ts-node` runtime. */ static detectTsNode(): boolean; /** * Uses some dark magic to get source path to caller where decorator is used. * Analyses stack trace of error created inside the function call. */ static lookupPathFromDecorator(name: string, stack?: string[]): string; /** * Gets the type of the argument. */ static getObjectType(value: any): string; /** * Checks whether the value is POJO (e.g. `{ foo: 'bar' }`, and not instance of `Foo`) */ static isPlainObject(value: any): value is Dictionary; /** * Executes the `cb` promise serially on every element of the `items` array and returns array of resolved values. */ static runSerial(items: Iterable, cb: (item: U) => Promise): Promise; static isCollection(item: any, prop?: EntityProperty, type?: ReferenceType): item is Collection; static normalizePath(...parts: string[]): string; static relativePath(path: string, relativeTo: string): string; static absolutePath(path: string, baseDir?: string): string; static hash(data: string): string; static runIfNotEmpty(clause: () => any, data: any): void; static defaultValue(prop: T, option: keyof T, defaultValue: any): void; static findDuplicates(items: T[]): T[]; static randomInt(min: number, max: number): number; static pathExists(path: string, options?: GlobbyOptions): Promise; /** * Extracts all possible values of a TS enum. Works with both string and numeric enums. */ static extractEnumValues(target: Dictionary): (string | number)[]; static flatten(arrays: T[][]): T[]; static isOperator(key: string, includeGroupOperators?: boolean): boolean; static getGlobalStorage(namespace: string): Dictionary; /** * Require a module from a specific location * @param id The module to require * @param from Location to start the node resolution */ static requireFrom(id: string, from: string): any; static getORMVersion(): string; /** * @see https://github.com/mikro-orm/mikro-orm/issues/840 */ static propertyDecoratorReturnValue(): any; }