export type IdentityEntityMergeRequest = {conflicting_alias_ids_to_keep?: Array | undefined, force?: boolean | undefined, from_entity_ids?: Array | undefined, to_entity_id?: string | undefined}; export type CreateApiIdentityEntityMergeArgs = {body: IdentityEntityMergeRequest}; export type CreateApiIdentityEntityMergeOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Merge two or more entities together * * POST /identity/entity/merge */ export const createApiIdentityEntityMerge = async (args: CreateApiIdentityEntityMergeArgs, options: CreateApiIdentityEntityMergeOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/identity/entity/merge${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 undefined };