/** * Returns true when `url` already carries an explicit network scheme. * * Per the WHATWG URL Standard, all network-fetch schemes (http, https, ftp, * ws, wss, file) require "://" — the authority component is mandatory. * This means "localhost:8080" is NOT a scheme: the colon separates host from * port, so callers should prepend "http://" to it. * * The scheme character set (ASCII alpha/digit/+/-/.) follows the WHATWG URL * scheme-state parser, which accepts the same characters as all major browsers. * @see https://url.spec.whatwg.org/#scheme-state * * @example * hasExplicitScheme('https://example.com') // true * hasExplicitScheme('ftp://files.example') // true * hasExplicitScheme('localhost:8080') // false — port colon, not scheme * hasExplicitScheme('example.com/api') // false — no scheme at all */ declare function hasExplicitScheme(url: string): boolean; interface QueryParam { name: string; value?: string; } interface BuildQueryStringOptions { encode?: boolean; } interface ExtractQueryParamsOptions { decode?: boolean; } declare function buildQueryString(paramsArray: QueryParam[], { encode }?: BuildQueryStringOptions): string; declare function parseQueryParams(query: string, { decode }?: ExtractQueryParamsOptions): QueryParam[]; declare const encodeUrl: (url: string) => string; /** * Strip the origin (scheme + authority) from a URL, returning the path, query, and fragment. * Returns '/' if the URL has no path component. * * @example * stripOrigin('https://example.com/api/users?name=foo') // '/api/users?name=foo' * stripOrigin('http://localhost:3000') // '/' */ declare const stripOrigin: (url: string) => string; /** * Builds a URL-encoded payload from various data formats * * This function handles multiple input formats: * - Array of objects with 'name' and 'value' properties (preserves order) * * @param data The request body data * @returns URL-encoded string suitable for application/x-www-form-urlencoded content type * * @example * // Array format (preserves order) * buildFormUrlEncodedPayload([{name: 'a', value: '1'}, {name: 'b', value: '2'}]) * // Returns: 'a=1&b=2' */ declare const buildFormUrlEncodedPayload: (params: Array<{ name: string; value: string | number | boolean | undefined; }>) => string; /** * Determines if the given object is a FormData instance. * Supports native FormData (Node 18+, browser) and the 'form-data' npm package. * @param obj - Object to check. * @returns True if obj is a FormData instance, false otherwise. */ declare const isFormData: (obj: unknown) => boolean; /** * Extracts boundary parameter from a Content-Type header value. * @param contentType - The Content-Type header value (e.g., "multipart/mixed; boundary=my-boundary") * @returns The boundary value if found, or null if not present */ declare const extractBoundaryFromContentType: (contentType: unknown) => string | null; /** * Was implemented specifically for request.url where the url might have variables * that might need to be sanitised before being passed to a URL validator that doesn't * allow special characters that bruno uses as variables (`{{var_name}}`) * * The function replaces the input string with a unique hash that can be restored * later by the helper returned by this function */ declare function patternHasher(input: string, pattern?: string | RegExp): { hashed: string; restore(current: string): string; }; /** * Valid examples: "?Name", "?Prompt Var", "?x" * Invalid examples: "? Name", "?Name ", "?{{Name}}", "?{Name}" */ declare const PROMPT_VARIABLE_TEXT_PATTERN: RegExp; /** * Valid matches: "{{?Name}}", "{{?Prompt Var}}", "{{?x}}" * Invalid: "{{? Name}}", "{{?Name }}", "{{?{Name}}}" */ declare const PROMPT_VARIABLE_TEMPLATE_PATTERN: RegExp; /** * Extract prompt variables matching {{?}} from a string. * @param {string} str - The input string. * @returns {string[]} - An array of extracted prompt variables. */ declare const extractPromptVariablesFromString: (str: string) => string[]; /** * Extract prompt variables from an object. * @param {*} obj - The input object. * @returns {string[]} - An array of extracted prompt variables. */ declare function extractPromptVariables(obj: any): string[]; interface DotenvVariable { name: string; value?: string; } /** * Serializes an array of environment variables to .env file format. * * This is the inverse of dotenvToJson - it converts a variables array * back to .env file content that can be parsed by the dotenv package. * * Quoting strategy based on dotenv parser behavior: * - Unquoted: preserves \, ", ' literally. Only # is problematic (starts comment). * - Single-quoted: everything is literal. Cannot contain single quotes. * - Double-quoted: only \n and \r are expanded. Everything else is literal. * * Therefore: * - Values with actual newlines/carriage returns → double-quote + escape \n/\r * - Values with # but no ' → single-quote (literal) * - Values with # and ' → backtick-quote or double-quote fallback * - Values with leading/trailing whitespace → quote to prevent trimming * - Everything else → unquoted (preserves \, ", ' as-is) */ declare const jsonToDotenv: (variables: DotenvVariable[]) => string; declare const ENV_VAR_WRITE_APIS: string[]; declare const GITHUB_DISCUSSION_URL = "https://github.com/usebruno/bruno/discussions/8257"; declare const ENV_VAR_WRITE_OPEN_PATTERN: RegExp; declare const scriptWritesEnvVar: (code?: string | null) => boolean; export { DotenvVariable, ENV_VAR_WRITE_APIS, ENV_VAR_WRITE_OPEN_PATTERN, GITHUB_DISCUSSION_URL, PROMPT_VARIABLE_TEMPLATE_PATTERN, PROMPT_VARIABLE_TEXT_PATTERN, buildFormUrlEncodedPayload, buildQueryString, encodeUrl, extractBoundaryFromContentType, extractPromptVariables, extractPromptVariablesFromString, hasExplicitScheme, isFormData, jsonToDotenv, parseQueryParams, patternHasher, scriptWritesEnvVar, stripOrigin };