@furkanogutcu/nest-common 0.0.1 → 0.0.3
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,9 +1,6 @@
|
|
1
1
|
import { TypeORMError } from 'typeorm';
|
2
2
|
import { AppException } from '../app.exception';
|
3
3
|
export declare class TypeORMExceptionTransformer {
|
4
|
-
private static joinColumnKeyValues;
|
5
|
-
static setJoinColumnKeyValues(values: string[]): void;
|
6
|
-
static getJoinColumnKeyValues(): string[];
|
7
4
|
static transform(exception: TypeORMError): AppException | undefined;
|
8
5
|
private static postgresQueryFailedExceptionMapper;
|
9
6
|
private static transformEntityNotFoundError;
|
@@ -6,12 +6,6 @@ const conflict_exception_1 = require("../conflict.exception");
|
|
6
6
|
const not_found_exception_1 = require("../not-found.exception");
|
7
7
|
const unprocessable_entity_exception_1 = require("../unprocessable-entity.exception");
|
8
8
|
class TypeORMExceptionTransformer {
|
9
|
-
static setJoinColumnKeyValues(values) {
|
10
|
-
this.joinColumnKeyValues = values;
|
11
|
-
}
|
12
|
-
static getJoinColumnKeyValues() {
|
13
|
-
return this.joinColumnKeyValues;
|
14
|
-
}
|
15
9
|
static transform(exception) {
|
16
10
|
if (exception instanceof typeorm_1.EntityNotFoundError) {
|
17
11
|
return this.transformEntityNotFoundError(exception);
|
@@ -32,12 +26,9 @@ class TypeORMExceptionTransformer {
|
|
32
26
|
if (!detail)
|
33
27
|
return;
|
34
28
|
const matches = detail.match(/\(([^)]+)\)/);
|
35
|
-
let conflictedFields = [];
|
36
29
|
if (matches && matches[1]) {
|
37
|
-
|
38
|
-
conflictedFields = keys.filter((key) => !TypeORMExceptionTransformer.joinColumnKeyValues.includes(key));
|
30
|
+
return new conflict_exception_1.AppConflictException({ conflictedFields: matches[1].split(', ').map((key) => key.trim()) });
|
39
31
|
}
|
40
|
-
return new conflict_exception_1.AppConflictException({ conflictedFields });
|
41
32
|
}
|
42
33
|
static transformNumericOverflowError(_exception) {
|
43
34
|
return new unprocessable_entity_exception_1.AppUnprocessableEntityException({
|
@@ -46,7 +37,6 @@ class TypeORMExceptionTransformer {
|
|
46
37
|
}
|
47
38
|
}
|
48
39
|
exports.TypeORMExceptionTransformer = TypeORMExceptionTransformer;
|
49
|
-
TypeORMExceptionTransformer.joinColumnKeyValues = [];
|
50
40
|
TypeORMExceptionTransformer.postgresQueryFailedExceptionMapper = {
|
51
41
|
22003: TypeORMExceptionTransformer.transformNumericOverflowError,
|
52
42
|
23505: TypeORMExceptionTransformer.transformConflictError,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"typeorm.exception-transformer.js","sourceRoot":"","sources":["../../../src/exceptions/transformers/typeorm.exception-transformer.ts"],"names":[],"mappings":";;;AAAA,qCAA8E;AAG9E,8DAA6D;AAC7D,gEAA8D;AAC9D,sFAAoF;AAEpF,MAAa,2BAA2B;
|
1
|
+
{"version":3,"file":"typeorm.exception-transformer.js","sourceRoot":"","sources":["../../../src/exceptions/transformers/typeorm.exception-transformer.ts"],"names":[],"mappings":";;;AAAA,qCAA8E;AAG9E,8DAA6D;AAC7D,gEAA8D;AAC9D,sFAAoF;AAEpF,MAAa,2BAA2B;IACtC,MAAM,CAAC,SAAS,CAAC,SAAuB;QACtC,IAAI,SAAS,YAAY,6BAAmB,EAAE,CAAC;YAC7C,OAAO,IAAI,CAAC,4BAA4B,CAAC,SAAS,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,SAAS,YAAY,0BAAgB,EAAE,CAAC;YAC1C,MAAM,aAAa,GAAI,SAAiB,CAAC,IAAI,CAAC;YAE9C,MAAM,WAAW,GAAG,2BAA2B,CAAC,kCAAkC,CAAC,CAAC,aAAa,CAAC,CAAC;YAEnG,IAAI,WAAW;gBAAE,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAWO,MAAM,CAAC,4BAA4B,CAAC,SAA8B;QACxE,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAEnD,OAAO,IAAI,0CAAoB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IAEO,MAAM,CAAC,sBAAsB,CAAC,SAA2B;QAC/D,MAAM,MAAM,GAAwB,SAAiB,EAAE,MAAM,CAAC;QAE9D,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAE5C,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,yCAAoB,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QACjH,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,6BAA6B,CAAC,UAA4B;QACvE,OAAO,IAAI,gEAA+B,CAAC;YACzC,OAAO,EAAE,4CAA4C;SACtD,CAAC,CAAC;IACL,CAAC;;AA9CH,kEA+CC;AAhCgB,8DAAkC,GAG7C;IAEF,KAAK,EAAE,2BAA2B,CAAC,6BAA6B;IAChE,KAAK,EAAE,2BAA2B,CAAC,sBAAsB;CAC1D,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@furkanogutcu/nest-common",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.3",
|
4
4
|
"description": "Package of common structures for NestJS.",
|
5
5
|
"author": "Furkan Ogutcu",
|
6
6
|
"license": "MIT",
|
@@ -49,18 +49,19 @@
|
|
49
49
|
"@nestjs/core": "^11.1.0",
|
50
50
|
"@nestjs/typeorm": "^11.0.0",
|
51
51
|
"@nestjs/testing": "11.1.0",
|
52
|
-
"@nestjs/platform-express": "^11.1.0"
|
53
|
-
},
|
54
|
-
"dependencies": {
|
52
|
+
"@nestjs/platform-express": "^11.1.0",
|
55
53
|
"zod": "^3.24.3",
|
56
54
|
"typeorm": "^0.3.22"
|
57
55
|
},
|
56
|
+
"dependencies": {},
|
58
57
|
"devDependencies": {
|
59
58
|
"@nestjs/common": "^11.1.0",
|
60
59
|
"@nestjs/core": "^11.1.0",
|
61
60
|
"@nestjs/typeorm": "^11.0.0",
|
62
61
|
"@nestjs/testing": "11.1.0",
|
63
62
|
"@nestjs/platform-express": "^11.1.0",
|
63
|
+
"zod": "^3.24.3",
|
64
|
+
"typeorm": "^0.3.22",
|
64
65
|
"@types/express": "5.0.1",
|
65
66
|
"@types/jest": "29.5.14",
|
66
67
|
"@types/node": "22.15.3",
|