|
|
|
|
@@ -72,11 +72,11 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
|
[slug: string | number | symbol]: Collection;
|
|
|
|
|
} = {}
|
|
|
|
|
} = {};
|
|
|
|
|
|
|
|
|
|
versions: {
|
|
|
|
|
[slug: string]: CollectionModel;
|
|
|
|
|
} = {}
|
|
|
|
|
} = {};
|
|
|
|
|
|
|
|
|
|
preferences: Preferences;
|
|
|
|
|
|
|
|
|
|
@@ -96,7 +96,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
|
|
|
|
|
mongoOptions: InitOptions['mongoOptions'];
|
|
|
|
|
|
|
|
|
|
mongoMemoryServer: any
|
|
|
|
|
mongoMemoryServer: any;
|
|
|
|
|
|
|
|
|
|
local: boolean;
|
|
|
|
|
|
|
|
|
|
@@ -108,9 +108,9 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
|
|
|
|
|
authenticate: PayloadAuthenticate;
|
|
|
|
|
|
|
|
|
|
express?: Express
|
|
|
|
|
express?: Express;
|
|
|
|
|
|
|
|
|
|
router?: Router
|
|
|
|
|
router?: Router;
|
|
|
|
|
|
|
|
|
|
types: {
|
|
|
|
|
blockTypes: any;
|
|
|
|
|
@@ -228,7 +228,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<TGeneratedTypes['collections'][T]> => {
|
|
|
|
|
const { create } = localOperations;
|
|
|
|
|
return create<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Find documents with criteria
|
|
|
|
|
@@ -240,7 +240,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<PaginatedDocs<TGeneratedTypes['collections'][T]>> => {
|
|
|
|
|
const { find } = localOperations;
|
|
|
|
|
return find<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Find document by ID
|
|
|
|
|
@@ -253,7 +253,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<TGeneratedTypes['collections'][T]> => {
|
|
|
|
|
const { findByID } = localOperations;
|
|
|
|
|
return findByID<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Update one or more documents
|
|
|
|
|
@@ -293,7 +293,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<PaginatedDocs<TypeWithVersion<TGeneratedTypes['collections'][T]>>> => {
|
|
|
|
|
const { findVersions } = localOperations;
|
|
|
|
|
return findVersions<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Find version by ID
|
|
|
|
|
@@ -305,7 +305,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<TypeWithVersion<TGeneratedTypes['collections'][T]>> => {
|
|
|
|
|
const { findVersionByID } = localOperations;
|
|
|
|
|
return findVersionByID<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Restore version by ID
|
|
|
|
|
@@ -317,56 +317,56 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<TGeneratedTypes['collections'][T]> => {
|
|
|
|
|
const { restoreVersion } = localOperations;
|
|
|
|
|
return restoreVersion<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
login = async <T extends keyof TGeneratedTypes['collections']>(
|
|
|
|
|
options: LoginOptions<T>,
|
|
|
|
|
): Promise<LoginResult & { user: TGeneratedTypes['collections'][T] }> => {
|
|
|
|
|
const { login } = localOperations.auth;
|
|
|
|
|
return login<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
forgotPassword = async <T extends keyof TGeneratedTypes['collections']>(
|
|
|
|
|
options: ForgotPasswordOptions<T>,
|
|
|
|
|
): Promise<ForgotPasswordResult> => {
|
|
|
|
|
const { forgotPassword } = localOperations.auth;
|
|
|
|
|
return forgotPassword<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
resetPassword = async <T extends keyof TGeneratedTypes['collections']>(
|
|
|
|
|
options: ResetPasswordOptions<T>,
|
|
|
|
|
): Promise<ResetPasswordResult> => {
|
|
|
|
|
const { resetPassword } = localOperations.auth;
|
|
|
|
|
return resetPassword<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
unlock = async <T extends keyof TGeneratedTypes['collections']>(
|
|
|
|
|
options: UnlockOptions<T>,
|
|
|
|
|
): Promise<boolean> => {
|
|
|
|
|
const { unlock } = localOperations.auth;
|
|
|
|
|
return unlock(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
verifyEmail = async <T extends keyof TGeneratedTypes['collections']>(
|
|
|
|
|
options: VerifyEmailOptions<T>,
|
|
|
|
|
): Promise<boolean> => {
|
|
|
|
|
const { verifyEmail } = localOperations.auth;
|
|
|
|
|
return verifyEmail(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
findGlobal = async <T extends keyof TGeneratedTypes['globals']>(
|
|
|
|
|
options: FindGlobalOptions<T>,
|
|
|
|
|
): Promise<TGeneratedTypes['globals'][T]> => {
|
|
|
|
|
const { findOne } = localGlobalOperations;
|
|
|
|
|
return findOne<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateGlobal = async <T extends keyof TGeneratedTypes['globals']>(
|
|
|
|
|
options: UpdateGlobalOptions<T>,
|
|
|
|
|
): Promise<TGeneratedTypes['globals'][T]> => {
|
|
|
|
|
const { update } = localGlobalOperations;
|
|
|
|
|
return update<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Find global versions with criteria
|
|
|
|
|
@@ -378,7 +378,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<PaginatedDocs<TypeWithVersion<TGeneratedTypes['globals'][T]>>> => {
|
|
|
|
|
const { findVersions } = localGlobalOperations;
|
|
|
|
|
return findVersions<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Find global version by ID
|
|
|
|
|
@@ -390,7 +390,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<TypeWithVersion<TGeneratedTypes['globals'][T]>> => {
|
|
|
|
|
const { findVersionByID } = localGlobalOperations;
|
|
|
|
|
return findVersionByID<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Restore global version by ID
|
|
|
|
|
@@ -402,7 +402,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
|
|
): Promise<TGeneratedTypes['globals'][T]> => {
|
|
|
|
|
const { restoreVersion } = localGlobalOperations;
|
|
|
|
|
return restoreVersion<T>(this, options);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type Payload = BasePayload<GeneratedTypes>
|
|
|
|
|
|