ts-japi
Version:
A highly-modular (typescript-friendly)-framework agnostic library for serializing data to the JSON:API specification
52 lines • 1.61 kB
TypeScript
import { ErrorSerializerOptions } from '../interfaces/error-serializer.interface';
import { ErrorDocument } from '../interfaces/json-api.interface';
import { Dictionary, SingleOrArray } from '../types/global.types';
/**
* The {@link ErrorSerializer} class is used to serialize errors.
*
* Example:
* ```typescript
* [[include:error-serializer.example.ts]]
* ```
*/
export default class ErrorSerializer<ErrorType extends Dictionary<any>> {
/**
* Default options. Can be edited to change default options globally.
*/
static defaultOptions: {
version: string;
attributes: {
id: string;
status: string;
code: string;
title: string;
detail: string;
source: {
pointer: string;
parameter: undefined;
header: undefined;
};
};
metaizers: {};
linkers: {};
};
/**
* The set of options for the serializer.
*/
private options;
/**
* Creates a {@link Serializer}.
*
* @param collectionName - The name of the collection of objects.
* @param options - Options for the serializer.
*/
constructor(options?: Partial<ErrorSerializerOptions<ErrorType>>);
/**
* The actual serialization function.
*
* @param errors - Errors to serialize.
* @param options - Options to use at runtime.
*/
serialize(errors: SingleOrArray<ErrorType>, options?: Partial<ErrorSerializerOptions<ErrorType>>): ErrorDocument;
}
//# sourceMappingURL=error-serializer.d.ts.map