import {z} from 'zod' export type GetApiApiV1OrgsOrgIdHelmChartsArgs = {orgId: number, name?: string | undefined, repo?: string | undefined, version?: string | undefined}; export type GetApiApiV1OrgsOrgIdHelmChartsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const helmChartsListResponseInnerChartsInnerInnerMaintainersInner = z.object({name: z.string().optional(), email: z.string().optional()}); export const helmChartsListResponseInnerChartsInnerInner = z.object({name: z.string().optional(), home: z.string().optional(), sources: z.array(z.string()).optional(), version: z.string().optional(), description: z.string().optional(), keywords: z.array(z.string()).optional(), maintainers: z.array(helmChartsListResponseInnerChartsInnerInnerMaintainersInner).optional(), engine: z.string().optional(), icon: z.string().optional(), appVersion: z.string().optional(), apiVersion: z.string().optional(), deprecated: z.boolean().optional(), urls: z.array(z.string()).optional(), created: z.string().optional(), digest: z.string().optional()}); export const helmChartsListResponseInner = z.object({name: z.string().optional(), charts: z.array(z.array(helmChartsListResponseInnerChartsInnerInner)).optional()}); export const helmChartsListResponse = z.array(helmChartsListResponseInner); 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 }; /** * Chart List * * GET /api/v1/orgs/{orgId}/helm/charts */ export const getApiApiV1OrgsOrgIdHelmCharts = async (args: GetApiApiV1OrgsOrgIdHelmChartsArgs, options?: GetApiApiV1OrgsOrgIdHelmChartsOptions) => { const {baseUrl = "http://localhost:9090", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.name != null) query.append("name", String(args.name)) if (args.repo != null) query.append("repo", String(args.repo)) if (args.version != null) query.append("version", String(args.version)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/orgs/${encodeURIComponent(String(args.orgId))}/helm/charts${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(helmChartsListResponse, await res.json()) };