@payloadcms/db-mongodb 3.64.0-internal.fc1e451 → 3.65.0-canary.0

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.
@@ -5,7 +5,7 @@ import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect
5
5
  import { getGlobal } from './utilities/getEntity.js';
6
6
  import { getSession } from './utilities/getSession.js';
7
7
  import { transform } from './utilities/transform.js';
8
- export const findGlobalVersions = async function findGlobalVersions({ global: globalSlug, limit, locale, page, pagination, req, select, skip, sort: sortArg, where = {} }) {
8
+ export const findGlobalVersions = async function findGlobalVersions({ global: globalSlug, limit = 0, locale, page, pagination, req, select, skip, sort: sortArg, where = {} }) {
9
9
  const { globalConfig, Model } = getGlobal({
10
10
  adapter: this,
11
11
  globalSlug,
@@ -78,7 +78,7 @@ export const findGlobalVersions = async function findGlobalVersions({ global: gl
78
78
  }));
79
79
  };
80
80
  }
81
- if (limit && limit >= 0) {
81
+ if (limit >= 0) {
82
82
  paginationOptions.limit = limit;
83
83
  // limit must also be set here, it's ignored when pagination is false
84
84
  paginationOptions.options.limit = limit;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindGlobalVersions } from 'payload'\n\nimport { APIError, buildVersionGlobalFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: MongooseAdapter,\n {\n global: globalSlug,\n limit,\n locale,\n page,\n pagination,\n req,\n select,\n skip,\n sort: sortArg,\n where = {},\n },\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug, versions: true })\n\n const versionFields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n\n const session = await getSession(this, req)\n const options: QueryOptions = {\n limit,\n session,\n skip,\n }\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: versionFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const query = await buildQuery({\n adapter: this,\n fields: versionFields,\n locale,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n projection: buildProjectionFromSelect({ adapter: this, fields: versionFields, select }),\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n hint: { _id: 1 },\n session,\n }),\n )\n }\n }\n\n if (limit && limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n\n paginationOptions.options!.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionGlobalFields(this.payload.config, globalConfig),\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildVersionGlobalFields","flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getGlobal","getSession","transform","findGlobalVersions","global","globalSlug","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","globalConfig","Model","adapter","versions","versionFields","payload","config","session","options","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","timestamps","query","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","data","docs","operation"],"mappings":"AAGA,SAAmBA,wBAAwB,EAAEC,uBAAuB,QAAQ,UAAS;AAIrF,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,QAAQC,UAAU,EAClBC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAMC,OAAO,EACbC,QAAQ,CAAC,CAAC,EACX;IAED,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGjB,UAAU;QAAEkB,SAAS,IAAI;QAAEb;QAAYc,UAAU;IAAK;IAEtF,MAAMC,gBAAgBzB,yBAAyB,IAAI,CAAC0B,OAAO,CAACC,MAAM,EAAEN,cAAc;IAElF,MAAMO,UAAU,MAAMtB,WAAW,IAAI,EAAES;IACvC,MAAMc,UAAwB;QAC5BlB;QACAiB;QACAX;IACF;IAEA,IAAIa,oBAAoB;IAExB,IAAIV,OAAO;QACT,MAAMW,cAAc9B,wBAAwBmB;QAC5CU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qEAAqE;QAErE+B,kBAAkBb,OAAO,CAAElB,KAAK,GAAGA;QAEnC,mCAAmC;QACnC,IAAIA,UAAU,GAAG;YACf+B,kBAAkB5B,UAAU,GAAG;QACjC;IACF;IAEA,MAAMyC,SAAS,MAAMjC,MAAMkC,QAAQ,CAACjB,OAAOG;IAE3CnC,UAAU;QACRgB,SAAS,IAAI;QACbkC,MAAMF,OAAOG,IAAI;QACjBrB,QAAQrC,yBAAyB,IAAI,CAAC0B,OAAO,CAACC,MAAM,EAAEN;QACtDsC,WAAW;IACb;IAEA,OAAOJ;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindGlobalVersions } from 'payload'\n\nimport { APIError, buildVersionGlobalFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: MongooseAdapter,\n {\n global: globalSlug,\n limit = 0,\n locale,\n page,\n pagination,\n req,\n select,\n skip,\n sort: sortArg,\n where = {},\n },\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug, versions: true })\n\n const versionFields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n\n const session = await getSession(this, req)\n const options: QueryOptions = {\n limit,\n session,\n skip,\n }\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: versionFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const query = await buildQuery({\n adapter: this,\n fields: versionFields,\n locale,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n projection: buildProjectionFromSelect({ adapter: this, fields: versionFields, select }),\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n hint: { _id: 1 },\n session,\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n\n paginationOptions.options!.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionGlobalFields(this.payload.config, globalConfig),\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildVersionGlobalFields","flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getGlobal","getSession","transform","findGlobalVersions","global","globalSlug","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","globalConfig","Model","adapter","versions","versionFields","payload","config","session","options","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","timestamps","query","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","data","docs","operation"],"mappings":"AAGA,SAAmBA,wBAAwB,EAAEC,uBAAuB,QAAQ,UAAS;AAIrF,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,QAAQC,UAAU,EAClBC,QAAQ,CAAC,EACTC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAMC,OAAO,EACbC,QAAQ,CAAC,CAAC,EACX;IAED,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGjB,UAAU;QAAEkB,SAAS,IAAI;QAAEb;QAAYc,UAAU;IAAK;IAEtF,MAAMC,gBAAgBzB,yBAAyB,IAAI,CAAC0B,OAAO,CAACC,MAAM,EAAEN,cAAc;IAElF,MAAMO,UAAU,MAAMtB,WAAW,IAAI,EAAES;IACvC,MAAMc,UAAwB;QAC5BlB;QACAiB;QACAX;IACF;IAEA,IAAIa,oBAAoB;IAExB,IAAIV,OAAO;QACT,MAAMW,cAAc9B,wBAAwBmB;QAC5CU,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,IAAIlB;IACJ,IAAI,CAACY,mBAAmB;QACtBZ,OAAOf,eAAe;YACpBoB,SAAS,IAAI;YACbI,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;YAC3BU,QAAQZ;YACRb;YACAM,MAAMC,WAAW;YACjBmB,YAAY;QACd;IACF;IAEA,MAAMC,QAAQ,MAAMrC,WAAW;QAC7BqB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OJ;AACT,EAAC"}
@@ -5,7 +5,7 @@ import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect
5
5
  import { getCollection } from './utilities/getEntity.js';
6
6
  import { getSession } from './utilities/getSession.js';
7
7
  import { transform } from './utilities/transform.js';
8
- export const findVersions = async function findVersions({ collection: collectionSlug, limit, locale, page, pagination, req = {}, select, skip, sort: sortArg, where = {} }) {
8
+ export const findVersions = async function findVersions({ collection: collectionSlug, limit = 0, locale, page, pagination, req = {}, select, skip, sort: sortArg, where = {} }) {
9
9
  const { collectionConfig, Model } = getCollection({
10
10
  adapter: this,
11
11
  collectionSlug,
@@ -78,7 +78,7 @@ export const findVersions = async function findVersions({ collection: collection
78
78
  }));
79
79
  };
80
80
  }
81
- if (limit && limit >= 0) {
81
+ if (limit >= 0) {
82
82
  paginationOptions.limit = limit;
83
83
  // limit must also be set here, it's ignored when pagination is false
84
84
  paginationOptions.options.limit = limit;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindVersions } from 'payload'\n\nimport { buildVersionCollectionFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: MongooseAdapter,\n {\n collection: collectionSlug,\n limit,\n locale,\n page,\n pagination,\n req = {},\n select,\n skip,\n sort: sortArg,\n where = {},\n },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n const session = await getSession(this, req)\n const options: QueryOptions = {\n limit,\n session,\n skip,\n }\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const query = await buildQuery({\n adapter: this,\n fields,\n locale,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields,\n select,\n }),\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n hint: { _id: 1 },\n session,\n }),\n )\n }\n }\n\n if (limit && limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n\n paginationOptions.options!.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionCollectionFields(this.payload.config, collectionConfig),\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildVersionCollectionFields","flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getCollection","getSession","transform","findVersions","collection","collectionSlug","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","collectionConfig","Model","adapter","versions","session","options","hasNearConstraint","constraints","some","prop","Object","keys","key","config","payload","fields","flattenedFields","timestamps","query","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","data","docs","operation"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,uBAAuB,QAAQ,UAAS;AAI/E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EACEC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAC,EACRC,MAAM,EACNC,IAAI,EACJC,MAAMC,OAAO,EACbC,QAAQ,CAAC,CAAC,EACX;IAED,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGjB,cAAc;QAChDkB,SAAS,IAAI;QACbb;QACAc,UAAU;IACZ;IAEA,MAAMC,UAAU,MAAMnB,WAAW,IAAI,EAAES;IACvC,MAAMW,UAAwB;QAC5Bf;QACAc;QACAR;IACF;IAEA,IAAIU,oBAAoB;IAExB,IAAIP,OAAO;QACT,MAAMQ,cAAc3B,wBAAwBmB;QAC5CO,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,IAAIf;IACJ,IAAI,CAACS,mBAAmB;QACtBT,OAAOf,eAAe;YACpBoB,SAAS,IAAI;YACbW,QAAQ,IAAI,C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MAAMyC,SAAS,MAAMjC,MAAMkC,QAAQ,CAACjB,OAAOG;IAE3CnC,UAAU;QACRgB,SAAS,IAAI;QACbkC,MAAMF,OAAOG,IAAI;QACjBtB,QAAQpC,6BAA6B,IAAI,CAACmC,OAAO,CAACD,MAAM,EAAEb;QAC1DsC,WAAW;IACb;IAEA,OAAOJ;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindVersions } from 'payload'\n\nimport { buildVersionCollectionFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: MongooseAdapter,\n {\n collection: collectionSlug,\n limit = 0,\n locale,\n page,\n pagination,\n req = {},\n select,\n skip,\n sort: sortArg,\n where = {},\n },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n const session = await getSession(this, req)\n const options: QueryOptions = {\n limit,\n session,\n skip,\n }\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const query = await buildQuery({\n adapter: this,\n fields,\n locale,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields,\n select,\n }),\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n hint: { _id: 1 },\n session,\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n\n paginationOptions.options!.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionCollectionFields(this.payload.config, collectionConfig),\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildVersionCollectionFields","flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getCollection","getSession","transform","findVersions","collection","collectionSlug","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","collectionConfig","Model","adapter","versions","session","options","hasNearConstraint","constraints","some","prop","Object","keys","key","config","payload","fields","flattenedFields","timestamps","query","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","data","docs","operation"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,uBAAuB,QAAQ,UAAS;AAI/E,SAASC,UAAU,QAAQ,0BA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MAAM,KAAK;IACvF,MAAMC,oBAAqC;QACzCC,MAAM;QACNC,YAAY;QACZjC;QACAe;QACAb;QACAC;QACA+B,YAAYzC,0BAA0B;YACpCmB,SAAS,IAAI;YACba;YACApB;QACF;QACAE;QACAsB;IACF;IAEA,IAAI,IAAI,CAACM,SAAS,EAAE;QAClB,MAAMC,gBAAgB;QACtBL,kBAAkBI,SAAS,GAAG;YAC5BlC,QAAQA,UAAUA,WAAW,SAASA,WAAW,MAAMA,SAASmC;YAChE,GAAG,IAAI,CAACD,SAAS;QACnB;IACF;IAEA,IAAI,CAACN,qBAAqBT,OAAOC,IAAI,CAACO,OAAOE,MAAM,KAAK,KAAK,IAAI,CAACO,iBAAiB,KAAK,MAAM;QAC5F,mHAAmH;QACnH,qHAAqH;QACrH,mHAAmH;QACnH,4BAA4B;QAC5BN,kBAAkBO,gBAAgB,GAAG;YACnC,OAAOC,QAAQC,OAAO,CACpB7B,MAAM8B,cAAc,CAACb,OAAO;gBAC1Bc,MAAM;oBAAEC,KAAK;gBAAE;gBACf7B;YACF;QAEJ;IACF;IAEA,IAAId,SAAS,GAAG;QACd+B,kBAAkB/B,KAAK,GAAGA;QAC1B,qEAAqE;QAErE+B,kBAAkBhB,OAAO,CAAEf,KAAK,GAAGA;QAEnC,mCAAmC;QACnC,IAAIA,UAAU,GAAG;YACf+B,kBAAkB5B,UAAU,GAAG;QACjC;IACF;IAEA,MAAMyC,SAAS,MAAMjC,MAAMkC,QAAQ,CAACjB,OAAOG;IAE3CnC,UAAU;QACRgB,SAAS,IAAI;QACbkC,MAAMF,OAAOG,IAAI;QACjBtB,QAAQpC,6BAA6B,IAAI,CAACmC,OAAO,CAACD,MAAM,EAAEb;QAC1DsC,WAAW;IACb;IAEA,OAAOJ;AACT,EAAC"}
@@ -116,6 +116,11 @@ const array = (field, schema, payload, buildSchemaOptions, parentIsLocalized)=>{
116
116
  };
117
117
  const blocks = (field, schema, payload, buildSchemaOptions, parentIsLocalized)=>{
118
118
  const fieldSchema = {
119
+ ...formatBaseSchema({
120
+ buildSchemaOptions,
121
+ field,
122
+ parentIsLocalized
123
+ }),
119
124
  type: [
120
125
  new mongoose.Schema({}, {
121
126
  _id: false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/buildSchema.ts"],"sourcesContent":["import type { IndexOptions, Schema, SchemaOptions, SchemaTypeOptions } from 'mongoose'\n\nimport mongoose from 'mongoose'\nimport {\n type ArrayField,\n type BlocksField,\n type CheckboxField,\n type CodeField,\n type CollapsibleField,\n type DateField,\n type EmailField,\n type Field,\n type FieldAffectingData,\n type GroupField,\n type JSONField,\n type NonPresentationalField,\n type NumberField,\n type Payload,\n type PointField,\n type RadioField,\n type RelationshipField,\n type RichTextField,\n type RowField,\n type SanitizedCompoundIndex,\n type SanitizedLocalizationConfig,\n type SelectField,\n type Tab,\n type TabsField,\n type TextareaField,\n type TextField,\n type UploadField,\n} from 'payload'\nimport {\n fieldAffectsData,\n fieldIsPresentationalOnly,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\ntype FieldSchemaGenerator<T extends Field = Field> = (\n field: T,\n schema: Schema,\n config: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n parentIsLocalized: boolean,\n) => void\n\n/**\n * get a field's defaultValue only if defined and not dynamic so that it can be set on the field schema\n * @param field\n */\nconst formatDefaultValue = (field: FieldAffectingData) =>\n typeof field.defaultValue !== 'undefined' && typeof field.defaultValue !== 'function'\n ? field.defaultValue\n : undefined\n\nconst formatBaseSchema = ({\n buildSchemaOptions,\n field,\n parentIsLocalized,\n}: {\n buildSchemaOptions: BuildSchemaOptions\n field: FieldAffectingData\n parentIsLocalized: boolean\n}) => {\n const { disableUnique, draftsEnabled, indexSortableFields } = buildSchemaOptions\n const schema: SchemaTypeOptions<unknown> = {\n default: formatDefaultValue(field),\n index: field.index || (!disableUnique && field.unique) || indexSortableFields || false,\n required: false,\n unique: (!disableUnique && field.unique) || false,\n }\n\n if (\n schema.unique &&\n (fieldShouldBeLocalized({ field, parentIsLocalized }) ||\n draftsEnabled ||\n (fieldAffectsData(field) &&\n field.type !== 'group' &&\n field.type !== 'tab' &&\n field.required !== true))\n ) {\n schema.sparse = true\n }\n\n if (field.hidden) {\n schema.hidden = true\n }\n\n return schema\n}\n\nconst localizeSchema = (\n entity: NonPresentationalField | Tab,\n schema: SchemaTypeOptions<any>,\n localization: false | SanitizedLocalizationConfig,\n parentIsLocalized: boolean,\n) => {\n if (\n fieldShouldBeLocalized({ field: entity, parentIsLocalized }) &&\n localization &&\n Array.isArray(localization.locales)\n ) {\n return {\n type: localization.localeCodes.reduce(\n (localeSchema, locale) => ({\n ...localeSchema,\n [locale]: schema,\n }),\n {\n _id: false,\n },\n ),\n localized: true,\n }\n }\n return schema\n}\n\nexport const buildSchema = (args: {\n buildSchemaOptions: BuildSchemaOptions\n compoundIndexes?: SanitizedCompoundIndex[]\n configFields: Field[]\n parentIsLocalized?: boolean\n payload: Payload\n}): Schema => {\n const { buildSchemaOptions = {}, configFields, parentIsLocalized, payload } = args\n const { allowIDField, options } = buildSchemaOptions\n let fields = {}\n\n let schemaFields = configFields\n\n if (!allowIDField) {\n const idField = schemaFields.find((field) => fieldAffectsData(field) && field.name === 'id')\n if (idField) {\n fields = {\n _id:\n idField.type === 'number'\n ? payload.db.useBigIntForNumberIDs\n ? mongoose.Schema.Types.BigInt\n : Number\n : String,\n }\n schemaFields = schemaFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n )\n }\n }\n\n const schema = new mongoose.Schema(fields, options as any)\n\n schemaFields.forEach((field) => {\n if (fieldIsVirtual(field)) {\n return\n }\n\n if (!fieldIsPresentationalOnly(field)) {\n const addFieldSchema = getSchemaGenerator(field.type)\n\n if (addFieldSchema) {\n addFieldSchema(field, schema, payload, buildSchemaOptions, parentIsLocalized ?? false)\n }\n }\n })\n\n if (args.compoundIndexes) {\n for (const index of args.compoundIndexes) {\n const indexDefinition: Record<string, 1> = {}\n\n for (const field of index.fields) {\n if (field.pathHasLocalized && payload.config.localization) {\n for (const locale of payload.config.localization.locales) {\n indexDefinition[field.localizedPath.replace('<locale>', locale.code)] = 1\n }\n } else {\n indexDefinition[field.path] = 1\n }\n }\n\n schema.index(indexDefinition, {\n unique: args.buildSchemaOptions.disableUnique ? false : index.unique,\n })\n }\n }\n\n return schema\n}\n\nconst array: FieldSchemaGenerator<ArrayField> = (\n field: ArrayField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n) => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: [\n buildSchema({\n buildSchemaOptions: {\n allowIDField: true,\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n payload,\n }),\n ],\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst blocks: FieldSchemaGenerator<BlocksField> = (\n field: BlocksField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const fieldSchema: SchemaTypeOptions<any> = {\n type: [new mongoose.Schema({}, { _id: false, discriminatorKey: 'blockType' })],\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n fieldSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n ;(field.blockReferences ?? field.blocks).forEach((blockItem) => {\n const blockSchema = new mongoose.Schema({}, { _id: false, id: false })\n\n const block = typeof blockItem === 'string' ? payload.blocks[blockItem] : blockItem\n\n if (!block) {\n return\n }\n\n block.fields.forEach((blockField) => {\n const addFieldSchema = getSchemaGenerator(blockField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n blockField,\n blockSchema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || field.localized) ?? false,\n )\n }\n })\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n payload.config.localization.localeCodes.forEach((localeCode) => {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(`${field.name}.${localeCode}`).discriminator(block.slug, blockSchema)\n })\n } else {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(field.name).discriminator(block.slug, blockSchema)\n }\n })\n}\n\nconst checkbox: FieldSchemaGenerator<CheckboxField> = (\n field: CheckboxField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: Boolean,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst code: FieldSchemaGenerator<CodeField> = (\n field: CodeField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst collapsible: FieldSchemaGenerator<CollapsibleField> = (\n field: CollapsibleField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, payload, buildSchemaOptions, parentIsLocalized)\n }\n })\n}\n\nconst date: FieldSchemaGenerator<DateField> = (\n field: DateField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: Date,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst email: FieldSchemaGenerator<EmailField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst group: FieldSchemaGenerator<GroupField> = (\n field: GroupField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n if (fieldAffectsData(field)) {\n const formattedBaseSchema = formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized })\n\n // carry indexSortableFields through to versions if drafts enabled\n const indexSortableFields =\n buildSchemaOptions.indexSortableFields &&\n field.name === 'version' &&\n buildSchemaOptions.draftsEnabled\n\n const baseSchema: SchemaTypeOptions<any> = {\n ...formattedBaseSchema,\n type: buildSchema({\n buildSchemaOptions: {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n indexSortableFields,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n payload,\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n baseSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n } else {\n field.fields.forEach((subField) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || field.localized) ?? false,\n )\n }\n })\n }\n}\n\nconst json: FieldSchemaGenerator<JSONField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst number: FieldSchemaGenerator<NumberField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: field.hasMany ? [Number] : Number,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst point: FieldSchemaGenerator<PointField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<unknown> = {\n type: {\n type: String,\n enum: ['Point'],\n ...(typeof field.defaultValue !== 'undefined' && {\n default: 'Point',\n }),\n },\n coordinates: {\n type: [Number],\n default: formatDefaultValue(field),\n required: false,\n },\n }\n\n if (\n buildSchemaOptions.disableUnique &&\n field.unique &&\n fieldShouldBeLocalized({ field, parentIsLocalized })\n ) {\n baseSchema.coordinates.sparse = true\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n\n if (field.index === true || field.index === undefined) {\n const indexOptions: IndexOptions = {}\n if (!buildSchemaOptions.disableUnique && field.unique) {\n indexOptions.sparse = true\n indexOptions.unique = true\n }\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n payload.config.localization.locales.forEach((locale) => {\n schema.index({ [`${field.name}.${locale.code}`]: '2dsphere' }, indexOptions)\n })\n } else {\n schema.index({ [field.name]: '2dsphere' }, indexOptions)\n }\n }\n}\n\nconst radio: FieldSchemaGenerator<RadioField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n enum: field.options.map((option) => {\n if (typeof option === 'object') {\n return option.value\n }\n return option\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst relationship: FieldSchemaGenerator<RelationshipField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n) => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n const valueType = getRelationshipValueType(field, payload)\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n schemaToReturn = {\n _id: false,\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.${locale}.relationTo`,\n },\n }\n } else {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: valueType,\n ref: field.relationTo,\n }\n }\n\n return {\n ...locales,\n [locale]: field.hasMany\n ? { type: [localeSchema], default: formatDefaultValue(field) }\n : localeSchema,\n }\n }, {}),\n localized: true,\n }\n } else if (hasManyRelations) {\n schemaToReturn = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.relationTo`,\n },\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n } else {\n schemaToReturn = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: valueType,\n ref: field.relationTo,\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n }\n\n schema.add({\n [field.name]: schemaToReturn,\n })\n}\n\nconst richText: FieldSchemaGenerator<RichTextField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst row: FieldSchemaGenerator<RowField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, payload, buildSchemaOptions, parentIsLocalized)\n }\n })\n}\n\nconst select: FieldSchemaGenerator<SelectField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n enum: field.options.map((option) => {\n if (typeof option === 'object') {\n return option.value\n }\n return option\n }),\n }\n\n if (buildSchemaOptions.draftsEnabled || !field.required) {\n ;(baseSchema.enum as unknown[]).push(null)\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n field.hasMany ? [baseSchema] : baseSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n}\n\nconst tabs: FieldSchemaGenerator<TabsField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n if (fieldIsVirtual(tab)) {\n return\n }\n const baseSchema = {\n type: buildSchema({\n buildSchemaOptions: {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: tab.fields,\n parentIsLocalized: parentIsLocalized || tab.localized,\n payload,\n }),\n }\n\n schema.add({\n [tab.name]: localizeSchema(tab, baseSchema, payload.config.localization, parentIsLocalized),\n })\n } else {\n tab.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || tab.localized) ?? false,\n )\n }\n })\n }\n })\n}\n\nconst text: FieldSchemaGenerator<TextField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: field.hasMany ? [String] : String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst textarea: FieldSchemaGenerator<TextareaField> = (\n field: TextareaField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst upload: FieldSchemaGenerator<UploadField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n const valueType = getRelationshipValueType(field, payload)\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n schemaToReturn = {\n _id: false,\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.${locale}.relationTo`,\n },\n }\n } else {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: valueType,\n ref: field.relationTo,\n }\n }\n\n return {\n ...locales,\n [locale]: field.hasMany\n ? { type: [localeSchema], default: formatDefaultValue(field) }\n : localeSchema,\n }\n }, {}),\n localized: true,\n }\n } else if (hasManyRelations) {\n schemaToReturn = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.relationTo`,\n },\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n } else {\n schemaToReturn = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: valueType,\n ref: field.relationTo,\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n }\n\n schema.add({\n [field.name]: schemaToReturn,\n })\n}\n\nconst getSchemaGenerator = (fieldType: string): FieldSchemaGenerator | null => {\n if (fieldType in fieldToSchemaMap) {\n return fieldToSchemaMap[fieldType as keyof typeof fieldToSchemaMap] as FieldSchemaGenerator\n }\n\n return null\n}\n\nconst fieldToSchemaMap = {\n array,\n blocks,\n checkbox,\n code,\n collapsible,\n date,\n email,\n group,\n json,\n number,\n point,\n radio,\n relationship,\n richText,\n row,\n select,\n tabs,\n text,\n textarea,\n upload,\n}\n\nconst getRelationshipValueType = (field: RelationshipField | UploadField, payload: Payload) => {\n if (typeof field.relationTo === 'string') {\n const customIDType = payload.collections[field.relationTo]?.customIDType\n\n if (!customIDType) {\n return mongoose.Schema.Types.ObjectId\n }\n\n if (customIDType === 'number') {\n if (payload.db.useBigIntForNumberIDs) {\n return mongoose.Schema.Types.BigInt\n } else {\n return mongoose.Schema.Types.Number\n }\n }\n\n return mongoose.Schema.Types.String\n }\n\n // has custom id relationTo\n if (\n field.relationTo.some((relationTo) => {\n return !!payload.collections[relationTo]?.customIDType\n })\n ) {\n return mongoose.Schema.Types.Mixed\n }\n\n return mongoose.Schema.Types.ObjectId\n}\n"],"names":["mongoose","fieldAffectsData","fieldIsPresentationalOnly","fieldIsVirtual","fieldShouldBeLocalized","tabHasName","formatDefaultValue","field","defaultValue","undefined","formatBaseSchema","buildSchemaOptions","parentIsLocalized","disableUnique","draftsEnabled","indexSortableFields","schema","default","index","unique","required","type","sparse","hidden","localizeSchema","entity","localization","Array","isArray","locales","localeCodes","reduce","localeSchema","locale","_id","localized","buildSchema","args","configFields","payload","allowIDField","options","fields","schemaFields","idField","find","name","db","useBigIntForNumberIDs","Schema","Types","BigInt","Number","String","filter","forEach","addFieldSchema","getSchemaGenerator","compoundIndexes","indexDefinition","pathHasLocalized","config","localizedPath","replace","code","path","array","baseSchema","id","minimize","add","blocks","fieldSchema","discriminatorKey","blockReferences","blockItem","blockSchema","block","blockField","localeCode","discriminator","slug","checkbox","Boolean","collapsible","subField","date","Date","email","group","formattedBaseSchema","json","Mixed","number","hasMany","point","enum","coordinates","indexOptions","radio","map","option","value","relationship","hasManyRelations","relationTo","schemaToReturn","valueType","getRelationshipValueType","refPath","ref","richText","row","select","push","tabs","tab","text","textarea","upload","fieldType","fieldToSchemaMap","customIDType","collections","ObjectId","some"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AA8B/B,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,iBAAgB;AAkBvB;;;CAGC,GACD,MAAMC,qBAAqB,CAACC,QAC1B,OAAOA,MAAMC,YAAY,KAAK,eAAe,OAAOD,MAAMC,YAAY,KAAK,aACvED,MAAMC,YAAY,GAClBC;AAEN,MAAMC,mBAAmB,CAAC,EACxBC,kBAAkB,EAClBJ,KAAK,EACLK,iBAAiB,EAKlB;IACC,MAAM,EAAEC,aAAa,EAAEC,aAAa,EAAEC,mBAAmB,EAAE,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xE,IAAI,OAAOhC,MAAMkG,UAAU,KAAK,UAAU;QACxC,MAAMiB,eAAenF,QAAQoF,WAAW,CAACpH,MAAMkG,UAAU,CAAC,EAAEiB;QAE5D,IAAI,CAACA,cAAc;YACjB,OAAO1H,SAASiD,MAAM,CAACC,KAAK,CAAC0E,QAAQ;QACvC;QAEA,IAAIF,iBAAiB,UAAU;YAC7B,IAAInF,QAAQQ,EAAE,CAACC,qBAAqB,EAAE;gBACpC,OAAOhD,SAASiD,MAAM,CAACC,KAAK,CAACC,MAAM;YACrC,OAAO;gBACL,OAAOnD,SAASiD,MAAM,CAACC,KAAK,CAACE,MAAM;YACrC;QACF;QAEA,OAAOpD,SAASiD,MAAM,CAACC,KAAK,CAACG,MAAM;IACrC;IAEA,2BAA2B;IAC3B,IACE9C,MAAMkG,UAAU,CAACoB,IAAI,CAAC,CAACpB;QACrB,OAAO,CAAC,CAAClE,QAAQoF,WAAW,CAAClB,WAAW,EAAEiB;IAC5C,IACA;QACA,OAAO1H,SAASiD,MAAM,CAACC,KAAK,CAAC0C,KAAK;IACpC;IAEA,OAAO5F,SAASiD,MAAM,CAACC,KAAK,CAAC0E,QAAQ;AACvC"}
1
+ {"version":3,"sources":["../../src/models/buildSchema.ts"],"sourcesContent":["import type { IndexOptions, Schema, SchemaOptions, SchemaTypeOptions } from 'mongoose'\n\nimport mongoose from 'mongoose'\nimport {\n type ArrayField,\n type BlocksField,\n type CheckboxField,\n type CodeField,\n type CollapsibleField,\n type DateField,\n type EmailField,\n type Field,\n type FieldAffectingData,\n type GroupField,\n type JSONField,\n type NonPresentationalField,\n type NumberField,\n type Payload,\n type PointField,\n type RadioField,\n type RelationshipField,\n type RichTextField,\n type RowField,\n type SanitizedCompoundIndex,\n type SanitizedLocalizationConfig,\n type SelectField,\n type Tab,\n type TabsField,\n type TextareaField,\n type TextField,\n type UploadField,\n} from 'payload'\nimport {\n fieldAffectsData,\n fieldIsPresentationalOnly,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\ntype FieldSchemaGenerator<T extends Field = Field> = (\n field: T,\n schema: Schema,\n config: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n parentIsLocalized: boolean,\n) => void\n\n/**\n * get a field's defaultValue only if defined and not dynamic so that it can be set on the field schema\n * @param field\n */\nconst formatDefaultValue = (field: FieldAffectingData) =>\n typeof field.defaultValue !== 'undefined' && typeof field.defaultValue !== 'function'\n ? field.defaultValue\n : undefined\n\nconst formatBaseSchema = ({\n buildSchemaOptions,\n field,\n parentIsLocalized,\n}: {\n buildSchemaOptions: BuildSchemaOptions\n field: FieldAffectingData\n parentIsLocalized: boolean\n}) => {\n const { disableUnique, draftsEnabled, indexSortableFields } = buildSchemaOptions\n const schema: SchemaTypeOptions<unknown> = {\n default: formatDefaultValue(field),\n index: field.index || (!disableUnique && field.unique) || indexSortableFields || false,\n required: false,\n unique: (!disableUnique && field.unique) || false,\n }\n\n if (\n schema.unique &&\n (fieldShouldBeLocalized({ field, parentIsLocalized }) ||\n draftsEnabled ||\n (fieldAffectsData(field) &&\n field.type !== 'group' &&\n field.type !== 'tab' &&\n field.required !== true))\n ) {\n schema.sparse = true\n }\n\n if (field.hidden) {\n schema.hidden = true\n }\n\n return schema\n}\n\nconst localizeSchema = (\n entity: NonPresentationalField | Tab,\n schema: SchemaTypeOptions<any>,\n localization: false | SanitizedLocalizationConfig,\n parentIsLocalized: boolean,\n) => {\n if (\n fieldShouldBeLocalized({ field: entity, parentIsLocalized }) &&\n localization &&\n Array.isArray(localization.locales)\n ) {\n return {\n type: localization.localeCodes.reduce(\n (localeSchema, locale) => ({\n ...localeSchema,\n [locale]: schema,\n }),\n {\n _id: false,\n },\n ),\n localized: true,\n }\n }\n return schema\n}\n\nexport const buildSchema = (args: {\n buildSchemaOptions: BuildSchemaOptions\n compoundIndexes?: SanitizedCompoundIndex[]\n configFields: Field[]\n parentIsLocalized?: boolean\n payload: Payload\n}): Schema => {\n const { buildSchemaOptions = {}, configFields, parentIsLocalized, payload } = args\n const { allowIDField, options } = buildSchemaOptions\n let fields = {}\n\n let schemaFields = configFields\n\n if (!allowIDField) {\n const idField = schemaFields.find((field) => fieldAffectsData(field) && field.name === 'id')\n if (idField) {\n fields = {\n _id:\n idField.type === 'number'\n ? payload.db.useBigIntForNumberIDs\n ? mongoose.Schema.Types.BigInt\n : Number\n : String,\n }\n schemaFields = schemaFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n )\n }\n }\n\n const schema = new mongoose.Schema(fields, options as any)\n\n schemaFields.forEach((field) => {\n if (fieldIsVirtual(field)) {\n return\n }\n\n if (!fieldIsPresentationalOnly(field)) {\n const addFieldSchema = getSchemaGenerator(field.type)\n\n if (addFieldSchema) {\n addFieldSchema(field, schema, payload, buildSchemaOptions, parentIsLocalized ?? false)\n }\n }\n })\n\n if (args.compoundIndexes) {\n for (const index of args.compoundIndexes) {\n const indexDefinition: Record<string, 1> = {}\n\n for (const field of index.fields) {\n if (field.pathHasLocalized && payload.config.localization) {\n for (const locale of payload.config.localization.locales) {\n indexDefinition[field.localizedPath.replace('<locale>', locale.code)] = 1\n }\n } else {\n indexDefinition[field.path] = 1\n }\n }\n\n schema.index(indexDefinition, {\n unique: args.buildSchemaOptions.disableUnique ? false : index.unique,\n })\n }\n }\n\n return schema\n}\n\nconst array: FieldSchemaGenerator<ArrayField> = (\n field: ArrayField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n) => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: [\n buildSchema({\n buildSchemaOptions: {\n allowIDField: true,\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n payload,\n }),\n ],\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst blocks: FieldSchemaGenerator<BlocksField> = (\n field: BlocksField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const fieldSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: [new mongoose.Schema({}, { _id: false, discriminatorKey: 'blockType' })],\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n fieldSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n ;(field.blockReferences ?? field.blocks).forEach((blockItem) => {\n const blockSchema = new mongoose.Schema({}, { _id: false, id: false })\n\n const block = typeof blockItem === 'string' ? payload.blocks[blockItem] : blockItem\n\n if (!block) {\n return\n }\n\n block.fields.forEach((blockField) => {\n const addFieldSchema = getSchemaGenerator(blockField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n blockField,\n blockSchema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || field.localized) ?? false,\n )\n }\n })\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n payload.config.localization.localeCodes.forEach((localeCode) => {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(`${field.name}.${localeCode}`).discriminator(block.slug, blockSchema)\n })\n } else {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(field.name).discriminator(block.slug, blockSchema)\n }\n })\n}\n\nconst checkbox: FieldSchemaGenerator<CheckboxField> = (\n field: CheckboxField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: Boolean,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst code: FieldSchemaGenerator<CodeField> = (\n field: CodeField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst collapsible: FieldSchemaGenerator<CollapsibleField> = (\n field: CollapsibleField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, payload, buildSchemaOptions, parentIsLocalized)\n }\n })\n}\n\nconst date: FieldSchemaGenerator<DateField> = (\n field: DateField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: Date,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst email: FieldSchemaGenerator<EmailField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst group: FieldSchemaGenerator<GroupField> = (\n field: GroupField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n if (fieldAffectsData(field)) {\n const formattedBaseSchema = formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized })\n\n // carry indexSortableFields through to versions if drafts enabled\n const indexSortableFields =\n buildSchemaOptions.indexSortableFields &&\n field.name === 'version' &&\n buildSchemaOptions.draftsEnabled\n\n const baseSchema: SchemaTypeOptions<any> = {\n ...formattedBaseSchema,\n type: buildSchema({\n buildSchemaOptions: {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n indexSortableFields,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n payload,\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n baseSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n } else {\n field.fields.forEach((subField) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || field.localized) ?? false,\n )\n }\n })\n }\n}\n\nconst json: FieldSchemaGenerator<JSONField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst number: FieldSchemaGenerator<NumberField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: field.hasMany ? [Number] : Number,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst point: FieldSchemaGenerator<PointField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<unknown> = {\n type: {\n type: String,\n enum: ['Point'],\n ...(typeof field.defaultValue !== 'undefined' && {\n default: 'Point',\n }),\n },\n coordinates: {\n type: [Number],\n default: formatDefaultValue(field),\n required: false,\n },\n }\n\n if (\n buildSchemaOptions.disableUnique &&\n field.unique &&\n fieldShouldBeLocalized({ field, parentIsLocalized })\n ) {\n baseSchema.coordinates.sparse = true\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n\n if (field.index === true || field.index === undefined) {\n const indexOptions: IndexOptions = {}\n if (!buildSchemaOptions.disableUnique && field.unique) {\n indexOptions.sparse = true\n indexOptions.unique = true\n }\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n payload.config.localization.locales.forEach((locale) => {\n schema.index({ [`${field.name}.${locale.code}`]: '2dsphere' }, indexOptions)\n })\n } else {\n schema.index({ [field.name]: '2dsphere' }, indexOptions)\n }\n }\n}\n\nconst radio: FieldSchemaGenerator<RadioField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n enum: field.options.map((option) => {\n if (typeof option === 'object') {\n return option.value\n }\n return option\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst relationship: FieldSchemaGenerator<RelationshipField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n) => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n const valueType = getRelationshipValueType(field, payload)\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n schemaToReturn = {\n _id: false,\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.${locale}.relationTo`,\n },\n }\n } else {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: valueType,\n ref: field.relationTo,\n }\n }\n\n return {\n ...locales,\n [locale]: field.hasMany\n ? { type: [localeSchema], default: formatDefaultValue(field) }\n : localeSchema,\n }\n }, {}),\n localized: true,\n }\n } else if (hasManyRelations) {\n schemaToReturn = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.relationTo`,\n },\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n } else {\n schemaToReturn = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: valueType,\n ref: field.relationTo,\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n }\n\n schema.add({\n [field.name]: schemaToReturn,\n })\n}\n\nconst richText: FieldSchemaGenerator<RichTextField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst row: FieldSchemaGenerator<RowField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, payload, buildSchemaOptions, parentIsLocalized)\n }\n })\n}\n\nconst select: FieldSchemaGenerator<SelectField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n enum: field.options.map((option) => {\n if (typeof option === 'object') {\n return option.value\n }\n return option\n }),\n }\n\n if (buildSchemaOptions.draftsEnabled || !field.required) {\n ;(baseSchema.enum as unknown[]).push(null)\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n field.hasMany ? [baseSchema] : baseSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n}\n\nconst tabs: FieldSchemaGenerator<TabsField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n if (fieldIsVirtual(tab)) {\n return\n }\n const baseSchema = {\n type: buildSchema({\n buildSchemaOptions: {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: tab.fields,\n parentIsLocalized: parentIsLocalized || tab.localized,\n payload,\n }),\n }\n\n schema.add({\n [tab.name]: localizeSchema(tab, baseSchema, payload.config.localization, parentIsLocalized),\n })\n } else {\n tab.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || tab.localized) ?? false,\n )\n }\n })\n }\n })\n}\n\nconst text: FieldSchemaGenerator<TextField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: field.hasMany ? [String] : String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst textarea: FieldSchemaGenerator<TextareaField> = (\n field: TextareaField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst upload: FieldSchemaGenerator<UploadField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n const valueType = getRelationshipValueType(field, payload)\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n schemaToReturn = {\n _id: false,\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.${locale}.relationTo`,\n },\n }\n } else {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: valueType,\n ref: field.relationTo,\n }\n }\n\n return {\n ...locales,\n [locale]: field.hasMany\n ? { type: [localeSchema], default: formatDefaultValue(field) }\n : localeSchema,\n }\n }, {}),\n localized: true,\n }\n } else if (hasManyRelations) {\n schemaToReturn = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.relationTo`,\n },\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n } else {\n schemaToReturn = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: valueType,\n ref: field.relationTo,\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n }\n\n schema.add({\n [field.name]: schemaToReturn,\n })\n}\n\nconst getSchemaGenerator = (fieldType: string): FieldSchemaGenerator | null => {\n if (fieldType in fieldToSchemaMap) {\n return fieldToSchemaMap[fieldType as keyof typeof fieldToSchemaMap] as FieldSchemaGenerator\n }\n\n return null\n}\n\nconst fieldToSchemaMap = {\n array,\n blocks,\n checkbox,\n code,\n collapsible,\n date,\n email,\n group,\n json,\n number,\n point,\n radio,\n relationship,\n richText,\n row,\n select,\n tabs,\n text,\n textarea,\n upload,\n}\n\nconst getRelationshipValueType = (field: RelationshipField | UploadField, payload: Payload) => {\n if (typeof field.relationTo === 'string') {\n const customIDType = payload.collections[field.relationTo]?.customIDType\n\n if (!customIDType) {\n return mongoose.Schema.Types.ObjectId\n }\n\n if (customIDType === 'number') {\n if (payload.db.useBigIntForNumberIDs) {\n return mongoose.Schema.Types.BigInt\n } else {\n return mongoose.Schema.Types.Number\n }\n }\n\n return mongoose.Schema.Types.String\n }\n\n // has custom id relationTo\n if (\n field.relationTo.some((relationTo) => {\n return !!payload.collections[relationTo]?.customIDType\n })\n ) {\n return mongoose.Schema.Types.Mixed\n }\n\n return mongoose.Schema.Types.ObjectId\n}\n"],"names":["mongoose","fieldAffectsData","fieldIsPresentationalOnly","fieldIsVirtual","fieldShouldBeLocalized","tabHasName","formatDefaultValue","field","defaultValue","undefined","formatBaseSchema","buildSchemaOptions","parentIsLocalized","disableUnique","draftsEnabled","indexSortableFields","schema","default","index","unique","required","type","sparse","hidden","localizeSchema","entity","localization","Array","isArray","locales","localeCodes","reduce","localeSchema","locale","_id","localized","buildSchema","args","configFields","payload","allowIDField","options","fields","schemaFields","idField","find","name","db","useBigIntForNumberIDs","Schema","Types","BigInt","Number","String","filter","forEach","addFieldSchema","getSchemaGenerator","compoundIndexes","indexDefinition","pathHasLocalized","config","localizedPath","replace","code","path","array","baseSchema","id","minimize","add","blocks","fieldSchema","discriminatorKey","blockReferences","blockItem","blockSchema","block","blockField","localeCode","discriminator","slug","checkbox","Boolean","collapsible","subField","date","Date","email","group","formattedBaseSchema","json","Mixed","number","hasMany","point","enum","coordinates","indexOptions","radio","map","option","value","relationship","hasManyRelations","relationTo","schemaToReturn","valueType","getRelationshipValueType","refPath","ref","richText","row","select","push","tabs","tab","text","textarea","upload","fieldType","fieldToSchemaMap","customIDType","collections","ObjectId","some"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AA8B/B,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,iBAAgB;AAkBvB;;;CAGC,GACD,MAAMC,qBAAqB,CAACC,QAC1B,OAAOA,MAAMC,YAAY,KAAK,eAAe,OAAOD,MAAMC,YAAY,KAAK,aACvED,MAAMC,YAAY,GAClBC;AAEN,MAAMC,mBAAmB,CAAC,EACxBC,kBAAkB,EAClBJ,KAAK,EACLK,iBAAiB,EAKlB;IACC,MAAM,EAAEC,aAAa,EAAEC,aAAa,EAAEC,mBAAmB,EAAE,GAAGJ;IAC9D,MAAMK,SAAqC;QACzCC,SAASX,mBAAmBC;QAC5BW,OAAOX,MAAMW,KAAK,IAAK,CAACL,iBAAiBN,MAAMY,MAAM,IAAKJ,uBAAuB;QACjFK,UAAU;QACVD,QAAQ,AAAC,CAACN,iBAAiBN,MAAMY,MAAM,IAAK;IAC9C;IAEA,IACEH,OAAOG,MAAM,IACZf,CAAAA,uBAAuB;QAAEG;QAAOK;IAAkB,MACjDE,iBACCb,iBAAiBM,UAChBA,MAAMc,IAAI,KAAK,WACfd,MAAMc,IAAI,KAAK,SACfd,MAAMa,QAAQ,KAAK,IAAI,GAC3B;QACAJ,OAAOM,MAAM,GAAG;IAClB;IAEA,IAAIf,MAAMgB,MAAM,EAAE;QAChBP,OAAOO,MAAM,GAAG;IAClB;IAEA,OAAOP;AACT;AAEA,MAAMQ,iBAAiB,CACrBC,QACAT,QACAU,cACAd;IAEA,IACER,uBAAuB;QAAEG,OAAOkB;Q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AAE,OAAO,CAAA;CAChC,CAAA;AA0KD,eAAO,MAAM,SAAS,+HAYnB,IAAI,qBA4XN,CAAA"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/utilities/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,KAAK,EAQN,MAAM,SAAS,CAAA;AAMhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAmQlD,KAAK,IAAI,GAAG;IACV,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,EAAE,CAAA;KAAE,GAAG,GAAG,CAAC,CAAA;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,GAAG,EAAE,CAAA;KAAE,GAAG,GAAG,CAAC,CAAA;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,EAAE,CAAA;KAAE,GAAG,GAAG,CAAC,CAAA;IAC9C,8BAA8B;IAC9B,OAAO,EAAE,eAAe,CAAA;IACxB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACzD,uCAAuC;IACvC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,SAAS,EAAE,MAAM,GAAG,OAAO,CAAA;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAmMD,eAAO,MAAM,SAAS,+HAYnB,IAAI,qBA6XN,CAAA"}
@@ -161,7 +161,7 @@ const sanitizeDate = ({ field, locale, ref, value })=>{
161
161
  ref[field.name] = value;
162
162
  }
163
163
  };
164
- const stripFields = ({ config, data, fields, reservedKeys = [] })=>{
164
+ const stripFields = ({ config, data, fields, parentIsLocalized = false, reservedKeys = [] })=>{
165
165
  for(const k in data){
166
166
  if (!fields.some((field)=>field.name === k) && !reservedKeys.includes(k)) {
167
167
  delete data[k];
@@ -173,11 +173,15 @@ const stripFields = ({ config, data, fields, reservedKeys = [] })=>{
173
173
  if (!fieldData || typeof fieldData !== 'object') {
174
174
  continue;
175
175
  }
176
+ const shouldLocalizeField = fieldShouldBeLocalized({
177
+ field,
178
+ parentIsLocalized
179
+ });
176
180
  if (field.type === 'blocks') {
177
181
  reservedKeys.push('blockType');
178
182
  }
179
183
  if ('flattenedFields' in field || 'blocks' in field) {
180
- if (field.localized && config.localization) {
184
+ if (shouldLocalizeField && config.localization) {
181
185
  for(const localeKey in fieldData){
182
186
  if (!config.localization.localeCodes.some((code)=>code === localeKey)) {
183
187
  delete fieldData[localeKey];
@@ -185,9 +189,6 @@ const stripFields = ({ config, data, fields, reservedKeys = [] })=>{
185
189
  }
186
190
  const localeData = fieldData[localeKey];
187
191
  if (!localeData || typeof localeData !== 'object') {
188
- if (field.type === 'blocks') {
189
- fieldData[localeKey] = [];
190
- }
191
192
  continue;
192
193
  }
193
194
  if (field.type === 'array' || field.type === 'blocks') {
@@ -232,6 +233,7 @@ const stripFields = ({ config, data, fields, reservedKeys = [] })=>{
232
233
  config,
233
234
  data,
234
235
  fields,
236
+ parentIsLocalized: parentIsLocalized || field.localized,
235
237
  reservedKeys
236
238
  });
237
239
  }
@@ -244,6 +246,7 @@ const stripFields = ({ config, data, fields, reservedKeys = [] })=>{
244
246
  config,
245
247
  data: localeData,
246
248
  fields: field.flattenedFields,
249
+ parentIsLocalized: parentIsLocalized || field.localized,
247
250
  reservedKeys
248
251
  });
249
252
  }
@@ -292,6 +295,7 @@ const stripFields = ({ config, data, fields, reservedKeys = [] })=>{
292
295
  config,
293
296
  data,
294
297
  fields,
298
+ parentIsLocalized: parentIsLocalized || field.localized,
295
299
  reservedKeys
296
300
  });
297
301
  }
@@ -304,6 +308,7 @@ const stripFields = ({ config, data, fields, reservedKeys = [] })=>{
304
308
  config,
305
309
  data: fieldData,
306
310
  fields: field.flattenedFields,
311
+ parentIsLocalized: parentIsLocalized || field.localized,
307
312
  reservedKeys
308
313
  });
309
314
  }
@@ -351,6 +356,7 @@ export const transform = ({ $addToSet, $inc, $pull, $push, adapter, data, fields
351
356
  cache: true,
352
357
  fields
353
358
  }),
359
+ parentIsLocalized: false,
354
360
  reservedKeys: [
355
361
  'id',
356
362
  'globalType'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/transform.ts"],"sourcesContent":["import type {\n CollectionConfig,\n DateField,\n Field,\n FlattenedBlock,\n FlattenedField,\n JoinField,\n RelationshipField,\n SanitizedConfig,\n TraverseFieldsCallback,\n UploadField,\n} from 'payload'\n\nimport { Types } from 'mongoose'\nimport { flattenAllFields, traverseFields } from 'payload'\nimport { fieldAffectsData, fieldShouldBeLocalized } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { isObjectID } from './isObjectID.js'\n\ninterface RelationObject {\n relationTo: string\n value: number | string\n}\n\nfunction isValidRelationObject(value: unknown): value is RelationObject {\n return typeof value === 'object' && value !== null && 'relationTo' in value && 'value' in value\n}\n\n/**\n * Process relationship values for polymorphic and simple relationships\n * Used by both $push and $remove operations\n */\nconst processRelationshipValues = (\n items: unknown[],\n field: RelationshipField | UploadField,\n config: SanitizedConfig,\n operation: 'read' | 'write',\n validateRelationships: boolean,\n adapter: MongooseAdapter,\n) => {\n return items.map((item) => {\n // Handle polymorphic relationships\n if (Array.isArray(field.relationTo) && isValidRelationObject(item)) {\n const relatedCollection = config.collections?.find(({ slug }) => slug === item.relationTo)\n if (relatedCollection) {\n return {\n relationTo: item.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: item.value,\n }),\n }\n }\n return item\n }\n\n // Handle simple relationships\n if (typeof field.relationTo === 'string') {\n const relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n if (relatedCollection) {\n return convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: item,\n })\n }\n }\n\n return item\n })\n}\n\nconst convertRelationshipValue = ({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value,\n}: {\n adapter: MongooseAdapter\n operation: Args['operation']\n relatedCollection: CollectionConfig\n validateRelationships?: boolean\n value: unknown\n}) => {\n const customIDField = relatedCollection.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (operation === 'read') {\n if (isObjectID(value)) {\n return value.toHexString()\n }\n\n if (\n customIDField?.type === 'number' &&\n typeof value === 'bigint' &&\n adapter.useBigIntForNumberIDs\n ) {\n return Number(value)\n }\n\n return value\n }\n\n if (customIDField) {\n return value\n }\n\n if (typeof value === 'string') {\n try {\n return new Types.ObjectId(value)\n } catch (e) {\n if (validateRelationships) {\n throw e\n }\n return value\n }\n }\n\n return value\n}\n\nconst sanitizeRelationship = ({\n adapter,\n config,\n field,\n locale,\n operation,\n ref,\n validateRelationships,\n value,\n}: {\n adapter: MongooseAdapter\n config: SanitizedConfig\n field: JoinField | RelationshipField | UploadField\n locale?: string\n operation: Args['operation']\n ref: Record<string, unknown>\n validateRelationships?: boolean\n value?: unknown\n}) => {\n if (field.type === 'join') {\n if (\n operation === 'read' &&\n value &&\n typeof value === 'object' &&\n 'docs' in value &&\n Array.isArray(value.docs)\n ) {\n for (let i = 0; i < value.docs.length; i++) {\n const item = value.docs[i]\n\n if (isObjectID(item)) {\n value.docs[i] = item.toHexString()\n } else if (Array.isArray(field.collection) && item) {\n // Fields here for polymorphic joins cannot be determinted, JSON.parse needed\n value.docs[i] = JSON.parse(JSON.stringify(value.docs[i]))\n }\n }\n }\n\n return value\n }\n let relatedCollection: CollectionConfig | undefined\n let result = value\n\n const hasManyRelations = typeof field.relationTo !== 'string'\n\n if (!hasManyRelations) {\n relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n }\n\n if (Array.isArray(value)) {\n result = value.map((val) => {\n // Handle has many - polymorphic\n if (isValidRelationObject(val)) {\n const relatedCollectionForSingleValue = config.collections?.find(\n ({ slug }) => slug === val.relationTo,\n )\n\n if (relatedCollectionForSingleValue) {\n return {\n relationTo: val.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection: relatedCollectionForSingleValue,\n validateRelationships,\n value: val.value,\n }),\n }\n }\n }\n\n if (relatedCollection) {\n return convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: val,\n })\n }\n\n return val\n })\n }\n // Handle has one - polymorphic\n else if (isValidRelationObject(value)) {\n relatedCollection = config.collections?.find(({ slug }) => slug === value.relationTo)\n\n if (relatedCollection) {\n result = {\n relationTo: value.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: value.value,\n }),\n }\n }\n }\n // Handle has one\n else if (relatedCollection) {\n result = convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value,\n })\n }\n\n if (locale) {\n ref[locale] = result\n } else {\n ref[field.name] = result\n }\n}\n\nconst sanitizeDate = ({\n field,\n locale,\n ref,\n value,\n}: {\n field: DateField\n locale?: string\n ref: Record<string, unknown>\n value: unknown\n}) => {\n if (!value) {\n return\n }\n\n if (value instanceof Date) {\n value = value.toISOString()\n }\n\n if (locale) {\n ref[locale] = value\n } else {\n ref[field.name] = value\n }\n}\n\ntype Args = {\n $addToSet?: Record<string, { $each: any[] } | any>\n $inc?: Record<string, number>\n $pull?: Record<string, { $in: any[] } | any>\n $push?: Record<string, { $each: any[] } | any>\n /** instance of the adapter */\n adapter: MongooseAdapter\n /** data to transform, can be an array of documents or a single document */\n data: Record<string, unknown> | Record<string, unknown>[]\n /** fields accossiated with the data */\n fields: Field[]\n /** slug of the global, pass only when the operation is `write` */\n globalSlug?: string\n /**\n * Type of the operation\n * read - sanitizes ObjectIDs, Date to strings.\n * write - sanitizes string relationships to ObjectIDs.\n */\n operation: 'read' | 'write'\n parentIsLocalized?: boolean\n /**\n * Throw errors on invalid relationships\n * @default true\n */\n validateRelationships?: boolean\n}\n\nconst stripFields = ({\n config,\n data,\n fields,\n reservedKeys = [],\n}: {\n config: SanitizedConfig\n data: any\n fields: FlattenedField[]\n reservedKeys?: string[]\n}) => {\n for (const k in data) {\n if (!fields.some((field) => field.name === k) && !reservedKeys.includes(k)) {\n delete data[k]\n }\n }\n\n for (const field of fields) {\n reservedKeys = []\n const fieldData = data[field.name]\n if (!fieldData || typeof fieldData !== 'object') {\n continue\n }\n\n if (field.type === 'blocks') {\n reservedKeys.push('blockType')\n }\n\n if ('flattenedFields' in field || 'blocks' in field) {\n if (field.localized && config.localization) {\n for (const localeKey in fieldData) {\n if (!config.localization.localeCodes.some((code) => code === localeKey)) {\n delete fieldData[localeKey]\n continue\n }\n\n const localeData = fieldData[localeKey]\n\n if (!localeData || typeof localeData !== 'object') {\n if (field.type === 'blocks') {\n fieldData[localeKey] = []\n }\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(localeData)) {\n continue\n }\n\n let hasNull = false\n for (let i = 0; i < localeData.length; i++) {\n const data = localeData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n localeData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({ config, data, fields, reservedKeys })\n }\n\n if (hasNull) {\n fieldData[localeKey] = localeData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({ config, data: localeData, fields: field.flattenedFields, reservedKeys })\n }\n }\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(fieldData)) {\n continue\n }\n\n let hasNull = false\n\n for (let i = 0; i < fieldData.length; i++) {\n const data = fieldData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n fieldData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({ config, data, fields, reservedKeys })\n }\n\n if (hasNull) {\n data[field.name] = fieldData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({ config, data: fieldData, fields: field.flattenedFields, reservedKeys })\n }\n }\n }\n}\n\nexport const transform = ({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter,\n data,\n fields,\n globalSlug,\n operation,\n parentIsLocalized = false,\n validateRelationships = true,\n}: Args) => {\n if (!data) {\n return null\n }\n\n if (Array.isArray(data)) {\n for (const item of data) {\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter,\n data: item,\n fields,\n globalSlug,\n operation,\n validateRelationships,\n })\n }\n return\n }\n\n const {\n payload: { config },\n } = adapter\n\n if (operation === 'read') {\n delete data['__v']\n data.id = data._id || data.id\n delete data['_id']\n\n if (isObjectID(data.id)) {\n data.id = data.id.toHexString()\n }\n\n // Handle BigInt conversion for custom ID fields of type 'number'\n if (adapter.useBigIntForNumberIDs && typeof data.id === 'bigint') {\n data.id = Number(data.id)\n }\n\n if (!adapter.allowAdditionalKeys) {\n stripFields({\n config,\n data,\n fields: flattenAllFields({ cache: true, fields }),\n reservedKeys: ['id', 'globalType'],\n })\n }\n }\n\n if (operation === 'write' && globalSlug) {\n data.globalType = globalSlug\n }\n\n const sanitize: TraverseFieldsCallback = ({\n field,\n parentIsLocalized,\n parentPath,\n parentRef: incomingParentRef,\n ref: incomingRef,\n }) => {\n if (!incomingRef || typeof incomingRef !== 'object') {\n return\n }\n\n const ref = incomingRef as Record<string, unknown>\n const parentRef = (incomingParentRef || {}) as Record<string, unknown>\n\n // Clear empty parent containers by setting them to undefined.\n const clearEmptyContainer = () => {\n if (!parentRef || typeof parentRef !== 'object') {\n return\n }\n if (!ref || typeof ref !== 'object') {\n return\n }\n if (Object.keys(ref).length > 0) {\n return\n }\n const containerKey = Object.keys(parentRef).find((k) => parentRef[k] === ref)\n if (containerKey) {\n parentRef[containerKey] = undefined\n }\n }\n\n if (\n $inc &&\n field.type === 'number' &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n if (value && typeof value === 'object' && '$inc' in value && typeof value.$inc === 'number') {\n $inc[`${parentPath}${field.name}`] = value.$inc\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n\n if (\n $push &&\n field.type === 'array' &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n\n if (\n value &&\n typeof value === 'object' &&\n ('$push' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue && typeof localeValue === 'object' && '$push' in localeValue,\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $push: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n if (Array.isArray(push)) {\n $push[`${parentPath}${field.name}.${localeKey}`] = { $each: push }\n } else if (typeof push === 'object') {\n $push[`${parentPath}${field.name}.${localeKey}`] = push\n }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$push' in value) {\n // Handle non-localized fields: { field: { $push: data } }\n const push = value.$push\n if (Array.isArray(push)) {\n $push[`${parentPath}${field.name}`] = { $each: push }\n } else if (typeof push === 'object') {\n $push[`${parentPath}${field.name}`] = push\n }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n // Handle $push operation for relationship fields (converts to $addToSet)\n\n // Handle $push operation for relationship fields (converts to $addToSet) - unified approach\n if (\n $addToSet &&\n (field.type === 'relationship' || field.type === 'upload') &&\n 'hasMany' in field &&\n field.hasMany &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n\n if (\n value &&\n typeof value === 'object' &&\n ('$push' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$push' in (localeValue as Record<string, unknown>),\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $push: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n const localeItems = Array.isArray(push) ? push : [push]\n const processedLocaleItems = processRelationshipValues(\n localeItems,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $addToSet[`${parentPath}${field.name}.${localeKey}`] = { $each: processedLocaleItems }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$push' in value) {\n // Handle non-localized fields: { field: { $push: data } }\n const itemsToAppend = Array.isArray(value.$push) ? value.$push : [value.$push]\n const processedItems = processRelationshipValues(\n itemsToAppend,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $addToSet[`${parentPath}${field.name}`] = { $each: processedItems }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n // Handle $remove operation for relationship fields (converts to $pull)\n if (\n $pull &&\n (field.type === 'relationship' || field.type === 'upload') &&\n 'hasMany' in field &&\n field.hasMany &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n if (\n value &&\n typeof value === 'object' &&\n ('$remove' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$remove' in (localeValue as Record<string, unknown>),\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $remove: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$remove' in localeValue) {\n hasLocaleOperations = true\n const remove = localeValue.$remove\n const localeItems = Array.isArray(remove) ? remove : [remove]\n const processedLocaleItems = processRelationshipValues(\n localeItems,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $pull[`${parentPath}${field.name}.${localeKey}`] = { $in: processedLocaleItems }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$remove' in value) {\n // Handle non-localized fields: { field: { $remove: data } }\n const itemsToRemove = Array.isArray(value.$remove) ? value.$remove : [value.$remove]\n const processedItems = processRelationshipValues(\n itemsToRemove,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $pull[`${parentPath}${field.name}`] = { $in: processedItems }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n if (field.type === 'date' && operation === 'read' && field.name in ref && ref[field.name]) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n const fieldRef = ref[field.name] as Record<string, unknown>\n if (!fieldRef || typeof fieldRef !== 'object') {\n return\n }\n\n for (const locale of config.localization.localeCodes) {\n sanitizeDate({\n field,\n locale,\n ref: fieldRef,\n value: fieldRef[locale],\n })\n }\n } else {\n sanitizeDate({\n field,\n ref,\n value: ref[field.name],\n })\n }\n }\n\n if (\n field.type === 'relationship' ||\n field.type === 'upload' ||\n (operation === 'read' && field.type === 'join')\n ) {\n if (!ref[field.name]) {\n return\n }\n\n // handle localized relationships\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n const locales = config.localization.locales\n const fieldRef = ref[field.name] as Record<string, unknown>\n if (typeof fieldRef !== 'object') {\n return\n }\n\n for (const { code } of locales) {\n const value = fieldRef[code]\n if (value) {\n sanitizeRelationship({\n adapter,\n config,\n field,\n locale: code,\n operation,\n ref: fieldRef,\n validateRelationships,\n value,\n })\n }\n }\n } else {\n // handle non-localized relationships\n sanitizeRelationship({\n adapter,\n config,\n field,\n locale: undefined,\n operation,\n ref,\n validateRelationships,\n value: ref[field.name],\n })\n }\n }\n }\n\n traverseFields({\n callback: sanitize,\n config,\n fields,\n fillEmpty: false,\n parentIsLocalized,\n ref: data,\n })\n\n if (operation === 'write') {\n if (typeof data.updatedAt === 'undefined') {\n // If data.updatedAt is explicitly set to `null` we should not set it - this means we don't want to change the value of updatedAt.\n data.updatedAt = new Date().toISOString()\n } else if (data.updatedAt === null) {\n // `updatedAt` may be explicitly set to null to disable updating it - if that is the case, we need to delete the property. Keeping it as null will\n // cause the database to think we want to set it to null, which we don't.\n delete data.updatedAt\n }\n }\n}\n"],"names":["Types","flattenAllFields","traverseFields","fieldAffectsData","fieldShouldBeLocalized","isObjectID","isValidRelationObject","value","processRelationshipValues","items","field","config","operation","validateRelationships","adapter","map","item","Array","isArray","relationTo","relatedCollection","collections","find","slug","convertRelationshipValue","customIDField","fields","name","toHexString","type","useBigIntForNumberIDs","Number","ObjectId","e","sanitizeRelationship","locale","ref","docs","i","length","collection","JSON","parse","stringify","result","hasManyRelations","val","relatedCollectionForSingleValue","sanitizeDate","Date","toISOString","stripFields","data","reservedKeys","k","some","includes","fieldData","push","localized","localization","localeKey","localeCodes","code","localeData","hasNull","flattenedFields","maybeBlock","undefined","blockReferences","maybeBlockReference","each","blockType","blocks","filter","Boolean","transform","$addToSet","$inc","$pull","$push","globalSlug","parentIsLocalized","payload","id","_id","allowAdditionalKeys","cache","globalType","sanitize","parentPath","parentRef","incomingParentRef","incomingRef","clearEmptyContainer","Object","keys","containerKey","values","localeValue","hasLocaleOperations","entries","forEach","$each","hasMany","localeItems","processedLocaleItems","itemsToAppend","processedItems","remove","$remove","$in","itemsToRemove","fieldRef","locales","callback","fillEmpty","updatedAt"],"mappings":"AAaA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,UAAS;AAC1D,SAASC,gBAAgB,EAAEC,sBAAsB,QAAQ,iBAAgB;AAIzE,SAASC,UAAU,QAAQ,kBAAiB;AAO5C,SAASC,sBAAsBC,KAAc;IAC3C,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,gBAAgBA,SAAS,WAAWA;AAC5F;AAEA;;;CAGC,GACD,MAAMC,4BAA4B,CAChCC,OACAC,OACAC,QACAC,WACAC,uBACAC;IAEA,OAAOL,MAAMM,GAAG,CAAC,CAACC;QAChB,mCAAmC;QACnC,IAAIC,MAAMC,OAAO,CAACR,MAAMS,UAAU,KAAKb,sBAAsBU,OAAO;YAClE,MAAMI,oBAAoBT,OAAOU,WAAW,EAAEC,KAAK,CAAC,EAAEC,IAAI,EAAE,GAAKA,S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;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/transform.ts"],"sourcesContent":["import type {\n CollectionConfig,\n DateField,\n Field,\n FlattenedBlock,\n FlattenedField,\n JoinField,\n RelationshipField,\n SanitizedConfig,\n TraverseFieldsCallback,\n UploadField,\n} from 'payload'\n\nimport { Types } from 'mongoose'\nimport { flattenAllFields, traverseFields } from 'payload'\nimport { fieldAffectsData, fieldShouldBeLocalized } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { isObjectID } from './isObjectID.js'\n\ninterface RelationObject {\n relationTo: string\n value: number | string\n}\n\nfunction isValidRelationObject(value: unknown): value is RelationObject {\n return typeof value === 'object' && value !== null && 'relationTo' in value && 'value' in value\n}\n\n/**\n * Process relationship values for polymorphic and simple relationships\n * Used by both $push and $remove operations\n */\nconst processRelationshipValues = (\n items: unknown[],\n field: RelationshipField | UploadField,\n config: SanitizedConfig,\n operation: 'read' | 'write',\n validateRelationships: boolean,\n adapter: MongooseAdapter,\n) => {\n return items.map((item) => {\n // Handle polymorphic relationships\n if (Array.isArray(field.relationTo) && isValidRelationObject(item)) {\n const relatedCollection = config.collections?.find(({ slug }) => slug === item.relationTo)\n if (relatedCollection) {\n return {\n relationTo: item.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: item.value,\n }),\n }\n }\n return item\n }\n\n // Handle simple relationships\n if (typeof field.relationTo === 'string') {\n const relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n if (relatedCollection) {\n return convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: item,\n })\n }\n }\n\n return item\n })\n}\n\nconst convertRelationshipValue = ({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value,\n}: {\n adapter: MongooseAdapter\n operation: Args['operation']\n relatedCollection: CollectionConfig\n validateRelationships?: boolean\n value: unknown\n}) => {\n const customIDField = relatedCollection.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (operation === 'read') {\n if (isObjectID(value)) {\n return value.toHexString()\n }\n\n if (\n customIDField?.type === 'number' &&\n typeof value === 'bigint' &&\n adapter.useBigIntForNumberIDs\n ) {\n return Number(value)\n }\n\n return value\n }\n\n if (customIDField) {\n return value\n }\n\n if (typeof value === 'string') {\n try {\n return new Types.ObjectId(value)\n } catch (e) {\n if (validateRelationships) {\n throw e\n }\n return value\n }\n }\n\n return value\n}\n\nconst sanitizeRelationship = ({\n adapter,\n config,\n field,\n locale,\n operation,\n ref,\n validateRelationships,\n value,\n}: {\n adapter: MongooseAdapter\n config: SanitizedConfig\n field: JoinField | RelationshipField | UploadField\n locale?: string\n operation: Args['operation']\n ref: Record<string, unknown>\n validateRelationships?: boolean\n value?: unknown\n}) => {\n if (field.type === 'join') {\n if (\n operation === 'read' &&\n value &&\n typeof value === 'object' &&\n 'docs' in value &&\n Array.isArray(value.docs)\n ) {\n for (let i = 0; i < value.docs.length; i++) {\n const item = value.docs[i]\n\n if (isObjectID(item)) {\n value.docs[i] = item.toHexString()\n } else if (Array.isArray(field.collection) && item) {\n // Fields here for polymorphic joins cannot be determinted, JSON.parse needed\n value.docs[i] = JSON.parse(JSON.stringify(value.docs[i]))\n }\n }\n }\n\n return value\n }\n let relatedCollection: CollectionConfig | undefined\n let result = value\n\n const hasManyRelations = typeof field.relationTo !== 'string'\n\n if (!hasManyRelations) {\n relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n }\n\n if (Array.isArray(value)) {\n result = value.map((val) => {\n // Handle has many - polymorphic\n if (isValidRelationObject(val)) {\n const relatedCollectionForSingleValue = config.collections?.find(\n ({ slug }) => slug === val.relationTo,\n )\n\n if (relatedCollectionForSingleValue) {\n return {\n relationTo: val.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection: relatedCollectionForSingleValue,\n validateRelationships,\n value: val.value,\n }),\n }\n }\n }\n\n if (relatedCollection) {\n return convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: val,\n })\n }\n\n return val\n })\n }\n // Handle has one - polymorphic\n else if (isValidRelationObject(value)) {\n relatedCollection = config.collections?.find(({ slug }) => slug === value.relationTo)\n\n if (relatedCollection) {\n result = {\n relationTo: value.relationTo,\n value: convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value: value.value,\n }),\n }\n }\n }\n // Handle has one\n else if (relatedCollection) {\n result = convertRelationshipValue({\n adapter,\n operation,\n relatedCollection,\n validateRelationships,\n value,\n })\n }\n\n if (locale) {\n ref[locale] = result\n } else {\n ref[field.name] = result\n }\n}\n\nconst sanitizeDate = ({\n field,\n locale,\n ref,\n value,\n}: {\n field: DateField\n locale?: string\n ref: Record<string, unknown>\n value: unknown\n}) => {\n if (!value) {\n return\n }\n\n if (value instanceof Date) {\n value = value.toISOString()\n }\n\n if (locale) {\n ref[locale] = value\n } else {\n ref[field.name] = value\n }\n}\n\ntype Args = {\n $addToSet?: Record<string, { $each: any[] } | any>\n $inc?: Record<string, number>\n $pull?: Record<string, { $in: any[] } | any>\n $push?: Record<string, { $each: any[] } | any>\n /** instance of the adapter */\n adapter: MongooseAdapter\n /** data to transform, can be an array of documents or a single document */\n data: Record<string, unknown> | Record<string, unknown>[]\n /** fields accossiated with the data */\n fields: Field[]\n /** slug of the global, pass only when the operation is `write` */\n globalSlug?: string\n /**\n * Type of the operation\n * read - sanitizes ObjectIDs, Date to strings.\n * write - sanitizes string relationships to ObjectIDs.\n */\n operation: 'read' | 'write'\n parentIsLocalized?: boolean\n /**\n * Throw errors on invalid relationships\n * @default true\n */\n validateRelationships?: boolean\n}\n\nconst stripFields = ({\n config,\n data,\n fields,\n parentIsLocalized = false,\n reservedKeys = [],\n}: {\n config: SanitizedConfig\n data: any\n fields: FlattenedField[]\n parentIsLocalized?: boolean\n reservedKeys?: string[]\n}) => {\n for (const k in data) {\n if (!fields.some((field) => field.name === k) && !reservedKeys.includes(k)) {\n delete data[k]\n }\n }\n\n for (const field of fields) {\n reservedKeys = []\n const fieldData = data[field.name]\n if (!fieldData || typeof fieldData !== 'object') {\n continue\n }\n\n const shouldLocalizeField = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n if (field.type === 'blocks') {\n reservedKeys.push('blockType')\n }\n\n if ('flattenedFields' in field || 'blocks' in field) {\n if (shouldLocalizeField && config.localization) {\n for (const localeKey in fieldData) {\n if (!config.localization.localeCodes.some((code) => code === localeKey)) {\n delete fieldData[localeKey]\n continue\n }\n\n const localeData = fieldData[localeKey]\n\n if (!localeData || typeof localeData !== 'object') {\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(localeData)) {\n continue\n }\n\n let hasNull = false\n for (let i = 0; i < localeData.length; i++) {\n const data = localeData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n localeData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({\n config,\n data,\n fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n\n if (hasNull) {\n fieldData[localeKey] = localeData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({\n config,\n data: localeData,\n fields: field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n }\n continue\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n if (!Array.isArray(fieldData)) {\n continue\n }\n\n let hasNull = false\n\n for (let i = 0; i < fieldData.length; i++) {\n const data = fieldData[i]\n let fields: FlattenedField[] | null = null\n\n if (field.type === 'array') {\n fields = field.flattenedFields\n } else {\n let maybeBlock: FlattenedBlock | undefined = undefined\n\n if (field.blockReferences) {\n const maybeBlockReference = field.blockReferences.find((each) => {\n const slug = typeof each === 'string' ? each : each.slug\n return slug === data.blockType\n })\n\n if (maybeBlockReference) {\n if (typeof maybeBlockReference === 'object') {\n maybeBlock = maybeBlockReference\n } else {\n maybeBlock = config.blocks?.find((each) => each.slug === maybeBlockReference)\n }\n }\n }\n\n if (!maybeBlock) {\n maybeBlock = field.blocks.find((each) => each.slug === data.blockType)\n }\n\n if (maybeBlock) {\n fields = maybeBlock.flattenedFields\n } else {\n fieldData[i] = null\n hasNull = true\n }\n }\n\n if (!fields) {\n continue\n }\n\n stripFields({\n config,\n data,\n fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n\n if (hasNull) {\n data[field.name] = fieldData.filter(Boolean)\n }\n\n continue\n } else {\n stripFields({\n config,\n data: fieldData,\n fields: field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n reservedKeys,\n })\n }\n }\n }\n}\n\nexport const transform = ({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter,\n data,\n fields,\n globalSlug,\n operation,\n parentIsLocalized = false,\n validateRelationships = true,\n}: Args) => {\n if (!data) {\n return null\n }\n\n if (Array.isArray(data)) {\n for (const item of data) {\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter,\n data: item,\n fields,\n globalSlug,\n operation,\n validateRelationships,\n })\n }\n return\n }\n\n const {\n payload: { config },\n } = adapter\n\n if (operation === 'read') {\n delete data['__v']\n data.id = data._id || data.id\n delete data['_id']\n\n if (isObjectID(data.id)) {\n data.id = data.id.toHexString()\n }\n\n // Handle BigInt conversion for custom ID fields of type 'number'\n if (adapter.useBigIntForNumberIDs && typeof data.id === 'bigint') {\n data.id = Number(data.id)\n }\n\n if (!adapter.allowAdditionalKeys) {\n stripFields({\n config,\n data,\n fields: flattenAllFields({ cache: true, fields }),\n parentIsLocalized: false,\n reservedKeys: ['id', 'globalType'],\n })\n }\n }\n\n if (operation === 'write' && globalSlug) {\n data.globalType = globalSlug\n }\n\n const sanitize: TraverseFieldsCallback = ({\n field,\n parentIsLocalized,\n parentPath,\n parentRef: incomingParentRef,\n ref: incomingRef,\n }) => {\n if (!incomingRef || typeof incomingRef !== 'object') {\n return\n }\n\n const ref = incomingRef as Record<string, unknown>\n const parentRef = (incomingParentRef || {}) as Record<string, unknown>\n\n // Clear empty parent containers by setting them to undefined.\n const clearEmptyContainer = () => {\n if (!parentRef || typeof parentRef !== 'object') {\n return\n }\n if (!ref || typeof ref !== 'object') {\n return\n }\n if (Object.keys(ref).length > 0) {\n return\n }\n const containerKey = Object.keys(parentRef).find((k) => parentRef[k] === ref)\n if (containerKey) {\n parentRef[containerKey] = undefined\n }\n }\n\n if (\n $inc &&\n field.type === 'number' &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n if (value && typeof value === 'object' && '$inc' in value && typeof value.$inc === 'number') {\n $inc[`${parentPath}${field.name}`] = value.$inc\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n\n if (\n $push &&\n field.type === 'array' &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n\n if (\n value &&\n typeof value === 'object' &&\n ('$push' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue && typeof localeValue === 'object' && '$push' in localeValue,\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $push: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n if (Array.isArray(push)) {\n $push[`${parentPath}${field.name}.${localeKey}`] = { $each: push }\n } else if (typeof push === 'object') {\n $push[`${parentPath}${field.name}.${localeKey}`] = push\n }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$push' in value) {\n // Handle non-localized fields: { field: { $push: data } }\n const push = value.$push\n if (Array.isArray(push)) {\n $push[`${parentPath}${field.name}`] = { $each: push }\n } else if (typeof push === 'object') {\n $push[`${parentPath}${field.name}`] = push\n }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n // Handle $push operation for relationship fields (converts to $addToSet)\n\n // Handle $push operation for relationship fields (converts to $addToSet) - unified approach\n if (\n $addToSet &&\n (field.type === 'relationship' || field.type === 'upload') &&\n 'hasMany' in field &&\n field.hasMany &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n\n if (\n value &&\n typeof value === 'object' &&\n ('$push' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$push' in (localeValue as Record<string, unknown>),\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $push: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n const localeItems = Array.isArray(push) ? push : [push]\n const processedLocaleItems = processRelationshipValues(\n localeItems,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $addToSet[`${parentPath}${field.name}.${localeKey}`] = { $each: processedLocaleItems }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$push' in value) {\n // Handle non-localized fields: { field: { $push: data } }\n const itemsToAppend = Array.isArray(value.$push) ? value.$push : [value.$push]\n const processedItems = processRelationshipValues(\n itemsToAppend,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $addToSet[`${parentPath}${field.name}`] = { $each: processedItems }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n // Handle $remove operation for relationship fields (converts to $pull)\n if (\n $pull &&\n (field.type === 'relationship' || field.type === 'upload') &&\n 'hasMany' in field &&\n field.hasMany &&\n operation === 'write' &&\n field.name in ref &&\n ref[field.name]\n ) {\n const value = ref[field.name]\n if (\n value &&\n typeof value === 'object' &&\n ('$remove' in value ||\n (config.localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n Object.values(value).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$remove' in (localeValue as Record<string, unknown>),\n )))\n ) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n // Handle localized fields: { field: { locale: { $remove: data } } }\n let hasLocaleOperations = false\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$remove' in localeValue) {\n hasLocaleOperations = true\n const remove = localeValue.$remove\n const localeItems = Array.isArray(remove) ? remove : [remove]\n const processedLocaleItems = processRelationshipValues(\n localeItems,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $pull[`${parentPath}${field.name}.${localeKey}`] = { $in: processedLocaleItems }\n }\n })\n\n if (hasLocaleOperations) {\n delete ref[field.name]\n clearEmptyContainer()\n }\n } else if (value && typeof value === 'object' && '$remove' in value) {\n // Handle non-localized fields: { field: { $remove: data } }\n const itemsToRemove = Array.isArray(value.$remove) ? value.$remove : [value.$remove]\n const processedItems = processRelationshipValues(\n itemsToRemove,\n field,\n config,\n operation,\n validateRelationships,\n adapter,\n )\n $pull[`${parentPath}${field.name}`] = { $in: processedItems }\n delete ref[field.name]\n clearEmptyContainer()\n }\n }\n }\n\n if (field.type === 'date' && operation === 'read' && field.name in ref && ref[field.name]) {\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n const fieldRef = ref[field.name] as Record<string, unknown>\n if (!fieldRef || typeof fieldRef !== 'object') {\n return\n }\n\n for (const locale of config.localization.localeCodes) {\n sanitizeDate({\n field,\n locale,\n ref: fieldRef,\n value: fieldRef[locale],\n })\n }\n } else {\n sanitizeDate({\n field,\n ref,\n value: ref[field.name],\n })\n }\n }\n\n if (\n field.type === 'relationship' ||\n field.type === 'upload' ||\n (operation === 'read' && field.type === 'join')\n ) {\n if (!ref[field.name]) {\n return\n }\n\n // handle localized relationships\n if (config.localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n const locales = config.localization.locales\n const fieldRef = ref[field.name] as Record<string, unknown>\n if (typeof fieldRef !== 'object') {\n return\n }\n\n for (const { code } of locales) {\n const value = fieldRef[code]\n if (value) {\n sanitizeRelationship({\n adapter,\n config,\n field,\n locale: code,\n operation,\n ref: fieldRef,\n validateRelationships,\n value,\n })\n }\n }\n } else {\n // handle non-localized relationships\n sanitizeRelationship({\n adapter,\n config,\n field,\n locale: undefined,\n operation,\n ref,\n validateRelationships,\n value: ref[field.name],\n })\n }\n }\n }\n\n traverseFields({\n callback: sanitize,\n config,\n fields,\n fillEmpty: false,\n parentIsLocalized,\n ref: data,\n })\n\n if (operation === 'write') {\n if (typeof data.updatedAt === 'undefined') {\n // If data.updatedAt is explicitly set to `null` we should not set it - this means we don't want to change the value of updatedAt.\n data.updatedAt = new Date().toISOString()\n } else if (data.updatedAt === null) {\n // `updatedAt` may be explicitly set to null to disable updating it - if that is the case, we need to delete the property. Keeping it as null will\n // cause the database to think we want to set it to null, which we don't.\n delete data.updatedAt\n }\n }\n}\n"],"names":["Types","flattenAllFields","traverseFields","fieldAffectsData","fieldShouldBeLocalized","isObjectID","isValidRelationObject","value","processRelationshipValues","items","field","config","operation","validateRelationships","adapter","map","item","Array","isArray","relationTo","relatedCollection","collections","find","slug","convertRelationshipValue","customIDField","fields","name","toHexString","type","useBigIntForNumberIDs","Number","ObjectId","e","sanitizeRelationship","locale","ref","docs","i","length","collection","JSON","parse","stringify","result","hasManyRelations","val","relatedCollectionForSingleValue","sanitizeDate","Date","toISOString","stripFields","data","parentIsLocalized","reservedKeys","k","some","includes","fieldData","shouldLocalizeField","push","localization","localeKey","localeCodes","code","localeData","hasNull","flattenedFields","maybeBlock","undefined","blockReferences","maybeBlockReference","each","blockType","blocks","localized","filter","Boolean","transform","$addToSet","$inc","$pull","$push","globalSlug","payload","id","_id","allowAdditionalKeys","cache","globalType","sanitize","parentPath","parentRef","incomingParentRef","incomingRef","clearEmptyContainer","Object","keys","containerKey","values","localeValue","hasLocaleOperations","entries","forEach","$each","hasMany","localeItems","processedLocaleItems","itemsToAppend","processedItems","remove","$remove","$in","itemsToRemove","fieldRef","locales","callback","fillEmpty","updatedAt"],"mappings":"AAaA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,UAAS;AAC1D,SAASC,gBAAgB,EAAEC,sBAAsB,QAAQ,iBAAgB;AAIzE,SAASC,UAAU,QAAQ,kBAAiB;AAO5C,SAASC,sBAAsBC,KAAc;IAC3C,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,gBAAgBA,SAAS,WAAWA;AAC5F;AAEA;;;CAGC,GACD,MAAMC,4BAA4B,CAChCC,OACAC,OACAC,QACAC,WACAC,uBACAC;IAEA,OAAOL,MAAMM,GAAG,CAAC,CAACC;QAChB,mCAAmC;QACnC,IAAIC,MAAMC,OAAO,CAACR,MAAMS,UAAU,KAAKb,sBAAsBU,OAAO;YAClE,MAAMI,oBAAoBT,OAAOU,WAAW,EAAEC,KAAK,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASP,KAAKG,UAAU;YACzF,IAAIC,mBAAmB;gBACrB,OAAO;oBACLD,YAAYH,KAAKG,UAAU;oBAC3BZ,OAAOiB,yBAAyB;wBAC9BV;wBACAF;wBACAQ;wBACAP;w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KAAKkE,SAAS;QACvB;IACF;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-mongodb",
3
- "version": "3.64.0-internal.fc1e451",
3
+ "version": "3.65.0-canary.0",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -49,11 +49,11 @@
49
49
  "@types/uuid": "10.0.0",
50
50
  "mongodb": "6.16.0",
51
51
  "mongodb-memory-server": "10.1.4",
52
- "payload": "3.64.0-internal.fc1e451",
52
+ "payload": "3.65.0-canary.0",
53
53
  "@payloadcms/eslint-config": "3.28.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "payload": "3.64.0-internal.fc1e451"
56
+ "payload": "3.65.0-canary.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "pnpm build:types && pnpm build:swc",