payload 3.57.0-internal.74d0404 → 3.57.0-internal.801ab5a
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/exports/shared.d.ts +0 -1
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +0 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts +1 -3
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +2 -37
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.d.ts +1 -3
- package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.js +15 -80
- package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +0 -1
- package/dist/globals/config/sanitize.js.map +1 -1
- package/package.json +2 -2
- package/dist/utilities/appendUploadSelectFields.d.ts +0 -11
- package/dist/utilities/appendUploadSelectFields.d.ts.map +0 -1
- package/dist/utilities/appendUploadSelectFields.js +0 -35
- package/dist/utilities/appendUploadSelectFields.js.map +0 -1
package/dist/exports/shared.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocum
|
|
|
15
15
|
export { validOperators, validOperatorSet } from '../types/constants.js';
|
|
16
16
|
export { formatFilesize } from '../uploads/formatFilesize.js';
|
|
17
17
|
export { isImage } from '../uploads/isImage.js';
|
|
18
|
-
export { appendUploadSelectFields } from '../utilities/appendUploadSelectFields.js';
|
|
19
18
|
export { combineWhereConstraints } from '../utilities/combineWhereConstraints.js';
|
|
20
19
|
export { deepCopyObject, deepCopyObjectComplex, deepCopyObjectSimple, deepCopyObjectSimpleWithoutReactComponents, } from '../utilities/deepCopyObject.js';
|
|
21
20
|
export { deepMerge, deepMergeWithCombinedArrays, deepMergeWithReactComponents, deepMergeWithSourceArrays, } from '../utilities/deepMerge.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/exports/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,GACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAA;AACnG,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAA;AAEpF,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,wBAAwB,GACzB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,cAAc,0BAA0B,CAAA;AAExC,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,GACV,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,2BAA2B,EAA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AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAE3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAA;AAEnF,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,4CAA4C,CAAA;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA"}
|
package/dist/exports/shared.js
CHANGED
|
@@ -14,7 +14,6 @@ export { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocum
|
|
|
14
14
|
export { validOperators, validOperatorSet } from '../types/constants.js';
|
|
15
15
|
export { formatFilesize } from '../uploads/formatFilesize.js';
|
|
16
16
|
export { isImage } from '../uploads/isImage.js';
|
|
17
|
-
export { appendUploadSelectFields } from '../utilities/appendUploadSelectFields.js';
|
|
18
17
|
export { combineWhereConstraints } from '../utilities/combineWhereConstraints.js';
|
|
19
18
|
export { deepCopyObject, deepCopyObjectComplex, deepCopyObjectSimple, deepCopyObjectSimpleWithoutReactComponents } from '../utilities/deepCopyObject.js';
|
|
20
19
|
export { deepMerge, deepMergeWithCombinedArrays, deepMergeWithReactComponents, deepMergeWithSourceArrays } from '../utilities/deepMerge.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/shared.ts"],"sourcesContent":["export {\n generateCookie,\n generateExpiredPayloadCookie,\n generatePayloadCookie,\n getCookieExpiration,\n parseCookies,\n} from '../auth/cookies.js'\nexport { getLoginOptions } from '../auth/getLoginOptions.js'\nexport { addSessionToUser, removeExpiredSessions } from '../auth/sessions.js'\nexport { getFromImportMap } from '../bin/generateImportMap/utilities/getFromImportMap.js'\nexport { parsePayloadComponent } from '../bin/generateImportMap/utilities/parsePayloadComponent.js'\nexport { defaults as collectionDefaults } from '../collections/config/defaults.js'\n\nexport { serverProps } from '../config/types.js'\n\nexport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\n\nexport {\n fieldAffectsData,\n fieldHasMaxDepth,\n fieldHasSubFields,\n fieldIsArrayType,\n fieldIsBlockType,\n fieldIsGroupType,\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsLocalized,\n fieldIsPresentationalOnly,\n fieldIsSidebar,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n fieldSupportsMany,\n groupHasName,\n optionIsObject,\n optionIsValue,\n optionsAreObjects,\n tabHasName,\n valueIsValueWithRelation,\n} from '../fields/config/types.js'\n\nexport { getFieldPaths } from '../fields/getFieldPaths.js'\nexport * from '../fields/validations.js'\n\nexport type {\n FolderBreadcrumb,\n FolderDocumentItemKey,\n FolderEnabledColection,\n FolderInterface,\n FolderOrDocument,\n GetFolderDataResult,\n Subfolder,\n} from '../folders/types.js'\n\nexport { buildFolderWhereConstraints } from '../folders/utils/buildFolderWhereConstraints.js'\nexport { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocumentItem.js'\nexport { validOperators, validOperatorSet } from '../types/constants.js'\n\nexport { formatFilesize } from '../uploads/formatFilesize.js'\n\nexport { isImage } from '../uploads/isImage.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/exports/shared.ts"],"sourcesContent":["export {\n generateCookie,\n generateExpiredPayloadCookie,\n generatePayloadCookie,\n getCookieExpiration,\n parseCookies,\n} from '../auth/cookies.js'\nexport { getLoginOptions } from '../auth/getLoginOptions.js'\nexport { addSessionToUser, removeExpiredSessions } from '../auth/sessions.js'\nexport { getFromImportMap } from '../bin/generateImportMap/utilities/getFromImportMap.js'\nexport { parsePayloadComponent } from '../bin/generateImportMap/utilities/parsePayloadComponent.js'\nexport { defaults as collectionDefaults } from '../collections/config/defaults.js'\n\nexport { serverProps } from '../config/types.js'\n\nexport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\n\nexport {\n fieldAffectsData,\n fieldHasMaxDepth,\n fieldHasSubFields,\n fieldIsArrayType,\n fieldIsBlockType,\n fieldIsGroupType,\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsLocalized,\n fieldIsPresentationalOnly,\n fieldIsSidebar,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n fieldSupportsMany,\n groupHasName,\n optionIsObject,\n optionIsValue,\n optionsAreObjects,\n tabHasName,\n valueIsValueWithRelation,\n} from '../fields/config/types.js'\n\nexport { getFieldPaths } from '../fields/getFieldPaths.js'\nexport * from '../fields/validations.js'\n\nexport type {\n FolderBreadcrumb,\n FolderDocumentItemKey,\n FolderEnabledColection,\n FolderInterface,\n FolderOrDocument,\n GetFolderDataResult,\n Subfolder,\n} from '../folders/types.js'\n\nexport { buildFolderWhereConstraints } from '../folders/utils/buildFolderWhereConstraints.js'\nexport { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocumentItem.js'\nexport { validOperators, validOperatorSet } from '../types/constants.js'\n\nexport { formatFilesize } from '../uploads/formatFilesize.js'\n\nexport { isImage } from '../uploads/isImage.js'\nexport { combineWhereConstraints } from '../utilities/combineWhereConstraints.js'\n\nexport {\n deepCopyObject,\n deepCopyObjectComplex,\n deepCopyObjectSimple,\n deepCopyObjectSimpleWithoutReactComponents,\n} from '../utilities/deepCopyObject.js'\nexport {\n deepMerge,\n deepMergeWithCombinedArrays,\n deepMergeWithReactComponents,\n deepMergeWithSourceArrays,\n} from '../utilities/deepMerge.js'\n\nexport { extractID } from '../utilities/extractID.js'\n\nexport { flattenAllFields } from '../utilities/flattenAllFields.js'\nexport { flattenTopLevelFields } from '../utilities/flattenTopLevelFields.js'\nexport { formatAdminURL } from '../utilities/formatAdminURL.js'\n\nexport { formatLabels, toWords } from '../utilities/formatLabels.js'\nexport { getBestFitFromSizes } from '../utilities/getBestFitFromSizes.js'\nexport { getDataByPath } from '../utilities/getDataByPath.js'\nexport { getFieldPermissions } from '../utilities/getFieldPermissions.js'\n\nexport { getSafeRedirect } from '../utilities/getSafeRedirect.js'\n\nexport { getSelectMode } from '../utilities/getSelectMode.js'\n\nexport { getSiblingData } from '../utilities/getSiblingData.js'\n\nexport { getUniqueListBy } from '../utilities/getUniqueListBy.js'\n\nexport { isNextBuild } from '../utilities/isNextBuild.js'\n\nexport { isNumber } from '../utilities/isNumber.js'\n\nexport { isPlainObject } from '../utilities/isPlainObject.js'\n\nexport {\n isReactClientComponent,\n isReactComponentOrFunction,\n isReactServerComponentOrFunction,\n} from '../utilities/isReactComponent.js'\n\nexport {\n hoistQueryParamsToAnd,\n mergeListSearchAndWhere,\n} from '../utilities/mergeListSearchAndWhere.js'\n\nexport { reduceFieldsToValues } from '../utilities/reduceFieldsToValues.js'\n\nexport { sanitizeUserDataForEmail } from '../utilities/sanitizeUserDataForEmail.js'\n\nexport { setsAreEqual } from '../utilities/setsAreEqual.js'\n\nexport { toKebabCase } from '../utilities/toKebabCase.js'\n\nexport {\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from '../utilities/transformColumnPreferences.js'\n\nexport { transformWhereQuery } from '../utilities/transformWhereQuery.js'\n\nexport { unflatten } from '../utilities/unflatten.js'\nexport { validateMimeType } from '../utilities/validateMimeType.js'\nexport { validateWhereQuery } from '../utilities/validateWhereQuery.js'\nexport { wait } from '../utilities/wait.js'\nexport { wordBoundariesRegex } from '../utilities/wordBoundariesRegex.js'\nexport { versionDefaults } from '../versions/defaults.js'\n\nexport { deepMergeSimple } from '@payloadcms/translations/utilities'\n"],"names":["generateCookie","generateExpiredPayloadCookie","generatePayloadCookie","getCookieExpiration","parseCookies","getLoginOptions","addSessionToUser","removeExpiredSessions","getFromImportMap","parsePayloadComponent","defaults","collectionDefaults","serverProps","defaultTimezones","fieldAffectsData","fieldHasMaxDepth","fieldHasSubFields","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","fieldIsHiddenOrDisabled","fieldIsID","fieldIsLocalized","fieldIsPresentationalOnly","fieldIsSidebar","fieldIsVirtual","fieldShouldBeLocalized","fieldSupportsMany","groupHasName","optionIsObject","optionIsValue","optionsAreObjects","tabHasName","valueIsValueWithRelation","getFieldPaths","buildFolderWhereConstraints","formatFolderOrDocumentItem","validOperators","validOperatorSet","formatFilesize","isImage","combineWhereConstraints","deepCopyObject","deepCopyObjectComplex","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","deepMerge","deepMergeWithCombinedArrays","deepMergeWithReactComponents","deepMergeWithSourceArrays","extractID","flattenAllFields","flattenTopLevelFields","formatAdminURL","formatLabels","toWords","getBestFitFromSizes","getDataByPath","getFieldPermissions","getSafeRedirect","getSelectMode","getSiblingData","getUniqueListBy","isNextBuild","isNumber","isPlainObject","isReactClientComponent","isReactComponentOrFunction","isReactServerComponentOrFunction","hoistQueryParamsToAnd","mergeListSearchAndWhere","reduceFieldsToValues","sanitizeUserDataForEmail","setsAreEqual","toKebabCase","transformColumnsToPreferences","transformColumnsToSearchParams","transformWhereQuery","unflatten","validateMimeType","validateWhereQuery","wait","wordBoundariesRegex","versionDefaults","deepMergeSimple"],"mappings":"AAAA,SACEA,cAAc,EACdC,4BAA4B,EAC5BC,qBAAqB,EACrBC,mBAAmB,EACnBC,YAAY,QACP,qBAAoB;AAC3B,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,gBAAgB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAC7E,SAASC,gBAAgB,QAAQ,yDAAwD;AACzF,SAASC,qBAAqB,QAAQ,8DAA6D;AACnG,SAASC,YAAYC,kBAAkB,QAAQ,oCAAmC;AAElF,SAASC,WAAW,QAAQ,qBAAoB;AAEhD,SAASC,gBAAgB,QAAQ,oDAAmD;AAEpF,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,EAChBC,uBAAuB,EACvBC,SAAS,EACTC,gBAAgB,EAChBC,yBAAyB,EACzBC,cAAc,EACdC,cAAc,EACdC,sBAAsB,EACtBC,iBAAiB,EACjBC,YAAY,EACZC,cAAc,EACdC,aAAa,EACbC,iBAAiB,EACjBC,UAAU,EACVC,wBAAwB,QACnB,4BAA2B;AAElC,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,cAAc,2BAA0B;AAYxC,SAASC,2BAA2B,QAAQ,kDAAiD;AAC7F,SAASC,0BAA0B,QAAQ,iDAAgD;AAC3F,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,wBAAuB;AAExE,SAASC,cAAc,QAAQ,+BAA8B;AAE7D,SAASC,OAAO,QAAQ,wBAAuB;AAC/C,SAASC,uBAAuB,QAAQ,0CAAyC;AAEjF,SACEC,cAAc,EACdC,qBAAqB,EACrBC,oBAAoB,EACpBC,0CAA0C,QACrC,iCAAgC;AACvC,SACEC,SAAS,EACTC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,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SanitizedJoins } from '../../collections/config/types.js';
|
|
2
2
|
import type { Config, SanitizedConfig } from '../../config/types.js';
|
|
3
|
-
import type { GlobalConfig } from '../../globals/config/types.js';
|
|
4
3
|
import type { Field } from './types.js';
|
|
5
4
|
type Args = {
|
|
6
5
|
collectionConfig?: CollectionConfig;
|
|
7
6
|
config: Config;
|
|
8
7
|
existingFieldNames?: Set<string>;
|
|
9
8
|
fields: Field[];
|
|
10
|
-
globalConfig?: GlobalConfig;
|
|
11
9
|
/**
|
|
12
10
|
* Used to prevent unnecessary sanitization of fields that are not top-level.
|
|
13
11
|
*/
|
|
@@ -36,6 +34,6 @@ type Args = {
|
|
|
36
34
|
*/
|
|
37
35
|
validRelationships: null | string[];
|
|
38
36
|
};
|
|
39
|
-
export declare const sanitizeFields: ({ collectionConfig, config, existingFieldNames, fields,
|
|
37
|
+
export declare const sanitizeFields: ({ collectionConfig, config, existingFieldNames, fields, isTopLevelField, joinPath, joins, parentIsLocalized, polymorphicJoins, requireFieldLevelRichTextEditor, richTextSanitizationPromises, validRelationships, }: Args) => Promise<Field[]>;
|
|
40
38
|
export {};
|
|
41
39
|
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,cAAc,EACf,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,cAAc,EACf,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AA0BvC,KAAK,IAAI,GAAG;IACV,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,gBAAgB,CAAC,EAAE,aAAa,EAAE,CAAA;IAClC;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IACzC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChF;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,wNAaxB,IAAI,KAAG,OAAO,CAAC,KAAK,EAAE,CAmVxB,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { deepMergeSimple } from '@payloadcms/translations/utilities';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
|
3
|
-
import { DuplicateFieldName,
|
|
3
|
+
import { DuplicateFieldName, InvalidFieldName, InvalidFieldRelationship, MissingEditorProp, MissingFieldType } from '../../errors/index.js';
|
|
4
4
|
import { ReservedFieldName } from '../../errors/ReservedFieldName.js';
|
|
5
|
-
import { flattenAllFields } from '../../utilities/flattenAllFields.js';
|
|
6
5
|
import { formatLabels, toWords } from '../../utilities/formatLabels.js';
|
|
7
6
|
import { baseBlockFields } from '../baseFields/baseBlockFields.js';
|
|
8
7
|
import { baseIDField } from '../baseFields/baseIDField.js';
|
|
@@ -13,7 +12,7 @@ import { validations } from '../validations.js';
|
|
|
13
12
|
import { reservedAPIKeyFieldNames, reservedBaseAuthFieldNames, reservedBaseUploadFieldNames, reservedVerifyFieldNames } from './reservedFieldNames.js';
|
|
14
13
|
import { sanitizeJoinField } from './sanitizeJoinField.js';
|
|
15
14
|
import { fieldAffectsData as _fieldAffectsData, fieldIsLocalized, tabHasName } from './types.js';
|
|
16
|
-
export const sanitizeFields = async ({ collectionConfig, config, existingFieldNames = new Set(), fields,
|
|
15
|
+
export const sanitizeFields = async ({ collectionConfig, config, existingFieldNames = new Set(), fields, isTopLevelField = true, joinPath = '', joins, parentIsLocalized, polymorphicJoins, requireFieldLevelRichTextEditor = false, richTextSanitizationPromises, validRelationships })=>{
|
|
17
16
|
if (!fields) {
|
|
18
17
|
return [];
|
|
19
18
|
}
|
|
@@ -278,40 +277,6 @@ export const sanitizeFields = async ({ collectionConfig, config, existingFieldNa
|
|
|
278
277
|
});
|
|
279
278
|
fields.splice(++i, 0, timezoneField);
|
|
280
279
|
}
|
|
281
|
-
if ('virtual' in field && typeof field.virtual === 'string') {
|
|
282
|
-
const virtualField = field;
|
|
283
|
-
const fields = (collectionConfig || globalConfig)?.fields;
|
|
284
|
-
if (fields) {
|
|
285
|
-
let flattenFields = flattenAllFields({
|
|
286
|
-
fields
|
|
287
|
-
});
|
|
288
|
-
const paths = field.virtual.split('.');
|
|
289
|
-
let isHasMany = false;
|
|
290
|
-
for (const [i, segment] of paths.entries()){
|
|
291
|
-
const field = flattenFields.find((e)=>e.name === segment);
|
|
292
|
-
if (!field) {
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
if (field.type === 'group' || field.type === 'tab' || field.type === 'array') {
|
|
296
|
-
flattenFields = field.flattenedFields;
|
|
297
|
-
} else if ((field.type === 'relationship' || field.type === 'upload') && i !== paths.length - 1 && typeof field.relationTo === 'string') {
|
|
298
|
-
if (field.hasMany && (virtualField.type === 'text' || virtualField.type === 'number' || virtualField.type === 'select')) {
|
|
299
|
-
if (isHasMany) {
|
|
300
|
-
throw new InvalidConfiguration(`Virtual field ${virtualField.name} in ${globalConfig ? `global ${globalConfig.slug}` : `collection ${collectionConfig?.slug}`} references 2 or more hasMany relationships on the path ${virtualField.virtual} which is not allowed.`);
|
|
301
|
-
}
|
|
302
|
-
isHasMany = true;
|
|
303
|
-
virtualField.hasMany = true;
|
|
304
|
-
}
|
|
305
|
-
const relatedCollection = config.collections?.find((e)=>e.slug === field.relationTo);
|
|
306
|
-
if (relatedCollection) {
|
|
307
|
-
flattenFields = flattenAllFields({
|
|
308
|
-
fields: relatedCollection.fields
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
280
|
}
|
|
316
281
|
return fields;
|
|
317
282
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import { deepMergeSimple } from '@payloadcms/translations/utilities'\nimport { v4 as uuid } from 'uuid'\n\nimport type {\n CollectionConfig,\n SanitizedJoin,\n SanitizedJoins,\n} from '../../collections/config/types.js'\nimport type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { GlobalConfig } from '../../globals/config/types.js'\nimport type { Field } from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidConfiguration,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingEditorProp,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { ReservedFieldName } from '../../errors/ReservedFieldName.js'\nimport { flattenAllFields } from '../../utilities/flattenAllFields.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { getFieldByPath } from '../../utilities/getFieldByPath.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { baseTimezoneField } from '../baseFields/timezone/baseField.js'\nimport { defaultTimezones } from '../baseFields/timezone/defaultTimezones.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport { validations } from '../validations.js'\nimport {\n reservedAPIKeyFieldNames,\n reservedBaseAuthFieldNames,\n reservedBaseUploadFieldNames,\n reservedVerifyFieldNames,\n} from './reservedFieldNames.js'\nimport { sanitizeJoinField } from './sanitizeJoinField.js'\nimport {\n fieldAffectsData as _fieldAffectsData,\n fieldIsLocalized,\n fieldIsVirtual,\n tabHasName,\n} from './types.js'\n\ntype Args = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n globalConfig?: GlobalConfig\n /**\n * Used to prevent unnecessary sanitization of fields that are not top-level.\n */\n isTopLevelField?: boolean\n joinPath?: string\n /**\n * When not passed in, assume that join are not supported (globals, arrays, blocks)\n */\n joins?: SanitizedJoins\n parentIsLocalized: boolean\n polymorphicJoins?: SanitizedJoin[]\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\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 /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport const sanitizeFields = async ({\n collectionConfig,\n config,\n existingFieldNames = new Set(),\n fields,\n globalConfig,\n isTopLevelField = true,\n joinPath = '',\n joins,\n parentIsLocalized,\n polymorphicJoins,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: Args): Promise<Field[]> => {\n if (!fields) {\n return []\n }\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]!\n\n if ('_sanitized' in field && field._sanitized === true) {\n continue\n }\n\n if ('_sanitized' in field) {\n field._sanitized = true\n }\n\n if (!field.type) {\n throw new MissingFieldType(field)\n }\n\n const fieldAffectsData = _fieldAffectsData(field)\n\n if (isTopLevelField && fieldAffectsData && field.name) {\n if (collectionConfig && collectionConfig.upload) {\n if (reservedBaseUploadFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n }\n\n if (\n collectionConfig &&\n collectionConfig.auth &&\n typeof collectionConfig.auth === 'object' &&\n !collectionConfig.auth.disableLocalStrategy\n ) {\n if (reservedBaseAuthFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n\n if (collectionConfig.auth.verify) {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n if (reservedAPIKeyFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n if (reservedVerifyFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n }\n }\n }\n\n // assert that field names do not contain forbidden characters\n if (fieldAffectsData && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n typeof field.label !== 'function' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n if (field.type === 'join') {\n sanitizeJoinField({ config, field, joinPath, joins, parentIsLocalized, polymorphicJoins })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n field.minRows = field.min\n }\n\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n field.maxRows = field.max\n }\n }\n\n if (field.type === 'upload') {\n if (!field.admin || !('isSortable' in field.admin)) {\n field.admin = {\n isSortable: true,\n ...field.admin,\n }\n }\n }\n\n if (field.type === 'array' && field.fields) {\n const hasCustomID = field.fields.some((f) => 'name' in f && f.name === 'id')\n if (!hasCustomID) {\n field.fields.push(baseIDField)\n }\n }\n\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (typeof field.localized !== 'undefined') {\n let shouldDisableLocalized = !config.localization\n\n if (\n process.env.NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized !== 'true' &&\n parentIsLocalized &&\n // @todo PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY=true will be the default in 4.0\n process.env.PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY !== 'true'\n ) {\n shouldDisableLocalized = true\n }\n\n if (shouldDisableLocalized) {\n delete field.localized\n }\n }\n\n if (typeof field.validate === 'undefined') {\n const defaultValidate = validations[field.type as keyof typeof validations]\n if (defaultValidate) {\n field.validate = (val: any, options: any) =>\n defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = (): true => true\n }\n }\n\n if (!field.hooks) {\n field.hooks = {}\n }\n\n if (!field.access) {\n field.access = {}\n }\n\n setDefaultBeforeDuplicate(field, parentIsLocalized)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\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\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({\n config: _config,\n isRoot: requireFieldLevelRichTextEditor,\n parentIsLocalized: (parentIsLocalized || field.localized)!,\n })\n }\n\n if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {\n config.i18n!.translations = deepMergeSimple(config.i18n!.translations!, field.editor.i18n)\n }\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n if (field.blockReferences && field.blocks?.length) {\n throw new Error('You cannot have both blockReferences and blocks in the same blocks field')\n }\n\n const blockSlugs: string[] = []\n\n for (const block of field.blockReferences ?? field.blocks) {\n const blockSlug = typeof block === 'string' ? block : block.slug\n\n if (blockSlugs.includes(blockSlug)) {\n throw new DuplicateFieldName(blockSlug)\n }\n\n blockSlugs.push(blockSlug)\n\n if (typeof block === 'string') {\n continue\n }\n\n if (block._sanitized === true) {\n continue\n }\n\n block._sanitized = true\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n block.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n isTopLevelField: false,\n parentIsLocalized: (parentIsLocalized || field.localized)!,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: fieldAffectsData ? new Set() : existingFieldNames,\n fields: field.fields,\n isTopLevelField: isTopLevelField && !fieldAffectsData,\n joinPath: fieldAffectsData ? `${joinPath ? joinPath + '.' : ''}${field.name}` : joinPath,\n joins,\n parentIsLocalized: parentIsLocalized || fieldIsLocalized(field),\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]!\n\n const isNamedTab = tabHasName(tab)\n\n if (isNamedTab && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n if (\n 'admin' in tab &&\n tab.admin?.condition &&\n typeof tab.admin.condition === 'function' &&\n !tab.id\n ) {\n // Always attach a UUID to tabs with a condition so there's no conflicts even if there are duplicate nested names\n tab.id = isNamedTab ? `${tab.name}_${uuid()}` : uuid()\n }\n\n tab.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: isNamedTab ? new Set() : existingFieldNames,\n fields: tab.fields,\n isTopLevelField: isTopLevelField && !isNamedTab,\n joinPath: isNamedTab ? `${joinPath ? joinPath + '.' : ''}${tab.name}` : joinPath,\n joins,\n parentIsLocalized: parentIsLocalized || (isNamedTab && tab.localized)!,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n field.tabs[j] = tab\n }\n }\n\n if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') {\n field.admin.disableBulkEdit = true\n }\n\n fields[i] = field\n\n // Insert our field after assignment\n if (field.type === 'date' && field.timezone) {\n const name = field.name + '_tz'\n const defaultTimezone = config.admin?.timezones?.defaultTimezone\n\n const supportedTimezones = config.admin?.timezones?.supportedTimezones\n\n const options =\n typeof supportedTimezones === 'function'\n ? supportedTimezones({ defaultTimezones })\n : supportedTimezones\n\n // Need to set the options here manually so that any database enums are generated correctly\n // The UI component will import the options from the config\n const timezoneField = baseTimezoneField({\n name,\n defaultValue: defaultTimezone,\n options,\n required: field.required,\n })\n\n fields.splice(++i, 0, timezoneField)\n }\n\n if ('virtual' in field && typeof field.virtual === 'string') {\n const virtualField = field\n const fields = (collectionConfig || globalConfig)?.fields\n if (fields) {\n let flattenFields = flattenAllFields({ fields })\n const paths = field.virtual.split('.')\n let isHasMany = false\n\n for (const [i, segment] of paths.entries()) {\n const field = flattenFields.find((e) => e.name === segment)\n if (!field) {\n break\n }\n\n if (field.type === 'group' || field.type === 'tab' || field.type === 'array') {\n flattenFields = field.flattenedFields\n } else if (\n (field.type === 'relationship' || field.type === 'upload') &&\n i !== paths.length - 1 &&\n typeof field.relationTo === 'string'\n ) {\n if (\n field.hasMany &&\n (virtualField.type === 'text' ||\n virtualField.type === 'number' ||\n virtualField.type === 'select')\n ) {\n if (isHasMany) {\n throw new InvalidConfiguration(\n `Virtual field ${virtualField.name} in ${globalConfig ? `global ${globalConfig.slug}` : `collection ${collectionConfig?.slug}`} references 2 or more hasMany relationships on the path ${virtualField.virtual} which is not allowed.`,\n )\n }\n\n isHasMany = true\n virtualField.hasMany = true\n }\n const relatedCollection = config.collections?.find((e) => e.slug === field.relationTo)\n if (relatedCollection) {\n flattenFields = flattenAllFields({ fields: relatedCollection.fields })\n }\n }\n }\n }\n }\n }\n\n return fields\n}\n"],"names":["deepMergeSimple","v4","uuid","DuplicateFieldName","InvalidConfiguration","InvalidFieldName","InvalidFieldRelationship","MissingEditorProp","MissingFieldType","ReservedFieldName","flattenAllFields","formatLabels","toWords","baseBlockFields","baseIDField","baseTimezoneField","defaultTimezones","setDefaultBeforeDuplicate","validations","reservedAPIKeyFieldNames","reservedBaseAuthFieldNames","reservedBaseUploadFieldNames","reservedVerifyFieldNames","sanitizeJoinField","fieldAffectsData","_fieldAffectsData","fieldIsLocalized","tabHasName","sanitizeFields","collectionConfig","config","existingFieldNames","Set","fields","globalConfig","isTopLevelField","joinPath","joins","parentIsLocalized","polymorphicJoins","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","i","length","field","_sanitized","type","name","upload","includes","auth","disableLocalStrategy","verify","label","defaultValue","required","relationships","Array","isArray","relationTo","forEach","relationship","min","minRows","console","warn","max","maxRows","admin","isSortable","hasCustomID","some","f","push","labels","has","add","localized","shouldDisableLocalized","localization","process","env","NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized","PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY","validate","defaultValidate","val","options","hooks","access","sanitizeRichText","_config","editor","isRoot","i18n","Object","keys","translations","blocks","blockReferences","Error","blockSlugs","block","blockSlug","slug","concat","j","tabs","tab","isNamedTab","condition","id","disableBulkEdit","timezone","defaultTimezone","timezones","supportedTimezones","timezoneField","splice","virtual","virtualField","flattenFields","paths","split","isHasMany","segment","entries","find","e","flattenedFields","hasMany","relatedCollection","collections"],"mappings":"AAAA,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAWjC,SACEC,kBAAkB,EAClBC,oBAAoB,EACpBC,gBAAgB,EAChBC,wBAAwB,EACxBC,iBAAiB,EACjBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,gBAAgB,QAAQ,sCAAqC;AACtE,SAASC,YAAY,EAAEC,OAAO,QAAQ,kCAAiC;AAEvE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SACEC,wBAAwB,EACxBC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,wBAAwB,QACnB,0BAAyB;AAChC,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SACEC,oBAAoBC,iBAAiB,EACrCC,gBAAgB,EAEhBC,UAAU,QACL,aAAY;AAqCnB,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,gBAAgB,EAChBC,MAAM,EACNC,qBAAqB,IAAIC,KAAK,EAC9BC,MAAM,EACNC,YAAY,EACZC,kBAAkB,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AAGmF,QAAQ,IAAIH,MAAMI,OAAO,GAAI;oBAC1C,MAAMlF,QAAQ6E,cAAcM,IAAI,CAAC,CAACC,IAAMA,EAAEjF,IAAI,KAAK8E;oBACnD,IAAI,CAACjF,OAAO;wBACV;oBACF;oBAEA,IAAIA,MAAME,IAAI,KAAK,WAAWF,MAAME,IAAI,KAAK,SAASF,MAAME,IAAI,KAAK,SAAS;wBAC5E2E,gBAAgB7E,MAAMqF,eAAe;oBACvC,OAAO,IACL,AAACrF,CAAAA,MAAME,IAAI,KAAK,kBAAkBF,MAAME,IAAI,KAAK,QAAO,KACxDJ,MAAMgF,MAAM/E,MAAM,GAAG,KACrB,OAAOC,MAAMe,UAAU,KAAK,UAC5B;wBACA,IACEf,MAAMsF,OAAO,IACZV,CAAAA,aAAa1E,IAAI,KAAK,UACrB0E,aAAa1E,IAAI,KAAK,YACtB0E,aAAa1E,IAAI,KAAK,QAAO,GAC/B;4BACA,IAAI8E,WAAW;gCACb,MAAM,IAAIzH,qBACR,CAAC,cAAc,EAAEqH,aAAazE,IAAI,CAAC,IAAI,EAAEd,eAAe,CAAC,OAAO,EAAEA,aAAauE,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE5E,kBAAkB4E,MAAM,CAAC,wDAAwD,EAAEgB,aAAaD,OAAO,CAAC,sBAAsB,CAAC;4BAEzO;4BAEAK,YAAY;4BACZJ,aAAaU,OAAO,GAAG;wBACzB;wBACA,MAAMC,oBAAoBtG,OAAOuG,WAAW,EAAEL,KAAK,CAACC,IAAMA,EAAExB,IAAI,KAAK5D,MAAMe,UAAU;wBACrF,IAAIwE,mBAAmB;4BACrBV,gBAAgBhH,iBAAiB;gCAAEuB,QAAQmG,kBAAkBnG,MAAM;4BAAC;wBACtE;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOA;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import { deepMergeSimple } from '@payloadcms/translations/utilities'\nimport { v4 as uuid } from 'uuid'\n\nimport type {\n CollectionConfig,\n SanitizedJoin,\n SanitizedJoins,\n} from '../../collections/config/types.js'\nimport type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { Field } from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingEditorProp,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { ReservedFieldName } from '../../errors/ReservedFieldName.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { baseTimezoneField } from '../baseFields/timezone/baseField.js'\nimport { defaultTimezones } from '../baseFields/timezone/defaultTimezones.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport { validations } from '../validations.js'\nimport {\n reservedAPIKeyFieldNames,\n reservedBaseAuthFieldNames,\n reservedBaseUploadFieldNames,\n reservedVerifyFieldNames,\n} from './reservedFieldNames.js'\nimport { sanitizeJoinField } from './sanitizeJoinField.js'\nimport { fieldAffectsData as _fieldAffectsData, fieldIsLocalized, tabHasName } from './types.js'\n\ntype Args = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n /**\n * Used to prevent unnecessary sanitization of fields that are not top-level.\n */\n isTopLevelField?: boolean\n joinPath?: string\n /**\n * When not passed in, assume that join are not supported (globals, arrays, blocks)\n */\n joins?: SanitizedJoins\n parentIsLocalized: boolean\n polymorphicJoins?: SanitizedJoin[]\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\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 /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport const sanitizeFields = async ({\n collectionConfig,\n config,\n existingFieldNames = new Set(),\n fields,\n isTopLevelField = true,\n joinPath = '',\n joins,\n parentIsLocalized,\n polymorphicJoins,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: Args): Promise<Field[]> => {\n if (!fields) {\n return []\n }\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]!\n\n if ('_sanitized' in field && field._sanitized === true) {\n continue\n }\n\n if ('_sanitized' in field) {\n field._sanitized = true\n }\n\n if (!field.type) {\n throw new MissingFieldType(field)\n }\n\n const fieldAffectsData = _fieldAffectsData(field)\n\n if (isTopLevelField && fieldAffectsData && field.name) {\n if (collectionConfig && collectionConfig.upload) {\n if (reservedBaseUploadFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n }\n\n if (\n collectionConfig &&\n collectionConfig.auth &&\n typeof collectionConfig.auth === 'object' &&\n !collectionConfig.auth.disableLocalStrategy\n ) {\n if (reservedBaseAuthFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n\n if (collectionConfig.auth.verify) {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n if (reservedAPIKeyFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n if (reservedVerifyFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n }\n }\n }\n\n // assert that field names do not contain forbidden characters\n if (fieldAffectsData && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n typeof field.label !== 'function' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n if (field.type === 'join') {\n sanitizeJoinField({ config, field, joinPath, joins, parentIsLocalized, polymorphicJoins })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n field.minRows = field.min\n }\n\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n field.maxRows = field.max\n }\n }\n\n if (field.type === 'upload') {\n if (!field.admin || !('isSortable' in field.admin)) {\n field.admin = {\n isSortable: true,\n ...field.admin,\n }\n }\n }\n\n if (field.type === 'array' && field.fields) {\n const hasCustomID = field.fields.some((f) => 'name' in f && f.name === 'id')\n if (!hasCustomID) {\n field.fields.push(baseIDField)\n }\n }\n\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (typeof field.localized !== 'undefined') {\n let shouldDisableLocalized = !config.localization\n\n if (\n process.env.NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized !== 'true' &&\n parentIsLocalized &&\n // @todo PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY=true will be the default in 4.0\n process.env.PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY !== 'true'\n ) {\n shouldDisableLocalized = true\n }\n\n if (shouldDisableLocalized) {\n delete field.localized\n }\n }\n\n if (typeof field.validate === 'undefined') {\n const defaultValidate = validations[field.type as keyof typeof validations]\n if (defaultValidate) {\n field.validate = (val: any, options: any) =>\n defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = (): true => true\n }\n }\n\n if (!field.hooks) {\n field.hooks = {}\n }\n\n if (!field.access) {\n field.access = {}\n }\n\n setDefaultBeforeDuplicate(field, parentIsLocalized)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\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\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({\n config: _config,\n isRoot: requireFieldLevelRichTextEditor,\n parentIsLocalized: (parentIsLocalized || field.localized)!,\n })\n }\n\n if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {\n config.i18n!.translations = deepMergeSimple(config.i18n!.translations!, field.editor.i18n)\n }\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n if (field.blockReferences && field.blocks?.length) {\n throw new Error('You cannot have both blockReferences and blocks in the same blocks field')\n }\n\n const blockSlugs: string[] = []\n\n for (const block of field.blockReferences ?? field.blocks) {\n const blockSlug = typeof block === 'string' ? block : block.slug\n\n if (blockSlugs.includes(blockSlug)) {\n throw new DuplicateFieldName(blockSlug)\n }\n\n blockSlugs.push(blockSlug)\n\n if (typeof block === 'string') {\n continue\n }\n\n if (block._sanitized === true) {\n continue\n }\n\n block._sanitized = true\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n block.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n isTopLevelField: false,\n parentIsLocalized: (parentIsLocalized || field.localized)!,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: fieldAffectsData ? new Set() : existingFieldNames,\n fields: field.fields,\n isTopLevelField: isTopLevelField && !fieldAffectsData,\n joinPath: fieldAffectsData ? `${joinPath ? joinPath + '.' : ''}${field.name}` : joinPath,\n joins,\n parentIsLocalized: parentIsLocalized || fieldIsLocalized(field),\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]!\n\n const isNamedTab = tabHasName(tab)\n\n if (isNamedTab && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n if (\n 'admin' in tab &&\n tab.admin?.condition &&\n typeof tab.admin.condition === 'function' &&\n !tab.id\n ) {\n // Always attach a UUID to tabs with a condition so there's no conflicts even if there are duplicate nested names\n tab.id = isNamedTab ? `${tab.name}_${uuid()}` : uuid()\n }\n\n tab.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: isNamedTab ? new Set() : existingFieldNames,\n fields: tab.fields,\n isTopLevelField: isTopLevelField && !isNamedTab,\n joinPath: isNamedTab ? `${joinPath ? joinPath + '.' : ''}${tab.name}` : joinPath,\n joins,\n parentIsLocalized: parentIsLocalized || (isNamedTab && tab.localized)!,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n field.tabs[j] = tab\n }\n }\n\n if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') {\n field.admin.disableBulkEdit = true\n }\n\n fields[i] = field\n\n // Insert our field after assignment\n if (field.type === 'date' && field.timezone) {\n const name = field.name + '_tz'\n const defaultTimezone = config.admin?.timezones?.defaultTimezone\n\n const supportedTimezones = config.admin?.timezones?.supportedTimezones\n\n const options =\n typeof supportedTimezones === 'function'\n ? supportedTimezones({ defaultTimezones })\n : supportedTimezones\n\n // Need to set the options here manually so that any database enums are generated correctly\n // The UI component will import the options from the config\n const timezoneField = baseTimezoneField({\n name,\n defaultValue: defaultTimezone,\n options,\n required: field.required,\n })\n\n fields.splice(++i, 0, timezoneField)\n }\n }\n\n return fields\n}\n"],"names":["deepMergeSimple","v4","uuid","DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingEditorProp","MissingFieldType","ReservedFieldName","formatLabels","toWords","baseBlockFields","baseIDField","baseTimezoneField","defaultTimezones","setDefaultBeforeDuplicate","validations","reservedAPIKeyFieldNames","reservedBaseAuthFieldNames","reservedBaseUploadFieldNames","reservedVerifyFieldNames","sanitizeJoinField","fieldAffectsData","_fieldAffectsData","fieldIsLocalized","tabHasName","sanitizeFields","collectionConfig","config","existingFieldNames","Set","fields","isTopLevelField","joinPath","joins","parentIsLocalized","polymorphicJoins","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","i","length","field","_sanitized","type","name","upload","includes","auth","disableLocalStrategy","verify","label","defaultValue","required","relationships","Array","isArray","relationTo","forEach","relationship","min","minRows","console","warn","max","maxRows","admin","isSortable","hasCustomID","some","f","push","labels","has","add","localized","shouldDisableLocalized","localization","process","env","NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized","PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY","validate","defaultValidate","val","options","hooks","access","sanitizeRichText","_config","editor","isRoot","i18n","Object","keys","translations","blocks","blockReferences","Error","blockSlugs","block","blockSlug","slug","concat","j","tabs","tab","isNamedTab","condition","id","disableBulkEdit","timezone","defaultTimezone","timezones","supportedTimezones","timezoneField","splice"],"mappings":"AAAA,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAAS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MAAMlE,OAAOH,MAAMG,IAAI,GAAG;YAC1B,MAAMmE,kBAAkBpF,OAAOsC,KAAK,EAAE+C,WAAWD;YAEjD,MAAME,qBAAqBtF,OAAOsC,KAAK,EAAE+C,WAAWC;YAEpD,MAAM7B,UACJ,OAAO6B,uBAAuB,aAC1BA,mBAAmB;gBAAEpG;YAAiB,KACtCoG;YAEN,2FAA2F;YAC3F,2DAA2D;YAC3D,MAAMC,gBAAgBtG,kBAAkB;gBACtCgC;gBACAO,cAAc4D;gBACd3B;gBACAhC,UAAUX,MAAMW,QAAQ;YAC1B;YAEAtB,OAAOqF,MAAM,CAAC,EAAE5E,GAAG,GAAG2E;QACxB;IACF;IAEA,OAAOpF;AACT,EAAC"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import type { PayloadRequest } from '../../../types/index.js';
|
|
2
2
|
import type { FlattenedField } from '../../config/types.js';
|
|
3
|
-
export declare const virtualFieldPopulationPromise: ({ name, draft, fallbackLocale, fields,
|
|
3
|
+
export declare const virtualFieldPopulationPromise: ({ name, draft, fallbackLocale, fields, locale, overrideAccess, ref, req, segments, showHiddenFields, siblingDoc, }: {
|
|
4
4
|
draft: boolean;
|
|
5
5
|
fallbackLocale: string;
|
|
6
6
|
fields: FlattenedField[];
|
|
7
|
-
hasMany?: boolean;
|
|
8
7
|
locale: string;
|
|
9
8
|
name: string;
|
|
10
9
|
overrideAccess: boolean;
|
|
11
10
|
ref: any;
|
|
12
11
|
req: PayloadRequest;
|
|
13
12
|
segments: string[];
|
|
14
|
-
shift?: boolean;
|
|
15
13
|
showHiddenFields: boolean;
|
|
16
14
|
siblingDoc: Record<string, unknown>;
|
|
17
15
|
}) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtualFieldPopulationPromise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/virtualFieldPopulationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"virtualFieldPopulationPromise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/virtualFieldPopulationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,6BAA6B,uHAYvC;IACD,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,GAAG,CAAA;IACR,GAAG,EAAE,cAAc,CAAA;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,KAAG,OAAO,CAAC,IAAI,CAuHf,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDataloaderCacheKey } from '../../../collections/dataloader.js';
|
|
2
|
-
export const virtualFieldPopulationPromise = async ({ name, draft, fallbackLocale, fields,
|
|
2
|
+
export const virtualFieldPopulationPromise = async ({ name, draft, fallbackLocale, fields, locale, overrideAccess, ref, req, segments, showHiddenFields, siblingDoc })=>{
|
|
3
3
|
const currentSegment = segments.shift();
|
|
4
4
|
if (!currentSegment) {
|
|
5
5
|
return;
|
|
@@ -10,15 +10,7 @@ export const virtualFieldPopulationPromise = async ({ name, draft, fallbackLocal
|
|
|
10
10
|
}
|
|
11
11
|
// Final step
|
|
12
12
|
if (segments.length === 0) {
|
|
13
|
-
|
|
14
|
-
if (!Array.isArray(siblingDoc[name])) {
|
|
15
|
-
siblingDoc[name] = [];
|
|
16
|
-
}
|
|
17
|
-
;
|
|
18
|
-
siblingDoc[name].push(currentValue);
|
|
19
|
-
} else {
|
|
20
|
-
siblingDoc[name] = currentValue;
|
|
21
|
-
}
|
|
13
|
+
siblingDoc[name] = currentValue;
|
|
22
14
|
return;
|
|
23
15
|
}
|
|
24
16
|
const currentField = fields.find((each)=>each.name === currentSegment);
|
|
@@ -43,75 +35,7 @@ export const virtualFieldPopulationPromise = async ({ name, draft, fallbackLocal
|
|
|
43
35
|
siblingDoc
|
|
44
36
|
});
|
|
45
37
|
}
|
|
46
|
-
if ((currentField.type === 'relationship' || currentField.type === 'upload') && typeof currentField.relationTo === 'string') {
|
|
47
|
-
const select = {};
|
|
48
|
-
let currentSelectRef = select;
|
|
49
|
-
const currentFields = req.payload.collections[currentField.relationTo]?.config.flattenedFields;
|
|
50
|
-
for(let i = 0; i < segments.length; i++){
|
|
51
|
-
const field = currentFields?.find((each)=>each.name === segments[i]);
|
|
52
|
-
const shouldBreak = i === segments.length - 1 || field?.type === 'relationship' || field?.type === 'upload';
|
|
53
|
-
currentSelectRef[segments[i]] = shouldBreak ? true : {};
|
|
54
|
-
currentSelectRef = currentSelectRef[segments[i]];
|
|
55
|
-
if (shouldBreak) {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (currentField.hasMany) {
|
|
60
|
-
if (!Array.isArray(currentValue)) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const docIDs = currentValue.map((e)=>{
|
|
64
|
-
if (!e) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
if (typeof e === 'object') {
|
|
68
|
-
return e.id;
|
|
69
|
-
}
|
|
70
|
-
return e;
|
|
71
|
-
}).filter((e)=>typeof e === 'string' || typeof e === 'number');
|
|
72
|
-
if (segments[0] === 'id' && segments.length === 0) {
|
|
73
|
-
siblingDoc[name] = docIDs;
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const collectionSlug = currentField.relationTo;
|
|
77
|
-
const populatedDocs = await Promise.all(docIDs.map((docID)=>{
|
|
78
|
-
return req.payloadDataLoader.load(createDataloaderCacheKey({
|
|
79
|
-
collectionSlug,
|
|
80
|
-
currentDepth: 0,
|
|
81
|
-
depth: 0,
|
|
82
|
-
docID,
|
|
83
|
-
draft,
|
|
84
|
-
fallbackLocale,
|
|
85
|
-
locale,
|
|
86
|
-
overrideAccess,
|
|
87
|
-
select,
|
|
88
|
-
showHiddenFields,
|
|
89
|
-
transactionID: req.transactionID
|
|
90
|
-
}));
|
|
91
|
-
}));
|
|
92
|
-
for (const doc of populatedDocs){
|
|
93
|
-
if (!doc) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
await virtualFieldPopulationPromise({
|
|
97
|
-
name,
|
|
98
|
-
draft,
|
|
99
|
-
fallbackLocale,
|
|
100
|
-
fields: req.payload.collections[currentField.relationTo].config.flattenedFields,
|
|
101
|
-
hasMany: true,
|
|
102
|
-
locale,
|
|
103
|
-
overrideAccess,
|
|
104
|
-
ref: doc,
|
|
105
|
-
req,
|
|
106
|
-
segments: [
|
|
107
|
-
...segments
|
|
108
|
-
],
|
|
109
|
-
showHiddenFields,
|
|
110
|
-
siblingDoc
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
38
|
+
if ((currentField.type === 'relationship' || currentField.type === 'upload') && typeof currentField.relationTo === 'string' && !currentField.hasMany) {
|
|
115
39
|
let docID;
|
|
116
40
|
if (typeof currentValue === 'object' && currentValue) {
|
|
117
41
|
docID = currentValue.id;
|
|
@@ -125,6 +49,18 @@ export const virtualFieldPopulationPromise = async ({ name, draft, fallbackLocal
|
|
|
125
49
|
if (typeof docID !== 'string' && typeof docID !== 'number') {
|
|
126
50
|
return;
|
|
127
51
|
}
|
|
52
|
+
const select = {};
|
|
53
|
+
let currentSelectRef = select;
|
|
54
|
+
const currentFields = req.payload.collections[currentField.relationTo]?.config.flattenedFields;
|
|
55
|
+
for(let i = 0; i < segments.length; i++){
|
|
56
|
+
const field = currentFields?.find((each)=>each.name === segments[i]);
|
|
57
|
+
const shouldBreak = i === segments.length - 1 || field?.type === 'relationship' || field?.type === 'upload';
|
|
58
|
+
currentSelectRef[segments[i]] = shouldBreak ? true : {};
|
|
59
|
+
currentSelectRef = currentSelectRef[segments[i]];
|
|
60
|
+
if (shouldBreak) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
128
64
|
const populatedDoc = await req.payloadDataLoader.load(createDataloaderCacheKey({
|
|
129
65
|
collectionSlug: currentField.relationTo,
|
|
130
66
|
currentDepth: 0,
|
|
@@ -146,7 +82,6 @@ export const virtualFieldPopulationPromise = async ({ name, draft, fallbackLocal
|
|
|
146
82
|
draft,
|
|
147
83
|
fallbackLocale,
|
|
148
84
|
fields: req.payload.collections[currentField.relationTo].config.flattenedFields,
|
|
149
|
-
hasMany,
|
|
150
85
|
locale,
|
|
151
86
|
overrideAccess,
|
|
152
87
|
ref: populatedDoc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/virtualFieldPopulationPromise.ts"],"sourcesContent":["import type { PayloadRequest } from '../../../types/index.js'\nimport type { FlattenedField } from '../../config/types.js'\n\nimport { createDataloaderCacheKey } from '../../../collections/dataloader.js'\n\nexport const virtualFieldPopulationPromise = async ({\n name,\n draft,\n fallbackLocale,\n fields,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/virtualFieldPopulationPromise.ts"],"sourcesContent":["import type { PayloadRequest } from '../../../types/index.js'\nimport type { FlattenedField } from '../../config/types.js'\n\nimport { createDataloaderCacheKey } from '../../../collections/dataloader.js'\n\nexport const virtualFieldPopulationPromise = async ({\n name,\n draft,\n fallbackLocale,\n fields,\n locale,\n overrideAccess,\n ref,\n req,\n segments,\n showHiddenFields,\n siblingDoc,\n}: {\n draft: boolean\n fallbackLocale: string\n fields: FlattenedField[]\n locale: string\n name: string\n overrideAccess: boolean\n ref: any\n req: PayloadRequest\n segments: string[]\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n}): Promise<void> => {\n const currentSegment = segments.shift()\n\n if (!currentSegment) {\n return\n }\n\n const currentValue = ref[currentSegment]\n\n if (typeof currentValue === 'undefined') {\n return\n }\n\n // Final step\n if (segments.length === 0) {\n siblingDoc[name] = currentValue\n return\n }\n\n const currentField = fields.find((each) => each.name === currentSegment)\n\n if (!currentField) {\n return\n }\n\n if (currentField.type === 'group' || currentField.type === 'tab') {\n if (!currentValue || typeof currentValue !== 'object') {\n return\n }\n\n return virtualFieldPopulationPromise({\n name,\n draft,\n fallbackLocale,\n fields: currentField.flattenedFields,\n locale,\n overrideAccess,\n ref: currentValue,\n req,\n segments,\n showHiddenFields,\n siblingDoc,\n })\n }\n\n if (\n (currentField.type === 'relationship' || currentField.type === 'upload') &&\n typeof currentField.relationTo === 'string' &&\n !currentField.hasMany\n ) {\n let docID: number | string\n\n if (typeof currentValue === 'object' && currentValue) {\n docID = currentValue.id\n } else {\n docID = currentValue\n }\n\n if (segments[0] === 'id' && segments.length === 0) {\n siblingDoc[name] = docID\n return\n }\n\n if (typeof docID !== 'string' && typeof docID !== 'number') {\n return\n }\n\n const select = {}\n let currentSelectRef: any = select\n const currentFields = req.payload.collections[currentField.relationTo]?.config.flattenedFields\n\n for (let i = 0; i < segments.length; i++) {\n const field = currentFields?.find((each) => each.name === segments[i])\n\n const shouldBreak =\n i === segments.length - 1 || field?.type === 'relationship' || field?.type === 'upload'\n\n currentSelectRef[segments[i]!] = shouldBreak ? true : {}\n currentSelectRef = currentSelectRef[segments[i]!]\n\n if (shouldBreak) {\n break\n }\n }\n\n const populatedDoc = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: currentField.relationTo,\n currentDepth: 0,\n depth: 0,\n docID,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n select,\n showHiddenFields,\n transactionID: req.transactionID as number,\n }),\n )\n\n if (!populatedDoc) {\n return\n }\n\n return virtualFieldPopulationPromise({\n name,\n draft,\n fallbackLocale,\n fields: req.payload.collections[currentField.relationTo]!.config.flattenedFields,\n locale,\n overrideAccess,\n ref: populatedDoc,\n req,\n segments,\n showHiddenFields,\n siblingDoc,\n })\n }\n}\n"],"names":["createDataloaderCacheKey","virtualFieldPopulationPromise","name","draft","fallbackLocale","fields","locale","overrideAccess","ref","req","segments","showHiddenFields","siblingDoc","currentSegment","shift","currentValue","length","currentField","find","each","type","flattenedFields","relationTo","hasMany","docID","id","select","currentSelectRef","currentFields","payload","collections","config","i","field","shouldBreak","populatedDoc","payloadDataLoader","load","collectionSlug","currentDepth","depth","transactionID"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,qCAAoC;AAE7E,OAAO,MAAMC,gCAAgC,OAAO,EAClDC,IAAI,EACJC,KAAK,EACLC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,GAAG,EACHC,GAAG,EACHC,QAAQ,EACRC,gBAAgB,EAChBC,UAAU,EAaX;IACC,MAAMC,iBAAiBH,SAASI,KAAK;IAErC,IAAI,CAACD,gBAAgB;QACnB;IACF;IAEA,MAAME,eAAeP,GAAG,CAACK,eAAe;IAExC,IAAI,OAAOE,iBAAiB,aAAa;QACvC;IACF;IAEA,aAAa;IACb,IAAIL,SAASM,MAAM,KAAK,GAAG;QACzBJ,UAAU,CAACV,KAAK,GAAGa;QACnB;IACF;IAEA,MAAME,eAAeZ,OAAOa,IAAI,CAAC,CAACC,OAASA,KAAKjB,IAAI,KAAKW;IAEzD,IAAI,CAACI,cAAc;QACjB;IACF;IAEA,IAAIA,aAAaG,IAAI,KAAK,WAAWH,aAAaG,IAAI,KAAK,OAAO;QAChE,IAAI,CAACL,gBAAgB,OAAOA,iBAAiB,UAAU;YACrD;QACF;QAEA,OAAOd,8BAA8B;YACnCC;YACAC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AE;YACAC;YACAmB;YACAf;YACA8B,eAAehC,IAAIgC,aAAa;QAClC;QAGF,IAAI,CAACN,cAAc;YACjB;QACF;QAEA,OAAOlC,8BAA8B;YACnCC;YACAC;YACAC;YACAC,QAAQI,IAAIoB,OAAO,CAACC,WAAW,CAACb,aAAaK,UAAU,CAAC,CAAES,MAAM,CAACV,eAAe;YAChFf;YACAC;YACAC,KAAK2B;YACL1B;YACAC;YACAC;YACAC;QACF;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAYrE,eAAO,MAAM,cAAc,WACjB,MAAM,UACN,YAAY,iCAKW,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,wBAC1D,MAAM,EAAE,KAC7B,OAAO,CAAC,qBAAqB,
|
|
1
|
+
{"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,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAYrE,eAAO,MAAM,cAAc,WACjB,MAAM,UACN,YAAY,iCAKW,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,wBAC1D,MAAM,EAAE,KAC7B,OAAO,CAAC,qBAAqB,CAuJ/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { GlobalConfig, 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 { flattenAllFields } from '../../utilities/flattenAllFields.js'\nimport { toWords } from '../../utilities/formatLabels.js'\nimport { baseVersionFields } from '../../versions/baseFields.js'\nimport { versionDefaults } from '../../versions/defaults.js'\nimport { defaultGlobalEndpoints } from '../endpoints/index.js'\n\nexport const sanitizeGlobal = async (\n config: Config,\n global: GlobalConfig,\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 _validRelationships?: string[],\n): Promise<SanitizedGlobalConfig> => {\n if (global._sanitized) {\n return global as SanitizedGlobalConfig\n }\n\n global._sanitized = true\n\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\n if (!global.hooks) {\n global.hooks = {}\n }\n\n if (!global.access) {\n global.access = {}\n }\n\n if (!global.admin) {\n global.admin = {}\n }\n\n if (!global.access.read) {\n global.access.read = defaultAccess\n }\n\n if (!global.access.update) {\n global.access.update = defaultAccess\n }\n\n if (!global.hooks.beforeValidate) {\n global.hooks.beforeValidate = []\n }\n\n if (!global.hooks.beforeChange) {\n global.hooks.beforeChange = []\n }\n\n if (!global.hooks.afterChange) {\n global.hooks.afterChange = []\n }\n\n if (!global.hooks.beforeRead) {\n global.hooks.beforeRead = []\n }\n\n if (!global.hooks.afterRead) {\n global.hooks.afterRead = []\n }\n\n // Sanitize fields\n const validRelationships = _validRelationships ?? config.collections?.map((c) => c.slug) ?? []\n\n global.fields = await sanitizeFields({\n config,\n fields: global.fields,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { GlobalConfig, 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 { flattenAllFields } from '../../utilities/flattenAllFields.js'\nimport { toWords } from '../../utilities/formatLabels.js'\nimport { baseVersionFields } from '../../versions/baseFields.js'\nimport { versionDefaults } from '../../versions/defaults.js'\nimport { defaultGlobalEndpoints } from '../endpoints/index.js'\n\nexport const sanitizeGlobal = async (\n config: Config,\n global: GlobalConfig,\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 _validRelationships?: string[],\n): Promise<SanitizedGlobalConfig> => {\n if (global._sanitized) {\n return global as SanitizedGlobalConfig\n }\n\n global._sanitized = true\n\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\n if (!global.hooks) {\n global.hooks = {}\n }\n\n if (!global.access) {\n global.access = {}\n }\n\n if (!global.admin) {\n global.admin = {}\n }\n\n if (!global.access.read) {\n global.access.read = defaultAccess\n }\n\n if (!global.access.update) {\n global.access.update = defaultAccess\n }\n\n if (!global.hooks.beforeValidate) {\n global.hooks.beforeValidate = []\n }\n\n if (!global.hooks.beforeChange) {\n global.hooks.beforeChange = []\n }\n\n if (!global.hooks.afterChange) {\n global.hooks.afterChange = []\n }\n\n if (!global.hooks.beforeRead) {\n global.hooks.beforeRead = []\n }\n\n if (!global.hooks.afterRead) {\n global.hooks.afterRead = []\n }\n\n // Sanitize fields\n const validRelationships = _validRelationships ?? config.collections?.map((c) => c.slug) ?? []\n\n global.fields = await sanitizeFields({\n config,\n fields: global.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n if (global.endpoints !== false) {\n if (!global.endpoints) {\n global.endpoints = []\n }\n\n for (const endpoint of defaultGlobalEndpoints) {\n global.endpoints.push(endpoint)\n }\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: boolean | null = null\n let hasCreatedAt: boolean | null = 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 ;(global as SanitizedGlobalConfig).flattenedFields = flattenAllFields({ fields: global.fields })\n\n return global as SanitizedGlobalConfig\n}\n"],"names":["defaultAccess","sanitizeFields","fieldAffectsData","mergeBaseFields","flattenAllFields","toWords","baseVersionFields","versionDefaults","defaultGlobalEndpoints","sanitizeGlobal","config","global","richTextSanitizationPromises","_validRelationships","_sanitized","label","slug","endpoints","hooks","access","admin","read","update","beforeValidate","beforeChange","afterChange","beforeRead","afterRead","validRelationships","collections","map","c","fields","parentIsLocalized","endpoint","push","versions","drafts","max","autosave","validate","interval","autosaveInterval","undefined","custom","hasUpdatedAt","hasCreatedAt","some","field","name","type","disableBulkEdit","hidden","t","flattenedFields"],"mappings":"AAGA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,kCAAiC;AAChE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,gBAAgB,QAAQ,sCAAqC;AACtE,SAASC,OAAO,QAAQ,kCAAiC;AACzD,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,sBAAsB,QAAQ,wBAAuB;AAE9D,OAAO,MAAMC,iBAAiB,OAC5BC,QACAC,QACA;;;GAGC,GACDC,8BACAC;IAEA,IAAIF,OAAOG,UAAU,EAAE;QACrB,OAAOH;IACT;IAEAA,OAAOG,UAAU,GAAG;IAEpBH,OAAOI,KAAK,GAAGJ,OAAOI,KAAK,IAAIV,QAAQM,OAAOK,IAAI;IAElD,oCAAoC;IACpC,uDAAuD;IACvD,oCAAoC;IAEpCL,OAAOM,SAAS,GAAGN,OAAOM,SAAS,IAAI,EAAE;IAEzC,IAAI,CAACN,OAAOO,KAAK,EAAE;QACjBP,OAAOO,KAAK,GAAG,CAAC;IAClB;IAEA,IAAI,CAACP,OAAOQ,MAAM,EAAE;QAClBR,OAAOQ,MAAM,GAAG,CAAC;IACnB;IAEA,IAAI,CAACR,OAAOS,KAAK,EAAE;QACjBT,OAAOS,KAAK,GAAG,CAAC;IAClB;IAEA,IAAI,CAACT,OAAOQ,MAAM,CAACE,IAAI,EAAE;QACvBV,OAAOQ,MAAM,CAACE,IAAI,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AAC,EAAEsC,CAAC,EAAE,GAAKA,EAAE;QACtB;IACF;IACA,IAAI,CAACP,cAAc;QACjBnC,OAAOqB,MAAM,CAACG,IAAI,CAAC;YACjBc,MAAM;YACNC,MAAM;YACN9B,OAAO;gBACL+B,iBAAiB;gBACjBC,QAAQ;YACV;YACArC,OAAO,CAAC,EAAEsC,CAAC,EAAE,GAAKA,EAAE;QACtB;IACF;;IAEE1C,OAAiC2C,eAAe,GAAGlD,iBAAiB;QAAE4B,QAAQrB,OAAOqB,MAAM;IAAC;IAE9F,OAAOrB;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.57.0-internal.
|
|
3
|
+
"version": "3.57.0-internal.801ab5a",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"undici": "7.10.0",
|
|
102
102
|
"uuid": "10.0.0",
|
|
103
103
|
"ws": "^8.16.0",
|
|
104
|
-
"@payloadcms/translations": "3.57.0-internal.
|
|
104
|
+
"@payloadcms/translations": "3.57.0-internal.801ab5a"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ClientCollectionConfig, SanitizedCollectionConfig, SelectType } from '../index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Mutates the incoming select object to append fields required for upload thumbnails
|
|
4
|
-
* @param collectionConfig
|
|
5
|
-
* @param select
|
|
6
|
-
*/
|
|
7
|
-
export declare const appendUploadSelectFields: ({ collectionConfig, select, }: {
|
|
8
|
-
collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig;
|
|
9
|
-
select: SelectType;
|
|
10
|
-
}) => void;
|
|
11
|
-
//# sourceMappingURL=appendUploadSelectFields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appendUploadSelectFields.d.ts","sourceRoot":"","sources":["../../src/utilities/appendUploadSelectFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEhG;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,kCAGlC;IACD,gBAAgB,EAAE,sBAAsB,GAAG,yBAAyB,CAAA;IACpE,MAAM,EAAE,UAAU,CAAA;CACnB,SAmCA,CAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mutates the incoming select object to append fields required for upload thumbnails
|
|
3
|
-
* @param collectionConfig
|
|
4
|
-
* @param select
|
|
5
|
-
*/ export const appendUploadSelectFields = ({ collectionConfig, select })=>{
|
|
6
|
-
if (!collectionConfig.upload || !select) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
select.mimeType = true;
|
|
10
|
-
select.thumbnailURL = true;
|
|
11
|
-
if (collectionConfig.upload.imageSizes && collectionConfig.upload.imageSizes.length > 0) {
|
|
12
|
-
if (collectionConfig.upload.adminThumbnail && typeof collectionConfig.upload.adminThumbnail === 'string') {
|
|
13
|
-
/** Only return image size properties that are required to generate the adminThumbnailURL */ select.sizes = {
|
|
14
|
-
[collectionConfig.upload.adminThumbnail]: {
|
|
15
|
-
filename: true
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
} else {
|
|
19
|
-
/** Only return image size properties that are required for thumbnails */ select.sizes = collectionConfig.upload.imageSizes.reduce((acc, imageSizeConfig)=>{
|
|
20
|
-
return {
|
|
21
|
-
...acc,
|
|
22
|
-
[imageSizeConfig.name]: {
|
|
23
|
-
filename: true,
|
|
24
|
-
url: true,
|
|
25
|
-
width: true
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}, {});
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
select.url = true;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=appendUploadSelectFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/appendUploadSelectFields.ts"],"sourcesContent":["import type { ClientCollectionConfig, SanitizedCollectionConfig, SelectType } from '../index.js'\n\n/**\n * Mutates the incoming select object to append fields required for upload thumbnails\n * @param collectionConfig\n * @param select\n */\nexport const appendUploadSelectFields = ({\n collectionConfig,\n select,\n}: {\n collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig\n select: SelectType\n}) => {\n if (!collectionConfig.upload || !select) {\n return\n }\n\n select.mimeType = true\n select.thumbnailURL = true\n\n if (collectionConfig.upload.imageSizes && collectionConfig.upload.imageSizes.length > 0) {\n if (\n collectionConfig.upload.adminThumbnail &&\n typeof collectionConfig.upload.adminThumbnail === 'string'\n ) {\n /** Only return image size properties that are required to generate the adminThumbnailURL */\n select.sizes = {\n [collectionConfig.upload.adminThumbnail]: {\n filename: true,\n },\n }\n } else {\n /** Only return image size properties that are required for thumbnails */\n select.sizes = collectionConfig.upload.imageSizes.reduce((acc, imageSizeConfig) => {\n return {\n ...acc,\n [imageSizeConfig.name]: {\n filename: true,\n url: true,\n width: true,\n },\n }\n }, {})\n }\n } else {\n select.url = true\n }\n}\n"],"names":["appendUploadSelectFields","collectionConfig","select","upload","mimeType","thumbnailURL","imageSizes","length","adminThumbnail","sizes","filename","reduce","acc","imageSizeConfig","name","url","width"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,2BAA2B,CAAC,EACvCC,gBAAgB,EAChBC,MAAM,EAIP;IACC,IAAI,CAACD,iBAAiBE,MAAM,IAAI,CAACD,QAAQ;QACvC;IACF;IAEAA,OAAOE,QAAQ,GAAG;IAClBF,OAAOG,YAAY,GAAG;IAEtB,IAAIJ,iBAAiBE,MAAM,CAACG,UAAU,IAAIL,iBAAiBE,MAAM,CAACG,UAAU,CAACC,MAAM,GAAG,GAAG;QACvF,IACEN,iBAAiBE,MAAM,CAACK,cAAc,IACtC,OAAOP,iBAAiBE,MAAM,CAACK,cAAc,KAAK,UAClD;YACA,0FAA0F,GAC1FN,OAAOO,KAAK,GAAG;gBACb,CAACR,iBAAiBE,MAAM,CAACK,cAAc,CAAC,EAAE;oBACxCE,UAAU;gBACZ;YACF;QACF,OAAO;YACL,uEAAuE,GACvER,OAAOO,KAAK,GAAGR,iBAAiBE,MAAM,CAACG,UAAU,CAACK,MAAM,CAAC,CAACC,KAAKC;gBAC7D,OAAO;oBACL,GAAGD,GAAG;oBACN,CAACC,gBAAgBC,IAAI,CAAC,EAAE;wBACtBJ,UAAU;wBACVK,KAAK;wBACLC,OAAO;oBACT;gBACF;YACF,GAAG,CAAC;QACN;IACF,OAAO;QACLd,OAAOa,GAAG,GAAG;IACf;AACF,EAAC"}
|