@open3cl/engine 1.4.1 → 1.4.2

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.
@@ -53,7 +53,7 @@ export default class DpeSanitizerService {
53
53
  }
54
54
 
55
55
  if (this.#isEnum(key)) {
56
- return val;
56
+ return val?.toString();
57
57
  }
58
58
 
59
59
  if (this.#isUndefinedVal(val)) {
package/engine.js CHANGED
@@ -19,6 +19,8 @@ import {
19
19
  collectionCanBeEmpty,
20
20
  containsAnySubstring,
21
21
  isEffetJoule,
22
+ use_enum_as_string,
23
+ useEnumAsString,
22
24
  xmlParser
23
25
  } from './utils.js';
24
26
  import { Inertie } from './7_inertie.js';
@@ -26,7 +28,7 @@ import getFicheTechnique from './ficheTechnique.js';
26
28
  import { ProductionENR } from './16.2_production_enr.js';
27
29
  import DpeSanitizerService from './dpe-sanitizer.service.js';
28
30
 
29
- const LIB_VERSION = '1.4.1';
31
+ const LIB_VERSION = '1.4.2';
30
32
 
31
33
  const dpeSanitizerService = new DpeSanitizerService();
32
34
 
@@ -66,7 +68,15 @@ export function calcul_3cl_xml(dpeXmlContent, options) {
66
68
  */
67
69
  export function calcul_3cl(inputDpe, options) {
68
70
  if (!options) options = { sanitize: true };
69
- const dpe = options.sanitize ? dpeSanitizerService.execute(inputDpe) : inputDpe;
71
+ let dpe;
72
+ if (options.sanitize) {
73
+ dpe = dpeSanitizerService.execute(inputDpe);
74
+ } else {
75
+ dpe = inputDpe;
76
+ if (use_enum_as_string) {
77
+ useEnumAsString(inputDpe);
78
+ }
79
+ }
70
80
  const modele = enums.modele_dpe[dpe.administratif.enum_modele_dpe_id];
71
81
  const dateDpe = dpe.administratif.date_etablissement_dpe;
72
82
  if (modele !== 'dpe 3cl 2021 méthode logement') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open3cl/engine",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Open Source 3CL-DPE engine",
5
5
  "main": "index.js",
6
6
  "directories": {
package/utils.js CHANGED
@@ -39,6 +39,18 @@ export function set_bug_for_bug_compat() {
39
39
  bug_for_bug_compat = true;
40
40
  }
41
41
 
42
+ export function useEnumAsString(jsonObj) {
43
+ for (const key in jsonObj) {
44
+ if (jsonObj.hasOwnProperty(key)) {
45
+ if (key.startsWith('enum_')) {
46
+ if (jsonObj[key] !== null) jsonObj[key] = jsonObj[key].toString();
47
+ } else if (typeof jsonObj[key] === 'object') {
48
+ useEnumAsString(jsonObj[key]);
49
+ }
50
+ }
51
+ }
52
+ }
53
+
42
54
  export let use_enum_as_string = false;
43
55
  export function set_use_enum_as_string() {
44
56
  use_enum_as_string = true;