import {z} from 'zod' export type ConfigAliyunOSS = {'access-key-id'?: string | undefined, 'access-key-secret'?: string | undefined, 'base-path'?: string | undefined, 'bucket-name'?: string | undefined, 'bucket-url'?: string | undefined, endpoint?: string | undefined}; export type ConfigAutocode = {'ai-path'?: string | undefined, module?: string | undefined, root?: string | undefined, server?: string | undefined, web?: string | undefined}; export type ConfigAwsS3 = {'base-url'?: string | undefined, bucket?: string | undefined, 'disable-ssl'?: boolean | undefined, endpoint?: string | undefined, 'path-prefix'?: string | undefined, region?: string | undefined, 's3-force-path-style'?: boolean | undefined, 'secret-id'?: string | undefined, 'secret-key'?: string | undefined}; export type ConfigCaptcha = {'img-height'?: number | undefined, 'img-width'?: number | undefined, 'key-long'?: number | undefined, 'open-captcha'?: number | undefined, 'open-captcha-timeout'?: number | undefined}; export type ConfigCloudflareR2 = {'access-key-id'?: string | undefined, 'account-id'?: string | undefined, 'base-url'?: string | undefined, bucket?: string | undefined, path?: string | undefined, 'secret-access-key'?: string | undefined}; export type ConfigCORSWhitelist = {'allow-credentials'?: boolean | undefined, 'allow-headers'?: string | undefined, 'allow-methods'?: string | undefined, 'allow-origin'?: string | undefined, 'expose-headers'?: string | undefined}; export type ConfigCORS = {mode?: string | undefined, whitelist?: Array | undefined}; export type ConfigSpecializedDB = {'alias-name'?: string | undefined, config?: string | undefined, 'db-name'?: string | undefined, disable?: boolean | undefined, engine?: string | undefined, 'log-mode'?: string | undefined, 'log-zap'?: boolean | undefined, 'max-idle-conns'?: number | undefined, 'max-open-conns'?: number | undefined, password?: string | undefined, path?: string | undefined, port?: string | undefined, prefix?: string | undefined, singular?: boolean | undefined, type?: string | undefined, username?: string | undefined}; export type ConfigDiskList = {'mount-point'?: string | undefined}; export type GithubComFlippedAuroraGinVueAdminServerConfigEmail = {from?: string | undefined, host?: string | undefined, 'is-ssl'?: boolean | undefined, nickname?: string | undefined, port?: number | undefined, secret?: string | undefined, to?: string | undefined}; export type ConfigExcel = {dir?: string | undefined}; export type ConfigHuaWeiObs = {'access-key'?: string | undefined, bucket?: string | undefined, endpoint?: string | undefined, path?: string | undefined, 'secret-key'?: string | undefined}; export type ConfigJWT = {'buffer-time'?: string | undefined, 'expires-time'?: string | undefined, issuer?: string | undefined, 'signing-key'?: string | undefined}; export type ConfigLocal = {path?: string | undefined, 'store-path'?: string | undefined}; export type ConfigMongoHost = {host?: string | undefined, port?: string | undefined}; export type ConfigMongo = {'auth-source'?: string | undefined, coll?: string | undefined, 'connect-timeout-ms'?: number | undefined, database?: string | undefined, hosts?: Array | undefined, 'is-zap'?: boolean | undefined, 'max-pool-size'?: number | undefined, 'min-pool-size'?: number | undefined, options?: string | undefined, password?: string | undefined, 'socket-timeout-ms'?: number | undefined, username?: string | undefined}; export type ConfigMssql = {config?: string | undefined, 'db-name'?: string | undefined, engine?: string | undefined, 'log-mode'?: string | undefined, 'log-zap'?: boolean | undefined, 'max-idle-conns'?: number | undefined, 'max-open-conns'?: number | undefined, password?: string | undefined, path?: string | undefined, port?: string | undefined, prefix?: string | undefined, singular?: boolean | undefined, username?: string | undefined}; export type ConfigMysql = {config?: string | undefined, 'db-name'?: string | undefined, engine?: string | undefined, 'log-mode'?: string | undefined, 'log-zap'?: boolean | undefined, 'max-idle-conns'?: number | undefined, 'max-open-conns'?: number | undefined, password?: string | undefined, path?: string | undefined, port?: string | undefined, prefix?: string | undefined, singular?: boolean | undefined, username?: string | undefined}; export type ConfigOracle = {config?: string | undefined, 'db-name'?: string | undefined, engine?: string | undefined, 'log-mode'?: string | undefined, 'log-zap'?: boolean | undefined, 'max-idle-conns'?: number | undefined, 'max-open-conns'?: number | undefined, password?: string | undefined, path?: string | undefined, port?: string | undefined, prefix?: string | undefined, singular?: boolean | undefined, username?: string | undefined}; export type ConfigPgsql = {config?: string | undefined, 'db-name'?: string | undefined, engine?: string | undefined, 'log-mode'?: string | undefined, 'log-zap'?: boolean | undefined, 'max-idle-conns'?: number | undefined, 'max-open-conns'?: number | undefined, password?: string | undefined, path?: string | undefined, port?: string | undefined, prefix?: string | undefined, singular?: boolean | undefined, username?: string | undefined}; export type ConfigQiniu = {'access-key'?: string | undefined, bucket?: string | undefined, 'img-path'?: string | undefined, 'secret-key'?: string | undefined, 'use-cdn-domains'?: boolean | undefined, 'use-https'?: boolean | undefined, zone?: string | undefined}; export type ConfigRedis = {addr?: string | undefined, clusterAddrs?: Array | undefined, db?: number | undefined, password?: string | undefined, useCluster?: boolean | undefined}; export type ConfigSqlite = {config?: string | undefined, 'db-name'?: string | undefined, engine?: string | undefined, 'log-mode'?: string | undefined, 'log-zap'?: boolean | undefined, 'max-idle-conns'?: number | undefined, 'max-open-conns'?: number | undefined, password?: string | undefined, path?: string | undefined, port?: string | undefined, prefix?: string | undefined, singular?: boolean | undefined, username?: string | undefined}; export type ConfigSystem = {addr?: number | undefined, 'db-type'?: string | undefined, 'iplimit-count'?: number | undefined, 'iplimit-time'?: number | undefined, 'oss-type'?: string | undefined, 'router-prefix'?: string | undefined, 'use-mongo'?: boolean | undefined, 'use-multipoint'?: boolean | undefined, 'use-redis'?: boolean | undefined}; export type ConfigTencentCOS = {'base-url'?: string | undefined, bucket?: string | undefined, 'path-prefix'?: string | undefined, region?: string | undefined, 'secret-id'?: string | undefined, 'secret-key'?: string | undefined}; export type ConfigZap = {director?: string | undefined, 'encode-level'?: string | undefined, format?: string | undefined, level?: string | undefined, 'log-in-console'?: boolean | undefined, prefix?: string | undefined, 'retention-day'?: number | undefined, 'show-line'?: boolean | undefined, 'stacktrace-key'?: string | undefined}; export type ConfigServer = {'aliyun-oss'?: ConfigAliyunOSS | undefined, autocode?: ConfigAutocode | undefined, 'aws-s3'?: ConfigAwsS3 | undefined, captcha?: ConfigCaptcha | undefined, 'cloudflare-r2'?: ConfigCloudflareR2 | undefined, cors?: ConfigCORS | undefined, 'db-list'?: Array | undefined, 'disk-list'?: Array | undefined, email?: GithubComFlippedAuroraGinVueAdminServerConfigEmail | undefined, excel?: ConfigExcel | undefined, 'hua-wei-obs'?: ConfigHuaWeiObs | undefined, jwt?: ConfigJWT | undefined, local?: ConfigLocal | undefined, mongo?: ConfigMongo | undefined, mssql?: ConfigMssql | undefined, mysql?: ConfigMysql | undefined, oracle?: ConfigOracle | undefined, pgsql?: ConfigPgsql | undefined, qiniu?: ConfigQiniu | undefined, redis?: ConfigRedis | undefined, sqlite?: ConfigSqlite | undefined, system?: ConfigSystem | undefined, 'tencent-cos'?: ConfigTencentCOS | undefined, zap?: ConfigZap | undefined}; export type SystemSystem = {config?: ConfigServer | undefined}; export type CreateApiSystemSetSystemConfigArgs = {body: SystemSystem}; export type CreateApiSystemSetSystemConfigOptions = {baseUrl: string, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiSystemSetSystemConfigResponse = z.object({code: z.number().int().optional(), data: z.string().optional(), msg: 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 }; /** * 设置配置文件内容 * * POST /system/setSystemConfig */ export const createApiSystemSetSystemConfig = async (args: CreateApiSystemSetSystemConfigArgs, options: CreateApiSystemSetSystemConfigOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKeyAuth !== undefined) headers.set("x-token", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/system/setSystemConfig${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(createApiSystemSetSystemConfigResponse, await res.json()) };