UNPKG

@gentrace/core

Version:
28 lines (22 loc) 849 B
import { globalGentraceApi } from "./init"; type PipelineParams = { label?: string; slug?: string; }; /** * Retrieves pipelines from the Gentrace API. * @async * @param {PipelineParams} [params] - Optional parameters to filter the pipelines. * @returns {Promise<Array<Pipeline>>} - A promise that resolves to an array of pipelines. * @throws {Error} - Throws an error if the Gentrace API key is not initialized. */ export const getPipelines = async (params?: PipelineParams) => { if (!globalGentraceApi) { throw new Error("Gentrace API key not initialized. Call init() first."); } const label = (params ?? {}).label; const slug = (params ?? {}).slug; const parameters: (string | undefined)[] = [label, slug]; const response = await globalGentraceApi.v1PipelinesGet(...parameters); return response.data.pipelines; };