import type { LucidModel, LucidRow } from '@adonisjs/lucid/types/model'; import { JsonApiResource } from './resource.ts'; export type JsonApiResourceClass = Pick & { /** * `never` parameters keep subclass constructors (which narrow the row and * ctx types, e.g. `Article` + `HttpContext`) assignable under strict * contravariance; instantiation goes through instantiateResource() below. */ new (resource: never, ctx?: never): JsonApiResource; }; /** * Instantiates a resource definition for a row. The construct signature on * JsonApiResourceClass uses a `never` parameter for variance reasons; this * is the one sanctioned bridge past it. */ export declare function instantiateResource(ResourceClass: JsonApiResourceClass, row: LucidRow, ctx?: unknown): JsonApiResource; /** * Maps Lucid models to their JSON:API resource classes. Models without an * explicit resource get an auto-derived one (camelCased table name as type, * all serializable columns as attributes, all relations exposed). */ export declare class JsonApiRegistry { #private; register(resources: JsonApiResourceClass[]): this; /** * The JSON:API type string for a model class. Defaults to the kebab-cased * table name (auth_access_tokens → auth-access-tokens); hyphens are legal * in type values per the spec's member-name character rules. */ typeFor(Model: LucidModel): string; /** * The resource class for a model class, auto-derived when not registered. */ resourceFor(Model: LucidModel): JsonApiResourceClass; /** * The resource class for a row, resolving through resolveResource when * the row's resource declares one (single-table inheritance). Hooks can * chain; a repeated class ends the walk so a cycle cannot loop. */ resourceForRow(row: LucidRow): JsonApiResourceClass; /** * The JSON:API type string for a row. Differs from typeFor(Model) only * when the row's resource resolves to a concrete subtype resource. */ typeForRow(row: LucidRow): string; /** * The types a relation targeting this model accepts on writes. A model * whose resource declares subtypes accepts every member of the family * and nothing else. The base's own abstract type never appears in * payloads. Every other model accepts its single type, as before. */ acceptedTypesFor(Model: LucidModel): string[]; }