/** * The `util` module provides a set of functions commonly needed to author custom components. * Many functions in the `util` module are used to coerce data into a particular type, and can be accessed through `util.types`. * For example, `util.types.toInt("5.5")` will return an integer, `5`. */ import { ConnectionDefinition, DataPayload, Element, JSONForm, KeyValuePair, ObjectFieldMap, ObjectSelection } from "./types"; export declare const isObjectWithOneTruthyKey: (value: unknown, keys: string[]) => boolean; export declare const isObjectWithTruthyKeys: (value: unknown, keys: string[]) => boolean; /** * This function returns a version of the headers object where all header * names (keys) are lower-cased. Header values are left unchanged. * * @param headers The headers to convert to lower case. * @returns A new header object with lower-cased keys. * @example * import { util } from "@prismatic-io/spectral"; * * util.types.lowerCaseHeaders({ "Content-Type": "application/json" }); * // { "content-type": "application/json" } * * util.types.lowerCaseHeaders({ * "Cache-Control": "max-age=604800", * "Accept-Language": "en-us", * }); * // { "cache-control": "max-age=604800", "accept-language": "en-us" } */ export declare const lowerCaseHeaders: (headers: Record) => Record; /** * This function parses a JSON string and returns the resulting object, * or returns the value as-is if it is already an object. * * @param value The JSON string or object to convert. * @returns An object, parsing JSON as necessary. * @example * import { util } from "@prismatic-io/spectral"; * * util.types.toObject('{"foo":"bar","baz":123}'); * // { foo: "bar", baz: 123 } * * util.types.toObject({ foo: "bar", baz: 123 }); * // { foo: "bar", baz: 123 } (returned as-is) */ export declare const toObject: (value: unknown) => object; export * from "./conditionalLogic"; export * from "./errors"; declare const _default: { types: { isBool: (value: unknown) => value is boolean; toBool: (value: unknown, defaultValue?: boolean) => boolean; isInt: (value: unknown) => value is number; toInt: (value: unknown, defaultValue?: number) => number; isNumber: (value: unknown) => boolean; toNumber: (value: unknown, defaultValue?: number) => number; isBigInt: (value: unknown) => value is bigint; toBigInt: (value: unknown) => bigint; isDate: (value: unknown) => value is Date; toDate: (value: unknown) => Date; isUrl: (value: string) => boolean; isBufferDataPayload: (value: unknown) => value is DataPayload; toBufferDataPayload: (value: unknown) => DataPayload; isData: (value: unknown) => boolean; toData: (value: unknown) => DataPayload; isString: (value: unknown) => value is string; toString: (value: unknown, defaultValue?: string) => string; keyValPairListToObject: (kvpList: KeyValuePair[], valueConverter?: (value: unknown) => TValue) => Record; isJSON: (value: string) => boolean; toJSON: (value: unknown, prettyPrint?: boolean, retainKeyOrder?: boolean) => string; lowerCaseHeaders: (headers: Record) => Record; isObjectSelection: (value: unknown) => value is ObjectSelection; toObjectSelection: (value: unknown) => ObjectSelection; isObjectFieldMap: (value: unknown) => value is ObjectFieldMap; toObjectFieldMap: (value: unknown) => ObjectFieldMap; isJSONForm: (value: unknown) => value is JSONForm; toJSONForm: (value: unknown) => JSONForm; isPicklist: (value: unknown) => boolean; isSchedule: (value: unknown) => boolean; isConnection: (value: unknown) => value is ConnectionDefinition; isElement: (value: unknown) => value is Element; toObject: (value: unknown) => object; cleanObject: (obj: Record, predicate?: (v: any) => boolean) => Record; }; }; export default _default;