@payloadcms/db-mongodb 3.0.0-canary.98e0119 → 3.0.0-canary.99cbde3

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.
Files changed (49) hide show
  1. package/dist/index.d.ts +10 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/init.js +4 -4
  5. package/dist/init.js.map +1 -1
  6. package/dist/models/buildCollectionSchema.d.ts +2 -2
  7. package/dist/models/buildCollectionSchema.d.ts.map +1 -1
  8. package/dist/models/buildCollectionSchema.js +4 -4
  9. package/dist/models/buildCollectionSchema.js.map +1 -1
  10. package/dist/models/buildGlobalModel.d.ts +2 -2
  11. package/dist/models/buildGlobalModel.d.ts.map +1 -1
  12. package/dist/models/buildGlobalModel.js +4 -4
  13. package/dist/models/buildGlobalModel.js.map +1 -1
  14. package/dist/models/buildSchema.d.ts +2 -2
  15. package/dist/models/buildSchema.d.ts.map +1 -1
  16. package/dist/models/buildSchema.js +82 -61
  17. package/dist/models/buildSchema.js.map +1 -1
  18. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts.map +1 -1
  19. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +12 -7
  20. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -1
  21. package/dist/predefinedMigrations/relationships-v2-v3.js +1 -1
  22. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -1
  23. package/dist/predefinedMigrations/versions-v1-v2.js +1 -1
  24. package/dist/predefinedMigrations/versions-v1-v2.js.map +1 -1
  25. package/dist/queries/buildSearchParams.js +1 -0
  26. package/dist/queries/buildSearchParams.js.map +1 -1
  27. package/dist/queries/sanitizeQueryValue.d.ts +3 -2
  28. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  29. package/dist/queries/sanitizeQueryValue.js +145 -36
  30. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  31. package/dist/updateGlobal.d.ts.map +1 -1
  32. package/dist/updateGlobal.js +2 -1
  33. package/dist/updateGlobal.js.map +1 -1
  34. package/dist/updateGlobalVersion.d.ts +1 -1
  35. package/dist/updateGlobalVersion.d.ts.map +1 -1
  36. package/dist/updateGlobalVersion.js +2 -1
  37. package/dist/updateGlobalVersion.js.map +1 -1
  38. package/dist/updateVersion.d.ts.map +1 -1
  39. package/dist/updateVersion.js +2 -1
  40. package/dist/updateVersion.js.map +1 -1
  41. package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -1
  42. package/dist/utilities/buildProjectionFromSelect.js.map +1 -1
  43. package/dist/utilities/sanitizeRelationshipIDs.js +1 -0
  44. package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -1
  45. package/dist/utilities/sanitizeRelationshipIDs.spec.js +408 -0
  46. package/dist/utilities/sanitizeRelationshipIDs.spec.js.map +1 -0
  47. package/package.json +3 -4
  48. package/dist/queries/mock.js +0 -2
  49. package/dist/queries/mock.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/predefinedMigrations/migrateRelationshipsV2_V3.ts"],"sourcesContent":["import type { ClientSession, Model } from 'mongoose'\nimport type { Field, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { sanitizeRelationshipIDs } from '../utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from '../withSession.js'\n\nconst migrateModelWithBatching = async ({\n batchSize,\n config,\n fields,\n Model,\n session,\n}: {\n batchSize: number\n config: SanitizedConfig\n fields: Field[]\n Model: Model<any>\n session: ClientSession\n}): Promise<void> => {\n let hasNext = true\n let skip = 0\n\n while (hasNext) {\n const docs = await Model.find({}, {}, { lean: true, limit: batchSize + 1, session, skip })\n hasNext = docs.length > batchSize\n\n if (hasNext) {\n docs.pop()\n }\n\n for (const doc of docs) {\n sanitizeRelationshipIDs({ config, data: doc, fields })\n }\n\n await Model.bulkWrite(\n docs.map((doc) => ({\n updateOne: {\n filter: { _id: doc._id },\n update: doc,\n },\n })),\n { session },\n )\n\n skip += batchSize\n }\n}\n\nconst hasRelationshipOrUploadField = ({ fields }: { fields: Field[] }): boolean => {\n for (const field of fields) {\n if (field.type === 'relationship' || field.type === 'upload') {\n return true\n }\n\n if ('fields' in field) {\n if (hasRelationshipOrUploadField({ fields: field.fields })) {\n return true\n }\n }\n\n if ('blocks' in field) {\n for (const block of field.blocks) {\n if (hasRelationshipOrUploadField({ fields: block.fields })) {\n return true\n }\n }\n }\n\n if ('tabs' in field) {\n for (const tab of field.tabs) {\n if (hasRelationshipOrUploadField({ fields: tab.fields })) {\n return true\n }\n }\n }\n }\n\n return false\n}\n\nexport async function migrateRelationshipsV2_V3({\n batchSize,\n req,\n}: {\n batchSize: number\n req: PayloadRequest\n}): Promise<void> {\n const { payload } = req\n const db = payload.db as MongooseAdapter\n const config = payload.config\n\n const { session } = await withSession(db, req)\n\n for (const collection of payload.config.collections.filter(hasRelationshipOrUploadField)) {\n payload.logger.info(`Migrating collection \"${collection.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: collection.fields,\n Model: db.collections[collection.slug],\n session,\n })\n\n payload.logger.info(`Migrated collection \"${collection.slug}\"`)\n\n if (collection.versions) {\n payload.logger.info(`Migrating collection versions \"${collection.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: buildVersionCollectionFields(config, collection),\n Model: db.versions[collection.slug],\n session,\n })\n\n payload.logger.info(`Migrated collection versions \"${collection.slug}\"`)\n }\n }\n\n const { globals: GlobalsModel } = db\n\n for (const global of payload.config.globals.filter(hasRelationshipOrUploadField)) {\n payload.logger.info(`Migrating global \"${global.slug}\"`)\n\n const doc = await GlobalsModel.findOne<Record<string, unknown>>(\n {\n globalType: {\n $eq: global.slug,\n },\n },\n {},\n { lean: true, session },\n )\n\n sanitizeRelationshipIDs({ config, data: doc, fields: global.fields })\n\n await GlobalsModel.updateOne(\n {\n globalType: {\n $eq: global.slug,\n },\n },\n doc,\n { session },\n )\n\n payload.logger.info(`Migrated global \"${global.slug}\"`)\n\n if (global.versions) {\n payload.logger.info(`Migrating global versions \"${global.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: buildVersionGlobalFields(config, global),\n Model: db.versions[global.slug],\n session,\n })\n\n payload.logger.info(`Migrated global versions \"${global.slug}\"`)\n }\n }\n}\n"],"names":["buildVersionCollectionFields","buildVersionGlobalFields","sanitizeRelationshipIDs","withSession","migrateModelWithBatching","batchSize","config","fields","Model","session","hasNext","skip","docs","find","lean","limit","length","pop","doc","data","bulkWrite","map","updateOne","filter","_id","update","hasRelationshipOrUploadField","field","type","block","blocks","tab","tabs","migrateRelationshipsV2_V3","req","payload","db","collection","collections","logger","info","slug","versions","globals","GlobalsModel","global","findOne","globalType","$eq"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAIhF,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,WAAW,QAAQ,oBAAmB;AAE/C,MAAMC,2BAA2B,OAAO,EACtCC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,OAAO,EAOR;IACC,IAAIC,UAAU;IACd,IAAIC,OAAO;IAEX,MAAOD,QAAS;QACd,MAAME,OAAO,MAAMJ,MAAMK,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG;YAAEC,MAAM;YAAMC,OAAOV,YAAY;YAAGI;YAASE;QAAK;QACxFD,UAAUE,KAAKI,MAAM,GAAGX;QAExB,IAAIK,SAAS;YACXE,KAAKK,GAAG;QACV;QAEA,KAAK,MAAMC,OAAON,KAAM;YACtBV,wBAAwB;gBAAEI;gBAAQa,MAAMD;gBAAKX;YAAO;QACtD;QAEA,MAAMC,MAAMY,SAAS,CACnBR,KAAKS,GAAG,CAAC,CAACH,MAAS,CAAA;gBACjBI,WAAW;oBACTC,QAAQ;wBAAEC,KAAKN,IAAIM,GAAG;oBAAC;oBACvBC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B,EAAEK,OAAOJ,IAAI,CAAC,CAAC,CAAC;YAEhE,MAAMrC,yBAAyB;gBAC7BC;gBACAC;gBACAC,QAAQN,yBAAyBK,QAAQuC;gBACzCrC,OAAO4B,GAAGM,QAAQ,CAACG,OAAOJ,IAAI,CAAC;gBAC/BhC;YACF;YAEA0B,QAAQI,MAAM,CAACC,IAAI,CAAC,CAAC,0BAA0B,EAAEK,OAAOJ,IAAI,CAAC,CAAC,CAAC;QACjE;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/predefinedMigrations/migrateRelationshipsV2_V3.ts"],"sourcesContent":["import type { ClientSession, Model } from 'mongoose'\nimport type { Field, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { sanitizeRelationshipIDs } from '../utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from '../withSession.js'\n\nconst migrateModelWithBatching = async ({\n batchSize,\n config,\n fields,\n Model,\n session,\n}: {\n batchSize: number\n config: SanitizedConfig\n fields: Field[]\n Model: Model<any>\n session: ClientSession\n}): Promise<void> => {\n let hasNext = true\n let skip = 0\n\n while (hasNext) {\n const docs = await Model.find(\n {},\n {},\n {\n lean: true,\n limit: batchSize + 1,\n session,\n skip,\n },\n )\n\n if (docs.length === 0) {\n break\n }\n\n hasNext = docs.length > batchSize\n\n if (hasNext) {\n docs.pop()\n }\n\n for (const doc of docs) {\n sanitizeRelationshipIDs({ config, data: doc, fields })\n }\n\n await Model.collection.bulkWrite(\n docs.map((doc) => ({\n updateOne: {\n filter: { _id: doc._id },\n update: {\n $set: doc,\n },\n },\n })),\n { session },\n )\n\n skip += batchSize\n }\n}\n\nconst hasRelationshipOrUploadField = ({ fields }: { fields: Field[] }): boolean => {\n for (const field of fields) {\n if (field.type === 'relationship' || field.type === 'upload') {\n return true\n }\n\n if ('fields' in field) {\n if (hasRelationshipOrUploadField({ fields: field.fields })) {\n return true\n }\n }\n\n if ('blocks' in field) {\n for (const block of field.blocks) {\n if (hasRelationshipOrUploadField({ fields: block.fields })) {\n return true\n }\n }\n }\n\n if ('tabs' in field) {\n for (const tab of field.tabs) {\n if (hasRelationshipOrUploadField({ fields: tab.fields })) {\n return true\n }\n }\n }\n }\n\n return false\n}\n\nexport async function migrateRelationshipsV2_V3({\n batchSize,\n req,\n}: {\n batchSize: number\n req: PayloadRequest\n}): Promise<void> {\n const { payload } = req\n const db = payload.db as MongooseAdapter\n const config = payload.config\n\n const { session } = await withSession(db, req)\n\n for (const collection of payload.config.collections.filter(hasRelationshipOrUploadField)) {\n payload.logger.info(`Migrating collection \"${collection.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: collection.fields,\n Model: db.collections[collection.slug],\n session,\n })\n\n payload.logger.info(`Migrated collection \"${collection.slug}\"`)\n\n if (collection.versions) {\n payload.logger.info(`Migrating collection versions \"${collection.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: buildVersionCollectionFields(config, collection),\n Model: db.versions[collection.slug],\n session,\n })\n\n payload.logger.info(`Migrated collection versions \"${collection.slug}\"`)\n }\n }\n\n const { globals: GlobalsModel } = db\n\n for (const global of payload.config.globals.filter(hasRelationshipOrUploadField)) {\n payload.logger.info(`Migrating global \"${global.slug}\"`)\n\n const doc = await GlobalsModel.findOne<Record<string, unknown>>(\n {\n globalType: {\n $eq: global.slug,\n },\n },\n {},\n { lean: true, session },\n )\n\n sanitizeRelationshipIDs({ config, data: doc, fields: global.fields })\n\n await GlobalsModel.collection.updateOne(\n {\n globalType: global.slug,\n },\n { $set: doc },\n { session },\n )\n\n payload.logger.info(`Migrated global \"${global.slug}\"`)\n\n if (global.versions) {\n payload.logger.info(`Migrating global versions \"${global.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: buildVersionGlobalFields(config, global),\n Model: db.versions[global.slug],\n session,\n })\n\n payload.logger.info(`Migrated global versions \"${global.slug}\"`)\n }\n }\n}\n"],"names":["buildVersionCollectionFields","buildVersionGlobalFields","sanitizeRelationshipIDs","withSession","migrateModelWithBatching","batchSize","config","fields","Model","session","hasNext","skip","docs","find","lean","limit","length","pop","doc","data","collection","bulkWrite","map","updateOne","filter","_id","update","$set","hasRelationshipOrUploadField","field","type","block","blocks","tab","tabs","migrateRelationshipsV2_V3","req","payload","db","collections","logger","info","slug","versions","globals","GlobalsModel","global","findOne","globalType","$eq"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAIhF,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,WAAW,QAAQ,oBAAmB;AAE/C,MAAMC,2BAA2B,OAAO,EACtCC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,OAAO,EAOR;IACC,IAAIC,UAAU;IACd,IAAIC,OAAO;IAEX,MAAOD,QAAS;QACd,MAAME,OAAO,MAAMJ,MAAMK,IAAI,CAC3B,CAAC,GACD,CAAC,GACD;YACEC,MAAM;YACNC,OAAOV,YAAY;YACnBI;YACAE;QACF;QAGF,IAAIC,KAAKI,MAAM,KAAK,GAAG;YACrB;QACF;QAEAN,UAAUE,KAAKI,MAAM,GAAGX;QAExB,IAAIK,SAAS;YACXE,KAAKK,GAAG;QACV;QAEA,KAAK,MAAMC,OAAON,KAAM;YACtBV,wBAAwB;gBAAEI;gBAAQa,MAAMD;gBAAKX;YAAO;QACtD;QAEA,MAAMC,MAAMY,UAAU,CAACC,SAAS,CAC9BT,KAAKU,GAAG,CAAC,CAACJ,MAAS,CAAA;gBACjBK,WAAW;oBACTC,QAAQ;wBAAEC,KAAKP,IAAIO,GAAG;oBAAC;oBACvBC,QAAQ;wBACNC,MAAMT;oBACR;gBACF;YACF,CAAA,IACA;YAAET;QAAQ;QAGZE,QAAQN;IACV;AACF;AAEA,MAAMuB,+BAA+B,CAAC,EAAErB,MAAM,EAAuB;IACnE,KAAK,MAAMsB,SAAStB,OAAQ;QAC1B,IAAI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,CAACG,OAAOJ,IAAI,CAAC;gBAC/BjC;YACF;YAEA4B,QAAQG,MAAM,CAACC,IAAI,CAAC,CAAC,0BAA0B,EAAEK,OAAOJ,IAAI,CAAC,CAAC,CAAC;QACjE;IACF;AACF"}
@@ -4,6 +4,6 @@ const upSQL = ` await migrateRelationshipsV2_V3({
4
4
  req,
5
5
  })
6
6
  `;
7
- export { imports, upSQL }; //# sourceMappingURL=versions-v2-v3.js.map
7
+ export { imports, upSQL };
8
8
 
9
9
  //# sourceMappingURL=relationships-v2-v3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"sourcesContent":["const imports = `import { migrateRelationshipsV2_V3 } from '@payloadcms/db-mongodb/migration-utils'`\nconst upSQL = ` await migrateRelationshipsV2_V3({\n batchSize: 100,\n req,\n })\n`\nexport { imports, upSQL }\n\n//# sourceMappingURL=versions-v2-v3.js.map\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,kFAAkF,CAAC;AACpG,MAAMC,QAAQ,CAAC;;;;AAIf,CAAC;AACD,SAASD,OAAO,EAAEC,KAAK,GAAE,CAEzB,0CAA0C"}
1
+ {"version":3,"sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"sourcesContent":["const imports = `import { migrateRelationshipsV2_V3 } from '@payloadcms/db-mongodb/migration-utils'`\nconst upSQL = ` await migrateRelationshipsV2_V3({\n batchSize: 100,\n req,\n })\n`\nexport { imports, upSQL }\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,kFAAkF,CAAC;AACpG,MAAMC,QAAQ,CAAC;;;;AAIf,CAAC;AACD,SAASD,OAAO,EAAEC,KAAK,GAAE"}
@@ -3,6 +3,6 @@ const upSQL = ` await migrateVersionsV1_V2({
3
3
  req,
4
4
  })
5
5
  `;
6
- export { imports, upSQL }; //# sourceMappingURL=versions-v2-v3.js.map
6
+ export { imports, upSQL };
7
7
 
8
8
  //# sourceMappingURL=versions-v1-v2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/predefinedMigrations/versions-v1-v2.ts"],"sourcesContent":["const imports = `import { migrateVersionsV1_V2 } from '@payloadcms/db-mongodb/migration-utils'`\nconst upSQL = ` await migrateVersionsV1_V2({\n req,\n })\n`\nexport { imports, upSQL }\n\n//# sourceMappingURL=versions-v2-v3.js.map\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,6EAA6E,CAAC;AAC/F,MAAMC,QAAQ,CAAC;;;AAGf,CAAC;AACD,SAASD,OAAO,EAAEC,KAAK,GAAE,CAEzB,0CAA0C"}
1
+ {"version":3,"sources":["../../src/predefinedMigrations/versions-v1-v2.ts"],"sourcesContent":["const imports = `import { migrateVersionsV1_V2 } from '@payloadcms/db-mongodb/migration-utils'`\nconst upSQL = ` await migrateVersionsV1_V2({\n req,\n })\n`\nexport { imports, upSQL }\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,6EAA6E,CAAC;AAC/F,MAAMC,QAAQ,CAAC;;;AAGf,CAAC;AACD,SAASD,OAAO,EAAEC,KAAK,GAAE"}
@@ -50,6 +50,7 @@ const subQueryOptions = {
50
50
  hasCustomID,
51
51
  operator,
52
52
  path,
53
+ payload,
53
54
  val
54
55
  });
55
56
  if (!sanitizedQueryValue) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queries/buildSearchParams.ts"],"sourcesContent":["import type { Field, Operator, PathToQuery, Payload } from 'payload'\n\nimport { Types } from 'mongoose'\nimport { getLocalizedPaths } from 'payload'\nimport { validOperators } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { operatorMap } from './operatorMap.js'\nimport { sanitizeQueryValue } from './sanitizeQueryValue.js'\n\ntype SearchParam = {\n path?: string\n rawQuery?: unknown\n value?: unknown\n}\n\nconst subQueryOptions = {\n lean: true,\n limit: 50,\n}\n\n/**\n * Convert the Payload key / value / operator into a MongoDB query\n */\nexport async function buildSearchParam({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath,\n locale,\n operator,\n payload,\n val,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n incomingPath: string\n locale?: string\n operator: string\n payload: Payload\n val: unknown\n}): Promise<SearchParam> {\n // Replace GraphQL nested field double underscore formatting\n let sanitizedPath = incomingPath.replace(/__/g, '.')\n if (sanitizedPath === 'id') {\n sanitizedPath = '_id'\n }\n\n let paths: PathToQuery[] = []\n\n let hasCustomID = false\n\n if (sanitizedPath === '_id') {\n const customIDFieldType = payload.collections[collectionSlug]?.customIDType\n\n let idFieldType: 'number' | 'text' = 'text'\n\n if (customIDFieldType) {\n idFieldType = customIDFieldType\n hasCustomID = true\n }\n\n paths.push({\n collectionSlug,\n complete: true,\n field: {\n name: 'id',\n type: idFieldType,\n } as Field,\n path: '_id',\n })\n } else {\n paths = await getLocalizedPaths({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath: sanitizedPath,\n locale,\n payload,\n })\n }\n\n const [{ field, path }] = paths\n\n if (path) {\n const sanitizedQueryValue = sanitizeQueryValue({\n field,\n hasCustomID,\n operator,\n path,\n val,\n })\n\n if (!sanitizedQueryValue) {\n return undefined\n }\n\n const { operator: formattedOperator, rawQuery, val: formattedValue } = sanitizedQueryValue\n\n if (rawQuery) {\n return { value: rawQuery }\n }\n\n // If there are multiple collections to search through,\n // Recursively build up a list of query constraints\n if (paths.length > 1) {\n // Remove top collection and reverse array\n // to work backwards from top\n const pathsToQuery = paths.slice(1).reverse()\n\n const initialRelationshipQuery = {\n value: {},\n } as SearchParam\n\n const relationshipQuery = await pathsToQuery.reduce(\n async (priorQuery, { collectionSlug: slug, path: subPath }, i) => {\n const priorQueryResult = await priorQuery\n\n const SubModel = (payload.db as MongooseAdapter).collections[slug]\n\n // On the \"deepest\" collection,\n // Search on the value passed through the query\n if (i === 0) {\n const subQuery = await SubModel.buildQuery({\n locale,\n payload,\n where: {\n [subPath]: {\n [formattedOperator]: val,\n },\n },\n })\n\n const result = await SubModel.find(subQuery, subQueryOptions)\n\n const $in: unknown[] = []\n\n result.forEach((doc) => {\n const stringID = doc._id.toString()\n $in.push(stringID)\n\n if (Types.ObjectId.isValid(stringID)) {\n $in.push(doc._id)\n }\n })\n\n if (pathsToQuery.length === 1) {\n return {\n path,\n value: { $in },\n }\n }\n\n const nextSubPath = pathsToQuery[i + 1].path\n\n return {\n value: { [nextSubPath]: { $in } },\n }\n }\n\n const subQuery = priorQueryResult.value\n const result = await SubModel.find(subQuery, subQueryOptions)\n\n const $in = result.map((doc) => doc._id)\n\n // If it is the last recursion\n // then pass through the search param\n if (i + 1 === pathsToQuery.length) {\n return {\n path,\n value: { $in },\n }\n }\n\n return {\n value: {\n _id: { $in },\n },\n }\n },\n Promise.resolve(initialRelationshipQuery),\n )\n\n return relationshipQuery\n }\n\n if (formattedOperator && validOperators.includes(formattedOperator as Operator)) {\n const operatorKey = operatorMap[formattedOperator]\n\n if (field.type === 'relationship' || field.type === 'upload') {\n let hasNumberIDRelation\n let multiIDCondition = '$or'\n if (operatorKey === '$ne') {\n multiIDCondition = '$and'\n }\n\n const result = {\n value: {\n [multiIDCondition]: [{ [path]: { [operatorKey]: formattedValue } }],\n },\n }\n\n if (typeof formattedValue === 'string') {\n if (Types.ObjectId.isValid(formattedValue)) {\n result.value[multiIDCondition].push({\n [path]: { [operatorKey]: new Types.ObjectId(formattedValue) },\n })\n } else {\n ;(Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo]).forEach(\n (relationTo) => {\n const isRelatedToCustomNumberID =\n payload.collections[relationTo]?.customIDType === 'number'\n\n if (isRelatedToCustomNumberID) {\n hasNumberIDRelation = true\n }\n },\n )\n\n if (hasNumberIDRelation) {\n result.value[multiIDCondition].push({\n [path]: { [operatorKey]: parseFloat(formattedValue) },\n })\n }\n }\n }\n\n if (result.value[multiIDCondition].length > 1) {\n return result\n }\n }\n\n if (formattedOperator === 'like' && typeof formattedValue === 'string') {\n const words = formattedValue.split(' ')\n\n const result = {\n value: {\n $and: words.map((word) => ({\n [path]: {\n $options: 'i',\n $regex: word.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&'),\n },\n })),\n },\n }\n\n return result\n }\n\n // Some operators like 'near' need to define a full query\n // so if there is no operator key, just return the value\n if (!operatorKey) {\n return {\n path,\n value: formattedValue,\n }\n }\n\n return {\n path,\n value: { [operatorKey]: formattedValue },\n }\n }\n }\n return undefined\n}\n"],"names":["Types","getLocalizedPaths","validOperators","operatorMap","sanitizeQueryValue","subQueryOptions","lean","limit","buildSearchParam","collectionSlug","fields","globalSlug","incomingPath","locale","operator","payload","val","sanitizedPath","replace","paths","hasCustomID","customIDFieldType","collections","customIDType","idFieldType","push","complete","field","name","type","path","sanitizedQueryValue","undefined","formattedOperator","rawQuery","formattedValue","value","length","pathsToQuery","slice","reverse","initialRelationshipQuery","relationshipQuery","reduce","priorQuery","slug","subPath","i","priorQueryResult","SubModel","db","subQuery","buildQuery","where","result","find","$in","forEach","doc","stringID","_id","toString","ObjectId","isValid","nextSubPath","map","Promise","resolve","includes","operatorKey","hasNumberIDRelation","multiIDCondition","Array","isArray","relationTo","isRelatedToCustomNumberID","parseFloat","words","split","$and","word","$options","$regex"],"mappings":"AAEA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,iBAAiB,QAAQ,UAAS;AAC3C,SAASC,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAQ5D,MAAMC,kBAAkB;IACtBC,MAAM;IACNC,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,eAAeC,iBAAiB,EACrCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,YAAY,EACZC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,GAAG,EAUJ;IACC,4DAA4D;IAC5D,IAAIC,gBAAgBL,aAAaM,OAAO,CAAC,OAAO;IAChD,IAAID,kBAAkB,MAAM;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ACtE,MAAM0C,QAAQ1C,eAAe2C,KAAK,CAAC;gBAEnC,MAAMxB,SAAS;oBACblB,OAAO;wBACL2C,MAAMF,MAAMZ,GAAG,CAAC,CAACe,OAAU,CAAA;gCACzB,CAAClD,KAAK,EAAE;oCACNmD,UAAU;oCACVC,QAAQF,KAAK9D,OAAO,CAAC,uBAAuB;gCAC9C;4BACF,CAAA;oBACF;gBACF;gBAEA,OAAOoC;YACT;YAEA,yDAAyD;YACzD,wDAAwD;YACxD,IAAI,CAACe,aAAa;gBAChB,OAAO;oBACLvC;oBACAM,OAAOD;gBACT;YACF;YAEA,OAAO;gBACLL;gBACAM,OAAO;oBAAE,CAACiC,YAAY,EAAElC;gBAAe;YACzC;QACF;IACF;IACA,OAAOH;AACT"}
1
+ {"version":3,"sources":["../../src/queries/buildSearchParams.ts"],"sourcesContent":["import type { Field, Operator, PathToQuery, Payload } from 'payload'\n\nimport { Types } from 'mongoose'\nimport { getLocalizedPaths } from 'payload'\nimport { validOperators } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { operatorMap } from './operatorMap.js'\nimport { sanitizeQueryValue } from './sanitizeQueryValue.js'\n\ntype SearchParam = {\n path?: string\n rawQuery?: unknown\n value?: unknown\n}\n\nconst subQueryOptions = {\n lean: true,\n limit: 50,\n}\n\n/**\n * Convert the Payload key / value / operator into a MongoDB query\n */\nexport async function buildSearchParam({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath,\n locale,\n operator,\n payload,\n val,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n incomingPath: string\n locale?: string\n operator: string\n payload: Payload\n val: unknown\n}): Promise<SearchParam> {\n // Replace GraphQL nested field double underscore formatting\n let sanitizedPath = incomingPath.replace(/__/g, '.')\n if (sanitizedPath === 'id') {\n sanitizedPath = '_id'\n }\n\n let paths: PathToQuery[] = []\n\n let hasCustomID = false\n\n if (sanitizedPath === '_id') {\n const customIDFieldType = payload.collections[collectionSlug]?.customIDType\n\n let idFieldType: 'number' | 'text' = 'text'\n\n if (customIDFieldType) {\n idFieldType = customIDFieldType\n hasCustomID = true\n }\n\n paths.push({\n collectionSlug,\n complete: true,\n field: {\n name: 'id',\n type: idFieldType,\n } as Field,\n path: '_id',\n })\n } else {\n paths = await getLocalizedPaths({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath: sanitizedPath,\n locale,\n payload,\n })\n }\n\n const [{ field, path }] = paths\n if (path) {\n const sanitizedQueryValue = sanitizeQueryValue({\n field,\n hasCustomID,\n operator,\n path,\n payload,\n val,\n })\n\n if (!sanitizedQueryValue) {\n return undefined\n }\n\n const { operator: formattedOperator, rawQuery, val: formattedValue } = sanitizedQueryValue\n\n if (rawQuery) {\n return { value: rawQuery }\n }\n\n // If there are multiple collections to search through,\n // Recursively build up a list of query constraints\n if (paths.length > 1) {\n // Remove top collection and reverse array\n // to work backwards from top\n const pathsToQuery = paths.slice(1).reverse()\n\n const initialRelationshipQuery = {\n value: {},\n } as SearchParam\n\n const relationshipQuery = await pathsToQuery.reduce(\n async (priorQuery, { collectionSlug: slug, path: subPath }, i) => {\n const priorQueryResult = await priorQuery\n\n const SubModel = (payload.db as MongooseAdapter).collections[slug]\n\n // On the \"deepest\" collection,\n // Search on the value passed through the query\n if (i === 0) {\n const subQuery = await SubModel.buildQuery({\n locale,\n payload,\n where: {\n [subPath]: {\n [formattedOperator]: val,\n },\n },\n })\n\n const result = await SubModel.find(subQuery, subQueryOptions)\n\n const $in: unknown[] = []\n\n result.forEach((doc) => {\n const stringID = doc._id.toString()\n $in.push(stringID)\n\n if (Types.ObjectId.isValid(stringID)) {\n $in.push(doc._id)\n }\n })\n\n if (pathsToQuery.length === 1) {\n return {\n path,\n value: { $in },\n }\n }\n\n const nextSubPath = pathsToQuery[i + 1].path\n\n return {\n value: { [nextSubPath]: { $in } },\n }\n }\n\n const subQuery = priorQueryResult.value\n const result = await SubModel.find(subQuery, subQueryOptions)\n\n const $in = result.map((doc) => doc._id)\n\n // If it is the last recursion\n // then pass through the search param\n if (i + 1 === pathsToQuery.length) {\n return {\n path,\n value: { $in },\n }\n }\n\n return {\n value: {\n _id: { $in },\n },\n }\n },\n Promise.resolve(initialRelationshipQuery),\n )\n\n return relationshipQuery\n }\n\n if (formattedOperator && validOperators.includes(formattedOperator as Operator)) {\n const operatorKey = operatorMap[formattedOperator]\n\n if (field.type === 'relationship' || field.type === 'upload') {\n let hasNumberIDRelation\n let multiIDCondition = '$or'\n if (operatorKey === '$ne') {\n multiIDCondition = '$and'\n }\n\n const result = {\n value: {\n [multiIDCondition]: [{ [path]: { [operatorKey]: formattedValue } }],\n },\n }\n\n if (typeof formattedValue === 'string') {\n if (Types.ObjectId.isValid(formattedValue)) {\n result.value[multiIDCondition].push({\n [path]: { [operatorKey]: new Types.ObjectId(formattedValue) },\n })\n } else {\n ;(Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo]).forEach(\n (relationTo) => {\n const isRelatedToCustomNumberID =\n payload.collections[relationTo]?.customIDType === 'number'\n\n if (isRelatedToCustomNumberID) {\n hasNumberIDRelation = true\n }\n },\n )\n\n if (hasNumberIDRelation) {\n result.value[multiIDCondition].push({\n [path]: { [operatorKey]: parseFloat(formattedValue) },\n })\n }\n }\n }\n\n if (result.value[multiIDCondition].length > 1) {\n return result\n }\n }\n\n if (formattedOperator === 'like' && typeof formattedValue === 'string') {\n const words = formattedValue.split(' ')\n\n const result = {\n value: {\n $and: words.map((word) => ({\n [path]: {\n $options: 'i',\n $regex: word.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&'),\n },\n })),\n },\n }\n\n return result\n }\n\n // Some operators like 'near' need to define a full query\n // so if there is no operator key, just return the value\n if (!operatorKey) {\n return {\n path,\n value: formattedValue,\n }\n }\n\n return {\n path,\n value: { [operatorKey]: formattedValue },\n }\n }\n }\n return undefined\n}\n"],"names":["Types","getLocalizedPaths","validOperators","operatorMap","sanitizeQueryValue","subQueryOptions","lean","limit","buildSearchParam","collectionSlug","fields","globalSlug","incomingPath","locale","operator","payload","val","sanitizedPath","replace","paths","hasCustomID","customIDFieldType","collections","customIDType","idFieldType","push","complete","field","name","type","path","sanitizedQueryValue","undefined","formattedOperator","rawQuery","formattedValue","value","length","pathsToQuery","slice","reverse","initialRelationshipQuery","relationshipQuery","reduce","priorQuery","slug","subPath","i","priorQueryResult","SubModel","db","subQuery","buildQuery","where","result","find","$in","forEach","doc","stringID","_id","toString","ObjectId","isValid","nextSubPath","map","Promise","resolve","includes","operatorKey","hasNumberIDRelation","multiIDCondition","Array","isArray","relationTo","isRelatedToCustomNumberID","parseFloat","words","split","$and","word","$options","$regex"],"mappings":"AAEA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,iBAAiB,QAAQ,UAAS;AAC3C,SAASC,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAQ5D,MAAMC,kBAAkB;IACtBC,MAAM;IACNC,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,eAAeC,iBAAiB,EACrCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,YAAY,EACZC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,GAAG,EAUJ;IACC,4DAA4D;IAC5D,IAAIC,gBAAgBL,aAAaM,OAAO,CAAC,OAAO;IAChD,IAAID,kBAAkB,MAAM;QAC1BA,gBAAgB;IAClB;IAEA,IAAIE,QAAuB,EAAE;IAE7B,IAAIC,cAAc;IAElB,IAAIH,kBAAkB,OAAO;QAC3B,MAAMI,oBAAoBN,QAAQO,WAAW,CAACb,eAAe,EAAEc;QAE/D,IAAIC,cAAiC;QAErC,IAAIH,mBAAmB;YACrBG,cAAcH;YACdD,cAAc;QAChB;QAEAD,MAAMM,IAAI,CAAC;YACThB;YACAiB,UAAU;YACVC,OAAO;gBACLC,MAAM;gBACNC,MAAML;YACR;YACAM,MAAM;QACR;IACF,OAAO;QACLX,QAAQ,MAAMlB,kBAAkB;YA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EA,OAAO;gBACLL;gBACAM,OAAO;oBAAE,CAACiC,YAAY,EAAElC;gBAAe;YACzC;QACF;IACF;IACA,OAAOH;AACT"}
@@ -1,12 +1,13 @@
1
- import type { Field, TabAsField } from 'payload';
1
+ import type { Field, Payload, TabAsField } from 'payload';
2
2
  type SanitizeQueryValueArgs = {
3
3
  field: Field | TabAsField;
4
4
  hasCustomID: boolean;
5
5
  operator: string;
6
6
  path: string;
7
+ payload: Payload;
7
8
  val: any;
8
9
  };
9
- export declare const sanitizeQueryValue: ({ field, hasCustomID, operator, path, val, }: SanitizeQueryValueArgs) => {
10
+ export declare const sanitizeQueryValue: ({ field, hasCustomID, operator, path, payload, val, }: SanitizeQueryValueArgs) => {
10
11
  operator?: string;
11
12
  rawQuery?: unknown;
12
13
  val?: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeQueryValue.d.ts","sourceRoot":"","sources":["../../src/queries/sanitizeQueryValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAKhD,KAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AA0BD,eAAO,MAAM,kBAAkB,iDAM5B,sBAAsB,KAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CAsOd,CAAA"}
1
+ {"version":3,"file":"sanitizeQueryValue.d.ts","sourceRoot":"","sources":["../../src/queries/sanitizeQueryValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,OAAO,EAAqB,UAAU,EAAE,MAAM,SAAS,CAAA;AAKnF,KAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AA+DD,eAAO,MAAM,kBAAkB,0DAO5B,sBAAsB,KAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CAqTd,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Types } from 'mongoose';
2
- import { createArrayFromCommaDelineated } from 'payload';
3
- const buildExistsQuery = (formattedValue, path)=>{
2
+ import { createArrayFromCommaDelineated, flattenTopLevelFields } from 'payload';
3
+ const buildExistsQuery = (formattedValue, path, treatEmptyString = true)=>{
4
4
  if (formattedValue) {
5
5
  return {
6
6
  rawQuery: {
@@ -15,11 +15,13 @@ const buildExistsQuery = (formattedValue, path)=>{
15
15
  $ne: null
16
16
  }
17
17
  },
18
- {
19
- [path]: {
20
- $ne: ''
18
+ ...treatEmptyString ? [
19
+ {
20
+ [path]: {
21
+ $ne: ''
22
+ }
21
23
  }
22
- }
24
+ ] : []
23
25
  ]
24
26
  }
25
27
  };
@@ -37,19 +39,67 @@ const buildExistsQuery = (formattedValue, path)=>{
37
39
  $eq: null
38
40
  }
39
41
  },
40
- {
41
- [path]: {
42
- $eq: ''
42
+ ...treatEmptyString ? [
43
+ {
44
+ [path]: {
45
+ $eq: ''
46
+ }
43
47
  }
44
- }
48
+ ] : []
45
49
  ]
46
50
  }
47
51
  };
48
52
  }
49
53
  };
50
- export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=>{
54
+ // returns nestedField Field object from blocks.nestedField path because getLocalizedPaths splits them only for relationships
55
+ const getFieldFromSegments = ({ field, segments })=>{
56
+ if ('blocks' in field) {
57
+ for (const block of field.blocks){
58
+ const field = getFieldFromSegments({
59
+ field: block,
60
+ segments
61
+ });
62
+ if (field) {
63
+ return field;
64
+ }
65
+ }
66
+ }
67
+ if ('fields' in field) {
68
+ for(let i = 0; i < segments.length; i++){
69
+ const foundField = flattenTopLevelFields(field.fields).find((each)=>each.name === segments[i]);
70
+ if (!foundField) {
71
+ break;
72
+ }
73
+ if (foundField && segments.length - 1 === i) {
74
+ return foundField;
75
+ }
76
+ segments.shift();
77
+ return getFieldFromSegments({
78
+ field: foundField,
79
+ segments
80
+ });
81
+ }
82
+ }
83
+ };
84
+ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, payload, val })=>{
51
85
  let formattedValue = val;
52
86
  let formattedOperator = operator;
87
+ if ([
88
+ 'array',
89
+ 'blocks',
90
+ 'group',
91
+ 'tab'
92
+ ].includes(field.type) && path.includes('.')) {
93
+ const segments = path.split('.');
94
+ segments.shift();
95
+ const foundField = getFieldFromSegments({
96
+ field,
97
+ segments
98
+ });
99
+ if (foundField) {
100
+ field = foundField;
101
+ }
102
+ }
53
103
  // Disregard invalid _ids
54
104
  if (path === '_id') {
55
105
  if (typeof val === 'string' && val.split(',').length === 1) {
@@ -85,24 +135,20 @@ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=
85
135
  formattedValue = createArrayFromCommaDelineated(val);
86
136
  }
87
137
  formattedValue = formattedValue.reduce((formattedValues, inVal)=>{
88
- const newValues = [
89
- inVal
90
- ];
91
138
  if (!hasCustomID) {
92
139
  if (Types.ObjectId.isValid(inVal)) {
93
- newValues.push(new Types.ObjectId(inVal));
140
+ formattedValues.push(new Types.ObjectId(inVal));
94
141
  }
95
142
  }
96
143
  if (field.type === 'number') {
97
144
  const parsedNumber = parseFloat(inVal);
98
145
  if (!Number.isNaN(parsedNumber)) {
99
- newValues.push(parsedNumber);
146
+ formattedValues.push(parsedNumber);
100
147
  }
148
+ } else {
149
+ formattedValues.push(inVal);
101
150
  }
102
- return [
103
- ...formattedValues,
104
- ...newValues
105
- ];
151
+ return formattedValues;
106
152
  }, []);
107
153
  }
108
154
  }
@@ -171,30 +217,89 @@ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=
171
217
  }
172
218
  };
173
219
  }
220
+ const relationTo = field.relationTo;
174
221
  if ([
175
222
  'in',
176
223
  'not_in'
177
224
  ].includes(operator) && Array.isArray(formattedValue)) {
178
225
  formattedValue = formattedValue.reduce((formattedValues, inVal)=>{
179
- const newValues = [
180
- inVal
181
- ];
182
- if (Types.ObjectId.isValid(inVal)) {
183
- newValues.push(new Types.ObjectId(inVal));
226
+ if (!inVal) {
227
+ return formattedValues;
228
+ }
229
+ if (typeof relationTo === 'string' && payload.collections[relationTo].customIDType) {
230
+ if (payload.collections[relationTo].customIDType === 'number') {
231
+ const parsedNumber = parseFloat(inVal);
232
+ if (!Number.isNaN(parsedNumber)) {
233
+ formattedValues.push(parsedNumber);
234
+ return formattedValues;
235
+ }
236
+ }
237
+ formattedValues.push(inVal);
238
+ return formattedValues;
184
239
  }
185
- const parsedNumber = parseFloat(inVal);
186
- if (!Number.isNaN(parsedNumber)) {
187
- newValues.push(parsedNumber);
240
+ if (Array.isArray(relationTo) && relationTo.some((relationTo)=>!!payload.collections[relationTo].customIDType)) {
241
+ if (Types.ObjectId.isValid(inVal.toString())) {
242
+ formattedValues.push(new Types.ObjectId(inVal));
243
+ } else {
244
+ formattedValues.push(inVal);
245
+ }
246
+ return formattedValues;
188
247
  }
189
- return [
190
- ...formattedValues,
191
- ...newValues
192
- ];
248
+ if (Types.ObjectId.isValid(inVal.toString())) {
249
+ formattedValues.push(new Types.ObjectId(inVal));
250
+ }
251
+ return formattedValues;
193
252
  }, []);
194
253
  }
195
- if (typeof formattedValue === 'string') {
196
- if (Types.ObjectId.isValid(formattedValue)) {
197
- formattedValue = new Types.ObjectId(formattedValue);
254
+ if ([
255
+ 'contains',
256
+ 'equals',
257
+ 'like',
258
+ 'not_equals'
259
+ ].includes(operator) && (!Array.isArray(relationTo) || !path.endsWith('.relationTo'))) {
260
+ if (typeof relationTo === 'string') {
261
+ const customIDType = payload.collections[relationTo].customIDType;
262
+ if (customIDType) {
263
+ if (customIDType === 'number') {
264
+ formattedValue = parseFloat(val);
265
+ if (Number.isNaN(formattedValue)) {
266
+ return {
267
+ operator: formattedOperator,
268
+ val: undefined
269
+ };
270
+ }
271
+ }
272
+ } else {
273
+ if (!Types.ObjectId.isValid(formattedValue)) {
274
+ return {
275
+ operator: formattedOperator,
276
+ val: undefined
277
+ };
278
+ }
279
+ formattedValue = new Types.ObjectId(formattedValue);
280
+ }
281
+ } else {
282
+ const hasCustomIDType = relationTo.some((relationTo)=>!!payload.collections[relationTo].customIDType);
283
+ if (hasCustomIDType) {
284
+ if (typeof val === 'string') {
285
+ const formattedNumber = Number(val);
286
+ formattedValue = [
287
+ Types.ObjectId.isValid(val) ? new Types.ObjectId(val) : val
288
+ ];
289
+ formattedOperator = operator === 'not_equals' ? 'not_in' : 'in';
290
+ if (!Number.isNaN(formattedNumber)) {
291
+ formattedValue.push(formattedNumber);
292
+ }
293
+ }
294
+ } else {
295
+ if (!Types.ObjectId.isValid(formattedValue)) {
296
+ return {
297
+ operator: formattedOperator,
298
+ val: undefined
299
+ };
300
+ }
301
+ formattedValue = new Types.ObjectId(formattedValue);
302
+ }
198
303
  }
199
304
  }
200
305
  }
@@ -244,7 +349,11 @@ export const sanitizeQueryValue = ({ field, hasCustomID, operator, path, val })=
244
349
  }
245
350
  if (operator === 'exists') {
246
351
  formattedValue = formattedValue === 'true' || formattedValue === true;
247
- return buildExistsQuery(formattedValue, path);
352
+ // _id can't be empty string, will error Cast to ObjectId failed for value ""
353
+ return buildExistsQuery(formattedValue, path, ![
354
+ 'relationship',
355
+ 'upload'
356
+ ].includes(field.type));
248
357
  }
249
358
  }
250
359
  if ((path === '_id' || path === 'parent') && operator === 'like' && formattedValue.length === 24 && !hasCustomID) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queries/sanitizeQueryValue.ts"],"sourcesContent":["import type { Field, TabAsField } from 'payload'\n\nimport { Types } from 'mongoose'\nimport { createArrayFromCommaDelineated } from 'payload'\n\ntype SanitizeQueryValueArgs = {\n field: Field | TabAsField\n hasCustomID: boolean\n operator: string\n path: string\n val: any\n}\n\nconst buildExistsQuery = (formattedValue, path) => {\n if (formattedValue) {\n return {\n rawQuery: {\n $and: [\n { [path]: { $exists: true } },\n { [path]: { $ne: null } },\n { [path]: { $ne: '' } }, // Exclude null and empty string\n ],\n },\n }\n } else {\n return {\n rawQuery: {\n $or: [\n { [path]: { $exists: false } },\n { [path]: { $eq: null } },\n { [path]: { $eq: '' } }, // Treat empty string as null / undefined\n ],\n },\n }\n }\n}\n\nexport const sanitizeQueryValue = ({\n field,\n hasCustomID,\n operator,\n path,\n val,\n}: SanitizeQueryValueArgs): {\n operator?: string\n rawQuery?: unknown\n val?: unknown\n} => {\n let formattedValue = val\n let formattedOperator = operator\n\n // Disregard invalid _ids\n if (path === '_id') {\n if (typeof val === 'string' && val.split(',').length === 1) {\n if (!hasCustomID) {\n const isValid = Types.ObjectId.isValid(val)\n\n if (!isValid) {\n return { operator: formattedOperator, val: undefined }\n } else {\n if (['in', 'not_in'].includes(operator)) {\n formattedValue = createArrayFromCommaDelineated(formattedValue).map(\n (id) => new Types.ObjectId(id),\n )\n } else {\n formattedValue = new Types.ObjectId(val)\n }\n }\n }\n\n if (field.type === 'number') {\n const parsedNumber = parseFloat(val)\n\n if (Number.isNaN(parsedNumber)) {\n return { operator: formattedOperator, val: undefined }\n }\n }\n } else if (Array.isArray(val) || (typeof val === 'string' && val.split(',').length > 1)) {\n if (typeof val === 'string') {\n formattedValue = createArrayFromCommaDelineated(val)\n }\n\n formattedValue = formattedValue.reduce((formattedValues, inVal) => {\n const newValues = [inVal]\n if (!hasCustomID) {\n if (Types.ObjectId.isValid(inVal)) {\n newValues.push(new Types.ObjectId(inVal))\n }\n }\n\n if (field.type === 'number') {\n const parsedNumber = parseFloat(inVal)\n if (!Number.isNaN(parsedNumber)) {\n newValues.push(parsedNumber)\n }\n }\n\n return [...formattedValues, ...newValues]\n }, [])\n }\n }\n\n // Cast incoming values as proper searchable types\n if (field.type === 'checkbox' && typeof val === 'string') {\n if (val.toLowerCase() === 'true') {\n formattedValue = true\n }\n if (val.toLowerCase() === 'false') {\n formattedValue = false\n }\n }\n\n if (['all', 'in', 'not_in'].includes(operator) && typeof formattedValue === 'string') {\n formattedValue = createArrayFromCommaDelineated(formattedValue)\n\n if (field.type === 'number') {\n formattedValue = formattedValue.map((arrayVal) => parseFloat(arrayVal))\n }\n }\n\n if (field.type === 'number') {\n if (typeof formattedValue === 'string' && operator !== 'exists') {\n formattedValue = Number(val)\n }\n\n if (operator === 'exists') {\n formattedValue = val === 'true' ? true : val === 'false' ? false : Boolean(val)\n\n return buildExistsQuery(formattedValue, path)\n }\n }\n\n if (field.type === 'date' && typeof val === 'string' && operator !== 'exists') {\n formattedValue = new Date(val)\n if (Number.isNaN(Date.parse(formattedValue))) {\n return undefined\n }\n }\n\n if (['relationship', 'upload'].includes(field.type)) {\n if (val === 'null') {\n formattedValue = null\n }\n\n // Object equality requires the value to be the first key in the object that is being queried.\n if (\n operator === 'equals' &&\n formattedValue &&\n typeof formattedValue === 'object' &&\n formattedValue.value &&\n formattedValue.relationTo\n ) {\n const { value } = formattedValue\n const isValid = Types.ObjectId.isValid(value)\n\n if (isValid) {\n formattedValue.value = new Types.ObjectId(value)\n }\n\n return {\n rawQuery: {\n $and: [\n { [`${path}.value`]: { $eq: formattedValue.value } },\n { [`${path}.relationTo`]: { $eq: formattedValue.relationTo } },\n ],\n },\n }\n }\n\n if (['in', 'not_in'].includes(operator) && Array.isArray(formattedValue)) {\n formattedValue = formattedValue.reduce((formattedValues, inVal) => {\n const newValues = [inVal]\n if (Types.ObjectId.isValid(inVal)) {\n newValues.push(new Types.ObjectId(inVal))\n }\n\n const parsedNumber = parseFloat(inVal)\n if (!Number.isNaN(parsedNumber)) {\n newValues.push(parsedNumber)\n }\n\n return [...formattedValues, ...newValues]\n }, [])\n }\n\n if (typeof formattedValue === 'string') {\n if (Types.ObjectId.isValid(formattedValue)) {\n formattedValue = new Types.ObjectId(formattedValue)\n }\n }\n }\n\n // Set up specific formatting necessary by operators\n\n if (operator === 'near') {\n let lng\n let lat\n let maxDistance\n let minDistance\n\n if (Array.isArray(formattedValue)) {\n ;[lng, lat, maxDistance, minDistance] = formattedValue\n }\n\n if (typeof formattedValue === 'string') {\n ;[lng, lat, maxDistance, minDistance] = createArrayFromCommaDelineated(formattedValue)\n }\n\n if (lng == null || lat == null || (maxDistance == null && minDistance == null)) {\n formattedValue = undefined\n } else {\n formattedValue = {\n $geometry: { type: 'Point', coordinates: [parseFloat(lng), parseFloat(lat)] },\n }\n\n if (maxDistance) {\n formattedValue.$maxDistance = parseFloat(maxDistance)\n }\n if (minDistance) {\n formattedValue.$minDistance = parseFloat(minDistance)\n }\n }\n }\n\n if (operator === 'within' || operator === 'intersects') {\n formattedValue = {\n $geometry: formattedValue,\n }\n }\n\n if (path !== '_id' || (path === '_id' && hasCustomID && field.type === 'text')) {\n if (operator === 'contains' && !Types.ObjectId.isValid(formattedValue)) {\n formattedValue = {\n $options: 'i',\n $regex: formattedValue.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&'),\n }\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n\n return buildExistsQuery(formattedValue, path)\n }\n }\n\n if (\n (path === '_id' || path === 'parent') &&\n operator === 'like' &&\n formattedValue.length === 24 &&\n !hasCustomID\n ) {\n formattedOperator = 'equals'\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n\n // Clearable fields\n if (['relationship', 'select', 'upload'].includes(field.type)) {\n if (formattedValue) {\n return {\n rawQuery: {\n $and: [{ [path]: { $exists: true } }, { [path]: { $ne: null } }],\n },\n }\n } else {\n return {\n rawQuery: {\n $or: [{ [path]: { $exists: false } }, { [path]: { $eq: null } }],\n },\n }\n }\n }\n }\n\n return { operator: formattedOperator, val: formattedValue }\n}\n"],"names":["Types","createArrayFromCommaDelineated","buildExistsQuery","formattedValue","path","rawQuery","$and","$exists","$ne","$or","$eq","sanitizeQueryValue","field","hasCustomID","operator","val","formattedOperator","split","length","isValid","ObjectId","undefined","includes","map","id","type","parsedNumber","parseFloat","Number","isNaN","Array","isArray","reduce","formattedValues","inVal","newValues","push","toLowerCase","arrayVal","Boolean","Date","parse","value","relationTo","lng","lat","maxDistance","minDistance","$geometry","coordinates","$maxDistance","$minDistance","$options","$regex","replace"],"mappings":"AAEA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,8BAA8B,QAAQ,UAAS;AAUxD,MAAMC,mBAAmB,CAACC,gBAAgBC;IACxC,IAAID,gBAAgB;QAClB,OAAO;YACLE,UAAU;gBACRC,MAAM;oBACJ;wBAAE,CAACF,KAAK,EAAE;4BAAEG,SAAS;wBAAK;oBAAE;oBAC5B;wBAAE,CAACH,KAAK,EAAE;4BAAEI,KAAK;wBAAK;oBAAE;oBACxB;wBAAE,CAACJ,KAAK,EAAE;4BAAEI,KAAK;wBAAG;oBAAE;iBACvB;YACH;QACF;IACF,OAAO;QACL,OAAO;YACLH,UAAU;gBACRI,KAAK;oBACH;wBAAE,CAACL,KAAK,EAAE;4BAAEG,SAAS;wBAAM;oBAAE;oBAC7B;wBAAE,CAACH,KAAK,EAAE;4BAAEM,KAAK;wBAAK;oBAAE;oBACxB;wBAAE,CAACN,KAAK,EAAE;4BAAEM,KAAK;wBAAG;oBAAE;iBACvB;YACH;QACF;IACF;AACF;AAEA,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,KAAK,EACLC,WAAW,EACXC,QAAQ,EACRV,IAAI,EACJW,GAAG,EACoB;IAKvB,IAAIZ,iBAAiBY;IACrB,IAAIC,oBAAoBF;IAExB,yBAAyB;IACzB,IAAIV,SAAS,OAAO;QAClB,IAAI,OAAOW,QAAQ,YAAYA,IAAIE,KAAK,C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CAAK;4BAAE;4BAAG;gCAAE,CAACH,KAAK,EAAE;oCAAEI,KAAK;gCAAK;4BAAE;yBAAE;oBAClE;gBACF;YACF,OAAO;gBACL,OAAO;oBACLH,UAAU;wBACRI,KAAK;4BAAC;gCAAE,CAACL,KAAK,EAAE;oCAAEG,SAAS;gCAAM;4BAAE;4BAAG;gCAAE,CAACH,KAAK,EAAE;oCAAEM,KAAK;gCAAK;4BAAE;yBAAE;oBAClE;gBACF;YACF;QACF;IACF;IAEA,OAAO;QAAEI,UAAUE;QAAmBD,KAAKZ;IAAe;AAC5D,EAAC"}
1
+ {"version":3,"sources":["../../src/queries/sanitizeQueryValue.ts"],"sourcesContent":["import type { Block, Field, Payload, RelationshipField, TabAsField } from 'payload'\n\nimport { Types } from 'mongoose'\nimport { createArrayFromCommaDelineated, flattenTopLevelFields } from 'payload'\n\ntype SanitizeQueryValueArgs = {\n field: Field | TabAsField\n hasCustomID: boolean\n operator: string\n path: string\n payload: Payload\n val: any\n}\n\nconst buildExistsQuery = (formattedValue, path, treatEmptyString = true) => {\n if (formattedValue) {\n return {\n rawQuery: {\n $and: [\n { [path]: { $exists: true } },\n { [path]: { $ne: null } },\n ...(treatEmptyString ? [{ [path]: { $ne: '' } }] : []), // Treat empty string as null / undefined\n ],\n },\n }\n } else {\n return {\n rawQuery: {\n $or: [\n { [path]: { $exists: false } },\n { [path]: { $eq: null } },\n ...(treatEmptyString ? [{ [path]: { $eq: '' } }] : []), // Treat empty string as null / undefined\n ],\n },\n }\n }\n}\n\n// returns nestedField Field object from blocks.nestedField path because getLocalizedPaths splits them only for relationships\nconst getFieldFromSegments = ({\n field,\n segments,\n}: {\n field: Block | Field | TabAsField\n segments: string[]\n}) => {\n if ('blocks' in field) {\n for (const block of field.blocks) {\n const field = getFieldFromSegments({ field: block, segments })\n if (field) {\n return field\n }\n }\n }\n\n if ('fields' in field) {\n for (let i = 0; i < segments.length; i++) {\n const foundField = flattenTopLevelFields(field.fields).find(\n (each) => each.name === segments[i],\n )\n\n if (!foundField) {\n break\n }\n\n if (foundField && segments.length - 1 === i) {\n return foundField\n }\n\n segments.shift()\n return getFieldFromSegments({ field: foundField, segments })\n }\n }\n}\n\nexport const sanitizeQueryValue = ({\n field,\n hasCustomID,\n operator,\n path,\n payload,\n val,\n}: SanitizeQueryValueArgs): {\n operator?: string\n rawQuery?: unknown\n val?: unknown\n} => {\n let formattedValue = val\n let formattedOperator = operator\n\n if (['array', 'blocks', 'group', 'tab'].includes(field.type) && path.includes('.')) {\n const segments = path.split('.')\n segments.shift()\n const foundField = getFieldFromSegments({ field, segments })\n\n if (foundField) {\n field = foundField\n }\n }\n\n // Disregard invalid _ids\n if (path === '_id') {\n if (typeof val === 'string' && val.split(',').length === 1) {\n if (!hasCustomID) {\n const isValid = Types.ObjectId.isValid(val)\n\n if (!isValid) {\n return { operator: formattedOperator, val: undefined }\n } else {\n if (['in', 'not_in'].includes(operator)) {\n formattedValue = createArrayFromCommaDelineated(formattedValue).map(\n (id) => new Types.ObjectId(id),\n )\n } else {\n formattedValue = new Types.ObjectId(val)\n }\n }\n }\n\n if (field.type === 'number') {\n const parsedNumber = parseFloat(val)\n\n if (Number.isNaN(parsedNumber)) {\n return { operator: formattedOperator, val: undefined }\n }\n }\n } else if (Array.isArray(val) || (typeof val === 'string' && val.split(',').length > 1)) {\n if (typeof val === 'string') {\n formattedValue = createArrayFromCommaDelineated(val)\n }\n\n formattedValue = formattedValue.reduce((formattedValues, inVal) => {\n if (!hasCustomID) {\n if (Types.ObjectId.isValid(inVal)) {\n formattedValues.push(new Types.ObjectId(inVal))\n }\n }\n\n if (field.type === 'number') {\n const parsedNumber = parseFloat(inVal)\n if (!Number.isNaN(parsedNumber)) {\n formattedValues.push(parsedNumber)\n }\n } else {\n formattedValues.push(inVal)\n }\n\n return formattedValues\n }, [])\n }\n }\n\n // Cast incoming values as proper searchable types\n if (field.type === 'checkbox' && typeof val === 'string') {\n if (val.toLowerCase() === 'true') {\n formattedValue = true\n }\n if (val.toLowerCase() === 'false') {\n formattedValue = false\n }\n }\n\n if (['all', 'in', 'not_in'].includes(operator) && typeof formattedValue === 'string') {\n formattedValue = createArrayFromCommaDelineated(formattedValue)\n\n if (field.type === 'number') {\n formattedValue = formattedValue.map((arrayVal) => parseFloat(arrayVal))\n }\n }\n\n if (field.type === 'number') {\n if (typeof formattedValue === 'string' && operator !== 'exists') {\n formattedValue = Number(val)\n }\n\n if (operator === 'exists') {\n formattedValue = val === 'true' ? true : val === 'false' ? false : Boolean(val)\n\n return buildExistsQuery(formattedValue, path)\n }\n }\n\n if (field.type === 'date' && typeof val === 'string' && operator !== 'exists') {\n formattedValue = new Date(val)\n if (Number.isNaN(Date.parse(formattedValue))) {\n return undefined\n }\n }\n\n if (['relationship', 'upload'].includes(field.type)) {\n if (val === 'null') {\n formattedValue = null\n }\n\n // Object equality requires the value to be the first key in the object that is being queried.\n if (\n operator === 'equals' &&\n formattedValue &&\n typeof formattedValue === 'object' &&\n formattedValue.value &&\n formattedValue.relationTo\n ) {\n const { value } = formattedValue\n const isValid = Types.ObjectId.isValid(value)\n\n if (isValid) {\n formattedValue.value = new Types.ObjectId(value)\n }\n\n return {\n rawQuery: {\n $and: [\n { [`${path}.value`]: { $eq: formattedValue.value } },\n { [`${path}.relationTo`]: { $eq: formattedValue.relationTo } },\n ],\n },\n }\n }\n\n const relationTo = (field as RelationshipField).relationTo\n\n if (['in', 'not_in'].includes(operator) && Array.isArray(formattedValue)) {\n formattedValue = formattedValue.reduce((formattedValues, inVal) => {\n if (!inVal) {\n return formattedValues\n }\n\n if (typeof relationTo === 'string' && payload.collections[relationTo].customIDType) {\n if (payload.collections[relationTo].customIDType === 'number') {\n const parsedNumber = parseFloat(inVal)\n if (!Number.isNaN(parsedNumber)) {\n formattedValues.push(parsedNumber)\n return formattedValues\n }\n }\n\n formattedValues.push(inVal)\n return formattedValues\n }\n\n if (\n Array.isArray(relationTo) &&\n relationTo.some((relationTo) => !!payload.collections[relationTo].customIDType)\n ) {\n if (Types.ObjectId.isValid(inVal.toString())) {\n formattedValues.push(new Types.ObjectId(inVal))\n } else {\n formattedValues.push(inVal)\n }\n return formattedValues\n }\n\n if (Types.ObjectId.isValid(inVal.toString())) {\n formattedValues.push(new Types.ObjectId(inVal))\n }\n\n return formattedValues\n }, [])\n }\n\n if (\n ['contains', 'equals', 'like', 'not_equals'].includes(operator) &&\n (!Array.isArray(relationTo) || !path.endsWith('.relationTo'))\n ) {\n if (typeof relationTo === 'string') {\n const customIDType = payload.collections[relationTo].customIDType\n\n if (customIDType) {\n if (customIDType === 'number') {\n formattedValue = parseFloat(val)\n\n if (Number.isNaN(formattedValue)) {\n return { operator: formattedOperator, val: undefined }\n }\n }\n } else {\n if (!Types.ObjectId.isValid(formattedValue)) {\n return { operator: formattedOperator, val: undefined }\n }\n formattedValue = new Types.ObjectId(formattedValue)\n }\n } else {\n const hasCustomIDType = relationTo.some(\n (relationTo) => !!payload.collections[relationTo].customIDType,\n )\n\n if (hasCustomIDType) {\n if (typeof val === 'string') {\n const formattedNumber = Number(val)\n formattedValue = [Types.ObjectId.isValid(val) ? new Types.ObjectId(val) : val]\n formattedOperator = operator === 'not_equals' ? 'not_in' : 'in'\n if (!Number.isNaN(formattedNumber)) {\n formattedValue.push(formattedNumber)\n }\n }\n } else {\n if (!Types.ObjectId.isValid(formattedValue)) {\n return { operator: formattedOperator, val: undefined }\n }\n formattedValue = new Types.ObjectId(formattedValue)\n }\n }\n }\n }\n\n // Set up specific formatting necessary by operators\n\n if (operator === 'near') {\n let lng\n let lat\n let maxDistance\n let minDistance\n\n if (Array.isArray(formattedValue)) {\n ;[lng, lat, maxDistance, minDistance] = formattedValue\n }\n\n if (typeof formattedValue === 'string') {\n ;[lng, lat, maxDistance, minDistance] = createArrayFromCommaDelineated(formattedValue)\n }\n\n if (lng == null || lat == null || (maxDistance == null && minDistance == null)) {\n formattedValue = undefined\n } else {\n formattedValue = {\n $geometry: { type: 'Point', coordinates: [parseFloat(lng), parseFloat(lat)] },\n }\n\n if (maxDistance) {\n formattedValue.$maxDistance = parseFloat(maxDistance)\n }\n if (minDistance) {\n formattedValue.$minDistance = parseFloat(minDistance)\n }\n }\n }\n\n if (operator === 'within' || operator === 'intersects') {\n formattedValue = {\n $geometry: formattedValue,\n }\n }\n\n if (path !== '_id' || (path === '_id' && hasCustomID && field.type === 'text')) {\n if (operator === 'contains' && !Types.ObjectId.isValid(formattedValue)) {\n formattedValue = {\n $options: 'i',\n $regex: formattedValue.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&'),\n }\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n\n // _id can't be empty string, will error Cast to ObjectId failed for value \"\"\n return buildExistsQuery(\n formattedValue,\n path,\n !['relationship', 'upload'].includes(field.type),\n )\n }\n }\n\n if (\n (path === '_id' || path === 'parent') &&\n operator === 'like' &&\n formattedValue.length === 24 &&\n !hasCustomID\n ) {\n formattedOperator = 'equals'\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n\n // Clearable fields\n if (['relationship', 'select', 'upload'].includes(field.type)) {\n if (formattedValue) {\n return {\n rawQuery: {\n $and: [{ [path]: { $exists: true } }, { [path]: { $ne: null } }],\n },\n }\n } else {\n return {\n rawQuery: {\n $or: [{ [path]: { $exists: false } }, { [path]: { $eq: null } }],\n },\n }\n }\n }\n }\n\n return { operator: formattedOperator, val: formattedValue }\n}\n"],"names":["Types","createArrayFromCommaDelineated","flattenTopLevelFields","buildExistsQuery","formattedValue","path","treatEmptyString","rawQuery","$and","$exists","$ne","$or","$eq","getFieldFromSegments","field","segments","block","blocks","i","length","foundField","fields","find","each","name","shift","sanitizeQueryValue","hasCustomID","operator","payload","val","formattedOperator","includes","type","split","isValid","ObjectId","undefined","map","id","parsedNumber","parseFloat","Number","isNaN","Array","isArray","reduce","formattedValues","inVal","push","toLowerCase","arrayVal","Boolean","Date","parse","value","relationTo","collections","customIDType","some","toString","endsWith","hasCustomIDType","formattedNumber","lng","lat","maxDistance","minDistance","$geometry","coordinates","$maxDistance","$minDistance","$options","$regex","replace"],"mappings":"AAEA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,8BAA8B,EAAEC,qBAAqB,QAAQ,UAAS;AAW/E,MAAMC,mBAAmB,CAACC,gBAAgBC,MAAMC,mBAAmB,IAAI;IACrE,IAAIF,gBAAgB;QAClB,OAAO;YACLG,UAAU;gBACRC,MAAM;oBACJ;wBAAE,CAACH,KAAK,EAAE;4BAAEI,SAAS;wBAAK;oBAAE;oBAC5B;wBAAE,CAACJ,KAAK,EAAE;4BAAEK,KAAK;wBAAK;oBAAE;uBACpBJ,mBAAmB;wBAAC;4BAAE,CAACD,KAAK,EAAE;gCAAEK,KAAK;4BAAG;wBAAE;qBAAE,GAAG,EAAE;iBACtD;YACH;QACF;IACF,OAAO;QACL,OAAO;YACLH,UAAU;gBACRI,KAAK;oBACH;wBAAE,CAACN,KAAK,EAAE;4BAAEI,SAAS;wBAAM;oBAAE;oBAC7B;wBAAE,CAACJ,KAAK,EAAE;4BAAEO,KAAK;wBAAK;oBAAE;uBACpBN,mBAAmB;wBAAC;4BAAE,CAACD,KAAK,EAAE;gCAAEO,KAAK;4BAAG;wBAAE;qBAAE,GAAG,EAAE;iBACtD;YACH;QACF;IACF;AACF;AAEA,6HAA6H;AAC7H,MAAMC,uBAAuB,CAAC,EAC5BC,KAAK,EACLC,QAAQ,EAIT;IACC,IAAI,YAAYD,OAAO;QACrB,KAAK,MAAME,SAASF,MAAMG,MAAM,CAAE;YAChC,MAAMH,QAAQD,qBAAqB;gBAAEC,OAAOE;gBAAOD;YAAS;YAC5D,IAAID,OAAO;gBACT,OAAOA;YACT;QACF;IACF;IAEA,IAAI,YAAYA,OAAO;QACrB,IAAK,IAAII,IAAI,GAAGA,IAAIH,SAASI,MAAM,EAAED,IAAK;YACxC,MAAME,aAAalB,sBAAsBY,MAAMO,MAAM,EAAEC,IAAI,CACzD,CAACC,OAASA,KAAKC,IAA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,CAAClB,MAAMmB,IAAI,GAAG;YAC7D,IAAI7B,gBAAgB;gBAClB,OAAO;oBACLG,UAAU;wBACRC,MAAM;4BAAC;gCAAE,CAACH,KAAK,EAAE;oCAAEI,SAAS;gCAAK;4BAAE;4BAAG;gCAAE,CAACJ,KAAK,EAAE;oCAAEK,KAAK;gCAAK;4BAAE;yBAAE;oBAClE;gBACF;YACF,OAAO;gBACL,OAAO;oBACLH,UAAU;wBACRI,KAAK;4BAAC;gCAAE,CAACN,KAAK,EAAE;oCAAEI,SAAS;gCAAM;4BAAE;4BAAG;gCAAE,CAACJ,KAAK,EAAE;oCAAEO,KAAK;gCAAK;4BAAE;yBAAE;oBAClE;gBACF;YACF;QACF;IACF;IAEA,OAAO;QAAEgB,UAAUG;QAAmBD,KAAK1B;IAAe;AAC5D,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3D,eAAO,MAAM,YAAY,EAAE,YA+B1B,CAAA"}
1
+ {"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3D,eAAO,MAAM,YAAY,EAAE,YAgC1B,CAAA"}
@@ -2,10 +2,11 @@ import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect
2
2
  import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
3
3
  import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
4
4
  import { withSession } from './withSession.js';
5
- export const updateGlobal = async function updateGlobal({ slug, data, req = {}, select }) {
5
+ export const updateGlobal = async function updateGlobal({ slug, data, options: optionsArgs = {}, req = {}, select }) {
6
6
  const Model = this.globals;
7
7
  const fields = this.payload.config.globals.find((global)=>global.slug === slug).fields;
8
8
  const options = {
9
+ ...optionsArgs,
9
10
  ...await withSession(this, req),
10
11
  lean: true,
11
12
  new: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { PayloadRequest, UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug, data, req = {} as PayloadRequest, select },\n) {\n const Model = this.globals\n const fields = this.payload.config.globals.find((global) => global.slug === slug).fields\n\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({ adapter: this, fields, select }),\n }\n\n let result\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data,\n fields,\n })\n\n result = await Model.findOneAndUpdate({ globalType: slug }, sanitizedData, options)\n\n result = JSON.parse(JSON.stringify(result))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["buildProjectionFromSelect","sanitizeInternalFields","sanitizeRelationshipIDs","withSession","updateGlobal","slug","data","req","select","Model","globals","fields","payload","config","find","global","options","lean","new","projection","adapter","result","sanitizedData","findOneAndUpdate","globalType","JSON","parse","stringify","id","_id"],"mappings":"AAIA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAAmB,EAAEC,MAAM,EAAE;IAElD,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,MAAM,CAACH,OAAO,CAACI,IAAI,CAAC,CAACC,SAAWA,OAAOV,IAAI,KAAKA,MAAMM,MAAM;IAExF,MAAMK,UAAU;QACd,GAAI,MAAMb,YAAY,IAAI,EAAEI,IAAI;QAChCU,MAAM;QACNC,KAAK;QACLC,YAAYnB,0BAA0B;YAAEoB,SAAS,IAAI;YAAET;YAAQH;QAAO;IACxE;IAEA,IAAIa;IAEJ,MAAMC,gBAAgBpB,wBAAwB;QAC5CW,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3BP;QACAK;IACF;IAEAU,SAAS,MAAMZ,MAAMc,gBAAgB,CAAC;QAAEC,YAAYnB;IAAK,GAAGiB,eAAeN;IAE3EK,SAASI,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IAEnC,uBAAuB;IACvBA,OAAOO,EAAE,GAAGP,OAAOQ,GAAG;IACtBR,SAASpB,uBAAuBoB;IAEhC,OAAOA;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { PayloadRequest, UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug, data, options: optionsArgs = {}, req = {} as PayloadRequest, select },\n) {\n const Model = this.globals\n const fields = this.payload.config.globals.find((global) => global.slug === slug).fields\n\n const options: QueryOptions = {\n ...optionsArgs,\n ...(await withSession(this, req)),\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({ adapter: this, fields, select }),\n }\n\n let result\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data,\n fields,\n })\n\n result = await Model.findOneAndUpdate({ globalType: slug }, sanitizedData, options)\n\n result = JSON.parse(JSON.stringify(result))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["buildProjectionFromSelect","sanitizeInternalFields","sanitizeRelationshipIDs","withSession","updateGlobal","slug","data","options","optionsArgs","req","select","Model","globals","fields","payload","config","find","global","lean","new","projection","adapter","result","sanitizedData","findOneAndUpdate","globalType","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,SAASC,cAAc,CAAC,CAAC,EAAEC,MAAM,CAAC,CAAmB,EAAEC,MAAM,EAAE;IAE7E,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,MAAM,CAACH,OAAO,CAACI,IAAI,CAAC,CAACC,SAAWA,OAAOZ,IAAI,KAAKA,MAAMQ,MAAM;IAExF,MAAMN,UAAwB;QAC5B,GAAGC,WAAW;QACd,GAAI,MAAML,YAAY,IAAI,EAAEM,IAAI;QAChCS,MAAM;QACNC,KAAK;QACLC,YAAYpB,0BAA0B;YAAEqB,SAAS,IAAI;YAAER;YAAQH;QAAO;IACxE;IAEA,IAAIY;IAEJ,MAAMC,gBAAgBrB,wBAAwB;QAC5Ca,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3BT;QACAO;IACF;IAEAS,SAAS,MAAMX,MAAMa,gBAAgB,CAAC;QAAEC,YAAYpB;IAAK,GAAGkB,eAAehB;IAE3Ee,SAASI,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IAEnC,uBAAuB;IACvBA,OAAOO,EAAE,GAAGP,OAAOQ,GAAG;IACtBR,SAASrB,uBAAuBqB;IAEhC,OAAOA;AACT,EAAC"}
@@ -1,4 +1,4 @@
1
1
  import { type TypeWithID, type UpdateGlobalVersionArgs } from 'payload';
2
2
  import type { MongooseAdapter } from './index.js';
3
- export declare function updateGlobalVersion<T extends TypeWithID>(this: MongooseAdapter, { id, global: globalSlug, locale, req, select, versionData, where, }: UpdateGlobalVersionArgs<T>): Promise<any>;
3
+ export declare function updateGlobalVersion<T extends TypeWithID>(this: MongooseAdapter, { id, global: globalSlug, locale, options: optionsArgs, req, select, versionData, where, }: UpdateGlobalVersionArgs<T>): Promise<any>;
4
4
  //# sourceMappingURL=updateGlobalVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC7B,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAMjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EACE,EAAE,EACF,MAAM,EAAE,UAAU,EAClB,MAAM,EACN,GAA0B,EAC1B,MAAM,EACN,WAAW,EACX,KAAK,GACN,EAAE,uBAAuB,CAAC,CAAC,CAAC,gBAwC9B"}
1
+ {"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC7B,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAMjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EACE,EAAE,EACF,MAAM,EAAE,UAAU,EAClB,MAAM,EACN,OAAO,EAAE,WAAgB,EACzB,GAA0B,EAC1B,MAAM,EACN,WAAW,EACX,KAAK,GACN,EAAE,uBAAuB,CAAC,CAAC,CAAC,gBAyC9B"}
@@ -2,7 +2,7 @@ import { buildVersionGlobalFields } from 'payload';
2
2
  import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
3
3
  import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
4
4
  import { withSession } from './withSession.js';
5
- export async function updateGlobalVersion({ id, global: globalSlug, locale, req = {}, select, versionData, where }) {
5
+ export async function updateGlobalVersion({ id, global: globalSlug, locale, options: optionsArgs = {}, req = {}, select, versionData, where }) {
6
6
  const VersionModel = this.versions[globalSlug];
7
7
  const whereToUse = where || {
8
8
  id: {
@@ -11,6 +11,7 @@ export async function updateGlobalVersion({ id, global: globalSlug, locale, req
11
11
  };
12
12
  const fields = buildVersionGlobalFields(this.payload.config, this.payload.config.globals.find((global)=>global.slug === globalSlug));
13
13
  const options = {
14
+ ...optionsArgs,
14
15
  ...await withSession(this, req),
15
16
  lean: true,
16
17
  new: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import {\n buildVersionGlobalFields,\n type PayloadRequest,\n type TypeWithID,\n type UpdateGlobalVersionArgs,\n} from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: MongooseAdapter,\n {\n id,\n global: globalSlug,\n locale,\n req = {} as PayloadRequest,\n select,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const VersionModel = this.versions[globalSlug]\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionGlobalFields(\n this.payload.config,\n this.payload.config.globals.find((global) => global.slug === globalSlug),\n )\n\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({ adapter: this, fields, select }),\n }\n\n const query = await VersionModel.buildQuery({\n locale,\n payload: this.payload,\n where: whereToUse,\n })\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: versionData,\n fields,\n })\n\n const doc = await VersionModel.findOneAndUpdate(query, sanitizedData, options)\n\n const result = JSON.parse(JSON.stringify(doc))\n\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["buildVersionGlobalFields","buildProjectionFromSelect","sanitizeRelationshipIDs","withSession","updateGlobalVersion","id","global","globalSlug","locale","req","select","versionData","where","VersionModel","versions","whereToUse","equals","fields","payload","config","globals","find","slug","options","lean","new","projection","adapter","query","buildQuery","sanitizedData","data","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"mappings":"AAAA,SACEA,wBAAwB,QAInB,UAAS;AAIhB,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,oBAEpB,EACEC,EAAE,EACFC,QAAQC,UAAU,EAClBC,MAAM,EACNC,MAAM,CAAC,CAAmB,EAC1BC,MAAM,EACNC,WAAW,EACXC,KAAK,EACsB;IAE7B,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACP,WAAW;IAC9C,MAAMQ,aAAaH,SAAS;QAAEP,IAAI;YAAEW,QAAQX;QAAG;IAAE;IACjD,MAAMY,SAASjB,yBACb,IAAI,CAACkB,OAAO,CAACC,MAAM,EACnB,IAAI,CAACD,OAAO,CAACC,MAAM,CAACC,OAAO,CAACC,IAAI,CAAC,CAACf,SAAWA,OAAOgB,IAAI,KAAKf;IAG/D,MAAMgB,UAAU;QACd,GAAI,MAAMpB,YAAY,IAAI,EAAEM,IAAI;QAChCe,MAAM;QACNC,KAAK;QACLC,YAAYzB,0BAA0B;YAAE0B,SAAS,IAAI;YAAEV;YAAQP;QAAO;IACxE;IAEA,MAAMkB,QAAQ,MAAMf,aAAagB,UAAU,CAAC;QAC1CrB;QACAU,SAAS,IAAI,CAACA,OAAO;QACrBN,OAAOG;IACT;IAEA,MAAMe,gBAAgB5B,wBAAwB;QAC5CiB,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3BY,MAAMpB;QACNM;IACF;IAEA,MAAMe,MAAM,MAAMnB,aAAaoB,gBAAgB,CAACL,OAAOE,eAAeP;IAEtE,MAAMW,SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEzC,MAAMM,oBAAoBN,IAAIO,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAO7B,EAAE,GAAG6B,OAAOM,GAAG;IACtB,IAAIF,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT"}
1
+ {"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\n\nimport {\n buildVersionGlobalFields,\n type PayloadRequest,\n type TypeWithID,\n type UpdateGlobalVersionArgs,\n} from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: MongooseAdapter,\n {\n id,\n global: globalSlug,\n locale,\n options: optionsArgs = {},\n req = {} as PayloadRequest,\n select,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const VersionModel = this.versions[globalSlug]\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionGlobalFields(\n this.payload.config,\n this.payload.config.globals.find((global) => global.slug === globalSlug),\n )\n\n const options: QueryOptions = {\n ...optionsArgs,\n ...(await withSession(this, req)),\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({ adapter: this, fields, select }),\n }\n\n const query = await VersionModel.buildQuery({\n locale,\n payload: this.payload,\n where: whereToUse,\n })\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: versionData,\n fields,\n })\n\n const doc = await VersionModel.findOneAndUpdate(query, sanitizedData, options)\n\n const result = JSON.parse(JSON.stringify(doc))\n\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["buildVersionGlobalFields","buildProjectionFromSelect","sanitizeRelationshipIDs","withSession","updateGlobalVersion","id","global","globalSlug","locale","options","optionsArgs","req","select","versionData","where","VersionModel","versions","whereToUse","equals","fields","payload","config","globals","find","slug","lean","new","projection","adapter","query","buildQuery","sanitizedData","data","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"mappings":"AAEA,SACEA,wBAAwB,QAInB,UAAS;AAIhB,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,oBAEpB,EACEC,EAAE,EACFC,QAAQC,UAAU,EAClBC,MAAM,EACNC,SAASC,cAAc,CAAC,CAAC,EACzBC,MAAM,CAAC,CAAmB,EAC1BC,MAAM,EACNC,WAAW,EACXC,KAAK,EACsB;IAE7B,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACT,WAAW;IAC9C,MAAMU,aAAaH,SAAS;QAAET,IAAI;YAAEa,QAAQb;QAAG;IAAE;IACjD,MAAMc,SAASnB,yBACb,IAAI,CAACoB,OAAO,CAACC,MAAM,EACnB,IAAI,CAACD,OAAO,CAACC,MAAM,CAACC,OAAO,CAACC,IAAI,CAAC,CAACjB,SAAWA,OAAOkB,IAAI,KAAKjB;IAG/D,MAAME,UAAwB;QAC5B,GAAGC,WAAW;QACd,GAAI,MAAMP,YAAY,IAAI,EAAEQ,IAAI;QAChCc,MAAM;QACNC,KAAK;QACLC,YAAY1B,0BAA0B;YAAE2B,SAAS,IAAI;YAAET;YAAQP;QAAO;IACxE;IAEA,MAAMiB,QAAQ,MAAMd,aAAae,UAAU,CAAC;QAC1CtB;QACAY,SAAS,IAAI,CAACA,OAAO;QACrBN,OAAOG;IACT;IAEA,MAAMc,gBAAgB7B,wBAAwB;QAC5CmB,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3BW,MAAMnB;QACNM;IACF;IAEA,MAAMc,MAAM,MAAMlB,aAAamB,gBAAgB,CAACL,OAAOE,eAAetB;IAEtE,MAAM0B,SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEzC,MAAMM,oBAAoBN,IAAIO,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAO9B,EAAE,GAAG8B,OAAOM,GAAG;IACtB,IAAIF,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAQ/F,eAAO,MAAM,aAAa,EAAE,aA0C3B,CAAA"}
1
+ {"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqD,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAQ/F,eAAO,MAAM,aAAa,EAAE,aAoD3B,CAAA"}