UNPKG

@avonjs/avonjs

Version:

A fluent Node.js API generator.

57 lines (56 loc) 1.9 kB
import { type ArraySchema } from 'joi'; import FieldCollection from '../Collections/FieldCollection'; import type { AnyValue, FilledCallback, Model, OpenApiSchema, Optional, ResolveCallback, Rules } from '../Contracts'; import type AvonRequest from '../Http/Requests/AvonRequest'; import Field from './Field'; export default class List extends Field { /** * The validation rules callback for creation and updates. */ protected rulesSchema: ArraySchema; /** * The validation rules callback for creation. */ protected creationRulesSchema: ArraySchema; /** * The validation rules callback for updates. */ protected updateRulesSchema: ArraySchema; /** * The object possible keys. */ protected fields: FieldCollection; constructor(attribute: string, fields?: Field[], resolveCallback?: ResolveCallback); /** * Get the creation rules for this field. */ getCreationRules(request: AvonRequest): Rules; /** * Get the update rules for this field. */ getUpdateRules(request: AvonRequest): Rules; /** * 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>; /** * Mutate the field value for response. */ getMutatedValue(request: AvonRequest, value: AnyValue): any; /** * Determine field is filterable or not. */ isFilterable(): boolean; /** * Determine field is orderable or not. */ isOrderable(): boolean; /** * Get the swagger-ui schema. */ protected responseSchema(request: AvonRequest): OpenApiSchema; /** * Get the swagger-ui schema. */ protected payloadSchema(request: AvonRequest): OpenApiSchema; }