payload 4.0.0-internal.d28e9fb → 4.0.0-internal.fa345ef
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/LICENSE.md +1 -1
- package/bin.js +11 -0
- package/dist/admin/RichText.d.ts +4 -17
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/adapters/cookies.d.ts +21 -0
- package/dist/admin/adapters/cookies.d.ts.map +1 -0
- package/dist/admin/adapters/cookies.js +3 -0
- package/dist/admin/adapters/cookies.js.map +1 -0
- package/dist/admin/adapters/devReload.d.ts +9 -0
- package/dist/admin/adapters/devReload.d.ts.map +1 -0
- package/dist/admin/adapters/devReload.js +6 -0
- package/dist/admin/adapters/devReload.js.map +1 -0
- package/dist/admin/adapters/index.d.ts +7 -0
- package/dist/admin/adapters/index.d.ts.map +1 -0
- package/dist/admin/adapters/index.js +3 -0
- package/dist/admin/adapters/index.js.map +1 -0
- package/dist/admin/adapters/render.d.ts +16 -0
- package/dist/admin/adapters/render.d.ts.map +1 -0
- package/dist/admin/adapters/render.js +7 -0
- package/dist/admin/adapters/render.js.map +1 -0
- package/dist/admin/adapters/router.d.ts +56 -0
- package/dist/admin/adapters/router.d.ts.map +1 -0
- package/dist/admin/adapters/router.js +3 -0
- package/dist/admin/adapters/router.js.map +1 -0
- package/dist/admin/adapters/server.d.ts +23 -0
- package/dist/admin/adapters/server.d.ts.map +1 -0
- package/dist/admin/adapters/server.js +6 -0
- package/dist/admin/adapters/server.js.map +1 -0
- package/dist/admin/adapters/views.d.ts +36 -0
- package/dist/admin/adapters/views.d.ts.map +1 -0
- package/dist/admin/adapters/views.js +7 -0
- package/dist/admin/adapters/views.js.map +1 -0
- package/dist/admin/elements/Table.d.ts +1 -0
- package/dist/admin/elements/Table.d.ts.map +1 -1
- package/dist/admin/elements/Table.js.map +1 -1
- package/dist/admin/fields/Row.d.ts +2 -2
- package/dist/admin/fields/Row.d.ts.map +1 -1
- package/dist/admin/fields/Row.js.map +1 -1
- package/dist/admin/forms/Description.d.ts +2 -2
- package/dist/admin/forms/Description.d.ts.map +1 -1
- package/dist/admin/forms/Description.js.map +1 -1
- package/dist/admin/forms/Field.d.ts +10 -5
- package/dist/admin/forms/Field.d.ts.map +1 -1
- package/dist/admin/forms/Field.js.map +1 -1
- package/dist/admin/functions/index.d.ts +9 -0
- package/dist/admin/functions/index.d.ts.map +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +3 -2
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/dashboard.d.ts +7 -0
- package/dist/admin/views/dashboard.d.ts.map +1 -1
- package/dist/admin/views/dashboard.js.map +1 -1
- package/dist/admin/views/document.d.ts +5 -3
- package/dist/admin/views/document.d.ts.map +1 -1
- package/dist/admin/views/document.js.map +1 -1
- package/dist/admin/views/hierarchyList.d.ts +1 -0
- package/dist/admin/views/hierarchyList.d.ts.map +1 -1
- package/dist/admin/views/hierarchyList.js.map +1 -1
- package/dist/admin/views/list.d.ts +10 -1
- package/dist/admin/views/list.d.ts.map +1 -1
- package/dist/admin/views/list.js.map +1 -1
- package/dist/auth/baseFields/apiKey.d.ts +10 -2
- package/dist/auth/baseFields/apiKey.d.ts.map +1 -1
- package/dist/auth/baseFields/apiKey.js +35 -24
- package/dist/auth/baseFields/apiKey.js.map +1 -1
- package/dist/auth/cookies.d.ts.map +1 -1
- package/dist/auth/defaultAccess.d.ts +1 -1
- package/dist/auth/defaultAccess.d.ts.map +1 -1
- package/dist/auth/defaultAccess.js +1 -1
- package/dist/auth/defaultAccess.js.map +1 -1
- package/dist/auth/defaultUser.d.ts.map +1 -1
- package/dist/auth/defaultUser.js +2 -1
- package/dist/auth/defaultUser.js.map +1 -1
- package/dist/auth/ensureUsernameOrEmail.d.ts.map +1 -1
- package/dist/auth/executeAccess.d.ts.map +1 -1
- package/dist/auth/executeAuthStrategies.d.ts.map +1 -1
- package/dist/auth/extractAccessFromPermission.d.ts.map +1 -1
- package/dist/auth/extractJWT.d.ts.map +1 -1
- package/dist/auth/getAuthFields.d.ts.map +1 -1
- package/dist/auth/getAuthFields.js +2 -2
- package/dist/auth/getAuthFields.js.map +1 -1
- package/dist/auth/getFieldsToSign.d.ts.map +1 -1
- package/dist/auth/getLoginOptions.d.ts.map +1 -1
- package/dist/auth/isUserLocked.d.ts.map +1 -1
- package/dist/auth/jwt.d.ts.map +1 -1
- package/dist/auth/operations/access.d.ts.map +1 -1
- package/dist/auth/operations/auth.d.ts +2 -2
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/init.d.ts.map +1 -1
- package/dist/auth/operations/local/auth.d.ts.map +1 -1
- package/dist/auth/operations/login.d.ts +2 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/logout.d.ts.map +1 -1
- package/dist/auth/operations/me.d.ts.map +1 -1
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +9 -3
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/verifyEmail.d.ts.map +1 -1
- package/dist/auth/sendVerificationEmail.d.ts +2 -2
- package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
- package/dist/auth/sendVerificationEmail.js +1 -1
- package/dist/auth/sendVerificationEmail.js.map +1 -1
- package/dist/auth/sessions.d.ts +4 -5
- package/dist/auth/sessions.d.ts.map +1 -1
- package/dist/auth/sessions.js +5 -3
- package/dist/auth/sessions.js.map +1 -1
- package/dist/auth/strategies/apiKey.d.ts.map +1 -1
- package/dist/auth/strategies/apiKey.js +6 -17
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
- package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +2 -2
- 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.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.d.ts.map +1 -1
- package/dist/auth/types.d.ts +28 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/build.d.ts +25 -0
- package/dist/bin/build.d.ts.map +1 -0
- package/dist/bin/build.js +80 -0
- package/dist/bin/build.js.map +1 -0
- package/dist/bin/build.spec.js +170 -0
- package/dist/bin/build.spec.js.map +1 -0
- package/dist/bin/generateImportMap/index.d.ts.map +1 -1
- package/dist/bin/generateImportMap/index.js +8 -5
- package/dist/bin/generateImportMap/index.js.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.js +11 -0
- package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
- package/dist/bin/generateImportMap/iterateConfig.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateConfig.js +12 -0
- package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
- package/dist/bin/generateImportMap/iterateFields.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateFields.js +4 -1
- package/dist/bin/generateImportMap/iterateFields.js.map +1 -1
- package/dist/bin/generateImportMap/utilities/getFromImportMap.d.ts.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts +5 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +32 -18
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
- package/dist/bin/generateTypes.d.ts +3 -2
- package/dist/bin/generateTypes.d.ts.map +1 -1
- package/dist/bin/generateTypes.js +11 -1
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +9 -0
- package/dist/bin/index.js.map +1 -1
- package/dist/bin/loadEnv.d.ts +3 -1
- package/dist/bin/loadEnv.d.ts.map +1 -1
- package/dist/bin/loadEnv.js +40 -10
- package/dist/bin/loadEnv.js.map +1 -1
- package/dist/bin/migrate.d.ts.map +1 -1
- package/dist/collections/config/client.d.ts +1 -1
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +1 -0
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +0 -4
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +2 -17
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/defaults.spec.js +47 -0
- package/dist/collections/config/defaults.spec.js.map +1 -0
- package/dist/collections/config/sanitize.d.ts +10 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +214 -230
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/sanitizeCompoundIndexes.d.ts.map +1 -1
- package/dist/collections/config/types.d.ts +11 -7
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/config/useAsTitle.d.ts.map +1 -1
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/endpoints/create.d.ts.map +1 -1
- package/dist/collections/endpoints/create.js +0 -2
- package/dist/collections/endpoints/create.js.map +1 -1
- package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
- package/dist/collections/endpoints/updateByID.js +1 -2
- package/dist/collections/endpoints/updateByID.js.map +1 -1
- package/dist/collections/operations/count.d.ts.map +1 -1
- package/dist/collections/operations/count.js +1 -0
- package/dist/collections/operations/count.js.map +1 -1
- package/dist/collections/operations/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/create.d.ts +0 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +15 -6
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +3 -0
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.js +1 -0
- package/dist/collections/operations/findDistinct.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/count.d.ts +3 -3
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/countVersions.d.ts +3 -3
- package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/countVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +3 -3
- 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/findDistinct.d.ts +2 -2
- package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/local/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +3 -3
- 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 +3 -3
- 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/restoreVersion.d.ts +3 -3
- 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 +7 -11
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js +1 -2
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/update.d.ts +0 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +8 -4
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +0 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +1 -5
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utilities/buildAfterOperation.d.ts.map +1 -1
- package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts +9 -0
- package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts.map +1 -0
- package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js +170 -0
- package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js.map +1 -0
- package/dist/collections/operations/utilities/sanitizeSortQuery.d.ts.map +1 -1
- package/dist/collections/operations/utilities/types.d.ts +0 -9
- package/dist/collections/operations/utilities/types.d.ts.map +1 -1
- package/dist/collections/operations/utilities/types.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts +1 -2
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +64 -65
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/build.d.ts.map +1 -1
- package/dist/config/build.js +8 -0
- package/dist/config/build.js.map +1 -1
- package/dist/config/client.d.ts +3 -3
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +2 -1
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts +0 -4
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +0 -78
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/definePlugin.d.ts +10 -10
- package/dist/config/definePlugin.d.ts.map +1 -1
- package/dist/config/definePlugin.js +7 -11
- package/dist/config/definePlugin.js.map +1 -1
- package/dist/config/orderable/index.d.ts.map +1 -1
- package/dist/config/orderable/index.js +23 -0
- package/dist/config/orderable/index.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +362 -271
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +125 -38
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -1
- package/dist/database/combineQueries.d.ts.map +1 -1
- package/dist/database/getLocalizedPaths.d.ts.map +1 -1
- package/dist/database/getLocalizedPaths.js +1 -1
- package/dist/database/getLocalizedPaths.js.map +1 -1
- package/dist/database/migrations/findMigrationDir.d.ts.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -1
- package/dist/database/migrations/migrationsCollection.d.ts.map +1 -1
- package/dist/database/migrations/migrationsCollection.js +2 -1
- package/dist/database/migrations/migrationsCollection.js.map +1 -1
- package/dist/database/migrations/readMigrationFiles.d.ts.map +1 -1
- package/dist/database/migrations/writeMigrationIndex.d.ts.map +1 -1
- package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
- package/dist/database/sanitizeWhereQuery.d.ts.map +1 -1
- package/dist/duplicateDocument/index.d.ts.map +1 -1
- package/dist/email/getStringifiedToAddress.d.ts.map +1 -1
- package/dist/errors/ValidationError.d.ts +1 -0
- package/dist/errors/ValidationError.d.ts.map +1 -1
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/exports/internal.d.ts +0 -1
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +0 -1
- package/dist/exports/internal.js.map +1 -1
- package/dist/exports/migrations.d.ts +5 -13
- package/dist/exports/migrations.d.ts.map +1 -1
- package/dist/exports/migrations.js +5 -13
- package/dist/exports/migrations.js.map +1 -1
- package/dist/exports/shared.d.ts +23 -1
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +23 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/index.js +1 -1
- package/dist/fields/baseFields/slug/index.js.map +1 -1
- package/dist/fields/config/client.d.ts +3 -3
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +12 -13
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +315 -338
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitizeJoinField.d.ts.map +1 -1
- package/dist/fields/config/types.d.ts +45 -66
- 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.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +12 -3
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +3 -3
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.js +2 -2
- package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +11 -2
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/isFieldDisabled.d.ts.map +1 -1
- package/dist/fields/mergeBaseFields.d.ts.map +1 -1
- package/dist/fields/setDefaultBeforeDuplicate.d.ts.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +5 -4
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/config/client.d.ts.map +1 -1
- package/dist/globals/config/sanitize.d.ts +6 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +122 -132
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/sanitize.spec.js +43 -0
- package/dist/globals/config/sanitize.spec.js.map +1 -0
- package/dist/globals/endpoints/update.d.ts.map +1 -1
- package/dist/globals/endpoints/update.js +0 -2
- package/dist/globals/endpoints/update.js.map +1 -1
- package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
- package/dist/globals/operations/docAccess.d.ts.map +1 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countVersions.d.ts +3 -3
- package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +3 -3
- 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 +3 -3
- 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 +3 -3
- 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/restoreVersion.d.ts +3 -3
- 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 -9
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js +1 -2
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/update.d.ts +0 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +52 -58
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/hierarchy/addHierarchyToCollection.d.ts.map +1 -1
- package/dist/hierarchy/buildParentField.d.ts.map +1 -1
- package/dist/hierarchy/constants.d.ts.map +1 -1
- package/dist/hierarchy/getInitialTreeData.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionAfterDelete.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionAfterRead.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionBeforeChange.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts.map +1 -1
- package/dist/hierarchy/hooks/collectionBeforeOperation.d.ts.map +1 -1
- package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts.map +1 -1
- package/dist/hierarchy/injectHierarchyButton.d.ts.map +1 -1
- package/dist/hierarchy/resolveHierarchyCollections.d.ts.map +1 -1
- package/dist/hierarchy/resolveHierarchyCollections.js +1 -1
- package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -1
- package/dist/hierarchy/sanitizeHierarchyCollection.d.ts.map +1 -1
- package/dist/hierarchy/sanitizeHierarchyCollection.js +3 -1
- package/dist/hierarchy/sanitizeHierarchyCollection.js.map +1 -1
- package/dist/hierarchy/types.d.ts +8 -1
- package/dist/hierarchy/types.d.ts.map +1 -1
- package/dist/hierarchy/types.js.map +1 -1
- package/dist/index.bundled.d.ts +808 -366
- package/dist/index.d.ts +72 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -55
- package/dist/index.js.map +1 -1
- package/dist/kv/adapters/DatabaseKVAdapter.d.ts.map +1 -1
- package/dist/kv/adapters/DatabaseKVAdapter.js +1 -0
- package/dist/kv/adapters/DatabaseKVAdapter.js.map +1 -1
- package/dist/locked-documents/config.d.ts.map +1 -1
- package/dist/locked-documents/config.js +2 -1
- package/dist/locked-documents/config.js.map +1 -1
- package/dist/preferences/config.d.ts.map +1 -1
- package/dist/preferences/config.js +2 -1
- package/dist/preferences/config.js.map +1 -1
- package/dist/preferences/deleteUserPreferences.d.ts.map +1 -1
- package/dist/preferences/keys.d.ts +4 -0
- package/dist/preferences/keys.d.ts.map +1 -1
- package/dist/preferences/keys.js +4 -1
- package/dist/preferences/keys.js.map +1 -1
- package/dist/preferences/types.d.ts +15 -0
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js +3 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/query-presets/access.d.ts.map +1 -1
- package/dist/query-presets/config.d.ts.map +1 -1
- package/dist/query-presets/config.js +77 -37
- package/dist/query-presets/config.js.map +1 -1
- package/dist/query-presets/constraints.d.ts.map +1 -1
- package/dist/query-presets/constraints.js +3 -2
- package/dist/query-presets/constraints.js.map +1 -1
- package/dist/queues/config/collection.d.ts.map +1 -1
- package/dist/queues/config/collection.js +2 -1
- package/dist/queues/config/collection.js.map +1 -1
- package/dist/queues/config/generateJobsJSONSchemas.d.ts +1 -1
- package/dist/queues/config/generateJobsJSONSchemas.d.ts.map +1 -1
- package/dist/queues/config/generateJobsJSONSchemas.js +33 -12
- package/dist/queues/config/generateJobsJSONSchemas.js.map +1 -1
- package/dist/queues/config/global.d.ts.map +1 -1
- package/dist/queues/config/global.js +2 -1
- package/dist/queues/config/global.js.map +1 -1
- package/dist/queues/endpoints/run.d.ts.map +1 -1
- package/dist/queues/localAPI.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/getQueuesWithSchedules.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -1
- package/dist/queues/utilities/getJobTaskStatus.d.ts.map +1 -1
- package/dist/translations/getLocalI18n.d.ts.map +1 -1
- package/dist/types/index.d.ts +18 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/checkFileAccess.d.ts.map +1 -1
- package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
- package/dist/uploads/docWithFilenameExists.d.ts.map +1 -1
- package/dist/uploads/endpoints/getFileFromURL.d.ts.map +1 -1
- package/dist/uploads/endpoints/getFileFromURL.js +9 -5
- package/dist/uploads/endpoints/getFileFromURL.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/isEligibleRequest.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processNested.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/utilities.d.ts.map +1 -1
- package/dist/uploads/fileExists.d.ts.map +1 -1
- package/dist/uploads/generateFileData.d.ts +2 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +5 -2
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getBaseFields.d.ts.map +1 -1
- package/dist/uploads/getBaseFields.js +7 -19
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/getExternalFile.d.ts.map +1 -1
- package/dist/uploads/getFileByPath.d.ts.map +1 -1
- package/dist/uploads/getFileTypeFallback.d.ts.map +1 -1
- package/dist/uploads/getSafeFilename.d.ts.map +1 -1
- package/dist/uploads/image-resizing/createImageSize.d.ts.map +1 -1
- package/dist/uploads/image-resizing/generateImageSizeFilename.d.ts.map +1 -1
- package/dist/uploads/image-resizing/getImageResizeAction.d.ts.map +1 -1
- package/dist/uploads/image-resizing/parseFilename.d.ts.map +1 -1
- package/dist/uploads/image-resizing/sanitizeResizeConfig.d.ts.map +1 -1
- package/dist/uploads/matchMimeType.d.ts +8 -0
- package/dist/uploads/matchMimeType.d.ts.map +1 -0
- package/dist/uploads/matchMimeType.js +19 -0
- package/dist/uploads/matchMimeType.js.map +1 -0
- package/dist/uploads/matchMimeType.spec.js +66 -0
- package/dist/uploads/matchMimeType.spec.js.map +1 -0
- package/dist/uploads/mimeTypeValidator.d.ts.map +1 -1
- package/dist/uploads/safeFetch.d.ts +1 -1
- package/dist/uploads/safeFetch.d.ts.map +1 -1
- package/dist/uploads/safeFetch.js +11 -5
- package/dist/uploads/safeFetch.js.map +1 -1
- package/dist/uploads/saveBufferToFile.d.ts.map +1 -1
- package/dist/uploads/tempFile.d.ts.map +1 -1
- package/dist/uploads/types.d.ts +33 -29
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/uploads/uploadFiles.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +6 -0
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/addLocalesToRequest.d.ts.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts.map +1 -1
- package/dist/utilities/appendDateTimezoneSelectFields.d.ts.map +1 -1
- package/dist/utilities/appendDateTimezoneSelectFields.js +2 -2
- package/dist/utilities/appendDateTimezoneSelectFields.js.map +1 -1
- package/dist/utilities/appendNonTrashedFilter.d.ts.map +1 -1
- package/dist/utilities/appendUploadSelectFields.d.ts.map +1 -1
- package/dist/utilities/canAccessAdmin.d.ts.map +1 -1
- package/dist/utilities/checkDocumentLockStatus.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts +68 -16
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +311 -117
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +619 -85
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts +2 -2
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
- package/dist/utilities/createPayloadRequest.js +1 -0
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/deepCopyObject.d.ts.map +1 -1
- package/dist/utilities/deepCopyObject.js +8 -0
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/dependencies/dependencyChecker.js +1 -1
- package/dist/utilities/dependencies/dependencyChecker.js.map +1 -1
- package/dist/utilities/dependencies/getDependencies.d.ts.map +1 -1
- package/dist/utilities/dependencies/getDependencies.js +5 -5
- package/dist/utilities/dependencies/getDependencies.js.map +1 -1
- package/dist/utilities/dependencies/resolveFrom.d.ts.map +1 -1
- package/dist/utilities/dynamicImport.js +1 -1
- package/dist/utilities/dynamicImport.js.map +1 -1
- package/dist/utilities/escapeRegExp.d.ts.map +1 -1
- package/dist/utilities/extractID.d.ts.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.d.ts.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.js +5 -12
- package/dist/utilities/filterDataToSelectedLocales.js.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.spec.js +1 -2
- package/dist/utilities/filterDataToSelectedLocales.spec.js.map +1 -1
- package/dist/utilities/flattenAllFields.d.ts.map +1 -1
- package/dist/utilities/flattenAllFields.js +78 -102
- package/dist/utilities/flattenAllFields.js.map +1 -1
- package/dist/utilities/formatAdminURL.d.ts.map +1 -1
- package/dist/utilities/formatErrors.d.ts.map +1 -1
- package/dist/utilities/formatErrors.js +3 -1
- package/dist/utilities/formatErrors.js.map +1 -1
- package/dist/utilities/formatLabels.d.ts.map +1 -1
- package/dist/utilities/getBestFitFromSizes.d.ts.map +1 -1
- package/dist/utilities/getBlockSelect.d.ts.map +1 -1
- package/dist/utilities/getDataByPath.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +7 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +24 -7
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
- package/dist/utilities/getFieldByPath.d.ts.map +1 -1
- package/dist/utilities/getFieldByPath.js +1 -1
- package/dist/utilities/getFieldByPath.js.map +1 -1
- package/dist/utilities/getFieldPermissions.d.ts.map +1 -1
- package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
- package/dist/utilities/getRequestEntity.d.ts.map +1 -1
- package/dist/utilities/getRequestLanguage.d.ts +2 -2
- package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
- package/dist/utilities/getRequestLanguage.js.map +1 -1
- package/dist/utilities/getRequestOrigin.d.ts.map +1 -1
- package/dist/utilities/getSafeRedirect.d.ts.map +1 -1
- package/dist/utilities/getSelectMode.d.ts.map +1 -1
- package/dist/utilities/getSiblingData.d.ts.map +1 -1
- package/dist/utilities/getTranslatedLabel.d.ts.map +1 -1
- package/dist/utilities/getVersionsConfig.d.ts.map +1 -1
- package/dist/utilities/getVersionsConfig.js.map +1 -1
- package/dist/utilities/handleEndpoints.d.ts.map +1 -1
- package/dist/utilities/handleEndpoints.js +7 -4
- package/dist/utilities/handleEndpoints.js.map +1 -1
- package/dist/utilities/headersWithCors.d.ts.map +1 -1
- package/dist/utilities/isEntityHidden.d.ts.map +1 -1
- package/dist/utilities/isURLAllowed.d.ts.map +1 -1
- package/dist/utilities/isValidID.d.ts.map +1 -1
- package/dist/utilities/logError.d.ts.map +1 -1
- package/dist/utilities/logger.d.ts.map +1 -1
- package/dist/utilities/mergeHeaders.d.ts.map +1 -1
- package/dist/utilities/mergeListSearchAndWhere.d.ts.map +1 -1
- package/dist/utilities/mergeLocalizedData.d.ts +14 -4
- package/dist/utilities/mergeLocalizedData.d.ts.map +1 -1
- package/dist/utilities/mergeLocalizedData.js +54 -46
- package/dist/utilities/mergeLocalizedData.js.map +1 -1
- package/dist/utilities/mergeLocalizedData.spec.js +23 -23
- package/dist/utilities/mergeLocalizedData.spec.js.map +1 -1
- package/dist/utilities/optionsAreEqual.d.ts.map +1 -1
- package/dist/utilities/parseBooleanString.d.ts.map +1 -1
- package/dist/utilities/parseCookies.d.ts.map +1 -1
- package/dist/utilities/parseParams/index.d.ts +2 -5
- package/dist/utilities/parseParams/index.d.ts.map +1 -1
- package/dist/utilities/parseParams/index.js.map +1 -1
- package/dist/utilities/parseParams/index.spec.js +0 -9
- package/dist/utilities/parseParams/index.spec.js.map +1 -1
- package/dist/utilities/profiling.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
- package/dist/utilities/resolveSelect.d.ts.map +1 -1
- package/dist/utilities/routeError.d.ts.map +1 -1
- package/dist/utilities/sanitizeFallbackLocale.d.ts.map +1 -1
- package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
- package/dist/utilities/sanitizeJoinParams.d.ts.map +1 -1
- package/dist/utilities/sanitizePopulateParam.d.ts.map +1 -1
- package/dist/utilities/sanitizeSelect.d.ts.map +1 -1
- package/dist/utilities/sanitizeSelectParam.d.ts.map +1 -1
- package/dist/utilities/sanitizeSortParams.d.ts.map +1 -1
- package/dist/utilities/setsAreEqual.d.ts.map +1 -1
- package/dist/utilities/slugify.d.ts.map +1 -1
- package/dist/utilities/stripUnselectedFields.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/oneWayHash.d.ts.map +1 -1
- package/dist/utilities/timestamp.d.ts.map +1 -1
- package/dist/utilities/toKebabCase.d.ts.map +1 -1
- package/dist/utilities/transformColumnPreferences.d.ts.map +1 -1
- package/dist/utilities/transformColumnPreferences.js +4 -2
- package/dist/utilities/transformColumnPreferences.js.map +1 -1
- package/dist/utilities/transformWhereQuery.d.ts.map +1 -1
- package/dist/utilities/traverseFields.d.ts.map +1 -1
- package/dist/utilities/traverseFields.js +2 -4
- package/dist/utilities/traverseFields.js.map +1 -1
- package/dist/utilities/traverseForLocalizedFields.d.ts.map +1 -1
- package/dist/utilities/traverseForLocalizedFields.js +3 -0
- package/dist/utilities/traverseForLocalizedFields.js.map +1 -1
- package/dist/utilities/unflatten.d.ts.map +1 -1
- package/dist/utilities/validateMimeType.d.ts.map +1 -1
- package/dist/utilities/validateTimezones.d.ts.map +1 -1
- package/dist/utilities/validateWhereQuery.d.ts.map +1 -1
- package/dist/utilities/wordBoundariesRegex.d.ts.map +1 -1
- package/dist/utilities/wrapInternalEndpoints.d.ts.map +1 -1
- package/dist/versions/baseFields.d.ts +1 -2
- package/dist/versions/baseFields.d.ts.map +1 -1
- package/dist/versions/baseFields.js +0 -13
- package/dist/versions/baseFields.js.map +1 -1
- package/dist/versions/buildCollectionFields.d.ts.map +1 -1
- package/dist/versions/buildCollectionFields.js +0 -2
- package/dist/versions/buildCollectionFields.js.map +1 -1
- package/dist/versions/buildGlobalFields.d.ts.map +1 -1
- package/dist/versions/buildGlobalFields.js +0 -2
- package/dist/versions/buildGlobalFields.js.map +1 -1
- package/dist/versions/buildSingleLocalePublishData.d.ts +32 -0
- package/dist/versions/buildSingleLocalePublishData.d.ts.map +1 -0
- package/dist/versions/buildSingleLocalePublishData.js +37 -0
- package/dist/versions/buildSingleLocalePublishData.js.map +1 -0
- package/dist/versions/buildVersionCompoundIndexes.d.ts.map +1 -1
- package/dist/versions/deleteCollectionVersions.d.ts.map +1 -1
- package/dist/versions/deleteScheduledPublishJobs.d.ts.map +1 -1
- package/dist/versions/drafts/appendVersionToQueryKey.d.ts.map +1 -1
- package/dist/versions/drafts/getQueryDraftsSelect.d.ts.map +1 -1
- package/dist/versions/drafts/getQueryDraftsSort.d.ts.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
- package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
- package/dist/versions/getLatestCollectionVersion.d.ts.map +1 -1
- package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
- package/dist/versions/migrations/localizeStatus/shared.d.ts.map +1 -1
- package/dist/versions/saveVersion.d.ts +0 -2
- package/dist/versions/saveVersion.d.ts.map +1 -1
- package/dist/versions/saveVersion.js +12 -17
- package/dist/versions/saveVersion.js.map +1 -1
- package/dist/versions/schedule/job.d.ts.map +1 -1
- package/dist/versions/schedule/job.js +2 -9
- package/dist/versions/schedule/job.js.map +1 -1
- package/dist/versions/types.d.ts +2 -15
- package/dist/versions/types.d.ts.map +1 -1
- package/dist/versions/types.js.map +1 -1
- package/package.json +23 -20
- package/dist/database/migrations/templates/localizeStatus.d.ts +0 -10
- package/dist/database/migrations/templates/localizeStatus.d.ts.map +0 -1
- package/dist/database/migrations/templates/localizeStatus.js +0 -54
- package/dist/database/migrations/templates/localizeStatus.js.map +0 -1
- package/dist/utilities/sanitizeProfiler.d.ts +0 -38
- package/dist/utilities/sanitizeProfiler.d.ts.map +0 -1
- package/dist/utilities/sanitizeProfiler.js +0 -101
- package/dist/utilities/sanitizeProfiler.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/index.d.ts +0 -12
- package/dist/versions/migrations/localizeStatus/index.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/index.js +0 -33
- package/dist/versions/migrations/localizeStatus/index.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/down.d.ts +0 -9
- package/dist/versions/migrations/localizeStatus/mongo/down.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/down.js +0 -112
- package/dist/versions/migrations/localizeStatus/mongo/down.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/index.d.ts +0 -8
- package/dist/versions/migrations/localizeStatus/mongo/index.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/index.js +0 -8
- package/dist/versions/migrations/localizeStatus/mongo/index.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/up.d.ts +0 -9
- package/dist/versions/migrations/localizeStatus/mongo/up.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/mongo/up.js +0 -220
- package/dist/versions/migrations/localizeStatus/mongo/up.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/down.d.ts +0 -11
- package/dist/versions/migrations/localizeStatus/sql/down.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/down.js +0 -213
- package/dist/versions/migrations/localizeStatus/sql/down.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/index.d.ts +0 -8
- package/dist/versions/migrations/localizeStatus/sql/index.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/index.js +0 -8
- package/dist/versions/migrations/localizeStatus/sql/index.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts +0 -13
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js +0 -51
- package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts +0 -13
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js +0 -54
- package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/up.d.ts +0 -11
- package/dist/versions/migrations/localizeStatus/sql/up.d.ts.map +0 -1
- package/dist/versions/migrations/localizeStatus/sql/up.js +0 -277
- package/dist/versions/migrations/localizeStatus/sql/up.js.map +0 -1
- package/dist/versions/saveSnapshot.d.ts +0 -18
- package/dist/versions/saveSnapshot.d.ts.map +0 -1
- package/dist/versions/saveSnapshot.js +0 -38
- package/dist/versions/saveSnapshot.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: ['string', 'null'],\n },\n },\n required: ['blockType'],\n },\n ],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: 'string',\n },\n },\n required: ['blockType', 'field'],\n },\n ],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n typescriptSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n $ref: '#/definitions/SharedBlock',\n },\n ],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.definitions?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n typescriptSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.definitions.test.properties.title.required).toStrictEqual(false)\n })\n\n it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async () => {\n const namedBlock: Block = {\n slug: 'myBlock',\n interfaceName: 'MyBlock',\n fields: [{ name: 'text', type: 'text' }],\n }\n\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'arr',\n type: 'array',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n {\n name: 'grp',\n type: 'group',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n\n // Without forceInlineBlocks: blocks field uses $ref\n const schemaDefault = configToJSONSchema(sanitizedConfig, 'text')\n const arrItemsDefault = schemaDefault.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksDefault = (arrItemsDefault.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksDefault).toStrictEqual({ $ref: '#/definitions/MyBlock' })\n\n // With forceInlineBlocks: blocks field is inlined, no $ref\n const schemaInline = configToJSONSchema(sanitizedConfig, 'text', undefined, {\n forceInlineBlocks: true,\n })\n const arrItemsInline = schemaInline.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksInline = (arrItemsInline.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksInline).not.toHaveProperty('$ref')\n expect(arrBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n\n const grpBlocksInline = (\n schemaInline.definitions!.test.properties!.grp.properties!.blocks.items as JSONSchema4\n ).oneOf![0]\n expect(grpBlocksInline).not.toHaveProperty('$ref')\n expect(grpBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","config","collections","slug","fields","name","type","required","timestamps","sanitizedConfig","schema","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","blocks","blockField","blockFieldRequired","blockFieldWithFields","oneOf","blockName","blockType","const","field","blockFieldWithFieldsRequired","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","typescriptSchema","jsonSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","interfaceName","editor","CellComponent","FieldComponent","validate","toBe","expectedBlockSchema","richText","someBlockField","$ref","SharedBlock","defaultValue","namedBlock","schemaDefault","arrItemsDefault","arr","arrBlocksDefault","schemaInline","undefined","forceInlineBlocks","arrItemsInline","arrBlocksInline","not","toHavePro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AAO8D,kBAAkB/C,aAAa,CAAC;YAAEwC,MAAM;QAAwB;QAEvE,2DAA2D;QAC3D,MAAMQ,eAAe7D,mBAAmBS,iBAAiB,QAAQqD,WAAW;YAC1EC,mBAAmB;QACrB;QACA,MAAMC,iBAAiBH,aAAalD,WAAW,CAAEC,IAAI,CAACG,UAAU,CAAE4C,GAAG,CAACzC,KAAK;QAC3E,MAAM+C,kBAAkB,AAACD,eAAejD,UAAU,CAAEK,MAAM,CAACF,KAAK,CAAiBM,KAAK,AAAC,CAAC,EAAE;QAC1F1B,OAAOmE,iBAAiBC,GAAG,CAACC,cAAc,CAAC;QAC3CrE,OAAOmE,gBAAgBlD,UAAU,EAAEW,WAAWb,aAAa,CAAC;YAAEc,OAAO;QAAU;QAE/E,MAAMyC,kBAAkB,AACtBP,aAAalD,WAAW,CAAEC,IAAI,CAACG,UAAU,CAAEsD,GAAG,CAACtD,UAAU,CAAEK,MAAM,CAACF,KAAK,CACvEM,KAAK,AAAC,CAAC,EAAE;QACX1B,OAAOsE,iBAAiBF,GAAG,CAACC,cAAc,CAAC;QAC3CrE,OAAOsE,gBAAgBrD,UAAU,EAAEW,WAAWb,aAAa,CAAC;YAAEc,OAAO;QAAU;IACjF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema, entityToStandaloneJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should generate separate input types when generateInputTypes is enabled', async () => {\n // @ts-expect-error partial config\n const config: Config = {\n collections: [\n { slug: 'authors', fields: [{ name: 'name', type: 'text' }] },\n { slug: 'categories', fields: [{ name: 'title', type: 'text' }] },\n {\n slug: 'posts',\n fields: [\n { name: 'title', type: 'text', required: true },\n {\n name: 'status',\n type: 'select',\n defaultValue: 'draft',\n options: ['draft', 'published'],\n required: true,\n },\n { name: 'author', type: 'relationship', relationTo: 'authors' },\n { name: 'categories', type: 'relationship', hasMany: true, relationTo: 'categories' },\n ],\n },\n ],\n typescript: { generateInputTypes: true },\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n // Output (read) shape is unchanged: relationships may be populated, managed fields are present,\n // and a required field with a defaultValue stays required.\n const postsOutput = schema?.$defs?.posts as JSONSchema4\n expect(postsOutput.title).toBe('Post')\n expect(postsOutput.properties!.author).toStrictEqual({\n oneOf: [{ type: ['string', 'null'] }, { $ref: '#/$defs/authors' }],\n })\n expect(postsOutput.properties!.categories).toStrictEqual({\n type: ['array', 'null'],\n items: { oneOf: [{ type: 'string' }, { $ref: '#/$defs/categories' }] },\n })\n expect(postsOutput.required).toStrictEqual(['id', 'title', 'status', 'updatedAt', 'createdAt'])\n\n // Input (write) shape: relationships are ID-only, the defaultValue field is optional, `id` is\n // optional, and createdAt/updatedAt are dropped. `id` and the defaulted `status` are optional\n // but NOT nullable - nullability follows the read shape, where they're non-null.\n expect(schema?.$defs?.posts_input).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: 'string' },\n title: { type: 'string' },\n status: { type: 'string', enum: ['draft', 'published'] },\n author: { type: ['string', 'null'] },\n categories: { type: ['array', 'null'], items: { type: 'string' } },\n },\n required: ['title'],\n title: 'PostInput',\n })\n\n // The Config type exposes input shapes under `collectionsInput`.\n expect((schema?.properties?.collectionsInput as JSONSchema4)?.properties?.posts).toStrictEqual({\n $ref: '#/$defs/posts_input',\n })\n })\n\n it('should skip input types by default and generate them when enabled', async () => {\n // @ts-expect-error partial config\n const offByDefault: Config = {\n collections: [{ slug: 'posts', fields: [{ name: 'title', type: 'text' }] }],\n }\n const { jsonSchema: defaultSchema } = configToJSONSchema(\n await sanitizeConfig(offByDefault),\n 'text',\n )\n expect(defaultSchema?.$defs?.posts_input).toBeUndefined()\n expect(defaultSchema?.properties?.collectionsInput).toBeUndefined()\n\n // @ts-expect-error partial config\n const enabled: Config = {\n collections: [{ slug: 'posts', fields: [{ name: 'title', type: 'text' }] }],\n typescript: { generateInputTypes: true },\n }\n const { jsonSchema: enabledSchema } = configToJSONSchema(\n await sanitizeConfig(enabled),\n 'text',\n )\n expect(enabledSchema?.$defs?.posts_input).toBeDefined()\n expect(enabledSchema?.properties?.collectionsInput).toBeDefined()\n })\n\n it('should generate Input-suffixed definitions for named interfaces and blocks', async () => {\n // @ts-expect-error partial config\n const config: Config = {\n collections: [\n { slug: 'authors', fields: [{ name: 'name', type: 'text' }] },\n {\n slug: 'pages',\n fields: [\n {\n name: 'meta',\n type: 'group',\n interfaceName: 'Meta',\n fields: [{ name: 'author', type: 'relationship', relationTo: 'authors' }],\n },\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n {\n slug: 'hero',\n fields: [\n { name: 'heading', type: 'text', required: true },\n { name: 'cta', type: 'relationship', relationTo: 'authors' },\n ],\n },\n ],\n },\n ],\n },\n ],\n typescript: { generateInputTypes: true },\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n // Read-shaped named interface keeps the populated-doc union...\n expect((schema?.$defs?.Meta as JSONSchema4).properties!.author).toStrictEqual({\n oneOf: [{ type: ['string', 'null'] }, { $ref: '#/$defs/authors' }],\n })\n // ...and a separate `Input` definition is ID-only, so the two don't collide.\n expect((schema?.$defs?.MetaInput as JSONSchema4).properties!.author).toStrictEqual({\n type: ['string', 'null'],\n })\n\n // Blocks get the same treatment: read-shaped `Hero`, write-shaped `HeroInput`.\n const heroInput = schema?.$defs?.HeroInput as JSONSchema4\n expect(heroInput.properties!.cta).toStrictEqual({ type: ['string', 'null'] })\n expect(heroInput.required).toStrictEqual(['blockType', 'heading'])\n expect((schema?.$defs?.Hero as JSONSchema4).properties!.cta).toStrictEqual({\n oneOf: [{ type: ['string', 'null'] }, { $ref: '#/$defs/authors' }],\n })\n })\n\n it('passes the variant to field-level jsonSchema transforms', async () => {\n // @ts-expect-error partial config\n const config: Config = {\n collections: [\n {\n slug: 'posts',\n fields: [\n {\n name: 'custom',\n type: 'text',\n jsonSchema: [({ jsonSchema, variant }) => ({ ...jsonSchema, description: variant })],\n },\n ],\n },\n ],\n typescript: { generateInputTypes: true },\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect((schema?.$defs?.posts as JSONSchema4).properties!.custom.description).toBe('output')\n expect((schema?.$defs?.posts_input as JSONSchema4).properties!.custom.description).toBe('input')\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'testRequired',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [{ $ref: '#/$defs/Test' }],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [{ $ref: '#/$defs/TestRequired' }],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('keeps the first block interface name clean and content-hashes the colliding one', async () => {\n // @ts-expect-error - partial config for testing\n const config: Config = {\n collections: [\n {\n slug: 'pages',\n fields: [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n { slug: 'hero', fields: [{ name: 'title', type: 'text' }] },\n { slug: 'cta', fields: [{ name: 'label', type: 'text' }] },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n {\n slug: 'posts',\n fields: [\n {\n name: 'layout',\n type: 'blocks',\n // Same slug `hero`, DIFFERENT fields → name collision with pages' hero.\n blocks: [{ slug: 'hero', fields: [{ name: 'heading', type: 'text' }] }],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n const defs = schema.$defs!\n\n // The first `hero` keeps the clean name; the unique block is unaffected.\n expect(defs.Hero).toBeDefined()\n expect(defs.Cta).toBeDefined()\n\n // Only the second, differently-shaped `hero` is disambiguated with a content hash.\n const hashedHeroNames = Object.keys(defs).filter((k) => /^Hero_[0-9A-F]{8}$/.test(k))\n expect(hashedHeroNames).toHaveLength(1)\n\n // The disambiguated interface carries the explanatory JSDoc note; the clean one does not.\n expect((defs[hashedHeroNames[0]!] as { description?: string }).description).toContain(\n 'content hash',\n )\n expect((defs.Hero as { description?: string }).description).toBeUndefined()\n\n // Each collection's block field references its own block's interface.\n const refsOf = (slug: string): string[] =>\n (\n defs[slug] as { properties: { layout: { items: { oneOf: Array<{ $ref: string }> } } } }\n ).properties.layout.items.oneOf.map((r) => r.$ref)\n expect(refsOf('pages')).toContain('#/$defs/Hero')\n expect(refsOf('pages')).toContain('#/$defs/Cta')\n expect(refsOf('posts')).toStrictEqual([`#/$defs/${hashedHeroNames[0]}`])\n\n // Hashing is deterministic: regenerating yields identical names.\n const { jsonSchema: schema2 } = configToJSONSchema(sanitizedConfig, 'text')\n expect(\n Object.keys(schema2.$defs!)\n .filter((k) => /^Hero/.test(k))\n .sort(),\n ).toStrictEqual(\n Object.keys(defs)\n .filter((k) => /^Hero/.test(k))\n .sort(),\n )\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n jsonSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n $ref: '#/$defs/SharedBlock',\n },\n ],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.$defs?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('content-hashes a colliding explicit interfaceName instead of overwriting it', async () => {\n // Two different blocks both set `interfaceName: 'Hero'` - each must keep its own definition.\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blocksField',\n type: 'blocks',\n blocks: [\n {\n slug: 'blockA',\n fields: [{ name: 'title', type: 'text' }],\n interfaceName: 'Hero',\n },\n {\n slug: 'blockB',\n fields: [{ name: 'subtitle', type: 'number' }],\n interfaceName: 'Hero',\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n } as unknown as Config\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema } = configToJSONSchema(sanitizedConfig, 'text')\n const defs = jsonSchema.$defs!\n\n // Each differently-shaped block keeps its own interface (one clean, one hash-suffixed).\n const heroNames = Object.keys(defs).filter((k) => /^Hero(_[0-9A-F]{8})?$/.test(k))\n expect(heroNames).toHaveLength(2)\n\n // ...and they carry distinct field shapes (not a silent overwrite).\n const shapeOf = (name: string): string =>\n Object.keys((defs[name] as { properties: Record<string, unknown> }).properties)\n .sort()\n .join(',')\n expect(shapeOf(heroNames[0]!)).not.toBe(shapeOf(heroNames[1]!))\n })\n\n it('reuses one definition when the same block is registered more than once', async () => {\n // Reusing one block across fields registers an identical schema each time, so it dedupes.\n const heroBlock = {\n slug: 'hero',\n fields: [{ name: 'title', type: 'text' }],\n interfaceName: 'Hero',\n }\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n { name: 'a', type: 'blocks', blocks: [heroBlock] },\n { name: 'b', type: 'blocks', blocks: [heroBlock] },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n } as unknown as Config\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema } = configToJSONSchema(sanitizedConfig, 'text')\n\n const heroNames = Object.keys(jsonSchema.$defs!).filter((k) => /^Hero(_[0-9A-F]{8})?$/.test(k))\n expect(heroNames).toEqual(['Hero'])\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n jsonSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.$defs.test.properties.title.required).toStrictEqual(false)\n })\n\n it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async () => {\n const namedBlock: Block = {\n slug: 'myBlock',\n interfaceName: 'MyBlock',\n fields: [{ name: 'text', type: 'text' }],\n }\n\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'arr',\n type: 'array',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n {\n name: 'grp',\n type: 'group',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n\n // Without forceInlineBlocks: blocks field uses $ref\n const { jsonSchema: schemaDefault } = configToJSONSchema(sanitizedConfig, 'text')\n const arrItemsDefault = schemaDefault.$defs!.test.properties!.arr.items as JSONSchema4\n const arrBlocksDefault = (arrItemsDefault.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksDefault).toStrictEqual({ $ref: '#/$defs/MyBlock' })\n\n // With forceInlineBlocks: blocks field is inlined, no $ref\n const { jsonSchema: schemaInline } = configToJSONSchema(sanitizedConfig, 'text', undefined, {\n forceInlineBlocks: true,\n })\n const arrItemsInline = schemaInline.$defs!.test.properties!.arr.items as JSONSchema4\n const arrBlocksInline = (arrItemsInline.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksInline).not.toHaveProperty('$ref')\n expect(arrBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n\n const grpBlocksInline = (\n schemaInline.$defs!.test.properties!.grp.properties!.blocks.items as JSONSchema4\n ).oneOf![0]\n expect(grpBlocksInline).not.toHaveProperty('$ref')\n expect(grpBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n })\n\n it('entityToStandaloneJSONSchema bundles only the definitions an entity references', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [{ name: 'title', type: 'text' }],\n }\n\n // @ts-expect-error partial config\n const config: Config = {\n admin: {\n timezones: {\n supportedTimezones: [\n { label: 'UTC', value: 'UTC' },\n { label: 'New York', value: 'America/New_York' },\n ],\n },\n },\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'with-refs',\n fields: [\n { name: 'layout', type: 'blocks', blocks: ['sharedBlock'] },\n { name: 'when', type: 'date', timezone: true },\n ],\n timestamps: false,\n versions: false,\n },\n {\n slug: 'other',\n fields: [{ name: 'title', type: 'text' }],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const entity = sanitizedConfig.collections.find(\n (collection) => collection.slug === 'with-refs',\n )!\n\n const schema = entityToStandaloneJSONSchema({\n config: sanitizedConfig,\n defaultIDType: 'text',\n entity,\n })\n\n // Has its own $schema, so it resolves on its own.\n expect(schema.$schema).toBe('https://json-schema.org/draft/2020-12/schema')\n\n // The block reference is resolved inline, so it can't dangle.\n const layoutItems = (schema.properties?.layout as JSONSchema4)?.items as JSONSchema4\n const inlinedBlock = (layoutItems?.oneOf?.[0] ?? {}) as JSONSchema4\n expect(inlinedBlock.properties?.blockType).toStrictEqual({ const: 'sharedBlock' })\n expect(inlinedBlock.properties?.title).toBeDefined()\n\n // A timezone field pulls in supportedTimezones from the root config.\n expect(schema.$defs?.supportedTimezones).toBeDefined()\n\n // Doesn't pull in unrelated collections.\n expect(schema.$defs?.other).toBeUndefined()\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","entityToStandaloneJSONSchema","config","collections","slug","fields","name","type","required","timestamps","versions","sanitizedConfig","jsonSchema","schema","$defs","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","defaultValue","options","relationTo","hasMany","typescript","generateInputTypes","postsOutput","posts","toBe","author","oneOf","$ref","categories","posts_input","status","enum","collectionsInput","offByDefault","defaultSchema","toBeUndefined","enabled","enabledSchema","toBeDefined","interfaceName","blocks","Meta","MetaInput","heroInput","HeroInput","cta","Hero","variant","description","custom","blockField","blockFieldRequired","blockFieldWithFields","blockFieldWithFieldsRequired","defs","Cta","hashedHeroNames","Object","keys","filter","k","toHaveLength","toContain","refsOf","layout","map","r","schema2","sort","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","editor","CellComponent","FieldComponent","validate","expectedBlockSchema","blockName","blockType","const","richText","someBlockField","SharedBlock","heroNames","shapeOf","join","not","heroBlock","toEqual","namedBlock","schemaDefault","arrItemsDefault","arr","arrBlocksDefault","schemaInline","undefined","forceInlineBlocks","arrItemsInline","arrBlocksInline","toHaveProperty","grpBlocksInline","grp","admin","timezones","supportedTimezones","value","timezone","entity","find","collection","defaultIDType","$schema","layoutItems","inlinedBlock","other"],"mappings":"AACA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,EAAEC,4BAA4B,QAAQ,0BAAyB;AAG1FL,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,mBAAmB;QACnB,MAAMK,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNC,UAAU;gCACZ;6BACD;wBACH;qBACD;oBACDC,YAAY;oBACZC,UAAU;gBACZ;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMZ,eAAeG;QAC7C,MAAM,EAAEU,YAAYC,MAAM,EAAE,GAAGb,mBAAmBW,iBAAiB;QAEnEb,OAAOe,QAAQC,OAAOC,MAAMC,aAAa,CAAC;YACxCT,MAAM;YACNU,sBAAsB;YACtBC,YAAY;gBACVC,IAAI;oBACFZ,MAAM;gBACR;gBACAa,mBAAmB;oBACjBb,MAAM;wBAAC;wBAAS;qBAAO;oBACvBc,OAAO;wBACLd,MAAM;wBACNU,sBAAsB;wBACtBC,YAAY;4BACVC,IAAI;gCACFZ,MAAM;oCAAC;oCAAU;iCAAO;4BAC1B;4BACAa,mBAAmB;gCACjBb,MAAM;4BACR;wBACF;wBACAC,UAAU;4BAAC;yBAAoB;oBACjC;gBACF;YACF;YAC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mH,UAAU;wBAAK;qBAC9C;oBACDjH,YAAY;oBACZC,UAAU;gBACZ;gBACA;oBACEN,MAAM;oBACNC,QAAQ;wBAAC;4BAAEC,MAAM;4BAASC,MAAM;wBAAO;qBAAE;oBACzCE,YAAY;oBACZC,UAAU;gBACZ;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMZ,eAAeG;QAC7C,MAAMyH,SAAShH,gBAAgBR,WAAW,CAACyH,IAAI,CAC7C,CAACC,aAAeA,WAAWzH,IAAI,KAAK;QAGtC,MAAMS,SAASZ,6BAA6B;YAC1CC,QAAQS;YACRmH,eAAe;YACfH;QACF;QAEA,kDAAkD;QAClD7H,OAAOe,OAAOkH,OAAO,EAAEhG,IAAI,CAAC;QAE5B,8DAA8D;QAC9D,MAAMiG,cAAenH,OAAOK,UAAU,EAAEqD,QAAwBlD;QAChE,MAAM4G,eAAgBD,aAAa/F,OAAO,CAAC,EAAE,IAAI,CAAC;QAClDnC,OAAOmI,aAAa/G,UAAU,EAAE4E,WAAW9E,aAAa,CAAC;YAAE+E,OAAO;QAAc;QAChFjG,OAAOmI,aAAa/G,UAAU,EAAEI,OAAOuB,WAAW;QAElD,qEAAqE;QACrE/C,OAAOe,OAAOC,KAAK,EAAE0G,oBAAoB3E,WAAW;QAEpD,yCAAyC;QACzC/C,OAAOe,OAAOC,KAAK,EAAEoH,OAAOxF,aAAa;IAC3C;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Payload, RequestContext, TypedLocale,
|
|
1
|
+
import type { Payload, RequestContext, TypedLocale, User } from '../index.js';
|
|
2
2
|
import type { PayloadRequest } from '../types/index.js';
|
|
3
3
|
export type CreateLocalReqOptions = {
|
|
4
4
|
context?: RequestContext;
|
|
@@ -7,7 +7,7 @@ export type CreateLocalReqOptions = {
|
|
|
7
7
|
locale?: string;
|
|
8
8
|
req?: Partial<PayloadRequest>;
|
|
9
9
|
urlSuffix?: string;
|
|
10
|
-
user?:
|
|
10
|
+
user?: User;
|
|
11
11
|
};
|
|
12
12
|
type CreateLocalReq = (options: CreateLocalReqOptions, payload: Payload) => Promise<PayloadRequest>;
|
|
13
13
|
export declare const createLocalReq: CreateLocalReq;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLocalReq.d.ts","sourceRoot":"","sources":["../../src/utilities/createLocalReq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"createLocalReq.d.ts","sourceRoot":"","sources":["../../src/utilities/createLocalReq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAsFvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,KAAK,cAAc,GAAG,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;AAEnG,eAAO,MAAM,cAAc,EAAE,cA+D5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/createLocalReq.ts"],"sourcesContent":["import type { Payload, RequestContext, TypedLocale,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/createLocalReq.ts"],"sourcesContent":["import type { Payload, RequestContext, TypedLocale, User } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { getDataLoader } from '../collections/dataloader.js'\nimport { getLocalI18n } from '../translations/getLocalI18n.js'\nimport { sanitizeFallbackLocale } from '../utilities/sanitizeFallbackLocale.js'\n\nfunction getRequestContext(\n req: Partial<PayloadRequest> = { context: null } as unknown as PayloadRequest,\n context: RequestContext = {},\n): RequestContext {\n if (req.context) {\n if (Object.keys(req.context).length === 0 && req.context.constructor === Object) {\n // if req.context is `{}` avoid unnecessary spread\n return context\n } else {\n return { ...req.context, ...context }\n }\n } else {\n return context\n }\n}\n\nconst attachFakeURLProperties = (req: Partial<PayloadRequest>, urlSuffix?: string) => {\n /**\n * *NOTE*\n * If no URL is provided, the local API was called outside\n * the context of a request. Therefore we create a fake URL object.\n * `ts-expect-error` is used below for properties that are 'read-only'.\n * Since they do not exist yet we can safely ignore the error.\n */\n let urlObject: undefined | URL\n\n function getURLObject() {\n if (urlObject) {\n return urlObject\n }\n\n const fallbackURL = `http://${req.host || 'localhost'}${urlSuffix || ''}`\n\n const urlToUse =\n req?.url ||\n (req.payload?.config?.serverURL\n ? `${req.payload?.config.serverURL}${urlSuffix || ''}`\n : fallbackURL)\n\n try {\n urlObject = new URL(urlToUse)\n } catch (_err) {\n req.payload?.logger.error(\n `Failed to create URL object from URL: ${urlToUse}, falling back to ${fallbackURL}`,\n )\n\n urlObject = new URL(fallbackURL)\n }\n\n return urlObject\n }\n\n if (!req.host) {\n req.host = getURLObject().host\n }\n\n if (!req.protocol) {\n req.protocol = getURLObject().protocol\n }\n\n if (!req.pathname) {\n req.pathname = getURLObject().pathname\n }\n\n if (!req.searchParams) {\n // @ts-expect-error eslint-disable-next-line no-param-reassign\n req.searchParams = getURLObject().searchParams\n }\n\n if (!req.origin) {\n // @ts-expect-error eslint-disable-next-line no-param-reassign\n req.origin = getURLObject().origin\n }\n\n if (!req?.url) {\n // @ts-expect-error eslint-disable-next-line no-param-reassign\n req.url = getURLObject().href\n }\n}\n\nexport type CreateLocalReqOptions = {\n context?: RequestContext\n depth?: number\n fallbackLocale?: false | TypedLocale\n locale?: string\n req?: Partial<PayloadRequest>\n urlSuffix?: string\n user?: User\n}\n\ntype CreateLocalReq = (options: CreateLocalReqOptions, payload: Payload) => Promise<PayloadRequest>\n\nexport const createLocalReq: CreateLocalReq = async (\n {\n context,\n depth,\n fallbackLocale,\n locale: localeArg,\n req = {} as PayloadRequest,\n urlSuffix,\n user,\n },\n payload,\n): Promise<PayloadRequest> => {\n const localization = payload.config?.localization\n\n if (localization) {\n const locale = localeArg === '*' ? 'all' : localeArg\n const defaultLocale = localization.defaultLocale\n const localeCandidate = locale || req?.locale || req?.query?.locale\n\n req.locale =\n localeCandidate && typeof localeCandidate === 'string' ? localeCandidate : defaultLocale\n\n const sanitizedFallback = sanitizeFallbackLocale({\n fallbackLocale: fallbackLocale!,\n locale: req.locale,\n localization,\n })\n\n req.fallbackLocale = sanitizedFallback!\n }\n\n const i18n =\n req?.i18n ||\n (await getLocalI18n({ config: payload.config, language: payload.config.i18n.fallbackLanguage }))\n\n if (!req.headers) {\n req.headers = new Headers()\n }\n\n req.context = getRequestContext(req, context)\n req.payloadAPI = req?.payloadAPI || 'local'\n req.payload = payload\n req.i18n = i18n\n req.t = i18n.t\n req.user = user || req?.user || null\n\n // Ensure user.collection is set for auth-related access control\n // TODO (4.0): Instead of silently falling back, throw an error if user.collection is missing\n if (req.user && !req.user.collection) {\n req.user = { ...req.user, collection: payload.config.admin.user }\n }\n\n req.payloadDataLoader = req?.payloadDataLoader || getDataLoader(req as PayloadRequest)\n req.routeParams = req?.routeParams || {}\n req.query = req?.query || {}\n\n if (typeof depth !== 'undefined') {\n req.query.depth = depth\n }\n\n attachFakeURLProperties(req, urlSuffix)\n\n return req as PayloadRequest\n}\n"],"names":["getDataLoader","getLocalI18n","sanitizeFallbackLocale","getRequestContext","req","context","Object","keys","length","attachFakeURLProperties","urlSuffix","urlObject","getURLObject","fallbackURL","host","urlToUse","url","payload","config","serverURL","URL","_err","logger","error","protocol","pathname","searchParams","origin","href","createLocalReq","depth","fallbackLocale","locale","localeArg","user","localization","defaultLocale","localeCandidate","query","sanitizedFallback","i18n","language","fallbackLanguage","headers","Headers","payloadAPI","t","collection","admin","payloadDataLoader","routeParams"],"mappings":"AAGA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,YAAY,QAAQ,kCAAiC;AAC9D,SAASC,sBAAsB,QAAQ,yCAAwC;AAE/E,SAASC,kBACPC,MAA+B;IAAEC,SAAS;AAAK,CAA8B,EAC7EA,UAA0B,CAAC,CAAC;IAE5B,IAAID,IAAIC,OAAO,EAAE;QACf,IAAIC,OAAOC,IAAI,CAACH,IAAIC,OAAO,EAAEG,MAAM,KAAK,KAAKJ,IAAIC,OAAO,CAAC,WAAW,KAAKC,QAAQ;YAC/E,kDAAkD;YAClD,OAAOD;QACT,OAAO;YACL,OAAO;gBAAE,GAAGD,IAAIC,OAAO;gBAAE,GAAGA,OAAO;YAAC;QACtC;IACF,OAAO;QACL,OAAOA;IACT;AACF;AAEA,MAAMI,0BAA0B,CAACL,KAA8BM;IAC7D;;;;;;GAMC,GACD,IAAIC;IAEJ,SAASC;QACP,IAAID,WAAW;YACb,OAAOA;QACT;QAEA,MAAME,cAAc,CAAC,OAAO,EAAET,IAAIU,IAAI,IAAI,cAAcJ,aAAa,IAAI;QAEzE,MAAMK,WACJX,KAAKY,OACJZ,CAAAA,IAAIa,OAAO,EAAEC,QAAQC,YAClB,GAAGf,IAAIa,OAAO,EAAEC,OAAOC,YAAYT,aAAa,IAAI,GACpDG,WAAU;QAEhB,IAAI;YACFF,YAAY,IAAIS,IAAIL;QACtB,EAAE,OAAOM,MAAM;YACbjB,IAAIa,OAAO,EAAEK,OAAOC,MAClB,CAAC,sCAAsC,EAAER,SAAS,kBAAkB,EAAEF,aAAa;YAGrFF,YAAY,IAAIS,IAAIP;QACtB;QAEA,OAAOF;IACT;IAEA,IAAI,CAACP,IAAIU,IAAI,EAAE;QACbV,IAAIU,IAAI,GAAGF,eAAeE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AAA;KACnB,CAAA;IACD,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"createPayloadRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/createPayloadRequest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,KAAK,EAAkC,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAUvF,KAAK,IAAI,GAAG;IACV,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,MAAM,CAAC,EAAE;QACP,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,qFAMxC,IAAI,KAAG,OAAO,CAAC,cAAc,CA2G/B,CAAA"}
|
|
@@ -35,6 +35,7 @@ export const createPayloadRequest = async ({ canSetHeaders, config: configPromis
|
|
|
35
35
|
let locale = searchParams.get('locale');
|
|
36
36
|
const { search: queryToParse } = urlProperties;
|
|
37
37
|
const query = queryToParse ? qs.parse(queryToParse, {
|
|
38
|
+
allowEmptyArrays: true,
|
|
38
39
|
arrayLimit: 1000,
|
|
39
40
|
depth: 10,
|
|
40
41
|
ignoreQueryPrefix: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/createPayloadRequest.ts"],"sourcesContent":["import { initI18n } from '@payloadcms/translations'\nimport * as qs from 'qs-esm'\n\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { TypedFallbackLocale } from '../index.js'\nimport type { CustomPayloadRequestProperties, PayloadRequest } from '../types/index.js'\n\nimport { executeAuthStrategies } from '../auth/executeAuthStrategies.js'\nimport { getDataLoader } from '../collections/dataloader.js'\nimport { getPayload } from '../index.js'\nimport { sanitizeLocales } from './addLocalesToRequest.js'\nimport { formatAdminURL } from './formatAdminURL.js'\nimport { getRequestLanguage } from './getRequestLanguage.js'\nimport { parseCookies } from './parseCookies.js'\n\ntype Args = {\n canSetHeaders?: boolean\n config: Promise<SanitizedConfig> | SanitizedConfig\n params?: {\n collection: string\n }\n payloadInstanceCacheKey?: string\n request: Request\n}\n\nexport const createPayloadRequest = async ({\n canSetHeaders,\n config: configPromise,\n params,\n payloadInstanceCacheKey,\n request,\n}: Args): Promise<PayloadRequest> => {\n const cookies = parseCookies(request.headers)\n const payload = await getPayload({\n config: configPromise,\n cron: true,\n key: payloadInstanceCacheKey,\n })\n\n const { config } = payload\n const localization = config.localization\n\n const urlProperties = new URL(request.url)\n const { pathname, searchParams } = urlProperties\n\n const isGraphQL =\n !config.graphQL.disable &&\n pathname ===\n formatAdminURL({\n apiRoute: config.routes.api,\n path: config.routes.graphQL as `/${string}`,\n })\n\n const language = getRequestLanguage({\n config,\n cookies,\n headers: request.headers,\n })\n\n const i18n = await initI18n({\n config: config.i18n,\n context: 'api',\n language,\n })\n\n let locale = searchParams.get('locale')\n\n const { search: queryToParse } = urlProperties\n\n const query = queryToParse\n ? qs.parse(queryToParse, {\n arrayLimit: 1000,\n depth: 10,\n ignoreQueryPrefix: true,\n })\n : {}\n\n const fallbackFromRequest = (query.fallbackLocale ||\n searchParams.get('fallback-locale') ||\n searchParams.get('fallbackLocale')) as TypedFallbackLocale\n\n let fallbackLocale = fallbackFromRequest\n\n if (localization) {\n const locales = sanitizeLocales({\n fallbackLocale: fallbackLocale!,\n locale: locale!,\n localization,\n })\n\n fallbackLocale = locales.fallbackLocale!\n locale = locales.locale!\n }\n\n const customRequest: CustomPayloadRequestProperties = {\n context: {},\n fallbackLocale: fallbackLocale!,\n hash: urlProperties.hash,\n host: urlProperties.host,\n href: urlProperties.href,\n i18n,\n locale,\n origin: urlProperties.origin,\n pathname: urlProperties.pathname,\n payload,\n payloadAPI: isGraphQL ? 'GraphQL' : 'REST',\n payloadDataLoader: undefined!,\n payloadUploadSizes: {},\n port: urlProperties.port,\n protocol: urlProperties.protocol,\n query,\n routeParams: params || {},\n search: urlProperties.search,\n searchParams: urlProperties.searchParams,\n t: i18n.t,\n transactionID: undefined,\n user: null,\n }\n\n const req: PayloadRequest = Object.assign(request, customRequest)\n\n req.payloadDataLoader = getDataLoader(req)\n\n const { responseHeaders, user } = await executeAuthStrategies({\n canSetHeaders,\n headers: req.headers,\n isGraphQL,\n payload,\n })\n\n req.user = user\n\n if (responseHeaders) {\n req.responseHeaders = responseHeaders\n }\n\n return req\n}\n"],"names":["initI18n","qs","executeAuthStrategies","getDataLoader","getPayload","sanitizeLocales","formatAdminURL","getRequestLanguage","parseCookies","createPayloadRequest","canSetHeaders","config","configPromise","params","payloadInstanceCacheKey","request","cookies","headers","payload","cron","key","localization","urlProperties","URL","url","pathname","searchParams","isGraphQL","graphQL","disable","apiRoute","routes","api","path","language","i18n","context","locale","get","search","queryToParse","query","parse","arrayLimit","depth","ignoreQueryPrefix","fallbackFromRequest","fallbackLocale","locales","customRequest","hash","host","href","origin","payloadAPI","payloadDataLoader","undefined","payloadUploadSizes","port","protocol","routeParams","t","transactionID","user","req","Object","assign","responseHeaders"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,YAAYC,QAAQ,SAAQ;AAM5B,SAASC,qBAAqB,QAAQ,mCAAkC;AACxE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,UAAU,QAAQ,cAAa;AACxC,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAYhD,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,aAAa,EACbC,QAAQC,aAAa,EACrBC,MAAM,EACNC,uBAAuB,EACvBC,OAAO,EACF;IACL,MAAMC,UAAUR,aAAaO,QAAQE,OAAO;IAC5C,MAAMC,UAAU,MAAMd,WAAW;QAC/BO,QAAQC;QACRO,MAAM;QACNC,KAAKN;IACP;IAEA,MAAM,EAAEH,MAAM,EAAE,GAAGO;IACnB,MAAMG,eAAeV,OAAOU,YAAY;IAExC,MAAMC,gBAAgB,IAAIC,IAAIR,QAAQS,GAAG;IACzC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGJ;IAEnC,MAAMK,YACJ,CAAChB,OAAOiB,OAAO,CAACC,OAAO,IACvBJ,aACEnB,eAAe;QACbwB,UAAUnB,OAAOoB,MAAM,CAACC,GAAG;QAC3BC,MAAMtB,OAAOoB,MAAM,CAACH,OAAO;IAC7B;IAEJ,MAAMM,WAAW3B,mBAAmB;QAClCI;QACAK;QACAC,SAASF,QAAQE,OAAO;IAC1B;IAEA,MAAMkB,OAAO,MAAMnC,SAAS;QAC1BW,QAAQA,OAAOwB,IAAI;QACnBC,SAAS;QACTF;IACF;IAEA,IAAIG,SAASX,aAAaY,GAAG,CAAC;IAE9B,MAAM,EAAEC,QAAQC,YAAY,EAAE,GAAGlB;IAEjC,MAAMmB,QAAQD,eACVvC,GAAGyC,KAAK,CAACF,cAAc;QACrBG,YAAY;QACZC,OAAO;QACPC,mBAAmB;IACrB,KACA,CAAC;IAEL,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/createPayloadRequest.ts"],"sourcesContent":["import { initI18n } from '@payloadcms/translations'\nimport * as qs from 'qs-esm'\n\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { TypedFallbackLocale } from '../index.js'\nimport type { CustomPayloadRequestProperties, PayloadRequest } from '../types/index.js'\n\nimport { executeAuthStrategies } from '../auth/executeAuthStrategies.js'\nimport { getDataLoader } from '../collections/dataloader.js'\nimport { getPayload } from '../index.js'\nimport { sanitizeLocales } from './addLocalesToRequest.js'\nimport { formatAdminURL } from './formatAdminURL.js'\nimport { getRequestLanguage } from './getRequestLanguage.js'\nimport { parseCookies } from './parseCookies.js'\n\ntype Args = {\n canSetHeaders?: boolean\n config: Promise<SanitizedConfig> | SanitizedConfig\n params?: {\n collection: string\n }\n payloadInstanceCacheKey?: string\n request: Request\n}\n\nexport const createPayloadRequest = async ({\n canSetHeaders,\n config: configPromise,\n params,\n payloadInstanceCacheKey,\n request,\n}: Args): Promise<PayloadRequest> => {\n const cookies = parseCookies(request.headers)\n const payload = await getPayload({\n config: configPromise,\n cron: true,\n key: payloadInstanceCacheKey,\n })\n\n const { config } = payload\n const localization = config.localization\n\n const urlProperties = new URL(request.url)\n const { pathname, searchParams } = urlProperties\n\n const isGraphQL =\n !config.graphQL.disable &&\n pathname ===\n formatAdminURL({\n apiRoute: config.routes.api,\n path: config.routes.graphQL as `/${string}`,\n })\n\n const language = getRequestLanguage({\n config,\n cookies,\n headers: request.headers,\n })\n\n const i18n = await initI18n({\n config: config.i18n,\n context: 'api',\n language,\n })\n\n let locale = searchParams.get('locale')\n\n const { search: queryToParse } = urlProperties\n\n const query = queryToParse\n ? qs.parse(queryToParse, {\n allowEmptyArrays: true,\n arrayLimit: 1000,\n depth: 10,\n ignoreQueryPrefix: true,\n })\n : {}\n\n const fallbackFromRequest = (query.fallbackLocale ||\n searchParams.get('fallback-locale') ||\n searchParams.get('fallbackLocale')) as TypedFallbackLocale\n\n let fallbackLocale = fallbackFromRequest\n\n if (localization) {\n const locales = sanitizeLocales({\n fallbackLocale: fallbackLocale!,\n locale: locale!,\n localization,\n })\n\n fallbackLocale = locales.fallbackLocale!\n locale = locales.locale!\n }\n\n const customRequest: CustomPayloadRequestProperties = {\n context: {},\n fallbackLocale: fallbackLocale!,\n hash: urlProperties.hash,\n host: urlProperties.host,\n href: urlProperties.href,\n i18n,\n locale,\n origin: urlProperties.origin,\n pathname: urlProperties.pathname,\n payload,\n payloadAPI: isGraphQL ? 'GraphQL' : 'REST',\n payloadDataLoader: undefined!,\n payloadUploadSizes: {},\n port: urlProperties.port,\n protocol: urlProperties.protocol,\n query,\n routeParams: params || {},\n search: urlProperties.search,\n searchParams: urlProperties.searchParams,\n t: i18n.t,\n transactionID: undefined,\n user: null,\n }\n\n const req: PayloadRequest = Object.assign(request, customRequest)\n\n req.payloadDataLoader = getDataLoader(req)\n\n const { responseHeaders, user } = await executeAuthStrategies({\n canSetHeaders,\n headers: req.headers,\n isGraphQL,\n payload,\n })\n\n req.user = user\n\n if (responseHeaders) {\n req.responseHeaders = responseHeaders\n }\n\n return req\n}\n"],"names":["initI18n","qs","executeAuthStrategies","getDataLoader","getPayload","sanitizeLocales","formatAdminURL","getRequestLanguage","parseCookies","createPayloadRequest","canSetHeaders","config","configPromise","params","payloadInstanceCacheKey","request","cookies","headers","payload","cron","key","localization","urlProperties","URL","url","pathname","searchParams","isGraphQL","graphQL","disable","apiRoute","routes","api","path","language","i18n","context","locale","get","search","queryToParse","query","parse","allowEmptyArrays","arrayLimit","depth","ignoreQueryPrefix","fallbackFromRequest","fallbackLocale","locales","customRequest","hash","host","href","origin","payloadAPI","payloadDataLoader","undefined","payloadUploadSizes","port","protocol","routeParams","t","transactionID","user","req","Object","assign","responseHeaders"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,YAAYC,QAAQ,SAAQ;AAM5B,SAASC,qBAAqB,QAAQ,mCAAkC;AACxE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,UAAU,QAAQ,cAAa;AACxC,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAYhD,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,aAAa,EACbC,QAAQC,aAAa,EACrBC,MAAM,EACNC,uBAAuB,EACvBC,OAAO,EACF;IACL,MAAMC,UAAUR,aAAaO,QAAQE,OAAO;IAC5C,MAAMC,UAAU,MAAMd,WAAW;QAC/BO,QAAQC;QACRO,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AAUH,cAAcG,QAAQ;QAChCP;QACAqC,YAAY5B,YAAY,YAAY;QACpC6B,mBAAmBC;QACnBC,oBAAoB,CAAC;QACrBC,MAAMrC,cAAcqC,IAAI;QACxBC,UAAUtC,cAAcsC,QAAQ;QAChCnB;QACAoB,aAAahD,UAAU,CAAC;QACxB0B,QAAQjB,cAAciB,MAAM;QAC5Bb,cAAcJ,cAAcI,YAAY;QACxCoC,GAAG3B,KAAK2B,CAAC;QACTC,eAAeN;QACfO,MAAM;IACR;IAEA,MAAMC,MAAsBC,OAAOC,MAAM,CAACpD,SAASmC;IAEnDe,IAAIT,iBAAiB,GAAGrD,cAAc8D;IAEtC,MAAM,EAAEG,eAAe,EAAEJ,IAAI,EAAE,GAAG,MAAM9D,sBAAsB;QAC5DQ;QACAO,SAASgD,IAAIhD,OAAO;QACpBU;QACAT;IACF;IAEA+C,IAAID,IAAI,GAAGA;IAEX,IAAII,iBAAiB;QACnBH,IAAIG,eAAe,GAAGA;IACxB;IAEA,OAAOH;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepCopyObject.d.ts","sourceRoot":"","sources":["../../src/utilities/deepCopyObject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AA2DlD,eAAO,MAAM,cAAc,GAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"deepCopyObject.d.ts","sourceRoot":"","sources":["../../src/utilities/deepCopyObject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AA2DlD,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,GAAG,CAAC,KAAG,CAiCxC,CAAA;AAQD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,eAAe,UAAQ,GAAG,CAAC,CA6B9F;AAED,wBAAgB,0CAA0C,CAAC,CAAC,SAAS,SAAS,EAC5E,KAAK,EAAE,CAAC,EACR,IAAI,GAAE;IACJ,YAAY,CAAC,EAAE,OAAO,CAAA;CAClB,GACL,CAAC,CAuCH;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,GAAE,OAAO,CAAC,GAAG,EAAE,GAAG,CAAiB,GAAG,CAAC,CAqE/F"}
|
|
@@ -103,6 +103,11 @@ Benchmark: https://github.com/AlessioGr/fastest-deep-clone-json/blob/main/test/b
|
|
|
103
103
|
if (value instanceof Date) {
|
|
104
104
|
return new Date(value);
|
|
105
105
|
}
|
|
106
|
+
// BSON ObjectId instances expose extra enumerable properties (e.g. `buffer`) via `for...in`
|
|
107
|
+
// that corrupt the copy. Detect BSON types early and convert them to their string representation.
|
|
108
|
+
if ('_bsontype' in value && typeof value.toHexString === 'function') {
|
|
109
|
+
return value.toHexString();
|
|
110
|
+
}
|
|
106
111
|
const ret = {};
|
|
107
112
|
for(const k in value){
|
|
108
113
|
const v = value[k];
|
|
@@ -132,6 +137,9 @@ export function deepCopyObjectSimpleWithoutReactComponents(value, opts = {}) {
|
|
|
132
137
|
if (value instanceof Date) {
|
|
133
138
|
return new Date(value);
|
|
134
139
|
}
|
|
140
|
+
if ('_bsontype' in value && typeof value.toHexString === 'function') {
|
|
141
|
+
return value.toHexString();
|
|
142
|
+
}
|
|
135
143
|
const ret = {};
|
|
136
144
|
for(const k in value){
|
|
137
145
|
const v = value[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/deepCopyObject.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { JsonValue } from '../types/index.js'\n\n/*\nMain deepCopyObject handling - from rfdc: https://github.com/davidmarkclements/rfdc/blob/master/index.js\n\nCopyright 2019 \"David Mark Clements <david.mark.clements@gmail.com>\"\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and\nto permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions\nof the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\nTO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\nCONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n*/\n\nfunction copyBuffer(cur: any) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nconst constructorHandlers = new Map()\nconstructorHandlers.set(Date, (o: any) => new Date(o))\nconstructorHandlers.set(Map, (o: any, fn: any) => new Map(cloneArray<any>(Array.from(o), fn)))\nconstructorHandlers.set(Set, (o: any, fn: any) => new Set(cloneArray(Array.from(o), fn)))\nconstructorHandlers.set(RegExp, (regex: RegExp) => new RegExp(regex.source, regex.flags))\n\nlet handler: ((o: any, fn: any) => any) | null = null\n\nfunction cloneArray<T extends object>(a: T, fn: (o: any) => any): T {\n const keys = Object.keys(a)\n const a2 = new Array(keys.length) as T\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i] as keyof typeof a\n const cur = a[k] as any\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof RegExp) {\n a2[k] = new RegExp(cur.source, cur.flags) as any\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n a2[k] = handler(cur, fn)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2\n}\n\nexport const deepCopyObject = <T>(o: T): T => {\n if (typeof o !== 'object' || o === null) {\n return o\n }\n if (Array.isArray(o)) {\n return cloneArray(o, deepCopyObject)\n }\n if (o instanceof RegExp) {\n return new RegExp(o.source, o.flags) as T\n }\n\n if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {\n return handler(o, deepCopyObject)\n }\n const o2 = {} as T\n for (const k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) {\n continue\n }\n const cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof RegExp) {\n o2[k] = new RegExp(cur.source, cur.flags) as any\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n o2[k] = handler(cur, deepCopyObject)\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = deepCopyObject(cur)\n }\n }\n return o2\n}\n\n/*\nFast deepCopyObjectSimple handling - from fast-json-clone: https://github.com/rhysd/fast-json-clone\n\nBenchmark: https://github.com/AlessioGr/fastest-deep-clone-json/blob/main/test/benchmark.js\n*/\n\n/**\n * A deepCopyObject implementation which only works for JSON objects and arrays, and is faster than\n * JSON.parse(JSON.stringify(obj))\n *\n * @param value The JSON value to be cloned. There are two invariants. 1) It must not contain circles\n * as JSON does not allow it. This function will cause infinite loop for such values by\n * design. 2) It must contain JSON values only. Other values like `Date`, `Regexp`, `Map`,\n * `Set`, `Buffer`, ... are not allowed.\n * @returns The cloned JSON value.\n */\nexport function deepCopyObjectSimple<T extends JsonValue>(value: T, filterUndefined = false): T {\n if (typeof value !== 'object' || value === null) {\n return value\n } else if (Array.isArray(value)) {\n return value.map((e) =>\n typeof e !== 'object' || e === null ? e : deepCopyObjectSimple(e, filterUndefined),\n ) as T\n } else {\n if (value instanceof Date) {\n return new Date(value) as unknown as T\n }\n const ret: { [key: string]: T } = {}\n for (const k in value) {\n const v = value[k]\n if (filterUndefined && v === undefined) {\n continue\n }\n ret[k] =\n typeof v !== 'object' || v === null\n ? v\n : (deepCopyObjectSimple(v as T, filterUndefined) as any)\n }\n return ret as unknown as T\n }\n}\n\nexport function deepCopyObjectSimpleWithoutReactComponents<T extends JsonValue>(\n value: T,\n opts: {\n excludeFiles?: boolean\n } = {},\n): T {\n if (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n typeof value.$$typeof === 'symbol'\n ) {\n return undefined!\n } else if (typeof value !== 'object' || value === null) {\n return value\n } else if (Array.isArray(value)) {\n return value.map((e) =>\n typeof e !== 'object' || e === null ? e : deepCopyObjectSimpleWithoutReactComponents(e, opts),\n ) as T\n } else {\n // Handle File objects by returning them as-is (don't serialize to plain object) or exclude if excludeFiles is provided\n if (value instanceof File) {\n if (opts.excludeFiles) {\n return undefined!\n }\n\n return value as unknown as T\n }\n if (value instanceof Date) {\n return new Date(value) as unknown as T\n }\n const ret: { [key: string]: T } = {}\n for (const k in value) {\n const v = value[k]\n ret[k] =\n typeof v !== 'object' || v === null\n ? v\n : (deepCopyObjectSimpleWithoutReactComponents(v as T, opts) as any)\n }\n return ret as unknown as T\n }\n}\n\n/**\n * A deepCopyObject implementation which is slower than deepCopyObject, but more correct.\n * Can be used if correctness is more important than speed. Supports circular dependencies\n */\nexport function deepCopyObjectComplex<T>(object: T, cache: WeakMap<any, any> = new WeakMap()): T {\n if (object === null) {\n return null!\n }\n\n if (cache.has(object)) {\n return cache.get(object)\n }\n\n // Handle File\n if (object instanceof File) {\n return object as unknown as T\n }\n\n // Handle Date\n if (object instanceof Date) {\n return new Date(object.getTime()) as unknown as T\n }\n\n // Handle RegExp\n if (object instanceof RegExp) {\n return new RegExp(object.source, object.flags) as unknown as T\n }\n\n // Handle Map\n if (object instanceof Map) {\n const clonedMap = new Map()\n cache.set(object, clonedMap)\n for (const [key, value] of object.entries()) {\n clonedMap.set(key, deepCopyObjectComplex(value, cache))\n }\n return clonedMap as unknown as T\n }\n\n // Handle Set\n if (object instanceof Set) {\n const clonedSet = new Set()\n cache.set(object, clonedSet)\n for (const value of object.values()) {\n clonedSet.add(deepCopyObjectComplex(value, cache))\n }\n return clonedSet as unknown as T\n }\n\n // Handle Array and Object\n if (typeof object === 'object' && object !== null) {\n if ('$$typeof' in object && typeof object.$$typeof === 'symbol') {\n return object\n }\n\n const clonedObject: any = Array.isArray(object)\n ? []\n : Object.create(Object.getPrototypeOf(object))\n cache.set(object, clonedObject)\n\n for (const key in object) {\n if (\n Object.prototype.hasOwnProperty.call(object, key) ||\n Object.getOwnPropertySymbols(object).includes(key as any)\n ) {\n clonedObject[key] = deepCopyObjectComplex(object[key], cache)\n }\n }\n\n return clonedObject as T\n }\n\n // Handle all other cases\n return object\n}\n"],"names":["copyBuffer","cur","Buffer","from","buffer","slice","byteOffset","length","constructorHandlers","Map","set","Date","o","fn","cloneArray","Array","Set","RegExp","regex","source","flags","handler","a","keys","Object","a2","i","k","get","ArrayBuffer","isView","deepCopyObject","isArray","o2","hasOwnProperty","call","deepCopyObjectSimple","value","filterUndefined","map","e","ret","v","undefined","deepCopyObjectSimpleWithoutReactComponents","opts","$$typeof","File","excludeFiles","deepCopyObjectComplex","object","cache","WeakMap","has","getTime","clonedMap","key","entries","clonedSet","values","add","clonedObject","create","getPrototypeOf","prototype","getOwnPropertySymbols","includes"],"mappings":"AAAA,qDAAqD,GAGrD;;;;;;;;;;;;;;;;;;AAkBA,GAEA,SAASA,WAAWC,GAAQ;IAC1B,IAAIA,eAAeC,QAAQ;QACzB,OAAOA,OAAOC,IAAI,CAACF;IACrB;IAEA,OAAO,IAAIA,IAAI,WAAW,CAACA,IAAIG,MAAM,CAACC,KAAK,IAAIJ,IAAIK,UAAU,EAAEL,IAAIM,MAAM;AAC3E;AAEA,MAAMC,sBAAsB,IAAIC;AAChCD,oBAAoBE,GAAG,CAACC,MAAM,CAACC,IAAW,IAAID,KAA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B,OAAOwC,SAAS,CAAC9B,cAAc,CAACC,IAAI,CAACe,QAAQM,QAC7ChC,OAAOyC,qBAAqB,CAACf,QAAQgB,QAAQ,CAACV,MAC9C;gBACAK,YAAY,CAACL,IAAI,GAAGP,sBAAsBC,MAAM,CAACM,IAAI,EAAEL;YACzD;QACF;QAEA,OAAOU;IACT;IAEA,yBAAyB;IACzB,OAAOX;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/deepCopyObject.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { JsonValue } from '../types/index.js'\n\n/*\nMain deepCopyObject handling - from rfdc: https://github.com/davidmarkclements/rfdc/blob/master/index.js\n\nCopyright 2019 \"David Mark Clements <david.mark.clements@gmail.com>\"\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and\nto permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions\nof the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\nTO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\nCONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n*/\n\nfunction copyBuffer(cur: any) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nconst constructorHandlers = new Map()\nconstructorHandlers.set(Date, (o: any) => new Date(o))\nconstructorHandlers.set(Map, (o: any, fn: any) => new Map(cloneArray<any>(Array.from(o), fn)))\nconstructorHandlers.set(Set, (o: any, fn: any) => new Set(cloneArray(Array.from(o), fn)))\nconstructorHandlers.set(RegExp, (regex: RegExp) => new RegExp(regex.source, regex.flags))\n\nlet handler: ((o: any, fn: any) => any) | null = null\n\nfunction cloneArray<T extends object>(a: T, fn: (o: any) => any): T {\n const keys = Object.keys(a)\n const a2 = new Array(keys.length) as T\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i] as keyof typeof a\n const cur = a[k] as any\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof RegExp) {\n a2[k] = new RegExp(cur.source, cur.flags) as any\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n a2[k] = handler(cur, fn)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2\n}\n\nexport const deepCopyObject = <T>(o: T): T => {\n if (typeof o !== 'object' || o === null) {\n return o\n }\n if (Array.isArray(o)) {\n return cloneArray(o, deepCopyObject)\n }\n if (o instanceof RegExp) {\n return new RegExp(o.source, o.flags) as T\n }\n\n if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {\n return handler(o, deepCopyObject)\n }\n const o2 = {} as T\n for (const k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) {\n continue\n }\n const cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof RegExp) {\n o2[k] = new RegExp(cur.source, cur.flags) as any\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n o2[k] = handler(cur, deepCopyObject)\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = deepCopyObject(cur)\n }\n }\n return o2\n}\n\n/*\nFast deepCopyObjectSimple handling - from fast-json-clone: https://github.com/rhysd/fast-json-clone\n\nBenchmark: https://github.com/AlessioGr/fastest-deep-clone-json/blob/main/test/benchmark.js\n*/\n\n/**\n * A deepCopyObject implementation which only works for JSON objects and arrays, and is faster than\n * JSON.parse(JSON.stringify(obj))\n *\n * @param value The JSON value to be cloned. There are two invariants. 1) It must not contain circles\n * as JSON does not allow it. This function will cause infinite loop for such values by\n * design. 2) It must contain JSON values only. Other values like `Date`, `Regexp`, `Map`,\n * `Set`, `Buffer`, ... are not allowed.\n * @returns The cloned JSON value.\n */\nexport function deepCopyObjectSimple<T extends JsonValue>(value: T, filterUndefined = false): T {\n if (typeof value !== 'object' || value === null) {\n return value\n } else if (Array.isArray(value)) {\n return value.map((e) =>\n typeof e !== 'object' || e === null ? e : deepCopyObjectSimple(e, filterUndefined),\n ) as T\n } else {\n if (value instanceof Date) {\n return new Date(value) as unknown as T\n }\n // BSON ObjectId instances expose extra enumerable properties (e.g. `buffer`) via `for...in`\n // that corrupt the copy. Detect BSON types early and convert them to their string representation.\n if ('_bsontype' in value && typeof (value as any).toHexString === 'function') {\n return (value as any).toHexString() as unknown as T\n }\n const ret: { [key: string]: T } = {}\n for (const k in value) {\n const v = value[k]\n if (filterUndefined && v === undefined) {\n continue\n }\n ret[k] =\n typeof v !== 'object' || v === null\n ? v\n : (deepCopyObjectSimple(v as T, filterUndefined) as any)\n }\n return ret as unknown as T\n }\n}\n\nexport function deepCopyObjectSimpleWithoutReactComponents<T extends JsonValue>(\n value: T,\n opts: {\n excludeFiles?: boolean\n } = {},\n): T {\n if (\n typeof value === 'object' &&\n value !== null &&\n '$$typeof' in value &&\n typeof value.$$typeof === 'symbol'\n ) {\n return undefined!\n } else if (typeof value !== 'object' || value === null) {\n return value\n } else if (Array.isArray(value)) {\n return value.map((e) =>\n typeof e !== 'object' || e === null ? e : deepCopyObjectSimpleWithoutReactComponents(e, opts),\n ) as T\n } else {\n // Handle File objects by returning them as-is (don't serialize to plain object) or exclude if excludeFiles is provided\n if (value instanceof File) {\n if (opts.excludeFiles) {\n return undefined!\n }\n\n return value as unknown as T\n }\n if (value instanceof Date) {\n return new Date(value) as unknown as T\n }\n if ('_bsontype' in value && typeof (value as any).toHexString === 'function') {\n return (value as any).toHexString() as unknown as T\n }\n const ret: { [key: string]: T } = {}\n for (const k in value) {\n const v = value[k]\n ret[k] =\n typeof v !== 'object' || v === null\n ? v\n : (deepCopyObjectSimpleWithoutReactComponents(v as T, opts) as any)\n }\n return ret as unknown as T\n }\n}\n\n/**\n * A deepCopyObject implementation which is slower than deepCopyObject, but more correct.\n * Can be used if correctness is more important than speed. Supports circular dependencies\n */\nexport function deepCopyObjectComplex<T>(object: T, cache: WeakMap<any, any> = new WeakMap()): T {\n if (object === null) {\n return null!\n }\n\n if (cache.has(object)) {\n return cache.get(object)\n }\n\n // Handle File\n if (object instanceof File) {\n return object as unknown as T\n }\n\n // Handle Date\n if (object instanceof Date) {\n return new Date(object.getTime()) as unknown as T\n }\n\n // Handle RegExp\n if (object instanceof RegExp) {\n return new RegExp(object.source, object.flags) as unknown as T\n }\n\n // Handle Map\n if (object instanceof Map) {\n const clonedMap = new Map()\n cache.set(object, clonedMap)\n for (const [key, value] of object.entries()) {\n clonedMap.set(key, deepCopyObjectComplex(value, cache))\n }\n return clonedMap as unknown as T\n }\n\n // Handle Set\n if (object instanceof Set) {\n const clonedSet = new Set()\n cache.set(object, clonedSet)\n for (const value of object.values()) {\n clonedSet.add(deepCopyObjectComplex(value, cache))\n }\n return clonedSet as unknown as T\n }\n\n // Handle Array and Object\n if (typeof object === 'object' && object !== null) {\n if ('$$typeof' in object && typeof object.$$typeof === 'symbol') {\n return object\n }\n\n const clonedObject: any = Array.isArray(object)\n ? []\n : Object.create(Object.getPrototypeOf(object))\n cache.set(object, clonedObject)\n\n for (const key in object) {\n if (\n Object.prototype.hasOwnProperty.call(object, key) ||\n Object.getOwnPropertySymbols(object).includes(key as any)\n ) {\n clonedObject[key] = deepCopyObjectComplex(object[key], cache)\n }\n }\n\n return clonedObject as T\n }\n\n // Handle all other cases\n return object\n}\n"],"names":["copyBuffer","cur","Buffer","from","buffer","slice","byteOffset","length","constructorHandlers","Map","set","Date","o","fn","cloneArray","Array","Set","RegExp","regex","source","flags","handler","a","keys","Object","a2","i","k","get","ArrayBuffer","isView","deepCopyObject","isArray","o2","hasOwnProperty","call","deepCopyObjectSimple","value","filterUndefined","map","e","toHexString","ret","v","undefined","deepCopyObjectSimpleWithoutReactComponents","opts","$$typeof","File","excludeFiles","deepCopyObjectComplex","object","cache","WeakMap","has","getTime","clonedMap","key","entries","clonedSet","values","add","clonedObject","create","getPrototypeOf","prototype","getOwnPropertySymbols","includes"],"mappings":"AAAA,qDAAqD,GAGrD;;;;;;;;;;;;;;;;;;AAkBA,GAEA,SAASA,WAAWC,GAAQ;IAC1B,IAAIA,eAAeC,QAAQ;QACzB,OAAOA,OAAOC,IAAI,CAACF;IACrB;IAEA,OAAO,IAAIA,IAAI,WAAW,CAACA,IAAIG,MAAM,CAACC,KAAK,IAAIJ,IAAIK,UAAU,EAAEL,IAAIM,MAAM;AAC3E;AAEA,MAAMC,sBAAsB,IAAIC;AAChCD,oBAAoBE,GAAG,CAACC,MAAM,CAACC,IAAW,IAAID,KAAKC;AACnDJ,oBAAoBE,GAAG,CAACD,KAAK,CAACG,GAAQC,KAAY,IAAIJ,IAAIK,WAAgBC,MAAMZ,IAAI,CAACS,IAAIC;AACzFL,oBAAoBE,GAAG,CAACM,KAAK,CAACJ,GAAQC,KAAY,IAAIG,IAAIF,WAAWC,MAAMZ,IAAI,CAACS,IAAIC;AACpFL,oBAAoBE,GAAG,CAACO,QAAQ,CAACC,QAAkB,IAAID,OAAOC,MAAMC,MAAM,EAAED,MAAME,KAAK;AAEvF,IAAIC,UAA6C;AAEjD,SAASP,WAA6BQ,CAAI,EAAET,EAAmB;IAC7D,MAAMU,OAAOC,OAAOD,IAAI,CAACD;IACzB,MAAMG,KAAK,IAAIV,MAAMQ,KAAKhB,MAAM;IAChC,IAAK,IAAImB,IAA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
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
-
import { getDependencies } from '
|
|
3
|
+
import { getDependencies } from './getDependencies.js';
|
|
4
4
|
import { compareVersions } from './versionUtils.js';
|
|
5
5
|
const filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const dirname = path.dirname(filename);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/dependencies/dependencyChecker.ts"],"sourcesContent":["import path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport { getDependencies } from '
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/dependencies/dependencyChecker.ts"],"sourcesContent":["import path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport { getDependencies } from './getDependencies.js'\nimport { compareVersions } from './versionUtils.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nexport type CustomVersionParser = (version: string) => { parts: number[]; preReleases: string[] }\n\nexport type DependencyCheckerArgs = {\n /**\n * Define dependency groups to ensure that all dependencies within that group are on the same version, and that no dependencies in that group with different versions are found\n */\n dependencyGroups?: {\n dependencies: string[]\n /**\n * Name of the dependency group to be displayed in the error message\n */\n name: string\n targetVersion?: string\n targetVersionDependency?: string\n }[]\n /**\n * Dependency package names keyed to their required versions. Supports >= (greater or equal than version) as a prefix, or no prefix for the exact version\n */\n dependencyVersions?: {\n [dependency: string]: {\n customVersionParser?: CustomVersionParser\n required?: boolean\n version?: string\n }\n }\n}\n\nexport async function checkDependencies({\n dependencyGroups,\n dependencyVersions,\n}: DependencyCheckerArgs): Promise<void> {\n if (dependencyGroups?.length) {\n for (const dependencyGroup of dependencyGroups) {\n const resolvedDependencies = await getDependencies(dirname, dependencyGroup.dependencies)\n\n // Go through each resolved dependency. If any dependency has a mismatching version, throw an error\n const foundVersions: {\n [version: string]: string\n } = {}\n for (const [_pkg, { version }] of resolvedDependencies.resolved) {\n if (!Object.keys(foundVersions).includes(version)) {\n foundVersions[version] = _pkg\n }\n }\n if (Object.keys(foundVersions).length > 1) {\n const targetVersion =\n dependencyGroup.targetVersion ??\n resolvedDependencies.resolved.get(dependencyGroup.targetVersionDependency!)?.version\n if (targetVersion) {\n const formattedVersionsWithPackageNameString = Object.entries(foundVersions)\n .filter(([version]) => version !== targetVersion)\n .map(([version, pkg]) => `${pkg}@${version} (Please change this to ${targetVersion})`)\n .join(', ')\n throw new Error(\n `Mismatching \"${dependencyGroup.name}\" dependency versions found: ${formattedVersionsWithPackageNameString}. All \"${dependencyGroup.name}\" packages must have the same version. This is an error with your set-up, not a bug in Payload. Please go to your package.json and ensure all \"${dependencyGroup.name}\" packages have the same version.`,\n )\n } else {\n const formattedVersionsWithPackageNameString = Object.entries(foundVersions)\n .map(([version, pkg]) => `${pkg}@${version}`)\n .join(', ')\n throw new Error(\n `Mismatching \"${dependencyGroup.name}\" dependency versions found: ${formattedVersionsWithPackageNameString}. All \"${dependencyGroup.name}\" packages must have the same version. This is an error with your set-up, not a bug in Payload. Please go to your package.json and ensure all \"${dependencyGroup.name}\" packages have the same version.`,\n )\n }\n }\n }\n }\n\n if (dependencyVersions && Object.keys(dependencyVersions).length) {\n const resolvedDependencies = await getDependencies(dirname, Object.keys(dependencyVersions))\n for (const [dependency, settings] of Object.entries(dependencyVersions)) {\n const resolvedDependency = resolvedDependencies.resolved.get(dependency)\n if (!resolvedDependency) {\n if (!settings.required) {\n continue\n }\n throw new Error(`Dependency ${dependency} not found. Please ensure it is installed.`)\n }\n\n if (settings.version) {\n const settingsVersionToCheck = settings.version.startsWith('>=')\n ? settings.version.slice(2)\n : settings.version\n\n const versionCompareResult = compareVersions(\n resolvedDependency.version,\n settingsVersionToCheck,\n settings.customVersionParser,\n )\n\n if (settings.version.startsWith('>=')) {\n if (versionCompareResult === 'lower') {\n throw new Error(\n `Dependency ${dependency} is on version ${resolvedDependency.version}, but ${settings.version} or greater is required. Please update this dependency.`,\n )\n }\n } else if (versionCompareResult === 'lower' || versionCompareResult === 'greater') {\n throw new Error(\n `Dependency ${dependency} is on version ${resolvedDependency.version}, but ${settings.version} is required. Please update this dependency.`,\n )\n }\n }\n }\n }\n}\n"],"names":["path","fileURLToPath","getDependencies","compareVersions","filename","url","dirname","checkDependencies","dependencyGroups","dependencyVersions","length","dependencyGroup","resolvedDependencies","dependencies","foundVersions","_pkg","version","resolved","Object","keys","includes","targetVersion","get","targetVersionDependency","formattedVersionsWithPackageNameString","entries","filter","map","pkg","join","Error","name","dependency","settings","resolvedDependency","required","settingsVersionToCheck","startsWith","slice","versionCompareResult","customVersionParser"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAEnC,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,eAAe,QAAQ,oBAAmB;AAEnD,MAAMC,WAAWH,cAAc,YAAYI,GAAG;AAC9C,MAAMC,UAAUN,KAAKM,OAAO,CAACF;AA6B7B,OAAO,eAAeG,kBAAkB,EACtCC,gBAAgB,EAChBC,kBAAkB,EACI;IACtB,IAAID,kBAAkBE,QAAQ;QAC5B,KAAK,MAAMC,mBAAmBH,iBAAkB;YAC9C,MAAMI,uBAAuB,MAAMV,gBAAgBI,SAASK,gBAAgBE,YAAY;YAExF,mGAAmG;YACnG,MAAMC,gBAEF,CAAC;YACL,KAAK,MAAM,CAACC,MAAM,EAAEC,OAAO,EAAE,CAAC,IAAIJ,qBAAqBK,QAAQ,CAAE;gBAC/D,IAAI,CAACC,OAAOC,IAAI,CAACL,eAAeM,QAAQ,CAACJ,UAAU;oBACjDF,aAAa,CAACE,QAAQ,GAAGD;gBAC3B;YACF;YACA,IAAIG,OAAOC,IAAI,CAACL,eAAeJ,MAAM,GAAG,GAAG;gBACzC,MAAMW,gBACJV,gBAAgBU,aAAa,IAC7BT,qBAAqBK,QAAQ,CAACK,GAAG,CAACX,gBAAgBY,uBAAuB,GAAIP;gBAC/E,IAAIK,eAAe;oBACjB,MAAMG,yCAA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SAASjB,OAAO,CAACqB,UAAU,CAAC,QACvDJ,SAASjB,OAAO,CAACsB,KAAK,CAAC,KACvBL,SAASjB,OAAO;gBAEpB,MAAMuB,uBAAuBpC,gBAC3B+B,mBAAmBlB,OAAO,EAC1BoB,wBACAH,SAASO,mBAAmB;gBAG9B,IAAIP,SAASjB,OAAO,CAACqB,UAAU,CAAC,OAAO;oBACrC,IAAIE,yBAAyB,SAAS;wBACpC,MAAM,IAAIT,MACR,CAAC,WAAW,EAAEE,WAAW,eAAe,EAAEE,mBAAmBlB,OAAO,CAAC,MAAM,EAAEiB,SAASjB,OAAO,CAAC,uDAAuD,CAAC;oBAE1J;gBACF,OAAO,IAAIuB,yBAAyB,WAAWA,yBAAyB,WAAW;oBACjF,MAAM,IAAIT,MACR,CAAC,WAAW,EAAEE,WAAW,eAAe,EAAEE,mBAAmBlB,OAAO,CAAC,MAAM,EAAEiB,SAASjB,OAAO,CAAC,4CAA4C,CAAC;gBAE/I;YACF;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDependencies.d.ts","sourceRoot":"","sources":["../../../src/utilities/dependencies/getDependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDependencies.d.ts","sourceRoot":"","sources":["../../../src/utilities/dependencies/getDependencies.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,QAAQ,EAAE,GAAG,CACX,MAAM,EACN;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CACF,CAAA;CACF,CAAA;AAED,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,qBAAqB,CAAC,CA+DhC"}
|
|
@@ -17,12 +17,12 @@ import path from 'path';
|
|
|
17
17
|
import { fileURLToPath } from 'url';
|
|
18
18
|
import { findUp } from '../findUp.js';
|
|
19
19
|
import { resolveFrom } from './resolveFrom.js';
|
|
20
|
-
const filename = fileURLToPath(import.meta.url);
|
|
21
|
-
const dirname = path.dirname(filename);
|
|
22
|
-
const payloadPkgDirname = path.resolve(dirname, '../../../') // pkg dir (outside src)
|
|
23
|
-
;
|
|
24
|
-
const resolvedCwd = path.resolve(process.cwd());
|
|
25
20
|
export async function getDependencies(baseDir, requiredPackages) {
|
|
21
|
+
const filename = fileURLToPath(import.meta.url);
|
|
22
|
+
const dirname = path.dirname(filename);
|
|
23
|
+
const payloadPkgDirname = path.resolve(dirname, '../../../') // pkg dir (outside src)
|
|
24
|
+
;
|
|
25
|
+
const resolvedCwd = path.resolve(process.cwd());
|
|
26
26
|
const resolutions = new Map();
|
|
27
27
|
const missingPackages = [];
|
|
28
28
|
await Promise.all(requiredPackages.map(async (pkg)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/dependencies/getDependencies.ts"],"sourcesContent":["/*\n This source code has been taken and modified from https://github.com/vercel/next.js/blob/41a80533f900467e1b788bd2673abe2dca20be6a/packages/next/src/lib/has-necessary-dependencies.ts\n\n License:\n\n The MIT License (MIT)\n\n Copyright (c) 2024 Vercel, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\nimport { promises as fs } from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport { findUp } from '../findUp.js'\nimport { resolveFrom } from './resolveFrom.js'\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/dependencies/getDependencies.ts"],"sourcesContent":["/*\n This source code has been taken and modified from https://github.com/vercel/next.js/blob/41a80533f900467e1b788bd2673abe2dca20be6a/packages/next/src/lib/has-necessary-dependencies.ts\n\n License:\n\n The MIT License (MIT)\n\n Copyright (c) 2024 Vercel, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\nimport { promises as fs } from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport { findUp } from '../findUp.js'\nimport { resolveFrom } from './resolveFrom.js'\n\nexport type NecessaryDependencies = {\n missing: string[]\n resolved: Map<\n string,\n {\n path: string\n version: string\n }\n >\n}\n\nexport async function getDependencies(\n baseDir: string,\n requiredPackages: string[],\n): Promise<NecessaryDependencies> {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n const payloadPkgDirname = path.resolve(dirname, '../../../') // pkg dir (outside src)\n const resolvedCwd = path.resolve(process.cwd())\n\n const resolutions = new Map<\n string,\n {\n path: string\n version: string\n }\n >()\n const missingPackages: string[] = []\n\n await Promise.all(\n requiredPackages.map(async (pkg) => {\n try {\n const pkgPath = await fs.realpath(resolveFrom(baseDir, pkg))\n const pkgDir = path.dirname(pkgPath)\n\n let packageJsonFilePath: null | string = null\n\n const foundPackageJsonDir = await findUp({\n dir: pkgDir,\n fileNames: ['package.json'],\n })\n\n if (foundPackageJsonDir) {\n const resolvedFoundPath = path.resolve(foundPackageJsonDir)\n\n if (\n resolvedFoundPath.startsWith(resolvedCwd) ||\n resolvedFoundPath.startsWith(payloadPkgDirname)\n ) {\n // We don't want to match node modules outside the user's project. Checking for both process.cwd and dirname is a reliable way to do this.\n packageJsonFilePath = resolvedFoundPath\n }\n }\n\n // No need to check if packageJsonFilePath exists - findUp checks that for us\n if (packageJsonFilePath) {\n // parse version\n const packageJson = JSON.parse(await fs.readFile(packageJsonFilePath, 'utf8'))\n const version = packageJson.version\n\n resolutions.set(pkg, {\n path: packageJsonFilePath,\n version,\n })\n } else {\n return missingPackages.push(pkg)\n }\n } catch (_) {\n return missingPackages.push(pkg)\n }\n }),\n )\n\n return {\n missing: missingPackages,\n resolved: resolutions,\n }\n}\n"],"names":["promises","fs","path","fileURLToPath","findUp","resolveFrom","getDependencies","baseDir","requiredPackages","filename","url","dirname","payloadPkgDirname","resolve","resolvedCwd","process","cwd","resolutions","Map","missingPackages","Promise","all","map","pkg","pkgPath","realpath","pkgDir","packageJsonFilePath","foundPackageJsonDir","dir","fileNames","resolvedFoundPath","startsWith","packageJson","JSON","parse","readFile","version","set","push","_","missing","resolved"],"mappings":"AAAA;;;;;;;;;;;;;;AAcA,GAEA,SAASA,YAAYC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,EAAE,OAAOiB,GAAG;YACV,OAAOrB,gBAAgBoB,IAAI,CAAChB;QAC9B;IACF;IAGF,OAAO;QACLkB,SAAStB;QACTuB,UAAUzB;IACZ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveFrom.d.ts","sourceRoot":"","sources":["../../../src/utilities/dependencies/resolveFrom.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"resolveFrom.d.ts","sourceRoot":"","sources":["../../../src/utilities/dependencies/resolveFrom.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,WAAW,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,EAAE,SAAS,OAAO,QAgDpF,CAAA"}
|
|
@@ -13,7 +13,7 @@ import { pathToFileURL } from 'url';
|
|
|
13
13
|
// Vitest runs tests in a VM context where eval'd dynamic imports fail with
|
|
14
14
|
// ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING. Use direct import in test environment.
|
|
15
15
|
if (process.env.VITEST) {
|
|
16
|
-
return await import(/* webpackIgnore: true */ importPath);
|
|
16
|
+
return await import(/* webpackIgnore: true */ /* @vite-ignore */ importPath);
|
|
17
17
|
}
|
|
18
18
|
// Without the eval, the Next.js bundler will throw this error when encountering the import statement:
|
|
19
19
|
// ⚠ Compiled with warnings in X.Xs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/dynamicImport.ts"],"sourcesContent":["import path from 'path'\nimport { pathToFileURL } from 'url'\n\n/**\n * Dynamically imports a module from a file path or module specifier.\n *\n * Uses a direct `import()` in Vitest (where eval'd imports fail with ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING),\n * and `eval(`import(...)`)` elsewhere to hide the import from Next.js bundler static analysis.\n *\n * @param modulePathOrSpecifier - Either an absolute file path or a module specifier (package name)\n */\nexport async function dynamicImport<T = unknown>(modulePathOrSpecifier: string): Promise<T> {\n // Convert absolute file paths to file:// URLs, but leave package specifiers as-is\n const importPath = path.isAbsolute(modulePathOrSpecifier)\n ? pathToFileURL(modulePathOrSpecifier).href\n : modulePathOrSpecifier\n\n // Vitest runs tests in a VM context where eval'd dynamic imports fail with\n // ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING. Use direct import in test environment.\n if (process.env.VITEST) {\n return await import(/* webpackIgnore: true */ importPath)\n }\n\n // Without the eval, the Next.js bundler will throw this error when encountering the import statement:\n // ⚠ Compiled with warnings in X.Xs\n // Critical dependency: the request of a dependency is an expression\n return await eval(`import('${importPath}')`)\n}\n"],"names":["path","pathToFileURL","dynamicImport","modulePathOrSpecifier","importPath","isAbsolute","href","process","env","VITEST","eval"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAEnC;;;;;;;CAOC,GACD,OAAO,eAAeC,cAA2BC,qBAA6B;IAC5E,kFAAkF;IAClF,MAAMC,aAAaJ,KAAKK,UAAU,CAACF,yBAC/BF,cAAcE,uBAAuBG,IAAI,GACzCH;IAEJ,2EAA2E;IAC3E,iFAAiF;IACjF,IAAII,QAAQC,GAAG,CAACC,MAAM,EAAE;QACtB,OAAO,MAAM,MAAM,CAAC,uBAAuB,GAAGL;
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/dynamicImport.ts"],"sourcesContent":["import path from 'path'\nimport { pathToFileURL } from 'url'\n\n/**\n * Dynamically imports a module from a file path or module specifier.\n *\n * Uses a direct `import()` in Vitest (where eval'd imports fail with ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING),\n * and `eval(`import(...)`)` elsewhere to hide the import from Next.js bundler static analysis.\n *\n * @param modulePathOrSpecifier - Either an absolute file path or a module specifier (package name)\n */\nexport async function dynamicImport<T = unknown>(modulePathOrSpecifier: string): Promise<T> {\n // Convert absolute file paths to file:// URLs, but leave package specifiers as-is\n const importPath = path.isAbsolute(modulePathOrSpecifier)\n ? pathToFileURL(modulePathOrSpecifier).href\n : modulePathOrSpecifier\n\n // Vitest runs tests in a VM context where eval'd dynamic imports fail with\n // ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING. Use direct import in test environment.\n if (process.env.VITEST) {\n return await import(/* webpackIgnore: true */ /* @vite-ignore */ importPath)\n }\n\n // Without the eval, the Next.js bundler will throw this error when encountering the import statement:\n // ⚠ Compiled with warnings in X.Xs\n // Critical dependency: the request of a dependency is an expression\n return await eval(`import('${importPath}')`)\n}\n"],"names":["path","pathToFileURL","dynamicImport","modulePathOrSpecifier","importPath","isAbsolute","href","process","env","VITEST","eval"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAEnC;;;;;;;CAOC,GACD,OAAO,eAAeC,cAA2BC,qBAA6B;IAC5E,kFAAkF;IAClF,MAAMC,aAAaJ,KAAKK,UAAU,CAACF,yBAC/BF,cAAcE,uBAAuBG,IAAI,GACzCH;IAEJ,2EAA2E;IAC3E,iFAAiF;IACjF,IAAII,QAAQC,GAAG,CAACC,MAAM,EAAE;QACtB,OAAO,MAAM,MAAM,CAAC,uBAAuB,GAAG,gBAAgB,GAAGL;IACnE;IAEA,sGAAsG;IACtG,mCAAmC;IACnC,oEAAoE;IACpE,OAAO,MAAMM,KAAK,CAAC,QAAQ,EAAEN,WAAW,EAAE,CAAC;AAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escapeRegExp.d.ts","sourceRoot":"","sources":["../../src/utilities/escapeRegExp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"escapeRegExp.d.ts","sourceRoot":"","sources":["../../src/utilities/escapeRegExp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MACC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractID.d.ts","sourceRoot":"","sources":["../../src/utilities/extractID.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,MAAM,SAAS,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"extractID.d.ts","sourceRoot":"","sources":["../../src/utilities/extractID.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,MAAM,SAAS,MAAM,GAAG,MAAM,EACtD,YAAY;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,KAClC,MAMF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterDataToSelectedLocales.d.ts","sourceRoot":"","sources":["../../src/utilities/filterDataToSelectedLocales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAkB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAInD,KAAK,+BAA+B,GAAG;IACrC,qBAAqB,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IAChD,cAAc,EAAE,UAAU,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B,CAAA;AAuBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,qBAAqB,EACrB,cAAc,EACd,MAAM,EACN,iBAAyB,EACzB,eAAe,GAChB,EAAE,+BAA+B,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"filterDataToSelectedLocales.d.ts","sourceRoot":"","sources":["../../src/utilities/filterDataToSelectedLocales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAkB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAInD,KAAK,+BAA+B,GAAG;IACrC,qBAAqB,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IAChD,cAAc,EAAE,UAAU,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B,CAAA;AAuBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,qBAAqB,EACrB,cAAc,EACd,MAAM,EACN,iBAAyB,EACzB,eAAe,GAChB,EAAE,+BAA+B,GAAG,UAAU,CA8N9C"}
|
|
@@ -66,18 +66,11 @@ import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/
|
|
|
66
66
|
return rows;
|
|
67
67
|
}
|
|
68
68
|
return rows.map((blockData)=>{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
} else {
|
|
75
|
-
block = blockOrReference;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
} else if (field.blocks) {
|
|
79
|
-
block = field.blocks.find((b)=>b.slug === blockData.blockType);
|
|
80
|
-
}
|
|
69
|
+
const blockOrSlug = field.blocks.find((b)=>{
|
|
70
|
+
const slug = typeof b === 'string' ? b : b.slug;
|
|
71
|
+
return slug === blockData.blockType;
|
|
72
|
+
});
|
|
73
|
+
const block = typeof blockOrSlug === 'string' ? configBlockReferences?.find((b)=>b.slug === blockOrSlug) : blockOrSlug;
|
|
81
74
|
if (block) {
|
|
82
75
|
const filtered = filterDataToSelectedLocales({
|
|
83
76
|
configBlockReferences,
|