import { NotFoundError } from '@takeshape/errors';
import find from 'lodash/find.js';
export function getShapeById(projectSchema, shapeId) {
    return find(projectSchema.shapes, (shape) => shape.id === shapeId);
}
export function getShape(context, name) {
    return context.shapes[name];
}
export function ensureShape(projectSchema, name) {
    const shape = getShape(projectSchema, name);
    if (!shape) {
        throw new NotFoundError(`Shape "${name}" Not found`);
    }
    return shape;
}
export function ensureShapeById(projectSchema, shapeId) {
    const shape = getShapeById(projectSchema, shapeId);
    if (!shape) {
        throw new NotFoundError(`Shape with id "${shapeId}" Not found`);
    }
    return shape;
}
