import type { QueryParamsSource } from "@warp-drive/core/types/params"; import type { BuildURLConfig } from "../../index.js"; export interface JSONAPIConfig extends BuildURLConfig { profiles?: { pagination?: string; [key: string]: string | undefined; }; extensions?: { atomic?: string; [key: string]: string | undefined; }; } export declare let CONFIG: JSONAPIConfig; export declare let ACCEPT_HEADER_VALUE: string; /** * Allows setting extensions and profiles to be used in the `Accept` header. * * Extensions and profiles are keyed by their namespace with the value being * their URI. * * Example: * * ```ts * setBuildURLConfig({ * extensions: { * atomic: 'https://jsonapi.org/ext/atomic' * }, * profiles: { * pagination: 'https://jsonapi.org/profiles/ethanresnick/cursor-pagination' * } * }); * ``` * * This also sets the global configuration for `buildBaseURL` * for host and namespace values for the global coniguration * done via `import { setBuildURLConfig } from '@warp-drive/utilities';` * * These values may still be overridden by passing * them to buildBaseURL directly. * * This method may be called as many times as needed * * ```ts * type BuildURLConfig = { * host: string; * namespace: string' * } * ``` * * @public * @param {BuildURLConfig} config * @return {void} */ export declare function setBuildURLConfig(config: JSONAPIConfig): void; interface RelatedObject { [key: string]: string | string[] | RelatedObject; } export type JsonApiQuery = { include?: string | string[] | RelatedObject; fields?: Record; page?: { size?: number; after?: string; before?: string; }; }; /** * Sorts query params by both key and value, returning a query params string * * Treats `included` specially, splicing it into an array if it is a string and sorting the array. * - If `included` is an object we build paths dynamically for you * Treats `fields` specially, building JSON:API partial fields params from an object * Treats `page` specially, building cursor-pagination profile page params from an object * * ```ts * const params = buildQueryParams({ * include: { * company: { * locations: 'address' * } * }, * fields: { * company: ['name', 'ticker'], * person: 'name' * }, * page: { * size: 10, * after: 'abc', * } * }); * * // => 'fields[company]=name,ticker&fields[person]=name&include=company.locations,company.locations.address&page[after]=abc&page[size]=10' * ``` * * Options: * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma' * * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2` * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2` * 'repeat': appends the key for every value e.g. `ids=1&ids=2` * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2` * * @public * @param {URLSearchParams | Object} params * @param {Object} [options] * @return {String} A sorted query params string without the leading `?` */ export declare function buildQueryParams(query: JsonApiQuery | QueryParamsSource): string; export {};