///
import { DeepRequired } from 'ts-essentials';
import { PaginateModel } from 'mongoose';
import { GraphQLInputObjectType, GraphQLNonNull, GraphQLObjectType } from 'graphql';
import { Response } from 'express';
import { Access, GeneratePreviewURL, EntityDescription, Endpoint } from '../../config/types';
import { Field } from '../../fields/config/types';
import { PayloadRequest } from '../../express/types';
import { IncomingAuthType, Auth } from '../../auth/types';
import { IncomingUploadType, Upload } from '../../uploads/types';
import { IncomingCollectionVersions, SanitizedCollectionVersions } from '../../versions/types';
declare type Register = (doc: T, password: string) => T;
interface PassportLocalModel {
register: Register;
authenticate: any;
}
export interface CollectionModel extends PaginateModel, PassportLocalModel {
buildQuery: (query: unknown, locale?: string) => Record;
}
export interface AuthCollectionModel extends CollectionModel {
resetPasswordToken: string;
resetPasswordExpiration: Date;
}
export declare type HookOperationType = 'create' | 'autosave' | 'read' | 'update' | 'delete' | 'refresh' | 'login' | 'forgotPassword';
declare type CreateOrUpdateOperation = Extract;
export declare type BeforeOperationHook = (args: {
args?: any;
/**
* Hook operation being performed
*/
operation: HookOperationType;
}) => any;
export declare type BeforeValidateHook = (args: {
data?: Partial;
req?: PayloadRequest;
/**
* Hook operation being performed
*/
operation: CreateOrUpdateOperation;
/**
* Original document before change
*
* `undefined` on 'create' operation
*/
originalDoc?: T;
}) => any;
export declare type BeforeChangeHook = (args: {
data: Partial;
req: PayloadRequest;
/**
* Hook operation being performed
*/
operation: CreateOrUpdateOperation;
/**
* Original document before change
*
* `undefined` on 'create' operation
*/
originalDoc?: T;
}) => any;
export declare type AfterChangeHook = (args: {
doc: T;
req: PayloadRequest;
/**
* Hook operation being performed
*/
operation: CreateOrUpdateOperation;
}) => any;
export declare type BeforeReadHook = (args: {
doc: T;
req: PayloadRequest;
query: {
[key: string]: any;
};
}) => any;
export declare type AfterReadHook = (args: {
doc: T;
req: PayloadRequest;
query?: {
[key: string]: any;
};
findMany?: boolean;
}) => any;
export declare type BeforeDeleteHook = (args: {
req: PayloadRequest;
id: string;
}) => any;
export declare type AfterDeleteHook = (args: {
doc: T;
req: PayloadRequest;
id: string;
}) => any;
export declare type AfterErrorHook = (err: Error, res: unknown) => {
response: any;
status: number;
} | void;
export declare type BeforeLoginHook = (args: {
req: PayloadRequest;
}) => any;
export declare type AfterLoginHook = (args: {
req: PayloadRequest;
doc: T;
token: string;
}) => any;
export declare type AfterLogoutHook = (args: {
req: PayloadRequest;
res: Response;
}) => any;
export declare type AfterMeHook = (args: {
req: PayloadRequest;
response: unknown;
}) => any;
export declare type AfterRefreshHook = (args: {
req: PayloadRequest;
res: Response;
token: string;
exp: number;
}) => any;
export declare type AfterForgotPasswordHook = (args: {
args?: any;
}) => any;
export declare type CollectionAdminOptions = {
/**
* Field to use as title in Edit view and first column in List view
*/
useAsTitle?: string;
/**
* Default columns to show in list view
*/
defaultColumns?: string[];
/**
* Custom description for collection
*/
description?: EntityDescription;
disableDuplicate?: boolean;
/**
* Hide the API URL within the Edit view
*/
hideAPIURL?: boolean;
/**
* Custom admin components
*/
components?: {
views?: {
Edit?: React.ComponentType;
List?: React.ComponentType;
};
};
pagination?: {
defaultLimit?: number;
limits?: number[];
};
enableRichTextRelationship?: boolean;
/**
* Function to generate custom preview URL
*/
preview?: GeneratePreviewURL;
};
export declare type CollectionConfig = {
slug: string;
/**
* Label configuration
*/
labels?: {
singular?: string;
plural?: string;
};
fields: Field[];
/**
* Collection admin options
*/
admin?: CollectionAdminOptions;
/**
* Hooks to modify Payload functionality
*/
hooks?: {
beforeOperation?: BeforeOperationHook[];
beforeValidate?: BeforeValidateHook[];
beforeChange?: BeforeChangeHook[];
afterChange?: AfterChangeHook[];
beforeRead?: BeforeReadHook[];
afterRead?: AfterReadHook[];
beforeDelete?: BeforeDeleteHook[];
afterDelete?: AfterDeleteHook[];
afterError?: AfterErrorHook;
beforeLogin?: BeforeLoginHook[];
afterLogin?: AfterLoginHook[];
afterLogout?: AfterLogoutHook[];
afterMe?: AfterMeHook[];
afterRefresh?: AfterRefreshHook[];
afterForgotPassword?: AfterForgotPasswordHook[];
};
/**
* Custom rest api endpoints
*/
endpoints?: Endpoint[];
/**
* Access control
*/
access?: {
create?: Access;
read?: Access;
readVersions?: Access;
update?: Access;
delete?: Access;
admin?: (args?: any) => boolean;
unlock?: Access;
};
/**
* Collection login options
*
* Use `true` to enable with default options
*/
auth?: IncomingAuthType | boolean;
/**
* Upload options
*/
upload?: IncomingUploadType | boolean;
versions?: IncomingCollectionVersions | boolean;
timestamps?: boolean;
};
export interface SanitizedCollectionConfig extends Omit, 'auth' | 'upload' | 'fields' | 'versions'> {
auth: Auth;
upload: Upload;
fields: Field[];
versions: SanitizedCollectionVersions;
}
export declare type Collection = {
Model: CollectionModel;
config: SanitizedCollectionConfig;
graphQL?: {
type: GraphQLObjectType;
JWT: GraphQLObjectType;
versionType: GraphQLObjectType;
whereInputType: GraphQLInputObjectType;
mutationInputType: GraphQLNonNull;
updateMutationInputType: GraphQLNonNull;
};
};
export declare type AuthCollection = {
Model: AuthCollectionModel;
config: SanitizedCollectionConfig;
};
export declare type TypeWithID = {
id: string | number;
};
export declare type TypeWithTimestamps = {
id: string | number;
createdAt: string;
updatedAt: string;
};
export {};