@payloadcms/db-mongodb 3.24.0-canary.05013b2 → 3.24.0-canary.1328522
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js +5 -2
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts.map +1 -1
- package/dist/countGlobalVersions.js +5 -3
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.d.ts.map +1 -1
- package/dist/countVersions.js +5 -3
- package/dist/countVersions.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +5 -2
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +9 -3
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +5 -2
- package/dist/deleteVersions.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +5 -2
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +6 -3
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +4 -3
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +5 -2
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +6 -3
- package/dist/findVersions.js.map +1 -1
- package/dist/init.js +1 -1
- package/dist/init.js.map +1 -1
- package/dist/models/buildCollectionSchema.d.ts.map +1 -1
- package/dist/models/buildCollectionSchema.js +2 -2
- package/dist/models/buildCollectionSchema.js.map +1 -1
- package/dist/models/buildGlobalModel.js +1 -1
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +6 -9
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +11 -35
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getBuildQueryPlugin.d.ts +14 -0
- package/dist/queries/getBuildQueryPlugin.d.ts.map +1 -0
- package/dist/queries/getBuildQueryPlugin.js +40 -0
- package/dist/queries/getBuildQueryPlugin.js.map +1 -0
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +6 -3
- package/dist/queryDrafts.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +3 -0
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +9 -3
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +8 -2
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +9 -3
- package/dist/updateVersion.js.map +1 -1
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +150 -3
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/package.json +3 -3
package/dist/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport mongoose from 'mongoose'\nimport mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2'\nimport paginate from 'mongoose-paginate-v2'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel } from './types.js'\n\nimport { buildCollectionSchema } from './models/buildCollectionSchema.js'\nimport { buildGlobalModel } from './models/buildGlobalModel.js'\nimport { buildSchema } from './models/buildSchema.js'\nimport { getBuildQueryPlugin } from './queries/
|
|
1
|
+
{"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport mongoose from 'mongoose'\nimport mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2'\nimport paginate from 'mongoose-paginate-v2'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel } from './types.js'\n\nimport { buildCollectionSchema } from './models/buildCollectionSchema.js'\nimport { buildGlobalModel } from './models/buildGlobalModel.js'\nimport { buildSchema } from './models/buildSchema.js'\nimport { getBuildQueryPlugin } from './queries/getBuildQueryPlugin.js'\nimport { getDBName } from './utilities/getDBName.js'\n\nexport const init: Init = function init(this: MongooseAdapter) {\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const schemaOptions = this.collectionsSchemaOptions[collection.slug]\n\n const schema = buildCollectionSchema(collection, this.payload, schemaOptions)\n\n if (collection.versions) {\n const versionModelName = getDBName({ config: collection, versions: true })\n\n const versionCollectionFields = buildVersionCollectionFields(this.payload.config, collection)\n\n const versionSchema = buildSchema({\n buildSchemaOptions: {\n disableUnique: true,\n draftsEnabled: true,\n indexSortableFields: this.payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: false,\n },\n ...schemaOptions,\n },\n configFields: versionCollectionFields,\n payload: this.payload,\n })\n\n versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(\n getBuildQueryPlugin({\n collectionSlug: collection.slug,\n versionsFields: buildVersionCollectionFields(this.payload.config, collection, true),\n }),\n )\n\n if (Object.keys(collection.joins).length > 0) {\n versionSchema.plugin(mongooseAggregatePaginate)\n }\n\n const versionCollectionName =\n this.autoPluralization === true && !collection.dbName ? undefined : versionModelName\n\n this.versions[collection.slug] = mongoose.model(\n versionModelName,\n versionSchema,\n versionCollectionName,\n ) as CollectionModel\n }\n\n const modelName = getDBName({ config: collection })\n const collectionName =\n this.autoPluralization === true && !collection.dbName ? undefined : modelName\n\n this.collections[collection.slug] = mongoose.model(\n modelName,\n schema,\n collectionName,\n ) as CollectionModel\n })\n\n this.globals = buildGlobalModel(this.payload)\n\n this.payload.config.globals.forEach((global) => {\n if (global.versions) {\n const versionModelName = getDBName({ config: global, versions: true })\n\n const versionGlobalFields = buildVersionGlobalFields(this.payload.config, global)\n\n const versionSchema = buildSchema({\n buildSchemaOptions: {\n disableUnique: true,\n draftsEnabled: true,\n indexSortableFields: this.payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: false,\n },\n },\n configFields: versionGlobalFields,\n payload: this.payload,\n })\n\n versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(\n getBuildQueryPlugin({\n versionsFields: buildVersionGlobalFields(this.payload.config, global, true),\n }),\n )\n\n this.versions[global.slug] = mongoose.model(\n versionModelName,\n versionSchema,\n versionModelName,\n ) as CollectionModel\n }\n })\n}\n"],"names":["mongoose","mongooseAggregatePaginate","paginate","buildVersionCollectionFields","buildVersionGlobalFields","buildCollectionSchema","buildGlobalModel","buildSchema","getBuildQueryPlugin","getDBName","init","payload","config","collections","forEach","collection","schemaOptions","collectionsSchemaOptions","slug","schema","versions","versionModelName","versionCollectionFields","versionSchema","buildSchemaOptions","disableUnique","draftsEnabled","indexSortableFields","options","minimize","timestamps","configFields","plugin","useEstimatedCount","collectionSlug","versionsFields","Object","keys","joins","length","versionCollectionName","autoPluralization","dbName","undefined","model","modelName","collectionName","globals","global","versionGlobalFields"],"mappings":"AAGA,OAAOA,cAAc,WAAU;AAC/B,OAAOC,+BAA+B,iCAAgC;AACtE,OAAOC,cAAc,uBAAsB;AAC3C,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAKhF,SAASC,qBAAqB,QAAQ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
1
|
-
{"version":3,"file":"buildCollectionSchema.d.ts","sourceRoot":"","sources":["../../src/models/buildCollectionSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAQjE,eAAO,MAAM,qBAAqB,eACpB,yBAAyB,WAC5B,OAAO,yBAEf,
|
|
1
|
+
{"version":3,"file":"buildCollectionSchema.d.ts","sourceRoot":"","sources":["../../src/models/buildCollectionSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAQjE,eAAO,MAAM,qBAAqB,eACpB,yBAAyB,WAC5B,OAAO,yBAEf,MAyCF,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2';
|
|
2
2
|
import paginate from 'mongoose-paginate-v2';
|
|
3
|
-
import { getBuildQueryPlugin } from '../queries/
|
|
3
|
+
import { getBuildQueryPlugin } from '../queries/getBuildQueryPlugin.js';
|
|
4
4
|
import { buildSchema } from './buildSchema.js';
|
|
5
5
|
export const buildCollectionSchema = (collection, payload, schemaOptions = {})=>{
|
|
6
6
|
const schema = buildSchema({
|
|
@@ -30,7 +30,7 @@ export const buildCollectionSchema = (collection, payload, schemaOptions = {})=>
|
|
|
30
30
|
}).plugin(getBuildQueryPlugin({
|
|
31
31
|
collectionSlug: collection.slug
|
|
32
32
|
}));
|
|
33
|
-
if (Object.keys(collection.joins).length > 0) {
|
|
33
|
+
if (Object.keys(collection.joins).length > 0 || Object.keys(collection.polymorphicJoins).length > 0) {
|
|
34
34
|
schema.plugin(mongooseAggregatePaginate);
|
|
35
35
|
}
|
|
36
36
|
return schema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/models/buildCollectionSchema.ts"],"sourcesContent":["import type { PaginateOptions, Schema } from 'mongoose'\nimport type { Payload, SanitizedCollectionConfig } from 'payload'\n\nimport mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2'\nimport paginate from 'mongoose-paginate-v2'\n\nimport { getBuildQueryPlugin } from '../queries/
|
|
1
|
+
{"version":3,"sources":["../../src/models/buildCollectionSchema.ts"],"sourcesContent":["import type { PaginateOptions, Schema } from 'mongoose'\nimport type { Payload, SanitizedCollectionConfig } from 'payload'\n\nimport mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2'\nimport paginate from 'mongoose-paginate-v2'\n\nimport { getBuildQueryPlugin } from '../queries/getBuildQueryPlugin.js'\nimport { buildSchema } from './buildSchema.js'\n\nexport const buildCollectionSchema = (\n collection: SanitizedCollectionConfig,\n payload: Payload,\n schemaOptions = {},\n): Schema => {\n const schema = buildSchema({\n buildSchemaOptions: {\n draftsEnabled: Boolean(\n typeof collection?.versions === 'object' && collection.versions.drafts,\n ),\n indexSortableFields: payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: collection.timestamps !== false,\n ...schemaOptions,\n },\n },\n configFields: collection.fields,\n payload,\n })\n\n if (Array.isArray(collection.upload.filenameCompoundIndex)) {\n const indexDefinition: Record<string, 1> = collection.upload.filenameCompoundIndex.reduce(\n (acc, index) => {\n acc[index] = 1\n return acc\n },\n {},\n )\n\n schema.index(indexDefinition, { unique: true })\n }\n\n schema\n .plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true })\n .plugin(getBuildQueryPlugin({ collectionSlug: collection.slug }))\n\n if (\n Object.keys(collection.joins).length > 0 ||\n Object.keys(collection.polymorphicJoins).length > 0\n ) {\n schema.plugin(mongooseAggregatePaginate)\n }\n\n return schema\n}\n"],"names":["mongooseAggregatePaginate","paginate","getBuildQueryPlugin","buildSchema","buildCollectionSchema","collection","payload","schemaOptions","schema","buildSchemaOptions","draftsEnabled","Boolean","versions","drafts","indexSortableFields","config","options","minimize","timestamps","configFields","fields","Array","isArray","upload","filenameCompoundIndex","indexDefinition","reduce","acc","index","unique","plugin","useEstimatedCount","collectionSlug","slug","Object","keys","joins","length","polymorphicJoins"],"mappings":"AAGA,OAAOA,+BAA+B,iCAAgC;AACtE,OAAOC,cAAc,uBAAsB;AAE3C,SAASC,mBAAmB,QAAQ,oCAAmC;AACvE,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,wBAAwB,CACnCC,YACAC,SACAC,gBAAgB,CAAC,CAAC;IAElB,MAAMC,SAASL,YAAY;QACzBM,oBAAoB;YAClBC,eAAeC,QACb,OAAON,YAAYO,aAAa,YAAYP,WAAWO,QAAQ,CAACC,MAAM;YAExEC,qBAAqBR,QAAQS,MAAM,CAACD,mBAAmB;YACvDE,SAAS;gBACPC,UAAU;gBACVC,YAAYb,WAAWa,UAAU,KAAK;gBACtC,GAAGX,aAAa;YAClB;QACF;QACAY,cAAcd,WAAWe,MAAM;QAC/Bd;IACF;IAEA,IAAIe,MAAMC,OAAO,CAACjB,WAAWkB,MAAM,CAACC,qBAAqB,GAAG;QAC1D,MAAMC,kBAAqCpB,WAAWkB,MAAM,CAACC,qBAAqB,CAACE,MAAM,CACvF,CAACC,KAAKC;YACJD,GAAG,CAACC,MAAM,GAAG;YACb,OAAOD;QACT,GACA,CAAC;QAGHnB,OAAOoB,KAAK,CAACH,iBAAiB;YAAEI,QAAQ;QAAK;IAC/C;IAEArB,OACGsB,MAAM,CAAuB7B,UAAU;QAAE8B,mBAAmB;IAAK,GACjED,MAAM,CAAC5B,oBAAoB;QAAE8B,gBAAgB3B,WAAW4B,IAAI;IAAC;IAEhE,IACEC,OAAOC,IAAI,CAAC9B,WAAW+B,KAAK,EAAEC,MAAM,GAAG,KACvCH,OAAOC,IAAI,CAAC9B,WAAWiC,gBAAgB,EAAED,MAAM,GAAG,GAClD;QACA7B,OAAOsB,MAAM,CAAC9B;IAChB;IAEA,OAAOQ;AACT,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
|
-
import { getBuildQueryPlugin } from '../queries/
|
|
2
|
+
import { getBuildQueryPlugin } from '../queries/getBuildQueryPlugin.js';
|
|
3
3
|
import { buildSchema } from './buildSchema.js';
|
|
4
4
|
export const buildGlobalModel = (payload)=>{
|
|
5
5
|
if (payload.config.globals && payload.config.globals.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/models/buildGlobalModel.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport mongoose from 'mongoose'\n\nimport type { GlobalModel } from '../types.js'\n\nimport { getBuildQueryPlugin } from '../queries/
|
|
1
|
+
{"version":3,"sources":["../../src/models/buildGlobalModel.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport mongoose from 'mongoose'\n\nimport type { GlobalModel } from '../types.js'\n\nimport { getBuildQueryPlugin } from '../queries/getBuildQueryPlugin.js'\nimport { buildSchema } from './buildSchema.js'\n\nexport const buildGlobalModel = (payload: Payload): GlobalModel | null => {\n if (payload.config.globals && payload.config.globals.length > 0) {\n const globalsSchema = new mongoose.Schema(\n {},\n { discriminatorKey: 'globalType', minimize: false, timestamps: true },\n )\n\n globalsSchema.plugin(getBuildQueryPlugin())\n\n const Globals = mongoose.model('globals', globalsSchema, 'globals') as unknown as GlobalModel\n\n Object.values(payload.config.globals).forEach((globalConfig) => {\n const globalSchema = buildSchema({\n buildSchemaOptions: {\n options: {\n minimize: false,\n },\n },\n configFields: globalConfig.fields,\n payload,\n })\n Globals.discriminator(globalConfig.slug, globalSchema)\n })\n\n return Globals\n }\n\n return null\n}\n"],"names":["mongoose","getBuildQueryPlugin","buildSchema","buildGlobalModel","payload","config","globals","length","globalsSchema","Schema","discriminatorKey","minimize","timestamps","plugin","Globals","model","Object","values","forEach","globalConfig","globalSchema","buildSchemaOptions","options","configFields","fields","discriminator","slug"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AAI/B,SAASC,mBAAmB,QAAQ,oCAAmC;AACvE,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,mBAAmB,CAACC;IAC/B,IAAIA,QAAQC,MAAM,CAACC,OAAO,IAAIF,QAAQC,MAAM,CAACC,OAAO,CAACC,MAAM,GAAG,GAAG;QAC/D,MAAMC,gBAAgB,IAAIR,SAASS,MAAM,CACvC,CAAC,GACD;YAAEC,kBAAkB;YAAcC,UAAU;YAAOC,YAAY;QAAK;QAGtEJ,cAAcK,MAAM,CAACZ;QAErB,MAAMa,UAAUd,SAASe,KAAK,CAAC,WAAWP,eAAe;QAEzDQ,OAAOC,MAAM,CAACb,QAAQC,MAAM,CAACC,OAAO,EAAEY,OAAO,CAAC,CAACC;YAC7C,MAAMC,eAAelB,YAAY;gBAC/BmB,oBAAoB;oBAClBC,SAAS;wBACPX,UAAU;oBACZ;gBACF;gBACAY,cAAcJ,aAAaK,MAAM;gBACjCpB;YACF;YACAU,QAAQW,aAAa,CAACN,aAAaO,IAAI,EAAEN;QAC3C;QAEA,OAAON;IACT;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type { FlattenedField,
|
|
2
|
-
type
|
|
1
|
+
import type { FlattenedField, Where } from 'payload';
|
|
2
|
+
import type { MongooseAdapter } from '../index.js';
|
|
3
|
+
export declare const buildQuery: ({ adapter, collectionSlug, fields, globalSlug, locale, where, }: {
|
|
4
|
+
adapter: MongooseAdapter;
|
|
3
5
|
collectionSlug?: string;
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export type BuildQueryArgs = {
|
|
6
|
+
fields: FlattenedField[];
|
|
7
7
|
globalSlug?: string;
|
|
8
8
|
locale?: string;
|
|
9
|
-
payload: Payload;
|
|
10
9
|
where: Where;
|
|
11
|
-
}
|
|
12
|
-
export declare const getBuildQueryPlugin: ({ collectionSlug, versionsFields, }?: GetBuildQueryPluginArgs) => (schema: any) => void;
|
|
13
|
-
export {};
|
|
10
|
+
}) => Promise<Record<string, unknown>>;
|
|
14
11
|
//# sourceMappingURL=buildQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/queries/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/queries/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,eAAO,MAAM,UAAU,oEAOpB;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,KAAK,CAAA;CACb,qCAYA,CAAA"}
|
|
@@ -1,39 +1,15 @@
|
|
|
1
|
-
import { QueryError } from 'payload';
|
|
2
1
|
import { parseParams } from './parseParams.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
if (collectionSlug) {
|
|
16
|
-
const collectionConfig = payload.collections[collectionSlug].config;
|
|
17
|
-
fields = collectionConfig.flattenedFields;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const errors = [];
|
|
21
|
-
const result = await parseParams({
|
|
22
|
-
collectionSlug,
|
|
23
|
-
fields,
|
|
24
|
-
globalSlug,
|
|
25
|
-
locale,
|
|
26
|
-
parentIsLocalized: false,
|
|
27
|
-
payload,
|
|
28
|
-
where
|
|
29
|
-
});
|
|
30
|
-
if (errors.length > 0) {
|
|
31
|
-
throw new QueryError(errors);
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
modifiedSchema.statics.buildQuery = buildQuery;
|
|
36
|
-
};
|
|
2
|
+
export const buildQuery = async ({ adapter, collectionSlug, fields, globalSlug, locale, where })=>{
|
|
3
|
+
const result = await parseParams({
|
|
4
|
+
collectionSlug,
|
|
5
|
+
fields,
|
|
6
|
+
globalSlug,
|
|
7
|
+
locale,
|
|
8
|
+
parentIsLocalized: false,
|
|
9
|
+
payload: adapter.payload,
|
|
10
|
+
where
|
|
11
|
+
});
|
|
12
|
+
return result;
|
|
37
13
|
};
|
|
38
14
|
|
|
39
15
|
//# sourceMappingURL=buildQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { FlattenedField,
|
|
1
|
+
{"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { FlattenedField, Where } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { parseParams } from './parseParams.js'\n\nexport const buildQuery = async ({\n adapter,\n collectionSlug,\n fields,\n globalSlug,\n locale,\n where,\n}: {\n adapter: MongooseAdapter\n collectionSlug?: string\n fields: FlattenedField[]\n globalSlug?: string\n locale?: string\n where: Where\n}) => {\n const result = await parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized: false,\n payload: adapter.payload,\n where,\n })\n\n return result\n}\n"],"names":["parseParams","buildQuery","adapter","collectionSlug","fields","globalSlug","locale","where","result","parentIsLocalized","payload"],"mappings":"AAIA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,aAAa,OAAO,EAC/BC,OAAO,EACPC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,KAAK,EAQN;IACC,MAAMC,SAAS,MAAMR,YAAY;QAC/BG;QACAC;QACAC;QACAC;QACAG,mBAAmB;QACnBC,SAASR,QAAQQ,OAAO;QACxBH;IACF;IAEA,OAAOC;AACT,EAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FlattenedField, Payload, Where } from 'payload';
|
|
2
|
+
type GetBuildQueryPluginArgs = {
|
|
3
|
+
collectionSlug?: string;
|
|
4
|
+
versionsFields?: FlattenedField[];
|
|
5
|
+
};
|
|
6
|
+
export type BuildQueryArgs = {
|
|
7
|
+
globalSlug?: string;
|
|
8
|
+
locale?: string;
|
|
9
|
+
payload: Payload;
|
|
10
|
+
where: Where;
|
|
11
|
+
};
|
|
12
|
+
export declare const getBuildQueryPlugin: ({ collectionSlug, versionsFields, }?: GetBuildQueryPluginArgs) => (schema: any) => void;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=getBuildQueryPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBuildQueryPlugin.d.ts","sourceRoot":"","sources":["../../src/queries/getBuildQueryPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAM7D,KAAK,uBAAuB,GAAG;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,cAAc,EAAE,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAKD,eAAO,MAAM,mBAAmB,yCAG7B,uBAAuB,0BAwCzB,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { QueryError } from 'payload';
|
|
2
|
+
import { parseParams } from './parseParams.js';
|
|
3
|
+
// This plugin asynchronously builds a list of Mongoose query constraints
|
|
4
|
+
// which can then be used in subsequent Mongoose queries.
|
|
5
|
+
// Deprecated in favor of using simpler buildQuery directly
|
|
6
|
+
export const getBuildQueryPlugin = ({ collectionSlug, versionsFields } = {})=>{
|
|
7
|
+
return function buildQueryPlugin(schema) {
|
|
8
|
+
const modifiedSchema = schema;
|
|
9
|
+
async function schemaBuildQuery({ globalSlug, locale, payload, where }) {
|
|
10
|
+
let fields = versionsFields;
|
|
11
|
+
if (!fields) {
|
|
12
|
+
if (globalSlug) {
|
|
13
|
+
const globalConfig = payload.globals.config.find(({ slug })=>slug === globalSlug);
|
|
14
|
+
fields = globalConfig.flattenedFields;
|
|
15
|
+
}
|
|
16
|
+
if (collectionSlug) {
|
|
17
|
+
const collectionConfig = payload.collections[collectionSlug].config;
|
|
18
|
+
fields = collectionConfig.flattenedFields;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const errors = [];
|
|
22
|
+
const result = await parseParams({
|
|
23
|
+
collectionSlug,
|
|
24
|
+
fields,
|
|
25
|
+
globalSlug,
|
|
26
|
+
locale,
|
|
27
|
+
parentIsLocalized: false,
|
|
28
|
+
payload,
|
|
29
|
+
where
|
|
30
|
+
});
|
|
31
|
+
if (errors.length > 0) {
|
|
32
|
+
throw new QueryError(errors);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
modifiedSchema.statics.buildQuery = schemaBuildQuery;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=getBuildQueryPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/queries/getBuildQueryPlugin.ts"],"sourcesContent":["import type { FlattenedField, Payload, Where } from 'payload'\n\nimport { QueryError } from 'payload'\n\nimport { parseParams } from './parseParams.js'\n\ntype GetBuildQueryPluginArgs = {\n collectionSlug?: string\n versionsFields?: FlattenedField[]\n}\n\nexport type BuildQueryArgs = {\n globalSlug?: string\n locale?: string\n payload: Payload\n where: Where\n}\n\n// This plugin asynchronously builds a list of Mongoose query constraints\n// which can then be used in subsequent Mongoose queries.\n// Deprecated in favor of using simpler buildQuery directly\nexport const getBuildQueryPlugin = ({\n collectionSlug,\n versionsFields,\n}: GetBuildQueryPluginArgs = {}) => {\n return function buildQueryPlugin(schema) {\n const modifiedSchema = schema\n async function schemaBuildQuery({\n globalSlug,\n locale,\n payload,\n where,\n }: BuildQueryArgs): Promise<Record<string, unknown>> {\n let fields = versionsFields\n if (!fields) {\n if (globalSlug) {\n const globalConfig = payload.globals.config.find(({ slug }) => slug === globalSlug)\n fields = globalConfig.flattenedFields\n }\n if (collectionSlug) {\n const collectionConfig = payload.collections[collectionSlug].config\n fields = collectionConfig.flattenedFields\n }\n }\n\n const errors = []\n const result = await parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized: false,\n payload,\n where,\n })\n\n if (errors.length > 0) {\n throw new QueryError(errors)\n }\n\n return result\n }\n modifiedSchema.statics.buildQuery = schemaBuildQuery\n }\n}\n"],"names":["QueryError","parseParams","getBuildQueryPlugin","collectionSlug","versionsFields","buildQueryPlugin","schema","modifiedSchema","schemaBuildQuery","globalSlug","locale","payload","where","fields","globalConfig","globals","config","find","slug","flattenedFields","collectionConfig","collections","errors","result","parentIsLocalized","length","statics","buildQuery"],"mappings":"AAEA,SAASA,UAAU,QAAQ,UAAS;AAEpC,SAASC,WAAW,QAAQ,mBAAkB;AAc9C,yEAAyE;AACzE,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,cAAc,EACdC,cAAc,EACU,GAAG,CAAC,CAAC;IAC7B,OAAO,SAASC,iBAAiBC,MAAM;QACrC,MAAMC,iBAAiBD;QACvB,eAAeE,iBAAiB,EAC9BC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,KAAK,EACU;YACf,IAAIC,SAAST;YACb,IAAI,CAACS,QAAQ;gBACX,IAAIJ,YAAY;oBACd,MAAMK,eAAeH,QAAQI,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAAST;oBACxEI,SAASC,aAAaK,eAAe;gBACvC;gBACA,IAAIhB,gBAAgB;oBAClB,MAAMiB,mBAAmBT,QAAQU,WAAW,CAAClB,eAAe,CAACa,MAAM;oBACnEH,SAASO,iBAAiBD,eAAe;gBAC3C;YACF;YAEA,MAAMG,SAAS,EAAE;YACjB,MAAMC,SAAS,MAAMtB,YAAY;gBAC/BE;gBACAU;gBACAJ;gBACAC;gBACAc,mBAAmB;gBACnBb;gBACAC;YACF;YAEA,IAAIU,OAAOG,MAAM,GAAG,GAAG;gBACrB,MAAM,IAAIzB,WAAWsB;YACvB;YAEA,OAAOC;QACT;QACAhB,eAAemB,OAAO,CAACC,UAAU,GAAGnB;IACtC;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizeQueryValue.d.ts","sourceRoot":"","sources":["../../src/queries/sanitizeQueryValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EACd,OAAO,EAER,MAAM,SAAS,CAAA;AAMhB,KAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,cAAc,CAAA;IACrB,WAAW,EAAE,OAAO,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AAiED,eAAO,MAAM,kBAAkB,qFAS5B,sBAAsB,KAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"sanitizeQueryValue.d.ts","sourceRoot":"","sources":["../../src/queries/sanitizeQueryValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EACd,OAAO,EAER,MAAM,SAAS,CAAA;AAMhB,KAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,cAAc,CAAA;IACrB,WAAW,EAAE,OAAO,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AAiED,eAAO,MAAM,kBAAkB,qFAS5B,sBAAsB,KAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CA6Vd,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/queries/sanitizeQueryValue.ts"],"sourcesContent":["import type {\n FlattenedBlock,\n FlattenedBlocksField,\n FlattenedField,\n Payload,\n RelationshipField,\n} from 'payload'\n\nimport { Types } from 'mongoose'\nimport { createArrayFromCommaDelineated } from 'payload'\nimport { fieldShouldBeLocalized } from 'payload/shared'\n\ntype SanitizeQueryValueArgs = {\n field: FlattenedField\n hasCustomID: boolean\n locale?: string\n operator: string\n parentIsLocalized: boolean\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 payload,\n segments,\n}: {\n field: FlattenedBlock | FlattenedField\n payload: Payload\n segments: string[]\n}) => {\n if ('blocks' in field || 'blockReferences' in field) {\n const _field: FlattenedBlocksField = field as FlattenedBlocksField\n for (const _block of _field.blockReferences ?? _field.blocks) {\n const block: FlattenedBlock = typeof _block === 'string' ? payload.blocks[_block] : _block\n const field = getFieldFromSegments({ field: block, payload, 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 = field.flattenedFields.find((each) => each.name === segments[i])\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, payload, segments })\n }\n }\n}\n\nexport const sanitizeQueryValue = ({\n field,\n hasCustomID,\n locale,\n operator,\n parentIsLocalized,\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, payload, 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 let localizedPath = path\n\n if (\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n payload.config.localization &&\n locale\n ) {\n localizedPath = `${path}.${locale}`\n }\n\n return {\n rawQuery: {\n $or: [\n {\n [localizedPath]: {\n $eq: {\n // disable auto sort\n /* eslint-disable */\n value: formattedValue.value,\n relationTo: formattedValue.relationTo,\n /* eslint-enable */\n },\n },\n },\n {\n [localizedPath]: {\n $eq: {\n relationTo: formattedValue.relationTo,\n value: formattedValue.value,\n },\n },\n },\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 if (\n operator === 'all' &&\n Array.isArray(relationTo) &&\n path.endsWith('.value') &&\n Array.isArray(formattedValue)\n ) {\n formattedValue.forEach((v, i) => {\n if (Types.ObjectId.isValid(v)) {\n formattedValue[i] = new Types.ObjectId(v)\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 && !Number.isNaN(Number(maxDistance))) {\n formattedValue.$maxDistance = parseFloat(maxDistance)\n }\n\n if (minDistance && !Number.isNaN(Number(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","fieldShouldBeLocalized","buildExistsQuery","formattedValue","path","treatEmptyString","rawQuery","$and","$exists","$ne","$or","$eq","getFieldFromSegments","field","payload","segments","_field","_block","blockReferences","blocks","block","i","length","foundField","flattenedFields","find","each","name","shift","sanitizeQueryValue","hasCustomID","locale","operator","parentIsLocalized","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","localizedPath","config","localization","collections","customIDType","some","toString","endsWith","hasCustomIDType","formattedNumber","forEach","v","lng","lat","maxDistance","minDistance","$geometry","coordinates","$maxDistance","$minDistance","$options","$regex","replace"],"mappings":"AAQA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,8BAA8B,QAAQ,UAAS;AACxD,SAASC,sBAAsB,QAAQ,iBAAgB;AAavD,MAAMC,mBAAmB,CAACC,gBAAgBC,MAAMC,mBAAmB,IAAI;IACrE,IAAIF,gBAAgB;QAClB,OAAO;YACLG,UAAU;gBACR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iBAAiB;gBACf8E,UAAU;gBACVC,QAAQ/E,eAAegF,OAAO,CAAC,uBAAuB;YACxD;QACF;QAEA,IAAInD,aAAa,UAAU;YACzB7B,iBAAiBA,mBAAmB,UAAUA,mBAAmB;YAEjE,6EAA6E;YAC7E,OAAOD,iBACLC,gBACAC,MACA,CAAC;gBAAC;gBAAgB;aAAS,CAACgC,QAAQ,CAACvB,MAAMwB,IAAI;QAEnD;IACF;IAEA,IACE,AAACjC,CAAAA,SAAS,SAASA,SAAS,QAAO,KACnC4B,aAAa,UACb7B,eAAemB,MAAM,KAAK,MAC1B,CAACQ,aACD;QACAK,oBAAoB;IACtB;IAEA,IAAIH,aAAa,UAAU;QACzB7B,iBAAiBA,mBAAmB,UAAUA,mBAAmB;QAEjE,mBAAmB;QACnB,IAAI;YAAC;YAAgB;YAAU;SAAS,CAACiC,QAAQ,CAACvB,MAAMwB,IAAI,GAAG;YAC7D,IAAIlC,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;QAAEqB,UAAUG;QAAmBD,KAAK/B;IAAe;AAC5D,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/queries/sanitizeQueryValue.ts"],"sourcesContent":["import type {\n FlattenedBlock,\n FlattenedBlocksField,\n FlattenedField,\n Payload,\n RelationshipField,\n} from 'payload'\n\nimport { Types } from 'mongoose'\nimport { createArrayFromCommaDelineated } from 'payload'\nimport { fieldShouldBeLocalized } from 'payload/shared'\n\ntype SanitizeQueryValueArgs = {\n field: FlattenedField\n hasCustomID: boolean\n locale?: string\n operator: string\n parentIsLocalized: boolean\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 payload,\n segments,\n}: {\n field: FlattenedBlock | FlattenedField\n payload: Payload\n segments: string[]\n}) => {\n if ('blocks' in field || 'blockReferences' in field) {\n const _field: FlattenedBlocksField = field as FlattenedBlocksField\n for (const _block of _field.blockReferences ?? _field.blocks) {\n const block: FlattenedBlock = typeof _block === 'string' ? payload.blocks[_block] : _block\n const field = getFieldFromSegments({ field: block, payload, 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 = field.flattenedFields.find((each) => each.name === segments[i])\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, payload, segments })\n }\n }\n}\n\nexport const sanitizeQueryValue = ({\n field,\n hasCustomID,\n locale,\n operator,\n parentIsLocalized,\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 if (['array', 'blocks', 'group', 'tab'].includes(field.type) && path.includes('.')) {\n const segments = path.split('.')\n segments.shift()\n const foundField = getFieldFromSegments({ field, payload, 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 let localizedPath = path\n\n if (\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n payload.config.localization &&\n locale\n ) {\n localizedPath = `${path}.${locale}`\n }\n\n return {\n rawQuery: {\n $or: [\n {\n [localizedPath]: {\n $eq: {\n // disable auto sort\n /* eslint-disable */\n value: formattedValue.value,\n relationTo: formattedValue.relationTo,\n /* eslint-enable */\n },\n },\n },\n {\n [localizedPath]: {\n $eq: {\n relationTo: formattedValue.relationTo,\n value: formattedValue.value,\n },\n },\n },\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 if (\n operator === 'all' &&\n Array.isArray(relationTo) &&\n path.endsWith('.value') &&\n Array.isArray(formattedValue)\n ) {\n formattedValue.forEach((v, i) => {\n if (Types.ObjectId.isValid(v)) {\n formattedValue[i] = new Types.ObjectId(v)\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 && !Number.isNaN(Number(maxDistance))) {\n formattedValue.$maxDistance = parseFloat(maxDistance)\n }\n\n if (minDistance && !Number.isNaN(Number(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","fieldShouldBeLocalized","buildExistsQuery","formattedValue","path","treatEmptyString","rawQuery","$and","$exists","$ne","$or","$eq","getFieldFromSegments","field","payload","segments","_field","_block","blockReferences","blocks","block","i","length","foundField","flattenedFields","find","each","name","shift","sanitizeQueryValue","hasCustomID","locale","operator","parentIsLocalized","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","localizedPath","config","localization","collections","customIDType","some","toString","endsWith","hasCustomIDType","formattedNumber","forEach","v","lng","lat","maxDistance","minDistance","$geometry","coordinates","$maxDistance","$minDistance","$options","$regex","replace"],"mappings":"AAQA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,8BAA8B,QAAQ,UAAS;AACxD,SAASC,sBAAsB,QAAQ,iBAAgB;AAavD,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,OAAO,EACPC,QAAQ,EAKT;IACC,IAAI,YAAYF,SAAS,qBAAqBA,OAAO;QACnD,MAAMG,SAA+BH;QACrC,KAAK,MAAMI,UAAUD,OAAOE,eAAe,IAAIF,OAAOG,MAAM,CAAE;YAC5D,MAAMC,QAAwB,OAAOH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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;QAAEqB,UAAUG;QAAmBD,KAAK/B;IAAe;AAC5D,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryDrafts.d.ts","sourceRoot":"","sources":["../src/queryDrafts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"queryDrafts.d.ts","sourceRoot":"","sources":["../src/queryDrafts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAa1C,eAAO,MAAM,WAAW,EAAE,WA8HzB,CAAA"}
|
package/dist/queryDrafts.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildVersionCollectionFields, combineQueries, flattenWhereToOperators } from 'payload';
|
|
2
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
2
3
|
import { buildSortParam } from './queries/buildSortParam.js';
|
|
3
4
|
import { buildJoinAggregation } from './utilities/buildJoinAggregation.js';
|
|
4
5
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
@@ -30,14 +31,16 @@ export const queryDrafts = async function queryDrafts({ collection, joins, limit
|
|
|
30
31
|
equals: true
|
|
31
32
|
}
|
|
32
33
|
}, where);
|
|
33
|
-
const
|
|
34
|
+
const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true);
|
|
35
|
+
const versionQuery = await buildQuery({
|
|
36
|
+
adapter: this,
|
|
37
|
+
fields,
|
|
34
38
|
locale,
|
|
35
|
-
payload: this.payload,
|
|
36
39
|
where: combinedWhere
|
|
37
40
|
});
|
|
38
41
|
const projection = buildProjectionFromSelect({
|
|
39
42
|
adapter: this,
|
|
40
|
-
fields
|
|
43
|
+
fields,
|
|
41
44
|
select
|
|
42
45
|
});
|
|
43
46
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
package/dist/queryDrafts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/queryDrafts.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { QueryDrafts } from 'payload'\n\nimport { buildVersionCollectionFields, combineQueries, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\n\nexport const queryDrafts: QueryDrafts = async function queryDrafts(\n this: MongooseAdapter,\n { collection, joins, limit, locale, page, pagination, req, select, sort: sortArg, where },\n) {\n const VersionModel = this.versions[collection]\n const collectionConfig = this.payload.collections[collection].config\n const options: QueryOptions = {\n session: await getSession(this, req),\n }\n\n let hasNearConstraint\n let sort\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n if (!hasNearConstraint) {\n sort = buildSortParam({\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n }\n\n const combinedWhere = combineQueries({ latest: { equals: true } }, where)\n\n const versionQuery = await
|
|
1
|
+
{"version":3,"sources":["../src/queryDrafts.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { QueryDrafts } from 'payload'\n\nimport { buildVersionCollectionFields, combineQueries, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\n\nexport const queryDrafts: QueryDrafts = async function queryDrafts(\n this: MongooseAdapter,\n { collection, joins, limit, locale, page, pagination, req, select, sort: sortArg, where },\n) {\n const VersionModel = this.versions[collection]\n const collectionConfig = this.payload.collections[collection].config\n const options: QueryOptions = {\n session: await getSession(this, req),\n }\n\n let hasNearConstraint\n let sort\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n if (!hasNearConstraint) {\n sort = buildSortParam({\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n }\n\n const combinedWhere = combineQueries({ latest: { equals: true } }, where)\n\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n const versionQuery = await buildQuery({\n adapter: this,\n fields,\n locale,\n where: combinedWhere,\n })\n\n const projection = buildProjectionFromSelect({\n adapter: this,\n fields,\n select,\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 =\n hasNearConstraint || !versionQuery || Object.keys(versionQuery).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n options,\n page,\n pagination,\n projection,\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 (\n !useEstimatedCount &&\n Object.keys(versionQuery).length === 0 &&\n this.disableIndexHints !== true\n ) {\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 VersionModel.countDocuments(versionQuery, {\n hint: { _id: 1 },\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 paginationOptions.options.limit = limit\n }\n\n let result\n\n const aggregate = await buildJoinAggregation({\n adapter: this,\n collection,\n collectionConfig,\n joins,\n locale,\n projection,\n query: versionQuery,\n versions: true,\n })\n\n // build join aggregation\n if (aggregate) {\n result = await VersionModel.aggregatePaginate(\n VersionModel.aggregate(aggregate),\n paginationOptions,\n )\n } else {\n result = await VersionModel.paginate(versionQuery, paginationOptions)\n }\n\n const docs = JSON.parse(JSON.stringify(result.docs))\n\n return {\n ...result,\n docs: docs.map((doc) => {\n doc = {\n _id: doc.parent,\n id: doc.parent,\n ...doc.version,\n }\n\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["buildVersionCollectionFields","combineQueries","flattenWhereToOperators","buildQuery","buildSortParam","buildJoinAggregation","buildProjectionFromSelect","getSession","sanitizeInternalFields","queryDrafts","collection","joins","limit","locale","page","pagination","req","select","sort","sortArg","where","VersionModel","versions","collectionConfig","payload","collections","config","options","session","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","flattenedFields","defaultSort","timestamps","combinedWhere","latest","equals","versionQuery","adapter","projection","useEstimatedCount","length","paginationOptions","lean","leanWithId","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","aggregate","query","aggregatePaginate","paginate","docs","JSON","parse","stringify","map","doc","parent","id","version"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,cAAc,EAAEC,uBAAuB,QAAQ,UAAS;AAI/F,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D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AMA,KAAKI,GAAG,CAAC,CAACC;YACdA,MAAM;gBACJX,KAAKW,IAAIC,MAAM;gBACfC,IAAIF,IAAIC,MAAM;gBACd,GAAGD,IAAIG,OAAO;YAChB;YAEA,OAAOjE,uBAAuB8D;QAChC;IACF;AACF,EAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ClientSession } from 'mongodb';
|
|
2
2
|
import type { AggregatePaginateModel, IndexDefinition, IndexOptions, Model, PaginateModel, SchemaOptions } from 'mongoose';
|
|
3
3
|
import type { ArrayField, BlocksField, CheckboxField, CodeField, CollapsibleField, DateField, EmailField, Field, GroupField, JoinField, JSONField, NumberField, Payload, PayloadRequest, PointField, RadioField, RelationshipField, RichTextField, RowField, SanitizedConfig, SelectField, TabsField, TextareaField, TextField, UploadField } from 'payload';
|
|
4
|
-
import type { BuildQueryArgs } from './queries/
|
|
4
|
+
import type { BuildQueryArgs } from './queries/getBuildQueryPlugin.js';
|
|
5
5
|
export interface CollectionModel extends Model<any>, PaginateModel<any>, AggregatePaginateModel<any> {
|
|
6
6
|
/** buildQuery is used to transform payload's where operator into what can be used by mongoose (e.g. id => _id) */
|
|
7
7
|
buildQuery: (args: BuildQueryArgs) => Promise<Record<string, unknown>>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,KAAK,EACL,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX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AE,OAAO,CAAA;IAChB;;OAEG;IACH,GAAG,EAAE,cAAc,CAAA;IACnB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA;AACD,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,GAAG,EAAE,cAAc,CAAA;IACnB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { ClientSession } from 'mongodb'\nimport type {\n AggregatePaginateModel,\n IndexDefinition,\n IndexOptions,\n Model,\n PaginateModel,\n SchemaOptions,\n} from 'mongoose'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GroupField,\n JoinField,\n JSONField,\n NumberField,\n Payload,\n PayloadRequest,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport type { BuildQueryArgs } from './queries/
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { ClientSession } from 'mongodb'\nimport type {\n AggregatePaginateModel,\n IndexDefinition,\n IndexOptions,\n Model,\n PaginateModel,\n SchemaOptions,\n} from 'mongoose'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GroupField,\n JoinField,\n JSONField,\n NumberField,\n Payload,\n PayloadRequest,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport type { BuildQueryArgs } from './queries/getBuildQueryPlugin.js'\n\nexport interface CollectionModel\n extends Model<any>,\n PaginateModel<any>,\n AggregatePaginateModel<any> {\n /** buildQuery is used to transform payload's where operator into what can be used by mongoose (e.g. id => _id) */\n buildQuery: (args: BuildQueryArgs) => Promise<Record<string, unknown>> // TODO: Delete this\n}\n\nexport interface AuthCollectionModel extends CollectionModel {\n resetPasswordExpiration: Date\n resetPasswordToken: string\n}\n\nexport type TypeOfIndex = {\n fields: IndexDefinition\n options?: IndexOptions\n}\n\nexport interface GlobalModel extends Model<Document> {\n buildQuery: (query: unknown, locale?: string) => Promise<Record<string, unknown>>\n}\n\nexport type BuildSchema<TSchema> = (args: {\n config: SanitizedConfig\n fields: Field[]\n options: BuildSchemaOptions\n}) => TSchema\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\nexport type FieldGenerator<TSchema, TField> = {\n config: SanitizedConfig\n field: TField\n options: BuildSchemaOptions\n schema: TSchema\n}\n\nexport type FieldGeneratorFunction<TSchema, TField extends Field> = (\n args: FieldGenerator<TSchema, TField>,\n) => void\n\n/**\n * Object mapping types to a schema based on TSchema\n */\nexport type FieldToSchemaMap<TSchema> = {\n array: FieldGeneratorFunction<TSchema, ArrayField>\n blocks: FieldGeneratorFunction<TSchema, BlocksField>\n checkbox: FieldGeneratorFunction<TSchema, CheckboxField>\n code: FieldGeneratorFunction<TSchema, CodeField>\n collapsible: FieldGeneratorFunction<TSchema, CollapsibleField>\n date: FieldGeneratorFunction<TSchema, DateField>\n email: FieldGeneratorFunction<TSchema, EmailField>\n group: FieldGeneratorFunction<TSchema, GroupField>\n join: FieldGeneratorFunction<TSchema, JoinField>\n json: FieldGeneratorFunction<TSchema, JSONField>\n number: FieldGeneratorFunction<TSchema, NumberField>\n point: FieldGeneratorFunction<TSchema, PointField>\n radio: FieldGeneratorFunction<TSchema, RadioField>\n relationship: FieldGeneratorFunction<TSchema, RelationshipField>\n richText: FieldGeneratorFunction<TSchema, RichTextField>\n row: FieldGeneratorFunction<TSchema, RowField>\n select: FieldGeneratorFunction<TSchema, SelectField>\n tabs: FieldGeneratorFunction<TSchema, TabsField>\n text: FieldGeneratorFunction<TSchema, TextField>\n textarea: FieldGeneratorFunction<TSchema, TextareaField>\n upload: FieldGeneratorFunction<TSchema, UploadField>\n}\n\nexport type MigrateUpArgs = {\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateUpArgs } from '@payloadcms/db-mongodb'\n *\n * export async function up({ session, payload, req }: MigrateUpArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n /**\n * The MongoDB client session that you can use to execute MongoDB methods directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateUpArgs } from '@payloadcms/db-mongodb'\n *\n * export async function up({ session, payload, req }: MigrateUpArgs): Promise<void> {\n * const { rows: posts } = await payload.db.collections.posts.collection.find({ session }).toArray()\n * }\n * ```\n */\n session?: ClientSession\n}\nexport type MigrateDownArgs = {\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateDownArgs } from '@payloadcms/db-mongodb'\n *\n * export async function down({ session, payload, req }: MigrateDownArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n /**\n * The MongoDB client session that you can use to execute MongoDB methods directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateDownArgs } from '@payloadcms/db-mongodb'\n *\n * export async function down({ session, payload, req }: MigrateDownArgs): Promise<void> {\n * const { rows: posts } = await payload.db.collections.posts.collection.find({ session }).toArray()\n * }\n * ```\n */\n session?: ClientSession\n}\n"],"names":[],"mappings":"AAgJA,WA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,eAAO,MAAM,YAAY,EAAE,YAwC1B,CAAA"}
|
package/dist/updateGlobal.js
CHANGED
|
@@ -25,6 +25,9 @@ export const updateGlobal = async function updateGlobal({ slug, data, options: o
|
|
|
25
25
|
result = await Model.findOneAndUpdate({
|
|
26
26
|
globalType: slug
|
|
27
27
|
}, sanitizedData, options);
|
|
28
|
+
if (!result) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
28
31
|
result = JSON.parse(JSON.stringify(result));
|
|
29
32
|
// custom id type reset
|
|
30
33
|
result.id = result._id;
|
package/dist/updateGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug, data, options: optionsArgs = {}, req, 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 lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: this.payload.config.globals.find((global) => global.slug === slug).flattenedFields,\n select,\n }),\n session: await getSession(this, req),\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","getSession","sanitizeInternalFields","sanitizeRelationshipIDs","updateGlobal","slug","data","options","optionsArgs","req","select","Model","globals","fields","payload","config","find","global","lean","new","projection","adapter","flattenedFields","session","result","sanitizedData","findOneAndUpdate","globalType","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,SAASC,cAAc,CAAC,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAE;IAEtD,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;QACdU,MAAM;QACNC,KAAK;QACLC,YAAYpB,0BAA0B;YACpCqB,SAAS,IAAI;YACbR,QAAQ,IAAI,CAACC,OAAO,CAACC,MAAM,CAACH,OAAO,CAACI,IAAI,CAAC,CAACC,SAAWA,OAAOZ,IAAI,KAAKA,MAAMiB,eAAe;YAC1FZ;QACF;QACAa,SAAS,MAAMtB,WAAW,IAAI,EAAEQ;IAClC;IAEA,IAAIe;IAEJ,MAAMC,gBAAgBtB,wBAAwB;QAC5CY,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3BT;QACAO;IACF;IAEAW,SAAS,MAAMb,MAAMe,gBAAgB,CAAC;QAAEC,YAAYtB;IAAK,GAAGoB,eAAelB;
|
|
1
|
+
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug, data, options: optionsArgs = {}, req, 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 lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: this.payload.config.globals.find((global) => global.slug === slug).flattenedFields,\n select,\n }),\n session: await getSession(this, req),\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 if (!result) {\n return null\n }\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","getSession","sanitizeInternalFields","sanitizeRelationshipIDs","updateGlobal","slug","data","options","optionsArgs","req","select","Model","globals","fields","payload","config","find","global","lean","new","projection","adapter","flattenedFields","session","result","sanitizedData","findOneAndUpdate","globalType","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,sBAAsB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A;AAEjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,UAAU,EAAE,KAAK,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAOjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EACE,EAAE,EACF,MAAM,EAAE,UAAU,EAClB,MAAM,EACN,OAAO,EAAE,WAAgB,EACzB,GAAG,EACH,MAAM,EACN,WAAW,EACX,KAAK,GACN,EAAE,uBAAuB,CAAC,CAAC,CAAC,gBAiD9B"}
|