import {z} from 'zod' export type LabelRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, name?: boolean | undefined, projectId?: boolean | undefined, color?: boolean | undefined, isArchived?: boolean | undefined}; export type SecurityCaseSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, caseNumber?: boolean | undefined, caseNumberWithPrefix?: boolean | undefined, title?: boolean | undefined, description?: boolean | undefined, securityCaseStatusId?: boolean | undefined, securityCasePriorityId?: boolean | undefined, verdict?: boolean | undefined, closingNote?: boolean | undefined, assignedToUserId?: boolean | undefined, assignedToTeamId?: boolean | undefined, source?: boolean | undefined, entities?: boolean | undefined, mitreTactics?: boolean | undefined, mitreTechniques?: boolean | undefined, customFields?: boolean | undefined, detectionCount?: boolean | undefined, firstDetectedAt?: boolean | undefined, lastDetectedAt?: boolean | undefined, acknowledgedAt?: boolean | undefined, containedAt?: boolean | undefined, closedAt?: boolean | undefined, acknowledgeDueAt?: boolean | undefined, containDueAt?: boolean | undefined, acknowledgeWarnedAt?: boolean | undefined, acknowledgeMissedAt?: boolean | undefined, containWarnedAt?: boolean | undefined, containMissedAt?: boolean | undefined, nextDueAt?: boolean | undefined, nextTargetCheckAt?: boolean | undefined, closedByUserId?: boolean | undefined, groupingKey?: boolean | undefined, notifiedSecurityCasePriorityId?: boolean | undefined, incidentId?: boolean | undefined, aiVerdict?: boolean | undefined, aiSuggestedSecurityCasePriorityId?: boolean | undefined, aiSuggestedPlaybookId?: boolean | undefined, aiTriageReport?: boolean | undefined, aiTriagedAt?: boolean | undefined, aiTriagePromptInjectionSuspected?: boolean | undefined, labels?: LabelRelationSelectSchema | undefined, createdByUserId?: boolean | undefined, deletedByUserId?: boolean | undefined}; export type CreateApiSecurityCaseIdGetItemArgs = {id: string, body: {select?: SecurityCaseSelectSchema | undefined}}; export type CreateApiSecurityCaseIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const securityCase = z.object({_id: z.string().optional(), createdAt: z.object({}).optional(), updatedAt: z.object({}).optional(), deletedAt: z.object({}).optional(), version: z.number().optional(), projectId: z.string(), caseNumber: z.number().optional(), caseNumberWithPrefix: z.string().optional(), title: z.string(), description: z.string().optional(), securityCaseStatusId: z.string().optional(), securityCasePriorityId: z.string().optional(), verdict: z.enum(["True Positive", "Benign Positive", "False Positive", "Undetermined"]).optional(), closingNote: z.string().optional(), assignedToUserId: z.string().optional(), assignedToTeamId: z.string().optional(), source: z.enum(["Detection Rule", "Threat Intel", "Connected Product", "Manual", "Entity Risk", "Data Security"]).optional(), entities: z.object({}).optional(), mitreTactics: z.object({}).optional(), mitreTechniques: z.object({}).optional(), customFields: z.object({}).optional(), detectionCount: z.number().optional(), firstDetectedAt: z.object({}).optional(), lastDetectedAt: z.object({}).optional(), acknowledgedAt: z.object({}).optional(), containedAt: z.object({}).optional(), closedAt: z.object({}).optional(), acknowledgeDueAt: z.object({}).optional(), containDueAt: z.object({}).optional(), acknowledgeWarnedAt: z.object({}).optional(), acknowledgeMissedAt: z.object({}).optional(), containWarnedAt: z.object({}).optional(), containMissedAt: z.object({}).optional(), nextDueAt: z.object({}).optional(), nextTargetCheckAt: z.object({}).optional(), closedByUserId: z.string().optional(), groupingKey: z.string().optional(), notifiedSecurityCasePriorityId: z.string().optional(), incidentId: z.string().optional(), aiVerdict: z.enum(["Likely Malicious", "Likely Benign", "Likely False Positive", "Inconclusive"]).optional(), aiSuggestedSecurityCasePriorityId: z.string().optional(), aiSuggestedPlaybookId: z.string().optional(), aiTriageReport: z.string().optional(), aiTriagedAt: z.object({}).optional(), aiTriagePromptInjectionSuspected: z.boolean().optional(), labels: z.array(z.object({_id: z.string().optional()})).optional(), createdByUserId: z.string().optional(), deletedByUserId: z.string().optional()}); export const createApiSecurityCaseIdGetItemResponse = z.object({data: securityCase.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 Security Case * * POST /security-case/{id}/get-item */ export const createApiSecurityCaseIdGetItem = async (args: CreateApiSecurityCaseIdGetItemArgs, options?: CreateApiSecurityCaseIdGetItemOptions) => { 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(/\/+$/, '')}/security-case/${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(createApiSecurityCaseIdGetItemResponse, await res.json()) };