/**
 * Typed x402 route registry — the single source of truth for:
 *  - middleware configuration
 *  - .well-known/x402.json
 *  - OpenAPI
 *  - playground
 *  - SDK types
 *  - documentation
 *  - endpoint counts
 *  - automated tests
 *
 * Every generator below reads this file. Nothing else may hand-write x402 rules.
 */

export type ProtocolVersion = "v2" | "v3";
export type ContractStatus =
  | "active"
  | "legacy"
  | "deprecated"
  | "paused"
  | "read-only";

export type PrivacyClass = "public" | "priced-read" | "priced-write" | "restricted";

export type Finality = "soft" | "safe" | "finalized";

export interface RouteRegistryEntry {
  id: string;                 // stable, kebab-case, unique across all routes
  method: "GET" | "POST" | "PUT" | "DELETE";
  path: string;               // absolute path served at theloopbreaker.com
  free: boolean;              // if true, price fields are absent
  price?: {
    amount: string;           // atomic units, decimal string (never number)
    asset: string;            // token address ("native" for chain asset)
    network: string;          // CAIP-2, for example "eip155:8453"
    payee: string;
    scheme: "exact";
    x402Version: 2;
  };
  version: ProtocolVersion;
  contractStatus: ContractStatus;
  requestSchema: string;      // JSONSchema $id
  responseSchema: string;     // JSONSchema $id
  responseStatus?: string;     // primary HTTP status for this route
  responseContracts?: string;  // deterministic status=url pairs used by the generator
  idempotencyRule: "none" | "key-required" | "key-optional";
  finality: Finality;
  dataSource: "onchain" | "indexer" | "computed" | "external";
  privacy: PrivacyClass;
  deprecatedAt?: string;      // ISO
  sunsetAt?: string;          // ISO
  description: string;
}

export type Registry = {
  version: string;            // registry semver
  generatedAt: string;
  routes: RouteRegistryEntry[];
};
