Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final
This commit is contained in:
@@ -14,7 +14,7 @@ const accessPromise = async ({
|
||||
currentDepth,
|
||||
hook,
|
||||
payload,
|
||||
}: OperationArguments) => {
|
||||
}: OperationArguments): Promise<void> => {
|
||||
const resultingData = data;
|
||||
|
||||
let accessOperation;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import crypto from 'crypto';
|
||||
import { Field, FieldHook } from '../config/types';
|
||||
|
||||
const encryptKey: FieldHook = ({ req, value }) => (value ? req.payload.encrypt(value) : undefined);
|
||||
const decryptKey: FieldHook = ({ req, value }) => (value ? req.payload.decrypt(value) : undefined);
|
||||
const encryptKey: FieldHook = ({ req, value }) => (value ? req.payload.encrypt(value as string) : undefined);
|
||||
const decryptKey: FieldHook = ({ req, value }) => (value ? req.payload.decrypt(value as string) : undefined);
|
||||
|
||||
export default [
|
||||
{
|
||||
@@ -40,7 +40,7 @@ export default [
|
||||
async ({ data, req, value }) => {
|
||||
if (data.apiKey) {
|
||||
return crypto.createHmac('sha1', req.payload.secret)
|
||||
.update(data.apiKey)
|
||||
.update(data.apiKey as string)
|
||||
.digest('hex');
|
||||
}
|
||||
if (data.enableAPIKey === false) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ImageSize } from '../../collections/config/types';
|
||||
import { ImageSize } from '../../uploads/types';
|
||||
import { Field } from '../config/types';
|
||||
|
||||
export default (imageSizes: ImageSize[]): Field[] => [
|
||||
|
||||
@@ -8,7 +8,7 @@ const hookPromise = async ({
|
||||
operation,
|
||||
fullOriginalDoc,
|
||||
fullData,
|
||||
}: OperationArguments) => {
|
||||
}: OperationArguments): Promise<void> => {
|
||||
const resultingData = data;
|
||||
|
||||
if ((field.type === 'relationship' || field.type === 'upload') && (data[field.name] === 'null' || data[field.name] === null)) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import traverseFields from './traverseFields';
|
||||
import { Collection } from '../collections/config/types';
|
||||
import { OperationArguments } from '../types';
|
||||
|
||||
export default async function performFieldOperations(entityConfig: Collection, args: OperationArguments): any {
|
||||
export default async function performFieldOperations(entityConfig: Collection, args: OperationArguments): Promise<{ [key: string]: unknown }> {
|
||||
const {
|
||||
data: fullData,
|
||||
originalDoc: fullOriginalDoc,
|
||||
@@ -49,7 +49,7 @@ export default async function performFieldOperations(entityConfig: Collection, a
|
||||
// //////////////////////////////////////////
|
||||
|
||||
traverseFields({
|
||||
fields: entityConfig.fields,
|
||||
fields: entityConfig.fields, // TODO: Bad typing, this exists
|
||||
data: fullData,
|
||||
originalDoc: fullOriginalDoc,
|
||||
path: '',
|
||||
|
||||
@@ -17,7 +17,7 @@ const populate = async ({
|
||||
const dataToUpdate = dataReference;
|
||||
|
||||
const fieldAsRelationship = field as RelationshipField;
|
||||
const relation = Array.isArray(fieldAsRelationship.relationTo) ? data.relationTo : fieldAsRelationship.relationTo;
|
||||
const relation = Array.isArray(fieldAsRelationship.relationTo) ? (data.relationTo as string) : fieldAsRelationship.relationTo;
|
||||
const relatedCollection = payload.collections[relation];
|
||||
|
||||
if (relatedCollection) {
|
||||
@@ -69,7 +69,7 @@ const relationshipPopulationPromise = ({
|
||||
req,
|
||||
overrideAccess,
|
||||
payload,
|
||||
}) => async () => {
|
||||
}) => async (): Promise<void> => {
|
||||
const resultingData = data;
|
||||
|
||||
if (field.hasMany && Array.isArray(data[field.name])) {
|
||||
|
||||
@@ -7,7 +7,7 @@ const validationPromise = async ({
|
||||
existingData,
|
||||
field,
|
||||
path,
|
||||
}: OperationArguments) => {
|
||||
}: OperationArguments): Promise<string | boolean> => {
|
||||
if (hook !== 'beforeChange') return true;
|
||||
|
||||
const hasCondition = field.admin && field.admin.condition;
|
||||
|
||||
@@ -59,11 +59,11 @@ export const number: Validator = (value: string, options: NumberOptions = {}) =>
|
||||
|
||||
export const text: Validator = (value, options: FieldOptions = {}) => {
|
||||
if (options.maxLength && (value && value.length > options.maxLength)) {
|
||||
return `This value must be shorter than the max length of ${options.max} characters.`;
|
||||
return `This value must be shorter than the max length of ${options.maxLength} characters.`;
|
||||
}
|
||||
|
||||
if (options.minLength && (value && value.length < options.minLength)) {
|
||||
return `This value must be longer than the minimum length of ${options.max} characters.`;
|
||||
return `This value must be longer than the minimum length of ${options.maxLength} characters.`;
|
||||
}
|
||||
|
||||
if (options.required) {
|
||||
|
||||
Reference in New Issue
Block a user