@avonjs/avonjs
Version:
A fluent Node.js API generator.
73 lines (72 loc) • 2.55 kB
TypeScript
import { type AnyRecord, type AnyValue, type FilledCallback, type Model, type OpenApiSchema, type Optional, type PrimaryKey, type Rules } from '../Contracts';
import type { Filter } from '../Filters';
import type AvonRequest from '../Http/Requests/AvonRequest';
import Relation from './Relation';
export default class BelongsTo extends Relation {
/**
* Indicates trashed items have to be included in the related resource.
*/
withTrashed: boolean;
/**
* Prevent the trashed item from being included in the query.
*/
withoutTrashed(): this;
/**
* Mutate the field value for response.
*/
getMutatedValue(request: AvonRequest, value: AnyValue): AnyValue;
/**
* Hydrate the given attribute on the model based on the incoming request.
*/
fillForAction<TModel extends Model>(request: AvonRequest, model: TModel): AnyValue;
/**
* Hydrate the given attribute on the model based on the incoming request.
*/
protected fillAttributeFromRequest<TModel extends Model>(request: AvonRequest, requestAttribute: string, model: TModel, attribute: string): Optional<FilledCallback>;
/**
* Get related models for given resources.
*/
searchRelatables(request: AvonRequest, resources: Model[]): Promise<Model[]>;
/**
* Format the given related resource.
*/
formatRelatedResource(request: AvonRequest, resource: Model): AnyRecord;
/**
* Indicates related resource soft deletes applied.
*/
protected softDeletes(): boolean;
/**
* Make the field filter.
*/
makeFilter(request: AvonRequest): Filter;
/**
* Determine field is resolvable or not.
*/
resolvable(): boolean;
/**
* Determine if the underlying file should be pruned when the resource is deleted.
*/
isPrunable(): boolean;
/**
* Determine field is orderable or not.
*/
isOrderable(): boolean;
/**
* Define orderable attribute.
*/
orderableAttribute(request: AvonRequest): string;
/**
* Get the validation rules for this field.
*/
getRules(request: AvonRequest): Rules;
protected getRelatedResource(request: AvonRequest, id: PrimaryKey): Promise<Optional<Model>>;
/**
* Get the base swagger-ui schema.
*/
protected baseSchema(request: AvonRequest): OpenApiSchema;
protected payloadSchema(request: AvonRequest): OpenApiSchema;
/**
* Get the swagger-ui schema.
*/
protected responseSchema(request: AvonRequest): OpenApiSchema;
}