payload 3.0.0-beta.7 → 3.0.0-beta.70
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/bin.js +6 -3
- package/dist/admin/LanguageOptions.d.ts +6 -0
- package/dist/admin/LanguageOptions.d.ts.map +1 -0
- package/dist/admin/LanguageOptions.js +3 -0
- package/dist/admin/LanguageOptions.js.map +1 -0
- package/dist/admin/RichText.d.ts +143 -28
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/elements/Cell.d.ts +3 -9
- package/dist/admin/elements/Cell.d.ts.map +1 -1
- package/dist/admin/elements/Cell.js.map +1 -1
- package/dist/admin/elements/DatePicker.d.ts +7 -7
- package/dist/admin/elements/DatePicker.d.ts.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 +3 -0
- 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.d.ts +6 -2
- package/dist/admin/elements/WithServerSideProps.d.ts.map +1 -1
- package/dist/admin/elements/WithServerSideProps.js.map +1 -1
- package/dist/admin/forms/Error.js.map +1 -1
- package/dist/admin/forms/FieldDescription.d.ts +1 -1
- package/dist/admin/forms/FieldDescription.d.ts.map +1 -1
- package/dist/admin/forms/FieldDescription.js.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 +3 -2
- package/dist/admin/forms/Label.d.ts.map +1 -1
- package/dist/admin/forms/Label.js.map +1 -1
- package/dist/admin/forms/RowLabel.d.ts +1 -1
- package/dist/admin/forms/RowLabel.d.ts.map +1 -1
- package/dist/admin/forms/RowLabel.js.map +1 -1
- package/dist/admin/types.d.ts +5 -3
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/types.d.ts +5 -3
- 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 +1 -2
- package/dist/auth/baseFields/accountLock.d.ts.map +1 -1
- package/dist/auth/baseFields/accountLock.js +1 -1
- package/dist/auth/baseFields/accountLock.js.map +1 -1
- package/dist/auth/baseFields/apiKey.d.ts +1 -2
- package/dist/auth/baseFields/apiKey.d.ts.map +1 -1
- package/dist/auth/baseFields/apiKey.js +7 -6
- package/dist/auth/baseFields/apiKey.js.map +1 -1
- package/dist/auth/baseFields/auth.d.ts +1 -2
- package/dist/auth/baseFields/auth.d.ts.map +1 -1
- package/dist/auth/baseFields/auth.js +1 -16
- package/dist/auth/baseFields/auth.js.map +1 -1
- package/dist/auth/baseFields/email.d.ts +5 -0
- package/dist/auth/baseFields/email.d.ts.map +1 -0
- package/dist/auth/baseFields/email.js +25 -0
- package/dist/auth/baseFields/email.js.map +1 -0
- package/dist/auth/baseFields/username.d.ts +3 -0
- package/dist/auth/baseFields/username.d.ts.map +1 -0
- package/dist/auth/baseFields/username.js +25 -0
- package/dist/auth/baseFields/username.js.map +1 -0
- package/dist/auth/baseFields/verification.d.ts +1 -2
- package/dist/auth/baseFields/verification.d.ts.map +1 -1
- package/dist/auth/baseFields/verification.js +1 -1
- package/dist/auth/baseFields/verification.js.map +1 -1
- package/dist/auth/cookies.d.ts +17 -5
- package/dist/auth/cookies.d.ts.map +1 -1
- package/dist/auth/cookies.js +45 -14
- 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 -3
- package/dist/auth/executeAuthStrategies.d.ts.map +1 -1
- package/dist/auth/executeAuthStrategies.js +6 -4
- 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 +1 -1
- package/dist/auth/getAccessResults.js.map +1 -1
- package/dist/auth/getAuthFields.d.ts +4 -0
- package/dist/auth/getAuthFields.d.ts.map +1 -0
- package/dist/auth/getAuthFields.js +35 -0
- package/dist/auth/getAuthFields.js.map +1 -0
- package/dist/auth/getFieldsToSign.d.ts +1 -1
- package/dist/auth/getFieldsToSign.d.ts.map +1 -1
- package/dist/auth/getFieldsToSign.js +1 -1
- package/dist/auth/getFieldsToSign.js.map +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/isLocked.d.ts.map +1 -1
- package/dist/auth/isLocked.js +4 -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 +3 -3
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js +3 -5
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts +5 -5
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/forgotPassword.js +34 -20
- 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 +6 -10
- 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 -4
- 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 +5 -8
- 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 -4
- 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 +7 -10
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js +108 -11
- 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 +2 -1
- package/dist/auth/operations/me.d.ts.map +1 -1
- package/dist/auth/operations/me.js +25 -9
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts +3 -3
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +35 -17
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts +7 -13
- 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 +0 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js +2 -2
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts +5 -7
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/unlock.js +22 -15
- 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.d.ts +5 -6
- package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
- package/dist/auth/sendVerificationEmail.js +7 -8
- package/dist/auth/sendVerificationEmail.js.map +1 -1
- package/dist/auth/strategies/apiKey.d.ts.map +1 -1
- package/dist/auth/strategies/apiKey.js +9 -3
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/strategies/jwt.d.ts.map +1 -1
- package/dist/auth/strategies/jwt.js +38 -3
- package/dist/auth/strategies/jwt.js.map +1 -1
- package/dist/auth/strategies/local/authenticate.d.ts +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 +3 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.js +10 -7
- package/dist/auth/strategies/local/generatePasswordSaltHash.js.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
- package/dist/auth/strategies/local/register.d.ts +2 -2
- package/dist/auth/strategies/local/register.d.ts.map +1 -1
- package/dist/auth/strategies/local/register.js +19 -7
- package/dist/auth/strategies/local/register.js.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.d.ts +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 +23 -13
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/generateTypes.d.ts +3 -1
- package/dist/bin/generateTypes.d.ts.map +1 -1
- package/dist/bin/generateTypes.js +25 -11
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/bin/loadEnv.d.ts +2 -2
- package/dist/bin/loadEnv.d.ts.map +1 -1
- package/dist/bin/loadEnv.js +18 -17
- package/dist/bin/loadEnv.js.map +1 -1
- package/dist/bin/loader/clientExtensions.js.map +1 -1
- package/dist/bin/loader/compile.d.ts +2 -2
- package/dist/bin/loader/compile.d.ts.map +1 -1
- package/dist/bin/loader/compile.js.map +1 -1
- package/dist/bin/loader/ignores.d.ts +2 -0
- package/dist/bin/loader/ignores.d.ts.map +1 -0
- package/dist/bin/loader/ignores.js +5 -0
- package/dist/bin/loader/ignores.js.map +1 -0
- package/dist/bin/loader/index.d.ts.map +1 -1
- package/dist/bin/loader/index.js +14 -15
- package/dist/bin/loader/index.js.map +1 -1
- package/dist/bin/loader/read-default-tsconfig.d.ts +25 -0
- package/dist/bin/loader/read-default-tsconfig.d.ts.map +1 -1
- package/dist/bin/loader/read-default-tsconfig.js +25 -1
- package/dist/bin/loader/read-default-tsconfig.js.map +1 -1
- package/dist/bin/loader/resolveOriginalPath.d.ts +10 -0
- package/dist/bin/loader/resolveOriginalPath.d.ts.map +1 -0
- package/dist/bin/loader/resolveOriginalPath.js +36 -0
- package/dist/bin/loader/resolveOriginalPath.js.map +1 -0
- 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 +155 -156
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +4 -1
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +5 -64
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +9 -1
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/reservedFieldNames.d.ts +15 -0
- package/dist/collections/config/reservedFieldNames.d.ts.map +1 -0
- package/dist/collections/config/reservedFieldNames.js +104 -0
- package/dist/collections/config/reservedFieldNames.js.map +1 -0
- package/dist/collections/config/reservedFieldNames.spec.js +148 -0
- package/dist/collections/config/reservedFieldNames.spec.js.map +1 -0
- package/dist/collections/config/sanitize.d.ts +2 -3
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +39 -40
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +71 -17
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/dataloader.d.ts +14 -0
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/dataloader.js +27 -12
- package/dist/collections/dataloader.js.map +1 -1
- package/dist/collections/operations/count.d.ts +14 -0
- package/dist/collections/operations/count.d.ts.map +1 -0
- package/dist/collections/operations/count.js +75 -0
- package/dist/collections/operations/count.js.map +1 -0
- 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 +8 -17
- 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 +2 -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 +1 -0
- 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 +3 -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 +1 -0
- 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 +4 -4
- 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 +2 -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 +1 -0
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts +20 -0
- package/dist/collections/operations/local/count.d.ts.map +1 -0
- package/dist/collections/operations/local/count.js +19 -0
- package/dist/collections/operations/local/count.js.map +1 -0
- package/dist/collections/operations/local/create.d.ts +7 -8
- 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 +15 -17
- 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 +4 -2
- package/dist/collections/operations/local/index.d.ts.map +1 -1
- package/dist/collections/operations/local/index.js +4 -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 +14 -14
- 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 +3 -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 +6 -3
- 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 +6 -2
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utils.d.ts +42 -33
- 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.d.ts.map +1 -1
- package/dist/config/build.js +3 -4
- package/dist/config/build.js.map +1 -1
- package/dist/config/client.d.ts +6 -5
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +26 -24
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +17 -4
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/find.d.ts.map +1 -1
- package/dist/config/find.js +20 -23
- package/dist/config/find.js.map +1 -1
- package/dist/config/sanitize.d.ts +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +53 -15
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +183 -93
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +7 -13
- package/dist/config/types.js.map +1 -1
- package/dist/database/combineQueries.js.map +1 -1
- package/dist/database/createDatabaseAdapter.d.ts.map +1 -1
- package/dist/database/createDatabaseAdapter.js +1 -1
- package/dist/database/createDatabaseAdapter.js.map +1 -1
- package/dist/database/flattenWhereToOperators.js.map +1 -1
- package/dist/database/getLocalizedPaths.d.ts.map +1 -1
- package/dist/database/getLocalizedPaths.js +0 -1
- package/dist/database/getLocalizedPaths.js.map +1 -1
- package/dist/database/migrations/createMigration.d.ts.map +1 -1
- package/dist/database/migrations/createMigration.js +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 +12 -0
- package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -0
- package/dist/database/migrations/getPredefinedMigration.js +41 -0
- package/dist/database/migrations/getPredefinedMigration.js.map +1 -0
- package/dist/database/migrations/migrate.d.ts.map +1 -1
- package/dist/database/migrations/migrate.js +2 -2
- package/dist/database/migrations/migrate.js.map +1 -1
- package/dist/database/migrations/migrateDown.d.ts.map +1 -1
- package/dist/database/migrations/migrateDown.js +1 -1
- package/dist/database/migrations/migrateDown.js.map +1 -1
- package/dist/database/migrations/migrateRefresh.d.ts.map +1 -1
- package/dist/database/migrations/migrateRefresh.js +1 -1
- package/dist/database/migrations/migrateRefresh.js.map +1 -1
- package/dist/database/migrations/migrateReset.d.ts.map +1 -1
- package/dist/database/migrations/migrateReset.js +1 -1
- package/dist/database/migrations/migrateReset.js.map +1 -1
- package/dist/database/migrations/migrateStatus.js +0 -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.d.ts.map +1 -1
- package/dist/database/queryValidation/validateQueryPaths.js +4 -4
- package/dist/database/queryValidation/validateQueryPaths.js.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.js +0 -3
- package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
- package/dist/database/types.d.ts +28 -14
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/email/consoleEmailAdapter.d.ts +3 -0
- package/dist/email/consoleEmailAdapter.d.ts.map +1 -0
- package/dist/email/consoleEmailAdapter.js +17 -0
- package/dist/email/consoleEmailAdapter.js.map +1 -0
- package/dist/email/defaults.d.ts +2 -2
- package/dist/email/defaults.d.ts.map +1 -1
- package/dist/email/defaults.js +3 -3
- package/dist/email/defaults.js.map +1 -1
- package/dist/email/getStringifiedToAddress.d.ts +3 -0
- package/dist/email/getStringifiedToAddress.d.ts.map +1 -0
- package/dist/email/getStringifiedToAddress.js +20 -0
- package/dist/email/getStringifiedToAddress.js.map +1 -0
- package/dist/email/sendEmail.d.ts +3 -2
- package/dist/email/sendEmail.d.ts.map +1 -1
- package/dist/email/sendEmail.js +8 -4
- package/dist/email/sendEmail.js.map +1 -1
- package/dist/email/types.d.ts +26 -18
- package/dist/email/types.d.ts.map +1 -1
- package/dist/email/types.js +5 -1
- package/dist/email/types.js.map +1 -1
- package/dist/errors/APIError.d.ts +3 -2
- package/dist/errors/APIError.d.ts.map +1 -1
- package/dist/errors/APIError.js +9 -4
- package/dist/errors/APIError.js.map +1 -1
- package/dist/errors/AuthenticationError.d.ts +3 -4
- package/dist/errors/AuthenticationError.d.ts.map +1 -1
- package/dist/errors/AuthenticationError.js +4 -5
- package/dist/errors/AuthenticationError.js.map +1 -1
- package/dist/errors/DuplicateCollection.d.ts +2 -3
- package/dist/errors/DuplicateCollection.d.ts.map +1 -1
- package/dist/errors/DuplicateCollection.js +2 -3
- package/dist/errors/DuplicateCollection.js.map +1 -1
- package/dist/errors/DuplicateFieldName.d.ts +2 -3
- package/dist/errors/DuplicateFieldName.d.ts.map +1 -1
- package/dist/errors/DuplicateFieldName.js +2 -3
- package/dist/errors/DuplicateFieldName.js.map +1 -1
- package/dist/errors/DuplicateGlobal.d.ts +2 -3
- package/dist/errors/DuplicateGlobal.d.ts.map +1 -1
- package/dist/errors/DuplicateGlobal.js +2 -3
- package/dist/errors/DuplicateGlobal.js.map +1 -1
- package/dist/errors/ErrorDeletingFile.d.ts +2 -3
- package/dist/errors/ErrorDeletingFile.d.ts.map +1 -1
- package/dist/errors/ErrorDeletingFile.js +2 -3
- package/dist/errors/ErrorDeletingFile.js.map +1 -1
- package/dist/errors/FileRetrievalError.d.ts +6 -0
- package/dist/errors/FileRetrievalError.d.ts.map +1 -0
- package/dist/errors/FileRetrievalError.js +13 -0
- package/dist/errors/FileRetrievalError.js.map +1 -0
- package/dist/errors/FileUploadError.d.ts +2 -3
- package/dist/errors/FileUploadError.d.ts.map +1 -1
- package/dist/errors/FileUploadError.js +2 -3
- package/dist/errors/FileUploadError.js.map +1 -1
- package/dist/errors/Forbidden.d.ts +2 -3
- package/dist/errors/Forbidden.d.ts.map +1 -1
- package/dist/errors/Forbidden.js +2 -3
- package/dist/errors/Forbidden.js.map +1 -1
- package/dist/errors/InvalidConfiguration.d.ts +2 -3
- package/dist/errors/InvalidConfiguration.d.ts.map +1 -1
- package/dist/errors/InvalidConfiguration.js +2 -3
- package/dist/errors/InvalidConfiguration.js.map +1 -1
- package/dist/errors/InvalidFieldName.d.ts +2 -3
- package/dist/errors/InvalidFieldName.d.ts.map +1 -1
- package/dist/errors/InvalidFieldName.js +2 -3
- package/dist/errors/InvalidFieldName.js.map +1 -1
- package/dist/errors/InvalidFieldRelationship.d.ts +2 -3
- package/dist/errors/InvalidFieldRelationship.d.ts.map +1 -1
- package/dist/errors/InvalidFieldRelationship.js +2 -3
- package/dist/errors/InvalidFieldRelationship.js.map +1 -1
- package/dist/errors/InvalidSchema.d.ts +2 -3
- package/dist/errors/InvalidSchema.d.ts.map +1 -1
- package/dist/errors/InvalidSchema.js +2 -3
- package/dist/errors/InvalidSchema.js.map +1 -1
- package/dist/errors/LockedAuth.d.ts +2 -3
- package/dist/errors/LockedAuth.d.ts.map +1 -1
- package/dist/errors/LockedAuth.js +2 -3
- package/dist/errors/LockedAuth.js.map +1 -1
- package/dist/errors/MissingCollectionLabel.d.ts +2 -3
- package/dist/errors/MissingCollectionLabel.d.ts.map +1 -1
- package/dist/errors/MissingCollectionLabel.js +2 -3
- package/dist/errors/MissingCollectionLabel.js.map +1 -1
- package/dist/errors/MissingEditorProp.d.ts +2 -3
- package/dist/errors/MissingEditorProp.d.ts.map +1 -1
- package/dist/errors/MissingEditorProp.js +3 -4
- package/dist/errors/MissingEditorProp.js.map +1 -1
- package/dist/errors/MissingFieldInputOptions.d.ts +2 -3
- package/dist/errors/MissingFieldInputOptions.d.ts.map +1 -1
- package/dist/errors/MissingFieldInputOptions.js +2 -3
- package/dist/errors/MissingFieldInputOptions.js.map +1 -1
- package/dist/errors/MissingFieldType.d.ts +2 -3
- package/dist/errors/MissingFieldType.d.ts.map +1 -1
- package/dist/errors/MissingFieldType.js +2 -3
- package/dist/errors/MissingFieldType.js.map +1 -1
- package/dist/errors/MissingFile.d.ts +2 -3
- package/dist/errors/MissingFile.d.ts.map +1 -1
- package/dist/errors/MissingFile.js +2 -3
- package/dist/errors/MissingFile.js.map +1 -1
- package/dist/errors/NotFound.d.ts +2 -3
- package/dist/errors/NotFound.d.ts.map +1 -1
- package/dist/errors/NotFound.js +2 -3
- package/dist/errors/NotFound.js.map +1 -1
- package/dist/errors/QueryError.d.ts +2 -3
- package/dist/errors/QueryError.d.ts.map +1 -1
- package/dist/errors/QueryError.js +2 -3
- package/dist/errors/QueryError.js.map +1 -1
- package/dist/errors/ReservedFieldName.d.ts +6 -0
- package/dist/errors/ReservedFieldName.d.ts.map +1 -0
- package/dist/errors/ReservedFieldName.js +8 -0
- package/dist/errors/ReservedFieldName.js.map +1 -0
- package/dist/errors/TimestampsRequired.d.ts +2 -3
- package/dist/errors/TimestampsRequired.d.ts.map +1 -1
- package/dist/errors/TimestampsRequired.js +2 -3
- package/dist/errors/TimestampsRequired.js.map +1 -1
- package/dist/errors/UnathorizedError.d.ts +2 -3
- package/dist/errors/UnathorizedError.d.ts.map +1 -1
- package/dist/errors/UnathorizedError.js +2 -3
- package/dist/errors/UnathorizedError.js.map +1 -1
- package/dist/errors/ValidationError.d.ts +16 -8
- package/dist/errors/ValidationError.d.ts.map +1 -1
- package/dist/errors/ValidationError.js +8 -6
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/errors/index.d.ts +22 -19
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +22 -19
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/types.js.map +1 -1
- package/dist/exports/components/utilities.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.d.ts +2 -0
- package/dist/exports/i18n/he.d.ts.map +1 -0
- package/dist/exports/i18n/he.js +3 -0
- package/dist/exports/i18n/he.js.map +1 -0
- 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.d.ts +5 -0
- package/dist/exports/node.d.ts.map +1 -1
- package/dist/exports/node.js +5 -1
- package/dist/exports/node.js.map +1 -1
- package/dist/exports/shared.d.ts +23 -0
- package/dist/exports/shared.d.ts.map +1 -0
- package/dist/exports/shared.js +24 -0
- package/dist/exports/shared.js.map +1 -0
- 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 +939 -702
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +5 -1
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts +9 -2
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +57 -36
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js +130 -139
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/types.d.ts +239 -134
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/getDefaultValue.d.ts +5 -5
- package/dist/fields/getDefaultValue.d.ts.map +1 -1
- package/dist/fields/getDefaultValue.js +4 -6
- package/dist/fields/getDefaultValue.js.map +1 -1
- package/dist/fields/getFieldPaths.d.ts +10 -0
- package/dist/fields/getFieldPaths.d.ts.map +1 -0
- package/dist/fields/getFieldPaths.js +45 -0
- package/dist/fields/getFieldPaths.js.map +1 -0
- package/dist/fields/hooks/afterChange/index.d.ts +12 -6
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.js +4 -2
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts +16 -8
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js +67 -3
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +10 -8
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js +3 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +6 -5
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js +7 -4
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +16 -4
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +148 -37
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts +2 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +16 -10
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +10 -4
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js +4 -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.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.js.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts +2 -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 +7 -7
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js +10 -5
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +16 -9
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +83 -18
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +23 -10
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js +4 -3
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +5 -5
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js +4 -2
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts +12 -4
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +73 -6
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +12 -4
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js +3 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/fields/mergeBaseFields.d.ts.map +1 -1
- package/dist/fields/mergeBaseFields.js +2 -2
- 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 +26 -16
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +80 -9
- package/dist/fields/validations.js.map +1 -1
- package/dist/fields/validations.spec.js +16 -15
- package/dist/fields/validations.spec.js.map +1 -1
- package/dist/globals/config/client.d.ts +7 -7
- package/dist/globals/config/client.d.ts.map +1 -1
- package/dist/globals/config/client.js +2 -1
- package/dist/globals/config/client.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts +2 -3
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +48 -41
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/types.d.ts +12 -7
- 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 +1 -0
- 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 +4 -2
- 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 +1 -0
- 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 +1 -0
- 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 +5 -2
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +220 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +219 -22
- package/dist/index.js.map +1 -1
- package/dist/preferences/deleteUserPreferences.js.map +1 -1
- package/dist/preferences/operations/delete.js +2 -2
- 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 +1 -1
- package/dist/preferences/operations/update.js.map +1 -1
- package/dist/preferences/preferencesCollection.js.map +1 -1
- package/dist/preferences/requestHandlers/delete.d.ts.map +1 -1
- package/dist/preferences/requestHandlers/delete.js +18 -5
- package/dist/preferences/requestHandlers/delete.js.map +1 -1
- package/dist/preferences/requestHandlers/findOne.d.ts.map +1 -1
- package/dist/preferences/requestHandlers/findOne.js +18 -5
- package/dist/preferences/requestHandlers/findOne.js.map +1 -1
- package/dist/preferences/requestHandlers/update.d.ts.map +1 -1
- package/dist/preferences/requestHandlers/update.js +19 -7
- package/dist/preferences/requestHandlers/update.js.map +1 -1
- package/dist/preferences/types.d.ts +2 -2
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/translations/getLocalI18n.d.ts +1 -1
- package/dist/translations/getLocalI18n.d.ts.map +1 -1
- package/dist/translations/getLocalI18n.js +1 -1
- package/dist/translations/getLocalI18n.js.map +1 -1
- package/dist/types/constants.js.map +1 -1
- package/dist/types/index.d.ts +42 -33
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/canResizeImage.d.ts +1 -1
- package/dist/uploads/canResizeImage.d.ts.map +1 -1
- package/dist/uploads/canResizeImage.js +1 -1
- package/dist/uploads/canResizeImage.js.map +1 -1
- package/dist/uploads/cropImage.d.ts +22 -6
- package/dist/uploads/cropImage.d.ts.map +1 -1
- package/dist/uploads/cropImage.js +18 -5
- package/dist/uploads/cropImage.js.map +1 -1
- package/dist/uploads/deleteAssociatedFiles.d.ts.map +1 -1
- package/dist/uploads/deleteAssociatedFiles.js +0 -2
- 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 +3 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +97 -36
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getBaseFields.d.ts.map +1 -1
- package/dist/uploads/getBaseFields.js +23 -4
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/getExternalFile.d.ts +4 -3
- package/dist/uploads/getExternalFile.d.ts.map +1 -1
- package/dist/uploads/getExternalFile.js +10 -6
- package/dist/uploads/getExternalFile.js.map +1 -1
- package/dist/uploads/getFileByPath.d.ts +2 -2
- package/dist/uploads/getFileByPath.d.ts.map +1 -1
- package/dist/uploads/getFileByPath.js +2 -3
- package/dist/uploads/getFileByPath.js.map +1 -1
- package/dist/uploads/getImageSize.d.ts +1 -1
- package/dist/uploads/getImageSize.d.ts.map +1 -1
- package/dist/uploads/getImageSize.js +19 -5
- package/dist/uploads/getImageSize.js.map +1 -1
- package/dist/uploads/getSafeFilename.d.ts +2 -2
- package/dist/uploads/getSafeFilename.d.ts.map +1 -1
- package/dist/uploads/getSafeFilename.js +1 -3
- package/dist/uploads/getSafeFilename.js.map +1 -1
- package/dist/uploads/imageResizer.d.ts +11 -11
- package/dist/uploads/imageResizer.d.ts.map +1 -1
- package/dist/uploads/imageResizer.js +181 -120
- package/dist/uploads/imageResizer.js.map +1 -1
- package/dist/uploads/isImage.d.ts +1 -1
- package/dist/uploads/isImage.d.ts.map +1 -1
- package/dist/uploads/isImage.js +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/optionallyAppendMetadata.d.ts +12 -0
- package/dist/uploads/optionallyAppendMetadata.d.ts.map +1 -0
- package/dist/uploads/optionallyAppendMetadata.js +15 -0
- package/dist/uploads/optionallyAppendMetadata.js.map +1 -0
- 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.d.ts +7 -0
- package/dist/uploads/tempFile.d.ts.map +1 -0
- package/dist/uploads/tempFile.js +39 -0
- package/dist/uploads/tempFile.js.map +1 -0
- package/dist/uploads/types.d.ts +120 -12
- 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 +1 -1
- package/dist/utilities/checkDuplicateCollections.js.map +1 -1
- package/dist/utilities/commitTransaction.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts +1 -0
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +211 -5
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +165 -11
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/createArrayFromCommaDelineated.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +10 -6
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/deepCopyObject.d.ts +18 -1
- package/dist/utilities/deepCopyObject.d.ts.map +1 -1
- package/dist/utilities/deepCopyObject.js +147 -16
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/deepMerge.d.ts +18 -1
- package/dist/utilities/deepMerge.d.ts.map +1 -1
- package/dist/utilities/deepMerge.js +38 -13
- package/dist/utilities/deepMerge.js.map +1 -1
- package/dist/utilities/dependencies/getDependencies.d.ts +9 -0
- package/dist/utilities/dependencies/getDependencies.d.ts.map +1 -0
- package/dist/utilities/dependencies/getDependencies.js +71 -0
- package/dist/utilities/dependencies/getDependencies.js.map +1 -0
- package/dist/utilities/dependencies/isError.d.ts +5 -0
- package/dist/utilities/dependencies/isError.d.ts.map +1 -0
- package/dist/utilities/dependencies/isError.js +19 -0
- package/dist/utilities/dependencies/isError.js.map +1 -0
- package/dist/utilities/dependencies/realPath.d.ts +3 -0
- package/dist/utilities/dependencies/realPath.d.ts.map +1 -0
- package/dist/utilities/dependencies/realPath.js +23 -0
- package/dist/utilities/dependencies/realPath.js.map +1 -0
- package/dist/utilities/dependencies/resolveFrom.d.ts +2 -0
- package/dist/utilities/dependencies/resolveFrom.d.ts.map +1 -0
- package/dist/utilities/dependencies/resolveFrom.js +58 -0
- package/dist/utilities/dependencies/resolveFrom.js.map +1 -0
- 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/getCollectionIDFieldTypes.js.map +1 -1
- package/dist/utilities/getDataByPath.d.ts +3 -0
- package/dist/utilities/getDataByPath.d.ts.map +1 -0
- package/dist/utilities/getDataByPath.js +18 -0
- package/dist/utilities/getDataByPath.js.map +1 -0
- 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/getSiblingData.d.ts +3 -0
- package/dist/utilities/getSiblingData.d.ts.map +1 -0
- package/dist/utilities/getSiblingData.js +33 -0
- package/dist/utilities/getSiblingData.js.map +1 -0
- package/dist/utilities/getUniqueListBy.d.ts +1 -1
- package/dist/utilities/getUniqueListBy.d.ts.map +1 -1
- package/dist/utilities/getUniqueListBy.js +1 -1
- package/dist/utilities/getUniqueListBy.js.map +1 -1
- package/dist/utilities/importWithoutClientFiles.d.ts.map +1 -1
- package/dist/utilities/importWithoutClientFiles.js +10 -4
- package/dist/utilities/importWithoutClientFiles.js.map +1 -1
- package/dist/utilities/initTransaction.d.ts.map +1 -1
- package/dist/utilities/initTransaction.js +9 -9
- package/dist/utilities/initTransaction.js.map +1 -1
- package/dist/utilities/isEntityHidden.d.ts +3 -3
- package/dist/utilities/isEntityHidden.d.ts.map +1 -1
- package/dist/utilities/isEntityHidden.js.map +1 -1
- package/dist/utilities/isNumber.js.map +1 -1
- package/dist/utilities/isPlainObject.d.ts +1 -1
- package/dist/utilities/isPlainObject.d.ts.map +1 -1
- package/dist/utilities/isPlainObject.js +4 -18
- package/dist/utilities/isPlainObject.js.map +1 -1
- package/dist/utilities/isReactComponent.d.ts +2 -3
- package/dist/utilities/isReactComponent.d.ts.map +1 -1
- package/dist/utilities/isReactComponent.js +17 -11
- 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.d.ts +1 -1
- package/dist/utilities/isolateObjectProperty.d.ts.map +1 -1
- package/dist/utilities/isolateObjectProperty.js +14 -5
- package/dist/utilities/isolateObjectProperty.js.map +1 -1
- package/dist/utilities/killTransaction.js +1 -1
- package/dist/utilities/killTransaction.js.map +1 -1
- package/dist/utilities/logger.d.ts +5 -7
- package/dist/utilities/logger.d.ts.map +1 -1
- package/dist/utilities/logger.js +4 -7
- 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/parseCookies.d.ts +1 -1
- package/dist/utilities/parseCookies.d.ts.map +1 -1
- package/dist/utilities/parseCookies.js +1 -1
- package/dist/utilities/parseCookies.js.map +1 -1
- package/dist/utilities/reduceFieldsToValues.d.ts +10 -0
- package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -0
- package/dist/utilities/reduceFieldsToValues.js +22 -0
- package/dist/utilities/reduceFieldsToValues.js.map +1 -0
- 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/conf/envPaths.d.ts +23 -0
- package/dist/utilities/telemetry/conf/envPaths.d.ts.map +1 -0
- package/dist/utilities/telemetry/conf/envPaths.js +70 -0
- package/dist/utilities/telemetry/conf/envPaths.js.map +1 -0
- package/dist/utilities/telemetry/conf/index.d.ts +84 -0
- package/dist/utilities/telemetry/conf/index.d.ts.map +1 -0
- package/dist/utilities/telemetry/conf/index.js +144 -0
- package/dist/utilities/telemetry/conf/index.js.map +1 -0
- package/dist/utilities/telemetry/events/adminInit.d.ts.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 +9 -0
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.js +64 -17
- 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/unflatten.d.ts +9 -0
- package/dist/utilities/unflatten.d.ts.map +1 -0
- package/dist/utilities/unflatten.js +64 -0
- package/dist/utilities/unflatten.js.map +1 -0
- package/dist/utilities/wait.js.map +1 -1
- package/dist/utilities/wordBoundariesRegex.js.map +1 -1
- package/dist/versions/baseFields.d.ts.map +1 -1
- package/dist/versions/baseFields.js +1 -0
- 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.d.ts +4 -0
- package/dist/versions/defaults.d.ts.map +1 -0
- package/dist/versions/defaults.js +5 -0
- package/dist/versions/defaults.js.map +1 -0
- 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 +2 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
- package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
- package/dist/versions/enforceMaxVersions.js +3 -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 +0 -1
- package/dist/versions/getLatestGlobalVersion.js.map +1 -1
- package/dist/versions/saveVersion.d.ts.map +1 -1
- package/dist/versions/saveVersion.js +4 -3
- package/dist/versions/saveVersion.js.map +1 -1
- package/dist/versions/types.d.ts +2 -0
- package/dist/versions/types.d.ts.map +1 -1
- package/dist/versions/types.js.map +1 -1
- package/package.json +95 -121
- package/dist/collections/config/schema.d.ts +0 -4
- package/dist/collections/config/schema.d.ts.map +0 -1
- package/dist/collections/config/schema.js +0 -176
- package/dist/collections/config/schema.js.map +0 -1
- package/dist/config/schema.d.ts +0 -5
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/config/schema.js +0 -146
- package/dist/config/schema.js.map +0 -1
- package/dist/config/shared/adminViewSchema.d.ts +0 -3
- package/dist/config/shared/adminViewSchema.d.ts.map +0 -1
- package/dist/config/shared/adminViewSchema.js +0 -11
- package/dist/config/shared/adminViewSchema.js.map +0 -1
- package/dist/config/shared/componentSchema.d.ts +0 -16
- package/dist/config/shared/componentSchema.d.ts.map +0 -1
- package/dist/config/shared/componentSchema.js +0 -27
- package/dist/config/shared/componentSchema.js.map +0 -1
- package/dist/config/validate.d.ts +0 -4
- package/dist/config/validate.d.ts.map +0 -1
- package/dist/config/validate.js +0 -89
- package/dist/config/validate.js.map +0 -1
- package/dist/email/build.d.ts +0 -5
- package/dist/email/build.d.ts.map +0 -1
- package/dist/email/build.js +0 -63
- package/dist/email/build.js.map +0 -1
- package/dist/email/mockHandler.d.ts +0 -5
- package/dist/email/mockHandler.d.ts.map +0 -1
- package/dist/email/mockHandler.js +0 -24
- package/dist/email/mockHandler.js.map +0 -1
- package/dist/exports/auth.d.ts +0 -6
- package/dist/exports/auth.d.ts.map +0 -1
- package/dist/exports/auth.js +0 -6
- package/dist/exports/auth.js.map +0 -1
- package/dist/exports/config.d.ts +0 -14
- package/dist/exports/config.d.ts.map +0 -1
- package/dist/exports/config.js +0 -14
- package/dist/exports/config.js.map +0 -1
- package/dist/exports/database.d.ts +0 -23
- package/dist/exports/database.d.ts.map +0 -1
- package/dist/exports/database.js +0 -22
- package/dist/exports/database.js.map +0 -1
- package/dist/exports/errors.d.ts +0 -2
- package/dist/exports/errors.d.ts.map +0 -1
- package/dist/exports/errors.js +0 -3
- package/dist/exports/errors.js.map +0 -1
- package/dist/exports/fields/index.d.ts +0 -3
- package/dist/exports/fields/index.d.ts.map +0 -1
- package/dist/exports/fields/index.js +0 -4
- package/dist/exports/fields/index.js.map +0 -1
- package/dist/exports/fields/validations.d.ts +0 -2
- package/dist/exports/fields/validations.d.ts.map +0 -1
- package/dist/exports/fields/validations.js +0 -3
- package/dist/exports/fields/validations.js.map +0 -1
- package/dist/exports/operations.d.ts +0 -30
- package/dist/exports/operations.d.ts.map +0 -1
- package/dist/exports/operations.js +0 -31
- package/dist/exports/operations.js.map +0 -1
- package/dist/exports/types.d.ts +0 -17
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -5
- package/dist/exports/types.js.map +0 -1
- package/dist/exports/uploads.d.ts +0 -2
- package/dist/exports/uploads.d.ts.map +0 -1
- package/dist/exports/uploads.js +0 -3
- package/dist/exports/uploads.js.map +0 -1
- package/dist/exports/utilities.d.ts +0 -31
- package/dist/exports/utilities.d.ts.map +0 -1
- package/dist/exports/utilities.js +0 -32
- package/dist/exports/utilities.js.map +0 -1
- package/dist/exports/versions.d.ts +0 -9
- package/dist/exports/versions.d.ts.map +0 -1
- package/dist/exports/versions.js +0 -9
- package/dist/exports/versions.js.map +0 -1
- package/dist/fields/config/schema.d.ts +0 -29
- package/dist/fields/config/schema.d.ts.map +0 -1
- package/dist/fields/config/schema.js +0 -477
- package/dist/fields/config/schema.js.map +0 -1
- package/dist/globals/config/schema.d.ts +0 -4
- package/dist/globals/config/schema.d.ts.map +0 -1
- package/dist/globals/config/schema.js +0 -69
- package/dist/globals/config/schema.js.map +0 -1
- package/dist/utilities/combineMerge.d.ts +0 -2
- package/dist/utilities/combineMerge.d.ts.map +0 -1
- package/dist/utilities/combineMerge.js +0 -16
- package/dist/utilities/combineMerge.js.map +0 -1
- package/dist/utilities/convertData.d.ts +0 -5
- package/dist/utilities/convertData.d.ts.map +0 -1
- package/dist/utilities/convertData.js +0 -16
- package/dist/utilities/convertData.js.map +0 -1
- package/dist/utilities/getCSSVariable.d.ts +0 -3
- package/dist/utilities/getCSSVariable.d.ts.map +0 -1
- package/dist/utilities/getCSSVariable.js +0 -3
- package/dist/utilities/getCSSVariable.js.map +0 -1
- package/dist/utilities/overwriteMerge.d.ts +0 -3
- package/dist/utilities/overwriteMerge.d.ts.map +0 -1
- package/dist/utilities/overwriteMerge.js +0 -4
- package/dist/utilities/overwriteMerge.js.map +0 -1
- package/src/index.ts +0 -499
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport getValueWithDefault from '../../getDefaultValue.js'\nimport { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js'\nimport { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc: T\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n if (fieldAffectsData(field)) {\n if (field.name === 'id') {\n if (field.type === 'number' && typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n\n siblingData[field.name] = parseFloat(value)\n }\n\n if (\n field.type === 'text' &&\n typeof siblingData[field.name]?.toString === 'function' &&\n typeof siblingData[field.name] !== 'string'\n ) {\n siblingData[field.name] = siblingData[field.name].toString()\n }\n }\n\n // Sanitize incoming data\n switch (field.type) {\n case 'number': {\n if (typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n const trimmed = value.trim()\n siblingData[field.name] = trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n\n break\n }\n\n case 'point': {\n if (Array.isArray(siblingData[field.name])) {\n siblingData[field.name] = (siblingData[field.name] as string[]).map((coordinate, i) => {\n if (typeof coordinate === 'string') {\n const value = siblingData[field.name][i] as string\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n return coordinate\n })\n }\n\n break\n }\n\n case 'checkbox': {\n if (siblingData[field.name] === 'true') siblingData[field.name] = true\n if (siblingData[field.name] === 'false') siblingData[field.name] = false\n if (siblingData[field.name] === '') siblingData[field.name] = false\n\n break\n }\n\n case 'richText': {\n if (typeof siblingData[field.name] === 'string') {\n try {\n const richTextJSON = JSON.parse(siblingData[field.name] as string)\n siblingData[field.name] = richTextJSON\n } catch {\n // Disregard this data as it is not valid.\n // Will be reported to user by field validation\n }\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n siblingData[field.name] === '' ||\n siblingData[field.name] === 'none' ||\n siblingData[field.name] === 'null' ||\n siblingData[field.name] === null\n ) {\n if (field.type === 'relationship' && field.hasMany === true) {\n siblingData[field.name] = []\n } else {\n siblingData[field.name] = null\n }\n }\n\n const value = siblingData[field.name]\n\n if (Array.isArray(field.relationTo)) {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: { relationTo: string; value: unknown }, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === relatedDoc.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = {\n ...relatedDoc,\n value: parseFloat(relatedDoc.value as string),\n }\n }\n })\n }\n if (\n field.type === 'relationship' &&\n field.hasMany !== true &&\n valueIsValueWithRelation(value)\n ) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === value.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = { ...value, value: parseFloat(value.value as string) }\n }\n }\n } else {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: unknown, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = parseFloat(relatedDoc as string)\n }\n })\n }\n if (field.type === 'relationship' && field.hasMany !== true && value) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = parseFloat(value as string)\n }\n }\n }\n break\n }\n\n case 'array':\n case 'blocks': {\n // Handle cases of arrays being intentionally set to 0\n if (siblingData[field.name] === '0' || siblingData[field.name] === 0) {\n siblingData[field.name] = []\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeValidate) {\n await field.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n req,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n if (field.access && field.access[operation]) {\n const result = overrideAccess\n ? true\n : await field.access[operation]({ id, data, doc, req, siblingData })\n\n if (!result) {\n delete siblingData[field.name]\n }\n }\n\n if (typeof siblingData[field.name] === 'undefined') {\n // If no incoming data, but existing document data is found, merge it in\n if (typeof siblingDoc[field.name] !== 'undefined') {\n siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name])\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getValueWithDefault({\n defaultValue: field.defaultValue,\n locale: req.locale,\n user: req.user,\n value: siblingData[field.name],\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: groupData,\n siblingDoc: groupDoc,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: getExistingRowDoc(row, siblingDoc[field.name]),\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row) => {\n const rowSiblingDoc = getExistingRowDoc(row, siblingDoc[field.name])\n const blockTypeToMatch = row.blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n row.blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: rowSiblingDoc,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n let tabSiblingDoc\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n tabSiblingDoc = siblingDoc\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["fieldAffectsData","tabHasName","valueIsValueWithRelation","getValueWithDefault","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","global","operation","overrideAccess","req","siblingData","siblingDoc","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","richTextJSON","JSON","parse","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","relationshipIDField","fields","collectionField","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","undefined","Promise","resolve","access","result","defaultValue","locale","user","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAMpC,SAASA,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,OAAOC,yBAAyB,2BAA0B;AAC1D,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SA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M;oBACpBjC;oBACAC;oBACAC;oBACAC;oBACAC,aAAa0D;oBACbzD,YAAY0D;gBACd;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX,MAAMvE,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMiE,IAAI,CAAChD,GAAG,CAAC,CAACiD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE1D,MAAM;wBAAM,CAAA;oBACvDP;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, JsonValue, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport { getDefaultValue } from '../../getDefaultValue.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js'\nimport { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n /**\n * The original data (not modified by any hooks)\n */\n doc: T\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n parentPath: (number | string)[]\n parentSchemaPath: string[]\n req: PayloadRequest\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n if (field.name === 'id') {\n if (field.type === 'number' && typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n\n siblingData[field.name] = parseFloat(value)\n }\n\n if (\n field.type === 'text' &&\n typeof siblingData[field.name]?.toString === 'function' &&\n typeof siblingData[field.name] !== 'string'\n ) {\n siblingData[field.name] = siblingData[field.name].toString()\n }\n }\n\n // Sanitize incoming data\n switch (field.type) {\n case 'number': {\n if (typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n const trimmed = value.trim()\n siblingData[field.name] = trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n\n break\n }\n\n case 'point': {\n if (Array.isArray(siblingData[field.name])) {\n siblingData[field.name] = (siblingData[field.name] as string[]).map((coordinate, i) => {\n if (typeof coordinate === 'string') {\n const value = siblingData[field.name][i] as string\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n return coordinate\n })\n }\n\n break\n }\n\n case 'checkbox': {\n if (siblingData[field.name] === 'true') siblingData[field.name] = true\n if (siblingData[field.name] === 'false') siblingData[field.name] = false\n if (siblingData[field.name] === '') siblingData[field.name] = false\n\n break\n }\n\n case 'richText': {\n if (typeof siblingData[field.name] === 'string') {\n try {\n const richTextJSON = JSON.parse(siblingData[field.name] as string)\n siblingData[field.name] = richTextJSON\n } catch {\n // Disregard this data as it is not valid.\n // Will be reported to user by field validation\n }\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n siblingData[field.name] === '' ||\n siblingData[field.name] === 'none' ||\n siblingData[field.name] === 'null' ||\n siblingData[field.name] === null\n ) {\n if (field.type === 'relationship' && field.hasMany === true) {\n siblingData[field.name] = []\n } else {\n siblingData[field.name] = null\n }\n }\n\n const value = siblingData[field.name]\n\n if (Array.isArray(field.relationTo)) {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: { relationTo: string; value: JsonValue }, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === relatedDoc.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = {\n ...relatedDoc,\n value: parseFloat(relatedDoc.value as string),\n }\n }\n })\n }\n if (\n field.type === 'relationship' &&\n field.hasMany !== true &&\n valueIsValueWithRelation(value)\n ) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === value.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = { ...value, value: parseFloat(value.value as string) }\n }\n }\n } else {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: unknown, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = parseFloat(relatedDoc as string)\n }\n })\n }\n if (field.type === 'relationship' && field.hasMany !== true && value) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = parseFloat(value as string)\n }\n }\n }\n break\n }\n\n case 'array':\n case 'blocks': {\n // Handle cases of arrays being intentionally set to 0\n if (siblingData[field.name] === '0' || siblingData[field.name] === 0) {\n siblingData[field.name] = []\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeValidate) {\n await field.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingData[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n if (field.access && field.access[operation]) {\n const result = overrideAccess\n ? true\n : await field.access[operation]({ id, data, doc, req, siblingData })\n\n if (!result) {\n delete siblingData[field.name]\n }\n }\n\n if (typeof siblingData[field.name] === 'undefined') {\n // If no incoming data, but existing document data is found, merge it in\n if (typeof siblingDoc[field.name] !== 'undefined') {\n siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name] as any)\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale: req.locale,\n user: req.user,\n value: siblingData[field.name],\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: groupData as JsonObject,\n siblingDoc: groupDoc as JsonObject,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: getExistingRowDoc(row as JsonObject, siblingDoc[field.name]),\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const rowSiblingDoc = getExistingRowDoc(row as JsonObject, siblingDoc[field.name])\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n ;(row as JsonObject).blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: rowSiblingDoc,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n let tabSiblingDoc\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n tabSiblingDoc = siblingDoc\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.beforeValidate?.length) {\n await editor.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingData[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","valueIsValueWithRelation","getDefaultValue","getFieldPaths","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","global","operation","overrideAccess","parentPath","parentSchemaPath","req","siblingData","siblingDoc","path","fieldPath","schemaPath","fieldSchemaPath","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","richTextJSON","JSON","parse","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","relationshipIDField","fields","collectionField","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","previousValue","undefined","Promise","resolve","access","result","defaultValue","locale","user","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab","editor","Error"],"mappings":"AAMA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAyBpD,oEAAoE;AACpE,2BAA2B;AAC3B,wBAAwB;AACxB,iCAAiC;AACjC,oDAAoD;AACpD,gDAAgD;AAEhD,OAAO,MAAMC,UAAU,OAAU,EAC/BC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAChBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAM,EAAEC,MAAMC,SAAS,EAAEC,YAAYC,eAAe,EAAE,GAAGtB,cAAc;QACrEU;QACAI;QACAC;IACF;IAEA,IAAInB,iBAAiBc,QAAQ;QAC3B,IAAIA,MAAMa,IAAI,KAAK,MAAM;YACvB,IAAIb,MAAMc,IAAI,KAAK,YAAY,OAAOP,WAAW,CAACP,MAAMa,IAAI,CAAC,KAAK,UAAU;gBAC1E,MAAME,QAAQR,WAAW,CAACP,MAAMa,IAAI,CAAC;gBAErCN,WAAW,CAACP,MAAMa,IAAI,CAAC,GAAGG,WAAWD;YACvC;YAEA,IACEf,MAAMc,IAAI,KAAK,UACf,OAAOP,WAAW,CAACP,MAAMa,IAAI,CAAC,EAAEI,aAAa,cAC7C,OAAOV,WAAW,CAACP,MAAMa,IA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,KAAK;YAAY;gBACf,IAAI,CAACR,OAAO2E,QAAQ;oBAClB,MAAM,IAAI1F,kBAAkBe,OAAO,8HAA8H;;gBACnK;gBACA,IAAI,OAAOA,OAAO2E,WAAW,YAAY;oBACvC,MAAM,IAAIC,MAAM;gBAClB;gBAEA,MAAMD,SAA0B3E,OAAO2E;gBAEvC,IAAIA,QAAQjC,OAAOC,gBAAgBvB,QAAQ;oBACzC,MAAMuD,OAAOjC,KAAK,CAACC,cAAc,CAACC,MAAM,CAAC,OAAOC,WAAWC;wBACzD,MAAMD;wBAEN,MAAME,cAAc,MAAMD,YAAY;4BACpClD;4BACAC;4BACAC;4BACAE;4BACAC;4BACAC;4BACA8C,aAAajD;4BACbI;4BACAM,MAAMC;4BACNuC,oBAAoBzC;4BACpB0C,eAAe3C,WAAW,CAACP,MAAMa,IAAI,CAAC;4BACtCP;4BACAK,YAAYC;4BACZL;4BACAQ,OAAOR,WAAW,CAACP,MAAMa,IAAI,CAAC;wBAChC;wBAEA,IAAIkC,gBAAgBI,WAAW;4BAC7B5C,WAAW,CAACP,MAAMa,IAAI,CAAC,GAAGkC;wBAC5B;oBACF,GAAGK,QAAQC,OAAO;gBACpB;gBACA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
|
|
2
2
|
import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
|
|
3
|
-
import type { PayloadRequest, RequestContext } from '../../../types/index.js';
|
|
3
|
+
import type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js';
|
|
4
4
|
import type { Field, TabAsField } from '../../config/types.js';
|
|
5
5
|
type Args<T> = {
|
|
6
6
|
collection: SanitizedCollectionConfig | null;
|
|
7
7
|
context: RequestContext;
|
|
8
8
|
data: T;
|
|
9
|
+
/**
|
|
10
|
+
* The original data (not modified by any hooks)
|
|
11
|
+
*/
|
|
9
12
|
doc: T;
|
|
10
13
|
fields: (Field | TabAsField)[];
|
|
11
14
|
global: SanitizedGlobalConfig | null;
|
|
12
15
|
id?: number | string;
|
|
13
16
|
operation: 'create' | 'update';
|
|
14
17
|
overrideAccess: boolean;
|
|
18
|
+
path: (number | string)[];
|
|
15
19
|
req: PayloadRequest;
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
schemaPath: string[];
|
|
21
|
+
siblingData: JsonObject;
|
|
22
|
+
/**
|
|
23
|
+
* The original siblingData (not modified by any hooks)
|
|
24
|
+
*/
|
|
25
|
+
siblingDoc: JsonObject;
|
|
18
26
|
};
|
|
19
|
-
export declare const traverseFields: <T>({ id, collection, context, data, doc, fields, global, operation, overrideAccess, req, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
|
|
27
|
+
export declare const traverseFields: <T>({ id, collection, context, data, doc, fields, global, operation, overrideAccess, path, req, schemaPath, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
|
|
20
28
|
export {};
|
|
21
29
|
//# sourceMappingURL=traverseFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACzF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP;;OAEG;IACH,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,WAAW,EAAE,UAAU,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,CAAC,sIAenC,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CAuBxB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promise } from './promise.js';
|
|
2
|
-
export const traverseFields = async ({ id, collection, context, data, doc, fields, global, operation, overrideAccess, req, siblingData, siblingDoc })=>{
|
|
2
|
+
export const traverseFields = async ({ id, collection, context, data, doc, fields, global, operation, overrideAccess, path, req, schemaPath, siblingData, siblingDoc })=>{
|
|
3
3
|
const promises = [];
|
|
4
4
|
fields.forEach((field)=>{
|
|
5
5
|
promises.push(promise({
|
|
@@ -12,6 +12,8 @@ export const traverseFields = async ({ id, collection, context, data, doc, field
|
|
|
12
12
|
global,
|
|
13
13
|
operation,
|
|
14
14
|
overrideAccess,
|
|
15
|
+
parentPath: path,
|
|
16
|
+
parentSchemaPath: schemaPath,
|
|
15
17
|
req,
|
|
16
18
|
siblingData,
|
|
17
19
|
siblingDoc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc: T\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n /**\n * The original data (not modified by any hooks)\n */\n doc: T\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n path: (number | string)[]\n req: PayloadRequest\n schemaPath: string[]\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\n}\n\nexport const traverseFields = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n overrideAccess,\n path,\n req,\n schemaPath,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const promises = []\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n parentPath: path,\n parentSchemaPath: schemaPath,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","data","doc","fields","global","operation","overrideAccess","path","req","schemaPath","siblingData","siblingDoc","promises","forEach","field","push","parentPath","parentSchemaPath","Promise","all"],"mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAyBtC,OAAO,MAAMC,iBAAiB,OAAU,EACtCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,IAAI,EACJC,GAAG,EACHC,UAAU,EACVC,WAAW,EACXC,UAAU,EACF;IACR,MAAMC,WAAW,EAAE;IACnBT,OAAOU,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXnB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAY;YACAV;YACAC;YACAC;YACAU,YAAYT;YACZU,kBAAkBR;YAClBD;YACAE;YACAC;QACF;IAEJ;IACA,MAAMO,QAAQC,GAAG,CAACP;AACpB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeBaseFields.d.ts","sourceRoot":"","sources":["../../src/fields/mergeBaseFields.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mergeBaseFields.d.ts","sourceRoot":"","sources":["../../src/fields/mergeBaseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,mBAAmB,CAAA;AAKlE,QAAA,MAAM,eAAe,WAAY,KAAK,EAAE,cAAc,KAAK,EAAE,KAAG,KAAK,EAqCpE,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { deepMergeWithReactComponents } from '../utilities/deepMerge.js';
|
|
2
2
|
import { fieldAffectsData, fieldHasSubFields } from './config/types.js';
|
|
3
3
|
const mergeBaseFields = (fields, baseFields)=>{
|
|
4
4
|
const mergedFields = [
|
|
@@ -19,7 +19,7 @@ const mergeBaseFields = (fields, baseFields)=>{
|
|
|
19
19
|
...match
|
|
20
20
|
};
|
|
21
21
|
mergedFields.splice(matchedIndex, 1);
|
|
22
|
-
const mergedField =
|
|
22
|
+
const mergedField = deepMergeWithReactComponents(baseField, matchCopy);
|
|
23
23
|
if (fieldHasSubFields(baseField) && fieldHasSubFields(matchCopy)) {
|
|
24
24
|
mergedField.fields = mergeBaseFields(matchCopy.fields, baseField.fields);
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/mergeBaseFields.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/fields/mergeBaseFields.ts"],"sourcesContent":["import type { Field, FieldWithSubFields } from './config/types.js'\n\nimport { deepMergeWithReactComponents } from '../utilities/deepMerge.js'\nimport { fieldAffectsData, fieldHasSubFields } from './config/types.js'\n\nconst mergeBaseFields = (fields: Field[], baseFields: Field[]): Field[] => {\n const mergedFields = [...(fields || [])]\n\n baseFields.forEach((baseField) => {\n let matchedIndex = null\n\n if (fieldAffectsData(baseField)) {\n const match = mergedFields.find((field, i) => {\n if (fieldAffectsData(field) && field.name === baseField.name) {\n matchedIndex = i\n return true\n }\n\n return false\n })\n\n if (match) {\n const matchCopy: Field = { ...match }\n mergedFields.splice(matchedIndex, 1)\n\n const mergedField = deepMergeWithReactComponents<Field>(baseField, matchCopy)\n\n if (fieldHasSubFields(baseField) && fieldHasSubFields(matchCopy)) {\n ;(mergedField as FieldWithSubFields).fields = mergeBaseFields(\n matchCopy.fields,\n baseField.fields,\n )\n }\n\n mergedFields.push(mergedField)\n } else {\n mergedFields.push(baseField)\n }\n }\n })\n\n return mergedFields\n}\n\nexport default mergeBaseFields\n"],"names":["deepMergeWithReactComponents","fieldAffectsData","fieldHasSubFields","mergeBaseFields","fields","baseFields","mergedFields","forEach","baseField","matchedIndex","match","find","field","i","name","matchCopy","splice","mergedField","push"],"mappings":"AAEA,SAASA,4BAA4B,QAAQ,4BAA2B;AACxE,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,oBAAmB;AAEvE,MAAMC,kBAAkB,CAACC,QAAiBC;IACxC,MAAMC,eAAe;WAAKF,UAAU,EAAE;KAAE;IAExCC,WAAWE,OAAO,CAAC,CAACC;QAClB,IAAIC,eAAe;QAEnB,IAAIR,iBAAiBO,YAAY;YAC/B,MAAME,QAAQJ,aAAaK,IAAI,CAAC,CAACC,OAAOC;gBACtC,IAAIZ,iBAAiBW,UAAUA,MAAME,IAAI,KAAKN,UAAUM,IAAI,EAAE;oBAC5DL,eAAeI;oBACf,OAAO;gBACT;gBAEA,OAAO;YACT;YAEA,IAAIH,OAAO;gBACT,MAAMK,YAAmB;oBAAE,GAAGL,KAAK;gBAAC;gBACpCJ,aAAaU,MAAM,CAACP,cAAc;gBAElC,MAAMQ,cAAcjB,6BAAoCQ,WAAWO;gBAEnE,IAAIb,kBAAkBM,cAAcN,kBAAkBa,YAAY;oBAC9DE,YAAmCb,MAAM,GAAGD,gBAC5CY,UAAUX,MAAM,EAChBI,UAAUJ,MAAM;gBAEpB;gBAEAE,aAAaY,IAAI,CAACD;YACpB,OAAO;gBACLX,aAAaY,IAAI,CAACV;YACpB;QACF;IACF;IAEA,OAAOF;AACT;AAEA,eAAeH,gBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/setDefaultBeforeDuplicate.ts"],"sourcesContent":["// default beforeDuplicate hook for required and unique fields\nimport type { FieldAffectingData, FieldHook } from './config/types.js'\n\nconst unique: FieldHook = ({ value }) => (typeof value === 'string' ? `${value} - Copy` : undefined)\nconst localizedUnique: FieldHook = ({ req, value }) =>\n value ? `${value} - ${req?.t('general:copy') ?? 'Copy'}` : undefined\nconst uniqueRequired: FieldHook = ({ value }) => `${value} - Copy`\nconst localizedUniqueRequired: FieldHook = ({ req, value }) =>\n `${value} - ${req?.t('general:copy') ?? 'Copy'}`\n\nexport const setDefaultBeforeDuplicate = (field: FieldAffectingData) => {\n if (\n (('required' in field && field.required) || field.unique) &&\n (!field.hooks?.beforeDuplicate ||\n (Array.isArray(field.hooks.beforeDuplicate) && field.hooks.beforeDuplicate.length === 0))\n ) {\n if ((field.type === 'text' || field.type === 'textarea') && field.required && field.unique) {\n field.hooks.beforeDuplicate = [field.localized ? localizedUniqueRequired : uniqueRequired]\n } else if (field.unique) {\n field.hooks.beforeDuplicate = [field.localized ? localizedUnique : unique]\n }\n }\n}\n"],"names":["unique","value","undefined","localizedUnique","req","t","uniqueRequired","localizedUniqueRequired","setDefaultBeforeDuplicate","field","required","hooks","beforeDuplicate","Array","isArray","length","type","localized"],"
|
|
1
|
+
{"version":3,"sources":["../../src/fields/setDefaultBeforeDuplicate.ts"],"sourcesContent":["// default beforeDuplicate hook for required and unique fields\nimport type { FieldAffectingData, FieldHook } from './config/types.js'\n\nconst unique: FieldHook = ({ value }) => (typeof value === 'string' ? `${value} - Copy` : undefined)\nconst localizedUnique: FieldHook = ({ req, value }) =>\n value ? `${value} - ${req?.t('general:copy') ?? 'Copy'}` : undefined\nconst uniqueRequired: FieldHook = ({ value }) => `${value} - Copy`\nconst localizedUniqueRequired: FieldHook = ({ req, value }) =>\n `${value} - ${req?.t('general:copy') ?? 'Copy'}`\n\nexport const setDefaultBeforeDuplicate = (field: FieldAffectingData) => {\n if (\n (('required' in field && field.required) || field.unique) &&\n (!field.hooks?.beforeDuplicate ||\n (Array.isArray(field.hooks.beforeDuplicate) && field.hooks.beforeDuplicate.length === 0))\n ) {\n if ((field.type === 'text' || field.type === 'textarea') && field.required && field.unique) {\n field.hooks.beforeDuplicate = [field.localized ? localizedUniqueRequired : uniqueRequired]\n } else if (field.unique) {\n field.hooks.beforeDuplicate = [field.localized ? localizedUnique : unique]\n }\n }\n}\n"],"names":["unique","value","undefined","localizedUnique","req","t","uniqueRequired","localizedUniqueRequired","setDefaultBeforeDuplicate","field","required","hooks","beforeDuplicate","Array","isArray","length","type","localized"],"mappings":"AAAA,8DAA8D;AAG9D,MAAMA,SAAoB,CAAC,EAAEC,KAAK,EAAE,GAAM,OAAOA,UAAU,WAAW,CAAC,EAAEA,MAAM,OAAO,CAAC,GAAGC;AAC1F,MAAMC,kBAA6B,CAAC,EAAEC,GAAG,EAAEH,KAAK,EAAE,GAChDA,QAAQ,CAAC,EAAEA,MAAM,GAAG,EAAEG,KAAKC,EAAE,mBAAmB,OAAO,CAAC,GAAGH;AAC7D,MAAMI,iBAA4B,CAAC,EAAEL,KAAK,EAAE,GAAK,CAAC,EAAEA,MAAM,OAAO,CAAC;AAClE,MAAMM,0BAAqC,CAAC,EAAEH,GAAG,EAAEH,KAAK,EAAE,GACxD,CAAC,EAAEA,MAAM,GAAG,EAAEG,KAAKC,EAAE,mBAAmB,OAAO,CAAC;AAElD,OAAO,MAAMG,4BAA4B,CAACC;IACxC,IACE,AAAC,CAAA,AAAC,cAAcA,SAASA,MAAMC,QAAQ,IAAKD,MAAMT,MAAM,AAAD,KACtD,CAAA,CAACS,MAAME,KAAK,EAAEC,mBACZC,MAAMC,OAAO,CAACL,MAAME,KAAK,CAACC,eAAe,KAAKH,MAAME,KAAK,CAACC,eAAe,CAACG,MAAM,KAAK,CAAC,GACzF;QACA,IAAI,AAACN,CAAAA,MAAMO,IAAI,KAAK,UAAUP,MAAMO,IAAI,KAAK,UAAS,KAAMP,MAAMC,QAAQ,IAAID,MAAMT,MAAM,EAAE;YAC1FS,MAAME,KAAK,CAACC,eAAe,GAAG;gBAACH,MAAMQ,SAAS,GAAGV,0BAA0BD;aAAe;QAC5F,OAAO,IAAIG,MAAMT,MAAM,EAAE;YACvBS,MAAME,KAAK,CAACC,eAAe,GAAG;gBAACH,MAAMQ,SAAS,GAAGd,kBAAkBH;aAAO;QAC5E;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/sortableFieldTypes.ts"],"sourcesContent":["export default ['text', 'textarea', 'code', 'json', 'number', 'email', 'radio', 'select', 'date']\n"],"names":[],"
|
|
1
|
+
{"version":3,"sources":["../../src/fields/sortableFieldTypes.ts"],"sourcesContent":["export default ['text', 'textarea', 'code', 'json', 'number', 'email', 'radio', 'select', 'date']\n"],"names":[],"mappings":"AAAA,eAAe;IAAC;IAAQ;IAAY;IAAQ;IAAQ;IAAU;IAAS;IAAS;IAAU;CAAO,CAAA"}
|
|
@@ -2,11 +2,12 @@ import type { ArrayField, BlockField, CheckboxField, CodeField, DateField, Email
|
|
|
2
2
|
export declare const text: Validate<string | string[], unknown, unknown, TextField>;
|
|
3
3
|
export declare const password: Validate<string, unknown, unknown, TextField>;
|
|
4
4
|
export declare const email: Validate<string, unknown, unknown, EmailField>;
|
|
5
|
+
export declare const username: Validate<string, unknown, unknown, TextField>;
|
|
5
6
|
export declare const textarea: Validate<string, unknown, unknown, TextareaField>;
|
|
6
7
|
export declare const code: Validate<string, unknown, unknown, CodeField>;
|
|
7
|
-
export declare const json: Validate<string, unknown, unknown,
|
|
8
|
+
export declare const json: Validate<string, unknown, unknown, {
|
|
8
9
|
jsonError?: string;
|
|
9
|
-
}>;
|
|
10
|
+
} & JSONField>;
|
|
10
11
|
export declare const checkbox: Validate<boolean, unknown, unknown, CheckboxField>;
|
|
11
12
|
export declare const date: Validate<Date, unknown, unknown, DateField>;
|
|
12
13
|
export declare const richText: Validate<object, unknown, unknown, RichTextField>;
|
|
@@ -25,34 +26,43 @@ declare const _default: {
|
|
|
25
26
|
code: Validate<string, unknown, unknown, CodeField>;
|
|
26
27
|
date: Validate<Date, unknown, unknown, DateField>;
|
|
27
28
|
email: Validate<string, unknown, unknown, EmailField>;
|
|
28
|
-
json: Validate<string, unknown, unknown,
|
|
29
|
+
json: Validate<string, unknown, unknown, {
|
|
30
|
+
jsonError?: string;
|
|
31
|
+
} & {
|
|
29
32
|
admin?: {
|
|
33
|
+
components?: {
|
|
34
|
+
Error?: import("../index.js").CustomComponent<import("../index.js").ErrorProps>;
|
|
35
|
+
Label?: import("../index.js").CustomComponent<import("../index.js").LabelProps>;
|
|
36
|
+
};
|
|
37
|
+
editorOptions?: import("@monaco-editor/react").EditorProps["options"];
|
|
38
|
+
} & {
|
|
30
39
|
className?: string;
|
|
31
40
|
components?: {
|
|
32
|
-
Cell?: import("../
|
|
33
|
-
|
|
41
|
+
Cell?: import("../index.js").CustomComponent;
|
|
42
|
+
Description?: import("../index.js").DescriptionComponent;
|
|
43
|
+
Field?: import("../index.js").CustomComponent;
|
|
34
44
|
Filter?: import("react").ComponentType<any>;
|
|
35
45
|
};
|
|
36
|
-
condition?: import("./config/types.js").Condition
|
|
37
|
-
|
|
46
|
+
condition?: import("./config/types.js").Condition;
|
|
47
|
+
custom?: Record<string, any>;
|
|
48
|
+
description?: import("../index.js").Description;
|
|
38
49
|
disableBulkEdit?: boolean;
|
|
50
|
+
disableListColumn?: boolean;
|
|
51
|
+
disableListFilter?: boolean;
|
|
39
52
|
disabled?: boolean;
|
|
40
53
|
hidden?: boolean;
|
|
41
54
|
position?: "sidebar";
|
|
42
55
|
readOnly?: boolean;
|
|
43
56
|
style?: import("react").CSSProperties;
|
|
44
57
|
width?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
editorOptions?: import("monaco-editor").editor.IStandaloneEditorConstructionOptions;
|
|
58
|
+
};
|
|
59
|
+
jsonSchema?: {
|
|
60
|
+
fileMatch: string[];
|
|
61
|
+
schema: import("json-schema").JSONSchema4;
|
|
62
|
+
uri: string;
|
|
51
63
|
};
|
|
52
64
|
type: "json";
|
|
53
|
-
} &
|
|
54
|
-
jsonError?: string;
|
|
55
|
-
}>;
|
|
65
|
+
} & Omit<import("./config/types.js").FieldBase, "admin">>;
|
|
56
66
|
number: Validate<number | number[], unknown, unknown, NumberField>;
|
|
57
67
|
password: Validate<string, unknown, unknown, TextField>;
|
|
58
68
|
point: Validate<[string | number, string | number], unknown, unknown, PointField>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/fields/validations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/fields/validations.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAK1B,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAkDzE,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CA8BlE,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAShE,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAuBlE,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CA6BtE,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAS9D,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,S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;;;;;;oBA1bhB,CAAC;2BAAiC,CAAC;qBAC3D,CAAC;sBAMwC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgarD,wBAkBC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import ObjectIdImport from 'bson-objectid';
|
|
3
|
+
const ObjectId = ObjectIdImport.default || ObjectIdImport;
|
|
1
4
|
import { isNumber } from '../utilities/isNumber.js';
|
|
2
5
|
import { isValidID } from '../utilities/isValidID.js';
|
|
3
6
|
export const text = (value, { hasMany, maxLength: fieldMaxLength, maxRows, minLength, minRows, req: { payload: { config }, t }, required })=>{
|
|
@@ -23,14 +26,14 @@ export const text = (value, { hasMany, maxLength: fieldMaxLength, maxRows, minLe
|
|
|
23
26
|
const length = stringValue?.length || 0;
|
|
24
27
|
if (typeof maxLength === 'number' && length > maxLength) {
|
|
25
28
|
return t('validation:shorterThanMax', {
|
|
26
|
-
label: t('value'),
|
|
29
|
+
label: t('general:value'),
|
|
27
30
|
maxLength,
|
|
28
31
|
stringValue
|
|
29
32
|
});
|
|
30
33
|
}
|
|
31
34
|
if (typeof minLength === 'number' && length < minLength) {
|
|
32
35
|
return t('validation:longerThanMin', {
|
|
33
|
-
label: t('value'),
|
|
36
|
+
label: t('general:value'),
|
|
34
37
|
minLength,
|
|
35
38
|
stringValue
|
|
36
39
|
});
|
|
@@ -68,6 +71,19 @@ export const email = (value, { req: { t }, required })=>{
|
|
|
68
71
|
}
|
|
69
72
|
return true;
|
|
70
73
|
};
|
|
74
|
+
export const username = (value, { req: { payload: { config }, t }, required })=>{
|
|
75
|
+
let maxLength;
|
|
76
|
+
if (typeof config?.defaultMaxTextLength === 'number') maxLength = config.defaultMaxTextLength;
|
|
77
|
+
if (value && maxLength && value.length > maxLength) {
|
|
78
|
+
return t('validation:shorterThanMax', {
|
|
79
|
+
maxLength
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (value && !/^[\w.-]+$/.test(value) || !value && required) {
|
|
83
|
+
return t('validation:username');
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
71
87
|
export const textarea = (value, { maxLength: fieldMaxLength, minLength, req: { payload: { config }, t }, required })=>{
|
|
72
88
|
let maxLength;
|
|
73
89
|
if (typeof config?.defaultMaxTextLength === 'number') maxLength = config.defaultMaxTextLength;
|
|
@@ -93,13 +109,55 @@ export const code = (value, { req: { t }, required })=>{
|
|
|
93
109
|
}
|
|
94
110
|
return true;
|
|
95
111
|
};
|
|
96
|
-
export const json = (value, { jsonError, req: { t }, required })=>{
|
|
112
|
+
export const json = async (value, { jsonError, jsonSchema, req: { t }, required })=>{
|
|
113
|
+
const isNotEmpty = (value)=>{
|
|
114
|
+
if (value === undefined || value === null) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
if (typeof value === 'object' && Object.keys(value).length === 0) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
};
|
|
125
|
+
const fetchSchema = ({ schema, uri })=>{
|
|
126
|
+
if (uri && schema) return schema;
|
|
127
|
+
// @ts-expect-error
|
|
128
|
+
return fetch(uri).then((response)=>{
|
|
129
|
+
if (!response.ok) {
|
|
130
|
+
throw new Error('Network response was not ok');
|
|
131
|
+
}
|
|
132
|
+
return response.json();
|
|
133
|
+
}).then((json)=>{
|
|
134
|
+
const jsonSchemaSanitizations = {
|
|
135
|
+
id: undefined,
|
|
136
|
+
$id: json.id,
|
|
137
|
+
$schema: 'http://json-schema.org/draft-07/schema#'
|
|
138
|
+
};
|
|
139
|
+
return Object.assign(json, jsonSchemaSanitizations);
|
|
140
|
+
});
|
|
141
|
+
};
|
|
97
142
|
if (required && !value) {
|
|
98
143
|
return t('validation:required');
|
|
99
144
|
}
|
|
100
145
|
if (jsonError !== undefined) {
|
|
101
146
|
return t('validation:invalidInput');
|
|
102
147
|
}
|
|
148
|
+
if (jsonSchema && isNotEmpty(value)) {
|
|
149
|
+
try {
|
|
150
|
+
jsonSchema.schema = await fetchSchema(jsonSchema);
|
|
151
|
+
const { schema } = jsonSchema;
|
|
152
|
+
// @ts-expect-error
|
|
153
|
+
const ajv = new Ajv();
|
|
154
|
+
if (!ajv.validate(schema, value)) {
|
|
155
|
+
return t(ajv.errorsText());
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return t(error.message);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
103
161
|
return true;
|
|
104
162
|
};
|
|
105
163
|
export const checkbox = (value, { req: { t }, required })=>{
|
|
@@ -110,7 +168,7 @@ export const checkbox = (value, { req: { t }, required })=>{
|
|
|
110
168
|
};
|
|
111
169
|
export const date = (value, { req: { t }, required })=>{
|
|
112
170
|
if (value && !isNaN(Date.parse(value.toString()))) {
|
|
113
|
-
|
|
171
|
+
return true;
|
|
114
172
|
}
|
|
115
173
|
if (value) {
|
|
116
174
|
return t('validation:notValidDate', {
|
|
@@ -123,6 +181,12 @@ export const date = (value, { req: { t }, required })=>{
|
|
|
123
181
|
return true;
|
|
124
182
|
};
|
|
125
183
|
export const richText = async (value, options)=>{
|
|
184
|
+
if (!options?.editor) {
|
|
185
|
+
throw new Error('richText field has no editor property.');
|
|
186
|
+
}
|
|
187
|
+
if (typeof options?.editor === 'function') {
|
|
188
|
+
throw new Error('Attempted to access unsanitized rich text editor.');
|
|
189
|
+
}
|
|
126
190
|
const editor = options?.editor;
|
|
127
191
|
return editor.validate(value, options);
|
|
128
192
|
};
|
|
@@ -208,7 +272,7 @@ const validateFilterOptions = async (value, { id, data, filterOptions, relationT
|
|
|
208
272
|
if (typeof filterOptions !== 'undefined' && value) {
|
|
209
273
|
const options = {};
|
|
210
274
|
const falseCollections = [];
|
|
211
|
-
const collections =
|
|
275
|
+
const collections = !Array.isArray(relationTo) ? [
|
|
212
276
|
relationTo
|
|
213
277
|
] : relationTo;
|
|
214
278
|
const values = Array.isArray(value) ? value : [
|
|
@@ -228,8 +292,12 @@ const validateFilterOptions = async (value, { id, data, filterOptions, relationT
|
|
|
228
292
|
}
|
|
229
293
|
const valueIDs = [];
|
|
230
294
|
values.forEach((val)=>{
|
|
231
|
-
if (typeof val === 'object'
|
|
232
|
-
|
|
295
|
+
if (typeof val === 'object') {
|
|
296
|
+
if (val?.value) {
|
|
297
|
+
valueIDs.push(val.value);
|
|
298
|
+
} else if (ObjectId.isValid(val)) {
|
|
299
|
+
valueIDs.push(new ObjectId(val).toHexString());
|
|
300
|
+
}
|
|
233
301
|
}
|
|
234
302
|
if (typeof val === 'string' || typeof val === 'number') {
|
|
235
303
|
valueIDs.push(val);
|
|
@@ -277,6 +345,9 @@ const validateFilterOptions = async (value, { id, data, filterOptions, relationT
|
|
|
277
345
|
if (typeof val === 'string' || typeof val === 'number') {
|
|
278
346
|
requestedID = val;
|
|
279
347
|
}
|
|
348
|
+
if (typeof val === 'object' && ObjectId.isValid(val)) {
|
|
349
|
+
requestedID = new ObjectId(val).toHexString();
|
|
350
|
+
}
|
|
280
351
|
}
|
|
281
352
|
if (Array.isArray(relationTo) && typeof val === 'object' && val?.relationTo) {
|
|
282
353
|
collection = val.relationTo;
|
|
@@ -311,7 +382,7 @@ export const upload = (value, options)=>{
|
|
|
311
382
|
};
|
|
312
383
|
export const relationship = async (value, options)=>{
|
|
313
384
|
const { maxRows, minRows, relationTo, req: { payload, t }, required } = options;
|
|
314
|
-
if ((!value || Array.isArray(value) && value.length === 0) && required) {
|
|
385
|
+
if ((!value && typeof value !== 'number' || Array.isArray(value) && value.length === 0) && required) {
|
|
315
386
|
return t('validation:required');
|
|
316
387
|
}
|
|
317
388
|
if (Array.isArray(value) && value.length > 0) {
|
|
@@ -340,7 +411,7 @@ export const relationship = async (value, options)=>{
|
|
|
340
411
|
if (typeof relationTo === 'string') {
|
|
341
412
|
collectionSlug = relationTo;
|
|
342
413
|
// custom id
|
|
343
|
-
if (val) {
|
|
414
|
+
if (val || typeof val === 'number') {
|
|
344
415
|
requestedID = val;
|
|
345
416
|
}
|
|
346
417
|
}
|