export type CreateApiIntermediatePathAuthorizableIdKsHtmlArgs = {intermediatePath: string, authorizableId: string, ':operation'?: string | undefined, currentPassword?: string | undefined, newPassword?: string | undefined, rePassword?: string | undefined, keyPassword?: string | undefined, keyStorePass?: string | undefined, alias?: string | undefined, newAlias?: string | undefined, removeAlias?: string | undefined, body: BodyInit}; export type CreateApiIntermediatePathAuthorizableIdKsHtmlOptions = {baseUrl: string, aemAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * POST /{intermediatePath}/{authorizableId}.ks.html */ export const createApiIntermediatePathAuthorizableIdKsHtml = async (args: CreateApiIntermediatePathAuthorizableIdKsHtmlArgs, options: CreateApiIntermediatePathAuthorizableIdKsHtmlOptions) => { const {baseUrl, fetch: fetchFn = fetch, aemAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args[':operation'] != null) query.append(":operation", String(args[':operation'])) if (args.currentPassword != null) query.append("currentPassword", String(args.currentPassword)) if (args.newPassword != null) query.append("newPassword", String(args.newPassword)) if (args.rePassword != null) query.append("rePassword", String(args.rePassword)) if (args.keyPassword != null) query.append("keyPassword", String(args.keyPassword)) if (args.keyStorePass != null) query.append("keyStorePass", String(args.keyStorePass)) if (args.alias != null) query.append("alias", String(args.alias)) if (args.newAlias != null) query.append("newAlias", String(args.newAlias)) if (args.removeAlias != null) query.append("removeAlias", String(args.removeAlias)) if (aemAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${aemAuth.username}:${aemAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.intermediatePath))}/${encodeURIComponent(String(args.authorizableId))}.ks.html${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };