payload 3.0.0-beta.127 → 3.0.0-beta.129
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 +8 -21
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/elements/Cell.d.ts +7 -9
- package/dist/admin/elements/Cell.d.ts.map +1 -1
- package/dist/admin/elements/Cell.js.map +1 -1
- package/dist/admin/fields/Array.d.ts +3 -3
- package/dist/admin/fields/Array.d.ts.map +1 -1
- package/dist/admin/fields/Array.js.map +1 -1
- package/dist/admin/fields/Blocks.d.ts +2 -1
- package/dist/admin/fields/Blocks.d.ts.map +1 -1
- package/dist/admin/fields/Blocks.js.map +1 -1
- package/dist/admin/fields/Checkbox.d.ts +1 -0
- package/dist/admin/fields/Checkbox.d.ts.map +1 -1
- package/dist/admin/fields/Checkbox.js.map +1 -1
- package/dist/admin/fields/Code.d.ts +2 -1
- package/dist/admin/fields/Code.d.ts.map +1 -1
- package/dist/admin/fields/Code.js.map +1 -1
- package/dist/admin/fields/Collapsible.d.ts +5 -2
- package/dist/admin/fields/Collapsible.d.ts.map +1 -1
- package/dist/admin/fields/Collapsible.js.map +1 -1
- package/dist/admin/fields/Date.d.ts +1 -0
- package/dist/admin/fields/Date.d.ts.map +1 -1
- package/dist/admin/fields/Date.js.map +1 -1
- package/dist/admin/fields/Email.d.ts +1 -1
- package/dist/admin/fields/Email.d.ts.map +1 -1
- package/dist/admin/fields/Email.js.map +1 -1
- package/dist/admin/fields/Group.d.ts +5 -2
- package/dist/admin/fields/Group.d.ts.map +1 -1
- package/dist/admin/fields/Group.js.map +1 -1
- package/dist/admin/fields/Hidden.d.ts +7 -6
- package/dist/admin/fields/Hidden.d.ts.map +1 -1
- package/dist/admin/fields/Hidden.js.map +1 -1
- package/dist/admin/fields/JSON.d.ts +1 -0
- package/dist/admin/fields/JSON.d.ts.map +1 -1
- package/dist/admin/fields/JSON.js.map +1 -1
- package/dist/admin/fields/Join.d.ts +3 -1
- package/dist/admin/fields/Join.d.ts.map +1 -1
- package/dist/admin/fields/Join.js.map +1 -1
- package/dist/admin/fields/Number.d.ts +1 -0
- package/dist/admin/fields/Number.d.ts.map +1 -1
- package/dist/admin/fields/Number.js.map +1 -1
- package/dist/admin/fields/Point.d.ts +1 -0
- package/dist/admin/fields/Point.d.ts.map +1 -1
- package/dist/admin/fields/Point.js.map +1 -1
- package/dist/admin/fields/Radio.d.ts +1 -0
- package/dist/admin/fields/Radio.d.ts.map +1 -1
- package/dist/admin/fields/Radio.js.map +1 -1
- package/dist/admin/fields/Relationship.d.ts +1 -0
- package/dist/admin/fields/Relationship.d.ts.map +1 -1
- package/dist/admin/fields/Relationship.js.map +1 -1
- package/dist/admin/fields/RichText.d.ts +3 -2
- package/dist/admin/fields/RichText.d.ts.map +1 -1
- package/dist/admin/fields/RichText.js.map +1 -1
- package/dist/admin/fields/Row.d.ts +1 -2
- package/dist/admin/fields/Row.d.ts.map +1 -1
- package/dist/admin/fields/Row.js.map +1 -1
- package/dist/admin/fields/Select.d.ts +1 -0
- package/dist/admin/fields/Select.d.ts.map +1 -1
- package/dist/admin/fields/Select.js.map +1 -1
- package/dist/admin/fields/Tabs.d.ts +4 -2
- package/dist/admin/fields/Tabs.d.ts.map +1 -1
- package/dist/admin/fields/Tabs.js.map +1 -1
- package/dist/admin/fields/Text.d.ts +1 -0
- package/dist/admin/fields/Text.d.ts.map +1 -1
- package/dist/admin/fields/Text.js.map +1 -1
- package/dist/admin/fields/Textarea.d.ts +1 -0
- package/dist/admin/fields/Textarea.d.ts.map +1 -1
- package/dist/admin/fields/Textarea.js.map +1 -1
- package/dist/admin/fields/UI.d.ts +8 -0
- package/dist/admin/fields/UI.d.ts.map +1 -0
- package/dist/admin/fields/UI.js +3 -0
- package/dist/admin/fields/UI.js.map +1 -0
- package/dist/admin/fields/Upload.d.ts +1 -0
- package/dist/admin/fields/Upload.d.ts.map +1 -1
- package/dist/admin/fields/Upload.js.map +1 -1
- package/dist/admin/forms/Description.d.ts +1 -2
- package/dist/admin/forms/Description.d.ts.map +1 -1
- package/dist/admin/forms/Description.js.map +1 -1
- package/dist/admin/forms/Error.d.ts +0 -2
- package/dist/admin/forms/Error.d.ts.map +1 -1
- package/dist/admin/forms/Error.js.map +1 -1
- package/dist/admin/forms/Field.d.ts +53 -29
- package/dist/admin/forms/Field.d.ts.map +1 -1
- package/dist/admin/forms/Field.js.map +1 -1
- package/dist/admin/forms/Form.d.ts +46 -3
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/forms/Label.d.ts +1 -2
- package/dist/admin/forms/Label.d.ts.map +1 -1
- package/dist/admin/forms/Label.js.map +1 -1
- package/dist/admin/functions/index.d.ts +44 -0
- package/dist/admin/functions/index.d.ts.map +1 -0
- package/dist/admin/functions/index.js +3 -0
- package/dist/admin/functions/index.js.map +1 -0
- package/dist/admin/types.d.ts +63 -20
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js +4 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/types.d.ts +9 -6
- package/dist/admin/views/types.d.ts.map +1 -1
- package/dist/admin/views/types.js.map +1 -1
- package/dist/assets/images/github-banner-nextjs-native.jpg +0 -0
- package/dist/auth/ensureUsernameOrEmail.js +4 -4
- package/dist/auth/ensureUsernameOrEmail.js.map +1 -1
- package/dist/auth/getFieldsToSign.js +13 -13
- package/dist/auth/getFieldsToSign.js.map +1 -1
- package/dist/auth/operations/local/auth.d.ts.map +1 -1
- package/dist/auth/operations/local/auth.js +2 -2
- package/dist/auth/operations/local/auth.js.map +1 -1
- package/dist/auth/operations/login.js +10 -10
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.js +2 -2
- package/dist/auth/strategies/local/generatePasswordSaltHash.js.map +1 -1
- package/dist/auth/strategies/local/register.js +4 -4
- package/dist/auth/strategies/local/register.js.map +1 -1
- package/dist/bin/generateImportMap/index.d.ts.map +1 -1
- package/dist/bin/generateImportMap/index.js +32 -5
- package/dist/bin/generateImportMap/index.js.map +1 -1
- package/dist/bin/generateImportMap/parsePayloadComponent.d.ts +1 -1
- package/dist/bin/generateImportMap/parsePayloadComponent.js +5 -5
- package/dist/bin/generateImportMap/parsePayloadComponent.js.map +1 -1
- package/dist/bin/migrate.js +17 -17
- package/dist/bin/migrate.js.map +1 -1
- package/dist/collections/config/client.d.ts +23 -35
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +104 -1
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +4 -2
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +3 -3
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/countVersions.d.ts +14 -0
- package/dist/collections/operations/countVersions.d.ts.map +1 -0
- package/dist/collections/operations/countVersions.js +74 -0
- package/dist/collections/operations/countVersions.js.map +1 -0
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js +1 -0
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/countVersions.d.ts +20 -0
- package/dist/collections/operations/local/countVersions.d.ts.map +1 -0
- package/dist/collections/operations/local/countVersions.js +20 -0
- package/dist/collections/operations/local/countVersions.js.map +1 -0
- package/dist/collections/operations/local/index.d.ts +2 -0
- package/dist/collections/operations/local/index.d.ts.map +1 -1
- package/dist/collections/operations/local/index.js +2 -0
- package/dist/collections/operations/local/index.js.map +1 -1
- package/dist/collections/operations/utils.d.ts +6 -0
- package/dist/collections/operations/utils.d.ts.map +1 -1
- package/dist/collections/operations/utils.js.map +1 -1
- package/dist/config/client.d.ts +10 -13
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +36 -0
- package/dist/config/client.js.map +1 -1
- package/dist/config/types.d.ts +20 -15
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/getLocalizedPaths.js +1 -1
- package/dist/database/getLocalizedPaths.js.map +1 -1
- package/dist/database/sanitizeJoinQuery.js +6 -6
- package/dist/database/sanitizeJoinQuery.js.map +1 -1
- package/dist/database/types.d.ts +14 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/errors/ValidationError.d.ts +1 -1
- package/dist/errors/ValidationError.d.ts.map +1 -1
- package/dist/errors/ValidationError.js +1 -1
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/exports/shared.d.ts +3 -1
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +3 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/config/client.d.ts +16 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +229 -1
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts +2 -2
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +7 -21
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitizeJoinField.d.ts +2 -2
- package/dist/fields/config/sanitizeJoinField.d.ts.map +1 -1
- package/dist/fields/config/sanitizeJoinField.js +2 -2
- package/dist/fields/config/sanitizeJoinField.js.map +1 -1
- package/dist/fields/config/types.d.ts +28 -171
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/getFieldPaths.d.ts +25 -8
- package/dist/fields/getFieldPaths.d.ts.map +1 -1
- package/dist/fields/getFieldPaths.js +9 -37
- package/dist/fields/getFieldPaths.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 +66 -62
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js +2 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +2 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +107 -103
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- 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.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +8 -5
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +99 -110
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -4
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.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 +47 -43
- package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.js +2 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.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 +105 -101
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js +2 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/globals/config/client.d.ts +18 -25
- package/dist/globals/config/client.d.ts.map +1 -1
- package/dist/globals/config/client.js +53 -1
- package/dist/globals/config/client.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +3 -1
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/operations/countGlobalVersions.d.ts +13 -0
- package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -0
- package/dist/globals/operations/countGlobalVersions.js +49 -0
- package/dist/globals/operations/countGlobalVersions.js.map +1 -0
- package/dist/globals/operations/local/countGlobalVersions.d.ts +20 -0
- package/dist/globals/operations/local/countGlobalVersions.d.ts.map +1 -0
- package/dist/globals/operations/local/countGlobalVersions.js +20 -0
- package/dist/globals/operations/local/countGlobalVersions.js.map +1 -0
- package/dist/globals/operations/local/index.d.ts +2 -0
- package/dist/globals/operations/local/index.d.ts.map +1 -1
- package/dist/globals/operations/local/index.js +2 -0
- package/dist/globals/operations/local/index.js.map +1 -1
- package/dist/index.d.ts +28 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/queues/config/jobsCollection.d.ts.map +1 -1
- package/dist/queues/config/jobsCollection.js +2 -11
- package/dist/queues/config/jobsCollection.js.map +1 -1
- package/dist/queues/config/types/workflowTypes.d.ts +2 -1
- package/dist/queues/config/types/workflowTypes.d.ts.map +1 -1
- package/dist/queues/config/types/workflowTypes.js.map +1 -1
- package/dist/queues/localAPI.d.ts +2 -0
- package/dist/queues/localAPI.d.ts.map +1 -1
- package/dist/queues/localAPI.js +13 -0
- package/dist/queues/localAPI.js.map +1 -1
- package/dist/utilities/configToJSONSchema.js +232 -232
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts +1 -1
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +4 -4
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/deepCopyObject.d.ts +1 -0
- package/dist/utilities/deepCopyObject.d.ts.map +1 -1
- package/dist/utilities/deepCopyObject.js +23 -0
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/fieldSchemaToJSON.js +17 -17
- package/dist/utilities/fieldSchemaToJSON.js.map +1 -1
- package/dist/utilities/formatErrors.d.ts +6 -0
- package/dist/utilities/formatErrors.d.ts.map +1 -0
- package/dist/utilities/formatErrors.js +56 -0
- package/dist/utilities/formatErrors.js.map +1 -0
- package/dist/utilities/telemetry/conf/index.js +2 -2
- package/dist/utilities/telemetry/conf/index.js.map +1 -1
- package/dist/versions/saveVersion.d.ts.map +1 -1
- package/dist/versions/saveVersion.js +1 -7
- package/dist/versions/saveVersion.js.map +1 -1
- package/dist/versions/types.d.ts +1 -1
- package/dist/versions/types.d.ts.map +1 -1
- package/dist/versions/types.js.map +1 -1
- package/license.md +22 -0
- package/package.json +3 -3
- package/dist/utilities/mergeListSearchAndWhere.d.ts +0 -12
- package/dist/utilities/mergeListSearchAndWhere.d.ts.map +0 -1
- package/dist/utilities/mergeListSearchAndWhere.js +0 -57
- package/dist/utilities/mergeListSearchAndWhere.js.map +0 -1
|
@@ -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 { 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,I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A8C,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 fieldIndex: number\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 fieldIndex,\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 index: fieldIndex,\n parentIndexPath: '', // Doesn't matter, as unnamed fields do not affect data, and hooks are only run on fields that affect data\n parentPath: parentPath.join('.'),\n parentSchemaPath: parentSchemaPath.join('.'),\n })\n const fieldPath = _fieldPath ? _fieldPath.split('.') : []\n const fieldSchemaPath = _fieldSchemaPath ? _fieldSchemaPath.split('.') : []\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 'array':\n\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 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 '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 case 'relationship':\n\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 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 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 '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 'collapsible':\n\n case 'row': {\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 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 '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 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 default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","valueIsValueWithRelation","getDefaultValue","getFieldPaths","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","fieldIndex","global","operation","overrideAccess","parentPath","parentSchemaPath","req","siblingData","siblingDoc","path","_fieldPath","schemaPath","_fieldSchemaPath","index","parentIndexPath","join","fieldPath","split","fieldSchemaPath","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","fields","relationshipIDField","collectionField","richTextJSON","JSON","parse","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","previousValue","undefined","Promise","resolve","access","result","defaultValue","locale","user","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","groupData","groupDoc","editor","Error","tabSiblingData","tabSiblingDoc","tabs","tab"],"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;AA0BpD,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,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAChBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAM,EAAEC,MAAMC,UAAU,EAAEC,YAAYC,gBAAgB,EAAE,GAAGvB,cAAc;QACvEU;QACAc,OAAOb;QACPc,iBAAiB;QACjBV,YAAYA,WAAWW,IAA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AQ3C,MAAM2C,MAAM;oBACpBzC;oBACAC;oBACAC;oBACAM,MAAMO;oBACNV;oBACAK,YAAYO;oBACZX,aAAawE;oBACbvE,YAAYwE;gBACd;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX,MAAMxF,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACA4C,QAAQ3C,MAAMkF,IAAI,CAACpD,GAAG,CAAC,CAACqD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE9D,MAAM;wBAAM,CAAA;oBACvDnB;oBACAC;oBACAC;oBACAM,MAAMO;oBACNV;oBACAK,YAAYO;oBACZX;oBACAC;gBACF;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
@@ -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,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,CAA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AAM,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,CAwBxB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promise } from './promise.js';
|
|
2
2
|
export const traverseFields = async ({ id, collection, context, data, doc, fields, global, operation, overrideAccess, path, req, schemaPath, siblingData, siblingDoc })=>{
|
|
3
3
|
const promises = [];
|
|
4
|
-
fields.forEach((field)=>{
|
|
4
|
+
fields.forEach((field, fieldIndex)=>{
|
|
5
5
|
promises.push(promise({
|
|
6
6
|
id,
|
|
7
7
|
collection,
|
|
@@ -9,6 +9,7 @@ export const traverseFields = async ({ id, collection, context, data, doc, field
|
|
|
9
9
|
data,
|
|
10
10
|
doc,
|
|
11
11
|
field,
|
|
12
|
+
fieldIndex,
|
|
12
13
|
global,
|
|
13
14
|
operation,
|
|
14
15
|
overrideAccess,
|
|
@@ -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 { 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;
|
|
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, fieldIndex) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\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","fieldIndex","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,OAAOC;QACrBH,SAASI,IAAI,CACXpB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAY;YACAC;YACAX;YACAC;YACAC;YACAW,YAAYV;YACZW,kBAAkBT;YAClBD;YACAE;YACAC;QACF;IAEJ;IACA,MAAMQ,QAAQC,GAAG,CAACR;AACpB,EAAC"}
|
|
@@ -1,33 +1,26 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { ClientField } from '../../fields/config/client.js';
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { LivePreviewConfig, SanitizedConfig, ServerOnlyLivePreviewProperties } from '../../config/types.js';
|
|
3
|
+
import type { Payload } from '../../types/index.js';
|
|
5
4
|
import type { SanitizedGlobalConfig } from './types.js';
|
|
5
|
+
import { type ClientField } from '../../fields/config/client.js';
|
|
6
6
|
export type ServerOnlyGlobalProperties = keyof Pick<SanitizedGlobalConfig, 'access' | 'admin' | 'custom' | 'endpoints' | 'fields' | 'hooks'>;
|
|
7
|
-
export type ServerOnlyGlobalAdminProperties = keyof Pick<SanitizedGlobalConfig['admin'], 'hidden'
|
|
7
|
+
export type ServerOnlyGlobalAdminProperties = keyof Pick<SanitizedGlobalConfig['admin'], 'hidden'>;
|
|
8
8
|
export type ClientGlobalConfig = {
|
|
9
|
-
_isPreviewEnabled?: true;
|
|
10
9
|
admin: {
|
|
11
|
-
components:
|
|
12
|
-
elements: {
|
|
13
|
-
PreviewButton: MappedComponent;
|
|
14
|
-
PublishButton: MappedComponent;
|
|
15
|
-
SaveButton: MappedComponent;
|
|
16
|
-
SaveDraftButton: MappedComponent;
|
|
17
|
-
};
|
|
18
|
-
views: {
|
|
19
|
-
edit: {
|
|
20
|
-
[key: string]: MappedView;
|
|
21
|
-
api: MappedView;
|
|
22
|
-
default: MappedView;
|
|
23
|
-
livePreview: MappedView;
|
|
24
|
-
version: MappedView;
|
|
25
|
-
versions: MappedView;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
10
|
+
components: null;
|
|
29
11
|
livePreview?: Omit<LivePreviewConfig, ServerOnlyLivePreviewProperties>;
|
|
30
|
-
|
|
12
|
+
preview?: boolean;
|
|
13
|
+
} & Omit<SanitizedGlobalConfig['admin'], 'components' | 'livePreview' | 'preview' | ServerOnlyGlobalAdminProperties>;
|
|
31
14
|
fields: ClientField[];
|
|
32
15
|
} & Omit<SanitizedGlobalConfig, 'admin' | 'fields' | ServerOnlyGlobalProperties>;
|
|
16
|
+
export declare const createClientGlobalConfig: ({ defaultIDType, global, i18n, }: {
|
|
17
|
+
defaultIDType: Payload["config"]["db"]["defaultIDType"];
|
|
18
|
+
global: SanitizedConfig["globals"][0];
|
|
19
|
+
i18n: I18nClient;
|
|
20
|
+
}) => ClientGlobalConfig;
|
|
21
|
+
export declare const createClientGlobalConfigs: ({ defaultIDType, globals, i18n, }: {
|
|
22
|
+
defaultIDType: Payload["config"]["db"]["defaultIDType"];
|
|
23
|
+
globals: SanitizedConfig["globals"];
|
|
24
|
+
i18n: I18nClient;
|
|
25
|
+
}) => ClientGlobalConfig[];
|
|
33
26
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/globals/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/globals/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,+BAA+B,EAChC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,+BAA+B,CAAA;AAGpF,MAAM,MAAM,0BAA0B,GAAG,MAAM,IAAI,CACjD,qBAAqB,EACrB,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CACjE,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAA;AAElG,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE;QACL,UAAU,EAAE,IAAI,CAAA;QAChB,WAAW,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,+BAA+B,CAAC,CAAA;QACtE,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,GAAG,IAAI,CACN,qBAAqB,CAAC,OAAO,CAAC,EAC9B,YAAY,GAAG,aAAa,GAAG,SAAS,GAAG,+BAA+B,CAC3E,CAAA;IACD,MAAM,EAAE,WAAW,EAAE,CAAA;CACtB,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,QAAQ,GAAG,0BAA0B,CAAC,CAAA;AAYhF,eAAO,MAAM,wBAAwB,qCAIlC;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACrC,IAAI,EAAE,UAAU,CAAA;CACjB,KAAG,kBAyCH,CAAA;AAED,eAAO,MAAM,yBAAyB,sCAInC;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACnC,IAAI,EAAE,UAAU,CAAA;CACjB,KAAG,kBAAkB,EAcrB,CAAA"}
|
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
import { createClientFields } from '../../fields/config/client.js';
|
|
2
|
+
import { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js';
|
|
3
|
+
const serverOnlyProperties = [
|
|
4
|
+
'hooks',
|
|
5
|
+
'access',
|
|
6
|
+
'endpoints',
|
|
7
|
+
'custom'
|
|
8
|
+
];
|
|
9
|
+
const serverOnlyGlobalAdminProperties = [
|
|
10
|
+
'hidden'
|
|
11
|
+
];
|
|
12
|
+
export const createClientGlobalConfig = ({ defaultIDType, global, i18n })=>{
|
|
13
|
+
const clientGlobal = deepCopyObjectSimple(global);
|
|
14
|
+
clientGlobal.fields = createClientFields({
|
|
15
|
+
clientFields: clientGlobal?.fields || [],
|
|
16
|
+
defaultIDType,
|
|
17
|
+
fields: global.fields,
|
|
18
|
+
i18n
|
|
19
|
+
});
|
|
20
|
+
serverOnlyProperties.forEach((key)=>{
|
|
21
|
+
if (key in clientGlobal) {
|
|
22
|
+
delete clientGlobal[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (!clientGlobal.admin) {
|
|
26
|
+
clientGlobal.admin = {};
|
|
27
|
+
}
|
|
28
|
+
serverOnlyGlobalAdminProperties.forEach((key)=>{
|
|
29
|
+
if (key in clientGlobal.admin) {
|
|
30
|
+
delete clientGlobal.admin[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (global.admin.preview) {
|
|
34
|
+
clientGlobal.admin.preview = true;
|
|
35
|
+
}
|
|
36
|
+
clientGlobal.admin.components = null;
|
|
37
|
+
if ('livePreview' in clientGlobal.admin && clientGlobal.admin.livePreview && 'url' in clientGlobal.admin.livePreview) {
|
|
38
|
+
delete clientGlobal.admin.livePreview.url;
|
|
39
|
+
}
|
|
40
|
+
return clientGlobal;
|
|
41
|
+
};
|
|
42
|
+
export const createClientGlobalConfigs = ({ defaultIDType, globals, i18n })=>{
|
|
43
|
+
const clientGlobals = new Array(globals.length);
|
|
44
|
+
for(let i = 0; i < globals.length; i++){
|
|
45
|
+
const global = globals[i];
|
|
46
|
+
clientGlobals[i] = createClientGlobalConfig({
|
|
47
|
+
defaultIDType,
|
|
48
|
+
global,
|
|
49
|
+
i18n
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return clientGlobals;
|
|
53
|
+
};
|
|
2
54
|
|
|
3
55
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/config/client.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/config/client.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport type {\n LivePreviewConfig,\n SanitizedConfig,\n ServerOnlyLivePreviewProperties,\n} from '../../config/types.js'\nimport type { Payload } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from './types.js'\n\nimport { type ClientField, createClientFields } from '../../fields/config/client.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\n\nexport type ServerOnlyGlobalProperties = keyof Pick<\n SanitizedGlobalConfig,\n 'access' | 'admin' | 'custom' | 'endpoints' | 'fields' | 'hooks'\n>\n\nexport type ServerOnlyGlobalAdminProperties = keyof Pick<SanitizedGlobalConfig['admin'], 'hidden'>\n\nexport type ClientGlobalConfig = {\n admin: {\n components: null\n livePreview?: Omit<LivePreviewConfig, ServerOnlyLivePreviewProperties>\n preview?: boolean\n } & Omit<\n SanitizedGlobalConfig['admin'],\n 'components' | 'livePreview' | 'preview' | ServerOnlyGlobalAdminProperties\n >\n fields: ClientField[]\n} & Omit<SanitizedGlobalConfig, 'admin' | 'fields' | ServerOnlyGlobalProperties>\n\nconst serverOnlyProperties: Partial<ServerOnlyGlobalProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n // `admin` is handled separately\n]\n\nconst serverOnlyGlobalAdminProperties: Partial<ServerOnlyGlobalAdminProperties>[] = ['hidden']\n\nexport const createClientGlobalConfig = ({\n defaultIDType,\n global,\n i18n,\n}: {\n defaultIDType: Payload['config']['db']['defaultIDType']\n global: SanitizedConfig['globals'][0]\n i18n: I18nClient\n}): ClientGlobalConfig => {\n const clientGlobal = deepCopyObjectSimple(global) as unknown as ClientGlobalConfig\n\n clientGlobal.fields = createClientFields({\n clientFields: clientGlobal?.fields || [],\n defaultIDType,\n fields: global.fields,\n i18n,\n })\n\n serverOnlyProperties.forEach((key) => {\n if (key in clientGlobal) {\n delete clientGlobal[key]\n }\n })\n\n if (!clientGlobal.admin) {\n clientGlobal.admin = {} as ClientGlobalConfig['admin']\n }\n\n serverOnlyGlobalAdminProperties.forEach((key) => {\n if (key in clientGlobal.admin) {\n delete clientGlobal.admin[key]\n }\n })\n\n if (global.admin.preview) {\n clientGlobal.admin.preview = true\n }\n\n clientGlobal.admin.components = null\n\n if (\n 'livePreview' in clientGlobal.admin &&\n clientGlobal.admin.livePreview &&\n 'url' in clientGlobal.admin.livePreview\n ) {\n delete clientGlobal.admin.livePreview.url\n }\n\n return clientGlobal\n}\n\nexport const createClientGlobalConfigs = ({\n defaultIDType,\n globals,\n i18n,\n}: {\n defaultIDType: Payload['config']['db']['defaultIDType']\n globals: SanitizedConfig['globals']\n i18n: I18nClient\n}): ClientGlobalConfig[] => {\n const clientGlobals = new Array(globals.length)\n\n for (let i = 0; i < globals.length; i++) {\n const global = globals[i]\n\n clientGlobals[i] = createClientGlobalConfig({\n defaultIDType,\n global,\n i18n,\n })\n }\n\n return clientGlobals\n}\n"],"names":["createClientFields","deepCopyObjectSimple","serverOnlyProperties","serverOnlyGlobalAdminProperties","createClientGlobalConfig","defaultIDType","global","i18n","clientGlobal","fields","clientFields","forEach","key","admin","preview","components","livePreview","url","createClientGlobalConfigs","globals","clientGlobals","Array","length","i"],"mappings":"AAUA,SAA2BA,kBAAkB,QAAQ,gCAA+B;AACpF,SAASC,oBAAoB,QAAQ,oCAAmC;AAqBxE,MAAMC,uBAA8D;IAClE;IACA;IACA;IACA;CAED;AAED,MAAMC,kCAA8E;IAAC;CAAS;AAE9F,OAAO,MAAMC,2BAA2B,CAAC,EACvCC,aAAa,EACbC,MAAM,EACNC,IAAI,EAKL;IACC,MAAMC,eAAeP,qBAAqBK;IAE1CE,aAAaC,MAAM,GAAGT,mBAAmB;QACvCU,cAAcF,cAAcC,UAAU,EAAE;QACxCJ;QACAI,QAAQH,OAAOG,MAAM;QACrBF;IACF;IAEAL,qBAAqBS,OAAO,CAAC,CAACC;QAC5B,IAAIA,OAAOJ,cAAc;YACvB,OAAOA,YAAY,CAACI,IAAI;QAC1B;IACF;IAEA,IAAI,CAACJ,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
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/globals/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAUvD,eAAO,MAAM,eAAe,WAClB,MAAM,iCAKiB,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,KAC/E,OAAO,CAAC,qBAAqB,EAAE,CAmIjC,CAAA"}
|
|
@@ -59,9 +59,11 @@ export const sanitizeGlobals = async (config, /**
|
|
|
59
59
|
if (global.versions) {
|
|
60
60
|
if (global.versions === true) {
|
|
61
61
|
global.versions = {
|
|
62
|
-
drafts: false
|
|
62
|
+
drafts: false,
|
|
63
|
+
max: 100
|
|
63
64
|
};
|
|
64
65
|
}
|
|
66
|
+
global.versions.max = typeof global.versions.max === 'number' ? global.versions.max : 100;
|
|
65
67
|
if (global.versions.drafts) {
|
|
66
68
|
if (global.versions.drafts === true) {
|
|
67
69
|
global.versions.drafts = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from './types.js'\n\nimport defaultAccess from '../../auth/defaultAccess.js'\nimport { sanitizeFields } from '../../fields/config/sanitize.js'\nimport { fieldAffectsData } from '../../fields/config/types.js'\nimport mergeBaseFields from '../../fields/mergeBaseFields.js'\nimport { toWords } from '../../utilities/formatLabels.js'\nimport baseVersionFields from '../../versions/baseFields.js'\nimport { versionDefaults } from '../../versions/defaults.js'\n\nexport const sanitizeGlobals = async (\n config: Config,\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>,\n): Promise<SanitizedGlobalConfig[]> => {\n const { collections, globals } = config\n\n for (let i = 0; i < globals.length; i++) {\n const global = globals[i]\n global.label = global.label || toWords(global.slug)\n\n // /////////////////////////////////\n // Ensure that collection has required object structure\n // /////////////////////////////////\n\n global.endpoints = global.endpoints ?? []\n if (!global.hooks) {\n global.hooks = {}\n }\n if (!global.access) {\n global.access = {}\n }\n if (!global.admin) {\n global.admin = {}\n }\n\n if (!global.access.read) {\n global.access.read = defaultAccess\n }\n if (!global.access.update) {\n global.access.update = defaultAccess\n }\n\n if (!global.hooks.beforeValidate) {\n global.hooks.beforeValidate = []\n }\n if (!global.hooks.beforeChange) {\n global.hooks.beforeChange = []\n }\n if (!global.hooks.afterChange) {\n global.hooks.afterChange = []\n }\n if (!global.hooks.beforeRead) {\n global.hooks.beforeRead = []\n }\n if (!global.hooks.afterRead) {\n global.hooks.afterRead = []\n }\n\n // Sanitize fields\n const validRelationships = collections.map((c) => c.slug) || []\n global.fields = await sanitizeFields({\n config,\n fields: global.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n if (global.versions) {\n if (global.versions === true) {\n global.versions = { drafts: false }\n }\n\n if (global.versions.drafts) {\n if (global.versions.drafts === true) {\n global.versions.drafts = {\n autosave: false,\n validate: false,\n }\n }\n\n if (global.versions.drafts.autosave === true) {\n global.versions.drafts.autosave = {\n interval: versionDefaults.autosaveInterval,\n }\n }\n\n if (global.versions.drafts.validate === undefined) {\n global.versions.drafts.validate = false\n }\n\n global.fields = mergeBaseFields(global.fields, baseVersionFields)\n }\n }\n\n if (!global.custom) {\n global.custom = {}\n }\n\n // /////////////////////////////////\n // Sanitize fields\n // /////////////////////////////////\n let hasUpdatedAt = null\n let hasCreatedAt = null\n global.fields.some((field) => {\n if (fieldAffectsData(field)) {\n if (field.name === 'updatedAt') {\n hasUpdatedAt = true\n }\n if (field.name === 'createdAt') {\n hasCreatedAt = true\n }\n }\n return hasCreatedAt && hasUpdatedAt\n })\n if (!hasUpdatedAt) {\n global.fields.push({\n name: 'updatedAt',\n type: 'date',\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n label: ({ t }) => t('general:updatedAt'),\n })\n }\n if (!hasCreatedAt) {\n global.fields.push({\n name: 'createdAt',\n type: 'date',\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n label: ({ t }) => t('general:createdAt'),\n })\n }\n\n globals[i] = global\n }\n\n return globals as SanitizedGlobalConfig[]\n}\n"],"names":["defaultAccess","sanitizeFields","fieldAffectsData","mergeBaseFields","toWords","baseVersionFields","versionDefaults","sanitizeGlobals","config","richTextSanitizationPromises","collections","globals","i","length","global","label","slug","endpoints","hooks","access","admin","read","update","beforeValidate","beforeChange","afterChange","beforeRead","afterRead","validRelationships","map","c","fields","parentIsLocalized","versions","drafts","autosave","validate","interval","autosaveInterval","undefined","custom","hasUpdatedAt","hasCreatedAt","some","field","name","push","type","disableBulkEdit","hidden","t"],"mappings":"AAGA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,kCAAiC;AAChE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,OAAOC,qBAAqB,kCAAiC;AAC7D,SAASC,OAAO,QAAQ,kCAAiC;AACzD,OAAOC,uBAAuB,+BAA8B;AAC5D,SAASC,eAAe,QAAQ,6BAA4B;AAE5D,OAAO,MAAMC,kBAAkB,OAC7BC,QACA;;;GAGC,GACDC;IAEA,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAE,GAAGH;IAEjC,IAAK,IAAII,IAAI,GAAGA,IAAID,QAAQE,MAAM,EAAED,IAAK;QACvC,MAAME,SAASH,OAAO,CAACC,EAAE;QACzBE,OAAOC,KAAK,GAAGD,OAAOC,KAAK,IAAIX,QAAQU,OAAOE,IAAI;QAElD,oCAAoC;QACpC,uDAAuD;QACvD,oCAAoC;QAEpCF,OAAOG,SAAS,GAAGH,OAAOG,SAAS,IAAI,EAAE;QACzC,IAAI,CAACH,OAA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EC,QAAQ;
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from './types.js'\n\nimport defaultAccess from '../../auth/defaultAccess.js'\nimport { sanitizeFields } from '../../fields/config/sanitize.js'\nimport { fieldAffectsData } from '../../fields/config/types.js'\nimport mergeBaseFields from '../../fields/mergeBaseFields.js'\nimport { toWords } from '../../utilities/formatLabels.js'\nimport baseVersionFields from '../../versions/baseFields.js'\nimport { versionDefaults } from '../../versions/defaults.js'\n\nexport const sanitizeGlobals = async (\n config: Config,\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>,\n): Promise<SanitizedGlobalConfig[]> => {\n const { collections, globals } = config\n\n for (let i = 0; i < globals.length; i++) {\n const global = globals[i]\n global.label = global.label || toWords(global.slug)\n\n // /////////////////////////////////\n // Ensure that collection has required object structure\n // /////////////////////////////////\n\n global.endpoints = global.endpoints ?? []\n if (!global.hooks) {\n global.hooks = {}\n }\n if (!global.access) {\n global.access = {}\n }\n if (!global.admin) {\n global.admin = {}\n }\n\n if (!global.access.read) {\n global.access.read = defaultAccess\n }\n if (!global.access.update) {\n global.access.update = defaultAccess\n }\n\n if (!global.hooks.beforeValidate) {\n global.hooks.beforeValidate = []\n }\n if (!global.hooks.beforeChange) {\n global.hooks.beforeChange = []\n }\n if (!global.hooks.afterChange) {\n global.hooks.afterChange = []\n }\n if (!global.hooks.beforeRead) {\n global.hooks.beforeRead = []\n }\n if (!global.hooks.afterRead) {\n global.hooks.afterRead = []\n }\n\n // Sanitize fields\n const validRelationships = collections.map((c) => c.slug) || []\n global.fields = await sanitizeFields({\n config,\n fields: global.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n if (global.versions) {\n if (global.versions === true) {\n global.versions = { drafts: false, max: 100 }\n }\n\n global.versions.max = typeof global.versions.max === 'number' ? global.versions.max : 100\n\n if (global.versions.drafts) {\n if (global.versions.drafts === true) {\n global.versions.drafts = {\n autosave: false,\n validate: false,\n }\n }\n\n if (global.versions.drafts.autosave === true) {\n global.versions.drafts.autosave = {\n interval: versionDefaults.autosaveInterval,\n }\n }\n\n if (global.versions.drafts.validate === undefined) {\n global.versions.drafts.validate = false\n }\n\n global.fields = mergeBaseFields(global.fields, baseVersionFields)\n }\n }\n\n if (!global.custom) {\n global.custom = {}\n }\n\n // /////////////////////////////////\n // Sanitize fields\n // /////////////////////////////////\n let hasUpdatedAt = null\n let hasCreatedAt = null\n global.fields.some((field) => {\n if (fieldAffectsData(field)) {\n if (field.name === 'updatedAt') {\n hasUpdatedAt = true\n }\n if (field.name === 'createdAt') {\n hasCreatedAt = true\n }\n }\n return hasCreatedAt && hasUpdatedAt\n })\n if (!hasUpdatedAt) {\n global.fields.push({\n name: 'updatedAt',\n type: 'date',\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n label: ({ t }) => t('general:updatedAt'),\n })\n }\n if (!hasCreatedAt) {\n global.fields.push({\n name: 'createdAt',\n type: 'date',\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n label: ({ t }) => t('general:createdAt'),\n })\n }\n\n globals[i] = global\n }\n\n return globals as SanitizedGlobalConfig[]\n}\n"],"names":["defaultAccess","sanitizeFields","fieldAffectsData","mergeBaseFields","toWords","baseVersionFields","versionDefaults","sanitizeGlobals","config","richTextSanitizationPromises","collections","globals","i","length","global","label","slug","endpoints","hooks","access","admin","read","update","beforeValidate","beforeChange","afterChange","beforeRead","afterRead","validRelationships","map","c","fields","parentIsLocalized","versions","drafts","max","autosave","validate","interval","autosaveInterval","undefined","custom","hasUpdatedAt","hasCreatedAt","some","field","name","push","type","disableBulkEdit","hidden","t"],"mappings":"AAGA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,kCAAiC;AACh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B,OAAOiB,MAAM,GAAG5B,gBAAgBW,OAAOiB,MAAM,EAAE1B;YACjD;QACF;QAEA,IAAI,CAACS,OAAO2B,MAAM,EAAE;YAClB3B,OAAO2B,MAAM,GAAG,CAAC;QACnB;QAEA,oCAAoC;QACpC,kBAAkB;QAClB,oCAAoC;QACpC,IAAIC,eAAe;QACnB,IAAIC,eAAe;QACnB7B,OAAOiB,MAAM,CAACa,IAAI,CAAC,CAACC;YAClB,IAAI3C,iBAAiB2C,QAAQ;gBAC3B,IAAIA,MAAMC,IAAI,KAAK,aAAa;oBAC9BJ,eAAe;gBACjB;gBACA,IAAIG,MAAMC,IAAI,KAAK,aAAa;oBAC9BH,eAAe;gBACjB;YACF;YACA,OAAOA,gBAAgBD;QACzB;QACA,IAAI,CAACA,cAAc;YACjB5B,OAAOiB,MAAM,CAACgB,IAAI,CAAC;gBACjBD,MAAM;gBACNE,MAAM;gBACN5B,OAAO;oBACL6B,iBAAiB;oBACjBC,QAAQ;gBACV;gBACAnC,OAAO,CAAC,EAAEoC,CAAC,EAAE,GAAKA,EAAE;YACtB;QACF;QACA,IAAI,CAACR,cAAc;YACjB7B,OAAOiB,MAAM,CAACgB,IAAI,CAAC;gBACjBD,MAAM;gBACNE,MAAM;gBACN5B,OAAO;oBACL6B,iBAAiB;oBACjBC,QAAQ;gBACV;gBACAnC,OAAO,CAAC,EAAEoC,CAAC,EAAE,GAAKA,EAAE;YACtB;QACF;QAEAxC,OAAO,CAACC,EAAE,GAAGE;IACf;IAEA,OAAOH;AACT,EAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PayloadRequest, Where } from '../../types/index.js';
|
|
2
|
+
import { type GlobalSlug, type SanitizedGlobalConfig } from '../../index.js';
|
|
3
|
+
export type Arguments = {
|
|
4
|
+
disableErrors?: boolean;
|
|
5
|
+
global: SanitizedGlobalConfig;
|
|
6
|
+
overrideAccess?: boolean;
|
|
7
|
+
req?: PayloadRequest;
|
|
8
|
+
where?: Where;
|
|
9
|
+
};
|
|
10
|
+
export declare const countGlobalVersionsOperation: <TSlug extends GlobalSlug>(args: Arguments) => Promise<{
|
|
11
|
+
totalDocs: number;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=countGlobalVersions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countGlobalVersions.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/countGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAKjE,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAGvB,MAAM,MAAM,SAAS,GAAG;IACtB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,qBAAqB,CAAA;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,eAAO,MAAM,4BAA4B,GAAU,KAAK,SAAS,UAAU,QACnE,SAAS,KACd,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAuD/B,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import executeAccess from '../../auth/executeAccess.js';
|
|
2
|
+
import { combineQueries } from '../../database/combineQueries.js';
|
|
3
|
+
import { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js';
|
|
4
|
+
import { buildVersionGlobalFields } from '../../index.js';
|
|
5
|
+
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
6
|
+
export const countGlobalVersionsOperation = async (args)=>{
|
|
7
|
+
try {
|
|
8
|
+
const { disableErrors, global, overrideAccess, req: { payload }, req, where } = args;
|
|
9
|
+
// /////////////////////////////////////
|
|
10
|
+
// Access
|
|
11
|
+
// /////////////////////////////////////
|
|
12
|
+
let accessResult;
|
|
13
|
+
if (!overrideAccess) {
|
|
14
|
+
accessResult = await executeAccess({
|
|
15
|
+
disableErrors,
|
|
16
|
+
req
|
|
17
|
+
}, global.access.readVersions);
|
|
18
|
+
// If errors are disabled, and access returns false, return empty results
|
|
19
|
+
if (accessResult === false) {
|
|
20
|
+
return {
|
|
21
|
+
totalDocs: 0
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const fullWhere = combineQueries(where, accessResult);
|
|
26
|
+
const versionFields = buildVersionGlobalFields(payload.config, global);
|
|
27
|
+
await validateQueryPaths({
|
|
28
|
+
globalConfig: global,
|
|
29
|
+
overrideAccess,
|
|
30
|
+
req,
|
|
31
|
+
versionFields,
|
|
32
|
+
where
|
|
33
|
+
});
|
|
34
|
+
const result = await payload.db.countGlobalVersions({
|
|
35
|
+
global: global.slug,
|
|
36
|
+
req,
|
|
37
|
+
where: fullWhere
|
|
38
|
+
});
|
|
39
|
+
// /////////////////////////////////////
|
|
40
|
+
// Return results
|
|
41
|
+
// /////////////////////////////////////
|
|
42
|
+
return result;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
await killTransaction(args.req);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=countGlobalVersions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/countGlobalVersions.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport {\n buildVersionGlobalFields,\n type GlobalSlug,\n type SanitizedGlobalConfig,\n} from '../../index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n disableErrors?: boolean\n global: SanitizedGlobalConfig\n overrideAccess?: boolean\n req?: PayloadRequest\n where?: Where\n}\n\nexport const countGlobalVersionsOperation = async <TSlug extends GlobalSlug>(\n args: Arguments,\n): Promise<{ totalDocs: number }> => {\n try {\n const {\n disableErrors,\n global,\n overrideAccess,\n req: { payload },\n req,\n where,\n } = args\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ disableErrors, req }, global.access.readVersions)\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n totalDocs: 0,\n }\n }\n }\n\n const fullWhere = combineQueries(where, accessResult)\n\n const versionFields = buildVersionGlobalFields(payload.config, global)\n\n await validateQueryPaths({\n globalConfig: global,\n overrideAccess,\n req,\n versionFields,\n where,\n })\n\n const result = await payload.db.countGlobalVersions({\n global: global.slug,\n req,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","buildVersionGlobalFields","killTransaction","countGlobalVersionsOperation","args","disableErrors","global","overrideAccess","req","payload","where","accessResult","access","readVersions","totalDocs","fullWhere","versionFields","config","globalConfig","result","db","countGlobalVersions","slug","error"],"mappings":"AAGA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SACEC,wBAAwB,QAGnB,iBAAgB;AACvB,SAASC,eAAe,QAAQ,qCAAoC;AAUpE,OAAO,MAAMC,+BAA+B,OAC1CC;IAEA,IAAI;QACF,MAAM,EACJC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,KAAK,EAAEC,OAAO,EAAE,EAChBD,GAAG,EACHE,KAAK,EACN,GAAGN;QAEJ,wCAAwC;QACxC,SAAS;QACT,wCAAwC;QAExC,IAAIO;QAEJ,IAAI,CAACJ,gBAAgB;YACnBI,eAAe,MAAMb,cAAc;gBAAEO;gBAAeG;YAAI,GAAGF,OAAOM,MAAM,CAACC,YAAY;YAErF,yEAAyE;YACzE,IAAIF,iBAAiB,OAAO;gBAC1B,OAAO;oBACLG,WAAW;gBACb;YACF;QACF;QAEA,MAAMC,YAAYhB,eAAeW,OAAOC;QAExC,MAAMK,gBAAgBf,yBAAyBQ,QAAQQ,MAAM,EAAEX;QAE/D,MAAMN,mBAAmB;YACvBkB,cAAcZ;YACdC;YACAC;YACAQ;YACAN;QACF;QAEA,MAAMS,SAAS,MAAMV,QAAQW,EAAE,CAACC,mBAAmB,CAAC;YAClDf,QAAQA,OAAOgB,IAAI;YACnBd;YACAE,OAAOK;QACT;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOI;IACT,EAAE,OAAOI,OAAgB;QACvB,MAAMrB,gBAAgBE,KAAKI,GAAG;QAC9B,MAAMe;IACR;AACF,EAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
+
import type { Document, PayloadRequest, Where } from '../../../types/index.js';
|
|
3
|
+
export type CountGlobalVersionsOptions<TSlug extends GlobalSlug> = {
|
|
4
|
+
/**
|
|
5
|
+
* context, which will then be passed to req.context, which can be read by hooks
|
|
6
|
+
*/
|
|
7
|
+
context?: RequestContext;
|
|
8
|
+
depth?: number;
|
|
9
|
+
disableErrors?: boolean;
|
|
10
|
+
global: TSlug;
|
|
11
|
+
locale?: TypedLocale;
|
|
12
|
+
overrideAccess?: boolean;
|
|
13
|
+
req?: PayloadRequest;
|
|
14
|
+
user?: Document;
|
|
15
|
+
where?: Where;
|
|
16
|
+
};
|
|
17
|
+
export default function countGlobalVersionsLocal<TSlug extends GlobalSlug>(payload: Payload, options: CountGlobalVersionsOptions<TSlug>): Promise<{
|
|
18
|
+
totalDocs: number;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=countGlobalVersions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countGlobalVersions.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/countGlobalVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAM9E,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,UAAU,IAAI;IACjE;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,KAAK,CAAA;IACb,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAGD,wBAA8B,wBAAwB,CAAC,KAAK,SAAS,UAAU,EAC7E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,0BAA0B,CAAC,KAAK,CAAC,GACzC,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBhC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { APIError } from '../../../errors/index.js';
|
|
2
|
+
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
|
+
import { countGlobalVersionsOperation } from '../countGlobalVersions.js';
|
|
4
|
+
// eslint-disable-next-line no-restricted-exports
|
|
5
|
+
export default async function countGlobalVersionsLocal(payload, options) {
|
|
6
|
+
const { disableErrors, global: globalSlug, overrideAccess = true, where } = options;
|
|
7
|
+
const global = payload.globals.config.find(({ slug })=>slug === globalSlug);
|
|
8
|
+
if (!global) {
|
|
9
|
+
throw new APIError(`The global with slug ${String(globalSlug)} can't be found. Count Global Versions Operation.`);
|
|
10
|
+
}
|
|
11
|
+
return countGlobalVersionsOperation({
|
|
12
|
+
disableErrors,
|
|
13
|
+
global,
|
|
14
|
+
overrideAccess,
|
|
15
|
+
req: await createLocalReq(options, payload),
|
|
16
|
+
where
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=countGlobalVersions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/countGlobalVersions.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countGlobalVersionsOperation } from '../countGlobalVersions.js'\n\nexport type CountGlobalVersionsOptions<TSlug extends GlobalSlug> = {\n /**\n * context, which will then be passed to req.context, which can be read by hooks\n */\n context?: RequestContext\n depth?: number\n disableErrors?: boolean\n global: TSlug\n locale?: TypedLocale\n overrideAccess?: boolean\n req?: PayloadRequest\n user?: Document\n where?: Where\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default async function countGlobalVersionsLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: CountGlobalVersionsOptions<TSlug>,\n): Promise<{ totalDocs: number }> {\n const { disableErrors, global: globalSlug, overrideAccess = true, where } = options\n\n const global = payload.globals.config.find(({ slug }) => slug === globalSlug)\n\n if (!global) {\n throw new APIError(\n `The global with slug ${String(globalSlug)} can't be found. Count Global Versions Operation.`,\n )\n }\n\n return countGlobalVersionsOperation<TSlug>({\n disableErrors,\n global,\n overrideAccess,\n req: await createLocalReq(options, payload),\n where,\n })\n}\n"],"names":["APIError","createLocalReq","countGlobalVersionsOperation","countGlobalVersionsLocal","payload","options","disableErrors","global","globalSlug","overrideAccess","where","globals","config","find","slug","String","req"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,4BAA4B,QAAQ,4BAA2B;AAiBxE,iDAAiD;AACjD,eAAe,eAAeC,yBAC5BC,OAAgB,EAChBC,OAA0C;IAE1C,MAAM,EAAEC,aAAa,EAAEC,QAAQC,UAAU,EAAEC,iBAAiB,IAAI,EAAEC,KAAK,EAAE,GAAGL;IAE5E,MAAME,SAASH,QAAQO,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASN;IAElE,IAAI,CAACD,QAAQ;QACX,MAAM,IAAIP,SACR,CAAC,qBAAqB,EAAEe,OAAOP,YAAY,iDAAiD,CAAC;IAEjG;IAEA,OAAON,6BAAoC;QACzCI;QACAC;QACAE;QACAO,KAAK,MAAMf,eAAeI,SAASD;QACnCM;IACF;AACF"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import countGlobalVersions from './countGlobalVersions.js';
|
|
1
2
|
import findOne from './findOne.js';
|
|
2
3
|
import findVersionByID from './findVersionByID.js';
|
|
3
4
|
import findVersions from './findVersions.js';
|
|
4
5
|
import restoreVersion from './restoreVersion.js';
|
|
5
6
|
import update from './update.js';
|
|
6
7
|
declare const _default: {
|
|
8
|
+
countGlobalVersions: typeof countGlobalVersions;
|
|
7
9
|
findOne: typeof findOne;
|
|
8
10
|
findVersionByID: typeof findVersionByID;
|
|
9
11
|
findVersions: typeof findVersions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,eAAe,MAAM,sBAAsB,CAAA;AAClD,OAAO,YAAY,MAAM,mBAAmB,CAAA;AAC5C,OAAO,cAAc,MAAM,qBAAqB,CAAA;AAChD,OAAO,MAAM,MAAM,aAAa,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,0BAA0B,CAAA;AAC1D,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,eAAe,MAAM,sBAAsB,CAAA;AAClD,OAAO,YAAY,MAAM,mBAAmB,CAAA;AAC5C,OAAO,cAAc,MAAM,qBAAqB,CAAA;AAChD,OAAO,MAAM,MAAM,aAAa,CAAA;;;;;;;;;AAEhC,wBAOC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import countGlobalVersions from './countGlobalVersions.js';
|
|
1
2
|
import findOne from './findOne.js';
|
|
2
3
|
import findVersionByID from './findVersionByID.js';
|
|
3
4
|
import findVersions from './findVersions.js';
|
|
4
5
|
import restoreVersion from './restoreVersion.js';
|
|
5
6
|
import update from './update.js';
|
|
6
7
|
export default {
|
|
8
|
+
countGlobalVersions,
|
|
7
9
|
findOne,
|
|
8
10
|
findVersionByID,
|
|
9
11
|
findVersions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/index.ts"],"sourcesContent":["import findOne from './findOne.js'\nimport findVersionByID from './findVersionByID.js'\nimport findVersions from './findVersions.js'\nimport restoreVersion from './restoreVersion.js'\nimport update from './update.js'\n\nexport default {\n findOne,\n findVersionByID,\n findVersions,\n restoreVersion,\n update,\n}\n"],"names":["findOne","findVersionByID","findVersions","restoreVersion","update"],"mappings":"AAAA,OAAOA,aAAa,eAAc;AAClC,OAAOC,qBAAqB,uBAAsB;AAClD,OAAOC,kBAAkB,oBAAmB;AAC5C,OAAOC,oBAAoB,sBAAqB;AAChD,OAAOC,YAAY,cAAa;AAEhC,eAAe;
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/index.ts"],"sourcesContent":["import countGlobalVersions from './countGlobalVersions.js'\nimport findOne from './findOne.js'\nimport findVersionByID from './findVersionByID.js'\nimport findVersions from './findVersions.js'\nimport restoreVersion from './restoreVersion.js'\nimport update from './update.js'\n\nexport default {\n countGlobalVersions,\n findOne,\n findVersionByID,\n findVersions,\n restoreVersion,\n update,\n}\n"],"names":["countGlobalVersions","findOne","findVersionByID","findVersions","restoreVersion","update"],"mappings":"AAAA,OAAOA,yBAAyB,2BAA0B;AAC1D,OAAOC,aAAa,eAAc;AAClC,OAAOC,qBAAqB,uBAAsB;AAClD,OAAOC,kBAAkB,oBAAmB;AAC5C,OAAOC,oBAAoB,sBAAqB;AAChD,OAAOC,YAAY,cAAa;AAEhC,eAAe;IACbL;IACAC;IACAC;IACAC;IACAC;IACAC;AACF,EAAC"}
|