import {z} from 'zod' export type GetApiV1WorkspacesWorkspaceRegistriesRegistryIdItemsArgs = {registry_id: string, workspace: string, limit?: number | undefined, offset?: number | undefined}; export type GetApiV1WorkspacesWorkspaceRegistriesRegistryIdItemsOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const catalogComputeEstimate = z.object({currency: z.string().nullable(), hourly: z.string().nullable(), memory_gib: z.string(), vcpu: z.string()}); export const catalogToolPrice = z.object({amount: z.string(), basis: z.enum(["price", "vendor_cost"]), currency: z.string(), tool: z.string().nullable(), unavailable: z.boolean().optional(), unit: z.string()}); export const catalogItemPricingResponse = z.object({compute: catalogComputeEstimate.nullable().optional(), kind: z.enum(["paid", "own_key", "free"]), payers: z.array(z.string()), price_from: catalogToolPrice.nullable(), prices: z.array(catalogToolPrice)}); export const catalogConnection = z.object({id: z.string(), kind: z.enum(["mcp", "openapi"]), name: z.string()}); export const registryItemResponse = z.object({category: z.string().nullable().optional(), created_at: z.string(), description: z.string().nullable(), external_id: z.string(), featured: z.boolean().optional(), hosting: z.string().nullable().optional(), id: z.string(), installed_entity_id: z.string().nullable(), installed_version: z.string().nullable(), name: z.string(), pricing: catalogItemPricingResponse.nullable().optional(), registry_id: z.string(), registry_mode: z.enum(["mirror", "upstream"]).nullable().optional(), registry_name: z.string().nullable().optional(), registry_scope: z.enum(["platform", "workspace"]).nullable().optional(), registry_trust: z.enum(["official", "verified", "community", "private"]), spec: z.record(z.string(), z.unknown()), tags: z.array(z.string()), update_available: z.boolean(), updated_at: z.string(), version: z.string().nullable(), workspace_connections: z.array(catalogConnection).nullable().optional()}); export const getApiV1WorkspacesWorkspaceRegistriesRegistryIdItemsResponse = z.array(registryItemResponse); 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 }; /** * List Registry Items * * GET /v1/workspaces/{workspace}/registries/{registry_id}/items */ export const getApiV1WorkspacesWorkspaceRegistriesRegistryIdItems = async (args: GetApiV1WorkspacesWorkspaceRegistriesRegistryIdItemsArgs, options: GetApiV1WorkspacesWorkspaceRegistriesRegistryIdItemsOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/workspaces/${encodeURIComponent(String(args.workspace))}/registries/${encodeURIComponent(String(args.registry_id))}/items${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(getApiV1WorkspacesWorkspaceRegistriesRegistryIdItemsResponse, await res.json()) };