/**
 * Project naming conventions — auto-generated by Prism.
 *
 * Provides constants and helpers so that all generated (and hand-written)
 * code refers to endpoints, classes, and variables using the same naming
 * rules defined in the project's NamingConfig.
 *
 * Do not edit manually — changes will be overwritten on next generation.
 */

// ---------------------------------------------------------------------------
// Per-model naming look-ups
// ---------------------------------------------------------------------------

export interface ModelNaming {
  tableName: string;
  endpointSegment: string;
  endpointFull: string;
  modelClass: string;
  schemaClass: string;
  serviceClass: string;
  backendVar: string;
  frontendVar: string;
  constantVar: string;
}

export const MODEL_NAMES: Record<string, ModelNaming> = {
{% for entry in entries %}
  {{ entry.model_name }}: {
    tableName: "{{ entry.table_name }}",
    endpointSegment: "{{ entry.endpoint_segment }}",
    endpointFull: "{{ entry.endpoint_full }}",
    modelClass: "{{ entry.model_class }}",
    schemaClass: "{{ entry.schema_class }}",
    serviceClass: "{{ entry.service_class }}",
    backendVar: "{{ entry.backend_var }}",
    frontendVar: "{{ entry.frontend_var }}",
    constantVar: "{{ entry.constant_var }}",
  },
{% endfor %}
};

// ---------------------------------------------------------------------------
// Configuration
// ---------------------------------------------------------------------------

export const ENDPOINT_PREFIX = "{{ config.endpoint_prefix }}";

{% if config.abbreviations %}
export const ABBREVIATIONS: Record<string, string> = {
{% for full, abbrev in config.abbreviations.items() %}
  "{{ full }}": "{{ abbrev }}",
{% endfor %}
};
{% else %}
export const ABBREVIATIONS: Record<string, string> = {};
{% endif %}

// ---------------------------------------------------------------------------
// Public helpers
// ---------------------------------------------------------------------------

export function getEndpointPath(modelName: string): string {
  const entry = MODEL_NAMES[modelName];
  if (!entry) {
    throw new Error(`Unknown model: ${modelName}`);
  }
  return entry.endpointFull;
}

export function getClassName(modelName: string, kind: "model" | "schema" | "service" = "model"): string {
  const entry = MODEL_NAMES[modelName];
  if (!entry) {
    throw new Error(`Unknown model: ${modelName}`);
  }
  const key = `${kind}Class` as keyof ModelNaming;
  return entry[key];
}

export function getVariableName(modelName: string, target: "backend" | "frontend" | "constant" = "frontend"): string {
  const entry = MODEL_NAMES[modelName];
  if (!entry) {
    throw new Error(`Unknown model: ${modelName}`);
  }
  const key = `${target}Var` as keyof ModelNaming;
  return entry[key];
}
