import { IResolverObject } from 'graphql-tools'; export interface Pagination { last?: number; first?: number; before?: string; after?: string; perPage?: number; page?: number; } declare type PromiseOrScalar = T | (() => Promise); export interface PaginatedResponse { data: any[]; total: PromiseOrScalar; hasNextPage: PromiseOrScalar; hasPreviousPage: PromiseOrScalar; } export declare enum Operator { eq = "eq", neq = "neq", gt = "gt", gte = "gte", lt = "lt", lte = "lte", regex = "regex", near = "near", json = "json", jsonor = "jsonor", or = "or", jsonrgxp = "jsonrgxp" } export declare type Where = Record>; export interface OrderBy { field: string; value: 1 | -1; } export interface ListFindQuery { pagination?: Pagination; where?: Where; orderBy?: OrderBy; } export interface ListReadable { find(query?: ListFindQuery, context?: any): Promise; findOne({ where }: { where: Where; }, context?: any): Promise; findOneById(id: string, context?: any): Promise; } export declare enum ArrayOperator { set = "set", add = "add", remove = "remove" } export interface ArrayOperation { fieldName: string; value: any; operator: ArrayOperator; } export interface Mutation { getData(): Record; addField(name: string, value: any): void; getArrayOperations(): ArrayOperation[]; } export interface ListMutable { create(mutation: Mutation, context?: any): Promise; update(where: Where, mutation: Mutation, context?: any): Promise; delete(where: Where, context?: any): Promise; } export interface MapReadable { getMap?(): Promise>; } export interface MapMutable { updateMap?(mutation: Mutation): Promise; } export interface ToOneRelation { findOneByRelation(foreignKey: string, foreignId: string, context: any): Promise; updateOneRelation(id: string, foreignKey: string, foreignId: string, context: any): Promise; } export interface EmbeddableRelation { addEmbedIds?(foreignKey: string, ids: string[], context: any): any; removeEmbedIds?(foreignKey: string, ids: string[], context: any): any; findOneByEmbedId?(foreignKey: string, foreignId: string, context: any): Promise; findManyByEmbedId?(foreignKey: string, foreignId: string, context: any): Promise; } export interface OneToManyRelation { findManyFromOneRelation(foreignKey: string, foreignId: string, context: any): Promise; } export interface ManyToManyRelation { findManyFromManyRelation(sourceSideName: string, targetSideName: string, sourceSideId: string, context: any): Promise; addIdToManyRelation(sourceSideName: string, targetSideName: string, sourceSideId: string, targetSideId: string, context: any): Promise; removeIdFromManyRelation(sourceSideName: string, targetSideName: string, sourceSideId: string, targetSideId: string, context: any): Promise; } export interface FieldResolvable { resolveFields?(): IResolverObject; } export declare type DataSource = ListReadable & ListMutable & MapReadable & MapMutable & ToOneRelation & OneToManyRelation & ManyToManyRelation & EmbeddableRelation & FieldResolvable; export {};