@payloadcms/db-mongodb 3.9.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js +5 -3
- 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/create.d.ts.map +1 -1
- package/dist/create.js +5 -3
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +5 -3
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +5 -3
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +5 -3
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +3 -4
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +11 -11
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +6 -7
- package/dist/deleteVersions.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +8 -6
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +4 -4
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +6 -5
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +8 -5
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +5 -4
- package/dist/findVersions.js.map +1 -1
- package/dist/migrateFresh.js.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +2 -2
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -1
- package/dist/predefinedMigrations/migrateVersionsV1_V2.js +4 -4
- package/dist/predefinedMigrations/migrateVersionsV1_V2.js.map +1 -1
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +1 -0
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts +2 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +17 -6
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +5 -3
- package/dist/queryDrafts.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +4 -4
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +4 -4
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +4 -4
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +4 -4
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsert.d.ts.map +1 -1
- package/dist/upsert.js +1 -1
- package/dist/upsert.js.map +1 -1
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +6 -2
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/dist/utilities/getSession.d.ts +9 -0
- package/dist/utilities/getSession.d.ts.map +1 -0
- package/dist/{withSession.js → utilities/getSession.js} +7 -6
- package/dist/utilities/getSession.js.map +1 -0
- package/dist/utilities/handleError.d.ts +3 -2
- package/dist/utilities/handleError.d.ts.map +1 -1
- package/dist/utilities/handleError.js +8 -7
- package/dist/utilities/handleError.js.map +1 -1
- package/package.json +4 -4
- package/dist/withSession.d.ts +0 -11
- package/dist/withSession.d.ts.map +0 -1
- package/dist/withSession.js.map +0 -1
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { APIError, ValidationError } from 'payload';
|
|
3
3
|
export const handleError = ({ collection, error, global, req })=>{
|
|
4
|
+
if (!error || typeof error !== 'object') {
|
|
5
|
+
throw error;
|
|
6
|
+
}
|
|
7
|
+
const message = req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique';
|
|
4
8
|
// Handle uniqueness error from MongoDB
|
|
5
|
-
if (error.code === 11000 && error.keyValue) {
|
|
9
|
+
if ('code' in error && error.code === 11000 && 'keyValue' in error && error.keyValue) {
|
|
6
10
|
throw new ValidationError({
|
|
7
11
|
collection,
|
|
8
12
|
errors: [
|
|
9
13
|
{
|
|
10
|
-
message
|
|
14
|
+
message,
|
|
11
15
|
path: Object.keys(error.keyValue)[0]
|
|
12
16
|
}
|
|
13
17
|
],
|
|
14
18
|
global
|
|
15
|
-
}, req
|
|
16
|
-
} else if (error.code === 11000) {
|
|
17
|
-
throw new APIError(req.t('error:valueMustBeUnique'), httpStatus.BAD_REQUEST);
|
|
18
|
-
} else {
|
|
19
|
-
throw error;
|
|
19
|
+
}, req?.t);
|
|
20
20
|
}
|
|
21
|
+
throw new APIError(message, httpStatus.BAD_REQUEST);
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
//# sourceMappingURL=handleError.js.map
|
|
@@ -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
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/handleError.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport 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: unknown\n global?: string\n req?: Partial<PayloadRequest>\n}) => {\n if (!error || typeof error !== 'object') {\n throw error\n }\n\n const message = req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique'\n\n // Handle uniqueness error from MongoDB\n if ('code' in error && error.code === 11000 && 'keyValue' in error && error.keyValue) {\n throw new ValidationError(\n {\n collection,\n errors: [\n {\n message,\n path: Object.keys(error.keyValue)[0],\n },\n ],\n global,\n },\n req?.t,\n )\n }\n\n throw new APIError(message, httpStatus.BAD_REQUEST)\n}\n"],"names":["httpStatus","APIError","ValidationError","handleError","collection","error","global","req","message","t","code","keyValue","errors","path","Object","keys","BAD_REQUEST"],"mappings":"AAEA,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,IAAI,CAACF,SAAS,OAAOA,UAAU,UAAU;QACvC,MAAMA;IACR;IAEA,MAAMG,UAAUD,KAAKE,IAAIF,IAAIE,CAAC,CAAC,6BAA6B;IAE5D,uCAAuC;IACvC,IAAI,UAAUJ,SAASA,MAAMK,IAAI,KAAK,SAAS,cAAcL,SAASA,MAAMM,QAAQ,EAAE;QACpF,MAAM,IAAIT,gBACR;YACEE;YACAQ,QAAQ;gBACN;oBACEJ;oBACAK,MAAMC,OAAOC,IAAI,CAACV,MAAMM,QAAQ,CAAC,CAAC,EAAE;gBACtC;aACD;YACDL;QACF,GACAC,KAAKE;IAET;IAEA,MAAM,IAAIR,SAASO,SAASR,WAAWgB,WAAW;AACpD,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"@types/mongoose-aggregate-paginate-v2": "1.0.12",
|
|
49
49
|
"mongodb": "6.10.0",
|
|
50
50
|
"mongodb-memory-server": "^9",
|
|
51
|
-
"@payloadcms/eslint-config": "3.
|
|
52
|
-
"payload": "3.
|
|
51
|
+
"@payloadcms/eslint-config": "3.9.0",
|
|
52
|
+
"payload": "3.11.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"payload": "3.
|
|
55
|
+
"payload": "3.11.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "pnpm build:types && pnpm build:swc",
|
package/dist/withSession.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ClientSession } from 'mongoose';
|
|
2
|
-
import type { PayloadRequest } from 'payload';
|
|
3
|
-
import type { MongooseAdapter } from './index.js';
|
|
4
|
-
/**
|
|
5
|
-
* returns the session belonging to the transaction of the req.session if exists
|
|
6
|
-
* @returns ClientSession
|
|
7
|
-
*/
|
|
8
|
-
export declare function withSession(db: MongooseAdapter, req: PayloadRequest): Promise<{
|
|
9
|
-
session: ClientSession;
|
|
10
|
-
} | Record<string, never>>;
|
|
11
|
-
//# sourceMappingURL=withSession.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withSession.d.ts","sourceRoot":"","sources":["../src/withSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAU7D"}
|
package/dist/withSession.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/withSession.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\n/**\n * returns the session belonging to the transaction of the req.session if exists\n * @returns ClientSession\n */\nexport async function withSession(\n db: MongooseAdapter,\n req: PayloadRequest,\n): Promise<{ session: ClientSession } | Record<string, never>> {\n let transactionID = req.transactionID\n\n if (transactionID instanceof Promise) {\n transactionID = await req.transactionID\n }\n\n if (req) {\n return db.sessions[transactionID] ? { session: db.sessions[transactionID] } : {}\n }\n}\n"],"names":["withSession","db","req","transactionID","Promise","sessions","session"],"mappings":"AAKA;;;CAGC,GACD,OAAO,eAAeA,YACpBC,EAAmB,EACnBC,GAAmB;IAEnB,IAAIC,gBAAgBD,IAAIC,aAAa;IAErC,IAAIA,yBAAyBC,SAAS;QACpCD,gBAAgB,MAAMD,IAAIC,aAAa;IACzC;IAEA,IAAID,KAAK;QACP,OAAOD,GAAGI,QAAQ,CAACF,cAAc,GAAG;YAAEG,SAASL,GAAGI,QAAQ,CAACF,cAAc;QAAC,IAAI,CAAC;IACjF;AACF"}
|