function generateModelTypes(context) {
  const { model } = context;
  if (!model) {
    throw new Error("Model is required in template context");
  }
  const modelName = model.name;
  let attributes = model.attributes || {};
  if (Array.isArray(attributes)) {
    const obj = {};
    attributes.forEach((attr) => {
      if (attr && typeof attr === "object" && attr.name) {
        obj[attr.name] = attr;
      } else if (Array.isArray(attr) && attr.length >= 2) {
        obj[attr[0]] = attr[1];
      }
    });
    attributes = obj;
  }
  const properties = Object.entries(attributes).map(([name, attr]) => {
    const tsType = mapToTypeScript(attr.type);
    const optional = !attr.constraints?.required ? "?" : "";
    return `  ${name}${optional}: ${tsType};`;
  }).join("\n");
  return `/**
 * ${modelName} Type Definition
 * Auto-generated from SpecVerse model
 */

export interface ${modelName} {
${properties}
}

export type Create${modelName}Input = Omit<${modelName}, 'id' | 'createdAt' | 'updatedAt'>;
export type Update${modelName}Input = Partial<Create${modelName}Input>;
`;
}
function mapToTypeScript(type) {
  const typeMap = {
    "String": "string",
    "Integer": "number",
    "Float": "number",
    "Boolean": "boolean",
    "Date": "string",
    "DateTime": "string",
    "Timestamp": "string",
    "UUID": "string",
    "Email": "string",
    "URL": "string",
    "JSON": "Record<string, any>",
    "Array": "any[]"
  };
  return typeMap[type] || "any";
}
export {
  generateModelTypes as default
};
