export type GetApiAuthoringV1SearchArgs = {defType?: string | undefined, df?: string | undefined, facet?: string | undefined, 'facet.contains'?: string | undefined, 'facet.containsIgnoreCase'?: string | undefined, 'facet.field'?: string | undefined, 'facet.limit'?: string | undefined, 'facet.offset'?: string | undefined, 'facet.prefix'?: string | undefined, 'facet.range'?: string | undefined, 'facet.range.end'?: string | undefined, 'facet.range.gap'?: string | undefined, 'facet.range.start'?: string | undefined, fl?: string | undefined, fq?: string | undefined, 'f..'?: string | undefined, indent?: string | undefined, q?: string | undefined, qf?: string | undefined, rows?: number | undefined, sort?: string | undefined, start?: number | undefined}; export type GetApiAuthoringV1SearchOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Search in the authoring collection * * GET /authoring/v1/search */ export const getApiAuthoringV1Search = async (args: GetApiAuthoringV1SearchArgs, options: GetApiAuthoringV1SearchOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.defType != null) query.append("defType", String(args.defType)) if (args.df != null) query.append("df", String(args.df)) if (args.facet != null) query.append("facet", String(args.facet)) if (args['facet.contains'] != null) query.append("facet.contains", String(args['facet.contains'])) if (args['facet.containsIgnoreCase'] != null) query.append("facet.containsIgnoreCase", String(args['facet.containsIgnoreCase'])) if (args['facet.field'] != null) query.append("facet.field", String(args['facet.field'])) if (args['facet.limit'] != null) query.append("facet.limit", String(args['facet.limit'])) if (args['facet.offset'] != null) query.append("facet.offset", String(args['facet.offset'])) if (args['facet.prefix'] != null) query.append("facet.prefix", String(args['facet.prefix'])) if (args['facet.range'] != null) query.append("facet.range", String(args['facet.range'])) if (args['facet.range.end'] != null) query.append("facet.range.end", String(args['facet.range.end'])) if (args['facet.range.gap'] != null) query.append("facet.range.gap", String(args['facet.range.gap'])) if (args['facet.range.start'] != null) query.append("facet.range.start", String(args['facet.range.start'])) if (args.fl != null) query.append("fl", String(args.fl)) if (args.fq != null) query.append("fq", String(args.fq)) if (args['f..'] != null) query.append("f..", String(args['f..'])) if (args.indent != null) query.append("indent", String(args.indent)) if (args.q != null) query.append("q", String(args.q)) if (args.qf != null) query.append("qf", String(args.qf)) if (args.rows != null) query.append("rows", String(args.rows)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.start != null) query.append("start", String(args.start)) const url = `${baseUrl.replace(/\/+$/, '')}/authoring/v1/search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };