///
import { IncomingMessage } from 'http';
import { Readable } from 'stream';
import { GraphQLSchema, ExecutionResult, DocumentNode } from 'graphql';
import { InitialisedList } from '../lib/core/types-for-lists';
import type { BaseGeneratedListTypes, GqlNames } from './utils';
export declare type KeystoneContext = {
req?: IncomingMessage;
db: KeystoneDbAPI>;
query: KeystoneListsAPI>;
graphql: KeystoneGraphQLAPI;
sudo: () => KeystoneContext;
exitSudo: () => KeystoneContext;
withSession: (session: any) => KeystoneContext;
prisma: any;
files: FilesContext | undefined;
images: ImagesContext | undefined;
totalResults: number;
maxTotalResults: number;
/** @deprecated */
gqlNames: (listKey: string) => GqlNames;
experimental?: {
/** @deprecated This value is only available if you have config.experimental.contextInitialisedLists = true.
* This is not a stable API and may contain breaking changes in `patch` level releases.
*/
initialisedLists: Record;
};
} & Partial>;
export declare type KeystoneListsAPI> = {
[Key in keyof KeystoneListsTypeInfo]: {
findMany(args?: KeystoneListsTypeInfo[Key]['args']['listQuery'] & ResolveFields): Promise[]>;
findOne(args: {
readonly where: KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'];
} & ResolveFields): Promise>;
count(args?: {
readonly where?: KeystoneListsTypeInfo[Key]['inputs']['where'];
}): Promise;
updateOne(args: {
readonly where: KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'];
readonly data: KeystoneListsTypeInfo[Key]['inputs']['update'];
} & ResolveFields): Promise>;
updateMany(args: {
readonly data: readonly {
readonly where: KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'];
readonly data: KeystoneListsTypeInfo[Key]['inputs']['update'];
}[];
} & ResolveFields): Promise[]>;
createOne(args: {
readonly data: KeystoneListsTypeInfo[Key]['inputs']['create'];
} & ResolveFields): Promise>;
createMany(args: {
readonly data: readonly KeystoneListsTypeInfo[Key]['inputs']['create'][];
} & ResolveFields): Promise[]>;
deleteOne(args: {
readonly where: KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'];
} & ResolveFields): Promise | null>;
deleteMany(args: {
readonly where: readonly KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'][];
} & ResolveFields): Promise[]>;
};
};
declare type ResolveFields = {
/**
* @default 'id'
*/
readonly query?: string;
};
export declare type KeystoneDbAPI> = {
[Key in keyof KeystoneListsTypeInfo]: {
findMany(args?: KeystoneListsTypeInfo[Key]['args']['listQuery']): Promise;
findOne(args: {
readonly where: KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'];
}): Promise;
count(args?: {
readonly where?: KeystoneListsTypeInfo[Key]['inputs']['where'];
}): Promise;
updateOne(args: {
readonly where: KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'];
readonly data: KeystoneListsTypeInfo[Key]['inputs']['update'];
}): Promise;
updateMany(args: {
readonly data: readonly {
readonly where: KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'];
readonly data: KeystoneListsTypeInfo[Key]['inputs']['update'];
}[];
}): Promise;
createOne(args: {
readonly data: KeystoneListsTypeInfo[Key]['inputs']['create'];
}): Promise;
createMany(args: {
readonly data: readonly KeystoneListsTypeInfo[Key]['inputs']['create'][];
}): Promise;
deleteOne(args: {
readonly where: KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'];
}): Promise;
deleteMany(args: {
readonly where: readonly KeystoneListsTypeInfo[Key]['inputs']['uniqueWhere'][];
}): Promise;
};
};
export declare type KeystoneGraphQLAPI> = {
schema: GraphQLSchema;
run: (args: GraphQLExecutionArguments) => Promise>;
raw: (args: GraphQLExecutionArguments) => Promise;
};
declare type GraphQLExecutionArguments = {
query: string | DocumentNode;
variables?: Record;
};
export declare type SessionContext = {
session?: {
itemId: string;
listKey: string;
data?: Record;
} | any;
startSession(data: T): Promise;
endSession(): Promise;
};
export declare type AssetMode = 'local' | 'cloud';
export declare type FileData = {
mode: AssetMode;
filename: string;
filesize: number;
};
export declare type FilesContext = {
getUrl: (mode: AssetMode, filename: string) => Promise;
getDataFromRef: (ref: string) => Promise;
getDataFromStream: (stream: Readable, filename: string) => Promise;
};
export declare type ImageExtension = 'jpg' | 'png' | 'webp' | 'gif';
export declare type ImageMetadata = {
extension: ImageExtension;
filesize: number;
width: number;
height: number;
};
export declare type ImageData = {
mode: AssetMode;
id: string;
} & ImageMetadata;
export declare type ImagesContext = {
getUrl: (mode: AssetMode, id: string, extension: ImageExtension) => Promise;
getDataFromRef: (ref: string) => Promise;
getDataFromStream: (stream: Readable) => Promise;
};
export {};