import {z} from 'zod' export type GetApi1PlatformBuildDetailsArgs = {appId: string}; export type GetApi1PlatformBuildDetailsOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const platformBuildDetailsListAllProperties = z.object({id: z.string().optional(), platform: z.enum(["EPIC", "STEAM", "GOG"]).optional(), appId: z.string(), timeToPull: z.string(), platformBuildDetails: z.object({}), scheduledRelease: z.string().nullable(), label: z.string().max(100).optional(), semanticVersion: z.string().max(50).optional(), notes: z.string().max(10240).optional(), target: z.literal("GEFORCENOW").optional(), buildTags: z.array(z.string().max(1024)).optional(), createdBy: z.string().optional(), createdTime: z.string().optional(), modifiedBy: z.string().optional(), modifiedTime: z.string().optional()}); export const pagination = z.object({total: z.number().int().optional(), offset: z.number().int().optional(), limit: z.number().int().optional(), nextOffset: z.number().int().optional(), previousOffset: z.number().int().optional()}); export const platformBuildDetailsListResponse = z.object({data: z.array(platformBuildDetailsListAllProperties).optional(), paging: pagination.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 }; /** * GET /1/platform-build-details */ export const getApi1PlatformBuildDetails = async (args: GetApi1PlatformBuildDetailsArgs, options: GetApi1PlatformBuildDetailsOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.appId != null) query.append("appId", String(args.appId)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/1/platform-build-details${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(platformBuildDetailsListResponse, await res.json()) };