Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
41353f2
chore: add failing int test
AlessioGr Feb 14, 2025
209b9ad
ensure field localization is properly handled everywhere
AlessioGr Feb 16, 2025
505db12
Merge remote-tracking branch 'origin/main' into fix/block-references-…
AlessioGr Feb 16, 2025
cffe888
remove console.log in now-passing test
AlessioGr Feb 16, 2025
b17520d
prefer env variable over config compatibility property access
AlessioGr Feb 16, 2025
a61431e
fix build
AlessioGr Feb 16, 2025
6d9972e
chore: add PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY env variable fo…
AlessioGr Feb 16, 2025
ae2b3bb
fix logic error
AlessioGr Feb 16, 2025
603418f
work around pg bug
AlessioGr Feb 16, 2025
63e07ff
fix int test
AlessioGr Feb 16, 2025
869461b
fix int test data
AlessioGr Feb 16, 2025
88f3ec5
fix join field localization in postgres
AlessioGr Feb 16, 2025
2c8701b
fix: incorrect leavesFirst implementation in traverseFields utility
AlessioGr Feb 16, 2025
618491d
do not sanitize away field.localized in monorepo, to improve test cov…
AlessioGr Feb 16, 2025
35e9c27
remover no longer needed int test
AlessioGr Feb 16, 2025
475fd5b
address lint error
AlessioGr Feb 16, 2025
2a199d7
handle parentIsLocalized for join field
AlessioGr Feb 17, 2025
8c68ea9
Merge remote-tracking branch 'origin/main' into fix/block-references-…
AlessioGr Feb 17, 2025
63eb416
Merge remote-tracking branch 'origin/main' into fix/block-references-…
AlessioGr Feb 17, 2025
7653386
adjust test
AlessioGr Feb 17, 2025
4e7266e
introduce fieldShouldBeLocalized helper function
AlessioGr Feb 17, 2025
7d9fbaf
make new arguments optional where they'd be a breaking change
AlessioGr Feb 17, 2025
42c8f15
adjust incorrect fieldWithinLocalizedField logic in buildProjectionFr…
AlessioGr Feb 17, 2025
6fc5640
make more args optional
AlessioGr Feb 17, 2025
c05dc59
Merge branch 'main' into fix/block-references-localization
AlessioGr Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const defaultESLintIgnores = [
'next-env.d.ts',
'**/app',
'src/**/*.spec.ts',
'**/jest.setup.js',
]

/** @typedef {import('eslint').Linter.Config} Config */
Expand Down
2 changes: 2 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const config = withBundleAnalyzer(
env: {
PAYLOAD_CORE_DEV: 'true',
ROOT_DIR: path.resolve(dirname),
// @todo remove in 4.0 - will behave like this by default in 4.0
PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY: 'true',
},
async redirects() {
return [
Expand Down
38 changes: 23 additions & 15 deletions packages/db-mongodb/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ export const init: Init = function init(this: MongooseAdapter) {

const versionCollectionFields = buildVersionCollectionFields(this.payload.config, collection)

const versionSchema = buildSchema(this.payload, versionCollectionFields, {
disableUnique: true,
draftsEnabled: true,
indexSortableFields: this.payload.config.indexSortableFields,
options: {
minimize: false,
timestamps: false,
const versionSchema = buildSchema({
buildSchemaOptions: {
disableUnique: true,
draftsEnabled: true,
indexSortableFields: this.payload.config.indexSortableFields,
options: {
minimize: false,
timestamps: false,
},
...schemaOptions,
},
...schemaOptions,
configFields: versionCollectionFields,
payload: this.payload,
})

versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(
Expand Down Expand Up @@ -77,14 +81,18 @@ export const init: Init = function init(this: MongooseAdapter) {

const versionGlobalFields = buildVersionGlobalFields(this.payload.config, global)

const versionSchema = buildSchema(this.payload, versionGlobalFields, {
disableUnique: true,
draftsEnabled: true,
indexSortableFields: this.payload.config.indexSortableFields,
options: {
minimize: false,
timestamps: false,
const versionSchema = buildSchema({
buildSchemaOptions: {
disableUnique: true,
draftsEnabled: true,
indexSortableFields: this.payload.config.indexSortableFields,
options: {
minimize: false,
timestamps: false,
},
},
configFields: versionGlobalFields,
payload: this.payload,
})

versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(
Expand Down
20 changes: 13 additions & 7 deletions packages/db-mongodb/src/models/buildCollectionSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ export const buildCollectionSchema = (
payload: Payload,
schemaOptions = {},
): Schema => {
const schema = buildSchema(payload, collection.fields, {
draftsEnabled: Boolean(typeof collection?.versions === 'object' && collection.versions.drafts),
indexSortableFields: payload.config.indexSortableFields,
options: {
minimize: false,
timestamps: collection.timestamps !== false,
...schemaOptions,
const schema = buildSchema({
buildSchemaOptions: {
draftsEnabled: Boolean(
typeof collection?.versions === 'object' && collection.versions.drafts,
),
indexSortableFields: payload.config.indexSortableFields,
options: {
minimize: false,
timestamps: collection.timestamps !== false,
...schemaOptions,
},
},
configFields: collection.fields,
payload,
})

if (Array.isArray(collection.upload.filenameCompoundIndex)) {
Expand Down
10 changes: 7 additions & 3 deletions packages/db-mongodb/src/models/buildGlobalModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ export const buildGlobalModel = (payload: Payload): GlobalModel | null => {
const Globals = mongoose.model('globals', globalsSchema, 'globals') as unknown as GlobalModel

Object.values(payload.config.globals).forEach((globalConfig) => {
const globalSchema = buildSchema(payload, globalConfig.fields, {
options: {
minimize: false,
const globalSchema = buildSchema({
buildSchemaOptions: {
options: {
minimize: false,
},
},
configFields: globalConfig.fields,
payload,
})
Globals.discriminator(globalConfig.slug, globalSchema)
})
Expand Down
Loading