import {z} from 'zod' export type AuditLogV2QuerySchema = {projectId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, resourceType?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, resourceId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, resourceName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, rootResourceType?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, rootResourceId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, action?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, userId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, userName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, userEmail?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, userType?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, apiKeyId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, apiKeyName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, mcpOAuthGrantId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, mcpClientName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, workflowId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, workflowName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, changes?: ({_type: 'IsNull'} | {_type: 'NotNull'}) | undefined, _id?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, createdAt?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined}; 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 AuditLogV2SortSchema = {projectId?: ('ASC' | 'DESC') | undefined, resourceType?: ('ASC' | 'DESC') | undefined, resourceId?: ('ASC' | 'DESC') | undefined, resourceName?: ('ASC' | 'DESC') | undefined, rootResourceType?: ('ASC' | 'DESC') | undefined, rootResourceId?: ('ASC' | 'DESC') | undefined, action?: ('ASC' | 'DESC') | undefined, userId?: ('ASC' | 'DESC') | undefined, userName?: ('ASC' | 'DESC') | undefined, userEmail?: ('ASC' | 'DESC') | undefined, userType?: ('ASC' | 'DESC') | undefined, apiKeyId?: ('ASC' | 'DESC') | undefined, apiKeyName?: ('ASC' | 'DESC') | undefined, mcpOAuthGrantId?: ('ASC' | 'DESC') | undefined, mcpClientName?: ('ASC' | 'DESC') | undefined, workflowId?: ('ASC' | 'DESC') | undefined, workflowName?: ('ASC' | 'DESC') | undefined, retentionDate?: ('ASC' | 'DESC') | undefined, _id?: ('ASC' | 'DESC') | undefined, createdAt?: ('ASC' | 'DESC') | undefined}; export type AuditLogV2GroupBySchema = {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, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type CreateApiAuditLogGetListArgs = {body: {query?: AuditLogV2QuerySchema | undefined, select?: AuditLogV2SelectSchema | undefined, sort?: AuditLogV2SortSchema | undefined, groupBy?: AuditLogV2GroupBySchema | undefined, limit?: number | undefined, skip?: number | undefined}}; export type CreateApiAuditLogGetListOptions = {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 createApiAuditLogGetListResponse = z.object({data: z.array(auditLogV2).optional(), count: z.number().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 }; /** * List Audit Log * * POST /audit-log/get-list */ export const createApiAuditLogGetList = async (args: CreateApiAuditLogGetListArgs, options?: CreateApiAuditLogGetListOptions) => { 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/get-list${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(createApiAuditLogGetListResponse, await res.json()) };