import {z} from 'zod' export type ModelsquareV1UpdateEntrySlotRequest = {description?: string | undefined, descriptionEn?: string | undefined, iconUrl?: string | undefined, jumpUrl?: string | undefined, slotNo?: number | undefined, status?: number | undefined, title?: string | undefined, titleEn?: string | undefined}; export type UpdateApiV1AdminModelSquareEntrySlotsSlotNoArgs = {slotNo: number, body: ModelsquareV1UpdateEntrySlotRequest}; export type UpdateApiV1AdminModelSquareEntrySlotsSlotNoOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const modelsquareV1EntrySlot = z.object({createdAt: z.string().optional(), creator: z.string().optional(), description: z.string().optional(), descriptionEn: z.string().optional(), iconUrl: z.string().optional(), id: z.number().int().optional(), jumpUrl: z.string().optional(), slotName: z.string().optional(), slotNo: z.number().int().optional(), status: z.number().int().optional(), title: z.string().optional(), titleEn: z.string().optional(), updatedAt: z.string().optional(), updater: z.string().optional()}); export const modelsquareV1UpdateEntrySlotReply = z.object({entrySlot: modelsquareV1EntrySlot.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 }; /** * UpdateEntrySlot 修改固定入口位配置(仅平台管理员,slotNo 只允许 1/2/3)。 * * PUT /v1/admin/model-square/entry-slots/{slotNo} */ export const updateApiV1AdminModelSquareEntrySlotsSlotNo = async (args: UpdateApiV1AdminModelSquareEntrySlotsSlotNoArgs, options: UpdateApiV1AdminModelSquareEntrySlotsSlotNoOptions) => { 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/model-square/entry-slots/${encodeURIComponent(String(args.slotNo))}${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(modelsquareV1UpdateEntrySlotReply, await res.json()) };