@payloadcms/db-mongodb 3.17.2-canary.e4ecf14 → 3.18.0-canary.21c1fc5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleError.d.ts","sourceRoot":"","sources":["../../src/utilities/handleError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"handleError.d.ts","sourceRoot":"","sources":["../../src/utilities/handleError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,eAAO,MAAM,WAAW,wCAKrB;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CAC9B,UAwBA,CAAA"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { APIError, ValidationError } from 'payload';
|
|
1
|
+
import { ValidationError } from 'payload';
|
|
3
2
|
export const handleError = ({ collection, error, global, req })=>{
|
|
4
3
|
if (!error || typeof error !== 'object') {
|
|
5
4
|
throw error;
|
|
6
5
|
}
|
|
7
|
-
const message = req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique';
|
|
8
6
|
// Handle uniqueness error from MongoDB
|
|
9
7
|
if ('code' in error && error.code === 11000 && 'keyValue' in error && error.keyValue) {
|
|
8
|
+
const message = req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique';
|
|
10
9
|
throw new ValidationError({
|
|
11
10
|
collection,
|
|
12
11
|
errors: [
|
|
@@ -18,7 +17,7 @@ export const handleError = ({ collection, error, global, req })=>{
|
|
|
18
17
|
global
|
|
19
18
|
}, req?.t);
|
|
20
19
|
}
|
|
21
|
-
throw
|
|
20
|
+
throw error;
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
//# sourceMappingURL=handleError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/handleError.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/handleError.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { ValidationError } from 'payload'\n\nexport const handleError = ({\n collection,\n error,\n global,\n req,\n}: {\n collection?: string\n error: Error\n global?: string\n req?: Partial<PayloadRequest>\n}) => {\n if (!error || typeof error !== 'object') {\n throw error\n }\n\n // Handle uniqueness error from MongoDB\n if ('code' in error && error.code === 11000 && 'keyValue' in error && error.keyValue) {\n const message = req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique'\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 error\n}\n"],"names":["ValidationError","handleError","collection","error","global","req","code","keyValue","message","t","errors","path","Object","keys"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC,OAAO,MAAMC,cAAc,CAAC,EAC1BC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,GAAG,EAMJ;IACC,IAAI,CAACF,SAAS,OAAOA,UAAU,UAAU;QACvC,MAAMA;IACR;IAEA,uCAAuC;IACvC,IAAI,UAAUA,SAASA,MAAMG,IAAI,KAAK,SAAS,cAAcH,SAASA,MAAMI,QAAQ,EAAE;QACpF,MAAMC,UAAUH,KAAKI,IAAIJ,IAAII,CAAC,CAAC,6BAA6B;QAC5D,MAAM,IAAIT,gBACR;YACEE;YACAQ,QAAQ;gBACN;oBACEF;oBACAG,MAAMC,OAAOC,IAAI,CAACV,MAAMI,QAAQ,CAAC,CAAC,EAAE;gBACtC;aACD;YACDH;QACF,GACAC,KAAKI;IAET;IAEA,MAAMN;AACR,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.0-canary.21c1fc5",
|
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/mongoose-aggregate-paginate-v2": "1.0.12",
|
|
49
49
|
"mongodb": "6.10.0",
|
|
50
|
-
"mongodb-memory-server": "^
|
|
50
|
+
"mongodb-memory-server": "^10",
|
|
51
51
|
"@payloadcms/eslint-config": "3.9.0",
|
|
52
|
-
"payload": "3.
|
|
52
|
+
"payload": "3.18.0-canary.21c1fc5"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"payload": "3.
|
|
55
|
+
"payload": "3.18.0-canary.21c1fc5"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "pnpm build:types && pnpm build:swc",
|