import type { LiteralUnion } from 'type-fest';
import y from 'yaml';
import type { ToStringOptions } from 'yaml';
import * as t from '../types';
export { isMap, isSeq, isScalar, isPair, isCollection, isDocument, visit, } from 'yaml';
export declare function ensureYmlExt(value: string): string;
/**
 * Fetches a yaml file using the url provided.
 * If "as" is "json", the result will be parsed and returned as json
 *
 * @param url URL
 * @param as Return data as json or yml. Defaults to 'yml'
 * @returns { string | Record<string, any> }
 */
export declare function fetchYml(url: string, as: 'doc'): Promise<y.Document | y.Document.Parsed>;
export declare function fetchYml(url: string, as: 'json'): Promise<Record<string, any>>;
export declare function fetchYml(url: string, as?: 'yml'): Promise<string>;
export declare function getNodeTypeLabel(node: unknown): "Scalar" | "YAMLMap" | "YAMLSeq" | "Node" | "unknown";
export declare function isNode(value: unknown): value is y.Document | y.Document.Parsed | y.Node | y.Pair;
export declare function merge(node: unknown, value: unknown): unknown;
export declare function parse<DataType extends 'map' | 'object'>(dataType: DataType, yml?: string, opts?: y.DocumentOptions & y.ParseOptions & y.SchemaOptions): DataType extends 'map' ? y.Document.Parsed : Record<string, any>;
export declare function parseAs(value: unknown): string;
export declare function parseAs<As extends t.As>(as: As, value: unknown): t.ParsedAs<As>;
export declare const toDoc: (value: unknown) => y.Document<y.Node<any>>;
export declare const toJson: (value: unknown) => Record<string, any>;
export declare const toYml: (value: unknown) => string;
export declare function getScalars(node: unknown, fn?: (...args: Parameters<y.visitorFn<any>>) => boolean): y.Scalar[];
/**
 * Returns the stringified output of the yaml document or object.
 * If there are errors when parsing yaml documents, it returns a stringified yaml output of the errors instead
 * @param { y.Document } doc
 */
export declare function stringify<O extends Record<string, any> | y.Document>(value: O | null | undefined, opts?: ToStringOptions): string;
/**
 * Will convert value to a yaml document
 * @param value The value to convert. Supports yaml string or an object literal
 * @returns A yaml document
 */
export declare function toDocument(value: Record<string, any> | string, opts?: y.DocumentOptions & y.ParseOptions & y.SchemaOptions): y.Document<y.Node<unknown>>;
export declare function toNode<S extends string>(value: Record<LiteralUnion<S, string>, any>): y.YAMLMap<S>;
export declare function toNode<V extends null | undefined | string | boolean | number>(value: V): y.Scalar<V>;
export declare function toNode<S extends string>(value: y.YAMLMap): y.YAMLMap<S>;
export declare function toNode<O = any>(value: O[]): y.YAMLSeq<O>;
export declare function toNode<O extends y.Node>(value: O[]): t.YAMLNode;
export declare function withYmlExt(s?: string): string | false;
/**
 * Unwraps a Scalar node if given a Scalar
 * @param node Scalar or value
 * @returns The unwrapped scalar or value
 */
export declare function unwrap<N extends y.Document>(node: N): N['contents'];
export declare function unwrap<N extends y.Scalar>(node: N): N['value'];
export declare function unwrap<V = unknown>(root: V): V;
