import {z} from 'zod' export type LogicalOperators = 'or' | 'and'; export type GetApiApiV1PipelineBuildsArgs = {hydrate?: boolean | undefined, sort_by?: string | undefined, logical_operator?: LogicalOperators | undefined, page?: number | undefined, size?: number | undefined, id?: (string | string | null) | undefined, created?: (string | string | null) | undefined, updated?: (string | string | null) | undefined, scope_workspace?: (string | null) | undefined, workspace_id?: (string | string | null) | undefined, user_id?: (string | string | null) | undefined, pipeline_id?: (string | string | null) | undefined, stack_id?: (string | string | null) | undefined, is_local?: (boolean | null) | undefined, contains_code?: (boolean | null) | undefined, zenml_version?: (string | null) | undefined, python_version?: (string | null) | undefined, checksum?: (string | null) | undefined}; export type GetApiApiV1PipelineBuildsOptions = {baseUrl: string, CookieOAuth2TokenBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const userResponseBody = z.object({created: z.string(), updated: z.string(), active: z.boolean().optional(), activation_token: z.string().max(255).nullable().optional(), full_name: z.string().max(255).optional(), email_opted_in: z.boolean().nullable().optional(), is_service_account: z.boolean(), is_admin: z.boolean()}); export const userResponseMetadata = z.object({email: z.string().max(255).nullable().optional(), external_user_id: z.string().nullable().optional(), user_metadata: z.object({}).optional()}); export const userResponseResources = z.record(z.string(), z.unknown()); export const userResponse = z.object({body: userResponseBody.nullable().optional(), metadata: userResponseMetadata.nullable().optional(), resources: userResponseResources.nullable().optional(), id: z.string(), permission_denied: z.boolean().optional(), name: z.string().max(255)}); export const pipelineBuildResponseBody = z.object({created: z.string(), updated: z.string(), user: userResponse.nullable().optional()}); export const workspaceResponseBody = z.object({created: z.string(), updated: z.string()}); export const workspaceResponseMetadata = z.object({description: z.string().max(255).optional()}); export const workspaceResponseResources = z.record(z.string(), z.unknown()); export const workspaceResponse = z.object({body: workspaceResponseBody.nullable().optional(), metadata: workspaceResponseMetadata.nullable().optional(), resources: workspaceResponseResources.nullable().optional(), id: z.string(), permission_denied: z.boolean().optional(), name: z.string().max(255)}); export const executionStatus = z.enum(["initializing", "failed", "completed", "running", "cached"]); export const pipelineResponseBody = z.object({created: z.string(), updated: z.string(), user: userResponse.nullable().optional(), latest_run_id: z.string().nullable().optional(), latest_run_status: executionStatus.nullable().optional()}); export const pipelineResponseMetadata = z.object({workspace: workspaceResponse, description: z.string().nullable().optional()}); export const colorVariants = z.enum(["grey", "purple", "red", "green", "yellow", "orange", "lime", "teal", "turquoise", "magenta", "blue"]); export const tagResponseBody = z.object({created: z.string(), updated: z.string(), color: colorVariants.optional(), tagged_count: z.number().int()}); export const baseResponseMetadata = z.object({}); export const tagResponseResources = z.record(z.string(), z.unknown()); export const tagResponse = z.object({body: tagResponseBody.nullable().optional(), metadata: baseResponseMetadata.nullable().optional(), resources: tagResponseResources.nullable().optional(), id: z.string(), permission_denied: z.boolean().optional(), name: z.string().max(255)}); export const pipelineResponseResources = z.object({tags: z.array(tagResponse)}).and(z.record(z.string(), z.unknown())); export const pipelineResponse = z.object({body: pipelineResponseBody.nullable().optional(), metadata: pipelineResponseMetadata.nullable().optional(), resources: pipelineResponseResources.nullable().optional(), id: z.string(), permission_denied: z.boolean().optional(), name: z.string().max(255)}); export const stackResponseBody = z.object({created: z.string(), updated: z.string(), user: userResponse.nullable().optional()}); export const stackComponentType = z.enum(["alerter", "annotator", "artifact_store", "container_registry", "data_validator", "experiment_tracker", "feature_store", "image_builder", "model_deployer", "orchestrator", "step_operator", "model_registry"]); export const componentResponseBody = z.object({created: z.string(), updated: z.string(), user: userResponse.nullable().optional(), type: stackComponentType, flavor: z.string().max(255), integration: z.string().max(255).nullable().optional(), logo_url: z.string().nullable().optional()}); export const resourceTypeModel = z.object({name: z.string(), resource_type: z.string(), description: z.string().optional(), auth_methods: z.array(z.string()), supports_instances: z.boolean().optional(), logo_url: z.string().nullable().optional(), emoji: z.string().nullable().optional()}); export const authenticationMethodModel = z.object({name: z.string(), auth_method: z.string().max(255), description: z.string().optional(), config_schema: z.object({}).optional(), min_expiration_seconds: z.number().int().nullable().optional(), max_expiration_seconds: z.number().int().nullable().optional(), default_expiration_seconds: z.number().int().nullable().optional()}); export const serviceConnectorTypeModel = z.object({name: z.string(), connector_type: z.string().max(255), description: z.string().optional(), resource_types: z.array(resourceTypeModel), auth_methods: z.array(authenticationMethodModel), supports_auto_configuration: z.boolean().optional(), logo_url: z.string().nullable().optional(), emoji: z.string().nullable().optional(), docs_url: z.string().nullable().optional(), sdk_docs_url: z.string().nullable().optional(), local: z.boolean().optional(), remote: z.boolean().optional()}); export const serviceConnectorResponseBody = z.object({created: z.string(), updated: z.string(), user: userResponse.nullable().optional(), description: z.string().optional(), connector_type: z.union([z.string(), serviceConnectorTypeModel]), auth_method: z.string().max(255), resource_types: z.array(z.string()).optional(), resource_id: z.string().max(255).nullable().optional(), supports_instances: z.boolean().optional(), expires_at: z.string().nullable().optional(), expires_skew_tolerance: z.number().int().nullable().optional()}); export const serviceConnectorResponseMetadata = z.object({workspace: workspaceResponse, configuration: z.object({}).optional(), secret_id: z.string().nullable().optional(), expiration_seconds: z.number().int().nullable().optional(), secrets: z.record(z.string(), z.string().nullable()).optional(), labels: z.record(z.string(), z.string()).optional()}); export const serviceConnectorResponseResources = z.record(z.string(), z.unknown()); export const serviceConnectorResponse = z.object({body: serviceConnectorResponseBody.nullable().optional(), metadata: serviceConnectorResponseMetadata.nullable().optional(), resources: serviceConnectorResponseResources.nullable().optional(), id: z.string(), permission_denied: z.boolean().optional(), name: z.string().max(255)}); export const componentResponseMetadata = z.object({workspace: workspaceResponse, configuration: z.object({}), labels: z.object({}).nullable().optional(), component_spec_path: z.string().nullable().optional(), connector_resource_id: z.string().nullable().optional(), connector: serviceConnectorResponse.nullable().optional()}); export const componentResponseResources = z.record(z.string(), z.unknown()); export const componentResponse = z.object({body: componentResponseBody.nullable().optional(), metadata: componentResponseMetadata.nullable().optional(), resources: componentResponseResources.nullable().optional(), id: z.string(), permission_denied: z.boolean().optional(), name: z.string().max(255)}); export const stackResponseMetadata = z.object({workspace: workspaceResponse, components: z.record(z.string(), z.array(componentResponse)), description: z.string().max(255).nullable().optional(), stack_spec_path: z.string().nullable().optional(), labels: z.object({}).nullable().optional()}); export const stackResponseResources = z.record(z.string(), z.unknown()); export const stackResponse = z.object({body: stackResponseBody.nullable().optional(), metadata: stackResponseMetadata.nullable().optional(), resources: stackResponseResources.nullable().optional(), id: z.string(), permission_denied: z.boolean().optional(), name: z.string().max(255)}); export const buildItem = z.object({image: z.string(), dockerfile: z.string().nullable().optional(), requirements: z.string().nullable().optional(), settings_checksum: z.string().nullable().optional(), contains_code: z.boolean().optional(), requires_code_download: z.boolean().optional()}); export const pipelineBuildResponseMetadata = z.object({workspace: workspaceResponse, pipeline: pipelineResponse.nullable().optional(), stack: stackResponse.nullable().optional(), images: z.record(z.string(), buildItem).optional(), zenml_version: z.string().nullable().optional(), python_version: z.string().nullable().optional(), checksum: z.string().nullable().optional(), stack_checksum: z.string().nullable().optional(), is_local: z.boolean(), contains_code: z.boolean()}); export const pipelineBuildResponseResources = z.record(z.string(), z.unknown()); export const pipelineBuildResponse = z.object({body: pipelineBuildResponseBody.nullable().optional(), metadata: pipelineBuildResponseMetadata.nullable().optional(), resources: pipelineBuildResponseResources.nullable().optional(), id: z.string(), permission_denied: z.boolean().optional()}); export const pagePipelineBuildResponse = z.object({index: z.number().int().gt(0), max_size: z.number().int().gt(0), total_pages: z.number().int().gte(0), total: z.number().int().gte(0), items: z.array(pipelineBuildResponse)}); 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 Builds * * GET /api/v1/pipeline_builds */ export const getApiApiV1PipelineBuilds = async (args: GetApiApiV1PipelineBuildsArgs, options: GetApiApiV1PipelineBuildsOptions) => { const {baseUrl, fetch: fetchFn = fetch, CookieOAuth2TokenBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.hydrate != null) query.append("hydrate", String(args.hydrate)) if (args.sort_by != null) query.append("sort_by", String(args.sort_by)) if (args.logical_operator != null) query.append("logical_operator", String(args.logical_operator)) if (args.page != null) query.append("page", String(args.page)) if (args.size != null) query.append("size", String(args.size)) if (args.id != null) query.append("id", String(args.id)) if (args.created != null) query.append("created", String(args.created)) if (args.updated != null) query.append("updated", String(args.updated)) if (args.scope_workspace != null) query.append("scope_workspace", String(args.scope_workspace)) if (args.workspace_id != null) query.append("workspace_id", String(args.workspace_id)) if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args.pipeline_id != null) query.append("pipeline_id", String(args.pipeline_id)) if (args.stack_id != null) query.append("stack_id", String(args.stack_id)) if (args.is_local != null) query.append("is_local", String(args.is_local)) if (args.contains_code != null) query.append("contains_code", String(args.contains_code)) if (args.zenml_version != null) query.append("zenml_version", String(args.zenml_version)) if (args.python_version != null) query.append("python_version", String(args.python_version)) if (args.checksum != null) query.append("checksum", String(args.checksum)) if (CookieOAuth2TokenBearer !== undefined) headers.set('authorization', `Bearer ${CookieOAuth2TokenBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/pipeline_builds${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(pagePipelineBuildResponse, await res.json()) };