podverse-orm 5.1.14-alpha.0 → 5.1.15-alpha.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.
@@ -1 +1 @@
1
- {"version":3,"file":"hasDifferentValues.d.ts","sourceRoot":"","sources":["../../src/lib/hasDifferentValues.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAsBzE"}
1
+ {"version":3,"file":"hasDifferentValues.d.ts","sourceRoot":"","sources":["../../src/lib/hasDifferentValues.ts"],"names":[],"mappings":"AAkDA,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAsDzE"}
@@ -1,8 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasDifferentValues = hasDifferentValues;
4
- function hasDifferentValues(entity, dto) {
5
- return Object.keys(dto).some(key => {
4
+ const loggerService_1 = require("@orm/factories/loggerService");
5
+ function isDebugMode() {
6
+ var _a, _b, _c;
7
+ try {
8
+ // prefer explicit config on loggerService if available
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ const anyLogger = loggerService_1.loggerService;
11
+ const cfgLevel = (_c = (_b = (_a = anyLogger === null || anyLogger === void 0 ? void 0 : anyLogger.config) === null || _a === void 0 ? void 0 : _a.log) === null || _b === void 0 ? void 0 : _b.level) !== null && _c !== void 0 ? _c : anyLogger === null || anyLogger === void 0 ? void 0 : anyLogger.level;
12
+ if (typeof cfgLevel === "string")
13
+ return cfgLevel === "debug";
14
+ }
15
+ catch (_d) {
16
+ // ignore and fallthrough to env checks
17
+ }
18
+ return process.env.LOG_LEVEL === "debug";
19
+ }
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ function isNumeric(value) {
22
+ return value !== null && value !== '' && !isNaN(value);
23
+ }
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ function isObjectWithId(value) {
26
+ return value && typeof value === 'object' && 'id' in value;
27
+ }
28
+ function hasDifferentValuesNoLogs(entity, dto) {
29
+ const keys = Object.keys(dto);
30
+ return keys.some(key => {
6
31
  const entityValue = entity[key];
7
32
  const dtoValue = dto[key];
8
33
  const normalizedEntityValue = isNumeric(entityValue) ? Number(entityValue) : entityValue;
@@ -19,11 +44,50 @@ function hasDifferentValues(entity, dto) {
19
44
  return normalizedEntityValue !== normalizedDtoValue;
20
45
  });
21
46
  }
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- function isNumeric(value) {
24
- return !isNaN(value) && value !== null && value !== '';
25
- }
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- function isObjectWithId(value) {
28
- return value && typeof value === 'object' && 'id' in value;
47
+ function hasDifferentValues(entity, dto) {
48
+ if (!isDebugMode()) {
49
+ return hasDifferentValuesNoLogs(entity, dto);
50
+ }
51
+ // debug-mode with thorough logging
52
+ const keys = Object.keys(dto);
53
+ loggerService_1.loggerService.debug(`hasDifferentValues start: keys=${JSON.stringify(keys)}`);
54
+ const safeStringify = (v) => {
55
+ try {
56
+ return JSON.stringify(v);
57
+ }
58
+ catch (_a) {
59
+ try {
60
+ return String(v);
61
+ }
62
+ catch (_b) {
63
+ return '[unserializable]';
64
+ }
65
+ }
66
+ };
67
+ return keys.some(key => {
68
+ const entityValue = entity[key];
69
+ const dtoValue = dto[key];
70
+ loggerService_1.loggerService.debug(`Checking key="${key}" — entityValue=${safeStringify(entityValue)}, dtoValue=${safeStringify(dtoValue)}`);
71
+ const normalizedEntityValue = isNumeric(entityValue) ? Number(entityValue) : entityValue;
72
+ const normalizedDtoValue = isNumeric(dtoValue) ? Number(dtoValue) : dtoValue;
73
+ loggerService_1.loggerService.debug(`Normalized key="${key}" — normalizedEntityValue=${safeStringify(normalizedEntityValue)}, normalizedDtoValue=${safeStringify(normalizedDtoValue)}`);
74
+ if (isObjectWithId(normalizedEntityValue) && isNumeric(normalizedDtoValue)) {
75
+ const diff = normalizedEntityValue.id !== normalizedDtoValue;
76
+ loggerService_1.loggerService.debug(`Branch: entity is objectWithId, dto is numeric — entity.id=${normalizedEntityValue.id}, dto=${normalizedDtoValue}, different=${diff}`);
77
+ return diff;
78
+ }
79
+ if (isObjectWithId(dtoValue) && isNumeric(normalizedEntityValue)) {
80
+ const diff = dtoValue.id !== normalizedEntityValue;
81
+ loggerService_1.loggerService.debug(`Branch: dto is objectWithId, entity is numeric — dto.id=${dtoValue.id}, entity=${normalizedEntityValue}, different=${diff}`);
82
+ return diff;
83
+ }
84
+ if (isObjectWithId(normalizedEntityValue) && isObjectWithId(normalizedDtoValue)) {
85
+ const diff = normalizedEntityValue.id !== normalizedDtoValue.id;
86
+ loggerService_1.loggerService.debug(`Branch: both objectWithId — entity.id=${normalizedEntityValue.id}, dto.id=${normalizedDtoValue.id}, different=${diff}`);
87
+ return diff;
88
+ }
89
+ const diff = normalizedEntityValue !== normalizedDtoValue;
90
+ loggerService_1.loggerService.debug(`Branch: primitive/other compare — entity=${safeStringify(normalizedEntityValue)}, dto=${safeStringify(normalizedDtoValue)}, different=${diff}`);
91
+ return diff;
92
+ });
29
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"baseOneService.d.ts","sourceRoot":"","sources":["../../../src/services/base/baseOneService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAoB,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMrG,qBAAa,cAAc,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC,SAAS,MAAM,CAAC;IACpE,OAAO,CAAC,eAAe,CAAI;IAC3B,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,SAAS,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC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C,CAAC,GAAG,IAAI,CAAC;IAKvE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAwB7E,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAMxD"}
@@ -31,6 +31,11 @@ class BaseOneService {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
32
  var _a;
33
33
  let entity = yield this._get(parentEntity, config);
34
+ loggerService_1.loggerService.debug(`parentEntityKey: ${this.parentEntityKey}`);
35
+ loggerService_1.loggerService.debug(`dto: ${dto ? JSON.stringify(dto) : 'null'}`);
36
+ loggerService_1.loggerService.debug(`config: ${config ? JSON.stringify(config) : 'null'}`);
37
+ loggerService_1.loggerService.debug(`Entity exists: ${!!entity}`);
38
+ loggerService_1.loggerService.debug(`Entity has different values: ${entity ? (0, hasDifferentValues_1.hasDifferentValues)(entity, dto) : 'N/A'}`);
34
39
  if (!entity) {
35
40
  entity = new this.repositoryReadWrite.target();
36
41
  entity[this.parentEntityKey] = parentEntity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podverse-orm",
3
- "version": "5.1.14-alpha.0",
3
+ "version": "5.1.15-alpha.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "module-alias": "^2.2.3",
25
25
  "nanoid": "^5.1.6",
26
26
  "pg": "^8.16.3",
27
- "podverse-helpers": "^5.1.14-alpha.0",
27
+ "podverse-helpers": "^5.1.15-alpha.0",
28
28
  "typeorm": "^0.3.26",
29
29
  "typeorm-naming-strategies": "^4.1.0"
30
30
  },