import {z} from 'zod' export type AuditLogV2SelectSchema = {projectId?: boolean | undefined, resourceType?: boolean | undefined, resourceId?: boolean | undefined, resourceName?: boolean | undefined, rootResourceType?: boolean | undefined, rootResourceId?: boolean | undefined, action?: boolean | undefined, userId?: boolean | undefined, userName?: boolean | undefined, userEmail?: boolean | undefined, userType?: boolean | undefined, apiKeyId?: boolean | undefined, apiKeyName?: boolean | undefined, mcpOAuthGrantId?: boolean | undefined, mcpClientName?: boolean | undefined, workflowId?: boolean | undefined, workflowName?: boolean | undefined, changes?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type CreateApiAuditLogIdGetItemArgs = {id: string, body: {select?: AuditLogV2SelectSchema | undefined}}; export type CreateApiAuditLogIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const auditLogV2 = z.object({projectId: z.string(), resourceType: z.string(), resourceId: z.string(), resourceName: z.string().optional(), rootResourceType: z.string().optional(), rootResourceId: z.string().optional(), action: z.string(), userId: z.string().optional(), userName: z.string().optional(), userEmail: z.string().optional(), userType: z.string().optional(), apiKeyId: z.string().optional(), apiKeyName: z.string().optional(), mcpOAuthGrantId: z.string().optional(), mcpClientName: z.string().optional(), workflowId: z.string().optional(), workflowName: z.string().optional(), changes: z.array(z.object({})).optional()}); export const createApiAuditLogIdGetItemResponse = z.object({data: auditLogV2.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 Audit Log * * POST /audit-log/{id}/get-item */ export const createApiAuditLogIdGetItem = async (args: CreateApiAuditLogIdGetItemArgs, options?: CreateApiAuditLogIdGetItemOptions) => { 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(/\/+$/, '')}/audit-log/${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(createApiAuditLogIdGetItemResponse, await res.json()) };