@payloadcms/db-mongodb 3.0.0-canary.c696728 → 3.0.0-canary.c96fa61
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/countGlobalVersions.d.ts +3 -0
- package/dist/countGlobalVersions.d.ts.map +1 -0
- package/dist/countGlobalVersions.js +33 -0
- package/dist/countGlobalVersions.js.map +1 -0
- package/dist/countVersions.d.ts +3 -0
- package/dist/countVersions.d.ts.map +1 -0
- package/dist/countVersions.js +33 -0
- package/dist/countVersions.js.map +1 -0
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +3 -0
- package/dist/create.js.map +1 -1
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +8 -6
- package/dist/createMigration.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +18 -5
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +10 -2
- package/dist/deleteOne.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +9 -2
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +8 -2
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +7 -1
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +9 -1
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +8 -2
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/models/buildSchema.js +16 -1
- package/dist/models/buildSchema.js.map +1 -1
- package/dist/queries/buildSortParam.d.ts +2 -2
- package/dist/queries/buildSortParam.d.ts.map +1 -1
- package/dist/queries/buildSortParam.js +26 -17
- package/dist/queries/buildSortParam.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +60 -48
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +28 -6
- package/dist/queryDrafts.js.map +1 -1
- package/dist/types.d.ts +3 -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 +10 -3
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +10 -3
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +11 -3
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +10 -3
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsert.d.ts +3 -0
- package/dist/upsert.d.ts.map +1 -0
- package/dist/upsert.js +15 -0
- package/dist/upsert.js.map +1 -0
- package/dist/utilities/buildJoinAggregation.d.ts +4 -1
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +23 -12
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.d.ts +8 -0
- package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -0
- package/dist/utilities/buildProjectionFromSelect.js +171 -0
- package/dist/utilities/buildProjectionFromSelect.js.map +1 -0
- package/dist/utilities/handleError.js +2 -2
- package/dist/utilities/handleError.js.map +1 -1
- package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +1 -1
- package/dist/utilities/sanitizeRelationshipIDs.js +6 -2
- package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -1
- package/package.json +4 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import { buildVersionCollectionFields, type PayloadRequest, type UpdateVersion } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n { id, collection, locale, req = {} as PayloadRequest, versionData, where },\n) {\n const VersionModel = this.versions[collection]\n const whereToUse = where || { id: { equals: id } }\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n new: true,\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
|
1
|
+
{"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import { buildVersionCollectionFields, type PayloadRequest, type UpdateVersion } 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 const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n { id, collection, locale, req = {} as PayloadRequest, select, versionData, where },\n) {\n const VersionModel = this.versions[collection]\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collection].config,\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":["buildVersionCollectionFields","buildProjectionFromSelect","sanitizeRelationshipIDs","withSession","updateVersion","id","collection","locale","req","select","versionData","where","VersionModel","versions","whereToUse","equals","fields","payload","config","collections","options","lean","new","projection","adapter","query","buildQuery","sanitizedData","data","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"mappings":"AAAA,SAASA,4BAA4B,QAAiD,UAAS;AAI/F,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,EAAE,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAE;IAElF,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACP,WAAW;IAC9C,MAAMQ,aAAaH,SAAS;QAAEN,IAAI;YAAEU,QAAQV;QAAG;IAAE;IACjD,MAAMW,SAAShB,6BACb,IAAI,CAACiB,OAAO,CAACC,MAAM,EACnB,IAAI,CAACD,OAAO,CAACE,WAAW,CAACb,WAAW,CAACY,MAAM;IAG7C,MAAME,UAAU;QACd,GAAI,MAAMjB,YAAY,IAAI,EAAEK,IAAI;QAChCa,MAAM;QACNC,KAAK;QACLC,YAAYtB,0BAA0B;YAAEuB,SAAS,IAAI;YAAER;YAAQP;QAAO;IACxE;IAEA,MAAMgB,QAAQ,MAAMb,aAAac,UAAU,CAAC;QAC1CnB;QACAU,SAAS,IAAI,CAACA,OAAO;QACrBN,OAAOG;IACT;IAEA,MAAMa,gBAAgBzB,wBAAwB;QAC5CgB,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3BU,MAAMlB;QACNM;IACF;IAEA,MAAMa,MAAM,MAAMjB,aAAakB,gBAAgB,CAACL,OAAOE,eAAeP;IAEtE,MAAMW,SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEzC,MAAMM,oBAAoBN,IAAIO,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAO1B,EAAE,GAAG0B,OAAOM,GAAG;IACtB,IAAIF,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT,EAAC"}
|
package/dist/upsert.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../src/upsert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,MAAM,EAAE,MAAM,SAAS,CAAA;AAIrD,eAAO,MAAM,MAAM,EAAE,MAKpB,CAAA"}
|
package/dist/upsert.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
export const upsert = async function upsert({ collection, data, locale, req = {}, select, where }) {
|
2
|
+
return this.updateOne({
|
3
|
+
collection,
|
4
|
+
data,
|
5
|
+
locale,
|
6
|
+
options: {
|
7
|
+
upsert: true
|
8
|
+
},
|
9
|
+
req,
|
10
|
+
select,
|
11
|
+
where
|
12
|
+
});
|
13
|
+
};
|
14
|
+
|
15
|
+
//# sourceMappingURL=upsert.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/upsert.ts"],"sourcesContent":["import type { PayloadRequest, Upsert } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nexport const upsert: Upsert = async function upsert(\n this: MongooseAdapter,\n { collection, data, locale, req = {} as PayloadRequest, select, where },\n) {\n return this.updateOne({ collection, data, locale, options: { upsert: true }, req, select, where })\n}\n"],"names":["upsert","collection","data","locale","req","select","where","updateOne","options"],"mappings":"AAIA,OAAO,MAAMA,SAAiB,eAAeA,OAE3C,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAEvE,OAAO,IAAI,CAACC,SAAS,CAAC;QAAEN;QAAYC;QAAMC;QAAQK,SAAS;YAAER,QAAQ;QAAK;QAAGI;QAAKC;QAAQC;IAAM;AAClG,EAAC"}
|
@@ -8,8 +8,11 @@ type BuildJoinAggregationArgs = {
|
|
8
8
|
joins: JoinQuery;
|
9
9
|
limit?: number;
|
10
10
|
locale: string;
|
11
|
+
projection?: Record<string, true>;
|
11
12
|
query?: Where;
|
13
|
+
/** whether the query is from drafts */
|
14
|
+
versions?: boolean;
|
12
15
|
};
|
13
|
-
export declare const buildJoinAggregation: ({ adapter, collection, collectionConfig, joins, limit, locale, query, }: BuildJoinAggregationArgs) => Promise<PipelineStage[] | undefined>;
|
16
|
+
export declare const buildJoinAggregation: ({ adapter, collection, collectionConfig, joins, limit, locale, projection, query, versions, }: BuildJoinAggregationArgs) => Promise<PipelineStage[] | undefined>;
|
14
17
|
export {};
|
15
18
|
//# sourceMappingURL=buildJoinAggregation.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"buildJoinAggregation.d.ts","sourceRoot":"","sources":["../../src/utilities/buildJoinAggregation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,cAAc,CAAA;IAC1B,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,KAAK,EAAE,SAAS,CAAA;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;
|
1
|
+
{"version":3,"file":"buildJoinAggregation.d.ts","sourceRoot":"","sources":["../../src/utilities/buildJoinAggregation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,cAAc,CAAA;IAC1B,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,KAAK,EAAE,SAAS,CAAA;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAEjC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,oBAAoB,kGAU9B,wBAAwB,KAAG,OAAO,CAAC,aAAa,EAAE,GAAG,SAAS,CA+JhE,CAAA"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { buildSortParam } from '../queries/buildSortParam.js';
|
2
|
-
export const buildJoinAggregation = async ({ adapter, collection, collectionConfig, joins, limit, locale, query })=>{
|
2
|
+
export const buildJoinAggregation = async ({ adapter, collection, collectionConfig, joins, limit, locale, projection, query, versions })=>{
|
3
3
|
if (Object.keys(collectionConfig.joins).length === 0 || joins === false) {
|
4
4
|
return;
|
5
5
|
}
|
@@ -24,12 +24,18 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
24
24
|
for (const slug of Object.keys(joinConfig)){
|
25
25
|
for (const join of joinConfig[slug]){
|
26
26
|
const joinModel = adapter.collections[join.field.collection];
|
27
|
-
|
27
|
+
if (projection && !projection[join.joinPath]) {
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
if (joins?.[join.joinPath] === false) {
|
31
|
+
continue;
|
32
|
+
}
|
33
|
+
const { limit: limitJoin = join.field.defaultLimit ?? 10, sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort, where: whereJoin } = joins?.[join.joinPath] || {};
|
28
34
|
const sort = buildSortParam({
|
29
35
|
config: adapter.payload.config,
|
30
36
|
fields: adapter.payload.collections[slug].config.fields,
|
31
37
|
locale,
|
32
|
-
sort: sortJoin
|
38
|
+
sort: sortJoin,
|
33
39
|
timestamps: true
|
34
40
|
});
|
35
41
|
const sortProperty = Object.keys(sort)[0];
|
@@ -56,13 +62,13 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
56
62
|
}
|
57
63
|
if (adapter.payload.config.localization && locale === 'all') {
|
58
64
|
adapter.payload.config.localization.localeCodes.forEach((code)=>{
|
59
|
-
const as = `${join.
|
65
|
+
const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${code}`;
|
60
66
|
aggregate.push({
|
61
67
|
$lookup: {
|
62
68
|
as: `${as}.docs`,
|
63
69
|
foreignField: `${join.field.on}${code}`,
|
64
|
-
from: slug,
|
65
|
-
localField: '_id',
|
70
|
+
from: adapter.collections[slug].collection.name,
|
71
|
+
localField: versions ? 'parent' : '_id',
|
66
72
|
pipeline
|
67
73
|
}
|
68
74
|
}, {
|
@@ -74,14 +80,14 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
74
80
|
input: `$${as}.docs`
|
75
81
|
}
|
76
82
|
},
|
77
|
-
[`${as}.hasNextPage`]: {
|
83
|
+
[`${as}.hasNextPage`]: limitJoin ? {
|
78
84
|
$gt: [
|
79
85
|
{
|
80
86
|
$size: `$${as}.docs`
|
81
87
|
},
|
82
|
-
limitJoin
|
88
|
+
limitJoin
|
83
89
|
]
|
84
|
-
}
|
90
|
+
} : false
|
85
91
|
}
|
86
92
|
});
|
87
93
|
if (limitJoin > 0) {
|
@@ -99,13 +105,13 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
99
105
|
});
|
100
106
|
} else {
|
101
107
|
const localeSuffix = join.field.localized && adapter.payload.config.localization && locale ? `.${locale}` : '';
|
102
|
-
const as = `${join.
|
108
|
+
const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${localeSuffix}`;
|
103
109
|
aggregate.push({
|
104
110
|
$lookup: {
|
105
111
|
as: `${as}.docs`,
|
106
112
|
foreignField: `${join.field.on}${localeSuffix}`,
|
107
|
-
from: slug,
|
108
|
-
localField: '_id',
|
113
|
+
from: adapter.collections[slug].collection.name,
|
114
|
+
localField: versions ? 'parent' : '_id',
|
109
115
|
pipeline
|
110
116
|
}
|
111
117
|
}, {
|
@@ -142,6 +148,11 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
142
148
|
}
|
143
149
|
}
|
144
150
|
}
|
151
|
+
if (projection) {
|
152
|
+
aggregate.push({
|
153
|
+
$project: projection
|
154
|
+
});
|
155
|
+
}
|
145
156
|
return aggregate;
|
146
157
|
};
|
147
158
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildJoinAggregation.ts"],"sourcesContent":["import type { PipelineStage } from 'mongoose'\nimport type { CollectionSlug, JoinQuery, SanitizedCollectionConfig, Where } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { buildSortParam } from '../queries/buildSortParam.js'\n\ntype BuildJoinAggregationArgs = {\n adapter: MongooseAdapter\n collection: CollectionSlug\n collectionConfig: SanitizedCollectionConfig\n joins: JoinQuery\n // the number of docs to get at the top collection level\n limit?: number\n locale: string\n // the where clause for the top collection\n query?: Where\n}\n\nexport const buildJoinAggregation = async ({\n adapter,\n collection,\n collectionConfig,\n joins,\n limit,\n locale,\n query,\n}: BuildJoinAggregationArgs): Promise<PipelineStage[] | undefined> => {\n if (Object.keys(collectionConfig.joins).length === 0 || joins === false) {\n return\n }\n\n const joinConfig = adapter.payload.collections[collection].config.joins\n const aggregate: PipelineStage[] = [\n {\n $sort: { createdAt: -1 },\n },\n ]\n\n if (query) {\n aggregate.push({\n $match: query,\n })\n }\n\n if (limit) {\n aggregate.push({\n $limit: limit,\n })\n }\n\n for (const slug of Object.keys(joinConfig)) {\n for (const join of joinConfig[slug]) {\n const joinModel = adapter.collections[join.field.collection]\n\n const {\n limit: limitJoin = 10,\n sort: sortJoin,\n where: whereJoin,\n } = joins?.[join.
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildJoinAggregation.ts"],"sourcesContent":["import type { PipelineStage } from 'mongoose'\nimport type { CollectionSlug, JoinQuery, SanitizedCollectionConfig, Where } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { buildSortParam } from '../queries/buildSortParam.js'\n\ntype BuildJoinAggregationArgs = {\n adapter: MongooseAdapter\n collection: CollectionSlug\n collectionConfig: SanitizedCollectionConfig\n joins: JoinQuery\n // the number of docs to get at the top collection level\n limit?: number\n locale: string\n projection?: Record<string, true>\n // the where clause for the top collection\n query?: Where\n /** whether the query is from drafts */\n versions?: boolean\n}\n\nexport const buildJoinAggregation = async ({\n adapter,\n collection,\n collectionConfig,\n joins,\n limit,\n locale,\n projection,\n query,\n versions,\n}: BuildJoinAggregationArgs): Promise<PipelineStage[] | undefined> => {\n if (Object.keys(collectionConfig.joins).length === 0 || joins === false) {\n return\n }\n\n const joinConfig = adapter.payload.collections[collection].config.joins\n const aggregate: PipelineStage[] = [\n {\n $sort: { createdAt: -1 },\n },\n ]\n\n if (query) {\n aggregate.push({\n $match: query,\n })\n }\n\n if (limit) {\n aggregate.push({\n $limit: limit,\n })\n }\n\n for (const slug of Object.keys(joinConfig)) {\n for (const join of joinConfig[slug]) {\n const joinModel = adapter.collections[join.field.collection]\n\n if (projection && !projection[join.joinPath]) {\n continue\n }\n\n if (joins?.[join.joinPath] === false) {\n continue\n }\n\n const {\n limit: limitJoin = join.field.defaultLimit ?? 10,\n sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort,\n where: whereJoin,\n } = joins?.[join.joinPath] || {}\n\n const sort = buildSortParam({\n config: adapter.payload.config,\n fields: adapter.payload.collections[slug].config.fields,\n locale,\n sort: sortJoin,\n timestamps: true,\n })\n const sortProperty = Object.keys(sort)[0]\n const sortDirection = sort[sortProperty] === 'asc' ? 1 : -1\n\n const $match = await joinModel.buildQuery({\n locale,\n payload: adapter.payload,\n where: whereJoin,\n })\n\n const pipeline: Exclude<PipelineStage, PipelineStage.Merge | PipelineStage.Out>[] = [\n { $match },\n {\n $sort: { [sortProperty]: sortDirection },\n },\n ]\n\n if (limitJoin > 0) {\n pipeline.push({\n $limit: limitJoin + 1,\n })\n }\n\n if (adapter.payload.config.localization && locale === 'all') {\n adapter.payload.config.localization.localeCodes.forEach((code) => {\n const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${code}`\n\n aggregate.push(\n {\n $lookup: {\n as: `${as}.docs`,\n foreignField: `${join.field.on}${code}`,\n from: adapter.collections[slug].collection.name,\n localField: versions ? 'parent' : '_id',\n pipeline,\n },\n },\n {\n $addFields: {\n [`${as}.docs`]: {\n $map: {\n as: 'doc',\n in: '$$doc._id',\n input: `$${as}.docs`,\n },\n }, // Slicing the docs to match the limit\n [`${as}.hasNextPage`]: limitJoin\n ? { $gt: [{ $size: `$${as}.docs` }, limitJoin] }\n : false,\n // Boolean indicating if more docs than limit\n },\n },\n )\n if (limitJoin > 0) {\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, limitJoin],\n },\n },\n })\n }\n })\n } else {\n const localeSuffix =\n join.field.localized && adapter.payload.config.localization && locale ? `.${locale}` : ''\n const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${localeSuffix}`\n\n aggregate.push(\n {\n $lookup: {\n as: `${as}.docs`,\n foreignField: `${join.field.on}${localeSuffix}`,\n from: adapter.collections[slug].collection.name,\n localField: versions ? 'parent' : '_id',\n pipeline,\n },\n },\n {\n $addFields: {\n [`${as}.docs`]: {\n $map: {\n as: 'doc',\n in: '$$doc._id',\n input: `$${as}.docs`,\n },\n }, // Slicing the docs to match the limit\n [`${as}.hasNextPage`]: {\n $gt: [{ $size: `$${as}.docs` }, limitJoin || Number.MAX_VALUE],\n }, // Boolean indicating if more docs than limit\n },\n },\n )\n if (limitJoin > 0) {\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, limitJoin],\n },\n },\n })\n }\n }\n }\n }\n\n if (projection) {\n aggregate.push({ $project: projection })\n }\n\n return aggregate\n}\n"],"names":["buildSortParam","buildJoinAggregation","adapter","collection","collectionConfig","joins","limit","locale","projection","query","versions","Object","keys","length","joinConfig","payload","collections","config","aggregate","$sort","createdAt","push","$match","$limit","slug","join","joinModel","field","joinPath","limitJoin","defaultLimit","sort","sortJoin","defaultSort","where","whereJoin","fields","timestamps","sortProperty","sortDirection","buildQuery","pipeline","localization","localeCodes","forEach","code","as","$lookup","foreignField","on","from","name","localField","$addFields","$map","in","input","$gt","$size","$slice","localeSuffix","localized","Number","MAX_VALUE","$project"],"mappings":"AAKA,SAASA,cAAc,QAAQ,+BAA8B;AAiB7D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,UAAU,EACVC,gBAAgB,EAChBC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACiB;IACzB,IAAIC,OAAOC,IAAI,CAACR,iBAAiBC,KAAK,EAAEQ,MAAM,KAAK,KAAKR,UAAU,OAAO;QACvE;IACF;IAEA,MAAMS,aAAaZ,QAAQa,OAAO,CAACC,WAAW,CAACb,WAAW,CAACc,MAAM,CAACZ,KAAK;IACvE,MAAMa,YAA6B;QACjC;YACEC,OAAO;gBAAEC,WAAW,CAAC;YAAE;QACzB;KACD;IAED,IAAIX,OAAO;QACTS,UAAUG,IAAI,CAAC;YACbC,QAAQb;QACV;IACF;IAEA,IAAIH,OAAO;QACTY,UAAUG,IAAI,CAAC;YACbE,QAAQjB;QACV;IACF;IAEA,KAAK,MAAMkB,QAAQb,OAAOC,IAAI,CAACE,YAAa;QAC1C,KAAK,MAAMW,QAAQX,UAAU,CAACU,KAAK,CAAE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C,QAAQ,EAAEe,KAAKG,QAAQ,CAAC,CAAC,GAAGH,KAAKG,QAAQ,CAAC,EAAEgC,aAAa,CAAC;gBAEpF1C,UAAUG,IAAI,CACZ;oBACE0B,SAAS;wBACPD,IAAI,CAAC,EAAEA,GAAG,KAAK,CAAC;wBAChBE,cAAc,CAAC,EAAEvB,KAAKE,KAAK,CAACsB,EAAE,CAAC,EAAEW,aAAa,CAAC;wBAC/CV,MAAMhD,QAAQc,WAAW,CAACQ,KAAK,CAACrB,UAAU,CAACgD,IAAI;wBAC/CC,YAAY1C,WAAW,WAAW;wBAClC+B;oBACF;gBACF,GACA;oBACEY,YAAY;wBACV,CAAC,CAAC,EAAEP,GAAG,KAAK,CAAC,CAAC,EAAE;4BACdQ,MAAM;gCACJR,IAAI;gCACJS,IAAI;gCACJC,OAAO,CAAC,CAAC,EAAEV,GAAG,KAAK,CAAC;4BACtB;wBACF;wBACA,CAAC,CAAC,EAAEA,GAAG,YAAY,CAAC,CAAC,EAAE;4BACrBW,KAAK;gCAAC;oCAAEC,OAAO,CAAC,CAAC,EAAEZ,GAAG,KAAK,CAAC;gCAAC;gCAAGjB,aAAaiC,OAAOC,SAAS;6BAAC;wBAChE;oBACF;gBACF;gBAEF,IAAIlC,YAAY,GAAG;oBACjBX,UAAUG,IAAI,CAAC;wBACbgC,YAAY;4BACV,CAAC,CAAC,EAAEP,GAAG,KAAK,CAAC,CAAC,EAAE;gCACda,QAAQ;oCAAC,CAAC,CAAC,EAAEb,GAAG,KAAK,CAAC;oCAAEjB;iCAAU;4BACpC;wBACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,IAAIrB,YAAY;QACdU,UAAUG,IAAI,CAAC;YAAE2C,UAAUxD;QAAW;IACxC;IAEA,OAAOU;AACT,EAAC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { type Field, type SelectType } from 'payload';
|
2
|
+
import type { MongooseAdapter } from '../index.js';
|
3
|
+
export declare const buildProjectionFromSelect: ({ adapter, fields, select, }: {
|
4
|
+
adapter: MongooseAdapter;
|
5
|
+
fields: Field[];
|
6
|
+
select?: SelectType;
|
7
|
+
}) => Record<string, true> | undefined;
|
8
|
+
//# sourceMappingURL=buildProjectionFromSelect.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"buildProjectionFromSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/buildProjectionFromSelect.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAGV,KAAK,UAAU,EAEhB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA6MlD,eAAO,MAAM,yBAAyB,iCAInC;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,KAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,SAmB1B,CAAA"}
|
@@ -0,0 +1,171 @@
|
|
1
|
+
import { deepCopyObjectSimple } from 'payload';
|
2
|
+
import { fieldAffectsData, getSelectMode, tabHasName } from 'payload/shared';
|
3
|
+
const addFieldToProjection = ({ adapter, databaseSchemaPath, field, projection, withinLocalizedField })=>{
|
4
|
+
const { config } = adapter.payload;
|
5
|
+
if (withinLocalizedField && config.localization) {
|
6
|
+
for (const locale of config.localization.localeCodes){
|
7
|
+
const localeDatabaseSchemaPath = databaseSchemaPath.replace('<locale>', locale);
|
8
|
+
projection[`${localeDatabaseSchemaPath}${field.name}`] = true;
|
9
|
+
}
|
10
|
+
} else {
|
11
|
+
projection[`${databaseSchemaPath}${field.name}`] = true;
|
12
|
+
}
|
13
|
+
};
|
14
|
+
const traverseFields = ({ adapter, databaseSchemaPath = '', fields, projection, select, selectAllOnCurrentLevel = false, selectMode, withinLocalizedField = false })=>{
|
15
|
+
for (const field of fields){
|
16
|
+
if (fieldAffectsData(field)) {
|
17
|
+
if (selectMode === 'include') {
|
18
|
+
if (select[field.name] === true || selectAllOnCurrentLevel) {
|
19
|
+
addFieldToProjection({
|
20
|
+
adapter,
|
21
|
+
databaseSchemaPath,
|
22
|
+
field,
|
23
|
+
projection,
|
24
|
+
withinLocalizedField
|
25
|
+
});
|
26
|
+
continue;
|
27
|
+
}
|
28
|
+
if (!select[field.name]) {
|
29
|
+
continue;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
if (selectMode === 'exclude') {
|
33
|
+
if (typeof select[field.name] === 'undefined') {
|
34
|
+
addFieldToProjection({
|
35
|
+
adapter,
|
36
|
+
databaseSchemaPath,
|
37
|
+
field,
|
38
|
+
projection,
|
39
|
+
withinLocalizedField
|
40
|
+
});
|
41
|
+
continue;
|
42
|
+
}
|
43
|
+
if (select[field.name] === false) {
|
44
|
+
continue;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
let fieldDatabaseSchemaPath = databaseSchemaPath;
|
49
|
+
let fieldWithinLocalizedField = withinLocalizedField;
|
50
|
+
if (fieldAffectsData(field)) {
|
51
|
+
fieldDatabaseSchemaPath = `${databaseSchemaPath}${field.name}.`;
|
52
|
+
if (field.localized) {
|
53
|
+
fieldDatabaseSchemaPath = `${fieldDatabaseSchemaPath}<locale>.`;
|
54
|
+
fieldWithinLocalizedField = true;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
switch(field.type){
|
58
|
+
case 'collapsible':
|
59
|
+
case 'row':
|
60
|
+
traverseFields({
|
61
|
+
adapter,
|
62
|
+
databaseSchemaPath,
|
63
|
+
fields: field.fields,
|
64
|
+
projection,
|
65
|
+
select,
|
66
|
+
selectMode,
|
67
|
+
withinLocalizedField
|
68
|
+
});
|
69
|
+
break;
|
70
|
+
case 'tabs':
|
71
|
+
traverseFields({
|
72
|
+
adapter,
|
73
|
+
databaseSchemaPath,
|
74
|
+
fields: field.tabs.map((tab)=>({
|
75
|
+
...tab,
|
76
|
+
type: 'tab'
|
77
|
+
})),
|
78
|
+
projection,
|
79
|
+
select,
|
80
|
+
selectMode,
|
81
|
+
withinLocalizedField
|
82
|
+
});
|
83
|
+
break;
|
84
|
+
case 'group':
|
85
|
+
case 'tab':
|
86
|
+
case 'array':
|
87
|
+
{
|
88
|
+
let fieldSelect;
|
89
|
+
if (field.type === 'tab' && !tabHasName(field)) {
|
90
|
+
fieldSelect = select;
|
91
|
+
} else {
|
92
|
+
fieldSelect = select[field.name];
|
93
|
+
}
|
94
|
+
if (field.type === 'array' && selectMode === 'include') {
|
95
|
+
fieldSelect['id'] = true;
|
96
|
+
}
|
97
|
+
traverseFields({
|
98
|
+
adapter,
|
99
|
+
databaseSchemaPath: fieldDatabaseSchemaPath,
|
100
|
+
fields: field.fields,
|
101
|
+
projection,
|
102
|
+
select: fieldSelect,
|
103
|
+
selectMode,
|
104
|
+
withinLocalizedField: fieldWithinLocalizedField
|
105
|
+
});
|
106
|
+
break;
|
107
|
+
}
|
108
|
+
case 'blocks':
|
109
|
+
{
|
110
|
+
const blocksSelect = select[field.name];
|
111
|
+
for (const block of field.blocks){
|
112
|
+
if (selectMode === 'include' && blocksSelect[block.slug] === true || selectMode === 'exclude' && typeof blocksSelect[block.slug] === 'undefined') {
|
113
|
+
traverseFields({
|
114
|
+
adapter,
|
115
|
+
databaseSchemaPath: fieldDatabaseSchemaPath,
|
116
|
+
fields: block.fields,
|
117
|
+
projection,
|
118
|
+
select: {},
|
119
|
+
selectAllOnCurrentLevel: true,
|
120
|
+
selectMode: 'include',
|
121
|
+
withinLocalizedField: fieldWithinLocalizedField
|
122
|
+
});
|
123
|
+
continue;
|
124
|
+
}
|
125
|
+
let blockSelectMode = selectMode;
|
126
|
+
if (selectMode === 'exclude' && blocksSelect[block.slug] === false) {
|
127
|
+
blockSelectMode = 'include';
|
128
|
+
}
|
129
|
+
if (typeof blocksSelect[block.slug] !== 'object') {
|
130
|
+
blocksSelect[block.slug] = {};
|
131
|
+
}
|
132
|
+
if (blockSelectMode === 'include') {
|
133
|
+
blocksSelect[block.slug]['id'] = true;
|
134
|
+
blocksSelect[block.slug]['blockType'] = true;
|
135
|
+
}
|
136
|
+
traverseFields({
|
137
|
+
adapter,
|
138
|
+
databaseSchemaPath: fieldDatabaseSchemaPath,
|
139
|
+
fields: block.fields,
|
140
|
+
projection,
|
141
|
+
select: blocksSelect[block.slug],
|
142
|
+
selectMode: blockSelectMode,
|
143
|
+
withinLocalizedField: fieldWithinLocalizedField
|
144
|
+
});
|
145
|
+
}
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
default:
|
149
|
+
break;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
};
|
153
|
+
export const buildProjectionFromSelect = ({ adapter, fields, select })=>{
|
154
|
+
if (!select) {
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
const projection = {
|
158
|
+
_id: true
|
159
|
+
};
|
160
|
+
traverseFields({
|
161
|
+
adapter,
|
162
|
+
fields,
|
163
|
+
projection,
|
164
|
+
// Clone to safely mutate it later
|
165
|
+
select: deepCopyObjectSimple(select),
|
166
|
+
selectMode: getSelectMode(select)
|
167
|
+
});
|
168
|
+
return projection;
|
169
|
+
};
|
170
|
+
|
171
|
+
//# sourceMappingURL=buildProjectionFromSelect.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildProjectionFromSelect.ts"],"sourcesContent":["import {\n deepCopyObjectSimple,\n type Field,\n type FieldAffectingData,\n type SelectMode,\n type SelectType,\n type TabAsField,\n} from 'payload'\nimport { fieldAffectsData, getSelectMode, tabHasName } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nconst addFieldToProjection = ({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n}: {\n adapter: MongooseAdapter\n databaseSchemaPath: string\n field: FieldAffectingData\n projection: Record<string, true>\n withinLocalizedField: boolean\n}) => {\n const { config } = adapter.payload\n\n if (withinLocalizedField && config.localization) {\n for (const locale of config.localization.localeCodes) {\n const localeDatabaseSchemaPath = databaseSchemaPath.replace('<locale>', locale)\n projection[`${localeDatabaseSchemaPath}${field.name}`] = true\n }\n } else {\n projection[`${databaseSchemaPath}${field.name}`] = true\n }\n}\n\nconst traverseFields = ({\n adapter,\n databaseSchemaPath = '',\n fields,\n projection,\n select,\n selectAllOnCurrentLevel = false,\n selectMode,\n withinLocalizedField = false,\n}: {\n adapter: MongooseAdapter\n databaseSchemaPath?: string\n fields: (Field | TabAsField)[]\n projection: Record<string, true>\n select: SelectType\n selectAllOnCurrentLevel?: boolean\n selectMode: SelectMode\n withinLocalizedField?: boolean\n}) => {\n for (const field of fields) {\n if (fieldAffectsData(field)) {\n if (selectMode === 'include') {\n if (select[field.name] === true || selectAllOnCurrentLevel) {\n addFieldToProjection({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n })\n continue\n }\n\n if (!select[field.name]) {\n continue\n }\n }\n\n if (selectMode === 'exclude') {\n if (typeof select[field.name] === 'undefined') {\n addFieldToProjection({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n })\n continue\n }\n\n if (select[field.name] === false) {\n continue\n }\n }\n }\n\n let fieldDatabaseSchemaPath = databaseSchemaPath\n let fieldWithinLocalizedField = withinLocalizedField\n\n if (fieldAffectsData(field)) {\n fieldDatabaseSchemaPath = `${databaseSchemaPath}${field.name}.`\n\n if (field.localized) {\n fieldDatabaseSchemaPath = `${fieldDatabaseSchemaPath}<locale>.`\n fieldWithinLocalizedField = true\n }\n }\n\n switch (field.type) {\n case 'collapsible':\n case 'row':\n traverseFields({\n adapter,\n databaseSchemaPath,\n fields: field.fields,\n projection,\n select,\n selectMode,\n withinLocalizedField,\n })\n break\n\n case 'tabs':\n traverseFields({\n adapter,\n databaseSchemaPath,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n projection,\n select,\n selectMode,\n withinLocalizedField,\n })\n break\n\n case 'group':\n case 'tab':\n case 'array': {\n let fieldSelect: SelectType\n\n if (field.type === 'tab' && !tabHasName(field)) {\n fieldSelect = select\n } else {\n fieldSelect = select[field.name] as SelectType\n }\n\n if (field.type === 'array' && selectMode === 'include') {\n fieldSelect['id'] = true\n }\n\n traverseFields({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n fields: field.fields,\n projection,\n select: fieldSelect,\n selectMode,\n withinLocalizedField: fieldWithinLocalizedField,\n })\n\n break\n }\n\n case 'blocks': {\n const blocksSelect = select[field.name] as SelectType\n\n for (const block of field.blocks) {\n if (\n (selectMode === 'include' && blocksSelect[block.slug] === true) ||\n (selectMode === 'exclude' && typeof blocksSelect[block.slug] === 'undefined')\n ) {\n traverseFields({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n fields: block.fields,\n projection,\n select: {},\n selectAllOnCurrentLevel: true,\n selectMode: 'include',\n withinLocalizedField: fieldWithinLocalizedField,\n })\n continue\n }\n\n let blockSelectMode = selectMode\n\n if (selectMode === 'exclude' && blocksSelect[block.slug] === false) {\n blockSelectMode = 'include'\n }\n\n if (typeof blocksSelect[block.slug] !== 'object') {\n blocksSelect[block.slug] = {}\n }\n\n if (blockSelectMode === 'include') {\n blocksSelect[block.slug]['id'] = true\n blocksSelect[block.slug]['blockType'] = true\n }\n\n traverseFields({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n fields: block.fields,\n projection,\n select: blocksSelect[block.slug] as SelectType,\n selectMode: blockSelectMode,\n withinLocalizedField: fieldWithinLocalizedField,\n })\n }\n\n break\n }\n\n default:\n break\n }\n }\n}\n\nexport const buildProjectionFromSelect = ({\n adapter,\n fields,\n select,\n}: {\n adapter: MongooseAdapter\n fields: Field[]\n select?: SelectType\n}): Record<string, true> | undefined => {\n if (!select) {\n return\n }\n\n const projection: Record<string, true> = {\n _id: true,\n }\n\n traverseFields({\n adapter,\n fields,\n projection,\n // Clone to safely mutate it later\n select: deepCopyObjectSimple(select),\n selectMode: getSelectMode(select),\n })\n\n return projection\n}\n"],"names":["deepCopyObjectSimple","fieldAffectsData","getSelectMode","tabHasName","addFieldToProjection","adapter","databaseSchemaPath","field","projection","withinLocalizedField","config","payload","localization","locale","localeCodes","localeDatabaseSchemaPath","replace","name","traverseFields","fields","select","selectAllOnCurrentLevel","selectMode","fieldDatabaseSchemaPath","fieldWithinLocalizedField","localized","type","tabs","map","tab","fieldSelect","blocksSelect","block","blocks","slug","blockSelectMode","buildProjectionFromSelect","_id"],"mappings":"AAAA,SACEA,oBAAoB,QAMf,UAAS;AAChB,SAASC,gBAAgB,EAAEC,aAAa,EAAEC,UAAU,QAAQ,iBAAgB;AAI5E,MAAMC,uBAAuB,CAAC,EAC5BC,OAAO,EACPC,kBAAkB,EAClBC,KAAK,EACLC,UAAU,EACVC,oBAAoB,EAOrB;IACC,MAAM,EAAEC,MAAM,EAAE,GAAGL,QAAQM,OAAO;IAElC,IAAIF,wBAAwBC,OAAOE,YAAY,EAAE;QAC/C,KAAK,MAAMC,UAAUH,OAAOE,YAAY,CAACE,WAAW,CAAE;YACpD,MAAMC,2BAA2BT,mBAAmBU,OAAO,CAAC,YAAYH;YACxEL,UAAU,CAAC,CAAC,EAAEO,yBAAyB,EAAER,MAAMU,IAAI,CAAC,CAAC,CAAC,GAAG;QAC3D;IACF,OAAO;QACLT,UAAU,CAAC,CAAC,EAAEF,mBAAmB,EAAEC,MAAMU,IAAI,CAAC,CAAC,CAAC,GAAG;IACrD;AACF;AAEA,MAAMC,iBAAiB,CAAC,EACtBb,OAAO,EACPC,qBAAqB,EAAE,EACvBa,MAAM,EACNX,UAAU,EACVY,MAAM,EACNC,0BAA0B,KAAK,EAC/BC,UAAU,EACVb,uBAAuB,KAAK,EAU7B;IACC,KAAK,MAAMF,SAASY,OAAQ;QAC1B,IAAIlB,iBAAiBM,QAAQ;YAC3B,IAAIe,eAAe,WAAW;gBAC5B,IAAIF,MAAM,CAACb,MAAMU,IAAI,CAAC,KAAK,QAAQI,yBAAyB;oBAC1DjB,qBAAqB;wBACnBC;wBACAC;wBACAC;wBACAC;wBACAC;oBACF;oBACA;gBACF;gBAEA,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AAM,EACNC,MAAM,EAKP;IACC,IAAI,CAACA,QAAQ;QACX;IACF;IAEA,MAAMZ,aAAmC;QACvC6B,KAAK;IACP;IAEAnB,eAAe;QACbb;QACAc;QACAX;QACA,kCAAkC;QAClCY,QAAQpB,qBAAqBoB;QAC7BE,YAAYpB,cAAckB;IAC5B;IAEA,OAAOZ;AACT,EAAC"}
|
@@ -7,8 +7,8 @@ export const handleError = ({ collection, error, global, req })=>{
|
|
7
7
|
collection,
|
8
8
|
errors: [
|
9
9
|
{
|
10
|
-
|
11
|
-
|
10
|
+
message: req.t('error:valueMustBeUnique'),
|
11
|
+
path: Object.keys(error.keyValue)[0]
|
12
12
|
}
|
13
13
|
],
|
14
14
|
global
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/handleError.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { APIError, ValidationError } from 'payload'\n\nexport const handleError = ({\n collection,\n error,\n global,\n req,\n}: {\n collection?: string\n error\n global?: string\n req\n}) => {\n // Handle uniqueness error from MongoDB\n if (error.code === 11000 && error.keyValue) {\n throw new ValidationError(\n {\n collection,\n errors: [\n {\n
|
1
|
+
{"version":3,"sources":["../../src/utilities/handleError.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { APIError, ValidationError } from 'payload'\n\nexport const handleError = ({\n collection,\n error,\n global,\n req,\n}: {\n collection?: string\n error\n global?: string\n req\n}) => {\n // Handle uniqueness error from MongoDB\n if (error.code === 11000 && error.keyValue) {\n throw new ValidationError(\n {\n collection,\n errors: [\n {\n message: req.t('error:valueMustBeUnique'),\n path: Object.keys(error.keyValue)[0],\n },\n ],\n global,\n },\n req.t,\n )\n } else if (error.code === 11000) {\n throw new APIError(req.t('error:valueMustBeUnique'), httpStatus.BAD_REQUEST)\n } else {\n throw error\n }\n}\n"],"names":["httpStatus","APIError","ValidationError","handleError","collection","error","global","req","code","keyValue","errors","message","t","path","Object","keys","BAD_REQUEST"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,QAAQ,EAAEC,eAAe,QAAQ,UAAS;AAEnD,OAAO,MAAMC,cAAc,CAAC,EAC1BC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,GAAG,EAMJ;IACC,uCAAuC;IACvC,IAAIF,MAAMG,IAAI,KAAK,SAASH,MAAMI,QAAQ,EAAE;QAC1C,MAAM,IAAIP,gBACR;YACEE;YACAM,QAAQ;gBACN;oBACEC,SAASJ,IAAIK,CAAC,CAAC;oBACfC,MAAMC,OAAOC,IAAI,CAACV,MAAMI,QAAQ,CAAC,CAAC,EAAE;gBACtC;aACD;YACDH;QACF,GACAC,IAAIK,CAAC;IAET,OAAO,IAAIP,MAAMG,IAAI,KAAK,OAAO;QAC/B,MAAM,IAAIP,SAASM,IAAIK,CAAC,CAAC,4BAA4BZ,WAAWgB,WAAW;IAC7E,OAAO;QACL,MAAMX;IACR;AACF,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sanitizeRelationshipIDs.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizeRelationshipIDs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,KAAK,EAAE,eAAe,EAA0B,MAAM,SAAS,CAAA;AAM/F,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB,CAAA;
|
1
|
+
{"version":3,"file":"sanitizeRelationshipIDs.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizeRelationshipIDs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,KAAK,EAAE,eAAe,EAA0B,MAAM,SAAS,CAAA;AAM/F,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB,CAAA;AAuGD,eAAO,MAAM,uBAAuB,8BAIjC,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA6B/B,CAAA"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import mongoose from 'mongoose';
|
2
|
-
import { traverseFields } from 'payload';
|
2
|
+
import { APIError, traverseFields } from 'payload';
|
3
3
|
import { fieldAffectsData } from 'payload/shared';
|
4
4
|
function isValidRelationObject(value) {
|
5
5
|
return typeof value === 'object' && value !== null && 'relationTo' in value && 'value' in value;
|
@@ -7,7 +7,11 @@ function isValidRelationObject(value) {
|
|
7
7
|
const convertValue = ({ relatedCollection, value })=>{
|
8
8
|
const customIDField = relatedCollection.fields.find((field)=>fieldAffectsData(field) && field.name === 'id');
|
9
9
|
if (!customIDField) {
|
10
|
-
|
10
|
+
try {
|
11
|
+
return new mongoose.Types.ObjectId(value);
|
12
|
+
} catch (error) {
|
13
|
+
throw new APIError(`Failed to create ObjectId from value: ${value}. Error: ${error.message}`, 400);
|
14
|
+
}
|
11
15
|
}
|
12
16
|
return value;
|
13
17
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/sanitizeRelationshipIDs.ts"],"sourcesContent":["import type { CollectionConfig, Field, SanitizedConfig, TraverseFieldsCallback } from 'payload'\n\nimport mongoose from 'mongoose'\nimport { traverseFields } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\ntype Args = {\n config: SanitizedConfig\n data: Record<string, unknown>\n fields: Field[]\n}\n\ninterface RelationObject {\n relationTo: string\n value: number | string\n}\n\nfunction isValidRelationObject(value: unknown): value is RelationObject {\n return typeof value === 'object' && value !== null && 'relationTo' in value && 'value' in value\n}\n\nconst convertValue = ({\n relatedCollection,\n value,\n}: {\n relatedCollection: CollectionConfig\n value: number | string\n}): mongoose.Types.ObjectId | number | string => {\n const customIDField = relatedCollection.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!customIDField) {\n return new mongoose.Types.ObjectId(value)\n }\n\n return value\n}\n\nconst sanitizeRelationship = ({ config, field, locale, ref, value }) => {\n let relatedCollection: CollectionConfig | undefined\n let result = value\n\n const hasManyRelations = typeof field.relationTo !== 'string'\n\n if (!hasManyRelations) {\n relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n }\n\n if (Array.isArray(value)) {\n result = value.map((val) => {\n // Handle has many\n if (relatedCollection && val && (typeof val === 'string' || typeof val === 'number')) {\n return convertValue({\n relatedCollection,\n value: val,\n })\n }\n\n // Handle has many - polymorphic\n if (isValidRelationObject(val)) {\n const relatedCollectionForSingleValue = config.collections?.find(\n ({ slug }) => slug === val.relationTo,\n )\n\n if (relatedCollectionForSingleValue) {\n return {\n relationTo: val.relationTo,\n value: convertValue({\n relatedCollection: relatedCollectionForSingleValue,\n value: val.value,\n }),\n }\n }\n }\n\n return val\n })\n }\n\n // Handle has one - polymorphic\n if (isValidRelationObject(value)) {\n relatedCollection = config.collections?.find(({ slug }) => slug === value.relationTo)\n\n if (relatedCollection) {\n result = {\n relationTo: value.relationTo,\n value: convertValue({ relatedCollection, value: value.value }),\n }\n }\n }\n\n // Handle has one\n if (relatedCollection && value && (typeof value === 'string' || typeof value === 'number')) {\n result = convertValue({\n relatedCollection,\n value,\n })\n }\n if (locale) {\n ref[locale] = result\n } else {\n ref[field.name] = result\n }\n}\n\nexport const sanitizeRelationshipIDs = ({\n config,\n data,\n fields,\n}: Args): Record<string, unknown> => {\n const sanitize: TraverseFieldsCallback = ({ field, ref }) => {\n if (field.type === 'relationship' || field.type === 'upload') {\n // handle localized relationships\n if (config.localization && field.localized) {\n const locales = config.localization.locales\n const fieldRef = ref[field.name]\n for (const { code } of locales) {\n if (ref[field.name]?.[code]) {\n const value = ref[field.name][code]\n sanitizeRelationship({ config, field, locale: code, ref: fieldRef, value })\n }\n }\n } else {\n // handle non-localized relationships\n sanitizeRelationship({\n config,\n field,\n locale: undefined,\n ref,\n value: ref[field.name],\n })\n }\n }\n }\n\n traverseFields({ callback: sanitize, fields, ref: data })\n\n return data\n}\n"],"names":["mongoose","traverseFields","fieldAffectsData","isValidRelationObject","value","convertValue","relatedCollection","customIDField","fields","find","field","name","Types","ObjectId","sanitizeRelationship","config","locale","ref","result","hasManyRelations","relationTo","collections","slug","Array","isArray","map","val","relatedCollectionForSingleValue","sanitizeRelationshipIDs","data","sanitize","type","localization","localized","locales","fieldRef","code","undefined","callback"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AAC/B,SAASC,cAAc,QAAQ,UAAS;
|
1
|
+
{"version":3,"sources":["../../src/utilities/sanitizeRelationshipIDs.ts"],"sourcesContent":["import type { CollectionConfig, Field, SanitizedConfig, TraverseFieldsCallback } from 'payload'\n\nimport mongoose from 'mongoose'\nimport { APIError, traverseFields } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\ntype Args = {\n config: SanitizedConfig\n data: Record<string, unknown>\n fields: Field[]\n}\n\ninterface RelationObject {\n relationTo: string\n value: number | string\n}\n\nfunction isValidRelationObject(value: unknown): value is RelationObject {\n return typeof value === 'object' && value !== null && 'relationTo' in value && 'value' in value\n}\n\nconst convertValue = ({\n relatedCollection,\n value,\n}: {\n relatedCollection: CollectionConfig\n value: number | string\n}): mongoose.Types.ObjectId | number | string => {\n const customIDField = relatedCollection.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!customIDField) {\n try {\n return new mongoose.Types.ObjectId(value)\n } catch (error) {\n throw new APIError(\n `Failed to create ObjectId from value: ${value}. Error: ${error.message}`,\n 400,\n )\n }\n }\n\n return value\n}\n\nconst sanitizeRelationship = ({ config, field, locale, ref, value }) => {\n let relatedCollection: CollectionConfig | undefined\n let result = value\n\n const hasManyRelations = typeof field.relationTo !== 'string'\n\n if (!hasManyRelations) {\n relatedCollection = config.collections?.find(({ slug }) => slug === field.relationTo)\n }\n\n if (Array.isArray(value)) {\n result = value.map((val) => {\n // Handle has many\n if (relatedCollection && val && (typeof val === 'string' || typeof val === 'number')) {\n return convertValue({\n relatedCollection,\n value: val,\n })\n }\n\n // Handle has many - polymorphic\n if (isValidRelationObject(val)) {\n const relatedCollectionForSingleValue = config.collections?.find(\n ({ slug }) => slug === val.relationTo,\n )\n\n if (relatedCollectionForSingleValue) {\n return {\n relationTo: val.relationTo,\n value: convertValue({\n relatedCollection: relatedCollectionForSingleValue,\n value: val.value,\n }),\n }\n }\n }\n\n return val\n })\n }\n\n // Handle has one - polymorphic\n if (isValidRelationObject(value)) {\n relatedCollection = config.collections?.find(({ slug }) => slug === value.relationTo)\n\n if (relatedCollection) {\n result = {\n relationTo: value.relationTo,\n value: convertValue({ relatedCollection, value: value.value }),\n }\n }\n }\n\n // Handle has one\n if (relatedCollection && value && (typeof value === 'string' || typeof value === 'number')) {\n result = convertValue({\n relatedCollection,\n value,\n })\n }\n if (locale) {\n ref[locale] = result\n } else {\n ref[field.name] = result\n }\n}\n\nexport const sanitizeRelationshipIDs = ({\n config,\n data,\n fields,\n}: Args): Record<string, unknown> => {\n const sanitize: TraverseFieldsCallback = ({ field, ref }) => {\n if (field.type === 'relationship' || field.type === 'upload') {\n // handle localized relationships\n if (config.localization && field.localized) {\n const locales = config.localization.locales\n const fieldRef = ref[field.name]\n for (const { code } of locales) {\n if (ref[field.name]?.[code]) {\n const value = ref[field.name][code]\n sanitizeRelationship({ config, field, locale: code, ref: fieldRef, value })\n }\n }\n } else {\n // handle non-localized relationships\n sanitizeRelationship({\n config,\n field,\n locale: undefined,\n ref,\n value: ref[field.name],\n })\n }\n }\n }\n\n traverseFields({ callback: sanitize, fields, ref: data })\n\n return data\n}\n"],"names":["mongoose","APIError","traverseFields","fieldAffectsData","isValidRelationObject","value","convertValue","relatedCollection","customIDField","fields","find","field","name","Types","ObjectId","error","message","sanitizeRelationship","config","locale","ref","result","hasManyRelations","relationTo","collections","slug","Array","isArray","map","val","relatedCollectionForSingleValue","sanitizeRelationshipIDs","data","sanitize","type","localization","localized","locales","fieldRef","code","undefined","call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KAAK,MAAM,EAAE2B,IAAI,EAAE,IAAIF,QAAS;oBAC9B,IAAIjB,GAAG,CAACT,MAAMC,IAAI,CAAC,EAAE,CAAC2B,KAAK,EAAE;wBAC3B,MAAMlC,QAAQe,GAAG,CAACT,MAAMC,IAAI,CAAC,CAAC2B,KAAK;wBACnCtB,qBAAqB;4BAAEC;4BAAQP;4BAAOQ,QAAQoB;4BAAMnB,KAAKkB;4BAAUjC;wBAAM;oBAC3E;gBACF;YACF,OAAO;gBACL,qCAAqC;gBACrCY,qBAAqB;oBACnBC;oBACAP;oBACAQ,QAAQqB;oBACRpB;oBACAf,OAAOe,GAAG,CAACT,MAAMC,IAAI,CAAC;gBACxB;YACF;QACF;IACF;IAEAV,eAAe;QAAEuC,UAAUR;QAAUxB;QAAQW,KAAKY;IAAK;IAEvD,OAAOA;AACT,EAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
3
|
-
"version": "3.0.0-canary.
|
3
|
+
"version": "3.0.0-canary.c96fa61",
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
5
5
|
"homepage": "https://payloadcms.com",
|
6
6
|
"repository": {
|
@@ -38,11 +38,11 @@
|
|
38
38
|
"@types/mongoose-aggregate-paginate-v2": "1.0.6",
|
39
39
|
"mongodb": "4.17.1",
|
40
40
|
"mongodb-memory-server": "^9",
|
41
|
-
"@payloadcms/eslint-config": "3.0.0-beta.
|
42
|
-
"payload": "3.0.0-canary.
|
41
|
+
"@payloadcms/eslint-config": "3.0.0-beta.112",
|
42
|
+
"payload": "3.0.0-canary.c96fa61"
|
43
43
|
},
|
44
44
|
"peerDependencies": {
|
45
|
-
"payload": "3.0.0-canary.
|
45
|
+
"payload": "3.0.0-canary.c96fa61"
|
46
46
|
},
|
47
47
|
"scripts": {
|
48
48
|
"build": "pnpm build:types && pnpm build:swc",
|