import {z} from 'zod' export type V1IndexData = {data?: Array | undefined, search_score?: number | undefined, tenant?: string | undefined, will_be_deleted_at?: string | undefined}; export type GoogleprotobufAny = {'@type'?: string | undefined} | {[key: string]: unknown}; export type V1Meta = {annotations?: {[key: string]: string} | undefined, create_time?: string | undefined, created_by?: string | undefined, description?: string | undefined, index_data?: V1IndexData | undefined, kind?: string | undefined, name: string, parent_kind?: string | undefined, parent_uuid?: string | undefined, references?: {[key: string]: GoogleprotobufAny} | undefined, tags?: Array | undefined, update_time?: string | undefined, updated_by?: string | undefined, upsert_time?: string | undefined, version?: string | undefined}; export type V1LicenseDependencySpec = {category?: string | undefined, declared?: boolean | undefined, license_name?: string | undefined, osi_approved?: boolean | undefined, package_version_uuids?: Array | undefined, spdx_id: string}; export type LicenseDependencyServiceCreateLicenseDependencyBody = {meta: V1Meta, spec: V1LicenseDependencySpec, tenant_meta?: Record | undefined, uuid?: string | undefined}; export type CreateApiV1NamespacesTenantMetaNamespaceLicenseDependenciesArgs = {'tenant_meta.namespace': string, body: LicenseDependencyServiceCreateLicenseDependencyBody}; export type CreateApiV1NamespacesTenantMetaNamespaceLicenseDependenciesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const v1IndexData = z.object({data: z.array(z.string()).optional(), search_score: z.number().optional(), tenant: z.string().optional(), will_be_deleted_at: z.string().optional()}); export const googleprotobufAny = z.object({"@type": z.string().optional()}).and(z.record(z.string(), z.unknown())); export const v1Meta = z.object({annotations: z.record(z.string(), z.string()).optional(), create_time: z.string().optional(), created_by: z.string().optional(), description: z.string().optional(), index_data: v1IndexData.optional(), kind: z.string().optional(), name: z.string(), parent_kind: z.string().optional(), parent_uuid: z.string().optional(), references: z.record(z.string(), googleprotobufAny).optional(), tags: z.array(z.string()).optional(), update_time: z.string().optional(), updated_by: z.string().optional(), upsert_time: z.string().optional(), version: z.string().optional()}); export const v1LicenseDependencySpec = z.object({category: z.string().optional(), declared: z.boolean().optional(), license_name: z.string().optional(), osi_approved: z.boolean().optional(), package_version_uuids: z.array(z.string()).optional(), spdx_id: z.string()}); export const v1TenantMeta = z.object({namespace: z.string()}); export const v1LicenseDependency = z.object({meta: v1Meta, spec: v1LicenseDependencySpec, tenant_meta: v1TenantMeta.optional(), uuid: z.string().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 }; /** * CreateLicenseDependency * * POST /v1/namespaces/{tenant_meta.namespace}/license-dependencies */ export const createApiV1NamespacesTenantMetaNamespaceLicenseDependencies = async (args: CreateApiV1NamespacesTenantMetaNamespaceLicenseDependenciesArgs, options?: CreateApiV1NamespacesTenantMetaNamespaceLicenseDependenciesOptions) => { const {baseUrl = "https://api.endorlabs.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/namespaces/${encodeURIComponent(String(args['tenant_meta.namespace']))}/license-dependencies${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(v1LicenseDependency, await res.json()) };