Olivier Massot 2 роки тому
батько
коміт
0a27d3e5ae

+ 1 - 2
.gitignore

@@ -19,7 +19,6 @@ dist
 local.app.opentalent.fr.crt
 local.app.opentalent.fr.key
 /.project
-
 yarn.lock
-
 coverage/
+/.env.*.local

+ 3 - 3
services/data/normalizer/hydraNormalizer.ts

@@ -3,7 +3,7 @@ import UrlUtils from '~/services/utils/urlUtils'
 import {METADATA_TYPE} from '~/types/enum/data'
 import models from "~/models/models";
 import ApiResource from "~/models/ApiResource";
-import {isArray} from "lodash";
+import * as _ from 'lodash-es'
 
 /**
  * Normalisation et dé-normalisation du format de données Hydra
@@ -22,7 +22,7 @@ class HydraNormalizer {
       const value = entity[field]
       const targetEntity = iriEncodedFields[field].entity
 
-      if (isArray(value)) {
+      if (_.isArray(value)) {
         entity[field] = value.map((id: number) => {
           return UrlUtils.makeIRI(targetEntity, id)
         })
@@ -153,7 +153,7 @@ class HydraNormalizer {
       const value = instance[field]
       const targetEntity = iriEncodedFields[field].entity
 
-      if (isArray(value)) {
+      if (_.isArray(value)) {
         instance[field] = value.map((iri: string) => {
           return HydraNormalizer.getIdFromEntityIri(iri, targetEntity)
         })

+ 2 - 2
services/utils/urlUtils.ts

@@ -1,4 +1,4 @@
-import _, {isNumber} from "lodash";
+import _ from "lodash";
 
 /**
  * Classe permettant de construire une URL pour l'interrogation d'une API externe
@@ -133,7 +133,7 @@ class UrlUtils {
    * @see https://api-platform.com/docs/admin/handling-relations/
    */
   public static makeIRI(entity: string, id: number) {
-    if (!isNumber(id)) {
+    if (!_.isNumber(id)) {
       throw Error('Invalid id : ' + id)
     }
     return `/api/${entity}/${id}`