import { E_UNRESOLVABLE_MODEL } from "../../../errors"; import type { HttpContext } from '@adonisjs/core/http'; import type { AnySchema } from "../../../joi"; import type { ApplicationService } from '@adonisjs/core/types'; import type { ResourcefulRouterModelServiceOptionsService } from "../../router_macro/services/resourceful_router_model_options_service"; import type { ResourcefulModel, ResourcefulIndexResponse, ResourceResourcefulRecordResponse, ResourcefulQueryScopeCallback, ResourcefulPayloadSchemaGetter, ResourcefulPolicy, ResourcefulRouterMutatorOptions } from "../../../types"; type ODataMetadata = { context: string; } & Partial<{ count: number; nextLink: string; deltaLink: string; id: string | number | bigint; etag: string; readLink: string; editLink: string; navigationLink: string; type: string; mediaReadLink: string; mediaEditLink: string; mediaContentType: string; mediaEtag: string; }>; /** * Shapes `respond()` can be asked to serialize. Entity bodies are plain * dictionaries (after `toJSON()`); collections are arrays of those. Primitive * bodies cover `$count` and other raw text responses; `undefined` covers * 204/304 and minimal-preference updates. */ type RespondEntityBody = Record; type RespondBody = undefined | number | RespondEntityBody | RespondEntityBody[]; /** * Arguments for `respond()`. * * @property status HTTP status code of the response. * @property body Payload to serialize — a single entity, a collection of * entities, a primitive (e.g. `$count`), or `undefined` for empty bodies * (204/304, minimal-preference updates). * @property metadata OData `@odata.*` annotations for the response envelope * (context, count, nextLink, id, etag, etc.). * @property model Optional. The resourceful model describing the entity * shape of `body`. Drives the IEEE754 coercion pass — Edm.Int64 / * Edm.Decimal detection and `$expand` recursion into related models. Omit * when `body` isn't entity-shaped — 204/304 responses, error envelopes, * raw `$count` numbers — since there's nothing for the coercion pass to * walk. * @property isArray Optional. Marks `body` as a collection so it's serialized * into an OData feed (`value: [...]` / ``) instead of a single * entry. Omit when there's no body (204/304) or the body is a primitive — * there's no ambiguity in those cases. Defaults to `Array.isArray(body)`. * @property headers Optional. Request-level response headers to merge on * top of macro-level and controller-level defaults. * @property raw Optional. When `true`, serializes `String(body)` as * `text/plain` and skips OData envelope construction — used for `$count` * endpoints that must return a bare number per the spec. */ interface RespondOptions { status: number; body: RespondBody; metadata: ODataMetadata; model?: ResourcefulModel; isArray?: boolean; headers?: { [key: string]: string; }; raw?: boolean; } export type ResourcefulModelControllerHooks = { index: [ [ ResourcefulIndexResponse, HttpContext ], [ error: Error | null, ResourcefulIndexResponse, HttpContext ] ]; create: [ [ ResourceResourcefulRecordResponse, HttpContext ], [ error: Error | null, ResourceResourcefulRecordResponse, HttpContext ] ]; read: [ [ ResourceResourcefulRecordResponse, HttpContext ], [ error: Error | null, ResourceResourcefulRecordResponse, HttpContext ] ]; readRelated: [ [ ResourcefulIndexResponse, HttpContext ], [ error: Error | null, ResourcefulIndexResponse, HttpContext ] ]; update: [ [ ResourceResourcefulRecordResponse, HttpContext ], [ error: Error | null, ResourceResourcefulRecordResponse, HttpContext ] ]; }; export type ODataEntityUidAndRelationshipInformation = { uid: string | undefined; relationship: string | undefined; isCountRequest: boolean; }; export declare class ResourcefulModelController { #private; get options(): ResourcefulRouterModelServiceOptionsService; constructor(subpath: string, model: Promise, options: ResourcefulRouterModelServiceOptionsService, headers: { [key: string]: string; }, groupResourcefulQueryScopeCallbacks?: ResourcefulQueryScopeCallback[], groupResourcefulPayloadSchemaGetters?: ResourcefulPayloadSchemaGetter[], groupResourcefulRouterMutatorOptions?: ResourcefulRouterMutatorOptions, groupResourcefulPolicies?: ResourcefulPolicy[]); static getResourcefulModelCreatePayloadValidationSchema(model: ResourcefulModel, ctx: HttpContext, app: ApplicationService): Promise>; getODataContextUrl(fragment: string): Promise; resolveFullUrl(relative: string, ...more: string[]): Promise; resolveBaseRequirements(): Promise<{ model: E_UNRESOLVABLE_MODEL | ResourcefulModel; app: ApplicationService; }>; resolveUrlResource(ctx: HttpContext): string; resolveRequestRequirements(ctx: HttpContext): Promise<{ model: ResourcefulModel; app: ApplicationService; prefix: string; serveAs: "json" | "xml"; method: string; url: string; resource: string; query: Record; selections: string[] | undefined; isFullSet: boolean; metadataLevel: "full" | "minimal" | "none"; preference: "minimal" | "representation"; respond: (options: RespondOptions) => void; }>; serveModelRead(ctx: HttpContext): Promise; serveModelUpdate(ctx: HttpContext): Promise; serveModelDelete(ctx: HttpContext): Promise; serveModelCreate(ctx: HttpContext): Promise; serveModelReadRelated(ctx: HttpContext): Promise; serveModelSyncRelated(ctx: HttpContext): Promise; serveModelFunction(ctx: HttpContext): Promise; serveModelAction(ctx: HttpContext): Promise; serveModelInstanceFunction(ctx: HttpContext): Promise; serveModelInstanceAction(ctx: HttpContext): Promise; serveModelIndex(ctx: HttpContext): Promise; } export {};