import {z} from 'zod' export type AdminV1AnalyticsScriptEntry = {attributes?: {[key: string]: string} | undefined, content?: string | undefined, id?: string | undefined, src?: string | undefined, strategy?: string | undefined}; export type AdminV1AnalyticsScripts = {entries?: Array | undefined}; export type AdminV1SiteSettings = {allowRegister?: boolean | undefined, analyticsScripts?: AdminV1AnalyticsScripts | undefined, emailAliasRestrictionEnabled?: boolean | undefined, emailDomainWhitelist?: string | undefined, enterpriseUpgradeEnabled?: boolean | undefined, invoiceApplicationEnabled?: boolean | undefined, maintenanceMode?: boolean | undefined, passwordMinLength?: number | undefined, platformName?: string | undefined, platformNameEn?: string | undefined, platformUrl?: string | undefined, realnameBonusEnabled?: boolean | undefined, realnameEnforceApikeyCreate?: boolean | undefined, realnameEnforceGateway?: boolean | undefined, realnameEnforceTopup?: boolean | undefined, realnameMethodAlipayCertifyQrEnabled?: boolean | undefined, realnameMethodAlipayTwoMetaEnabled?: boolean | undefined, realnameVerifyEnabled?: boolean | undefined, rechargeMax?: string | undefined, rechargeMin?: string | undefined, registrationGeoRestrictionEnabled?: boolean | undefined, signupBonusEnabled?: boolean | undefined, signupBonusMicros?: string | undefined, supportEmail?: string | undefined, trialDays?: number | undefined, twoFactorRequired?: boolean | undefined, usageBodyCapture?: boolean | undefined}; export type AdminV1UpdateSiteSettingsRequest = {settings?: AdminV1SiteSettings | undefined}; export type UpdateApiV1AdminSettingsSiteArgs = {body: AdminV1UpdateSiteSettingsRequest}; export type UpdateApiV1AdminSettingsSiteOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const adminV1UpdateSiteSettingsReply = z.object({ok: z.boolean().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 }; /** * UpdateSiteSettings 批量更新站点公开配置。 * * PUT /v1/admin/settings/site */ export const updateApiV1AdminSettingsSite = async (args: UpdateApiV1AdminSettingsSiteArgs, options: UpdateApiV1AdminSettingsSiteOptions) => { 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") const url = `${baseUrl.replace(/\/+$/, '')}/v1/admin/settings/site${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(adminV1UpdateSiteSettingsReply, await res.json()) };