payload 3.92.1 → 3.93.0
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/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js +2 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js +2 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/strategies/local/authenticate.d.ts +3 -1
- package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
- package/dist/auth/strategies/local/authenticate.js +23 -19
- package/dist/auth/strategies/local/authenticate.js.map +1 -1
- package/dist/auth/strategies/local/authenticate.spec.js +91 -7
- package/dist/auth/strategies/local/authenticate.spec.js.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts +14 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.js +31 -15
- package/dist/auth/strategies/local/generatePasswordSaltHash.js.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.spec.js +76 -0
- package/dist/auth/strategies/local/generatePasswordSaltHash.spec.js.map +1 -0
- package/dist/collections/operations/create.js +8 -8
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +31 -26
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +3 -2
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +4 -0
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +10 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/getLocalizedPaths.d.ts.map +1 -1
- package/dist/database/getLocalizedPaths.js +15 -2
- package/dist/database/getLocalizedPaths.js.map +1 -1
- package/dist/database/queryValidation/hasReadAccessToQueryPath.d.ts +20 -0
- package/dist/database/queryValidation/hasReadAccessToQueryPath.d.ts.map +1 -0
- package/dist/database/queryValidation/hasReadAccessToQueryPath.js +86 -0
- package/dist/database/queryValidation/hasReadAccessToQueryPath.js.map +1 -0
- package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.js +28 -34
- package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
- package/dist/errors/DuplicateGlobal.d.ts.map +1 -1
- package/dist/errors/DuplicateGlobal.js +1 -1
- package/dist/errors/DuplicateGlobal.js.map +1 -1
- package/dist/errors/InvalidFieldName.js +1 -1
- package/dist/errors/InvalidFieldName.js.map +1 -1
- package/dist/errors/InvalidFieldRelationship.d.ts.map +1 -1
- package/dist/errors/InvalidFieldRelationship.js +1 -1
- package/dist/errors/InvalidFieldRelationship.js.map +1 -1
- package/dist/errors/MissingFieldInputOptions.js +1 -1
- package/dist/errors/MissingFieldInputOptions.js.map +1 -1
- package/dist/errors/ReservedFieldName.d.ts.map +1 -1
- package/dist/errors/ReservedFieldName.js +1 -1
- package/dist/errors/ReservedFieldName.js.map +1 -1
- package/dist/fields/getBlockFromField.d.ts +8 -0
- package/dist/fields/getBlockFromField.d.ts.map +1 -0
- package/dist/fields/getBlockFromField.js +6 -0
- package/dist/fields/getBlockFromField.js.map +1 -0
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js +6 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +17 -8
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +26 -1
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.js +28 -17
- package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +6 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/validations.js +3 -3
- package/dist/fields/validations.js.map +1 -1
- package/dist/fields/validations.spec.js +16 -0
- package/dist/fields/validations.spec.js.map +1 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +31 -26
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.bundled.d.ts +17 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/uploads/assertClientUploadAllowed.spec.js +29 -0
- package/dist/uploads/assertClientUploadAllowed.spec.js.map +1 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +18 -2
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getExternalFile.d.ts +11 -0
- package/dist/uploads/getExternalFile.d.ts.map +1 -1
- package/dist/uploads/getExternalFile.js +32 -21
- package/dist/uploads/getExternalFile.js.map +1 -1
- package/dist/uploads/getFileFromClientUpload.d.ts +6 -0
- package/dist/uploads/getFileFromClientUpload.d.ts.map +1 -1
- package/dist/uploads/getFileFromClientUpload.js +6 -0
- package/dist/uploads/getFileFromClientUpload.js.map +1 -1
- package/dist/uploads/getFileFromClientUpload.spec.js +30 -1
- package/dist/uploads/getFileFromClientUpload.spec.js.map +1 -1
- package/dist/uploads/getFileTypeIdentity.d.ts.map +1 -1
- package/dist/uploads/getFileTypeIdentity.js +6 -2
- package/dist/uploads/getFileTypeIdentity.js.map +1 -1
- package/dist/uploads/getFileTypeIdentity.spec.js +16 -0
- package/dist/uploads/getFileTypeIdentity.spec.js.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js +5 -2
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +4 -4
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +63 -31
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
- package/dist/utilities/mergeLocalizedData.d.ts +4 -4
- package/dist/utilities/mergeLocalizedData.d.ts.map +1 -1
- package/dist/utilities/mergeLocalizedData.js +24 -20
- package/dist/utilities/mergeLocalizedData.js.map +1 -1
- package/dist/utilities/mergeLocalizedData.spec.js +89 -22
- package/dist/utilities/mergeLocalizedData.spec.js.map +1 -1
- package/dist/utilities/sanitizePermissions.d.ts +5 -2
- package/dist/utilities/sanitizePermissions.d.ts.map +1 -1
- package/dist/utilities/sanitizePermissions.js +38 -4
- package/dist/utilities/sanitizePermissions.js.map +1 -1
- package/dist/utilities/sanitizePermissions.spec.js +118 -20
- package/dist/utilities/sanitizePermissions.spec.js.map +1 -1
- package/dist/versions/allLocalesPublicationStatus.d.ts +5 -5
- package/dist/versions/allLocalesPublicationStatus.d.ts.map +1 -1
- package/dist/versions/allLocalesPublicationStatus.js +2 -2
- package/dist/versions/allLocalesPublicationStatus.js.map +1 -1
- package/dist/versions/drafts/hasNonLocalizedDataChanged.d.ts +12 -0
- package/dist/versions/drafts/hasNonLocalizedDataChanged.d.ts.map +1 -0
- package/dist/versions/drafts/hasNonLocalizedDataChanged.js +165 -0
- package/dist/versions/drafts/hasNonLocalizedDataChanged.js.map +1 -0
- package/dist/versions/drafts/hasNonLocalizedDataChanged.spec.js +860 -0
- package/dist/versions/drafts/hasNonLocalizedDataChanged.spec.js.map +1 -0
- package/dist/versions/mergeLocalizedStatus.d.ts +9 -0
- package/dist/versions/mergeLocalizedStatus.d.ts.map +1 -0
- package/dist/versions/mergeLocalizedStatus.js +11 -0
- package/dist/versions/mergeLocalizedStatus.js.map +1 -0
- package/dist/versions/mergeLocalizedStatus.spec.js +52 -0
- package/dist/versions/mergeLocalizedStatus.spec.js.map +1 -0
- package/dist/versions/resolveLocalizedStatus.d.ts +19 -0
- package/dist/versions/resolveLocalizedStatus.d.ts.map +1 -0
- package/dist/versions/resolveLocalizedStatus.js +60 -0
- package/dist/versions/resolveLocalizedStatus.js.map +1 -0
- package/package.json +2 -2
|
@@ -5,6 +5,7 @@ import { isolateObjectProperty } from '../../utilities/isolateObjectProperty.js'
|
|
|
5
5
|
import { getLocalizedPaths } from '../getLocalizedPaths.js';
|
|
6
6
|
import { isNestedRelationshipQuery } from '../isNestedRelationshipQuery.js';
|
|
7
7
|
import { prefixWherePaths } from '../prefixWherePaths.js';
|
|
8
|
+
import { hasReadAccessToQueryPath } from './hasReadAccessToQueryPath.js';
|
|
8
9
|
import { validateQueryPaths } from './validateQueryPaths.js';
|
|
9
10
|
/**
|
|
10
11
|
* Validate the Payload key / value / operator
|
|
@@ -51,6 +52,7 @@ import { validateQueryPaths } from './validateQueryPaths.js';
|
|
|
51
52
|
// 3.x supports only the `contains` operator for nested relationship queries.
|
|
52
53
|
const isNestedHasManyQuery = operator === 'contains' && hasNestedWhere && Boolean(relatedCollectionSlug);
|
|
53
54
|
const isJoinContainsQuery = operator === 'contains' && relationshipField?.type === 'join' && typeof relationshipField.collection === 'string' && hasNestedWhere;
|
|
55
|
+
const nestedCollectionSlug = isNestedHasManyQuery ? relatedCollectionSlug : isJoinContainsQuery && relationshipField?.type === 'join' && typeof relationshipField.collection === 'string' ? relationshipField.collection : undefined;
|
|
54
56
|
// Plain-object values would be merged as raw query fragments.
|
|
55
57
|
if (operator === 'like' || operator === 'not_like' || operator === 'contains') {
|
|
56
58
|
const isValidNestedContains = operator === 'contains' && (isNestedHasManyQuery || isJoinContainsQuery);
|
|
@@ -62,10 +64,10 @@ import { validateQueryPaths } from './validateQueryPaths.js';
|
|
|
62
64
|
return;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
if (isNestedHasManyQuery &&
|
|
67
|
+
if ((isNestedHasManyQuery || isJoinContainsQuery) && nestedCollectionSlug) {
|
|
66
68
|
// Validate the nested query against the related collection.
|
|
67
69
|
promises.push(validateQueryPaths({
|
|
68
|
-
collectionConfig: req.payload.collections[
|
|
70
|
+
collectionConfig: req.payload.collections[nestedCollectionSlug].config,
|
|
69
71
|
errors,
|
|
70
72
|
overrideAccess,
|
|
71
73
|
policies,
|
|
@@ -178,42 +180,34 @@ import { validateQueryPaths } from './validateQueryPaths.js';
|
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
182
|
}
|
|
183
|
+
const entityType = collectionSlug ? 'collections' : 'globals';
|
|
184
|
+
const entitySlug = collectionSlug || globalConfig.slug;
|
|
185
|
+
const entity = collectionSlug ? req.payload.collections[collectionSlug].config : globalConfig;
|
|
181
186
|
let fieldPath = path;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
if (versionFields && !i && [
|
|
188
|
+
'latest',
|
|
189
|
+
'parent',
|
|
190
|
+
'snapshot',
|
|
191
|
+
'version'
|
|
192
|
+
].includes(fieldPath)) {
|
|
193
|
+
return;
|
|
185
194
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
fieldPath = fieldPath.replace('.value', '');
|
|
195
|
+
if (versionFields && !i) {
|
|
196
|
+
fieldPath = fieldPath.replace(/^(?:parent|version|snapshot|latest)\./, '');
|
|
189
197
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (segments.length) {
|
|
203
|
-
segments.forEach((segment)=>{
|
|
204
|
-
if (fieldAccess[segment]) {
|
|
205
|
-
if ('fields' in fieldAccess[segment]) {
|
|
206
|
-
fieldAccess = fieldAccess[segment].fields;
|
|
207
|
-
} else {
|
|
208
|
-
fieldAccess = fieldAccess[segment];
|
|
209
|
-
}
|
|
210
|
-
}
|
|
198
|
+
if (!hasReadAccessToQueryPath({
|
|
199
|
+
fields: entity.flattenedFields,
|
|
200
|
+
isParentLocalized: parentIsLocalized,
|
|
201
|
+
isRelatedToMany: field.type === 'join' || (field.type === 'relationship' || field.type === 'upload') && Boolean(field.hasMany),
|
|
202
|
+
path: fieldPath.split('.'),
|
|
203
|
+
permissions: policies[entityType][entitySlug].fields,
|
|
204
|
+
relatedCollectionSlug: paths[i + 1]?.collectionSlug || nestedCollectionSlug,
|
|
205
|
+
req,
|
|
206
|
+
shouldShowHiddenFields: showHiddenFields
|
|
207
|
+
})) {
|
|
208
|
+
errors.push({
|
|
209
|
+
path: fieldPath
|
|
211
210
|
});
|
|
212
|
-
if (!fieldAccess?.read?.permission) {
|
|
213
|
-
errors.push({
|
|
214
|
-
path: fieldPath
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
211
|
}
|
|
218
212
|
}
|
|
219
213
|
if (!isNestedHasManyQuery && i > 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/database/queryValidation/validateSearchParams.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { FlattenedField } from '../../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequest, WhereField } from '../../types/index.js'\nimport type { EntityPolicies, PathToQuery } from './types.js'\n\nimport { fieldAffectsData } from '../../fields/config/types.js'\nimport { SAFE_FIELD_PATH_REGEX } from '../../types/constants.js'\nimport { getEntityPermissions } from '../../utilities/getEntityPermissions/getEntityPermissions.js'\nimport { isolateObjectProperty } from '../../utilities/isolateObjectProperty.js'\nimport { getLocalizedPaths } from '../getLocalizedPaths.js'\nimport { isNestedRelationshipQuery } from '../isNestedRelationshipQuery.js'\nimport { prefixWherePaths } from '../prefixWherePaths.js'\nimport { validateQueryPaths } from './validateQueryPaths.js'\n\ntype Args = {\n collectionConfig?: SanitizedCollectionConfig\n constraint: WhereField\n errors: { path: string }[]\n fields: FlattenedField[]\n globalConfig?: SanitizedGlobalConfig\n operator: string\n overrideAccess: boolean\n parentIsLocalized?: boolean\n path: string\n // TODO: Rename to permissions or entityPermissions in 4.0\n policies: EntityPolicies\n polymorphicJoin?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n val: unknown\n versionFields?: FlattenedField[]\n}\n\n/**\n * Validate the Payload key / value / operator\n */\nexport async function validateSearchParam({\n collectionConfig,\n constraint,\n errors,\n fields,\n globalConfig,\n operator,\n overrideAccess,\n parentIsLocalized,\n path: incomingPath,\n policies,\n polymorphicJoin,\n req,\n showHiddenFields,\n val,\n versionFields,\n}: Args): Promise<void> {\n // Replace GraphQL nested field double underscore formatting\n let sanitizedPath\n if (incomingPath === '_id') {\n sanitizedPath = 'id'\n } else {\n sanitizedPath = incomingPath.replace(/__/g, '.')\n }\n let paths: PathToQuery[] = []\n const { slug } = (collectionConfig || globalConfig)!\n\n const blockReferencesPermissions = {}\n\n if (globalConfig && !policies.globals![slug]) {\n policies.globals![slug] = await getEntityPermissions({\n blockReferencesPermissions,\n entity: globalConfig,\n entityType: 'global',\n fetchData: false,\n operations: ['read'],\n req,\n })\n }\n\n if (sanitizedPath !== 'id') {\n paths = getLocalizedPaths({\n collectionSlug: collectionConfig?.slug,\n fields,\n globalSlug: globalConfig?.slug,\n incomingPath: sanitizedPath,\n locale: req.locale!,\n overrideAccess,\n parentIsLocalized,\n payload: req.payload,\n showHiddenFields,\n })\n }\n const promises: Promise<void>[] = []\n\n const relationshipField = paths.length === 1 ? paths[0]?.field : undefined\n const hasNestedWhere = isNestedRelationshipQuery(val)\n const relatedCollectionSlug =\n relationshipField &&\n (relationshipField.type === 'relationship' || relationshipField.type === 'upload') &&\n relationshipField.hasMany &&\n typeof relationshipField.relationTo === 'string'\n ? relationshipField.relationTo\n : undefined\n // 3.x supports only the `contains` operator for nested relationship queries.\n const isNestedHasManyQuery =\n operator === 'contains' && hasNestedWhere && Boolean(relatedCollectionSlug)\n\n const isJoinContainsQuery =\n operator === 'contains' &&\n relationshipField?.type === 'join' &&\n typeof relationshipField.collection === 'string' &&\n hasNestedWhere\n\n // Plain-object values would be merged as raw query fragments.\n if (operator === 'like' || operator === 'not_like' || operator === 'contains') {\n const isValidNestedContains =\n operator === 'contains' && (isNestedHasManyQuery || isJoinContainsQuery)\n\n const containsPlainObject =\n isNestedRelationshipQuery(val) ||\n (Array.isArray(val) && val.some((entry) => isNestedRelationshipQuery(entry)))\n\n if (containsPlainObject && !isValidNestedContains) {\n errors.push({ path: incomingPath })\n return\n }\n }\n\n if (isNestedHasManyQuery && relatedCollectionSlug) {\n // Validate the nested query against the related collection.\n promises.push(\n validateQueryPaths({\n collectionConfig: req.payload.collections[relatedCollectionSlug]!.config,\n errors,\n overrideAccess,\n policies,\n req,\n showHiddenFields,\n where: val,\n }),\n )\n }\n\n // Sanitize relation.otherRelation.id to relation.otherRelation\n if (paths.at(-1)?.path === 'id') {\n const previousField = paths.at(-2)?.field\n if (\n previousField &&\n (previousField.type === 'relationship' || previousField.type === 'upload') &&\n typeof previousField.relationTo === 'string'\n ) {\n paths.pop()\n }\n }\n\n promises.push(\n ...paths.map(async ({ collectionSlug, field, invalid, path }, i) => {\n if (invalid) {\n const isUnknownPolymorphicJoinField =\n polymorphicJoin && !field && SAFE_FIELD_PATH_REGEX.test(incomingPath)\n\n if (!isUnknownPolymorphicJoinField) {\n errors.push({ path })\n }\n\n return\n }\n\n // where: { relatedPosts: { equals: 1}} -> { 'relatedPosts.id': { equals: 1}}\n if (field.type === 'join' && path === incomingPath) {\n constraint[`${path}.id` as keyof WhereField] = constraint[path as keyof WhereField]\n delete constraint[path as keyof WhereField]\n }\n\n if ('virtual' in field && field.virtual) {\n if (field.virtual === true) {\n errors.push({ path })\n }\n }\n\n if (polymorphicJoin && path === 'relationTo') {\n return\n }\n\n if (!overrideAccess && fieldAffectsData(field)) {\n if (collectionSlug) {\n if (!policies.collections![collectionSlug]) {\n policies.collections![collectionSlug] = await getEntityPermissions({\n blockReferencesPermissions,\n entity: req.payload.collections[collectionSlug]!.config,\n entityType: 'collection',\n fetchData: false,\n operations: ['read'],\n req: isolateObjectProperty(req, 'transactionID'),\n })\n }\n\n if (\n ['hash', 'salt'].includes(incomingPath) &&\n collectionConfig!.auth &&\n !collectionConfig!.auth?.disableLocalStrategy\n ) {\n errors.push({ path: incomingPath })\n }\n\n const relatedCollectionReadPermission = policies.collections![collectionSlug].read\n const previousSegment = paths[i - 1]\n const traversedField = previousSegment?.field\n const isRelationshipHop =\n Boolean(traversedField) &&\n (traversedField!.type === 'relationship' ||\n traversedField!.type === 'upload' ||\n traversedField!.type === 'join')\n\n if (\n isRelationshipHop &&\n relatedCollectionReadPermission &&\n typeof relatedCollectionReadPermission === 'object' &&\n relatedCollectionReadPermission.where\n ) {\n const relationshipPath = paths\n .slice(0, i)\n .map(({ path: pathToRelationship }) => pathToRelationship)\n .join('.')\n\n const mutableWhere = constraint as Record<string, unknown>\n const existingAnd = Array.isArray(mutableWhere.and) ? mutableWhere.and : []\n\n // Has-many relationships and joins can point to many related documents, so the user's\n // filter and the access constraint must be satisfied by the SAME related document.\n // Scoping both into a single `contains` prevents a different, readable document from\n // masking one the user cannot read (a related-document oracle).\n const isHasManyRelationship =\n (traversedField!.type === 'relationship' || traversedField!.type === 'upload') &&\n traversedField!.hasMany\n const isJoin = traversedField!.type === 'join'\n\n if (isHasManyRelationship || isJoin) {\n const relatedFieldPath = paths.at(-1)?.path\n\n if (relatedFieldPath) {\n mutableWhere.and = [\n ...existingAnd,\n {\n [relationshipPath]: {\n contains: {\n and: [\n {\n [relatedFieldPath]: {\n [operator]: val,\n },\n },\n relatedCollectionReadPermission.where,\n ],\n },\n },\n },\n ]\n\n // The scoped `contains` above fully replaces the user's original filter;\n // so we can remove it from the top-level where clause\n delete mutableWhere[incomingPath]\n }\n } else {\n const accessWhere = prefixWherePaths({\n prefix: relationshipPath,\n where: relatedCollectionReadPermission.where,\n })\n\n mutableWhere.and = [...existingAnd, accessWhere]\n }\n }\n }\n let fieldPath = path\n // remove locale from end of path\n if (path.endsWith(`.${req.locale}`)) {\n fieldPath = path.slice(0, -(req.locale!.length + 1))\n }\n // remove \".value\" from ends of polymorphic relationship paths\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n Array.isArray(field.relationTo)\n ) {\n fieldPath = fieldPath.replace('.value', '')\n }\n\n const entityType: 'collections' | 'globals' = globalConfig ? 'globals' : 'collections'\n const entitySlug = collectionSlug || globalConfig!.slug\n const segments = fieldPath.split('.')\n\n let fieldAccess: any\n\n if (versionFields) {\n fieldAccess = policies[entityType]![entitySlug]!.fields\n\n if (\n segments[0] === 'parent' ||\n segments[0] === 'version' ||\n segments[0] === 'snapshot' ||\n segments[0] === 'latest'\n ) {\n segments.shift()\n }\n } else {\n fieldAccess = policies[entityType]![entitySlug]!.fields\n }\n\n if (segments.length) {\n segments.forEach((segment) => {\n if (fieldAccess[segment]) {\n if ('fields' in fieldAccess[segment]) {\n fieldAccess = fieldAccess[segment].fields\n } else {\n fieldAccess = fieldAccess[segment]\n }\n }\n })\n\n if (!fieldAccess?.read?.permission) {\n errors.push({ path: fieldPath })\n }\n }\n }\n\n if (!isNestedHasManyQuery && i > 1) {\n // Remove top collection and reverse array\n // to work backwards from top\n const pathsToQuery = paths.slice(1).reverse()\n\n pathsToQuery.forEach(\n ({ collectionSlug: pathCollectionSlug, path: subPath }, pathToQueryIndex) => {\n // On the \"deepest\" collection,\n // validate query of the relationship\n if (pathToQueryIndex === 0) {\n promises.push(\n validateQueryPaths({\n collectionConfig: req.payload.collections[pathCollectionSlug!]!.config,\n errors,\n globalConfig: undefined,\n overrideAccess,\n policies,\n req,\n showHiddenFields,\n where: {\n [subPath]: {\n [operator]: val,\n },\n },\n }),\n )\n }\n },\n )\n }\n }),\n )\n await Promise.all(promises)\n}\n"],"names":["fieldAffectsData","SAFE_FIELD_PATH_REGEX","getEntityPermissions","isolateObjectProperty","getLocalizedPaths","isNestedRelationshipQuery","prefixWherePaths","validateQueryPaths","validateSearchParam","collectionConfig","constraint","errors","fields","globalConfig","operator","overrideAccess","parentIsLocalized","path","incomingPath","policies","polymorphicJoin","req","showHiddenFields","val","versionFields","sanitizedPath","replace","paths","slug","blockReferencesPermissions","globals","entity","entityType","fetchData","operations","collectionSlug","globalSlug","locale","payload","promises","relationshipField","length","field","undefined","hasNestedWhere","relatedCollectionSlug","type","hasMany","relationTo","isNestedHasManyQuery","Boolean","isJoinContainsQuery","collection","isValidNestedContains","containsPlainObject","Array","isArray","some","entry","push","collections","config","where","at","previousField","pop","map","invalid","i","isUnknownPolymorphicJoinField","test","virtual","includes","auth","disableLocalStrategy","relatedCollectionReadPermission","read","previousSegment","traversedField","isRelationshipHop","relationshipPath","slice","pathToRelationship","join","mutableWhere","existingAnd","and","isHasManyRelationship","isJoin","relatedFieldPath","contains","accessWhere","prefix","fieldPath","endsWith","entitySlug","segments","split","fieldAccess","shift","forEach","segment","permission","pathsToQuery","reverse","pathCollectionSlug","subPath","pathToQueryIndex","Promise","all"],"mappings":"AAMA,SAASA,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,qBAAqB,QAAQ,2BAA0B;AAChE,SAASC,oBAAoB,QAAQ,+DAA8D;AACnG,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,kBAAkB,QAAQ,0BAAyB;AAqB5D;;CAEC,GACD,OAAO,eAAeC,oBAAoB,EACxCC,gBAAgB,EAChBC,UAAU,EACVC,MAAM,EACNC,MAAM,EACNC,YAAY,EACZC,QAAQ,EACRC,cAAc,EACdC,iBAAiB,EACjBC,MAAMC,YAAY,EAClBC,QAAQ,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AK,CAAC,GAAGuB,OAAO;YAE3CD,aAAaH,OAAO,CAClB,CAAC,EAAEjE,gBAAgBsE,kBAAkB,EAAExF,MAAMyF,OAAO,EAAE,EAAEC;gBACtD,+BAA+B;gBAC/B,qCAAqC;gBACrC,IAAIA,qBAAqB,GAAG;oBAC1BpE,SAASoB,IAAI,CACXpD,mBAAmB;wBACjBE,kBAAkBY,IAAIiB,OAAO,CAACsB,WAAW,CAAC6C,mBAAoB,CAAE5C,MAAM;wBACtElD;wBACAE,cAAc8B;wBACd5B;wBACAI;wBACAE;wBACAC;wBACAwC,OAAO;4BACL,CAAC4C,QAAQ,EAAE;gCACT,CAAC5F,SAAS,EAAES;4BACd;wBACF;oBACF;gBAEJ;YACF;QAEJ;IACF;IAEF,MAAMqF,QAAQC,GAAG,CAACtE;AACpB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/database/queryValidation/validateSearchParams.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { FlattenedField } from '../../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequest, WhereField } from '../../types/index.js'\nimport type { EntityPolicies, PathToQuery } from './types.js'\n\nimport { fieldAffectsData } from '../../fields/config/types.js'\nimport { SAFE_FIELD_PATH_REGEX } from '../../types/constants.js'\nimport { getEntityPermissions } from '../../utilities/getEntityPermissions/getEntityPermissions.js'\nimport { isolateObjectProperty } from '../../utilities/isolateObjectProperty.js'\nimport { getLocalizedPaths } from '../getLocalizedPaths.js'\nimport { isNestedRelationshipQuery } from '../isNestedRelationshipQuery.js'\nimport { prefixWherePaths } from '../prefixWherePaths.js'\nimport { hasReadAccessToQueryPath } from './hasReadAccessToQueryPath.js'\nimport { validateQueryPaths } from './validateQueryPaths.js'\n\ntype Args = {\n collectionConfig?: SanitizedCollectionConfig\n constraint: WhereField\n errors: { path: string }[]\n fields: FlattenedField[]\n globalConfig?: SanitizedGlobalConfig\n operator: string\n overrideAccess: boolean\n parentIsLocalized?: boolean\n path: string\n // TODO: Rename to permissions or entityPermissions in 4.0\n policies: EntityPolicies\n polymorphicJoin?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n val: unknown\n versionFields?: FlattenedField[]\n}\n\n/**\n * Validate the Payload key / value / operator\n */\nexport async function validateSearchParam({\n collectionConfig,\n constraint,\n errors,\n fields,\n globalConfig,\n operator,\n overrideAccess,\n parentIsLocalized,\n path: incomingPath,\n policies,\n polymorphicJoin,\n req,\n showHiddenFields,\n val,\n versionFields,\n}: Args): Promise<void> {\n // Replace GraphQL nested field double underscore formatting\n let sanitizedPath\n if (incomingPath === '_id') {\n sanitizedPath = 'id'\n } else {\n sanitizedPath = incomingPath.replace(/__/g, '.')\n }\n let paths: PathToQuery[] = []\n const { slug } = (collectionConfig || globalConfig)!\n\n const blockReferencesPermissions = {}\n\n if (globalConfig && !policies.globals![slug]) {\n policies.globals![slug] = await getEntityPermissions({\n blockReferencesPermissions,\n entity: globalConfig,\n entityType: 'global',\n fetchData: false,\n operations: ['read'],\n req,\n })\n }\n\n if (sanitizedPath !== 'id') {\n paths = getLocalizedPaths({\n collectionSlug: collectionConfig?.slug,\n fields,\n globalSlug: globalConfig?.slug,\n incomingPath: sanitizedPath,\n locale: req.locale!,\n overrideAccess,\n parentIsLocalized,\n payload: req.payload,\n showHiddenFields,\n })\n }\n const promises: Promise<void>[] = []\n\n const relationshipField = paths.length === 1 ? paths[0]?.field : undefined\n const hasNestedWhere = isNestedRelationshipQuery(val)\n const relatedCollectionSlug =\n relationshipField &&\n (relationshipField.type === 'relationship' || relationshipField.type === 'upload') &&\n relationshipField.hasMany &&\n typeof relationshipField.relationTo === 'string'\n ? relationshipField.relationTo\n : undefined\n // 3.x supports only the `contains` operator for nested relationship queries.\n const isNestedHasManyQuery =\n operator === 'contains' && hasNestedWhere && Boolean(relatedCollectionSlug)\n\n const isJoinContainsQuery =\n operator === 'contains' &&\n relationshipField?.type === 'join' &&\n typeof relationshipField.collection === 'string' &&\n hasNestedWhere\n\n const nestedCollectionSlug = isNestedHasManyQuery\n ? relatedCollectionSlug\n : isJoinContainsQuery &&\n relationshipField?.type === 'join' &&\n typeof relationshipField.collection === 'string'\n ? relationshipField.collection\n : undefined\n\n // Plain-object values would be merged as raw query fragments.\n if (operator === 'like' || operator === 'not_like' || operator === 'contains') {\n const isValidNestedContains =\n operator === 'contains' && (isNestedHasManyQuery || isJoinContainsQuery)\n\n const containsPlainObject =\n isNestedRelationshipQuery(val) ||\n (Array.isArray(val) && val.some((entry) => isNestedRelationshipQuery(entry)))\n\n if (containsPlainObject && !isValidNestedContains) {\n errors.push({ path: incomingPath })\n return\n }\n }\n\n if ((isNestedHasManyQuery || isJoinContainsQuery) && nestedCollectionSlug) {\n // Validate the nested query against the related collection.\n promises.push(\n validateQueryPaths({\n collectionConfig: req.payload.collections[nestedCollectionSlug]!.config,\n errors,\n overrideAccess,\n policies,\n req,\n showHiddenFields,\n where: val,\n }),\n )\n }\n\n // Sanitize relation.otherRelation.id to relation.otherRelation\n if (paths.at(-1)?.path === 'id') {\n const previousField = paths.at(-2)?.field\n if (\n previousField &&\n (previousField.type === 'relationship' || previousField.type === 'upload') &&\n typeof previousField.relationTo === 'string'\n ) {\n paths.pop()\n }\n }\n\n promises.push(\n ...paths.map(async ({ collectionSlug, field, invalid, path }, i) => {\n if (invalid) {\n const isUnknownPolymorphicJoinField =\n polymorphicJoin && !field && SAFE_FIELD_PATH_REGEX.test(incomingPath)\n\n if (!isUnknownPolymorphicJoinField) {\n errors.push({ path })\n }\n\n return\n }\n\n // where: { relatedPosts: { equals: 1}} -> { 'relatedPosts.id': { equals: 1}}\n if (field.type === 'join' && path === incomingPath) {\n constraint[`${path}.id` as keyof WhereField] = constraint[path as keyof WhereField]\n delete constraint[path as keyof WhereField]\n }\n\n if ('virtual' in field && field.virtual) {\n if (field.virtual === true) {\n errors.push({ path })\n }\n }\n\n if (polymorphicJoin && path === 'relationTo') {\n return\n }\n\n if (!overrideAccess && fieldAffectsData(field)) {\n if (collectionSlug) {\n if (!policies.collections![collectionSlug]) {\n policies.collections![collectionSlug] = await getEntityPermissions({\n blockReferencesPermissions,\n entity: req.payload.collections[collectionSlug]!.config,\n entityType: 'collection',\n fetchData: false,\n operations: ['read'],\n req: isolateObjectProperty(req, 'transactionID'),\n })\n }\n\n if (\n ['hash', 'salt'].includes(incomingPath) &&\n collectionConfig!.auth &&\n !collectionConfig!.auth?.disableLocalStrategy\n ) {\n errors.push({ path: incomingPath })\n }\n\n const relatedCollectionReadPermission = policies.collections![collectionSlug].read\n const previousSegment = paths[i - 1]\n const traversedField = previousSegment?.field\n const isRelationshipHop =\n Boolean(traversedField) &&\n (traversedField!.type === 'relationship' ||\n traversedField!.type === 'upload' ||\n traversedField!.type === 'join')\n\n if (\n isRelationshipHop &&\n relatedCollectionReadPermission &&\n typeof relatedCollectionReadPermission === 'object' &&\n relatedCollectionReadPermission.where\n ) {\n const relationshipPath = paths\n .slice(0, i)\n .map(({ path: pathToRelationship }) => pathToRelationship)\n .join('.')\n\n const mutableWhere = constraint as Record<string, unknown>\n const existingAnd = Array.isArray(mutableWhere.and) ? mutableWhere.and : []\n\n // Has-many relationships and joins can point to many related documents, so the user's\n // filter and the access constraint must be satisfied by the SAME related document.\n // Scoping both into a single `contains` prevents a different, readable document from\n // masking one the user cannot read (a related-document oracle).\n const isHasManyRelationship =\n (traversedField!.type === 'relationship' || traversedField!.type === 'upload') &&\n traversedField!.hasMany\n const isJoin = traversedField!.type === 'join'\n\n if (isHasManyRelationship || isJoin) {\n const relatedFieldPath = paths.at(-1)?.path\n\n if (relatedFieldPath) {\n mutableWhere.and = [\n ...existingAnd,\n {\n [relationshipPath]: {\n contains: {\n and: [\n {\n [relatedFieldPath]: {\n [operator]: val,\n },\n },\n relatedCollectionReadPermission.where,\n ],\n },\n },\n },\n ]\n\n // The scoped `contains` above fully replaces the user's original filter;\n // so we can remove it from the top-level where clause\n delete mutableWhere[incomingPath]\n }\n } else {\n const accessWhere = prefixWherePaths({\n prefix: relationshipPath,\n where: relatedCollectionReadPermission.where,\n })\n\n mutableWhere.and = [...existingAnd, accessWhere]\n }\n }\n }\n const entityType = collectionSlug ? 'collections' : 'globals'\n const entitySlug = collectionSlug || globalConfig!.slug\n const entity = collectionSlug\n ? req.payload.collections[collectionSlug]!.config\n : globalConfig!\n let fieldPath = path\n\n if (\n versionFields &&\n !i &&\n ['latest', 'parent', 'snapshot', 'version'].includes(fieldPath)\n ) {\n return\n }\n\n if (versionFields && !i) {\n fieldPath = fieldPath.replace(/^(?:parent|version|snapshot|latest)\\./, '')\n }\n\n if (\n !hasReadAccessToQueryPath({\n fields: entity.flattenedFields,\n isParentLocalized: parentIsLocalized,\n isRelatedToMany:\n field.type === 'join' ||\n ((field.type === 'relationship' || field.type === 'upload') &&\n Boolean(field.hasMany)),\n path: fieldPath.split('.'),\n permissions: policies[entityType]![entitySlug]!.fields,\n relatedCollectionSlug: paths[i + 1]?.collectionSlug || nestedCollectionSlug,\n req,\n shouldShowHiddenFields: showHiddenFields,\n })\n ) {\n errors.push({ path: fieldPath })\n }\n }\n\n if (!isNestedHasManyQuery && i > 1) {\n // Remove top collection and reverse array\n // to work backwards from top\n const pathsToQuery = paths.slice(1).reverse()\n\n pathsToQuery.forEach(\n ({ collectionSlug: pathCollectionSlug, path: subPath }, pathToQueryIndex) => {\n // On the \"deepest\" collection,\n // validate query of the relationship\n if (pathToQueryIndex === 0) {\n promises.push(\n validateQueryPaths({\n collectionConfig: req.payload.collections[pathCollectionSlug!]!.config,\n errors,\n globalConfig: undefined,\n overrideAccess,\n policies,\n req,\n showHiddenFields,\n where: {\n [subPath]: {\n [operator]: val,\n },\n },\n }),\n )\n }\n },\n )\n }\n }),\n )\n await Promise.all(promises)\n}\n"],"names":["fieldAffectsData","SAFE_FIELD_PATH_REGEX","getEntityPermissions","isolateObjectProperty","getLocalizedPaths","isNestedRelationshipQuery","prefixWherePaths","hasReadAccessToQueryPath","validateQueryPaths","validateSearchParam","collectionConfig","constraint","errors","fields","globalConfig","operator","overrideAccess","parentIsLocalized","path","incomingPath","policies","polymorphicJoin","req","showHiddenFields","val","versionFields","sanitizedPath","replace","paths","slug","blockReferencesPermissions","globals","entity","entityType","fetchData","operations","collectionSlug","globalSlug","locale","payload","promises","relationshipField","length","field","undefined","hasNestedWhere","relatedCollectionSlug","type","hasMany","relationTo","isNestedHasManyQuery","Boolean","isJoinContainsQuery","collection","nestedCollectionSlug","isValidNestedContains","containsPlainObject","Array","isArray","some","entry","push","collections","config","where","at","previousField","pop","map","invalid","i","isUnknownPolymorphicJoinField","test","virtual","includes","auth","disableLocalStrategy","relatedCollectionReadPermission","read","previousSegment","traversedField","isRelationshipHop","relationshipPath","slice","pathToRelationship","join","mutableWhere","existingAnd","and","isHasManyRelationship","isJoin","relatedFieldPath","contains","accessWhere","prefix","entitySlug","fieldPath","flattenedFields","isParentLocalized","isRelatedToMany","split","permissions","shouldShowHiddenFields","pathsToQuery","reverse","forEach","pathCollectionSlug","subPath","pathToQueryIndex","Promise","all"],"mappings":"AAMA,SAASA,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,qBAAqB,QAAQ,2BAA0B;AAChE,SAASC,oBAAoB,QAAQ,+DAA8D;AACnG,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,kBAAkB,QAAQ,0BAAyB;AAqB5D;;CAEC,GACD,OAAO,eAAeC,oBAAoB,EACxCC,gBAAgB,EAChBC,UAAU,EACVC,MAAM,EACNC,MAAM,EACNC,YAAY,EACZC,QAAQ,EACRC,cAAc,EACdC,iBAAiB,EACjBC,MAAMC,YAAY,EAClBC,QAAQ,EACRC,eAAe,EACfC,GAAG,EACHC,gBAAgB,EAChBC,GAAG,EACHC,aAAa,EACR;IACL,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ACtEnD;wBACAE,cAAc8B;wBACd5B;wBACAI;wBACAE;wBACAC;wBACAyC,OAAO;4BACL,CAAC2C,QAAQ,EAAE;gCACT,CAAC5F,SAAS,EAAES;4BACd;wBACF;oBACF;gBAEJ;YACF;QAEJ;IACF;IAEF,MAAMqF,QAAQC,GAAG,CAACtE;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DuplicateGlobal.d.ts","sourceRoot":"","sources":["../../src/errors/DuplicateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,MAAM,EAAE,YAAY;
|
|
1
|
+
{"version":3,"file":"DuplicateGlobal.d.ts","sourceRoot":"","sources":["../../src/errors/DuplicateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,MAAM,EAAE,YAAY;CAMjC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError } from './APIError.js';
|
|
2
2
|
export class DuplicateGlobal extends APIError {
|
|
3
3
|
constructor(config){
|
|
4
|
-
super(`Global label "${config.label}" is already in use`);
|
|
4
|
+
super(`Global label "${typeof config.label === 'string' ? config.label : config.slug}" is already in use`);
|
|
5
5
|
this.name = 'DuplicateGlobal';
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/DuplicateGlobal.ts"],"sourcesContent":["import type { GlobalConfig } from '../globals/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class DuplicateGlobal extends APIError {\n constructor(config: GlobalConfig) {\n super(`Global label \"${config.label}\" is already in use
|
|
1
|
+
{"version":3,"sources":["../../src/errors/DuplicateGlobal.ts"],"sourcesContent":["import type { GlobalConfig } from '../globals/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class DuplicateGlobal extends APIError {\n constructor(config: GlobalConfig) {\n super(\n `Global label \"${typeof config.label === 'string' ? config.label : config.slug}\" is already in use`,\n )\n this.name = 'DuplicateGlobal'\n }\n}\n"],"names":["APIError","DuplicateGlobal","config","label","slug","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,wBAAwBD;IACnC,YAAYE,MAAoB,CAAE;QAChC,KAAK,CACH,CAAC,cAAc,EAAE,OAAOA,OAAOC,KAAK,KAAK,WAAWD,OAAOC,KAAK,GAAGD,OAAOE,IAAI,CAAC,mBAAmB,CAAC;QAErG,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError } from './APIError.js';
|
|
2
2
|
export class InvalidFieldName extends APIError {
|
|
3
3
|
constructor(field, fieldName){
|
|
4
|
-
super(`Field ${field.label} has invalid name '${fieldName}'. Field names can not include periods (.) and must be alphanumeric.`);
|
|
4
|
+
super(`Field ${typeof field.label === 'string' ? field.label : fieldName} has invalid name '${fieldName}'. Field names can not include periods (.) and must be alphanumeric.`);
|
|
5
5
|
this.name = 'InvalidFieldName';
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/InvalidFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(\n `Field ${field.label} has invalid name '${fieldName}'. Field names can not include periods (.) and must be alphanumeric.`,\n )\n this.name = 'InvalidFieldName'\n }\n}\n"],"names":["APIError","InvalidFieldName","field","fieldName","label","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,yBAAyBD;IACpC,YAAYE,KAAyB,EAAEC,SAAiB,CAAE;QACxD,KAAK,CACH,CAAC,MAAM,
|
|
1
|
+
{"version":3,"sources":["../../src/errors/InvalidFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(\n `Field ${typeof field.label === 'string' ? field.label : fieldName} has invalid name '${fieldName}'. Field names can not include periods (.) and must be alphanumeric.`,\n )\n this.name = 'InvalidFieldName'\n }\n}\n"],"names":["APIError","InvalidFieldName","field","fieldName","label","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,yBAAyBD;IACpC,YAAYE,KAAyB,EAAEC,SAAiB,CAAE;QACxD,KAAK,CACH,CAAC,MAAM,EAAE,OAAOD,MAAME,KAAK,KAAK,WAAWF,MAAME,KAAK,GAAGD,UAAU,mBAAmB,EAAEA,UAAU,oEAAoE,CAAC;QAEzK,IAAI,CAACE,IAAI,GAAG;IACd;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidFieldRelationship.d.ts","sourceRoot":"","sources":["../../src/errors/InvalidFieldRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,wBAAyB,SAAQ,QAAQ;gBACxC,KAAK,EAAE,iBAAiB,GAAG,WAAW,EAAE,YAAY,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"InvalidFieldRelationship.d.ts","sourceRoot":"","sources":["../../src/errors/InvalidFieldRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,wBAAyB,SAAQ,QAAQ;gBACxC,KAAK,EAAE,iBAAiB,GAAG,WAAW,EAAE,YAAY,EAAE,MAAM;CAMzE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError } from './APIError.js';
|
|
2
2
|
export class InvalidFieldRelationship extends APIError {
|
|
3
3
|
constructor(field, relationship){
|
|
4
|
-
super(`Field ${field.label} has invalid relationship '${relationship}'.`);
|
|
4
|
+
super(`Field ${typeof field.label === 'string' ? field.label : field.name} has invalid relationship '${relationship}'.`);
|
|
5
5
|
this.name = 'InvalidFieldRelationship';
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/InvalidFieldRelationship.ts"],"sourcesContent":["import type { RelationshipField, UploadField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldRelationship extends APIError {\n constructor(field: RelationshipField | UploadField, relationship: string) {\n super(`Field ${field.label} has invalid relationship '${relationship}'
|
|
1
|
+
{"version":3,"sources":["../../src/errors/InvalidFieldRelationship.ts"],"sourcesContent":["import type { RelationshipField, UploadField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldRelationship extends APIError {\n constructor(field: RelationshipField | UploadField, relationship: string) {\n super(\n `Field ${typeof field.label === 'string' ? field.label : field.name} has invalid relationship '${relationship}'.`,\n )\n this.name = 'InvalidFieldRelationship'\n }\n}\n"],"names":["APIError","InvalidFieldRelationship","field","relationship","label","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,iCAAiCD;IAC5C,YAAYE,KAAsC,EAAEC,YAAoB,CAAE;QACxE,KAAK,CACH,CAAC,MAAM,EAAE,OAAOD,MAAME,KAAK,KAAK,WAAWF,MAAME,KAAK,GAAGF,MAAMG,IAAI,CAAC,2BAA2B,EAAEF,aAAa,EAAE,CAAC;QAEnH,IAAI,CAACE,IAAI,GAAG;IACd;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError } from './APIError.js';
|
|
2
2
|
export class MissingFieldInputOptions extends APIError {
|
|
3
3
|
constructor(field){
|
|
4
|
-
super(`Field ${field.label} is missing options.`);
|
|
4
|
+
super(`Field ${typeof field.label === 'string' ? field.label : field.name} is missing options.`);
|
|
5
5
|
this.name = 'MissingFieldInputOptions';
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/MissingFieldInputOptions.ts"],"sourcesContent":["import type { RadioField, SelectField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class MissingFieldInputOptions extends APIError {\n constructor(field: RadioField | SelectField) {\n super(`Field ${field.label} is missing options.`)\n this.name = 'MissingFieldInputOptions'\n }\n}\n"],"names":["APIError","MissingFieldInputOptions","field","label","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,iCAAiCD;IAC5C,YAAYE,KAA+B,CAAE;QAC3C,KAAK,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"sources":["../../src/errors/MissingFieldInputOptions.ts"],"sourcesContent":["import type { RadioField, SelectField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class MissingFieldInputOptions extends APIError {\n constructor(field: RadioField | SelectField) {\n super(`Field ${typeof field.label === 'string' ? field.label : field.name} is missing options.`)\n this.name = 'MissingFieldInputOptions'\n }\n}\n"],"names":["APIError","MissingFieldInputOptions","field","label","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,iCAAiCD;IAC5C,YAAYE,KAA+B,CAAE;QAC3C,KAAK,CAAC,CAAC,MAAM,EAAE,OAAOA,MAAMC,KAAK,KAAK,WAAWD,MAAMC,KAAK,GAAGD,MAAME,IAAI,CAAC,oBAAoB,CAAC;QAC/F,IAAI,CAACA,IAAI,GAAG;IACd;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReservedFieldName.d.ts","sourceRoot":"","sources":["../../src/errors/ReservedFieldName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"ReservedFieldName.d.ts","sourceRoot":"","sources":["../../src/errors/ReservedFieldName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;CAMzD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError } from './APIError.js';
|
|
2
2
|
export class ReservedFieldName extends APIError {
|
|
3
3
|
constructor(field, fieldName){
|
|
4
|
-
super(`Field ${field.label} has reserved name '${fieldName}'.`);
|
|
4
|
+
super(`Field ${typeof field.label === 'string' ? field.label : fieldName} has reserved name '${fieldName}'.`);
|
|
5
5
|
this.name = 'ReservedFieldName';
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/ReservedFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class ReservedFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(`Field ${field.label} has reserved name '${fieldName}'
|
|
1
|
+
{"version":3,"sources":["../../src/errors/ReservedFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class ReservedFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(\n `Field ${typeof field.label === 'string' ? field.label : fieldName} has reserved name '${fieldName}'.`,\n )\n this.name = 'ReservedFieldName'\n }\n}\n"],"names":["APIError","ReservedFieldName","field","fieldName","label","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,0BAA0BD;IACrC,YAAYE,KAAyB,EAAEC,SAAiB,CAAE;QACxD,KAAK,CACH,CAAC,MAAM,EAAE,OAAOD,MAAME,KAAK,KAAK,WAAWF,MAAME,KAAK,GAAGD,UAAU,oBAAoB,EAAEA,UAAU,EAAE,CAAC;QAExG,IAAI,CAACE,IAAI,GAAG;IACd;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PayloadRequest } from '../types/index.js';
|
|
2
|
+
import type { Block, BlocksField } from './config/types.js';
|
|
3
|
+
export declare const getBlockFromField: ({ blockType, field, req, }: {
|
|
4
|
+
blockType: string;
|
|
5
|
+
field: BlocksField;
|
|
6
|
+
req: PayloadRequest;
|
|
7
|
+
}) => Block | undefined;
|
|
8
|
+
//# sourceMappingURL=getBlockFromField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBlockFromField.d.ts","sourceRoot":"","sources":["../../src/fields/getBlockFromField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE3D,eAAO,MAAM,iBAAiB,+BAI3B;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,WAAW,CAAA;IAClB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,KAAK,GAAG,SAMX,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const getBlockFromField = ({ blockType, field, req })=>{
|
|
2
|
+
const block = (field.blockReferences ?? field.blocks).find((block)=>typeof block === 'string' ? block === blockType : block.slug === blockType);
|
|
3
|
+
return typeof block === 'string' ? req.payload.blocks[block] : block;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=getBlockFromField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/fields/getBlockFromField.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\nimport type { Block, BlocksField } from './config/types.js'\n\nexport const getBlockFromField = ({\n blockType,\n field,\n req,\n}: {\n blockType: string\n field: BlocksField\n req: PayloadRequest\n}): Block | undefined => {\n const block = (field.blockReferences ?? field.blocks).find((block) =>\n typeof block === 'string' ? block === blockType : block.slug === blockType,\n )\n\n return typeof block === 'string' ? req.payload.blocks[block] : block\n}\n"],"names":["getBlockFromField","blockType","field","req","block","blockReferences","blocks","find","slug","payload"],"mappings":"AAGA,OAAO,MAAMA,oBAAoB,CAAC,EAChCC,SAAS,EACTC,KAAK,EACLC,GAAG,EAKJ;IACC,MAAMC,QAAQ,AAACF,CAAAA,MAAMG,eAAe,IAAIH,MAAMI,MAAM,AAAD,EAAGC,IAAI,CAAC,CAACH,QAC1D,OAAOA,UAAU,WAAWA,UAAUH,YAAYG,MAAMI,IAAI,KAAKP;IAGnE,OAAO,OAAOG,UAAU,WAAWD,IAAIM,OAAO,CAACH,MAAM,CAACF,MAAM,GAAGA;AACjE,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterChange/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KA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,CAAC,EAAE,CAAA;CACvC,CAAA;AAKD,eAAO,MAAM,OAAO,yOAoBjB,IAAI,KAAG,OAAO,CAAC,IAAI,CAmTrB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MissingEditorProp } from '../../../errors/index.js';
|
|
2
2
|
import { fieldAffectsData, tabHasName } from '../../config/types.js';
|
|
3
|
+
import { getBlockFromField } from '../../getBlockFromField.js';
|
|
3
4
|
import { getFieldPaths } from '../../getFieldPaths.js';
|
|
4
5
|
import { traverseFields } from './traverseFields.js';
|
|
5
6
|
// This function is responsible for the following actions, in order:
|
|
@@ -88,7 +89,11 @@ export const promise = async ({ blockData, collection, context, data, doc, field
|
|
|
88
89
|
const promises = [];
|
|
89
90
|
rows.forEach((row, rowIndex)=>{
|
|
90
91
|
const blockTypeToMatch = row.blockType;
|
|
91
|
-
const block =
|
|
92
|
+
const block = getBlockFromField({
|
|
93
|
+
blockType: blockTypeToMatch,
|
|
94
|
+
field,
|
|
95
|
+
req
|
|
96
|
+
});
|
|
92
97
|
if (block) {
|
|
93
98
|
promises.push(traverseFields({
|
|
94
99
|
blockData: siblingData?.[field.name]?.[rowIndex],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterChange/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, PayloadRequest } from '../../../types/index.js'\nimport type { Block, Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n field: Field | TabAsField\n fieldIndex: number\n global: null | SanitizedGlobalConfig\n operation: 'create' | 'update'\n parentIndexPath: string\n parentIsLocalized: boolean\n parentPath: string\n parentSchemaPath: string\n previousDoc: JsonObject\n previousSiblingDoc: JsonObject\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingFields?: (Field | TabAsField)[]\n}\n\n// This function is responsible for the following actions, in order:\n// - Execute field hooks\n\nexport const promise = async ({\n blockData,\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\n global,\n operation,\n parentIndexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n siblingFields,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n const getNestedValue = (data: JsonObject, path: string[]) =>\n path.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), data)\n const previousValData =\n previousSiblingDoc && Object.keys(previousSiblingDoc).length > 0\n ? previousSiblingDoc\n : previousDoc\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if ('hooks' in field && field.hooks?.afterChange) {\n for (const hook of field.hooks.afterChange) {\n const hookedValue = await hook({\n blockData,\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue:\n getNestedValue(previousValData, pathSegments) ?? previousValData?.[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n siblingFields: siblingFields!,\n value: getNestedValue(siblingDoc, pathSegments) ?? siblingDoc?.[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n rows.forEach((row, rowIndex) => {\n promises.push(\n traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n\n rows.forEach((row, rowIndex) => {\n const blockTypeToMatch = (row as JsonObject).blockType\n\n const block: Block | undefined =\n req.payload.blocks[blockTypeToMatch] ??\n ((field.blockReferences ?? field.blocks).find(\n (curBlock) => typeof curBlock !== 'string' && curBlock.slug === blockTypeToMatch,\n ) as Block | undefined)\n\n if (block) {\n promises.push(\n traverseFields({\n blockData: siblingData?.[field.name]?.[rowIndex],\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n previousDoc,\n previousSiblingDoc: previousValData?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: (previousDoc?.[field.name] as JsonObject) || {},\n req,\n siblingData: (siblingData?.[field.name] as JsonObject) || {},\n siblingDoc: (siblingDoc?.[field.name] as JsonObject) || {},\n })\n } else {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\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\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?.afterChange?.length) {\n for (const hook of editor.hooks.afterChange) {\n const hookedValue = await hook({\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n parentIsLocalized,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue:\n getNestedValue(previousValData, pathSegments) ?? previousValData?.[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n value: siblingDoc?.[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabPreviousSiblingDoc = { ...previousDoc }\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n tabSiblingData = (siblingData?.[field.name] ?? {}) as JsonObject\n tabSiblingDoc = (siblingDoc?.[field.name] ?? {}) as JsonObject\n tabPreviousSiblingDoc = (previousSiblingDoc?.[field.name] ?? {}) as JsonObject\n }\n\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: tabPreviousSiblingDoc,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getFieldPaths","traverseFields","promise","blockData","collection","context","data","doc","field","fieldIndex","global","operation","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","siblingFields","indexPath","path","schemaPath","index","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","getNestedValue","reduce","acc","key","undefined","previousValData","Object","keys","length","hooks","afterChange","hook","hookedValue","originalDoc","previousValue","name","value","type","rows","Array","isArray","promises","forEach","row","rowIndex","push","fields","localized","Promise","all","blockTypeToMatch","blockType","block","payload","blocks","blockReferences","find","curBlock","slug","editor","Error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YwD;gBACd;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX,MAAM3E,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAqD,QAAQpD,MAAMuE,IAAI,CAAC/C,GAAG,CAAC,CAACgD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE7B,MAAM;wBAAM,CAAA;oBACvDzC;oBACAC;oBACAC,iBAAiBU;oBACjBT;oBACAC,YAAYS;oBACZR,kBAAkBS;oBAClBR;oBACAC,oBAAoB;wBAAE,GAAGA,kBAAkB;oBAAC;oBAC5CC;oBACAC,aAAaA,eAAe,CAAC;oBAC7BC,YAAY;wBAAE,GAAGA,UAAU;oBAAC;gBAC9B;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterChange/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, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getBlockFromField } from '../../getBlockFromField.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n field: Field | TabAsField\n fieldIndex: number\n global: null | SanitizedGlobalConfig\n operation: 'create' | 'update'\n parentIndexPath: string\n parentIsLocalized: boolean\n parentPath: string\n parentSchemaPath: string\n previousDoc: JsonObject\n previousSiblingDoc: JsonObject\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingFields?: (Field | TabAsField)[]\n}\n\n// This function is responsible for the following actions, in order:\n// - Execute field hooks\n\nexport const promise = async ({\n blockData,\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\n global,\n operation,\n parentIndexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n siblingFields,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n const getNestedValue = (data: JsonObject, path: string[]) =>\n path.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), data)\n const previousValData =\n previousSiblingDoc && Object.keys(previousSiblingDoc).length > 0\n ? previousSiblingDoc\n : previousDoc\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if ('hooks' in field && field.hooks?.afterChange) {\n for (const hook of field.hooks.afterChange) {\n const hookedValue = await hook({\n blockData,\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue:\n getNestedValue(previousValData, pathSegments) ?? previousValData?.[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n siblingFields: siblingFields!,\n value: getNestedValue(siblingDoc, pathSegments) ?? siblingDoc?.[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n rows.forEach((row, rowIndex) => {\n promises.push(\n traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n\n rows.forEach((row, rowIndex) => {\n const blockTypeToMatch = (row as JsonObject).blockType\n\n const block = getBlockFromField({ blockType: blockTypeToMatch, field, req })\n\n if (block) {\n promises.push(\n traverseFields({\n blockData: siblingData?.[field.name]?.[rowIndex],\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n previousDoc,\n previousSiblingDoc: previousValData?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: (previousDoc?.[field.name] as JsonObject) || {},\n req,\n siblingData: (siblingData?.[field.name] as JsonObject) || {},\n siblingDoc: (siblingDoc?.[field.name] as JsonObject) || {},\n })\n } else {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\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\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?.afterChange?.length) {\n for (const hook of editor.hooks.afterChange) {\n const hookedValue = await hook({\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n parentIsLocalized,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue:\n getNestedValue(previousValData, pathSegments) ?? previousValData?.[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n value: siblingDoc?.[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabPreviousSiblingDoc = { ...previousDoc }\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n tabSiblingData = (siblingData?.[field.name] ?? {}) as JsonObject\n tabSiblingDoc = (siblingDoc?.[field.name] ?? {}) as JsonObject\n tabPreviousSiblingDoc = (previousSiblingDoc?.[field.name] ?? {}) as JsonObject\n }\n\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: tabPreviousSiblingDoc,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getBlockFromField","getFieldPaths","traverseFields","promise","blockData","collection","context","data","doc","field","fieldIndex","global","operation","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","siblingFields","indexPath","path","schemaPath","index","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","getNestedValue","reduce","acc","key","undefined","previousValData","Object","keys","length","hooks","afterChange","hook","hookedValue","originalDoc","previousValue","name","value","type","rows","Array","isArray","promises","forEach","row","rowIndex","push","fields","localized","Promise","all","blockTypeToMatch","blockType","block","slug","editor","Error","tabSiblingData","tabSiblingDoc","tabPreviousSiblingDoc","isNamedTab","tabs","tab"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,cAAc,QAAQ,sBAAqB;AA2BpD,oEAAoE;AACpE,wBAAwB;AAExB,OAAO,MAAMC,UAAU,OAAO,EAC5BC,SAAS,EACTC,U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C9B;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAa/C,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,mBAAmB,CAAA;IACnC,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IACtC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAA;AAU/D,eAAO,MAAM,OAAO,2YAgCjB,IAAI,KAAG,OAAO,CAAC,IAAI,CAw4BrB,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { MissingEditorProp } from '../../../errors/index.js';
|
|
|
2
2
|
import { getBlockSelect } from '../../../utilities/getBlockSelect.js';
|
|
3
3
|
import { stripUnselectedFields } from '../../../utilities/stripUnselectedFields.js';
|
|
4
4
|
import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../../config/types.js';
|
|
5
|
+
import { getBlockFromField } from '../../getBlockFromField.js';
|
|
5
6
|
import { getDefaultValue } from '../../getDefaultValue.js';
|
|
6
7
|
import { getFieldPaths } from '../../getFieldPaths.js';
|
|
7
8
|
import { relationshipPopulationPromise } from './relationshipPopulationPromise.js';
|
|
@@ -358,15 +359,19 @@ export const promise = async ({ blockData, collection, context, currentDepth, de
|
|
|
358
359
|
if (Array.isArray(rows) && rows.length > 0) {
|
|
359
360
|
rows.forEach((row, rowIndex)=>{
|
|
360
361
|
const blockTypeToMatch = row.blockType;
|
|
361
|
-
const block =
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
366
|
-
select: select?.[field.name],
|
|
367
|
-
selectMode: selectMode
|
|
362
|
+
const block = getBlockFromField({
|
|
363
|
+
blockType: blockTypeToMatch,
|
|
364
|
+
field,
|
|
365
|
+
req
|
|
368
366
|
});
|
|
369
367
|
if (block) {
|
|
368
|
+
const { blockSelect, blockSelectMode } = getBlockSelect({
|
|
369
|
+
block,
|
|
370
|
+
// TODO: fix this
|
|
371
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
372
|
+
select: select?.[field.name],
|
|
373
|
+
selectMode: selectMode
|
|
374
|
+
});
|
|
370
375
|
traverseFields({
|
|
371
376
|
blockData: row,
|
|
372
377
|
collection,
|
|
@@ -405,7 +410,11 @@ export const promise = async ({ blockData, collection, context, currentDepth, de
|
|
|
405
410
|
if (Array.isArray(localeRows)) {
|
|
406
411
|
localeRows.forEach((row, rowIndex)=>{
|
|
407
412
|
const blockTypeToMatch = row.blockType;
|
|
408
|
-
const block =
|
|
413
|
+
const block = getBlockFromField({
|
|
414
|
+
blockType: blockTypeToMatch,
|
|
415
|
+
field,
|
|
416
|
+
req
|
|
417
|
+
});
|
|
409
418
|
if (block) {
|
|
410
419
|
traverseFields({
|
|
411
420
|
blockData: row,
|