import { Class } from '@spinajs/di'; import { ModelBase, SortOrder, IModelStatic, IOrmRelation, SelectQueryBuilder, IModelDescriptor } from '@spinajs/orm'; import { BaseController } from '@spinajs/http'; /** * CRUD routes address a row by one `:id` path segment, which cannot carry a composite key. * Returns the single key column, or throws so the caller gets a 400 instead of a query that * silently filters on half the key. */ export declare function _assertSingleColumnKey(descriptor: IModelDescriptor): string; export declare class JsonApiIncomingObject { data: { type: string; id: string; attributes: any; relationships: any; }; constructor(data: any); } export interface ITransformOptions { totalCount?: number; currentPage?: number; order?: SortOrder; orderBy?: string; perPage?: number; model: Class>; } export interface FromModelOptions { /** * Optiona route/param/body field for primary key * If not set , model primary key is used */ field?: string; /** * From where to get primary key value * Eg. body, query, param, header etc. * * If not set, param is used */ paramType?: string; /** * Sometimes we want to skip include relations eg. when we dont want to * load relations when getting another model in route * * It affect include & _include fields in incoming request */ noInclude?: boolean; /** * Optional list of relations to include always when loading model */ include?: string[]; /** * * Callback on query builder before model is fetched from DB * * It allows to modify query with data passed to route. * If not set it check for include, model owner ( if has @BelongsTo field marked) etc. * * @param this * @param routeParams passed route params to query * @returns */ query?: (this: SelectQueryBuilder, routeParams: any) => SelectQueryBuilder; } export interface IQueryFilterEntry { val: string; op?: string; } /** * Data collection transformer. Used to transform collection of models to specific api format eg. json api * By default transforms to simple json representation */ export declare abstract class CollectionApiTransformer { abstract transform(data: ModelBase[] | ModelBase, options?: ITransformOptions): unknown; } /** * Base class for crud operations. Provides helper functions */ export declare abstract class Crud extends BaseController { protected prepareQuery(model: IModelStatic, relation: string, id: any, callback: (this: SelectQueryBuilder>, relation: IOrmRelation) => void): { relation: any; relationModel: any; query: import("@spinajs/orm").ISelectQueryBuilder[]>; }; } //# sourceMappingURL=interfaces.d.ts.map