import * as Knex from "knex"; import Resource from "./resource"; import Password from "./attribute-types/password"; import Addon from "./addon"; import User from "./resources/user"; import ApplicationInstance from "./application-instance"; export declare enum HttpStatusCode { OK = 200, Created = 201, BadRequest = 400, Unauthorized = 401, Forbidden = 403, NotFound = 404, UnprocessableEntity = 422, InternalServerError = 500 } export declare const DEFAULT_PRIMARY_KEY = "id"; export declare type OperationDecorator = (operationCallback: Function, ...middlewareArguments: any[]) => (...args: any[]) => any; export declare type AttributeValue = string | number | boolean | string[] | number[] | boolean[] | object | object[]; export declare type ResourceAttributes = { [key: string]: AttributeValue; }; export declare type ResourceRelationships = { [key: string]: ResourceRelationship; }; export declare type ResourceRelationship = { meta?: Meta; links?: Links; data?: ResourceRelationshipData | ResourceRelationshipData[]; }; export declare type ResourceRelationshipData = { type: string; id: string; }; export declare type Meta = { [key: string]: AttributeValue; }; export declare type JsonApiDocument = { data: ResourceT | ResourceT[]; meta?: Meta; operations?: Operation[]; included?: RelatedResourcesT[]; }; export declare type JsonApiErrorsDocument = { errors: IJsonApiError[]; meta?: Meta; }; export interface IJsonApiError { id?: string; status: HttpStatusCode; code: string; title?: string; detail?: string; source?: { pointer?: string; parameter?: string; }; links?: { about?: string; }; } export declare type JsonApiParams = { include?: string[]; sort?: string[]; filter?: { [key: string]: string; }; page?: { [key: string]: number; }; fields?: { [key: string]: string[]; }; }; export declare type Links = { self: string | Link; related?: string | Link; }; export declare type Link = { href: string; meta?: Meta; }; export declare type Operation = { op: string; data?: Resource; included?: Resource[]; ref: { type: string; id?: string | undefined; lid?: string; relationship?: string; }; params?: JsonApiParams; links?: Links; meta?: Meta; }; export declare type OperationResponse = { data: Resource | Resource[] | null; included?: Resource[]; }; export declare type KnexRecord = { id: string; [key: string]: any; }; export declare type AttributeValueMatch = { attribute: string; value: AttributeValue; operator?: "not" | "some" | "every"; }; export declare type ResourceSchema = { primaryKeyName?: string; attributes: ResourceSchemaAttributes; relationships: ResourceSchemaRelationships; }; export declare type PasswordConstructor = typeof Password; export declare type ResourceSchemaAttributes = { [key: string]: StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor | PasswordConstructor; }; export declare type ResourceSchemaRelationships = { [key: string]: ResourceSchemaRelationship; }; export declare type ResourceSchemaRelationship = { type: () => typeof Resource; hasMany?: boolean; belongsTo?: boolean; foreignKeyName?: string; }; export interface HasId { id: any; [key: string]: any; } export declare type EagerLoadedData = { [key: string]: KnexRecord[] | undefined; }; export declare type ApplicationServices = { knex?: Knex; roles?: (this: ApplicationInstance, user: User) => Promise; permissions?: (this: ApplicationInstance, user: User) => Promise; } & { [key: string]: any; }; export interface IJsonApiSerializer { resourceTypeToTableName(resourceType: string): string; attributeToColumn(attributeName: string): string; columnToAttribute(columnName: string): string; relationshipToColumn(relationshipName: string, primaryKeyName?: string): string; columnToRelationship(columnName: string, primaryKeyName?: string): string; foreignResourceToForeignTableName(foreignResourceType: string, prefix?: string): string; deserializeResource(op: Operation, resourceClass: typeof Resource): Operation; serializeResource(resource: Resource, resourceType: typeof Resource): Resource; serializeRelationship(relationships: Resource | Resource[], resourceType: typeof Resource, primaryKeyName?: string): ResourceRelationshipData[]; serializeIncludedResources(data: Resource | Resource[] | void, resourceType: typeof Resource): Resource[] | null; } export interface IAddon { install(): Promise; } export declare type AddonOptions = { [key: string]: any; }; export declare type ApplicationAddons = { addon: typeof Addon; options: AddonOptions; }[];