import {z} from 'zod' export type BluenteInternalUserModelGoogleAuthResponse = {access_token?: string | undefined, apiKey?: string | undefined, appName?: string | undefined, createAt?: string | undefined, displayName?: string | undefined, email?: string | undefined, emailVerified?: boolean | undefined, id_token?: string | undefined, lastLoginAt?: string | undefined, providerData?: (Array<{displayName?: string | undefined, email?: string | undefined, photoUrl?: string | undefined, providerId?: string | undefined, uid?: string | undefined}>) | undefined, stsTokenManager?: {[key: string]: unknown} | undefined}; export type BluenteInternalUserModelMicrosoftAuthResponse = {orgInfo?: {[key: string]: unknown} | undefined}; export type BluenteInternalUserModelUserLoginRequest = {email: string, fullName?: string | undefined, google_auth?: BluenteInternalUserModelGoogleAuthResponse | undefined, invite_code?: string | undefined, microsoft_auth?: BluenteInternalUserModelMicrosoftAuthResponse | undefined, page?: string | undefined, password: string, platform?: string | undefined, type?: string | undefined}; export type CreateApiV2UserResendActivationArgs = {Authorization: string, body: BluenteInternalUserModelUserLoginRequest}; export type CreateApiV2UserResendActivationOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const bluenteInternalPlatformUtilsBaseResponse = z.object({code: z.number().int().optional(), data: z.unknown(), message: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Resend activation email * * POST /v2/user/resend_activation */ export const createApiV2UserResendActivation = async (args: CreateApiV2UserResendActivationArgs, options: CreateApiV2UserResendActivationOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/resend_activation${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 validateResponse(bluenteInternalPlatformUtilsBaseResponse, await res.json()) };