export type EnrichedSemanticTagDTO = Record; export type CreateApiTagsArgs = {'Accept-Language'?: string | undefined, body: EnrichedSemanticTagDTO}; export type CreateApiTagsOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a new semantic tag and adds it to the registry. * * POST /tags */ export const createApiTags = async (args: CreateApiTagsArgs, options: CreateApiTagsOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/tags${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };