payload 3.0.0-beta.124 → 3.0.0-beta.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/RichText.d.ts +4 -1
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/collections/config/types.d.ts +2 -2
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/create.d.ts +2 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +2 -1
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts +2 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +2 -1
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts +2 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js +2 -1
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/duplicate.d.ts +2 -1
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.js +2 -1
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/collections/operations/find.d.ts +2 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +11 -3
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts +2 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +23 -7
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts +2 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersionByID.js +2 -1
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.d.ts +2 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.js +2 -1
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts +2 -2
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +3 -2
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js +2 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +3 -2
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js +2 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +3 -2
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js +2 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +4 -3
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +4 -3
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js +2 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +3 -2
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js +2 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +3 -2
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js +2 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +3 -2
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js +2 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +3 -2
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js +2 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts +2 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +2 -1
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.d.ts +2 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +2 -1
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +2 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +8 -6
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/database/sanitizeJoinQuery.d.ts +22 -0
- package/dist/database/sanitizeJoinQuery.d.ts.map +1 -0
- package/dist/database/sanitizeJoinQuery.js +61 -0
- package/dist/database/sanitizeJoinQuery.js.map +1 -0
- package/dist/fields/config/types.d.ts +6 -3
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts +2 -1
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts +2 -1
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +3 -1
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js +2 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +4 -2
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +12 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts +3 -2
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +7 -3
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +4 -2
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js +2 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/index.d.ts +2 -1
- package/dist/fields/hooks/beforeDuplicate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/index.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +2 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/globals/config/types.d.ts +2 -2
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/globals/operations/findOne.d.ts +2 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js +2 -1
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts +2 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js +2 -1
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.d.ts +2 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.js +2 -1
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +2 -1
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js +2 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +2 -1
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js +2 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +2 -1
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js +2 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +2 -1
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js +2 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +2 -1
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js +2 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts +2 -1
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/restoreVersion.js +2 -1
- package/dist/globals/operations/restoreVersion.js.map +1 -1
- package/dist/globals/operations/update.d.ts +2 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +2 -1
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/queues/config/jobsCollection.d.ts.map +1 -1
- package/dist/queues/config/jobsCollection.js +15 -13
- package/dist/queues/config/jobsCollection.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +1 -1
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/queues/operations/runJobs/index.js +1 -1
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/dist/types/index.d.ts +6 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +35 -0
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, JsonValue, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport { getDefaultValue } from '../../getDefaultValue.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js'\nimport { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: T\n /**\n * The original data (not modified by any hooks)\n */\n doc: T\n field: Field | TabAsField\n global: null | SanitizedGlobalConfig\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n parentPath: (number | string)[]\n parentSchemaPath: string[]\n req: PayloadRequest\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n if (field.name === 'id') {\n if (field.type === 'number' && typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n\n siblingData[field.name] = parseFloat(value)\n }\n\n if (\n field.type === 'text' &&\n typeof siblingData[field.name]?.toString === 'function' &&\n typeof siblingData[field.name] !== 'string'\n ) {\n siblingData[field.name] = siblingData[field.name].toString()\n }\n }\n\n // Sanitize incoming data\n switch (field.type) {\n case 'number': {\n if (typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n const trimmed = value.trim()\n siblingData[field.name] = trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n\n break\n }\n\n case 'point': {\n if (Array.isArray(siblingData[field.name])) {\n siblingData[field.name] = (siblingData[field.name] as string[]).map((coordinate, i) => {\n if (typeof coordinate === 'string') {\n const value = siblingData[field.name][i] as string\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n return coordinate\n })\n }\n\n break\n }\n\n case 'checkbox': {\n if (siblingData[field.name] === 'true') {\n siblingData[field.name] = true\n }\n if (siblingData[field.name] === 'false') {\n siblingData[field.name] = false\n }\n if (siblingData[field.name] === '') {\n siblingData[field.name] = false\n }\n\n break\n }\n\n case 'richText': {\n if (typeof siblingData[field.name] === 'string') {\n try {\n const richTextJSON = JSON.parse(siblingData[field.name] as string)\n siblingData[field.name] = richTextJSON\n } catch {\n // Disregard this data as it is not valid.\n // Will be reported to user by field validation\n }\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n siblingData[field.name] === '' ||\n siblingData[field.name] === 'none' ||\n siblingData[field.name] === 'null' ||\n siblingData[field.name] === null\n ) {\n if (field.hasMany === true) {\n siblingData[field.name] = []\n } else {\n siblingData[field.name] = null\n }\n }\n\n const value = siblingData[field.name]\n\n if (Array.isArray(field.relationTo)) {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: { relationTo: string; value: JsonValue }, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === relatedDoc.relationTo,\n )\n if (relatedCollection?.fields) {\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = {\n ...relatedDoc,\n value: parseFloat(relatedDoc.value as string),\n }\n }\n }\n })\n }\n if (field.hasMany !== true && valueIsValueWithRelation(value)) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === value.relationTo,\n )\n if (relatedCollection?.fields) {\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = { ...value, value: parseFloat(value.value as string) }\n }\n }\n }\n } else {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: unknown, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n\n if (relatedCollection?.fields) {\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = parseFloat(relatedDoc as string)\n }\n }\n })\n }\n if (field.hasMany !== true && value) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n\n if (relatedCollection?.fields) {\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = parseFloat(value as string)\n }\n }\n }\n }\n break\n }\n\n case 'array':\n case 'blocks': {\n // Handle cases of arrays being intentionally set to 0\n if (siblingData[field.name] === '0' || siblingData[field.name] === 0) {\n siblingData[field.name] = []\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeValidate) {\n await field.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingData[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n if (field.access && field.access[operation]) {\n const result = overrideAccess\n ? true\n : await field.access[operation]({ id, data, doc, req, siblingData })\n\n if (!result) {\n delete siblingData[field.name]\n }\n }\n\n if (typeof siblingData[field.name] === 'undefined') {\n // If no incoming data, but existing document data is found, merge it in\n if (typeof siblingDoc[field.name] !== 'undefined') {\n siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name])\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale: req.locale,\n user: req.user,\n value: siblingData[field.name],\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: groupData as JsonObject,\n siblingDoc: groupDoc as JsonObject,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: getExistingRowDoc(row as JsonObject, siblingDoc[field.name]),\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const rowSiblingDoc = getExistingRowDoc(row as JsonObject, siblingDoc[field.name])\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n ;(row as JsonObject).blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: rowSiblingDoc,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n let tabSiblingDoc\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n tabSiblingDoc = siblingDoc\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.beforeValidate?.length) {\n await editor.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingData[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","valueIsValueWithRelation","getDefaultValue","getFieldPaths","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","global","operation","overrideAccess","parentPath","parentSchemaPath","req","siblingData","siblingDoc","path","fieldPath","schemaPath","fieldSchemaPath","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","richTextJSON","JSON","parse","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","fields","relationshipIDField","collectionField","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","previousValue","undefined","Promise","resolve","access","result","defaultValue","locale","user","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab","editor","Error"],"mappings":"AAMA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAyBpD,oEAAoE;AACpE,2BAA2B;AAC3B,wBAAwB;AACxB,iCAAiC;AACj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,WAAWC;wBACzD,MAAMD;wBAEN,MAAME,cAAc,MAAMD,YAAY;4BACpClD;4BACAC;4BACAC;4BACAE;4BACAC;4BACAC;4BACA8C,aAAajD;4BACbI;4BACAM,MAAMC;4BACNuC,oBAAoBzC;4BACpB0C,eAAe3C,WAAW,CAACP,MAAMa,IAAI,CAAC;4BACtCP;4BACAK,YAAYC;4BACZL;4BACAQ,OAAOR,WAAW,CAACP,MAAMa,IAAI,CAAC;wBAChC;wBAEA,IAAIkC,gBAAgBI,WAAW;4BAC7B5C,WAAW,CAACP,MAAMa,IAAI,CAAC,GAAGkC;wBAC5B;oBACF,GAAGK,QAAQC,OAAO;gBACpB;gBACA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, JsonValue, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport { getDefaultValue } from '../../getDefaultValue.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js'\nimport { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: T\n /**\n * The original data (not modified by any hooks)\n */\n doc: T\n field: Field | TabAsField\n global: null | SanitizedGlobalConfig\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n parentPath: (number | string)[]\n parentSchemaPath: string[]\n req: PayloadRequest\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n if (field.name === 'id') {\n if (field.type === 'number' && typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n\n siblingData[field.name] = parseFloat(value)\n }\n\n if (\n field.type === 'text' &&\n typeof siblingData[field.name]?.toString === 'function' &&\n typeof siblingData[field.name] !== 'string'\n ) {\n siblingData[field.name] = siblingData[field.name].toString()\n }\n }\n\n // Sanitize incoming data\n switch (field.type) {\n case 'number': {\n if (typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n const trimmed = value.trim()\n siblingData[field.name] = trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n\n break\n }\n\n case 'point': {\n if (Array.isArray(siblingData[field.name])) {\n siblingData[field.name] = (siblingData[field.name] as string[]).map((coordinate, i) => {\n if (typeof coordinate === 'string') {\n const value = siblingData[field.name][i] as string\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n return coordinate\n })\n }\n\n break\n }\n\n case 'checkbox': {\n if (siblingData[field.name] === 'true') {\n siblingData[field.name] = true\n }\n if (siblingData[field.name] === 'false') {\n siblingData[field.name] = false\n }\n if (siblingData[field.name] === '') {\n siblingData[field.name] = false\n }\n\n break\n }\n\n case 'richText': {\n if (typeof siblingData[field.name] === 'string') {\n try {\n const richTextJSON = JSON.parse(siblingData[field.name] as string)\n siblingData[field.name] = richTextJSON\n } catch {\n // Disregard this data as it is not valid.\n // Will be reported to user by field validation\n }\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n siblingData[field.name] === '' ||\n siblingData[field.name] === 'none' ||\n siblingData[field.name] === 'null' ||\n siblingData[field.name] === null\n ) {\n if (field.hasMany === true) {\n siblingData[field.name] = []\n } else {\n siblingData[field.name] = null\n }\n }\n\n const value = siblingData[field.name]\n\n if (Array.isArray(field.relationTo)) {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: { relationTo: string; value: JsonValue }, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === relatedDoc.relationTo,\n )\n if (relatedCollection?.fields) {\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = {\n ...relatedDoc,\n value: parseFloat(relatedDoc.value as string),\n }\n }\n }\n })\n }\n if (field.hasMany !== true && valueIsValueWithRelation(value)) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === value.relationTo,\n )\n if (relatedCollection?.fields) {\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = { ...value, value: parseFloat(value.value as string) }\n }\n }\n }\n } else {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: unknown, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n\n if (relatedCollection?.fields) {\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = parseFloat(relatedDoc as string)\n }\n }\n })\n }\n if (field.hasMany !== true && value) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n\n if (relatedCollection?.fields) {\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = parseFloat(value as string)\n }\n }\n }\n }\n break\n }\n\n case 'array':\n case 'blocks': {\n // Handle cases of arrays being intentionally set to 0\n if (siblingData[field.name] === '0' || siblingData[field.name] === 0) {\n siblingData[field.name] = []\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeValidate) {\n await field.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingData[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n if (field.access && field.access[operation]) {\n const result = overrideAccess\n ? true\n : await field.access[operation]({ id, data, doc, req, siblingData })\n\n if (!result) {\n delete siblingData[field.name]\n }\n }\n\n if (typeof siblingData[field.name] === 'undefined') {\n // If no incoming data, but existing document data is found, merge it in\n if (typeof siblingDoc[field.name] !== 'undefined') {\n siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name])\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale: req.locale,\n user: req.user,\n value: siblingData[field.name],\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: groupData as JsonObject,\n siblingDoc: groupDoc as JsonObject,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: getExistingRowDoc(row as JsonObject, siblingDoc[field.name]),\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const rowSiblingDoc = getExistingRowDoc(row as JsonObject, siblingDoc[field.name])\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n ;(row as JsonObject).blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: rowSiblingDoc,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n let tabSiblingDoc\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n tabSiblingDoc = siblingDoc\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.beforeValidate?.length) {\n await editor.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingData[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","valueIsValueWithRelation","getDefaultValue","getFieldPaths","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","global","operation","overrideAccess","parentPath","parentSchemaPath","req","siblingData","siblingDoc","path","fieldPath","schemaPath","fieldSchemaPath","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","richTextJSON","JSON","parse","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","fields","relationshipIDField","collectionField","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","previousValue","undefined","Promise","resolve","access","result","defaultValue","locale","user","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab","editor","Error"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAyBpD,oEAAoE;AACpE,2BAA2B;AAC3B,wBAAwB;AACxB,iCAAiC;AACjC,oDAAoD;AACpD,gDAAgD;AAEhD,OAAO,MAAMC,UAAU,OAAU,EAC/BC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAChBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAM,EAAEC,MAAMC,SAAS,EAAEC,YAAYC,eAAe,EAAE,GAAGtB,cAAc;QACrEU;QACAI;QACAC;IACF;IAEA,IAAInB,iBAAiBc,QAAQ;QAC3B,IAAIA,MAAMa,IAAI,KAAK,MAAM;YACvB,IAAIb,MAAMc,IAAI,KAAK,YAAY,OAAOP,WAAW,CAACP,MAAMa,IAAI,CAAC,KAAK,UAAU;gBAC1E,MAAME,QAAQR,WAAW,CAACP,MAAMa,IAAI,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AMC;oBACNJ;oBACAK,YAAYC;oBACZL,aAAagE;oBACb/D,YAAYgE;gBACd;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX,MAAM/E,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAwC,QAAQvC,MAAMyE,IAAI,CAAClD,GAAG,CAAC,CAACmD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE5D,MAAM;wBAAM,CAAA;oBACvDb;oBACAC;oBACAC;oBACAM,MAAMC;oBACNJ;oBACAK,YAAYC;oBACZL;oBACAC;gBACF;gBAEA;YACF;QAEA,KAAK;YAAY;gBACf,IAAI,CAACR,OAAO2E,QAAQ;oBAClB,MAAM,IAAI1F,kBAAkBe,OAAO,8HAA8H;;gBACnK;gBACA,IAAI,OAAOA,OAAO2E,WAAW,YAAY;oBACvC,MAAM,IAAIC,MAAM;gBAClB;gBAEA,MAAMD,SAA0B3E,OAAO2E;gBAEvC,IAAIA,QAAQjC,OAAOC,gBAAgBvB,QAAQ;oBACzC,MAAMuD,OAAOjC,KAAK,CAACC,cAAc,CAACC,MAAM,CAAC,OAAOC,WAAWC;wBACzD,MAAMD;wBAEN,MAAME,cAAc,MAAMD,YAAY;4BACpClD;4BACAC;4BACAC;4BACAE;4BACAC;4BACAC;4BACA8C,aAAajD;4BACbI;4BACAM,MAAMC;4BACNuC,oBAAoBzC;4BACpB0C,eAAe3C,WAAW,CAACP,MAAMa,IAAI,CAAC;4BACtCP;4BACAK,YAAYC;4BACZL;4BACAQ,OAAOR,WAAW,CAACP,MAAMa,IAAI,CAAC;wBAChC;wBAEA,IAAIkC,gBAAgBI,WAAW;4BAC7B5C,WAAW,CAACP,MAAMa,IAAI,CAAC,GAAGkC;wBAC5B;oBACF,GAAGK,QAAQC,OAAO;gBACpB;gBACA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
|
|
2
2
|
import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RequestContext } from '../../../index.js';
|
|
4
|
+
import type { JsonObject, PayloadRequest } from '../../../types/index.js';
|
|
4
5
|
import type { Field, TabAsField } from '../../config/types.js';
|
|
5
6
|
type Args<T> = {
|
|
6
7
|
collection: null | SanitizedCollectionConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP;;OAEG;IACH,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,WAAW,EAAE,UAAU,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,CAAC,sIAenC,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CAuBxB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, PayloadRequest
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: T\n /**\n * The original data (not modified by any hooks)\n */\n doc: T\n fields: (Field | TabAsField)[]\n global: null | SanitizedGlobalConfig\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n path: (number | string)[]\n req: PayloadRequest\n schemaPath: string[]\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\n}\n\nexport const traverseFields = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n overrideAccess,\n path,\n req,\n schemaPath,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const promises = []\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n parentPath: path,\n parentSchemaPath: schemaPath,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","data","doc","fields","global","operation","overrideAccess","path","req","schemaPath","siblingData","siblingDoc","promises","forEach","field","push","parentPath","parentSchemaPath","Promise","all"],"mappings":"AAMA,SAASA,OAAO,QAAQ,eAAc;AAyBtC,OAAO,MAAMC,iBAAiB,OAAU,EACtCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,IAAI,EACJC,GAAG,EACHC,UAAU,EACVC,WAAW,EACXC,UAAU,EACF;IACR,MAAMC,WAAW,EAAE;IACnBT,OAAOU,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXnB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAY;YACAV;YACAC;YACAC;YACAU,YAAYT;YACZU,kBAAkBR;YAClBD;YACAE;YACAC;QACF;IAEJ;IACA,MAAMO,QAAQC,GAAG,CAACP;AACpB,EAAC"}
|
|
@@ -4,8 +4,8 @@ import type { CustomPreviewButton, CustomPublishButton, CustomSaveButton, Custom
|
|
|
4
4
|
import type { Access, EditConfig, Endpoint, EntityDescription, EntityDescriptionComponent, GeneratePreviewURL, LivePreviewConfig, MetaConfig } from '../../config/types.js';
|
|
5
5
|
import type { DBIdentifierName } from '../../database/types.js';
|
|
6
6
|
import type { Field } from '../../fields/config/types.js';
|
|
7
|
-
import type { GlobalSlug, TypedGlobal, TypedGlobalSelect } from '../../index.js';
|
|
8
|
-
import type { PayloadRequest,
|
|
7
|
+
import type { GlobalSlug, RequestContext, TypedGlobal, TypedGlobalSelect } from '../../index.js';
|
|
8
|
+
import type { PayloadRequest, Where } from '../../types/index.js';
|
|
9
9
|
import type { IncomingGlobalVersions, SanitizedGlobalVersions } from '../../versions/types.js';
|
|
10
10
|
export type DataFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobal[TSlug];
|
|
11
11
|
export type SelectFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobalSelect[TSlug];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACX,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,sB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cAAc,EAAE,CAAA;QAC7B,cAAc,CAAC,EAAE,kBAAkB,EAAE,CAAA;KACtC,CAAA;IACD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACvC;;;OAGG;IACH,aAAa,CAAC,EACV;QACE,QAAQ,EAAE,MAAM,CAAA;KACjB,GACD,KAAK,CAAA;IACT,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,UAAU,CAAC,EAAE;QACX;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,QAAQ,CAAC,EAAE,OAAO,GAAG,sBAAsB,CAAA;CAC5C,CAAA;AAED,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC7E,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,EAAE,uBAAuB,CAAA;CAClC;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,qBAAqB,EAAE,CAAA;IAC/B,OAAO,CAAC,EACJ;QACE,CAAC,IAAI,EAAE,MAAM,GAAG;YACd,iBAAiB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;YACtC,IAAI,EAAE,iBAAiB,CAAA;YACvB,WAAW,CAAC,EAAE,iBAAiB,CAAA;SAChC,CAAA;KACF,GACD,KAAK,CAAA;CACV,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/config/types.ts"],"sourcesContent":["import type { GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport type { DeepRequired } from 'ts-essentials'\n\nimport type {\n CustomPreviewButton,\n CustomPublishButton,\n CustomSaveButton,\n CustomSaveDraftButton,\n} from '../../admin/types.js'\nimport type {\n Access,\n EditConfig,\n Endpoint,\n EntityDescription,\n EntityDescriptionComponent,\n GeneratePreviewURL,\n LivePreviewConfig,\n MetaConfig,\n} from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { Field } from '../../fields/config/types.js'\nimport type { GlobalSlug, TypedGlobal, TypedGlobalSelect } from '../../index.js'\nimport type { PayloadRequest,
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/config/types.ts"],"sourcesContent":["import type { GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport type { DeepRequired } from 'ts-essentials'\n\nimport type {\n CustomPreviewButton,\n CustomPublishButton,\n CustomSaveButton,\n CustomSaveDraftButton,\n} from '../../admin/types.js'\nimport type {\n Access,\n EditConfig,\n Endpoint,\n EntityDescription,\n EntityDescriptionComponent,\n GeneratePreviewURL,\n LivePreviewConfig,\n MetaConfig,\n} from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { Field } from '../../fields/config/types.js'\nimport type { GlobalSlug, RequestContext, TypedGlobal, TypedGlobalSelect } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { IncomingGlobalVersions, SanitizedGlobalVersions } from '../../versions/types.js'\n\nexport type DataFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobal[TSlug]\n\nexport type SelectFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobalSelect[TSlug]\n\nexport type BeforeValidateHook = (args: {\n context: RequestContext\n data?: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n originalDoc?: any\n req: PayloadRequest\n}) => any\n\nexport type BeforeChangeHook = (args: {\n context: RequestContext\n data: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n originalDoc?: any\n req: PayloadRequest\n}) => any\n\nexport type AfterChangeHook = (args: {\n context: RequestContext\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n previousDoc: any\n req: PayloadRequest\n}) => any\n\nexport type BeforeReadHook = (args: {\n context: RequestContext\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n req: PayloadRequest\n}) => any\n\nexport type AfterReadHook = (args: {\n context: RequestContext\n doc: any\n findMany?: boolean\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n query?: Where\n req: PayloadRequest\n}) => any\n\nexport type GlobalAdminOptions = {\n /**\n * Custom admin components\n */\n components?: {\n elements?: {\n Description?: EntityDescriptionComponent\n /**\n * Replaces the \"Preview\" button\n */\n PreviewButton?: CustomPreviewButton\n /**\n * Replaces the \"Publish\" button\n * + drafts must be enabled\n */\n PublishButton?: CustomPublishButton\n /**\n * Replaces the \"Save\" button\n * + drafts must be disabled\n */\n SaveButton?: CustomSaveButton\n /**\n * Replaces the \"Save Draft\" button\n * + drafts must be enabled\n * + autosave must be disabled\n */\n SaveDraftButton?: CustomSaveDraftButton\n }\n views?: {\n /**\n * Set to a React component to replace the entire Edit View, including all nested routes.\n * Set to an object to replace or modify individual nested routes, or to add new ones.\n */\n edit?: EditConfig\n }\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n /**\n * Custom description for collection\n */\n description?: EntityDescription\n /**\n * Place globals into a navigational group\n * */\n group?: Record<string, string> | string\n /**\n * Exclude the global from the admin nav and routes\n */\n hidden?: ((args: { user: PayloadRequest['user'] }) => boolean) | boolean\n /**\n * Hide the API URL within the Edit View\n */\n hideAPIURL?: boolean\n /**\n * Live preview options\n */\n livePreview?: LivePreviewConfig\n meta?: MetaConfig\n /**\n * Function to generate custom preview URL\n */\n preview?: GeneratePreviewURL\n}\n\nexport type GlobalConfig = {\n access?: {\n read?: Access\n readDrafts?: Access\n readVersions?: Access\n update?: Access\n }\n admin?: GlobalAdminOptions\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n endpoints?: false | Omit<Endpoint, 'root'>[]\n fields: Field[]\n graphQL?:\n | {\n name?: string\n }\n | false\n hooks?: {\n afterChange?: AfterChangeHook[]\n afterRead?: AfterReadHook[]\n beforeChange?: BeforeChangeHook[]\n beforeRead?: BeforeReadHook[]\n beforeValidate?: BeforeValidateHook[]\n }\n label?: Record<string, string> | string\n /**\n * Enables / Disables the ability to lock documents while editing\n * @default true\n */\n lockDocuments?:\n | {\n duration: number\n }\n | false\n slug: string\n /**\n * Options used in typescript generation\n */\n typescript?: {\n /**\n * Typescript generation name given to the interface type\n */\n interface?: string\n }\n versions?: boolean | IncomingGlobalVersions\n}\n\nexport interface SanitizedGlobalConfig\n extends Omit<DeepRequired<GlobalConfig>, 'endpoints' | 'fields' | 'versions'> {\n endpoints: Endpoint[] | false\n fields: Field[]\n versions: SanitizedGlobalVersions\n}\n\nexport type Globals = {\n config: SanitizedGlobalConfig[]\n graphQL?:\n | {\n [slug: string]: {\n mutationInputType: GraphQLNonNull<any>\n type: GraphQLObjectType\n versionType?: GraphQLObjectType\n }\n }\n | false\n}\n"],"names":[],"mappings":"AAqMA,WAWC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PayloadRequest, SelectType } from '../../types/index.js';
|
|
1
|
+
import type { PayloadRequest, PopulateType, SelectType } from '../../types/index.js';
|
|
2
2
|
import type { SanitizedGlobalConfig } from '../config/types.js';
|
|
3
3
|
type Args = {
|
|
4
4
|
depth?: number;
|
|
@@ -6,6 +6,7 @@ type Args = {
|
|
|
6
6
|
globalConfig: SanitizedGlobalConfig;
|
|
7
7
|
includeLockStatus?: boolean;
|
|
8
8
|
overrideAccess?: boolean;
|
|
9
|
+
populate?: PopulateType;
|
|
9
10
|
req: PayloadRequest;
|
|
10
11
|
select?: SelectType;
|
|
11
12
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAS,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAS,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAQ/D,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAChE,IAAI,KACT,OAAO,CAAC,CAAC,CAmLX,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { getSelectMode } from '../../utilities/getSelectMode.js';
|
|
|
4
4
|
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
5
5
|
import replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js';
|
|
6
6
|
export const findOneOperation = async (args)=>{
|
|
7
|
-
const { slug, depth, draft: draftEnabled = false, globalConfig, includeLockStatus, overrideAccess = false, req: { fallbackLocale, locale }, req, select, showHiddenFields } = args;
|
|
7
|
+
const { slug, depth, draft: draftEnabled = false, globalConfig, includeLockStatus, overrideAccess = false, populate, req: { fallbackLocale, locale }, req, select, showHiddenFields } = args;
|
|
8
8
|
try {
|
|
9
9
|
// /////////////////////////////////////
|
|
10
10
|
// Retrieve and execute access
|
|
@@ -118,6 +118,7 @@ export const findOneOperation = async (args)=>{
|
|
|
118
118
|
global: globalConfig,
|
|
119
119
|
locale,
|
|
120
120
|
overrideAccess,
|
|
121
|
+
populate,
|
|
121
122
|
req,
|
|
122
123
|
select,
|
|
123
124
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/findOne.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\ntype Args = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n includeLockStatus?: boolean\n overrideAccess?: boolean\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const findOneOperation = async <T extends Record<string, unknown>>(\n args: Args,\n): Promise<T> => {\n const {\n slug,\n depth,\n draft: draftEnabled = false,\n globalConfig,\n includeLockStatus,\n overrideAccess = false,\n req: { fallbackLocale, locale },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Retrieve and execute access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ req }, globalConfig.access.read)\n }\n\n // /////////////////////////////////////\n // Perform database operation\n // /////////////////////////////////////\n\n let doc = await req.payload.db.findGlobal({\n slug,\n locale,\n req,\n select,\n where: overrideAccess ? undefined : (accessResult as Where),\n })\n if (!doc) {\n doc = {}\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n if (includeLockStatus && slug) {\n let lockStatus = null\n\n try {\n const lockDocumentsProp = globalConfig?.lockDocuments\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const lockedDocument = await req.payload.find({\n collection: 'payload-locked-documents',\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n globalSlug: {\n equals: slug,\n },\n },\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]\n }\n } catch {\n // swallow error\n }\n\n doc._isLocked = !!lockStatus\n doc._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (globalConfig.versions?.drafts && draftEnabled) {\n doc = await replaceWithDraftIfAvailable({\n accessResult,\n doc,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // Execute before global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && doc.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete doc['globalType']\n }\n }\n\n // /////////////////////////////////////\n // Execute field-level hooks and access\n // /////////////////////////////////////\n\n doc = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc,\n draft: draftEnabled,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // Execute after global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return doc\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterRead","getSelectMode","killTransaction","replaceWithDraftIfAvailable","findOneOperation","args","slug","depth","draft","draftEnabled","globalConfig","includeLockStatus","overrideAccess","req","fallbackLocale","locale","select","showHiddenFields","accessResult","access","read","doc","payload","db","findGlobal","where","undefined","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","collection","limit","pagination","and","globalSlug","equals","updatedAt","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","versions","drafts","entity","entityType","hooks","beforeRead","reduce","priorHook","hook","context","global","Promise","resolve","globalType","selectMode","error"],"mappings":"AAIA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,iCAAiC,uDAAsD;
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/findOne.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, PopulateType, SelectType, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\ntype Args = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n includeLockStatus?: boolean\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const findOneOperation = async <T extends Record<string, unknown>>(\n args: Args,\n): Promise<T> => {\n const {\n slug,\n depth,\n draft: draftEnabled = false,\n globalConfig,\n includeLockStatus,\n overrideAccess = false,\n populate,\n req: { fallbackLocale, locale },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Retrieve and execute access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ req }, globalConfig.access.read)\n }\n\n // /////////////////////////////////////\n // Perform database operation\n // /////////////////////////////////////\n\n let doc = await req.payload.db.findGlobal({\n slug,\n locale,\n req,\n select,\n where: overrideAccess ? undefined : (accessResult as Where),\n })\n if (!doc) {\n doc = {}\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n if (includeLockStatus && slug) {\n let lockStatus = null\n\n try {\n const lockDocumentsProp = globalConfig?.lockDocuments\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const lockedDocument = await req.payload.find({\n collection: 'payload-locked-documents',\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n globalSlug: {\n equals: slug,\n },\n },\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]\n }\n } catch {\n // swallow error\n }\n\n doc._isLocked = !!lockStatus\n doc._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (globalConfig.versions?.drafts && draftEnabled) {\n doc = await replaceWithDraftIfAvailable({\n accessResult,\n doc,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // Execute before global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && doc.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete doc['globalType']\n }\n }\n\n // /////////////////////////////////////\n // Execute field-level hooks and access\n // /////////////////////////////////////\n\n doc = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc,\n draft: draftEnabled,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // Execute after global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return doc\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterRead","getSelectMode","killTransaction","replaceWithDraftIfAvailable","findOneOperation","args","slug","depth","draft","draftEnabled","globalConfig","includeLockStatus","overrideAccess","populate","req","fallbackLocale","locale","select","showHiddenFields","accessResult","access","read","doc","payload","db","findGlobal","where","undefined","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","collection","limit","pagination","and","globalSlug","equals","updatedAt","greater_than","Date","getTime","docs","length","_isLocked","_userEditing","user","value","versions","drafts","entity","entityType","hooks","beforeRead","reduce","priorHook","hook","context","global","Promise","resolve","globalType","selectMode","error"],"mappings":"AAIA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,SAAS,QAA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AShD,IAAIgD,OAAO;YACpBvD;YACAe;YACAd,OAAOC;YACPM;YACAgD,QAAQrD;YACRM;YACAJ;YACAC;YACAC;YACAG;YACAC;QACF;QAEA,wCAAwC;QACxC,4BAA4B;QAC5B,wCAAwC;QAExC,MAAMR,aAAa+C,KAAK,CAACzD,SAAS,CAAC2D,MAAM,CAAC,OAAOC,WAAWC;YAC1D,MAAMD;YAENtC,MACE,AAAC,MAAMuC,KAAK;gBACVC,SAAShD,IAAIgD,OAAO;gBACpBxC;gBACAyC,QAAQrD;gBACRI;YACF,MAAOQ;QACX,GAAG0C,QAAQC,OAAO;QAElB,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAO3C;IACT,EAAE,OAAO8C,OAAgB;QACvB,MAAMlE,gBAAgBY;QACtB,MAAMsD;IACR;AACF,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PayloadRequest, SelectType } from '../../types/index.js';
|
|
1
|
+
import type { PayloadRequest, PopulateType, SelectType } from '../../types/index.js';
|
|
2
2
|
import type { TypeWithVersion } from '../../versions/types.js';
|
|
3
3
|
import type { SanitizedGlobalConfig } from '../config/types.js';
|
|
4
4
|
export type Arguments = {
|
|
@@ -8,6 +8,7 @@ export type Arguments = {
|
|
|
8
8
|
globalConfig: SanitizedGlobalConfig;
|
|
9
9
|
id: number | string;
|
|
10
10
|
overrideAccess?: boolean;
|
|
11
|
+
populate?: PopulateType;
|
|
11
12
|
req: PayloadRequest;
|
|
12
13
|
select?: SelectType;
|
|
13
14
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersionByID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersionByID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAS/D,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,EAAE,qBAAqB,CAAA;IACnC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAU,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,cACnE,SAAS,KACd,OAAO,CAAC,CAAC,CA+HX,CAAA"}
|
|
@@ -5,7 +5,7 @@ import { afterRead } from '../../fields/hooks/afterRead/index.js';
|
|
|
5
5
|
import { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js';
|
|
6
6
|
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
7
7
|
export const findVersionByIDOperation = async (args)=>{
|
|
8
|
-
const { id, currentDepth, depth, disableErrors, globalConfig, overrideAccess, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields } = args;
|
|
8
|
+
const { id, currentDepth, depth, disableErrors, globalConfig, overrideAccess, populate, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields } = args;
|
|
9
9
|
try {
|
|
10
10
|
// /////////////////////////////////////
|
|
11
11
|
// Access
|
|
@@ -80,6 +80,7 @@ export const findVersionByIDOperation = async (args)=>{
|
|
|
80
80
|
global: globalConfig,
|
|
81
81
|
locale,
|
|
82
82
|
overrideAccess,
|
|
83
|
+
populate,
|
|
83
84
|
req,
|
|
84
85
|
select: typeof select?.version === 'object' ? select.version : undefined,
|
|
85
86
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/findVersionByID.ts"],"sourcesContent":["import type { FindGlobalVersionsArgs } from '../../database/types.js'\nimport type { PayloadRequest, SelectType } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { Forbidden, NotFound } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/findVersionByID.ts"],"sourcesContent":["import type { FindGlobalVersionsArgs } from '../../database/types.js'\nimport type { PayloadRequest, PopulateType, SelectType } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { Forbidden, NotFound } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n globalConfig: SanitizedGlobalConfig\n id: number | string\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const findVersionByIDOperation = async <T extends TypeWithVersion<T> = any>(\n args: Arguments,\n): Promise<T> => {\n const {\n id,\n currentDepth,\n depth,\n disableErrors,\n globalConfig,\n overrideAccess,\n populate,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n } = args\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ id, disableErrors, req }, globalConfig.access.readVersions)\n : true\n\n // If errors are disabled, and access returns false, return null\n if (accessResults === false) {\n return null\n }\n\n const hasWhereAccess = typeof accessResults === 'object'\n\n const findGlobalVersionsArgs: FindGlobalVersionsArgs = {\n global: globalConfig.slug,\n limit: 1,\n locale,\n req,\n select,\n where: combineQueries({ id: { equals: id } }, accessResults),\n }\n\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n if (!findGlobalVersionsArgs.where.and[0].id) {\n throw new NotFound(req.t)\n }\n\n const { docs: results } = await payload.db.findGlobalVersions(findGlobalVersionsArgs)\n if (!results || results?.length === 0) {\n if (!disableErrors) {\n if (!hasWhereAccess) {\n throw new NotFound(req.t)\n }\n if (hasWhereAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n return null\n }\n\n // Clone the result - it may have come back memoized\n let result: any = deepCopyObjectSimple(results[0])\n\n // Patch globalType onto version doc\n result.version.globalType = globalConfig.slug\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result.version,\n global: globalConfig,\n req,\n })) || result.version\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result.version = await afterRead({\n collection: null,\n context: req.context,\n currentDepth,\n depth,\n doc: result.version,\n draft: undefined,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n populate,\n req,\n select: typeof select?.version === 'object' ? select.version : undefined,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result.version =\n (await hook({\n context: req.context,\n doc: result.version,\n global: globalConfig,\n query: findGlobalVersionsArgs.where,\n req,\n })) || result.version\n }, Promise.resolve())\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","Forbidden","NotFound","afterRead","deepCopyObjectSimple","killTransaction","findVersionByIDOperation","args","id","currentDepth","depth","disableErrors","globalConfig","overrideAccess","populate","req","fallbackLocale","locale","payload","select","showHiddenFields","accessResults","access","readVersions","hasWhereAccess","findGlobalVersionsArgs","global","slug","limit","where","equals","and","t","docs","results","db","findGlobalVersions","length","result","version","globalType","hooks","beforeRead","reduce","priorHook","hook","context","doc","Promise","resolve","collection","draft","undefined","query","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,wBAAuB;AAC3D,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AAepE,OAAO,MAAMC,2BAA2B,OACtCC;IAEA,MAAM,EACJC,EAAE,EACFC,YAAY,EACZC,KAAK,EACLC,aAAa,EACbC,YAAY,EACZC,cAAc,EACdC,QAAQ,EACRC,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAE,EACxCH,GAAG,EACHI,MAAM,EACNC,gBAAgB,EACjB,GAAGb;IAEJ,IAAI;QACF,wCAAwC;QACxC,SAAS;QACT,wCAAwC;QAExC,MAAMc,gBAAgB,CAACR,iBACnB,MAAMd,cAAc;YAAES;YAAIG;YAAeI;QAAI,GAAGH,aAAaU,MAAM,CAACC,YAAY,IAChF;QAEJ,gEAAgE;QAChE,IAAIF,kBAAkB,OAAO;YAC3B,OAAO;QACT;QAEA,MAAMG,iBAAiB,OAAOH,kBAAkB;QAEhD,MAAMI,yBAAiD;YACrDC,QAAQd,aAAae,IAAI;YAC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U,QAAQd;YACRK;YACAJ;YACAC;YACAC;YACAI,QAAQ,OAAOA,QAAQoB,YAAY,WAAWpB,OAAOoB,OAAO,GAAGa;YAC/DhC;QACF;QAEA,wCAAwC;QACxC,qBAAqB;QACrB,wCAAwC;QAExC,MAAMR,aAAa6B,KAAK,CAACtC,SAAS,CAACwC,MAAM,CAAC,OAAOC,WAAWC;YAC1D,MAAMD;YAENN,OAAOC,OAAO,GACZ,AAAC,MAAMM,KAAK;gBACVC,SAAS/B,IAAI+B,OAAO;gBACpBC,KAAKT,OAAOC,OAAO;gBACnBb,QAAQd;gBACRyC,OAAO5B,uBAAuBI,KAAK;gBACnCd;YACF,MAAOuB,OAAOC,OAAO;QACzB,GAAGS,QAAQC,OAAO;QAElB,OAAOX;IACT,EAAE,OAAOgB,OAAgB;QACvB,MAAMjD,gBAAgBU;QACtB,MAAMuC;IACR;AACF,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PaginatedDocs } from '../../database/types.js';
|
|
2
|
-
import type { PayloadRequest, SelectType, Sort, Where } from '../../types/index.js';
|
|
2
|
+
import type { PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../types/index.js';
|
|
3
3
|
import type { TypeWithVersion } from '../../versions/types.js';
|
|
4
4
|
import type { SanitizedGlobalConfig } from '../config/types.js';
|
|
5
5
|
export type Arguments = {
|
|
@@ -9,6 +9,7 @@ export type Arguments = {
|
|
|
9
9
|
overrideAccess?: boolean;
|
|
10
10
|
page?: number;
|
|
11
11
|
pagination?: boolean;
|
|
12
|
+
populate?: PopulateType;
|
|
12
13
|
req?: PayloadRequest;
|
|
13
14
|
select?: SelectType;
|
|
14
15
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAU/D,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,qBAAqB,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAU,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,QAChE,SAAS,KACd,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAoI1B,CAAA"}
|
|
@@ -6,7 +6,7 @@ import { killTransaction } from '../../utilities/killTransaction.js';
|
|
|
6
6
|
import sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js';
|
|
7
7
|
import { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js';
|
|
8
8
|
export const findVersionsOperation = async (args)=>{
|
|
9
|
-
const { depth, globalConfig, limit, overrideAccess, page, pagination = true, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields, sort, where } = args;
|
|
9
|
+
const { depth, globalConfig, limit, overrideAccess, page, pagination = true, populate, req: { fallbackLocale, locale, payload }, req, select, showHiddenFields, sort, where } = args;
|
|
10
10
|
const versionFields = buildVersionGlobalFields(payload.config, globalConfig);
|
|
11
11
|
try {
|
|
12
12
|
// /////////////////////////////////////
|
|
@@ -60,6 +60,7 @@ export const findVersionsOperation = async (args)=>{
|
|
|
60
60
|
global: globalConfig,
|
|
61
61
|
locale,
|
|
62
62
|
overrideAccess,
|
|
63
|
+
populate,
|
|
63
64
|
req,
|
|
64
65
|
select,
|
|
65
66
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../database/types.js'\nimport type { PayloadRequest, SelectType, Sort, Where } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'\n\nexport type Arguments = {\n depth?: number\n globalConfig: SanitizedGlobalConfig\n limit?: number\n overrideAccess?: boolean\n page?: number\n pagination?: boolean\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n sort?: Sort\n where?: Where\n}\n\nexport const findVersionsOperation = async <T extends TypeWithVersion<T>>(\n args: Arguments,\n): Promise<PaginatedDocs<T>> => {\n const {\n depth,\n globalConfig,\n limit,\n overrideAccess,\n page,\n pagination = true,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n sort,\n where,\n } = args\n\n const versionFields = buildVersionGlobalFields(payload.config, globalConfig)\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ req }, globalConfig.access.readVersions)\n : true\n\n await validateQueryPaths({\n globalConfig,\n overrideAccess,\n req,\n versionFields,\n where,\n })\n\n const fullWhere = combineQueries(where, accessResults)\n\n // /////////////////////////////////////\n // Find\n // /////////////////////////////////////\n\n const paginatedDocs = await payload.db.findGlobalVersions<T>({\n global: globalConfig.slug,\n limit: limit ?? 10,\n locale,\n page: page || 1,\n pagination,\n req,\n select,\n sort,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n let result = {\n ...paginatedDocs,\n docs: await Promise.all(\n paginatedDocs.docs.map(async (data) => {\n return {\n ...data,\n version: await afterRead<T>({\n collection: null,\n context: req.context,\n depth,\n doc: {\n ...data.version,\n // Patch globalType onto version doc\n globalType: globalConfig.slug,\n },\n draft: undefined,\n fallbackLocale,\n findMany: true,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n }),\n }\n }),\n ),\n } as PaginatedDocs<T>\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n const docRef = doc\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef.version =\n (await hook({\n context: req.context,\n doc: doc.version,\n findMany: true,\n global: globalConfig,\n query: fullWhere,\n req,\n })) || doc.version\n }, Promise.resolve())\n\n return docRef\n }),\n ),\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: result.docs.map((doc) => sanitizeInternalFields<T>(doc)),\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","afterRead","killTransaction","sanitizeInternalFields","buildVersionGlobalFields","findVersionsOperation","args","depth","globalConfig","limit","overrideAccess","page","pagination","req","fallbackLocale","locale","payload","select","showHiddenFields","sort","where","versionFields","config","accessResults","access","readVersions","fullWhere","paginatedDocs","db","findGlobalVersions","global","slug","result","docs","Promise","all","map","data","version","collection","context","doc","globalType","draft","undefined","findMany","docRef","hooks","reduce","priorHook","hook","query","resolve","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,4BAA4B,4CAA2C;AAC9E,SAASC,wBAAwB,QAAQ,sCAAqC;
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../database/types.js'\nimport type { PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'\n\nexport type Arguments = {\n depth?: number\n globalConfig: SanitizedGlobalConfig\n limit?: number\n overrideAccess?: boolean\n page?: number\n pagination?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n sort?: Sort\n where?: Where\n}\n\nexport const findVersionsOperation = async <T extends TypeWithVersion<T>>(\n args: Arguments,\n): Promise<PaginatedDocs<T>> => {\n const {\n depth,\n globalConfig,\n limit,\n overrideAccess,\n page,\n pagination = true,\n populate,\n req: { fallbackLocale, locale, payload },\n req,\n select,\n showHiddenFields,\n sort,\n where,\n } = args\n\n const versionFields = buildVersionGlobalFields(payload.config, globalConfig)\n\n try {\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ req }, globalConfig.access.readVersions)\n : true\n\n await validateQueryPaths({\n globalConfig,\n overrideAccess,\n req,\n versionFields,\n where,\n })\n\n const fullWhere = combineQueries(where, accessResults)\n\n // /////////////////////////////////////\n // Find\n // /////////////////////////////////////\n\n const paginatedDocs = await payload.db.findGlobalVersions<T>({\n global: globalConfig.slug,\n limit: limit ?? 10,\n locale,\n page: page || 1,\n pagination,\n req,\n select,\n sort,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n let result = {\n ...paginatedDocs,\n docs: await Promise.all(\n paginatedDocs.docs.map(async (data) => {\n return {\n ...data,\n version: await afterRead<T>({\n collection: null,\n context: req.context,\n depth,\n doc: {\n ...data.version,\n // Patch globalType onto version doc\n globalType: globalConfig.slug,\n },\n draft: undefined,\n fallbackLocale,\n findMany: true,\n global: globalConfig,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n }),\n }\n }),\n ),\n } as PaginatedDocs<T>\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: await Promise.all(\n result.docs.map(async (doc) => {\n const docRef = doc\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n docRef.version =\n (await hook({\n context: req.context,\n doc: doc.version,\n findMany: true,\n global: globalConfig,\n query: fullWhere,\n req,\n })) || doc.version\n }, Promise.resolve())\n\n return docRef\n }),\n ),\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n result = {\n ...result,\n docs: result.docs.map((doc) => sanitizeInternalFields<T>(doc)),\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","afterRead","killTransaction","sanitizeInternalFields","buildVersionGlobalFields","findVersionsOperation","args","depth","globalConfig","limit","overrideAccess","page","pagination","populate","req","fallbackLocale","locale","payload","select","showHiddenFields","sort","where","versionFields","config","accessResults","access","readVersions","fullWhere","paginatedDocs","db","findGlobalVersions","global","slug","result","docs","Promise","all","map","data","version","collection","context","doc","globalType","draft","undefined","findMany","docRef","hooks","reduce","priorHook","hook","query","resolve","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,4BAA4B,4CAA2C;AAC9E,SAASC,wBAAwB,QAAQ,sCAAqC;AAiB9E,OAAO,MAAMC,wBAAwB,OACnCC;IAEA,MAAM,EACJC,KAAK,EACLC,YAAY,EACZC,KAAK,EACLC,cAAc,EACdC,IAAI,EACJC,aAAa,IAAI,EACjBC,QAAQ,EACRC,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAE,EACxCH,GAAG,EACHI,MAAM,EACNC,gBAAgB,EAChBC,IAAI,EACJC,KAAK,EACN,GAAGf;IAEJ,MAAMgB,gBAAgBlB,yBAAyBa,QAAQM,MAAM,EAAEf;IAE/D,IAAI;QACF,wCAAwC;QACxC,SAAS;QACT,wCAAwC;QAExC,MAAMgB,gBAAgB,CAACd,iBACnB,MAAMZ,cAAc;YAAEgB;QAAI,GAAGN,aAAaiB,MAAM,CAACC,YAAY,IAC7D;QAEJ,MAAM1B,mBAAmB;YACvBQ;YACAE;YACAI;YACAQ;YACAD;QACF;QAEA,MAAMM,YAAY5B,eAAesB,OAAOG;QAExC,wC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QACxC,iBAAiB;QACjB,wCAAwC;QAExCd,SAAS;YACP,GAAGA,MAAM;YACTC,MAAMD,OAAOC,IAAI,CAACG,GAAG,CAAC,CAACK,MAAQvC,uBAA0BuC;QAC3D;QAEA,OAAOT;IACT,EAAE,OAAOqB,OAAgB;QACvB,MAAMpD,gBAAgBY;QACtB,MAAMwC;IACR;AACF,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type { Document, PayloadRequest, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
|
|
2
|
+
import type { Document, PayloadRequest, PopulateType, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
|
|
3
3
|
import type { SelectFromGlobalSlug } from '../../config/types.js';
|
|
4
4
|
export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
5
5
|
context?: RequestContext;
|
|
@@ -9,6 +9,7 @@ export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
|
9
9
|
includeLockStatus?: boolean;
|
|
10
10
|
locale?: 'all' | TypedLocale;
|
|
11
11
|
overrideAccess?: boolean;
|
|
12
|
+
populate?: PopulateType;
|
|
12
13
|
req?: PayloadRequest;
|
|
13
14
|
select?: TSelect;
|
|
14
15
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAMjE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS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,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAA8B,YAAY,CACxC,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,oBAAoB,CAAC,KAAK,CAAC,EAE3C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CA8BpD"}
|
|
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { findOneOperation } from '../findOne.js';
|
|
4
4
|
export default async function findOneLocal(payload, options) {
|
|
5
|
-
const { slug: globalSlug, depth, draft = false, includeLockStatus, overrideAccess = true, select, showHiddenFields } = options;
|
|
5
|
+
const { slug: globalSlug, depth, draft = false, includeLockStatus, overrideAccess = true, populate, select, showHiddenFields } = options;
|
|
6
6
|
const globalConfig = payload.globals.config.find((config)=>config.slug === globalSlug);
|
|
7
7
|
if (!globalConfig) {
|
|
8
8
|
throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`);
|
|
@@ -14,6 +14,7 @@ export default async function findOneLocal(payload, options) {
|
|
|
14
14
|
globalConfig,
|
|
15
15
|
includeLockStatus,
|
|
16
16
|
overrideAccess,
|
|
17
|
+
populate,
|
|
17
18
|
req: await createLocalReq(options, payload),
|
|
18
19
|
select,
|
|
19
20
|
showHiddenFields
|