import {z} from 'zod' export type GetApiApiV30OrgsOrgUuidReportsArgs = {cursor?: string | undefined, limit?: string | undefined, orgUuid: string}; export type GetApiApiV30OrgsOrgUuidReportsOptions = {baseUrl?: string | undefined, bearerKey?: string | undefined, fetch?: typeof fetch | undefined}; export const entityTreeDTO = z.object({uuid: z.string().optional(), name: z.string().optional(), scopeUuid: z.string().optional(), scopeName: z.string().optional()}); export const reportExportProcessDTOV3 = z.object({uuid: z.string().optional(), name: z.string().optional(), scopeUuid: z.string().optional(), scopeName: z.string().optional(), subScopes: z.array(entityTreeDTO).optional(), title: z.string().optional(), reportType: z.enum(["attribution", "inventory", "vulnerabilities", "securityAlerts", "sbom", "Cbom", "securityAlertsLibrary", "Compliance", "Findings", "Suppressions", "Resolved", "spdx", "spdx_2_3", "cycloneDX", "cycloneDX_1_5", "cycloneDX_1_6", "dueDiligence", "unknown", "imgAttribution", "imgDueDiligence", "imgSpdx", "imgSpdx_2_3", "imgCycloneDX", "imgCycloneDX_1_5", "aiInventory", "aiFindings", "aiBom", "aiEntities", "conversationalSystemPrompts", "imgCycloneDX_1_6", "risk", "users", "zeroDayCatalog", "activityLog", "unifiedFindings"]).optional(), format: z.enum(["json", "html", "unknown", "xml", "excel", "yaml", "pdf", "tv", "rdf", "csv", "sarif", "text"]).optional(), scopeType: z.enum(["organization", "application", "project", "account", "unsupported"]).optional(), status: z.enum(["PENDING", "IN_PROGRESS", "FAILED", "FAILURE", "SUCCESS"]).optional(), createdBy: z.string().optional(), createdAt: z.string().optional()}); export const dWRResponsePageableV3ListReportExportProcessDTOV3 = z.object({additionalData: z.object({}).optional(), supportToken: z.string().optional(), response: z.array(reportExportProcessDTOV3).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 Reports * * GET /api/v3.0/orgs/{orgUuid}/reports */ export const getApiApiV30OrgsOrgUuidReports = async (args: GetApiApiV30OrgsOrgUuidReportsArgs, options?: GetApiApiV30OrgsOrgUuidReportsOptions) => { const {baseUrl = "https://baseUrl", fetch: fetchFn = fetch, bearerKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.limit != null) query.append("limit", String(args.limit)) if (bearerKey !== undefined) headers.set('authorization', `Bearer ${bearerKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3.0/orgs/${encodeURIComponent(String(args.orgUuid))}/reports${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(dWRResponsePageableV3ListReportExportProcessDTOV3, await res.json()) };