payload 3.0.0-beta.53 → 3.0.0-beta.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/LanguageOptions.js.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/elements/Cell.d.ts +0 -1
- package/dist/admin/elements/Cell.d.ts.map +1 -1
- package/dist/admin/elements/Cell.js.map +1 -1
- package/dist/admin/elements/DatePicker.js.map +1 -1
- package/dist/admin/elements/PreviewButton.js.map +1 -1
- package/dist/admin/elements/PublishButton.js.map +1 -1
- package/dist/admin/elements/SaveButton.js.map +1 -1
- package/dist/admin/elements/SaveDraftButton.js.map +1 -1
- package/dist/admin/elements/Tab.d.ts +0 -1
- package/dist/admin/elements/Tab.d.ts.map +1 -1
- package/dist/admin/elements/Tab.js.map +1 -1
- package/dist/admin/elements/Upload.d.ts +3 -0
- package/dist/admin/elements/Upload.d.ts.map +1 -0
- package/dist/admin/elements/Upload.js +3 -0
- package/dist/admin/elements/Upload.js.map +1 -0
- package/dist/admin/elements/WithServerSideProps.js.map +1 -1
- package/dist/admin/forms/Error.d.ts +0 -1
- package/dist/admin/forms/Error.d.ts.map +1 -1
- package/dist/admin/forms/Error.js.map +1 -1
- package/dist/admin/forms/FieldDescription.js.map +1 -1
- package/dist/admin/forms/FieldTypes.d.ts +0 -1
- package/dist/admin/forms/FieldTypes.d.ts.map +1 -1
- package/dist/admin/forms/FieldTypes.js.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/forms/Label.d.ts +0 -1
- package/dist/admin/forms/Label.d.ts.map +1 -1
- package/dist/admin/forms/Label.js.map +1 -1
- package/dist/admin/forms/RowLabel.js.map +1 -1
- package/dist/admin/types.d.ts +1 -0
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/types.d.ts +0 -1
- package/dist/admin/views/types.d.ts.map +1 -1
- package/dist/admin/views/types.js.map +1 -1
- package/dist/assets/assets.d.js.map +1 -1
- package/dist/auth/baseFields/accountLock.d.ts.map +1 -1
- package/dist/auth/baseFields/accountLock.js.map +1 -1
- package/dist/auth/baseFields/apiKey.d.ts.map +1 -1
- package/dist/auth/baseFields/apiKey.js.map +1 -1
- package/dist/auth/baseFields/auth.js.map +1 -1
- package/dist/auth/baseFields/verification.d.ts.map +1 -1
- package/dist/auth/baseFields/verification.js.map +1 -1
- package/dist/auth/cookies.d.ts +3 -3
- package/dist/auth/cookies.d.ts.map +1 -1
- package/dist/auth/cookies.js.map +1 -1
- package/dist/auth/crypto.js.map +1 -1
- package/dist/auth/defaultAccess.js.map +1 -1
- package/dist/auth/defaultUser.js.map +1 -1
- package/dist/auth/executeAccess.d.ts.map +1 -1
- package/dist/auth/executeAccess.js.map +1 -1
- package/dist/auth/executeAuthStrategies.d.ts +2 -2
- package/dist/auth/executeAuthStrategies.d.ts.map +1 -1
- package/dist/auth/executeAuthStrategies.js.map +1 -1
- package/dist/auth/extractJWT.d.ts +1 -1
- package/dist/auth/extractJWT.d.ts.map +1 -1
- package/dist/auth/extractJWT.js.map +1 -1
- package/dist/auth/getAccessResults.js.map +1 -1
- package/dist/auth/getFieldsToSign.d.ts +1 -1
- package/dist/auth/getFieldsToSign.d.ts.map +1 -1
- package/dist/auth/getFieldsToSign.js.map +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/isLocked.js.map +1 -1
- package/dist/auth/operations/access.d.ts.map +1 -1
- package/dist/auth/operations/access.js.map +1 -1
- package/dist/auth/operations/auth.d.ts +2 -3
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js +0 -4
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/init.d.ts.map +1 -1
- package/dist/auth/operations/init.js.map +1 -1
- package/dist/auth/operations/local/auth.d.ts.map +1 -1
- package/dist/auth/operations/local/auth.js.map +1 -1
- package/dist/auth/operations/local/forgotPassword.d.ts +3 -3
- package/dist/auth/operations/local/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/local/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/index.js.map +1 -1
- package/dist/auth/operations/local/login.d.ts +4 -4
- package/dist/auth/operations/local/login.d.ts.map +1 -1
- package/dist/auth/operations/local/login.js.map +1 -1
- package/dist/auth/operations/local/resetPassword.d.ts +3 -3
- package/dist/auth/operations/local/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/local/resetPassword.js.map +1 -1
- package/dist/auth/operations/local/unlock.d.ts +3 -3
- package/dist/auth/operations/local/unlock.d.ts.map +1 -1
- package/dist/auth/operations/local/unlock.js.map +1 -1
- package/dist/auth/operations/local/verifyEmail.d.ts +3 -3
- package/dist/auth/operations/local/verifyEmail.d.ts.map +1 -1
- package/dist/auth/operations/local/verifyEmail.js.map +1 -1
- package/dist/auth/operations/login.d.ts +4 -4
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/logout.d.ts.map +1 -1
- package/dist/auth/operations/logout.js.map +1 -1
- package/dist/auth/operations/me.d.ts +1 -0
- package/dist/auth/operations/me.d.ts.map +1 -1
- package/dist/auth/operations/me.js +1 -0
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts +1 -0
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +1 -0
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts +7 -10
- package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/operations/registerFirstUser.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/unlock.js.map +1 -1
- package/dist/auth/operations/verifyEmail.d.ts.map +1 -1
- package/dist/auth/operations/verifyEmail.js.map +1 -1
- package/dist/auth/sendVerificationEmail.js.map +1 -1
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/strategies/jwt.js.map +1 -1
- package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
- package/dist/auth/strategies/local/authenticate.js.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.js.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
- package/dist/auth/strategies/local/register.d.ts.map +1 -1
- package/dist/auth/strategies/local/register.js.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.js.map +1 -1
- package/dist/auth/types.d.ts +1 -2
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/bin/loadEnv.js.map +1 -1
- package/dist/bin/loader/clientExtensions.js.map +1 -1
- package/dist/bin/loader/compile.js.map +1 -1
- package/dist/bin/loader/ignores.js.map +1 -1
- package/dist/bin/loader/index.js.map +1 -1
- package/dist/bin/loader/read-default-tsconfig.js.map +1 -1
- package/dist/bin/loader/resolveOriginalPath.js.map +1 -1
- package/dist/bin/migrate.d.ts.map +1 -1
- package/dist/bin/migrate.js.map +1 -1
- package/dist/collections/config/build.js.map +1 -1
- package/dist/collections/config/client.d.ts +79 -109
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/schema.d.ts.map +1 -1
- package/dist/collections/config/schema.js +3 -5
- package/dist/collections/config/schema.js.map +1 -1
- package/dist/collections/config/types.d.ts +17 -10
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/dataloader.js.map +1 -1
- package/dist/collections/operations/count.d.ts +3 -2
- package/dist/collections/operations/count.d.ts.map +1 -1
- package/dist/collections/operations/count.js.map +1 -1
- package/dist/collections/operations/create.d.ts +5 -9
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts +5 -5
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts +4 -3
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/docAccess.js.map +1 -1
- package/dist/collections/operations/duplicate.d.ts +3 -3
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/collections/operations/find.d.ts +3 -2
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts +3 -2
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +2 -3
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts +1 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.d.ts +1 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts +5 -5
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +7 -7
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +12 -12
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +6 -5
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +7 -6
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +7 -6
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +7 -6
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +7 -6
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/index.d.ts +2 -2
- package/dist/collections/operations/local/index.d.ts.map +1 -1
- package/dist/collections/operations/local/index.js +2 -2
- package/dist/collections/operations/local/index.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +7 -6
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +12 -12
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts +1 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.d.ts +5 -6
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +5 -7
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utils.d.ts +39 -36
- package/dist/collections/operations/utils.d.ts.map +1 -1
- package/dist/collections/operations/utils.js +0 -1
- package/dist/collections/operations/utils.js.map +1 -1
- package/dist/config/build.js.map +1 -1
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/find.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shared/adminViewSchema.js.map +1 -1
- package/dist/config/shared/componentSchema.js.map +1 -1
- package/dist/config/shared/openGraphSchema.js.map +1 -1
- package/dist/config/types.d.ts +2 -3
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/config/validate.js.map +1 -1
- package/dist/database/combineQueries.js.map +1 -1
- package/dist/database/createDatabaseAdapter.js.map +1 -1
- package/dist/database/flattenWhereToOperators.js.map +1 -1
- package/dist/database/getLocalizedPaths.js.map +1 -1
- package/dist/database/migrations/createMigration.js.map +1 -1
- package/dist/database/migrations/getMigrations.js.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.js.map +1 -1
- package/dist/database/migrations/migrate.js.map +1 -1
- package/dist/database/migrations/migrateDown.js.map +1 -1
- package/dist/database/migrations/migrateRefresh.js.map +1 -1
- package/dist/database/migrations/migrateReset.js.map +1 -1
- package/dist/database/migrations/migrateStatus.js.map +1 -1
- package/dist/database/migrations/migrationTemplate.js.map +1 -1
- package/dist/database/migrations/migrationsCollection.js.map +1 -1
- package/dist/database/migrations/readMigrationFiles.d.ts.map +1 -1
- package/dist/database/migrations/readMigrationFiles.js.map +1 -1
- package/dist/database/queryValidation/types.js.map +1 -1
- package/dist/database/queryValidation/validateQueryPaths.js.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
- package/dist/database/types.d.ts +5 -6
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/email/consoleEmailAdapter.js.map +1 -1
- package/dist/email/defaults.js.map +1 -1
- package/dist/email/getStringifiedToAddress.js.map +1 -1
- package/dist/email/sendEmail.js.map +1 -1
- package/dist/email/types.js.map +1 -1
- package/dist/errors/APIError.js.map +1 -1
- package/dist/errors/AuthenticationError.js.map +1 -1
- package/dist/errors/DuplicateCollection.js.map +1 -1
- package/dist/errors/DuplicateFieldName.js.map +1 -1
- package/dist/errors/DuplicateGlobal.js.map +1 -1
- package/dist/errors/ErrorDeletingFile.js.map +1 -1
- package/dist/errors/FileRetrievalError.js.map +1 -1
- package/dist/errors/FileUploadError.js.map +1 -1
- package/dist/errors/Forbidden.js.map +1 -1
- package/dist/errors/InvalidConfiguration.js.map +1 -1
- package/dist/errors/InvalidFieldName.js.map +1 -1
- package/dist/errors/InvalidFieldRelationship.js.map +1 -1
- package/dist/errors/InvalidSchema.js.map +1 -1
- package/dist/errors/LockedAuth.js.map +1 -1
- package/dist/errors/MissingCollectionLabel.js.map +1 -1
- package/dist/errors/MissingEditorProp.js.map +1 -1
- package/dist/errors/MissingFieldInputOptions.js.map +1 -1
- package/dist/errors/MissingFieldType.js.map +1 -1
- package/dist/errors/MissingFile.js.map +1 -1
- package/dist/errors/NotFound.js.map +1 -1
- package/dist/errors/QueryError.js.map +1 -1
- package/dist/errors/TimestampsRequired.js.map +1 -1
- package/dist/errors/UnathorizedError.js.map +1 -1
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/types.js.map +1 -1
- package/dist/exports/i18n/ar.js.map +1 -1
- package/dist/exports/i18n/az.js.map +1 -1
- package/dist/exports/i18n/bg.js.map +1 -1
- package/dist/exports/i18n/cs.js.map +1 -1
- package/dist/exports/i18n/de.js.map +1 -1
- package/dist/exports/i18n/en.js.map +1 -1
- package/dist/exports/i18n/es.js.map +1 -1
- package/dist/exports/i18n/fa.js.map +1 -1
- package/dist/exports/i18n/fr.js.map +1 -1
- package/dist/exports/i18n/he.js.map +1 -1
- package/dist/exports/i18n/hr.js.map +1 -1
- package/dist/exports/i18n/hu.js.map +1 -1
- package/dist/exports/i18n/it.js.map +1 -1
- package/dist/exports/i18n/ja.js.map +1 -1
- package/dist/exports/i18n/ko.js.map +1 -1
- package/dist/exports/i18n/my.js.map +1 -1
- package/dist/exports/i18n/nb.js.map +1 -1
- package/dist/exports/i18n/nl.js.map +1 -1
- package/dist/exports/i18n/pl.js.map +1 -1
- package/dist/exports/i18n/pt.js.map +1 -1
- package/dist/exports/i18n/ro.js.map +1 -1
- package/dist/exports/i18n/rs.js.map +1 -1
- package/dist/exports/i18n/rsLatin.js.map +1 -1
- package/dist/exports/i18n/ru.js.map +1 -1
- package/dist/exports/i18n/sv.js.map +1 -1
- package/dist/exports/i18n/th.js.map +1 -1
- package/dist/exports/i18n/tr.js.map +1 -1
- package/dist/exports/i18n/uk.js.map +1 -1
- package/dist/exports/i18n/vi.js.map +1 -1
- package/dist/exports/i18n/zh.js.map +1 -1
- package/dist/exports/i18n/zhTw.js.map +1 -1
- package/dist/exports/node.js.map +1 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/baseFields/baseBlockFields.js.map +1 -1
- package/dist/fields/baseFields/baseIDField.js.map +1 -1
- package/dist/fields/config/client.d.ts +333 -334
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/schema.js +1 -1
- package/dist/fields/config/schema.js.map +1 -1
- package/dist/fields/config/types.d.ts +7 -6
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/getDefaultValue.js.map +1 -1
- package/dist/fields/getFieldPaths.js.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeChange/beforeDuplicate.js.map +1 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.js.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/fields/mergeBaseFields.js.map +1 -1
- package/dist/fields/setDefaultBeforeDuplicate.js.map +1 -1
- package/dist/fields/sortableFieldTypes.js.map +1 -1
- package/dist/fields/validations.d.ts +6 -7
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +1 -1
- package/dist/fields/validations.js.map +1 -1
- package/dist/fields/validations.spec.js.map +1 -1
- package/dist/globals/config/client.d.ts +2 -2
- package/dist/globals/config/client.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/schema.js.map +1 -1
- package/dist/globals/config/types.d.ts +2 -3
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/globals/operations/docAccess.d.ts.map +1 -1
- package/dist/globals/operations/docAccess.js.map +1 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +7 -6
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +7 -6
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +7 -6
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/index.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +7 -6
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +7 -6
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/restoreVersion.js.map +1 -1
- package/dist/globals/operations/update.d.ts +5 -7
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +55 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/preferences/deleteUserPreferences.js.map +1 -1
- package/dist/preferences/operations/delete.js.map +1 -1
- package/dist/preferences/operations/findOne.d.ts +2 -2
- package/dist/preferences/operations/findOne.d.ts.map +1 -1
- package/dist/preferences/operations/findOne.js.map +1 -1
- package/dist/preferences/operations/update.js.map +1 -1
- package/dist/preferences/preferencesCollection.js.map +1 -1
- package/dist/preferences/requestHandlers/delete.js.map +1 -1
- package/dist/preferences/requestHandlers/findOne.js.map +1 -1
- package/dist/preferences/requestHandlers/update.js.map +1 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/translations/getLocalI18n.js.map +1 -1
- package/dist/types/constants.js.map +1 -1
- package/dist/types/index.d.ts +3 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/canResizeImage.js.map +1 -1
- package/dist/uploads/cropImage.js +3 -3
- package/dist/uploads/cropImage.js.map +1 -1
- package/dist/uploads/deleteAssociatedFiles.js.map +1 -1
- package/dist/uploads/docWithFilenameExists.d.ts.map +1 -1
- package/dist/uploads/docWithFilenameExists.js.map +1 -1
- package/dist/uploads/fileExists.d.ts.map +1 -1
- package/dist/uploads/fileExists.js.map +1 -1
- package/dist/uploads/formatFilesize.js.map +1 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/getExternalFile.d.ts.map +1 -1
- package/dist/uploads/getExternalFile.js.map +1 -1
- package/dist/uploads/getFileByPath.d.ts +1 -1
- package/dist/uploads/getFileByPath.d.ts.map +1 -1
- package/dist/uploads/getFileByPath.js.map +1 -1
- package/dist/uploads/getImageSize.js.map +1 -1
- package/dist/uploads/getSafeFilename.js.map +1 -1
- package/dist/uploads/imageResizer.js.map +1 -1
- package/dist/uploads/isImage.js.map +1 -1
- package/dist/uploads/mimeTypeValidator.js.map +1 -1
- package/dist/uploads/mimeTypeValidator.spec.js.map +1 -1
- package/dist/uploads/saveBufferToFile.d.ts +0 -1
- package/dist/uploads/saveBufferToFile.d.ts.map +1 -1
- package/dist/uploads/saveBufferToFile.js.map +1 -1
- package/dist/uploads/tempFile.js.map +1 -1
- package/dist/uploads/types.d.ts +74 -7
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/uploads/unlinkTempFiles.js.map +1 -1
- package/dist/uploads/uploadFiles.d.ts.map +1 -1
- package/dist/uploads/uploadFiles.js.map +1 -1
- package/dist/utilities/checkDuplicateCollections.js.map +1 -1
- package/dist/utilities/combineMerge.js.map +1 -1
- package/dist/utilities/commitTransaction.js.map +1 -1
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/convertData.js.map +1 -1
- package/dist/utilities/createArrayFromCommaDelineated.js.map +1 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/deepMerge.js.map +1 -1
- package/dist/utilities/dependencies/getDependencies.d.ts.map +1 -1
- package/dist/utilities/dependencies/getDependencies.js +21 -4
- package/dist/utilities/dependencies/getDependencies.js.map +1 -1
- package/dist/utilities/dependencies/isError.js.map +1 -1
- package/dist/utilities/dependencies/realPath.d.ts +0 -1
- package/dist/utilities/dependencies/realPath.d.ts.map +1 -1
- package/dist/utilities/dependencies/realPath.js.map +1 -1
- package/dist/utilities/dependencies/resolveFrom.js.map +1 -1
- package/dist/utilities/fieldSchemaToJSON.d.ts.map +1 -1
- package/dist/utilities/fieldSchemaToJSON.js.map +1 -1
- package/dist/utilities/flattenTopLevelFields.js.map +1 -1
- package/dist/utilities/formatLabels.js.map +1 -1
- package/dist/utilities/formatLabels.spec.js.map +1 -1
- package/dist/utilities/getCSSVariable.js.map +1 -1
- package/dist/utilities/getCollectionIDFieldTypes.js.map +1 -1
- package/dist/utilities/getEntityPolicies.js.map +1 -1
- package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
- package/dist/utilities/getObjectDotNotation.js.map +1 -1
- package/dist/utilities/getUniqueListBy.js.map +1 -1
- package/dist/utilities/importWithoutClientFiles.d.ts.map +1 -1
- package/dist/utilities/importWithoutClientFiles.js.map +1 -1
- package/dist/utilities/initTransaction.js.map +1 -1
- package/dist/utilities/isEntityHidden.d.ts +2 -2
- package/dist/utilities/isEntityHidden.js.map +1 -1
- package/dist/utilities/isNumber.js.map +1 -1
- package/dist/utilities/isPlainObject.js.map +1 -1
- package/dist/utilities/isReactComponent.js.map +1 -1
- package/dist/utilities/isValidID.d.ts +1 -1
- package/dist/utilities/isValidID.js.map +1 -1
- package/dist/utilities/isolateObjectProperty.js.map +1 -1
- package/dist/utilities/killTransaction.js.map +1 -1
- package/dist/utilities/logger.d.ts.map +1 -1
- package/dist/utilities/logger.js.map +1 -1
- package/dist/utilities/mapAsync.js.map +1 -1
- package/dist/utilities/mergeListSearchAndWhere.js.map +1 -1
- package/dist/utilities/overwriteMerge.js.map +1 -1
- package/dist/utilities/parseCookies.d.ts +1 -1
- package/dist/utilities/parseCookies.d.ts.map +1 -1
- package/dist/utilities/parseCookies.js.map +1 -1
- package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
- package/dist/utilities/sanitizeInternalFields.js.map +1 -1
- package/dist/utilities/setsAreEqual.d.ts.map +1 -1
- package/dist/utilities/setsAreEqual.js.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.js.map +1 -1
- package/dist/utilities/telemetry/index.d.ts +1 -1
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.js.map +1 -1
- package/dist/utilities/telemetry/oneWayHash.d.ts +0 -1
- package/dist/utilities/telemetry/oneWayHash.d.ts.map +1 -1
- package/dist/utilities/telemetry/oneWayHash.js.map +1 -1
- package/dist/utilities/timestamp.js.map +1 -1
- package/dist/utilities/toKebabCase.js.map +1 -1
- package/dist/utilities/wait.js.map +1 -1
- package/dist/utilities/wordBoundariesRegex.js.map +1 -1
- package/dist/versions/baseFields.js.map +1 -1
- package/dist/versions/buildCollectionFields.js.map +1 -1
- package/dist/versions/buildGlobalFields.js.map +1 -1
- package/dist/versions/defaults.js.map +1 -1
- package/dist/versions/deleteCollectionVersions.d.ts.map +1 -1
- package/dist/versions/deleteCollectionVersions.js.map +1 -1
- package/dist/versions/drafts/appendVersionToQueryKey.js.map +1 -1
- package/dist/versions/drafts/getQueryDraftsSort.js.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
- package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
- package/dist/versions/enforceMaxVersions.js.map +1 -1
- package/dist/versions/getLatestCollectionVersion.d.ts.map +1 -1
- package/dist/versions/getLatestCollectionVersion.js.map +1 -1
- package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
- package/dist/versions/getLatestGlobalVersion.js.map +1 -1
- package/dist/versions/saveVersion.d.ts.map +1 -1
- package/dist/versions/saveVersion.js.map +1 -1
- package/dist/versions/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-use-before-define */\nimport type { EditorProps } from '@monaco-editor/react'\nimport type { CSSProperties } from 'react'\n\n//eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport monacoeditor from 'monaco-editor' // IMPORTANT - DO NOT REMOVE: This is required for pnpm's default isolated mode to work - even though the import is not used. This is due to a typescript bug: https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189. (tsbugisolatedmode)\nimport type React from 'react'\n\nimport type { RichTextAdapter, RichTextAdapterProvider } from '../../admin/RichText.js'\nimport type {\n ConditionalDateProps,\n Description,\n DescriptionComponent,\n ErrorProps,\n LabelProps,\n RowLabelComponent,\n} from '../../admin/types.js'\nimport type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js'\nimport type { CustomComponent, LabelFunction } from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { Operation, PayloadRequestWithData, RequestContext, Where } from '../../types/index.js'\nimport type { ClientFieldConfig } from './client.js'\n\nexport type FieldHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {\n /** The collection which the field belongs to. If the field belongs to a global, this will be null. */\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */\n data?: Partial<TData>\n /** The field which the hook is running against. */\n field: FieldAffectingData\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n /** The global which the field belongs to. If the field belongs to a collection, this will be null. */\n global: SanitizedGlobalConfig | null\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */\n originalDoc?: TData\n overrideAccess?: boolean\n /**\n * The path of the field, e.g. [\"group\", \"myArray\", 1, \"textField\"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.\n */\n path: (number | string)[]\n /** The document before changes were applied, only in `afterChange` hooks. */\n previousDoc?: TData\n /** The sibling data of the document before changes being applied, only in `beforeChange`, `beforeValidate`, `beforeDuplicate` and `afterChange` field hooks. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes, only in `beforeChange`, `afterChange`, `beforeDuplicate` and `beforeValidate` field hooks. */\n previousValue?: TValue\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequestWithData\n /**\n * The schemaPath of the field, e.g. [\"group\", \"myArray\", \"textField\"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.\n */\n schemaPath: string[]\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<TSiblingData>\n /**\n * The original siblingData with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.\n */\n siblingDocWithLocales?: Record<string, unknown>\n /** The value of the field. */\n value?: TValue\n}\n\nexport type FieldHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (\n args: FieldHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type FieldAccess<TData extends TypeWithID = any, TSiblingData = any> = (args: {\n /**\n * The incoming data used to `create` or `update` the document with. `data` is undefined during the `read` operation.\n */\n data?: Partial<TData>\n /**\n * The original data of the document before the `update` is applied. `doc` is undefined during the `create` operation.\n */\n doc?: TData\n /**\n * The `id` of the current document being read or updated. `id` is undefined during the `create` operation.\n */\n id?: number | string\n /** The `payload` object to interface with the payload API */\n req: PayloadRequestWithData\n /**\n * Immediately adjacent data to this field. For example, if this is a `group` field, then `siblingData` will be the other fields within the group.\n */\n siblingData?: Partial<TSiblingData>\n}) => Promise<boolean> | boolean\n\nexport type Condition<TData extends TypeWithID = any, TSiblingData = any> = (\n data: Partial<TData>,\n siblingData: Partial<TSiblingData>,\n { user }: { user: PayloadRequestWithData['user'] },\n) => boolean\n\nexport type FilterOptionsProps<TData = any> = {\n /**\n * An object containing the full collection or global document currently being edited.\n */\n data: TData\n /**\n * The `id` of the current document being edited. `id` is undefined during the `create` operation.\n */\n id: number | string\n /**\n * The collection `slug` to filter against, limited to this field's `relationTo` property.\n */\n relationTo: string\n /**\n * An object containing document data that is scoped to only fields within the same parent of this field.\n */\n siblingData: unknown\n /**\n * An object containing the currently authenticated user.\n */\n user: Partial<PayloadRequestWithData['user']>\n}\n\nexport type FilterOptions<TData = any> =\n | ((options: FilterOptionsProps<TData>) => Promise<Where | boolean> | Where | boolean)\n | Where\n | null\n\ntype Admin = {\n className?: string\n components?: {\n Cell?: CustomComponent\n Description?: DescriptionComponent\n Field?: CustomComponent\n /**\n * The Filter component has to be a client component\n */\n Filter?: React.ComponentType<any>\n }\n /**\n * You can programmatically show / hide fields based on what other fields are doing.\n * This is also run on the server, to determine if the field should be validated.\n */\n condition?: Condition\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n description?: Description\n disableBulkEdit?: boolean\n /**\n * Shows / hides fields from appearing in the list view column selector.\n * @type boolean\n */\n disableListColumn?: boolean\n /**\n * Shows / hides fields from appearing in the list view filter options.\n * @type boolean\n */\n disableListFilter?: boolean\n disabled?: boolean\n hidden?: boolean\n position?: 'sidebar'\n readOnly?: boolean\n style?: CSSProperties\n width?: string\n}\n\nexport type Labels = {\n plural: LabelFunction | Record<string, string> | string\n singular: LabelFunction | Record<string, string> | string\n}\n\nexport type BaseValidateOptions<TData, TSiblingData> = {\n data: Partial<TData>\n id?: number | string\n operation?: Operation\n preferences: DocumentPreferences\n req: PayloadRequestWithData\n siblingData: Partial<TSiblingData>\n}\n\nexport type ValidateOptions<TData, TSiblingData, TFieldConfig extends object> = BaseValidateOptions<\n TData,\n TSiblingData\n> &\n TFieldConfig\n\nexport type Validate<\n TValue = any,\n TData = any,\n TSiblingData = any,\n TFieldConfig extends object = object,\n> = (\n value: TValue,\n options: ValidateOptions<TData, TSiblingData, TFieldConfig>,\n) => Promise<string | true> | string | true\n\nexport type ClientValidate = Omit<Validate, 'req'>\n\nexport type OptionObject = {\n label: LabelFunction | Record<string, string> | string\n value: string\n}\n\nexport type Option = OptionObject | string\n\nexport interface FieldBase {\n access?: {\n create?: FieldAccess\n read?: FieldAccess\n update?: FieldAccess\n }\n admin?: Admin\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n defaultValue?: any\n hidden?: boolean\n hooks?: {\n afterChange?: FieldHook[]\n afterRead?: FieldHook[]\n beforeChange?: FieldHook[]\n /**\n * Runs before a document is duplicated to prevent errors in unique fields or return null to use defaultValue.\n */\n beforeDuplicate?: FieldHook[]\n beforeValidate?: FieldHook[]\n }\n index?: boolean\n label?: LabelFunction | Record<string, string> | false | string\n localized?: boolean\n name: string\n required?: boolean\n saveToJWT?: boolean | string\n unique?: boolean\n validate?: Validate\n}\n\nexport type NumberField = FieldBase & {\n admin?: Admin & {\n /** Set this property to a string that will be used for browser autocomplete. */\n autoComplete?: string\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n /** Set this property to define a placeholder string for the field. */\n placeholder?: Record<string, string> | string\n /** Set a value for the number field to increment / decrement using browser controls. */\n step?: number\n }\n /** Maximum value accepted. Used in the default `validation` function. */\n max?: number\n /** Minimum value accepted. Used in the default `validation` function. */\n min?: number\n type: 'number'\n} & (\n | {\n /** Makes this field an ordered array of numbers instead of just a single number. */\n hasMany: true\n /** Maximum number of numbers in the numbers array, if `hasMany` is set to true. */\n maxRows?: number\n /** Minimum number of numbers in the numbers array, if `hasMany` is set to true. */\n minRows?: number\n }\n | {\n /** Makes this field an ordered array of numbers instead of just a single number. */\n hasMany?: false | undefined\n /** Maximum number of numbers in the numbers array, if `hasMany` is set to true. */\n maxRows?: undefined\n /** Minimum number of numbers in the numbers array, if `hasMany` is set to true. */\n minRows?: undefined\n }\n )\n\nexport type TextField = FieldBase & {\n admin?: Admin & {\n autoComplete?: string\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n rtl?: boolean\n }\n maxLength?: number\n minLength?: number\n type: 'text'\n} & (\n | {\n /** Makes this field an ordered array of strings instead of just a single string. */\n hasMany: true\n /** Maximum number of strings in the strings array, if `hasMany` is set to true. */\n maxRows?: number\n /** Minimum number of strings in the strings array, if `hasMany` is set to true. */\n minRows?: number\n }\n | {\n /** Makes this field an ordered array of strings instead of just a single string. */\n hasMany?: false | undefined\n /** Maximum number of strings in the strings array, if `hasMany` is set to true. */\n maxRows?: undefined\n /** Minimum number of strings in the strings array, if `hasMany` is set to true. */\n minRows?: undefined\n }\n )\n\nexport type EmailField = FieldBase & {\n admin?: Admin & {\n autoComplete?: string\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n }\n type: 'email'\n}\n\nexport type TextareaField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n rows?: number\n rtl?: boolean\n }\n maxLength?: number\n minLength?: number\n type: 'textarea'\n}\n\nexport type CheckboxField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n }\n type: 'checkbox'\n}\n\nexport type DateField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n date?: ConditionalDateProps\n placeholder?: Record<string, string> | string\n }\n type: 'date'\n}\n\nexport type GroupField = Omit<FieldBase, 'required' | 'validation'> & {\n admin?: Admin & {\n hideGutter?: boolean\n }\n fields: Field[]\n /** Customize generated GraphQL and Typescript schema names.\n * By default, it is bound to the collection.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n type: 'group'\n}\n\nexport type RowAdmin = Omit<Admin, 'description'>\n\nexport type RowField = Omit<FieldBase, 'admin' | 'label' | 'name'> & {\n admin?: RowAdmin\n fields: Field[]\n type: 'row'\n}\n\nexport type CollapsibleField = Omit<FieldBase, 'label' | 'name'> & {\n fields: Field[]\n type: 'collapsible'\n} & (\n | {\n admin: Admin & {\n components: {\n RowLabel: RowLabelComponent\n } & Admin['components']\n initCollapsed?: boolean\n }\n label?: Required<FieldBase['label']>\n }\n | {\n admin?: Admin & {\n initCollapsed?: boolean\n }\n label: Required<FieldBase['label']>\n }\n )\n\nexport type TabsAdmin = Omit<Admin, 'description'>\n\ntype TabBase = Omit<FieldBase, 'required' | 'validation'> & {\n description?: Description\n fields: Field[]\n interfaceName?: string\n saveToJWT?: boolean | string\n}\n\nexport type NamedTab = TabBase & {\n /** Customize generated GraphQL and Typescript schema names.\n * The slug is used by default.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n}\n\nexport type UnnamedTab = Omit<TabBase, 'name'> & {\n interfaceName?: never\n /**\n * Can be either:\n * - A string, which will be used as the tab's label.\n * - An object, where the key is the language code and the value is the label.\n */\n label:\n | {\n [selectedLanguage: string]: string\n }\n | LabelFunction\n | string\n localized?: never\n}\n\nexport type Tab = NamedTab | UnnamedTab\n\nexport type TabsField = Omit<FieldBase, 'admin' | 'localized' | 'name' | 'saveToJWT'> & {\n admin?: TabsAdmin\n tabs: Tab[]\n type: 'tabs'\n}\n\nexport type TabAsField = Tab & {\n name?: string\n type: 'tab'\n}\n\nexport type UIField = {\n admin: {\n components?: {\n Cell?: CustomComponent\n Field: CustomComponent\n /**\n * The Filter component has to be a client component\n */\n Filter?: React.ComponentType<any>\n }\n condition?: Condition\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n disableBulkEdit?: boolean\n /**\n * Shows / hides fields from appearing in the list view column selector.\n * @type boolean\n */\n disableListColumn?: boolean\n position?: string\n width?: string\n }\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n label?: Record<string, string> | string\n name: string\n type: 'ui'\n}\n\nexport type UploadField = FieldBase & {\n admin?: {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n }\n filterOptions?: FilterOptions\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n relationTo: string\n type: 'upload'\n}\n\ntype CodeAdmin = Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n editorOptions?: EditorProps['options']\n language?: string\n}\n\nexport type CodeField = Omit<FieldBase, 'admin'> & {\n admin?: CodeAdmin\n maxLength?: number\n minLength?: number\n type: 'code'\n}\n\ntype JSONAdmin = Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n editorOptions?: EditorProps['options']\n}\n\nexport type JSONField = Omit<FieldBase, 'admin'> & {\n admin?: JSONAdmin\n jsonSchema?: Record<string, unknown>\n type: 'json'\n}\n\nexport type SelectField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n isClearable?: boolean\n isSortable?: boolean\n }\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n /**\n * Customize the DB enum name\n */\n enumName?: DBIdentifierName\n hasMany?: boolean\n options: Option[]\n type: 'select'\n}\n\ntype SharedRelationshipProperties = FieldBase & {\n filterOptions?: FilterOptions\n hasMany?: boolean\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n type: 'relationship'\n} & (\n | {\n hasMany: true\n /**\n * @deprecated Use 'maxRows' instead\n */\n max?: number\n maxRows?: number\n /**\n * @deprecated Use 'minRows' instead\n */\n min?: number\n minRows?: number\n }\n | {\n hasMany?: false | undefined\n /**\n * @deprecated Use 'maxRows' instead\n */\n max?: undefined\n maxRows?: undefined\n /**\n * @deprecated Use 'minRows' instead\n */\n min?: undefined\n minRows?: undefined\n }\n )\n\ntype RelationshipAdmin = Admin & {\n allowCreate?: boolean\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n isSortable?: boolean\n}\nexport type PolymorphicRelationshipField = SharedRelationshipProperties & {\n admin?: RelationshipAdmin & {\n sortOptions?: { [collectionSlug: string]: string }\n }\n relationTo: string[]\n}\nexport type SingleRelationshipField = SharedRelationshipProperties & {\n admin?: RelationshipAdmin & {\n sortOptions?: string\n }\n relationTo: string\n}\nexport type RelationshipField = PolymorphicRelationshipField | SingleRelationshipField\n\nexport type ValueWithRelation = {\n relationTo: string\n value: number | string\n}\n\nexport function valueIsValueWithRelation(value: unknown): value is ValueWithRelation {\n return value !== null && typeof value === 'object' && 'relationTo' in value && 'value' in value\n}\n\nexport type RelationshipValue =\n | (number | string)[]\n | ValueWithRelation\n | ValueWithRelation[]\n | (number | string)\n\nexport type RichTextField<\n Value extends object = any,\n AdapterProps = any,\n ExtraProperties = object,\n> = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n }\n editor?:\n | RichTextAdapter<Value, AdapterProps, AdapterProps>\n | RichTextAdapterProvider<Value, AdapterProps, AdapterProps>\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n type: 'richText'\n} & ExtraProperties\n\nexport type ArrayField = FieldBase & {\n admin?: Admin & {\n components?: {\n RowLabel?: RowLabelComponent\n } & Admin['components']\n initCollapsed?: boolean\n /**\n * Disable drag and drop sorting\n */\n isSortable?: boolean\n }\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n fields: Field[]\n /** Customize generated GraphQL and Typescript schema names.\n * By default, it is bound to the collection.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'array'\n}\n\nexport type RadioField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n layout?: 'horizontal' | 'vertical'\n }\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n /**\n * Customize the DB enum name\n */\n enumName?: DBIdentifierName\n options: Option[]\n type: 'radio'\n}\n\nexport type Block = {\n admin?: {\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n }\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n fields: Field[]\n /** @deprecated - please migrate to the interfaceName property instead. */\n graphQL?: {\n singularName?: string\n }\n imageAltText?: string\n imageURL?: string\n /** Customize generated GraphQL and Typescript schema names.\n * The slug is used by default.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n slug: string\n}\n\nexport type BlockField = FieldBase & {\n admin?: Admin & {\n initCollapsed?: boolean\n /**\n * Disable drag and drop sorting\n */\n isSortable?: boolean\n }\n blocks: Block[]\n defaultValue?: unknown\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'blocks'\n}\n\nexport type PointField = FieldBase & {\n type: 'point'\n}\n\nexport type Field =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | CollapsibleField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | RowField\n | SelectField\n | TabsField\n | TextField\n | TextareaField\n | UIField\n | UploadField\n\nexport type FieldAffectingData =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | SelectField\n | TabAsField\n | TextField\n | TextareaField\n | UploadField\n\nexport type NonPresentationalField =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | CollapsibleField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | RowField\n | SelectField\n | TabsField\n | TextField\n | TextareaField\n | UploadField\n\nexport type FieldWithPath = Field & {\n path?: string\n}\n\nexport type FieldWithSubFields = ArrayField | CollapsibleField | GroupField | RowField\n\nexport type FieldPresentationalOnly = UIField\n\nexport type FieldWithMany = RelationshipField | SelectField\n\nexport type FieldWithMaxDepth = RelationshipField | UploadField\n\nexport function fieldHasSubFields(field: ClientFieldConfig | Field): field is FieldWithSubFields {\n return (\n field.type === 'group' ||\n field.type === 'array' ||\n field.type === 'row' ||\n field.type === 'collapsible'\n )\n}\n\nexport function fieldIsArrayType(field: Field): field is ArrayField {\n return field.type === 'array'\n}\n\nexport function fieldIsBlockType(field: Field): field is BlockField {\n return field.type === 'blocks'\n}\n\nexport function fieldIsGroupType(field: Field): field is GroupField {\n return field.type === 'group'\n}\n\nexport function optionIsObject(option: Option): option is OptionObject {\n return typeof option === 'object'\n}\n\nexport function optionsAreObjects(options: Option[]): options is OptionObject[] {\n return Array.isArray(options) && typeof options?.[0] === 'object'\n}\n\nexport function optionIsValue(option: Option): option is string {\n return typeof option === 'string'\n}\n\nexport function fieldSupportsMany(field: Field): field is FieldWithMany {\n return field.type === 'select' || field.type === 'relationship'\n}\n\nexport function fieldHasMaxDepth(field: Field): field is FieldWithMaxDepth {\n return (\n (field.type === 'upload' || field.type === 'relationship') && typeof field.maxDepth === 'number'\n )\n}\n\nexport function fieldIsPresentationalOnly(\n field: ClientFieldConfig | Field | TabAsField,\n): field is UIField {\n return field.type === 'ui'\n}\n\nexport function fieldAffectsData(\n field: ClientFieldConfig | Field | TabAsField,\n): field is FieldAffectingData {\n return 'name' in field && !fieldIsPresentationalOnly(field)\n}\n\nexport function tabHasName(tab: Tab): tab is NamedTab {\n return 'name' in tab\n}\n\nexport function fieldIsLocalized(field: Field | Tab): boolean {\n return 'localized' in field && field.localized\n}\n\nexport type HookName =\n | 'afterChange'\n | 'afterRead'\n | 'beforeChange'\n | 'beforeRead'\n | 'beforeValidate'\n"],"names":["valueIsValueWithRelation","value","fieldHasSubFields","field","type","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","optionIsObject","option","optionsAreObjects","options","Array","isArray","optionIsValue","fieldSupportsMany","fieldHasMaxDepth","maxDepth","fieldIsPresentationalOnly","fieldAffectsData","tabHasName","tab","fieldIsLocalized","localized"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,qDAAqD,GACrD,uCAAuC,GA8mBvC,OAAO,SAASA,yBAAyBC,KAAc;IACrD,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,gBAAgBA,SAAS,WAAWA;AAC5F;AA8MA,OAAO,SAASC,kBAAkBC,KAAgC;IAChE,OACEA,MAAMC,IAAI,KAAK,WACfD,MAAMC,IAAI,KAAK,WACfD,MAAMC,IAAI,KAAK,SACfD,MAAMC,IAAI,KAAK;AAEnB;AAEA,OAAO,SAASC,iBAAiBF,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASE,iBAAiBH,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASG,iBAAiBJ,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASI,eAAeC,MAAc;IAC3C,OAAO,OAAOA,WAAW;AAC3B;AAEA,OAAO,SAASC,kBAAkBC,OAAiB;IACjD,OAAOC,MAAMC,OAAO,CAACF,YAAY,OAAOA,SAAS,CAAC,EAAE,KAAK;AAC3D;AAEA,OAAO,SAASG,cAAcL,MAAc;IAC1C,OAAO,OAAOA,WAAW;AAC3B;AAEA,OAAO,SAASM,kBAAkBZ,KAAY;IAC5C,OAAOA,MAAMC,IAAI,KAAK,YAAYD,MAAMC,IAAI,KAAK;AACnD;AAEA,OAAO,SAASY,iBAAiBb,KAAY;IAC3C,OACE,AAACA,CAAAA,MAAMC,IAAI,KAAK,YAAYD,MAAMC,IAAI,KAAK,cAAa,KAAM,OAAOD,MAAMc,QAAQ,KAAK;AAE5F;AAEA,OAAO,SAASC,0BACdf,KAA6C;IAE7C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASe,iBACdhB,KAA6C;IAE7C,OAAO,UAAUA,SAAS,CAACe,0BAA0Bf;AACvD;AAEA,OAAO,SAASiB,WAAWC,GAAQ;IACjC,OAAO,UAAUA;AACnB;AAEA,OAAO,SAASC,iBAAiBnB,KAAkB;IACjD,OAAO,eAAeA,SAASA,MAAMoB,SAAS;AAChD"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-use-before-define */\nimport type { EditorProps } from '@monaco-editor/react'\nimport type { CSSProperties } from 'react'\n\n//eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport monacoeditor from 'monaco-editor' // IMPORTANT - DO NOT REMOVE: This is required for pnpm's default isolated mode to work - even though the import is not used. This is due to a typescript bug: https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189. (tsbugisolatedmode)\nimport type React from 'react'\n\nimport type { RichTextAdapter, RichTextAdapterProvider } from '../../admin/RichText.js'\nimport type {\n ConditionalDateProps,\n Description,\n DescriptionComponent,\n ErrorProps,\n LabelProps,\n RowLabelComponent,\n} from '../../admin/types.js'\nimport type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js'\nimport type { CustomComponent, LabelFunction } from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { CollectionSlug, GeneratedTypes } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { Operation, PayloadRequestWithData, RequestContext, Where } from '../../types/index.js'\nimport type { ClientFieldConfig } from './client.js'\n\nexport type FieldHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {\n /** The collection which the field belongs to. If the field belongs to a global, this will be null. */\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */\n data?: Partial<TData>\n /** The field which the hook is running against. */\n field: FieldAffectingData\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n /** The global which the field belongs to. If the field belongs to a collection, this will be null. */\n global: SanitizedGlobalConfig | null\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */\n originalDoc?: TData\n overrideAccess?: boolean\n /**\n * The path of the field, e.g. [\"group\", \"myArray\", 1, \"textField\"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.\n */\n path: (number | string)[]\n /** The document before changes were applied, only in `afterChange` hooks. */\n previousDoc?: TData\n /** The sibling data of the document before changes being applied, only in `beforeChange`, `beforeValidate`, `beforeDuplicate` and `afterChange` field hooks. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes, only in `beforeChange`, `afterChange`, `beforeDuplicate` and `beforeValidate` field hooks. */\n previousValue?: TValue\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequestWithData\n /**\n * The schemaPath of the field, e.g. [\"group\", \"myArray\", \"textField\"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.\n */\n schemaPath: string[]\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<TSiblingData>\n /**\n * The original siblingData with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.\n */\n siblingDocWithLocales?: Record<string, unknown>\n /** The value of the field. */\n value?: TValue\n}\n\nexport type FieldHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (\n args: FieldHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type FieldAccess<TData extends TypeWithID = any, TSiblingData = any> = (args: {\n /**\n * The incoming data used to `create` or `update` the document with. `data` is undefined during the `read` operation.\n */\n data?: Partial<TData>\n /**\n * The original data of the document before the `update` is applied. `doc` is undefined during the `create` operation.\n */\n doc?: TData\n /**\n * The `id` of the current document being read or updated. `id` is undefined during the `create` operation.\n */\n id?: number | string\n /** The `payload` object to interface with the payload API */\n req: PayloadRequestWithData\n /**\n * Immediately adjacent data to this field. For example, if this is a `group` field, then `siblingData` will be the other fields within the group.\n */\n siblingData?: Partial<TSiblingData>\n}) => Promise<boolean> | boolean\n\nexport type Condition<TData extends TypeWithID = any, TSiblingData = any> = (\n data: Partial<TData>,\n siblingData: Partial<TSiblingData>,\n { user }: { user: PayloadRequestWithData['user'] },\n) => boolean\n\nexport type FilterOptionsProps<TData = any> = {\n /**\n * An object containing the full collection or global document currently being edited.\n */\n data: TData\n /**\n * The `id` of the current document being edited. `id` is undefined during the `create` operation.\n */\n id: number | string\n /**\n * The collection `slug` to filter against, limited to this field's `relationTo` property.\n */\n relationTo: CollectionSlug\n /**\n * An object containing document data that is scoped to only fields within the same parent of this field.\n */\n siblingData: unknown\n /**\n * An object containing the currently authenticated user.\n */\n user: Partial<PayloadRequestWithData['user']>\n}\n\nexport type FilterOptions<TData = any> =\n | ((options: FilterOptionsProps<TData>) => Promise<Where | boolean> | Where | boolean)\n | Where\n | null\n\ntype Admin = {\n className?: string\n components?: {\n Cell?: CustomComponent\n Description?: DescriptionComponent\n Field?: CustomComponent\n /**\n * The Filter component has to be a client component\n */\n Filter?: React.ComponentType<any>\n }\n /**\n * You can programmatically show / hide fields based on what other fields are doing.\n * This is also run on the server, to determine if the field should be validated.\n */\n condition?: Condition\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n description?: Description\n disableBulkEdit?: boolean\n /**\n * Shows / hides fields from appearing in the list view column selector.\n * @type boolean\n */\n disableListColumn?: boolean\n /**\n * Shows / hides fields from appearing in the list view filter options.\n * @type boolean\n */\n disableListFilter?: boolean\n disabled?: boolean\n hidden?: boolean\n position?: 'sidebar'\n readOnly?: boolean\n style?: CSSProperties\n width?: string\n}\n\nexport type Labels = {\n plural: LabelFunction | Record<string, string> | string\n singular: LabelFunction | Record<string, string> | string\n}\n\nexport type BaseValidateOptions<TData, TSiblingData> = {\n data: Partial<TData>\n id?: number | string\n operation?: Operation\n preferences: DocumentPreferences\n req: PayloadRequestWithData\n siblingData: Partial<TSiblingData>\n}\n\nexport type ValidateOptions<TData, TSiblingData, TFieldConfig extends object> = BaseValidateOptions<\n TData,\n TSiblingData\n> &\n TFieldConfig\n\nexport type Validate<\n TValue = any,\n TData = any,\n TSiblingData = any,\n TFieldConfig extends object = object,\n> = (\n value: TValue,\n options: ValidateOptions<TData, TSiblingData, TFieldConfig>,\n) => Promise<string | true> | string | true\n\nexport type ClientValidate = Omit<Validate, 'req'>\n\nexport type OptionObject = {\n label: LabelFunction | Record<string, string> | string\n value: string\n}\n\nexport type Option = OptionObject | string\n\nexport interface FieldBase {\n access?: {\n create?: FieldAccess\n read?: FieldAccess\n update?: FieldAccess\n }\n admin?: Admin\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n defaultValue?: any\n hidden?: boolean\n hooks?: {\n afterChange?: FieldHook[]\n afterRead?: FieldHook[]\n beforeChange?: FieldHook[]\n /**\n * Runs before a document is duplicated to prevent errors in unique fields or return null to use defaultValue.\n */\n beforeDuplicate?: FieldHook[]\n beforeValidate?: FieldHook[]\n }\n index?: boolean\n label?: LabelFunction | Record<string, string> | false | string\n localized?: boolean\n name: string\n required?: boolean\n saveToJWT?: boolean | string\n unique?: boolean\n validate?: Validate\n}\n\nexport type NumberField = FieldBase & {\n admin?: Admin & {\n /** Set this property to a string that will be used for browser autocomplete. */\n autoComplete?: string\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n /** Set this property to define a placeholder string for the field. */\n placeholder?: Record<string, string> | string\n /** Set a value for the number field to increment / decrement using browser controls. */\n step?: number\n }\n /** Maximum value accepted. Used in the default `validation` function. */\n max?: number\n /** Minimum value accepted. Used in the default `validation` function. */\n min?: number\n type: 'number'\n} & (\n | {\n /** Makes this field an ordered array of numbers instead of just a single number. */\n hasMany: true\n /** Maximum number of numbers in the numbers array, if `hasMany` is set to true. */\n maxRows?: number\n /** Minimum number of numbers in the numbers array, if `hasMany` is set to true. */\n minRows?: number\n }\n | {\n /** Makes this field an ordered array of numbers instead of just a single number. */\n hasMany?: false | undefined\n /** Maximum number of numbers in the numbers array, if `hasMany` is set to true. */\n maxRows?: undefined\n /** Minimum number of numbers in the numbers array, if `hasMany` is set to true. */\n minRows?: undefined\n }\n )\n\nexport type TextField = FieldBase & {\n admin?: Admin & {\n autoComplete?: string\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n rtl?: boolean\n }\n maxLength?: number\n minLength?: number\n type: 'text'\n} & (\n | {\n /** Makes this field an ordered array of strings instead of just a single string. */\n hasMany: true\n /** Maximum number of strings in the strings array, if `hasMany` is set to true. */\n maxRows?: number\n /** Minimum number of strings in the strings array, if `hasMany` is set to true. */\n minRows?: number\n }\n | {\n /** Makes this field an ordered array of strings instead of just a single string. */\n hasMany?: false | undefined\n /** Maximum number of strings in the strings array, if `hasMany` is set to true. */\n maxRows?: undefined\n /** Minimum number of strings in the strings array, if `hasMany` is set to true. */\n minRows?: undefined\n }\n )\n\nexport type EmailField = FieldBase & {\n admin?: Admin & {\n autoComplete?: string\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n }\n type: 'email'\n}\n\nexport type TextareaField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n rows?: number\n rtl?: boolean\n }\n maxLength?: number\n minLength?: number\n type: 'textarea'\n}\n\nexport type CheckboxField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n }\n type: 'checkbox'\n}\n\nexport type DateField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n date?: ConditionalDateProps\n placeholder?: Record<string, string> | string\n }\n type: 'date'\n}\n\nexport type GroupField = Omit<FieldBase, 'required' | 'validation'> & {\n admin?: Admin & {\n hideGutter?: boolean\n }\n fields: Field[]\n /** Customize generated GraphQL and Typescript schema names.\n * By default, it is bound to the collection.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n type: 'group'\n}\n\nexport type RowAdmin = Omit<Admin, 'description'>\n\nexport type RowField = Omit<FieldBase, 'admin' | 'label' | 'name'> & {\n admin?: RowAdmin\n fields: Field[]\n type: 'row'\n}\n\nexport type CollapsibleField = Omit<FieldBase, 'label' | 'name'> & {\n fields: Field[]\n type: 'collapsible'\n} & (\n | {\n admin: Admin & {\n components: {\n RowLabel: RowLabelComponent\n } & Admin['components']\n initCollapsed?: boolean\n }\n label?: Required<FieldBase['label']>\n }\n | {\n admin?: Admin & {\n initCollapsed?: boolean\n }\n label: Required<FieldBase['label']>\n }\n )\n\nexport type TabsAdmin = Omit<Admin, 'description'>\n\ntype TabBase = Omit<FieldBase, 'required' | 'validation'> & {\n description?: Description\n fields: Field[]\n interfaceName?: string\n saveToJWT?: boolean | string\n}\n\nexport type NamedTab = TabBase & {\n /** Customize generated GraphQL and Typescript schema names.\n * The slug is used by default.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n}\n\nexport type UnnamedTab = Omit<TabBase, 'name'> & {\n interfaceName?: never\n /**\n * Can be either:\n * - A string, which will be used as the tab's label.\n * - An object, where the key is the language code and the value is the label.\n */\n label:\n | {\n [selectedLanguage: string]: string\n }\n | LabelFunction\n | string\n localized?: never\n}\n\nexport type Tab = NamedTab | UnnamedTab\n\nexport type TabsField = Omit<FieldBase, 'admin' | 'localized' | 'name' | 'saveToJWT'> & {\n admin?: TabsAdmin\n tabs: Tab[]\n type: 'tabs'\n}\n\nexport type TabAsField = Tab & {\n name?: string\n type: 'tab'\n}\n\nexport type UIField = {\n admin: {\n components?: {\n Cell?: CustomComponent\n Field: CustomComponent\n /**\n * The Filter component has to be a client component\n */\n Filter?: React.ComponentType<any>\n }\n condition?: Condition\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n disableBulkEdit?: boolean\n /**\n * Shows / hides fields from appearing in the list view column selector.\n * @type boolean\n */\n disableListColumn?: boolean\n position?: string\n width?: string\n }\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n label?: Record<string, string> | string\n name: string\n type: 'ui'\n}\n\nexport type UploadField = FieldBase & {\n admin?: {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n }\n filterOptions?: FilterOptions\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n relationTo: CollectionSlug\n type: 'upload'\n}\n\ntype CodeAdmin = Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n editorOptions?: EditorProps['options']\n language?: string\n}\n\nexport type CodeField = Omit<FieldBase, 'admin'> & {\n admin?: CodeAdmin\n maxLength?: number\n minLength?: number\n type: 'code'\n}\n\ntype JSONAdmin = Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n editorOptions?: EditorProps['options']\n}\n\nexport type JSONField = Omit<FieldBase, 'admin'> & {\n admin?: JSONAdmin\n jsonSchema?: Record<string, unknown>\n type: 'json'\n}\n\nexport type SelectField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n isClearable?: boolean\n isSortable?: boolean\n }\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n /**\n * Customize the DB enum name\n */\n enumName?: DBIdentifierName\n hasMany?: boolean\n options: Option[]\n type: 'select'\n}\n\ntype SharedRelationshipProperties = FieldBase & {\n filterOptions?: FilterOptions\n hasMany?: boolean\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n type: 'relationship'\n} & (\n | {\n hasMany: true\n /**\n * @deprecated Use 'maxRows' instead\n */\n max?: number\n maxRows?: number\n /**\n * @deprecated Use 'minRows' instead\n */\n min?: number\n minRows?: number\n }\n | {\n hasMany?: false | undefined\n /**\n * @deprecated Use 'maxRows' instead\n */\n max?: undefined\n maxRows?: undefined\n /**\n * @deprecated Use 'minRows' instead\n */\n min?: undefined\n minRows?: undefined\n }\n )\n\ntype RelationshipAdmin = Admin & {\n allowCreate?: boolean\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n isSortable?: boolean\n}\nexport type PolymorphicRelationshipField = SharedRelationshipProperties & {\n admin?: RelationshipAdmin & {\n sortOptions?: { [collectionSlug: CollectionSlug]: string }\n }\n relationTo: CollectionSlug[]\n}\nexport type SingleRelationshipField = SharedRelationshipProperties & {\n admin?: RelationshipAdmin & {\n sortOptions?: string\n }\n relationTo: CollectionSlug\n}\nexport type RelationshipField = PolymorphicRelationshipField | SingleRelationshipField\n\nexport type ValueWithRelation = {\n relationTo: CollectionSlug\n value: number | string\n}\n\nexport function valueIsValueWithRelation(value: unknown): value is ValueWithRelation {\n return value !== null && typeof value === 'object' && 'relationTo' in value && 'value' in value\n}\n\nexport type RelationshipValue =\n | (number | string)[]\n | ValueWithRelation\n | ValueWithRelation[]\n | (number | string)\n\nexport type RichTextField<\n Value extends object = any,\n AdapterProps = any,\n ExtraProperties = object,\n> = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n }\n editor?:\n | RichTextAdapter<Value, AdapterProps, AdapterProps>\n | RichTextAdapterProvider<Value, AdapterProps, AdapterProps>\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n type: 'richText'\n} & ExtraProperties\n\nexport type ArrayField = FieldBase & {\n admin?: Admin & {\n components?: {\n RowLabel?: RowLabelComponent\n } & Admin['components']\n initCollapsed?: boolean\n /**\n * Disable drag and drop sorting\n */\n isSortable?: boolean\n }\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n fields: Field[]\n /** Customize generated GraphQL and Typescript schema names.\n * By default, it is bound to the collection.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'array'\n}\n\nexport type RadioField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: CustomComponent<ErrorProps>\n Label?: CustomComponent<LabelProps>\n }\n layout?: 'horizontal' | 'vertical'\n }\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n /**\n * Customize the DB enum name\n */\n enumName?: DBIdentifierName\n options: Option[]\n type: 'radio'\n}\n\nexport type Block = {\n admin?: {\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n }\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n fields: Field[]\n /** @deprecated - please migrate to the interfaceName property instead. */\n graphQL?: {\n singularName?: string\n }\n imageAltText?: string\n imageURL?: string\n /** Customize generated GraphQL and Typescript schema names.\n * The slug is used by default.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n slug: string\n}\n\nexport type BlockField = FieldBase & {\n admin?: Admin & {\n initCollapsed?: boolean\n /**\n * Disable drag and drop sorting\n */\n isSortable?: boolean\n }\n blocks: Block[]\n defaultValue?: unknown\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'blocks'\n}\n\nexport type PointField = FieldBase & {\n type: 'point'\n}\n\nexport type Field =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | CollapsibleField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | RowField\n | SelectField\n | TabsField\n | TextField\n | TextareaField\n | UIField\n | UploadField\n\nexport type FieldAffectingData =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | SelectField\n | TabAsField\n | TextField\n | TextareaField\n | UploadField\n\nexport type NonPresentationalField =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | CollapsibleField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | RowField\n | SelectField\n | TabsField\n | TextField\n | TextareaField\n | UploadField\n\nexport type FieldWithPath = Field & {\n path?: string\n}\n\nexport type FieldWithSubFields = ArrayField | CollapsibleField | GroupField | RowField\n\nexport type FieldPresentationalOnly = UIField\n\nexport type FieldWithMany = RelationshipField | SelectField\n\nexport type FieldWithMaxDepth = RelationshipField | UploadField\n\nexport function fieldHasSubFields(field: ClientFieldConfig | Field): field is FieldWithSubFields {\n return (\n field.type === 'group' ||\n field.type === 'array' ||\n field.type === 'row' ||\n field.type === 'collapsible'\n )\n}\n\nexport function fieldIsArrayType(field: Field): field is ArrayField {\n return field.type === 'array'\n}\n\nexport function fieldIsBlockType(field: Field): field is BlockField {\n return field.type === 'blocks'\n}\n\nexport function fieldIsGroupType(field: Field): field is GroupField {\n return field.type === 'group'\n}\n\nexport function optionIsObject(option: Option): option is OptionObject {\n return typeof option === 'object'\n}\n\nexport function optionsAreObjects(options: Option[]): options is OptionObject[] {\n return Array.isArray(options) && typeof options?.[0] === 'object'\n}\n\nexport function optionIsValue(option: Option): option is string {\n return typeof option === 'string'\n}\n\nexport function fieldSupportsMany(field: Field): field is FieldWithMany {\n return field.type === 'select' || field.type === 'relationship'\n}\n\nexport function fieldHasMaxDepth(field: Field): field is FieldWithMaxDepth {\n return (\n (field.type === 'upload' || field.type === 'relationship') && typeof field.maxDepth === 'number'\n )\n}\n\nexport function fieldIsPresentationalOnly(\n field: ClientFieldConfig | Field | TabAsField,\n): field is UIField {\n return field.type === 'ui'\n}\n\nexport function fieldAffectsData(\n field: ClientFieldConfig | Field | TabAsField,\n): field is FieldAffectingData {\n return 'name' in field && !fieldIsPresentationalOnly(field)\n}\n\nexport function tabHasName(tab: Tab): tab is NamedTab {\n return 'name' in tab\n}\n\nexport function fieldIsLocalized(field: Field | Tab): boolean {\n return 'localized' in field && field.localized\n}\n\nexport type HookName =\n | 'afterChange'\n | 'afterRead'\n | 'beforeChange'\n | 'beforeRead'\n | 'beforeValidate'\n"],"names":["valueIsValueWithRelation","value","fieldHasSubFields","field","type","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","optionIsObject","option","optionsAreObjects","options","Array","isArray","optionIsValue","fieldSupportsMany","fieldHasMaxDepth","maxDepth","fieldIsPresentationalOnly","fieldAffectsData","tabHasName","tab","fieldIsLocalized","localized"],"mappings":"AAAA,qDAAqD,GACrD,uCAAuC,GA+mBvC,OAAO,SAASA,yBAAyBC,KAAc;IACrD,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,gBAAgBA,SAAS,WAAWA;AAC5F;AA8MA,OAAO,SAASC,kBAAkBC,KAAgC;IAChE,OACEA,MAAMC,IAAI,KAAK,WACfD,MAAMC,IAAI,KAAK,WACfD,MAAMC,IAAI,KAAK,SACfD,MAAMC,IAAI,KAAK;AAEnB;AAEA,OAAO,SAASC,iBAAiBF,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASE,iBAAiBH,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASG,iBAAiBJ,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASI,eAAeC,MAAc;IAC3C,OAAO,OAAOA,WAAW;AAC3B;AAEA,OAAO,SAASC,kBAAkBC,OAAiB;IACjD,OAAOC,MAAMC,OAAO,CAACF,YAAY,OAAOA,SAAS,CAAC,EAAE,KAAK;AAC3D;AAEA,OAAO,SAASG,cAAcL,MAAc;IAC1C,OAAO,OAAOA,WAAW;AAC3B;AAEA,OAAO,SAASM,kBAAkBZ,KAAY;IAC5C,OAAOA,MAAMC,IAAI,KAAK,YAAYD,MAAMC,IAAI,KAAK;AACnD;AAEA,OAAO,SAASY,iBAAiBb,KAAY;IAC3C,OACE,AAACA,CAAAA,MAAMC,IAAI,KAAK,YAAYD,MAAMC,IAAI,KAAK,cAAa,KAAM,OAAOD,MAAMc,QAAQ,KAAK;AAE5F;AAEA,OAAO,SAASC,0BACdf,KAA6C;IAE7C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASe,iBACdhB,KAA6C;IAE7C,OAAO,UAAUA,SAAS,CAACe,0BAA0Bf;AACvD;AAEA,OAAO,SAASiB,WAAWC,GAAQ;IACjC,OAAO,UAAUA;AACnB;AAEA,OAAO,SAASC,iBAAiBnB,KAAkB;IACjD,OAAO,eAAeA,SAASA,MAAMoB,SAAS;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/getDefaultValue.ts"],"sourcesContent":["import type { PayloadRequestWithData } from '../types/index.js'\n\nimport { deepCopyObject } from '../utilities/deepCopyObject.js'\n\ntype Args = {\n defaultValue: unknown\n locale: string | undefined\n user: PayloadRequestWithData['user']\n value?: unknown\n}\n\nconst getValueWithDefault = ({ defaultValue, locale, user, value }: Args): unknown => {\n if (typeof value !== 'undefined') {\n return value\n }\n\n if (defaultValue && typeof defaultValue === 'function') {\n return defaultValue({ locale, user })\n }\n\n if (typeof defaultValue === 'object') {\n return deepCopyObject(defaultValue)\n }\n\n return defaultValue\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default getValueWithDefault\n"],"names":["deepCopyObject","getValueWithDefault","defaultValue","locale","user","value"],"
|
|
1
|
+
{"version":3,"sources":["../../src/fields/getDefaultValue.ts"],"sourcesContent":["import type { PayloadRequestWithData } from '../types/index.js'\n\nimport { deepCopyObject } from '../utilities/deepCopyObject.js'\n\ntype Args = {\n defaultValue: unknown\n locale: string | undefined\n user: PayloadRequestWithData['user']\n value?: unknown\n}\n\nconst getValueWithDefault = ({ defaultValue, locale, user, value }: Args): unknown => {\n if (typeof value !== 'undefined') {\n return value\n }\n\n if (defaultValue && typeof defaultValue === 'function') {\n return defaultValue({ locale, user })\n }\n\n if (typeof defaultValue === 'object') {\n return deepCopyObject(defaultValue)\n }\n\n return defaultValue\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default getValueWithDefault\n"],"names":["deepCopyObject","getValueWithDefault","defaultValue","locale","user","value"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iCAAgC;AAS/D,MAAMC,sBAAsB,CAAC,EAAEC,YAAY,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAQ;IACtE,IAAI,OAAOA,UAAU,aAAa;QAChC,OAAOA;IACT;IAEA,IAAIH,gBAAgB,OAAOA,iBAAiB,YAAY;QACtD,OAAOA,aAAa;YAAEC;YAAQC;QAAK;IACrC;IAEA,IAAI,OAAOF,iBAAiB,UAAU;QACpC,OAAOF,eAAeE;IACxB;IAEA,OAAOA;AACT;AAEA,iDAAiD;AACjD,eAAeD,oBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/getFieldPaths.ts"],"sourcesContent":["import type { Field, TabAsField } from './config/types.js'\n\nimport { tabHasName } from './config/types.js'\n\nexport function getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n}: {\n field: Field | TabAsField\n parentPath: (number | string)[]\n parentSchemaPath: string[]\n}): {\n path: (number | string)[]\n schemaPath: string[]\n} {\n if (field.type === 'tabs' || field.type === 'row' || field.type === 'collapsible') {\n return {\n path: parentPath,\n schemaPath: parentSchemaPath,\n }\n } else if (field.type === 'tab') {\n if (tabHasName(field)) {\n return {\n path: [...parentPath, field.name],\n schemaPath: [...parentSchemaPath, field.name],\n }\n } else {\n return {\n path: parentPath,\n schemaPath: parentSchemaPath,\n }\n }\n }\n const path = parentPath?.length ? [...parentPath, field.name] : [field.name]\n const schemaPath = parentSchemaPath?.length ? [...parentSchemaPath, field.name] : [field.name]\n\n return { path, schemaPath }\n}\n"],"names":["tabHasName","getFieldPaths","field","parentPath","parentSchemaPath","type","path","schemaPath","name","length"],"
|
|
1
|
+
{"version":3,"sources":["../../src/fields/getFieldPaths.ts"],"sourcesContent":["import type { Field, TabAsField } from './config/types.js'\n\nimport { tabHasName } from './config/types.js'\n\nexport function getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n}: {\n field: Field | TabAsField\n parentPath: (number | string)[]\n parentSchemaPath: string[]\n}): {\n path: (number | string)[]\n schemaPath: string[]\n} {\n if (field.type === 'tabs' || field.type === 'row' || field.type === 'collapsible') {\n return {\n path: parentPath,\n schemaPath: parentSchemaPath,\n }\n } else if (field.type === 'tab') {\n if (tabHasName(field)) {\n return {\n path: [...parentPath, field.name],\n schemaPath: [...parentSchemaPath, field.name],\n }\n } else {\n return {\n path: parentPath,\n schemaPath: parentSchemaPath,\n }\n }\n }\n const path = parentPath?.length ? [...parentPath, field.name] : [field.name]\n const schemaPath = parentSchemaPath?.length ? [...parentSchemaPath, field.name] : [field.name]\n\n return { path, schemaPath }\n}\n"],"names":["tabHasName","getFieldPaths","field","parentPath","parentSchemaPath","type","path","schemaPath","name","length"],"mappings":"AAEA,SAASA,UAAU,QAAQ,oBAAmB;AAE9C,OAAO,SAASC,cAAc,EAC5BC,KAAK,EACLC,UAAU,EACVC,gBAAgB,EAKjB;IAIC,IAAIF,MAAMG,IAAI,KAAK,UAAUH,MAAMG,IAAI,KAAK,SAASH,MAAMG,IAAI,KAAK,eAAe;QACjF,OAAO;YACLC,MAAMH;YACNI,YAAYH;QACd;IACF,OAAO,IAAIF,MAAMG,IAAI,KAAK,OAAO;QAC/B,IAAIL,WAAWE,QAAQ;YACrB,OAAO;gBACLI,MAAM;uBAAIH;oBAAYD,MAAMM,IAAI;iBAAC;gBACjCD,YAAY;uBAAIH;oBAAkBF,MAAMM,IAAI;iBAAC;YAC/C;QACF,OAAO;YACL,OAAO;gBACLF,MAAMH;gBACNI,YAAYH;YACd;QACF;IACF;IACA,MAAME,OAAOH,YAAYM,SAAS;WAAIN;QAAYD,MAAMM,IAAI;KAAC,GAAG;QAACN,MAAMM,IAAI;KAAC;IAC5E,MAAMD,aAAaH,kBAAkBK,SAAS;WAAIL;QAAkBF,MAAMM,IAAI;KAAC,GAAG;QAACN,MAAMM,IAAI;KAAC;IAE9F,OAAO;QAAEF;QAAMC;IAAW;AAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterChange/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAKrF,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IAChC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACxC,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterChange/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAKrF,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IAChC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACxC,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,yFAShE,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAqBrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterChange/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\n\nimport { deepCopyObject } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n /**\n * The data before hooks\n */\n data: Record<string, unknown> | T\n /**\n * The data after hooks\n */\n doc: Record<string, unknown> | T\n global: SanitizedGlobalConfig | null\n operation: 'create' | 'update'\n previousDoc: Record<string, unknown> | T\n req: PayloadRequestWithData\n}\n\n/**\n * This function is responsible for the following actions, in order:\n * - Execute field hooks\n */\nexport const afterChange = async <T extends Record<string, unknown>>({\n collection,\n context,\n data,\n doc: incomingDoc,\n global,\n operation,\n previousDoc,\n req,\n}: Args<T>): Promise<T> => {\n const doc = deepCopyObject(incomingDoc)\n\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: collection?.fields || global?.fields,\n global,\n operation,\n path: [],\n previousDoc,\n previousSiblingDoc: previousDoc,\n req,\n schemaPath: [],\n siblingData: data,\n siblingDoc: doc,\n })\n\n return doc\n}\n"],"names":["deepCopyObject","traverseFields","afterChange","collection","context","data","doc","incomingDoc","global","operation","previousDoc","req","fields","path","previousSiblingDoc","schemaPath","siblingData","siblingDoc"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterChange/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\n\nimport { deepCopyObject } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n /**\n * The data before hooks\n */\n data: Record<string, unknown> | T\n /**\n * The data after hooks\n */\n doc: Record<string, unknown> | T\n global: SanitizedGlobalConfig | null\n operation: 'create' | 'update'\n previousDoc: Record<string, unknown> | T\n req: PayloadRequestWithData\n}\n\n/**\n * This function is responsible for the following actions, in order:\n * - Execute field hooks\n */\nexport const afterChange = async <T extends Record<string, unknown>>({\n collection,\n context,\n data,\n doc: incomingDoc,\n global,\n operation,\n previousDoc,\n req,\n}: Args<T>): Promise<T> => {\n const doc = deepCopyObject(incomingDoc)\n\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: collection?.fields || global?.fields,\n global,\n operation,\n path: [],\n previousDoc,\n previousSiblingDoc: previousDoc,\n req,\n schemaPath: [],\n siblingData: data,\n siblingDoc: doc,\n })\n\n return doc\n}\n"],"names":["deepCopyObject","traverseFields","afterChange","collection","context","data","doc","incomingDoc","global","operation","previousDoc","req","fields","path","previousSiblingDoc","schemaPath","siblingData","siblingDoc"],"mappings":"AAIA,SAASA,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,sBAAqB;AAmBpD;;;CAGC,GACD,OAAO,MAAMC,cAAc,OAA0C,EACnEC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,KAAKC,WAAW,EAChBC,MAAM,EACNC,SAAS,EACTC,WAAW,EACXC,GAAG,EACK;IACR,MAAML,MAAMN,eAAeO;IAE3B,MAAMN,eAAe;QACnBE;QACAC;QACAC;QACAC;QACAM,QAAQT,YAAYS,UAAUJ,QAAQI;QACtCJ;QACAC;QACAI,MAAM,EAAE;QACRH;QACAI,oBAAoBJ;QACpBC;QACAI,YAAY,EAAE;QACdC,aAAaX;QACbY,YAAYX;IACd;IAEA,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterChange/promise.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAO9D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC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A;IAC5B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAC/B;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3C,GAAG,EAAE,sBAAsB,CAAA;IAC3B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAKD,eAAO,MAAM,OAAO,+JAejB,IAAI,KAAG,OAAO,CAAC,IAAI,CAoPrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterChange/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } 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 { getFieldPaths } from '../../getFieldPaths.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown>\n doc: Record<string, unknown>\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n operation: 'create' | 'update'\n /**\n * The parent's path\n */\n parentPath: (number | string)[]\n /**\n * The parent's schemaPath (path without indexes).\n */\n parentSchemaPath: string[]\n previousDoc: Record<string, unknown>\n previousSiblingDoc: Record<string, unknown>\n req: PayloadRequestWithData\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\n// This function is responsible for the following actions, in order:\n// - Execute field hooks\n\nexport const promise = async ({\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n}: Args): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (field.hooks?.afterChange) {\n await field.hooks.afterChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc: previousDoc[field.name] as Record<string, unknown>,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: (siblingData?.[field.name] as Record<string, unknown>) || {},\n siblingDoc: siblingDoc[field.name] as Record<string, unknown>,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n path: [...fieldPath, i],\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[i] || ({} as Record<string, unknown>),\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData?.[field.name]?.[i] || {},\n siblingDoc: { ...row } || {},\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const block = field.blocks.find((blockType) => blockType.slug === row.blockType)\n\n if (block) {\n promises.push(\n traverseFields({\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n path: [...fieldPath, i],\n previousDoc,\n previousSiblingDoc:\n previousDoc?.[field.name]?.[i] || ({} as Record<string, unknown>),\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData?.[field.name]?.[i] || {},\n siblingDoc: { ...row } || {},\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabPreviousSiblingDoc = siblingDoc\n\n if (tabHasName(field)) {\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n tabPreviousSiblingDoc = previousDoc[field.name] as Record<string, unknown>\n }\n\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc: tabPreviousSiblingDoc,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.afterChange?.length) {\n await editor.hooks.afterChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getFieldPaths","traverseFields","promise","collection","context","data","doc","field","global","operation","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","path","fieldPath","schemaPath","fieldSchemaPath","hooks","afterChange","reduce","priorHook","currentHook","hookedValue","originalDoc","previousValue","name","value","undefined","Promise","resolve","type","fields","rows","Array","isArray","promises","forEach","row","i","push","all","block","blocks","find","blockType","slug","tabSiblingData","tabSiblingDoc","tabPreviousSiblingDoc","tabs","map","tab","editor","Error","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterChange/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } 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 { getFieldPaths } from '../../getFieldPaths.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown>\n doc: Record<string, unknown>\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n operation: 'create' | 'update'\n /**\n * The parent's path\n */\n parentPath: (number | string)[]\n /**\n * The parent's schemaPath (path without indexes).\n */\n parentSchemaPath: string[]\n previousDoc: Record<string, unknown>\n previousSiblingDoc: Record<string, unknown>\n req: PayloadRequestWithData\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\n// This function is responsible for the following actions, in order:\n// - Execute field hooks\n\nexport const promise = async ({\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n}: Args): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (field.hooks?.afterChange) {\n await field.hooks.afterChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc: previousDoc[field.name] as Record<string, unknown>,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: (siblingData?.[field.name] as Record<string, unknown>) || {},\n siblingDoc: siblingDoc[field.name] as Record<string, unknown>,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n path: [...fieldPath, i],\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[i] || ({} as Record<string, unknown>),\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData?.[field.name]?.[i] || {},\n siblingDoc: { ...row } || {},\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const block = field.blocks.find((blockType) => blockType.slug === row.blockType)\n\n if (block) {\n promises.push(\n traverseFields({\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n path: [...fieldPath, i],\n previousDoc,\n previousSiblingDoc:\n previousDoc?.[field.name]?.[i] || ({} as Record<string, unknown>),\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData?.[field.name]?.[i] || {},\n siblingDoc: { ...row } || {},\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabPreviousSiblingDoc = siblingDoc\n\n if (tabHasName(field)) {\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n tabPreviousSiblingDoc = previousDoc[field.name] as Record<string, unknown>\n }\n\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc: tabPreviousSiblingDoc,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.afterChange?.length) {\n await editor.hooks.afterChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getFieldPaths","traverseFields","promise","collection","context","data","doc","field","global","operation","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","path","fieldPath","schemaPath","fieldSchemaPath","hooks","afterChange","reduce","priorHook","currentHook","hookedValue","originalDoc","previousValue","name","value","undefined","Promise","resolve","type","fields","rows","Array","isArray","promises","forEach","row","i","push","all","block","blocks","find","blockType","slug","tabSiblingData","tabSiblingDoc","tabPreviousSiblingDoc","tabs","map","tab","editor","Error","length"],"mappings":"AAAA,oCAAoC,GAOpC,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,cAAc,QAAQ,sBAAqB;AAyBpD,oEAAoE;AACpE,wBAAwB;AAExB,OAAO,MAAMC,UAAU,OAAO,EAC5BC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,EACVC,gBAAgB,EAChBC,WAAW,EACXC,kBAAkB,EAClBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACL;IACL,MAAM,EAAEC,MAAMC,SAAS,EAAEC,YAAYC,eAAe,EAAE,GAAGpB,cAAc;QACrEO;QACAG;QACAC;IACF;IAEA,IAAIb,iBAAiBS,QAAQ;QAC3B,gBAAgB;QAChB,IAAIA,MAAMc,KAAK,EAAEC,aAAa;YAC5B,MAAMf,MAAMc,KAAK,CAACC,WAAW,CAACC,MAAM,CAAC,OAAOC,WAAWC;gBACrD,MAAMD;gBAEN,MAAME,cAAc,MAAMD,YAAY;oBACpCtB;oBACAC;oBACAC;oBACAE;oBACAC;oBACAC;oBACAkB,aAAarB;oBACbW,MAAMC;oBACNN;oBACAC;oBACAe,eAAehB,WAAW,CAACL,MAAMsB,IAAI,CAAC;oBACtC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AE,CAAA;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,oJAexB,IAAI,KAAG,OAAO,CAAC,IAAI,CAyBrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterChange/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown>\n doc: Record<string, unknown>\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n operation: 'create' | 'update'\n path: (number | string)[]\n previousDoc: Record<string, unknown>\n previousSiblingDoc: Record<string, unknown>\n req: PayloadRequestWithData\n schemaPath: string[]\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\nexport const traverseFields = async ({\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n path,\n previousDoc,\n previousSiblingDoc,\n req,\n schemaPath,\n siblingData,\n siblingDoc,\n}: Args): Promise<void> => {\n const promises = []\n\n fields.forEach((field) => {\n promises.push(\n promise({\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","collection","context","data","doc","fields","global","operation","path","previousDoc","previousSiblingDoc","req","schemaPath","siblingData","siblingDoc","promises","forEach","field","push","parentPath","parentSchemaPath","Promise","all"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterChange/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown>\n doc: Record<string, unknown>\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n operation: 'create' | 'update'\n path: (number | string)[]\n previousDoc: Record<string, unknown>\n previousSiblingDoc: Record<string, unknown>\n req: PayloadRequestWithData\n schemaPath: string[]\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\nexport const traverseFields = async ({\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n path,\n previousDoc,\n previousSiblingDoc,\n req,\n schemaPath,\n siblingData,\n siblingDoc,\n}: Args): Promise<void> => {\n const promises = []\n\n fields.forEach((field) => {\n promises.push(\n promise({\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","collection","context","data","doc","fields","global","operation","path","previousDoc","previousSiblingDoc","req","schemaPath","siblingData","siblingDoc","promises","forEach","field","push","parentPath","parentSchemaPath","Promise","all"],"mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAmBtC,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,kBAAkB,EAClBC,GAAG,EACHC,UAAU,EACVC,WAAW,EACXC,UAAU,EACL;IACL,MAAMC,WAAW,EAAE;IAEnBV,OAAOW,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXnB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAa;YACAX;YACAC;YACAY,YAAYX;YACZY,kBAAkBR;YAClBH;YACAC;YACAC;YACAE;YACAC;QACF;IAEJ;IAEA,MAAMO,QAAQC,GAAG,CAACP;AACpB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\n\nimport { deepCopyObject } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n currentDepth?: number\n depth: number\n doc: Record<string, unknown>\n draft: boolean\n fallbackLocale: null | string\n findMany?: boolean\n flattenLocales?: boolean\n global: SanitizedGlobalConfig | null\n locale: string\n overrideAccess: boolean\n req: PayloadRequestWithData\n showHiddenFields: boolean\n}\n\n/**\n * This function is responsible for the following actions, in order:\n * - Remove hidden fields from response\n * - Flatten locales into requested locale. If the input doc contains all locales, the output doc after this function will only contain the requested locale.\n * - Sanitize outgoing data (point field, etc.)\n * - Execute field hooks\n * - Execute read access control\n * - Populate relationships\n */\n\nexport async function afterRead<T = any>(args: Args): Promise<T> {\n const {\n collection,\n context,\n currentDepth: incomingCurrentDepth,\n depth: incomingDepth,\n doc: incomingDoc,\n draft,\n fallbackLocale,\n findMany,\n flattenLocales = true,\n global,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n } = args\n\n const doc = deepCopyObject(incomingDoc)\n const fieldPromises = []\n const populationPromises = []\n\n let depth =\n incomingDepth || incomingDepth === 0\n ? parseInt(String(incomingDepth), 10)\n : req.payload.config.defaultDepth\n if (depth > req.payload.config.maxDepth) depth = req.payload.config.maxDepth\n\n const currentDepth = incomingCurrentDepth || 1\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: collection?.fields || global?.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [],\n populationPromises,\n req,\n schemaPath: [],\n showHiddenFields,\n siblingDoc: doc,\n })\n\n await Promise.all(fieldPromises)\n await Promise.all(populationPromises)\n\n return doc\n}\n"],"names":["deepCopyObject","traverseFields","afterRead","args","collection","context","currentDepth","incomingCurrentDepth","depth","incomingDepth","doc","incomingDoc","draft","fallbackLocale","findMany","flattenLocales","global","locale","overrideAccess","req","showHiddenFields","fieldPromises","populationPromises","parseInt","String","payload","config","defaultDepth","maxDepth","fields","path","schemaPath","siblingDoc","Promise","all"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\n\nimport { deepCopyObject } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n currentDepth?: number\n depth: number\n doc: Record<string, unknown>\n draft: boolean\n fallbackLocale: null | string\n findMany?: boolean\n flattenLocales?: boolean\n global: SanitizedGlobalConfig | null\n locale: string\n overrideAccess: boolean\n req: PayloadRequestWithData\n showHiddenFields: boolean\n}\n\n/**\n * This function is responsible for the following actions, in order:\n * - Remove hidden fields from response\n * - Flatten locales into requested locale. If the input doc contains all locales, the output doc after this function will only contain the requested locale.\n * - Sanitize outgoing data (point field, etc.)\n * - Execute field hooks\n * - Execute read access control\n * - Populate relationships\n */\n\nexport async function afterRead<T = any>(args: Args): Promise<T> {\n const {\n collection,\n context,\n currentDepth: incomingCurrentDepth,\n depth: incomingDepth,\n doc: incomingDoc,\n draft,\n fallbackLocale,\n findMany,\n flattenLocales = true,\n global,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n } = args\n\n const doc = deepCopyObject(incomingDoc)\n const fieldPromises = []\n const populationPromises = []\n\n let depth =\n incomingDepth || incomingDepth === 0\n ? parseInt(String(incomingDepth), 10)\n : req.payload.config.defaultDepth\n if (depth > req.payload.config.maxDepth) depth = req.payload.config.maxDepth\n\n const currentDepth = incomingCurrentDepth || 1\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: collection?.fields || global?.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [],\n populationPromises,\n req,\n schemaPath: [],\n showHiddenFields,\n siblingDoc: doc,\n })\n\n await Promise.all(fieldPromises)\n await Promise.all(populationPromises)\n\n return doc\n}\n"],"names":["deepCopyObject","traverseFields","afterRead","args","collection","context","currentDepth","incomingCurrentDepth","depth","incomingDepth","doc","incomingDoc","draft","fallbackLocale","findMany","flattenLocales","global","locale","overrideAccess","req","showHiddenFields","fieldPromises","populationPromises","parseInt","String","payload","config","defaultDepth","maxDepth","fields","path","schemaPath","siblingDoc","Promise","all"],"mappings":"AAIA,SAASA,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,sBAAqB;AAmBpD;;;;;;;;CAQC,GAED,OAAO,eAAeC,UAAmBC,IAAU;IACjD,MAAM,EACJC,UAAU,EACVC,OAAO,EACPC,cAAcC,oBAAoB,EAClCC,OAAOC,aAAa,EACpBC,KAAKC,WAAW,EAChBC,KAAK,EACLC,cAAc,EACdC,QAAQ,EACRC,iBAAiB,IAAI,EACrBC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,GAAG,EACHC,gBAAgB,EACjB,GAAGjB;IAEJ,MAAMO,MAAMV,eAAeW;IAC3B,MAAMU,gBAAgB,EAAE;IACxB,MAAMC,qBAAqB,EAAE;IAE7B,IAAId,QACFC,iBAAiBA,kBAAkB,IAC/Bc,SAASC,OAAOf,gBAAgB,MAChCU,IAAIM,OAAO,CAACC,MAAM,CAACC,YAAY;IACrC,IAAInB,QAAQW,IAAIM,OAAO,CAACC,MAAM,CAACE,QAAQ,EAAEpB,QAAQW,IAAIM,OAAO,CAACC,MAAM,CAACE,QAAQ;IAE5E,MAAMtB,eAAeC,wBAAwB;IAE7CN,eAAe;QACbG;QACAC;QACAC;QACAE;QACAE;QACAE;QACAC;QACAQ;QACAQ,QAAQzB,YAAYyB,UAAUb,QAAQa;QACtCf;QACAC;QACAC;QACAC;QACAC;QACAY,MAAM,EAAE;QACRR;QACAH;QACAY,YAAY,EAAE;QACdX;QACAY,YAAYtB;IACd;IAEA,MAAMuB,QAAQC,GAAG,CAACb;IAClB,MAAMY,QAAQC,GAAG,CAACZ;IAElB,OAAOZ;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAS9D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB;;OAEG;IACH,aAAa,EA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IAC5B,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAC/B;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,sBAAsB,CAAA;IAC3B,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAUD,eAAO,MAAM,OAAO,uRAuBjB,IAAI,KAAG,OAAO,CAAC,IAAI,CAklBrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } 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 getValueWithDefault from '../../getDefaultValue.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { relationshipPopulationPromise } from './relationshipPopulationPromise.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n currentDepth: number\n depth: number\n doc: Record<string, unknown>\n draft: boolean\n fallbackLocale: null | string\n field: Field | TabAsField\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n global: SanitizedGlobalConfig | null\n locale: null | string\n overrideAccess: boolean\n /**\n * The parent's path.\n */\n parentPath: (number | string)[]\n /**\n * The parent's schemaPath (path without indexes).\n */\n parentSchemaPath: string[]\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Remove hidden fields from response\n// - Flatten locales into requested locale\n// - Sanitize outgoing data (point field, etc.)\n// - Execute field hooks\n// - Execute read access control\n// - Populate relationships\n\nexport const promise = async ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath,\n parentSchemaPath,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (\n fieldAffectsData(field) &&\n field.hidden &&\n typeof siblingDoc[field.name] !== 'undefined' &&\n !showHiddenFields\n ) {\n delete siblingDoc[field.name]\n }\n\n const shouldHoistLocalizedValue =\n flattenLocales &&\n fieldAffectsData(field) &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null &&\n field.localized &&\n locale !== 'all' &&\n req.payload.config.localization\n\n if (shouldHoistLocalizedValue) {\n // replace actual value with localized value before sanitizing\n // { [locale]: fields } -> fields\n const value = siblingDoc[field.name][locale]\n\n let hoistedValue = value\n\n if (fallbackLocale && fallbackLocale !== locale) {\n const fallbackValue = siblingDoc[field.name][fallbackLocale]\n const isNullOrUndefined = typeof value === 'undefined' || value === null\n\n if (fallbackValue) {\n switch (field.type) {\n case 'text':\n case 'textarea': {\n if (value === '' || isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n\n default: {\n if (isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n }\n }\n }\n\n siblingDoc[field.name] = hoistedValue\n }\n\n // Sanitize outgoing field value\n switch (field.type) {\n case 'group': {\n // Fill groups with empty objects so fields with hooks within groups can populate\n // themselves virtually as necessary\n if (typeof siblingDoc[field.name] === 'undefined') {\n siblingDoc[field.name] = {}\n }\n\n break\n }\n case 'tabs': {\n field.tabs.forEach((tab) => {\n if (\n tabHasName(tab) &&\n (typeof siblingDoc[tab.name] === 'undefined' || siblingDoc[tab.name] === null)\n ) {\n siblingDoc[tab.name] = {}\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 if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n // Rich Text fields should use afterRead hooks to do population. The previous editor.populationPromises have been renamed to editor.graphQLPopulationPromises\n break\n }\n\n case 'point': {\n const pointDoc = siblingDoc[field.name] as Record<string, unknown>\n if (Array.isArray(pointDoc?.coordinates) && pointDoc.coordinates.length === 2) {\n siblingDoc[field.name] = pointDoc.coordinates\n } else {\n siblingDoc[field.name] = undefined\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (triggerHooks && field.hooks?.afterRead) {\n await field.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n data: doc,\n field,\n findMany,\n global,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingDoc,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n data: doc,\n field,\n findMany,\n global,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingDoc,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n let allowDefaultValue = true\n if (triggerAccessControl && field.access && field.access.read) {\n const result = overrideAccess\n ? true\n : await field.access.read({\n id: doc.id as number | string,\n data: doc,\n doc,\n req,\n siblingData: siblingDoc,\n })\n\n if (!result) {\n allowDefaultValue = false\n delete siblingDoc[field.name]\n }\n }\n\n // Set defaultValue on the field for globals being returned without being first created\n // or collection documents created prior to having a default\n if (\n allowDefaultValue &&\n typeof siblingDoc[field.name] === 'undefined' &&\n typeof field.defaultValue !== 'undefined'\n ) {\n siblingDoc[field.name] = await getValueWithDefault({\n defaultValue: field.defaultValue,\n locale,\n user: req.user,\n value: siblingDoc[field.name],\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n populationPromises.push(\n relationshipPopulationPromise({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n siblingDoc,\n }),\n )\n }\n }\n\n switch (field.type) {\n case 'group': {\n let groupDoc = siblingDoc[field.name] as Record<string, unknown>\n if (typeof siblingDoc[field.name] !== 'object') groupDoc = {}\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: groupDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, i) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, i) => {\n const block = field.blocks.find((blockType) => blockType.slug === row.blockType)\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n const block = field.blocks.find((blockType) => blockType.slug === row.blockType)\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tab': {\n let tabDoc = siblingDoc\n if (tabHasName(field)) {\n tabDoc = siblingDoc[field.name] as Record<string, unknown>\n if (typeof siblingDoc[field.name] !== 'object') tabDoc = {}\n }\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: tabDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tabs': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.afterRead?.length) {\n await editor.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getValueWithDefault","getFieldPaths","relationshipPopulationPromise","traverseFields","promise","collection","context","currentDepth","depth","doc","draft","fallbackLocale","field","fieldPromises","findMany","flattenLocales","global","locale","overrideAccess","parentPath","parentSchemaPath","populationPromises","req","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","path","fieldPath","schemaPath","fieldSchemaPath","hidden","name","shouldHoistLocalizedValue","localized","payload","config","localization","value","hoistedValue","fallbackValue","isNullOrUndefined","type","tabs","forEach","tab","editor","Error","pointDoc","Array","isArray","coordinates","length","undefined","hooks","afterRead","reduce","priorHook","currentHook","shouldRunHookOnAllLocales","hookPromises","Object","entries","map","hookedValue","data","operation","originalDoc","siblingData","Promise","all","resolve","allowDefaultValue","access","read","result","id","defaultValue","user","push","groupDoc","fields","rows","row","i","values","localeRows","block","blocks","find","blockType","slug","tabDoc"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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I,CAAC,CAACf,OAAO,GAAG+C;oCACnC;gCACF,CAAA;4BAGF,MAAMK,QAAQC,GAAG,CAACV;wBACpB,OAAO;4BACL,MAAMI,cAAc,MAAMN,YAAY;gCACpCrD;gCACAC;gCACAC;gCACA0D,MAAMxD;gCACND;gCACAE;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAiD,WAAW;gCACXC,aAAa1D;gCACbS;gCACAS,MAAMC;gCACNP;gCACAC;gCACAO,YAAYC;gCACZP;gCACA6C,aAAa5C;gCACbC;gCACAC;gCACAY,OAAOd,UAAU,CAACZ,MAAMoB,IAAI,CAAC;4BAC/B;4BAEA,IAAIgC,gBAAgBX,WAAW;gCAC7B7B,UAAU,CAACZ,MAAMoB,IAAI,CAAC,GAAGgC;4BAC3B;wBACF;oBACF,GAAGK,QAAQE,OAAO;gBACpB;gBACA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } 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 getValueWithDefault from '../../getDefaultValue.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { relationshipPopulationPromise } from './relationshipPopulationPromise.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n currentDepth: number\n depth: number\n doc: Record<string, unknown>\n draft: boolean\n fallbackLocale: null | string\n field: Field | TabAsField\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n global: SanitizedGlobalConfig | null\n locale: null | string\n overrideAccess: boolean\n /**\n * The parent's path.\n */\n parentPath: (number | string)[]\n /**\n * The parent's schemaPath (path without indexes).\n */\n parentSchemaPath: string[]\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Remove hidden fields from response\n// - Flatten locales into requested locale\n// - Sanitize outgoing data (point field, etc.)\n// - Execute field hooks\n// - Execute read access control\n// - Populate relationships\n\nexport const promise = async ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath,\n parentSchemaPath,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (\n fieldAffectsData(field) &&\n field.hidden &&\n typeof siblingDoc[field.name] !== 'undefined' &&\n !showHiddenFields\n ) {\n delete siblingDoc[field.name]\n }\n\n const shouldHoistLocalizedValue =\n flattenLocales &&\n fieldAffectsData(field) &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null &&\n field.localized &&\n locale !== 'all' &&\n req.payload.config.localization\n\n if (shouldHoistLocalizedValue) {\n // replace actual value with localized value before sanitizing\n // { [locale]: fields } -> fields\n const value = siblingDoc[field.name][locale]\n\n let hoistedValue = value\n\n if (fallbackLocale && fallbackLocale !== locale) {\n const fallbackValue = siblingDoc[field.name][fallbackLocale]\n const isNullOrUndefined = typeof value === 'undefined' || value === null\n\n if (fallbackValue) {\n switch (field.type) {\n case 'text':\n case 'textarea': {\n if (value === '' || isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n\n default: {\n if (isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n }\n }\n }\n\n siblingDoc[field.name] = hoistedValue\n }\n\n // Sanitize outgoing field value\n switch (field.type) {\n case 'group': {\n // Fill groups with empty objects so fields with hooks within groups can populate\n // themselves virtually as necessary\n if (typeof siblingDoc[field.name] === 'undefined') {\n siblingDoc[field.name] = {}\n }\n\n break\n }\n case 'tabs': {\n field.tabs.forEach((tab) => {\n if (\n tabHasName(tab) &&\n (typeof siblingDoc[tab.name] === 'undefined' || siblingDoc[tab.name] === null)\n ) {\n siblingDoc[tab.name] = {}\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 if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n // Rich Text fields should use afterRead hooks to do population. The previous editor.populationPromises have been renamed to editor.graphQLPopulationPromises\n break\n }\n\n case 'point': {\n const pointDoc = siblingDoc[field.name] as Record<string, unknown>\n if (Array.isArray(pointDoc?.coordinates) && pointDoc.coordinates.length === 2) {\n siblingDoc[field.name] = pointDoc.coordinates\n } else {\n siblingDoc[field.name] = undefined\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (triggerHooks && field.hooks?.afterRead) {\n await field.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n data: doc,\n field,\n findMany,\n global,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingDoc,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n data: doc,\n field,\n findMany,\n global,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingDoc,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n let allowDefaultValue = true\n if (triggerAccessControl && field.access && field.access.read) {\n const result = overrideAccess\n ? true\n : await field.access.read({\n id: doc.id as number | string,\n data: doc,\n doc,\n req,\n siblingData: siblingDoc,\n })\n\n if (!result) {\n allowDefaultValue = false\n delete siblingDoc[field.name]\n }\n }\n\n // Set defaultValue on the field for globals being returned without being first created\n // or collection documents created prior to having a default\n if (\n allowDefaultValue &&\n typeof siblingDoc[field.name] === 'undefined' &&\n typeof field.defaultValue !== 'undefined'\n ) {\n siblingDoc[field.name] = await getValueWithDefault({\n defaultValue: field.defaultValue,\n locale,\n user: req.user,\n value: siblingDoc[field.name],\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n populationPromises.push(\n relationshipPopulationPromise({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n siblingDoc,\n }),\n )\n }\n }\n\n switch (field.type) {\n case 'group': {\n let groupDoc = siblingDoc[field.name] as Record<string, unknown>\n if (typeof siblingDoc[field.name] !== 'object') groupDoc = {}\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: groupDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, i) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, i) => {\n const block = field.blocks.find((blockType) => blockType.slug === row.blockType)\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n const block = field.blocks.find((blockType) => blockType.slug === row.blockType)\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tab': {\n let tabDoc = siblingDoc\n if (tabHasName(field)) {\n tabDoc = siblingDoc[field.name] as Record<string, unknown>\n if (typeof siblingDoc[field.name] !== 'object') tabDoc = {}\n }\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: tabDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tabs': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.afterRead?.length) {\n await editor.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getValueWithDefault","getFieldPaths","relationshipPopulationPromise","traverseFields","promise","collection","context","currentDepth","depth","doc","draft","fallbackLocale","field","fieldPromises","findMany","flattenLocales","global","locale","overrideAccess","parentPath","parentSchemaPath","populationPromises","req","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","path","fieldPath","schemaPath","fieldSchemaPath","hidden","name","shouldHoistLocalizedValue","localized","payload","config","localization","value","hoistedValue","fallbackValue","isNullOrUndefined","type","tabs","forEach","tab","editor","Error","pointDoc","Array","isArray","coordinates","length","undefined","hooks","afterRead","reduce","priorHook","currentHook","shouldRunHookOnAllLocales","hookPromises","Object","entries","map","hookedValue","data","operation","originalDoc","siblingData","Promise","all","resolve","allowDefaultValue","access","read","result","id","defaultValue","user","push","groupDoc","fields","rows","row","i","values","localeRows","block","blocks","find","blockType","slug","tabDoc"],"mappings":"AAAA,oCAAoC,GAOpC,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,OAAOC,yBAAyB,2BAA0B;AAC1D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,6BAA6B,QAAQ,qCAAoC;AAClF,SAASC,cAAc,QAAQ,sBAAqB;AAoCpD,oEAAoE;AACpE,uCAAuC;AACvC,0CAA0C;AAC1C,+CAA+C;AAC/C,wBAAwB;AACxB,gCAAgC;AAChC,2BAA2B;AAE3B,OAAO,MAAMC,UAAU,OAAO,EAC5BC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,KAAK,EACLC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAChBC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,IAAI,EAC3BC,eAAe,IAAI,EACd;IACL,MAAM,EAAEC,MAAMC,SAAS,EAAEC,YAAYC,eAAe,EAAE,GAAG7B,cAAc;QACrEW;QACAO;QACAC;IACF;IAEA,IACEtB,iBAAiBc,UACjB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;wCACAC;wCACA0D,MAAMxD;wCACND;wCACAE;wCACAC;wCACAC;wCACAC;wCACAC;wCACAC;wCACAC;wCACAC;wCACAiD,WAAW;wCACXC,aAAa1D;wCACbS;wCACAS,MAAMC;wCACNP;wCACAC;wCACAO,YAAYC;wCACZP;wCACA6C,aAAa5C;wCACbC;wCACAC;wCACAY;oCACF;oCAEA,IAAI0B,gBAAgBX,WAAW;wCAC7B7B,UAAU,CAACZ,MAAMoB,IAAI,CAAC,CAACf,OAAO,GAAG+C;oCACnC;gCACF,CAAA;4BAGF,MAAMK,QAAQC,GAAG,CAACV;wBACpB,OAAO;4BACL,MAAMI,cAAc,MAAMN,YAAY;gCACpCrD;gCACAC;gCACAC;gCACA0D,MAAMxD;gCACND;gCACAE;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAiD,WAAW;gCACXC,aAAa1D;gCACbS;gCACAS,MAAMC;gCACNP;gCACAC;gCACAO,YAAYC;gCACZP;gCACA6C,aAAa5C;gCACbC;gCACAC;gCACAY,OAAOd,UAAU,CAACZ,MAAMoB,IAAI,CAAC;4BAC/B;4BAEA,IAAIgC,gBAAgBX,WAAW;gCAC7B7B,UAAU,CAACZ,MAAMoB,IAAI,CAAC,GAAGgC;4BAC3B;wBACF;oBACF,GAAGK,QAAQE,OAAO;gBACpB;gBACA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationshipPopulationPromise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/relationshipPopulationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAgG3E,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAAA;IACtC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC,CAAA;AAED,eAAO,MAAM,6BAA6B,sHAWvC,WAAW,KAAG,
|
|
1
|
+
{"version":3,"file":"relationshipPopulationPromise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/relationshipPopulationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAgG3E,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAAA;IACtC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC,CAAA;AAED,eAAO,MAAM,6BAA6B,sHAWvC,WAAW,KAAG,OAAO,CAAC,IAAI,CAqG5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/relationshipPopulationPromise.ts"],"sourcesContent":["import type { PayloadRequestWithData } from '../../../types/index.js'\nimport type { RelationshipField, UploadField } from '../../config/types.js'\n\nimport { createDataloaderCacheKey } from '../../../collections/dataloader.js'\nimport { fieldHasMaxDepth, fieldSupportsMany } from '../../config/types.js'\n\ntype PopulateArgs = {\n currentDepth: number\n data: Record<string, unknown>\n dataReference: Record<string, any>\n depth: number\n draft: boolean\n fallbackLocale: null | string\n field: RelationshipField | UploadField\n index?: number\n key?: string\n locale: null | string\n overrideAccess: boolean\n req: PayloadRequestWithData\n showHiddenFields: boolean\n}\n\nconst populate = async ({\n currentDepth,\n data,\n dataReference,\n depth,\n draft,\n fallbackLocale,\n field,\n index,\n key,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n}: PopulateArgs) => {\n const dataToUpdate = dataReference\n const relation = Array.isArray(field.relationTo) ? (data.relationTo as string) : field.relationTo\n const relatedCollection = req.payload.collections[relation]\n\n if (relatedCollection) {\n let id = Array.isArray(field.relationTo) ? data.value : data\n let relationshipValue\n const shouldPopulate = depth && currentDepth <= depth\n\n if (\n typeof id !== 'string' &&\n typeof id !== 'number' &&\n typeof id?.toString === 'function' &&\n typeof id !== 'object'\n ) {\n id = id.toString()\n }\n\n if (shouldPopulate) {\n relationshipValue = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: relatedCollection.config.slug,\n currentDepth: currentDepth + 1,\n depth,\n docID: id as string,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n showHiddenFields,\n transactionID: req.transactionID,\n }),\n )\n }\n\n if (!relationshipValue) {\n // ids are visible regardless of access controls\n relationshipValue = id\n }\n\n if (typeof index === 'number' && typeof key === 'string') {\n if (Array.isArray(field.relationTo)) {\n dataToUpdate[field.name][key][index].value = relationshipValue\n } else {\n dataToUpdate[field.name][key][index] = relationshipValue\n }\n } else if (typeof index === 'number' || typeof key === 'string') {\n if (Array.isArray(field.relationTo)) {\n dataToUpdate[field.name][index ?? key].value = relationshipValue\n } else {\n dataToUpdate[field.name][index ?? key] = relationshipValue\n }\n } else if (Array.isArray(field.relationTo)) {\n dataToUpdate[field.name].value = relationshipValue\n } else {\n dataToUpdate[field.name] = relationshipValue\n }\n }\n}\n\ntype PromiseArgs = {\n currentDepth: number\n depth: number\n draft: boolean\n fallbackLocale: null | string\n field: RelationshipField | UploadField\n locale: null | string\n overrideAccess: boolean\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, any>\n}\n\nexport const relationshipPopulationPromise = async ({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n siblingDoc,\n}: PromiseArgs): Promise<void> => {\n const resultingDoc = siblingDoc\n const populateDepth = fieldHasMaxDepth(field) && field.maxDepth < depth ? field.maxDepth : depth\n const rowPromises = []\n\n if (fieldSupportsMany(field) && field.hasMany) {\n if (\n locale === 'all' &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null\n ) {\n Object.keys(siblingDoc[field.name]).forEach((key) => {\n if (Array.isArray(siblingDoc[field.name][key])) {\n siblingDoc[field.name][key].forEach((relatedDoc, index) => {\n const rowPromise = async () => {\n await populate({\n currentDepth,\n data: siblingDoc[field.name][key][index],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n index,\n key,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n rowPromises.push(rowPromise())\n })\n }\n })\n } else if (Array.isArray(siblingDoc[field.name])) {\n siblingDoc[field.name].forEach((relatedDoc, index) => {\n const rowPromise = async () => {\n if (relatedDoc) {\n await populate({\n currentDepth,\n data: relatedDoc,\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n index,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n }\n\n rowPromises.push(rowPromise())\n })\n }\n } else if (\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null &&\n locale === 'all'\n ) {\n Object.keys(siblingDoc[field.name]).forEach((key) => {\n const rowPromise = async () => {\n await populate({\n currentDepth,\n data: siblingDoc[field.name][key],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n key,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n rowPromises.push(rowPromise())\n })\n\n await Promise.all(rowPromises)\n } else if (siblingDoc[field.name]) {\n await populate({\n currentDepth,\n data: siblingDoc[field.name],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n await Promise.all(rowPromises)\n}\n"],"names":["createDataloaderCacheKey","fieldHasMaxDepth","fieldSupportsMany","populate","currentDepth","data","dataReference","depth","draft","fallbackLocale","field","index","key","locale","overrideAccess","req","showHiddenFields","dataToUpdate","relation","Array","isArray","relationTo","relatedCollection","payload","collections","id","value","relationshipValue","shouldPopulate","toString","payloadDataLoader","load","collectionSlug","config","slug","docID","transactionID","name","relationshipPopulationPromise","siblingDoc","resultingDoc","populateDepth","maxDepth","rowPromises","hasMany","Object","keys","forEach","relatedDoc","rowPromise","push","Promise","all"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,wBAAwB,QAAQ,qCAAoC;AAC7E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,wBAAuB;AAkB3E,MAAMC,WAAW,OAAO,EACtBC,YAAY,EACZC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACLC,cAAc,EACdC,KAAK,EACLC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,cAAc,EACdC,GAAG,EACHC,gBAAgB,EACH;IACb,MAAMC,eAAeX;IACrB,MAAMY,WAAWC,MAAMC,OAAO,CAACV,MAAMW,UAAU,IAAKhB,K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ources":["../../../../src/fields/hooks/afterRead/relationshipPopulationPromise.ts"],"sourcesContent":["import type { PayloadRequestWithData } from '../../../types/index.js'\nimport type { RelationshipField, UploadField } from '../../config/types.js'\n\nimport { createDataloaderCacheKey } from '../../../collections/dataloader.js'\nimport { fieldHasMaxDepth, fieldSupportsMany } from '../../config/types.js'\n\ntype PopulateArgs = {\n currentDepth: number\n data: Record<string, unknown>\n dataReference: Record<string, any>\n depth: number\n draft: boolean\n fallbackLocale: null | string\n field: RelationshipField | UploadField\n index?: number\n key?: string\n locale: null | string\n overrideAccess: boolean\n req: PayloadRequestWithData\n showHiddenFields: boolean\n}\n\nconst populate = async ({\n currentDepth,\n data,\n dataReference,\n depth,\n draft,\n fallbackLocale,\n field,\n index,\n key,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n}: PopulateArgs) => {\n const dataToUpdate = dataReference\n const relation = Array.isArray(field.relationTo) ? (data.relationTo as string) : field.relationTo\n const relatedCollection = req.payload.collections[relation]\n\n if (relatedCollection) {\n let id = Array.isArray(field.relationTo) ? data.value : data\n let relationshipValue\n const shouldPopulate = depth && currentDepth <= depth\n\n if (\n typeof id !== 'string' &&\n typeof id !== 'number' &&\n typeof id?.toString === 'function' &&\n typeof id !== 'object'\n ) {\n id = id.toString()\n }\n\n if (shouldPopulate) {\n relationshipValue = await req.payloadDataLoader.load(\n createDataloaderCacheKey({\n collectionSlug: relatedCollection.config.slug,\n currentDepth: currentDepth + 1,\n depth,\n docID: id as string,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n showHiddenFields,\n transactionID: req.transactionID,\n }),\n )\n }\n\n if (!relationshipValue) {\n // ids are visible regardless of access controls\n relationshipValue = id\n }\n\n if (typeof index === 'number' && typeof key === 'string') {\n if (Array.isArray(field.relationTo)) {\n dataToUpdate[field.name][key][index].value = relationshipValue\n } else {\n dataToUpdate[field.name][key][index] = relationshipValue\n }\n } else if (typeof index === 'number' || typeof key === 'string') {\n if (Array.isArray(field.relationTo)) {\n dataToUpdate[field.name][index ?? key].value = relationshipValue\n } else {\n dataToUpdate[field.name][index ?? key] = relationshipValue\n }\n } else if (Array.isArray(field.relationTo)) {\n dataToUpdate[field.name].value = relationshipValue\n } else {\n dataToUpdate[field.name] = relationshipValue\n }\n }\n}\n\ntype PromiseArgs = {\n currentDepth: number\n depth: number\n draft: boolean\n fallbackLocale: null | string\n field: RelationshipField | UploadField\n locale: null | string\n overrideAccess: boolean\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, any>\n}\n\nexport const relationshipPopulationPromise = async ({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n siblingDoc,\n}: PromiseArgs): Promise<void> => {\n const resultingDoc = siblingDoc\n const populateDepth = fieldHasMaxDepth(field) && field.maxDepth < depth ? field.maxDepth : depth\n const rowPromises = []\n\n if (fieldSupportsMany(field) && field.hasMany) {\n if (\n locale === 'all' &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null\n ) {\n Object.keys(siblingDoc[field.name]).forEach((key) => {\n if (Array.isArray(siblingDoc[field.name][key])) {\n siblingDoc[field.name][key].forEach((relatedDoc, index) => {\n const rowPromise = async () => {\n await populate({\n currentDepth,\n data: siblingDoc[field.name][key][index],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n index,\n key,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n rowPromises.push(rowPromise())\n })\n }\n })\n } else if (Array.isArray(siblingDoc[field.name])) {\n siblingDoc[field.name].forEach((relatedDoc, index) => {\n const rowPromise = async () => {\n if (relatedDoc) {\n await populate({\n currentDepth,\n data: relatedDoc,\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n index,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n }\n\n rowPromises.push(rowPromise())\n })\n }\n } else if (\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null &&\n locale === 'all'\n ) {\n Object.keys(siblingDoc[field.name]).forEach((key) => {\n const rowPromise = async () => {\n await populate({\n currentDepth,\n data: siblingDoc[field.name][key],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n key,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n rowPromises.push(rowPromise())\n })\n\n await Promise.all(rowPromises)\n } else if (siblingDoc[field.name]) {\n await populate({\n currentDepth,\n data: siblingDoc[field.name],\n dataReference: resultingDoc,\n depth: populateDepth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n }\n await Promise.all(rowPromises)\n}\n"],"names":["createDataloaderCacheKey","fieldHasMaxDepth","fieldSupportsMany","populate","currentDepth","data","dataReference","depth","draft","fallbackLocale","field","index","key","locale","overrideAccess","req","showHiddenFields","dataToUpdate","relation","Array","isArray","relationTo","relatedCollection","payload","collections","id","value","relationshipValue","shouldPopulate","toString","payloadDataLoader","load","collectionSlug","config","slug","docID","transactionID","name","relationshipPopulationPromise","siblingDoc","resultingDoc","populateDepth","maxDepth","rowPromises","hasMany","Object","keys","forEach","relatedDoc","rowPromise","push","Promise","all"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,qCAAoC;AAC7E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,wBAAuB;AAkB3E,MAAMC,WAAW,OAAO,EACtBC,YAAY,EACZC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACLC,cAAc,EACdC,KAAK,EACLC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,cAAc,EACdC,GAAG,EACHC,gBAAgB,EACH;IACb,MAAMC,eAAeX;IACrB,MAAMY,WAAWC,MAAMC,OAAO,CAACV,MAAMW,UAAU,IAAKhB,KAAKgB,UAAU,GAAcX,MAAMW,UAAU;IACjG,MAAMC,oBAAoBP,IAAIQ,OAAO,CAACC,WAAW,CAACN,SAAS;IAE3D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7B,MAAM2B,IAAI,CAAC,GAAG;YAChDE,UAAU,CAAC7B,MAAM2B,IAAI,CAAC,CAACU,OAAO,CAAC,CAACC,YAAYrC;gBAC1C,MAAMsC,aAAa;oBACjB,IAAID,YAAY;wBACd,MAAM7C,SAAS;4BACbC;4BACAC,MAAM2C;4BACN1C,eAAekC;4BACfjC,OAAOkC;4BACPjC;4BACAC;4BACAC;4BACAC;4BACAE;4BACAC;4BACAC;4BACAC;wBACF;oBACF;gBACF;gBAEA2B,YAAYO,IAAI,CAACD;YACnB;QACF;IACF,OAAO,IACL,OAAOV,UAAU,CAAC7B,MAAM2B,IAAI,CAAC,KAAK,YAClCE,UAAU,CAAC7B,MAAM2B,IAAI,CAAC,KAAK,QAC3BxB,WAAW,OACX;QACAgC,OAAOC,IAAI,CAACP,UAAU,CAAC7B,MAAM2B,IAAI,CAAC,EAAEU,OAAO,CAAC,CAACnC;YAC3C,MAAMqC,aAAa;gBACjB,MAAM9C,SAAS;oBACbC;oBACAC,MAAMkC,UAAU,CAAC7B,MAAM2B,IAAI,CAAC,CAACzB,IAAI;oBACjCN,eAAekC;oBACfjC,OAAOkC;oBACPjC;oBACAC;oBACAC;oBACAE;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;YACF;YACA2B,YAAYO,IAAI,CAACD;QACnB;QAEA,MAAME,QAAQC,GAAG,CAACT;IACpB,OAAO,IAAIJ,UAAU,CAAC7B,MAAM2B,IAAI,CAAC,EAAE;QACjC,MAAMlC,SAAS;YACbC;YACAC,MAAMkC,UAAU,CAAC7B,MAAM2B,IAAI,CAAC;YAC5B/B,eAAekC;YACfjC,OAAOkC;YACPjC;YACAC;YACAC;YACAG;YACAC;YACAC;YACAC;QACF;IACF;IACA,MAAMmC,QAAQC,GAAG,CAACT;AACpB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n currentDepth: number\n depth: number\n doc: Record<string, unknown>\n draft: boolean\n fallbackLocale: null | string\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n fields: (Field | TabAsField)[]\n findMany: boolean\n flattenLocales: boolean\n global: SanitizedGlobalConfig | null\n locale: null | string\n overrideAccess: boolean\n path: (number | string)[]\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n schemaPath: string[]\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport const traverseFields = ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): void => {\n fields.forEach((field) => {\n fieldPromises.push(\n promise({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath: path,\n parentSchemaPath: schemaPath,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n }),\n )\n })\n}\n"],"names":["promise","traverseFields","collection","context","currentDepth","depth","doc","draft","fallbackLocale","fieldPromises","fields","findMany","flattenLocales","global","locale","overrideAccess","path","populationPromises","req","schemaPath","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","forEach","field","push","parentPath","parentSchemaPath"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n currentDepth: number\n depth: number\n doc: Record<string, unknown>\n draft: boolean\n fallbackLocale: null | string\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n fields: (Field | TabAsField)[]\n findMany: boolean\n flattenLocales: boolean\n global: SanitizedGlobalConfig | null\n locale: null | string\n overrideAccess: boolean\n path: (number | string)[]\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n schemaPath: string[]\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport const traverseFields = ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): void => {\n fields.forEach((field) => {\n fieldPromises.push(\n promise({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath: path,\n parentSchemaPath: schemaPath,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n }),\n )\n })\n}\n"],"names":["promise","traverseFields","collection","context","currentDepth","depth","doc","draft","fallbackLocale","fieldPromises","fields","findMany","flattenLocales","global","locale","overrideAccess","path","populationPromises","req","schemaPath","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","forEach","field","push","parentPath","parentSchemaPath"],"mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AA8BtC,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,kBAAkB,EAClBC,GAAG,EACHC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,IAAI,EAC3BC,eAAe,IAAI,EACd;IACLb,OAAOc,OAAO,CAAC,CAACC;QACdhB,cAAciB,IAAI,CAChB1B,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAiB;YACAhB;YACAE;YACAC;YACAC;YACAC;YACAC;YACAY,YAAYX;YACZY,kBAAkBT;YAClBF;YACAC;YACAE;YACAC;YACAC;YACAC;QACF;IAEJ;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/beforeDuplicate.ts"],"sourcesContent":["import type { FieldHookArgs } from '../../config/types.js'\n\nexport const beforeDuplicate = async (args: FieldHookArgs) =>\n await args.field.hooks.beforeDuplicate.reduce(async (priorHook, currentHook) => {\n await priorHook\n return await currentHook(args)\n }, Promise.resolve())\n"],"names":["beforeDuplicate","args","field","hooks","reduce","priorHook","currentHook","Promise","resolve"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/beforeDuplicate.ts"],"sourcesContent":["import type { FieldHookArgs } from '../../config/types.js'\n\nexport const beforeDuplicate = async (args: FieldHookArgs) =>\n await args.field.hooks.beforeDuplicate.reduce(async (priorHook, currentHook) => {\n await priorHook\n return await currentHook(args)\n }, Promise.resolve())\n"],"names":["beforeDuplicate","args","field","hooks","reduce","priorHook","currentHook","Promise","resolve"],"mappings":"AAEA,OAAO,MAAMA,kBAAkB,OAAOC,OACpC,MAAMA,KAAKC,KAAK,CAACC,KAAK,CAACH,eAAe,CAACI,MAAM,CAAC,OAAOC,WAAWC;QAC9D,MAAMD;QACN,OAAO,MAAMC,YAAYL;IAC3B,GAAGM,QAAQC,OAAO,IAAG"}
|