chore: merge master

This commit is contained in:
James
2021-12-29 16:45:52 -05:00
17 changed files with 140 additions and 27 deletions

View File

@@ -18,12 +18,12 @@ type Arguments = {
currentDepth: number
hook: HookName
payload: Payload
showHiddenFields: boolean
}
const accessPromise = async ({
data,
fullData,
originalDoc,
field,
operation,
overrideAccess,
@@ -34,6 +34,7 @@ const accessPromise = async ({
currentDepth,
hook,
payload,
showHiddenFields,
}: Arguments): Promise<void> => {
const resultingData = data;
@@ -56,6 +57,7 @@ const accessPromise = async ({
if ((field.type === 'relationship' || field.type === 'upload') && hook === 'afterRead') {
relationshipPopulations.push(relationshipPopulationPromise({
showHiddenFields,
data,
field,
depth,

View File

@@ -12,6 +12,7 @@ type PopulateArgs = {
field: RelationshipField | UploadField
index?: number
payload: Payload
showHiddenFields: boolean
}
const populate = async ({
@@ -24,6 +25,7 @@ const populate = async ({
field,
index,
payload,
showHiddenFields,
}: PopulateArgs) => {
const dataToUpdate = dataReference;
@@ -44,10 +46,11 @@ const populate = async ({
req,
collection: relatedCollection.config.slug,
id: idString as string,
depth,
currentDepth: currentDepth + 1,
overrideAccess,
disableErrors: true,
depth,
showHiddenFields,
});
}
@@ -76,6 +79,7 @@ type PromiseArgs = {
req: PayloadRequest
overrideAccess: boolean
payload: Payload
showHiddenFields: boolean
}
const relationshipPopulationPromise = ({
@@ -86,6 +90,7 @@ const relationshipPopulationPromise = ({
req,
overrideAccess,
payload,
showHiddenFields,
}: PromiseArgs) => async (): Promise<void> => {
const resultingData = data;
const populateDepth = fieldHasMaxDepth(field) && field.maxDepth < depth ? field.maxDepth : depth;
@@ -106,6 +111,7 @@ const relationshipPopulationPromise = ({
field,
index,
payload,
showHiddenFields,
});
}
};
@@ -124,6 +130,7 @@ const relationshipPopulationPromise = ({
data: data[field.name],
field,
payload,
showHiddenFields,
});
}
};

View File

@@ -11,6 +11,7 @@ type Arguments = {
payload: Payload
field: RichTextField
req: PayloadRequest
showHiddenFields: boolean
}
type RecurseRichTextArgs = {
@@ -22,6 +23,7 @@ type RecurseRichTextArgs = {
field: RichTextField
req: PayloadRequest
promises: Promise<void>[]
showHiddenFields: boolean
}
const populate = async ({
@@ -33,6 +35,7 @@ const populate = async ({
currentDepth,
payload,
req,
showHiddenFields,
}: Arguments & {
id: string,
collection: Collection
@@ -49,6 +52,7 @@ const populate = async ({
overrideAccess,
disableErrors: true,
depth,
showHiddenFields,
});
if (doc) {
@@ -67,6 +71,7 @@ const recurseRichText = ({
currentDepth = 0,
field,
promises,
showHiddenFields,
}: RecurseRichTextArgs) => {
if (Array.isArray(children)) {
(children as any[]).forEach((element) => {
@@ -86,6 +91,7 @@ const recurseRichText = ({
payload,
field,
collection,
showHiddenFields,
}));
}
@@ -99,6 +105,7 @@ const recurseRichText = ({
currentDepth,
field,
promises,
showHiddenFields,
});
}
});
@@ -113,6 +120,7 @@ const richTextRelationshipPromise = ({
depth,
currentDepth,
field,
showHiddenFields,
}: Arguments) => async (): Promise<void> => {
const promises = [];
@@ -125,6 +133,7 @@ const richTextRelationshipPromise = ({
currentDepth,
field,
promises,
showHiddenFields,
});
await Promise.all(promises);

View File

@@ -149,6 +149,7 @@ const traverseFields = (args: Arguments): void => {
depth,
field,
currentDepth,
showHiddenFields,
}));
}
}
@@ -215,6 +216,7 @@ const traverseFields = (args: Arguments): void => {
currentDepth,
hook,
payload,
showHiddenFields,
}));
hookPromises.push(() => hookPromise({
@@ -256,6 +258,7 @@ const traverseFields = (args: Arguments): void => {
docWithLocales: docWithLocales?.[field.name]?.[i],
path: `${path}${field.name}.${i}.`,
skipValidation: skipValidationFromHere,
showHiddenFields,
});
}
}
@@ -268,6 +271,7 @@ const traverseFields = (args: Arguments): void => {
docWithLocales: docWithLocales?.[field.name],
path: `${path}${field.name}.`,
skipValidation: skipValidationFromHere,
showHiddenFields,
});
}
}
@@ -286,6 +290,7 @@ const traverseFields = (args: Arguments): void => {
docWithLocales: docWithLocales?.[field.name]?.[i],
path: `${path}${field.name}.${i}.`,
skipValidation: skipValidationFromHere,
showHiddenFields,
});
}
});