export type CreateApiV1TestEndpointAuthArgs = {body: Record}; export type CreateApiV1TestEndpointAuthOptions = {baseUrl?: string | undefined, ProjectPublicApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Test endpoint with authentication check * * POST /v1/test-endpoint/auth */ export const createApiV1TestEndpointAuth = async (args: CreateApiV1TestEndpointAuthArgs, options?: CreateApiV1TestEndpointAuthOptions) => { const {baseUrl = "https://api.lunary.ai", fetch: fetchFn = fetch, ProjectPublicApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ProjectPublicApiKeyAuth !== undefined) headers.set('authorization', `Bearer ${ProjectPublicApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/test-endpoint/auth${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 };