import {z} from 'zod' export type ProfileSampleItemV3SelectSchema = {projectId?: boolean | undefined, primaryEntityId?: boolean | undefined, primaryEntityType?: boolean | undefined, profileId?: boolean | undefined, traceId?: boolean | undefined, spanId?: boolean | undefined, time?: boolean | undefined, timeUnixNano?: boolean | undefined, stacktrace?: boolean | undefined, stacktraceHash?: boolean | undefined, frameTypes?: boolean | undefined, value?: boolean | undefined, profileType?: boolean | undefined, labels?: boolean | undefined, entityKeys?: boolean | undefined, serviceEntityKey?: boolean | undefined, hostEntityKey?: boolean | undefined, k8sPodEntityKey?: boolean | undefined, k8sNodeEntityKey?: boolean | undefined, k8sClusterEntityKey?: boolean | undefined, containerEntityKey?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type CreateApiProfileSampleIdGetItemArgs = {id: string, body: {select?: ProfileSampleItemV3SelectSchema | undefined}}; export type CreateApiProfileSampleIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const profileSampleItemV3 = z.object({projectId: z.string(), primaryEntityId: z.string(), primaryEntityType: z.string().optional(), profileId: z.string(), traceId: z.string().optional(), spanId: z.string().optional(), time: z.string().optional(), timeUnixNano: z.string().optional(), stacktrace: z.array(z.string()).optional(), stacktraceHash: z.string(), frameTypes: z.array(z.string()).optional(), value: z.string().optional(), profileType: z.string(), labels: z.string().optional(), entityKeys: z.array(z.string()).optional(), serviceEntityKey: z.string().optional(), hostEntityKey: z.string().optional(), k8sPodEntityKey: z.string().optional(), k8sNodeEntityKey: z.string().optional(), k8sClusterEntityKey: z.string().optional(), containerEntityKey: z.string().optional()}); export const createApiProfileSampleIdGetItemResponse = z.object({data: profileSampleItemV3.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 ProfileSample * * POST /profile-sample/{id}/get-item */ export const createApiProfileSampleIdGetItem = async (args: CreateApiProfileSampleIdGetItemArgs, options?: CreateApiProfileSampleIdGetItemOptions) => { const {baseUrl = "https://oneuptime.com/api", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKey !== undefined) headers.set("APIKey", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/profile-sample/${encodeURIComponent(String(args.id))}/get-item${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(createApiProfileSampleIdGetItemResponse, await res.json()) };