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 = {root?: string | undefined, server?: string | undefined, 'server-api'?: string | undefined, 'server-initialize'?: string | undefined, 'server-model'?: string | undefined, 'server-plug'?: string | undefined, 'server-request'?: string | undefined, 'server-router'?: string | undefined, 'server-service'?: string | undefined, 'transfer-restart'?: boolean | undefined, web?: string | undefined, 'web-api'?: string | undefined, 'web-form'?: string | undefined, 'web-table'?: 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 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 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 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 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 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, db?: number | undefined, password?: string | undefined}; export type ConfigSystem = {addr?: number | undefined, 'db-type'?: string | undefined, env?: string | undefined, 'iplimit-count'?: number | undefined, 'iplimit-time'?: number | undefined, 'oss-type'?: string | undefined, 'router-prefix'?: string | 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 ConfigDetail = {compareField?: string | undefined, interval?: string | undefined, tableName?: string | undefined}; export type ConfigTimer = {detail?: Array | undefined, spec?: string | undefined, start?: boolean | undefined, with_seconds?: boolean | undefined}; export type ConfigZap = {director?: string | undefined, 'encode-level'?: string | undefined, format?: string | undefined, level?: string | undefined, 'log-in-console'?: boolean | undefined, 'max-age'?: number | undefined, prefix?: string | 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, cors?: ConfigCORS | undefined, 'db-list'?: Array | undefined, email?: GithubComFlippedAuroraGinVueAdminServerConfigEmail | undefined, excel?: ConfigExcel | undefined, 'hua-wei-obs'?: ConfigHuaWeiObs | undefined, jwt?: ConfigJWT | undefined, local?: ConfigLocal | undefined, mssql?: ConfigMssql | undefined, mysql?: ConfigMysql | undefined, oracle?: ConfigOracle | undefined, pgsql?: ConfigPgsql | undefined, sqlite?: ConfigSqlite | undefined, qiniu?: ConfigQiniu | undefined, redis?: ConfigRedis | undefined, system?: ConfigSystem | undefined, 'tencent-cos'?: ConfigTencentCOS | undefined, timer?: ConfigTimer | 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()) };