import type { ApplicationService } from '@adonisjs/core/types'; import { type Route } from '@adonisjs/core/http'; import { JsonApiRequestContext } from '../src/context.ts'; import { type PreloadScopeMap, type PreloadScopeTree } from '../src/query.ts'; import { type JsonApiResourceControllers, type JsonApiResourceOptions, type JsonApiResourceRoutes } from '../src/routes.ts'; /** Whatever an AdonisJS route's own use() accepts. */ type RouteMiddleware = Parameters[0]; /** * Registers the JSON:API integration: * * - `ctx.jsonApi` request helper (serialization, deserialization, query * building, relationship operations) * - `router.jsonApiResource()` macro for registering conventionally named * resource routes that drive link generation * - resource classes listed in `config/jsonapi.ts` * - the configured `JsonApiRegistry` as a container singleton, so code * outside a request (commands, jobs, tests) can resolve the same registry: * `await app.container.make(JsonApiRegistry)` */ export default class JsonApiProvider { #private; protected app: ApplicationService; constructor(app: ApplicationService); register(): void; boot(): Promise; /** * Resource classes import Lucid models, which must not happen before the * application is fully booted (importing models during provider boot can * capture uninitialized services, e.g. hash in auth mixins). */ ready(): Promise; } declare module '@adonisjs/core/http' { interface HttpContext { jsonApi: JsonApiRequestContext; } } declare module '@adonisjs/core/types' { interface HttpRouterService { jsonApiResource(type: string, controllers: JsonApiResourceControllers, options?: JsonApiResourceOptions): JsonApiResourceRoutes; } } /** * Two augmentations: the contract is what callers hold off jsonApi.query() * and Lucid's chainable methods, so they need the method there; the * concrete class is what Macroable.macro() keys off (name must be a key of * the instance type), so registering the macro needs it there too. */ declare module '@adonisjs/lucid/types/model' { interface ModelQueryBuilderContract> { withPreloadScopes(scopes: PreloadScopeMap): this; } } declare module '@adonisjs/lucid/orm' { interface ModelQueryBuilder { withPreloadScopes(scopes: PreloadScopeTree): this; } } export {};