UNPKG

@mnfst/sdk

Version:

Manifest JavaScript SDK

82 lines (81 loc) 2.69 kB
import { ImageSizesObject, RelationshipManifest } from "../../types/src"; /** * Get record key by its value. * * @param record * @param value * @returns key */ export declare function getRecordKeyByValue<T extends Record<string, string>, V extends T[keyof T]>(record: T, value: V): string | undefined; /** * Camelize a string or an array of strings. * * @param str The string or array of strings to camelize. * * @returns The camelized string. */ export declare function camelize(str: string | string[]): string; /** * Kebabize a string. * * @param str The string to kebabize. * * @returns The kebabized string. */ export declare function kebabize(str: string): string; /** * Lowercase the first letter of a string. * * @param str The string to lowercase the first letter of. * * @returns The string with the first letter lowercased. */ export declare function lowerCaseFirstLetter(str: string): string; /** * Uppercase the first letter of a string. * * @param str The string to uppercase the first letter of. * * @returns The string with the first letter in uppercase. */ export declare function upperCaseFirstLetter(str: string): string; /** * Get a random integer while excluding some values. */ export declare function getRandomIntExcluding({ min, max, exclude }: { min: number; max: number; exclude?: number[]; }): number; /** * Gets the DTO property name from a relationship manifest when passing one or several ids as value. Ex: "tags" -> "tagIds", "author" -> "authorId". * * @param relationship The relationship manifest. * * @returns The property name. */ export declare function getDtoPropertyNameFromRelationship(relationship: RelationshipManifest): string; /** * Gets the relationship name from a DTO property name when passing one or several ids as value. Ex: "tagIds" -> "tags", "authorId" -> "author". * * @param propertyName The DTO property name. * * @returns The relationship name. */ export declare function getRelationshipNameFromDtoPropertyName(propertyName: string): string; /** * Forces a value to be an array of numbers. Useful for data that come from HTML inputs. * * @param value The value to force into an array of numbers. * @returns An array of numbers. */ export declare function forceNumberArray(value: string | number | number[] | string[]): number[]; /** * Get the smallest size from an ImageSizesObject based on the width. * * @param imageSizesObject The ImageSizesObject. * * @returns The smallest size name. */ export declare function getSmallestImageSize(imageSizesObject: ImageSizesObject): string; export declare function base64ToBlob(base64: string, contentType: string): Blob;