import {z} from 'zod' export type GetApiApiV30ProjectsProjectUuidAiFindingsTechnologiesArgs = {projectUuid: string, cursor?: string | undefined, limit?: number | undefined}; export type GetApiApiV30ProjectsProjectUuidAiFindingsTechnologiesOptions = {baseUrl?: string | undefined, bearerKey?: string | undefined, fetch?: typeof fetch | undefined}; export const v3DTOAIComponent = z.object({componentId: z.string().optional(), componentName: z.string().optional(), componentType: z.string().optional(), componentVersion: z.string().optional()}); export const v3V3Pagination = z.object({cursor: z.number().int().optional(), hasMore: z.boolean().optional(), limit: z.number().int().optional(), total: z.number().int().optional()}); export const v3V3BaseResponseArrayV3DTOAIComponent = z.object({data: z.array(v3DTOAIComponent).optional(), pagination: v3V3Pagination.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 project AI technologies * * GET /api/v3.0/projects/{projectUuid}/ai/findings/technologies */ export const getApiApiV30ProjectsProjectUuidAiFindingsTechnologies = async (args: GetApiApiV30ProjectsProjectUuidAiFindingsTechnologiesArgs, options?: GetApiApiV30ProjectsProjectUuidAiFindingsTechnologiesOptions) => { 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/projects/${encodeURIComponent(String(args.projectUuid))}/ai/findings/technologies${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(v3V3BaseResponseArrayV3DTOAIComponent, await res.json()) };