import { d as defineEventHandler, b as getRouterParam, g as getQuery, c as createError, M as findByNameAndVersion } from '../../../nitro/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'stream';
import 'events';
import 'http';
import 'crypto';
import 'buffer';
import 'zlib';
import 'https';
import 'net';
import 'tls';
import 'url';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'vue-router';
import '@prisma/client';
import '@prisma/adapter-better-sqlite3';
import 'fs';
import 'path';
import 'fs/promises';
import 'child_process';
import 'node:child_process';
import 'node:url';

const _name__get = defineEventHandler(async (event) => {
  const rawName = getRouterParam(event, "name");
  const query = getQuery(event);
  if (!rawName) {
    throw createError({
      statusCode: 400,
      message: "Pipeline name required"
    });
  }
  const name = decodeURIComponent(rawName);
  const version = query["version"] ? parseInt(query["version"], 10) : void 0;
  const pipeline = await findByNameAndVersion(name, version);
  if (!pipeline) {
    const versionInfo = version !== void 0 ? ` v${version}` : "";
    throw createError({
      statusCode: 404,
      message: `Pipeline not found: ${name}${versionInfo}`
    });
  }
  return {
    name: pipeline.name,
    version: pipeline.version,
    description: pipeline.description,
    active: pipeline.active,
    draft: pipeline.draft,
    createdAt: pipeline.createdAt,
    createdFromVersion: pipeline.createdFromVersion,
    definition: pipeline.columns.filter((c) => c.segment === "definition").map((c) => ({ slug: c.slug, name: c.name, id: c.id })),
    action: pipeline.columns.filter((c) => c.segment === "action").map((c) => ({ slug: c.slug, name: c.name, id: c.id })),
    finish: pipeline.columns.filter((c) => c.segment === "finish").map((c) => ({ slug: c.slug, name: c.name, id: c.id }))
  };
});

export { _name__get as default };
//# sourceMappingURL=_name_.get.mjs.map
