import JSONParser from './json'; import { ResponderParams } from '../runtime/action'; import Request from '../runtime/request'; import { ResourceObject as JSONAPIResourceObject, AttributesObject as JSONAPIAttributesObject, RelationshipsObject as JSONAPIRelationshipsObject } from 'jsonapi-typescript'; /** * Parses incoming request bodies according to the JSON-API specification. For * incoming payloads with `included` arrays, the primary `data` is returned * under the `body` key, and `included` is moved to it's own property. * * @package parse * @since 0.1.0 */ export default class JSONAPIParser extends JSONParser { /** * The media type for JSON-API requests. If the incoming request doesn't have * this Content Type, the parser will immediately render a 400 Bad Request response */ type: string; parse(request: Request): Promise; /** * Parse a single resource object from a JSONAPI document. The resource * object could come from the top level `data` payload, or from the * sideloaded `included` records. * * @since 0.1.0 */ protected parseResource(resource: JSONAPIResourceObject): any; /** * Parse a resource object id * * @since 0.1.0 */ protected parseId(id: string): any; /** * Parse a resource object's type string * * @since 0.1.0 */ protected parseType(type: string): string; /** * Parse a resource object's attributes. By default, this converts from the * JSONAPI recommended dasheried keys to camelCase. * * @since 0.1.0 */ protected parseAttributes(attrs: JSONAPIAttributesObject): any; /** * Parse a resource object's relationships. By default, this converts from * the JSONAPI recommended dasheried keys to camelCase. * * @since 0.1.0 */ protected parseRelationships(relationships: JSONAPIRelationshipsObject): any; }