浏览代码

refactor and comments services

Olivier Massot 4 年之前
父节点
当前提交
bdc0e39570
共有 44 个文件被更改,包括 490 次插入512 次删除
  1. 2 2
      notes_relecture.md
  2. 31 24
      services/connection/connection.ts
  3. 21 13
      services/connection/constructUrl.ts
  4. 34 34
      services/dataDeleter/dataDeleter.ts
  5. 1 1
      services/dataDeleter/hook/_import.ts
  6. 0 11
      services/dataDeleter/hook/baseHook.ts
  7. 0 19
      services/dataDeleter/hook/hookExample.ts
  8. 62 43
      services/dataPersister/dataPersister.ts
  9. 1 1
      services/dataPersister/hook/_import.ts
  10. 0 11
      services/dataPersister/hook/baseHook.ts
  11. 0 19
      services/dataPersister/hook/hookExample.ts
  12. 43 31
      services/dataProvider/dataProvider.ts
  13. 20 13
      services/dataProvider/provider/baseProvider.ts
  14. 9 5
      services/dataProvider/provider/defaultProvider.ts
  15. 18 7
      services/dataProvider/provider/enumProvider.ts
  16. 1 1
      services/dataProvider/provider/hook/_import.ts
  17. 0 14
      services/dataProvider/provider/hook/baseHook.ts
  18. 0 19
      services/dataProvider/provider/hook/hookExample.ts
  19. 13 8
      services/dataProvider/provider/modelProvider.ts
  20. 16 0
      services/hooks/baseHook.ts
  21. 14 0
      services/hooks/hookExample.ts
  22. 17 12
      services/profile/accessProfile.ts
  23. 14 14
      services/profile/organizationProfile.ts
  24. 17 20
      services/rights/abilitiesUtils.ts
  25. 12 12
      services/rights/roleUtils.ts
  26. 2 2
      services/serializer/denormalizer/baseDenormalizer.ts
  27. 11 11
      services/serializer/denormalizer/hydra.ts
  28. 2 2
      services/serializer/denormalizer/yaml.ts
  29. 2 2
      services/serializer/normalizer/baseNormalizer.ts
  30. 9 5
      services/serializer/normalizer/model.ts
  31. 8 8
      services/serializer/serializer.ts
  32. 6 8
      services/store/query.ts
  33. 3 3
      services/store/repository.ts
  34. 3 3
      services/utils/apiError.ts
  35. 17 8
      services/utils/datesUtils.ts
  36. 40 32
      services/utils/objectProperties.ts
  37. 17 23
      tests/unit/services/connection/connection.spec.ts
  38. 8 14
      tests/unit/services/connection/constructUrl.spec.ts
  39. 0 14
      tests/unit/services/datadeleter/hook/baseHook.spec.ts
  40. 0 14
      tests/unit/services/datapersister/hook/baseHook.spec.ts
  41. 0 14
      tests/unit/services/dataprovider/hook/baseHook.spec.ts
  42. 1 1
      types/enums.ts
  43. 13 13
      types/interfaces.d.ts
  44. 2 1
      types/types.d.ts

+ 2 - 2
notes_relecture.md

@@ -7,11 +7,11 @@
 
 * config de l'host et du port: la doc mentionne que ce n'est pas conseillé 
   de les définir ici, en tout cas pour la prod <https://nuxtjs.org/docs/2.x/features/configuration#edit-host-and-port>
-* 
+* Vincent, avais tu vu ce plugin? https://vuex-orm.github.io/plugin-axios/guide/setup.html
 
 # Divers
 
 * Revoir les commentaires // QTN
 * manquerait pas un await dans middleware/auth.js?
 * un intérêt à utiliser les extensions .client.js et .server.js pour les plugins? (https://fr.nuxtjs.org/docs/2.x/directory-structure/plugins#convention-pour-le-nommage-des-plugins)
-* 
+* DatesUtils.sortDates: est-ce qu'un sort standard ne suffirait pas?

+ 31 - 24
services/connection/connection.ts

@@ -6,10 +6,11 @@ import { HTTP_METHOD } from '~/types/enums'
 /**
  * @category Services/connection
  * @class Connection
- * Classe Wrapper du connecteur de requete (Axios dans notre cas)
+ *
+ * Classe Wrapper du connecteur de requête (Axios dans notre cas)
  */
 class Connection {
-  static connector:NuxtAxiosInstance;
+  static connector: NuxtAxiosInstance;
 
   /**
    * Initialisation du connecteur (Axios dans notre cas)
@@ -20,29 +21,35 @@ class Connection {
   }
 
   /**
-   * Main méthode qui apperlera les méthode privées correspondantes (getItem, getCollection, put, post, delete)
-   * @param {HTTP_METHOD} method de requetage
+   * Main méthode qui appellera les méthodes privées correspondantes (getItem, getCollection, put, post, delete)
+   * @param {HTTP_METHOD} method Mode de requêtage (GET, PUT, DELETE...)
    * @param {string} url
    * @param {DataProviderArgs|DataPersisterArgs} args
    * @return {Promise<any>}
    */
-  invoke (method: HTTP_METHOD, url: string, args:DataProviderArgs|DataPersisterArgs): Promise<any> {
+  public static invoke (method: HTTP_METHOD, url: string, args: DataProviderArgs | DataPersisterArgs): Promise<any> {
     switch (method) {
       case HTTP_METHOD.GET:
-        if (args.id) { return this.getItem(url, args.id, args.progress) } else { return this.getCollection(url, args.progress) }
+        if (args.id) {
+          return Connection.getItem(url, args.id, args.progress)
+        } else {
+          return Connection.getCollection(url, args.progress)
+        }
 
       case HTTP_METHOD.PUT:
-        if (this.isArgsIsDataPersisterArgs(args)) {
-          if (!args.data) { throw new Error('data not found') }
-
-          return this.put(url, args.id, args.data, args.progress)
-        } else { throw new Error('args not a dataPersisterArgs') }
+        if (!Connection.isDataPersisterArgs(args)) {
+          throw new Error('*args* is not a dataPersisterArgs')
+        }
+        if (!args.data) {
+          throw new Error('*args* has no data')
+        }
+        return Connection.put(url, args.id, args.data, args.progress)
 
       case HTTP_METHOD.DELETE:
-        return this.deleteItem(url, args.id, args.progress)
+        return Connection.deleteItem(url, args.id, args.progress)
     }
 
-    throw new Error('Method unknown')
+    throw new Error('Unknown connection method was invoked')
   }
 
   /**
@@ -52,13 +59,13 @@ class Connection {
    * @param {boolean} progress
    * @return {Promise<any>}
    */
-  private getItem (url: string, id: number, progress: boolean = true): Promise<any> {
+  public static getItem (url: string, id: number, progress: boolean = true): Promise<any> {
     const config:AxiosRequestConfig = {
       url: `${url}/${id}`,
       method: HTTP_METHOD.GET,
       progress
     }
-    return this.request(config)
+    return Connection.request(config)
   }
 
   /**
@@ -67,13 +74,13 @@ class Connection {
    * @param {boolean} progress
    * @return {Promise<any>}
    */
-  private getCollection (url: string, progress: boolean = true): Promise<any> {
+  public static getCollection (url: string, progress: boolean = true): Promise<any> {
     const config:AxiosRequestConfig = {
       url: `${url}`,
       method: HTTP_METHOD.GET,
       progress
     }
-    return this.request(config)
+    return Connection.request(config)
   }
 
   /**
@@ -84,14 +91,14 @@ class Connection {
    * @param {boolean} progress
    * @return {Promise<any>}
    */
-  private put (url: string, id: number, data: AnyJson, progress: boolean = true): Promise<any> {
+  public static put (url: string, id: number, data: AnyJson, progress: boolean = true): Promise<any> {
     const config:AxiosRequestConfig = {
       url: `${url}/${id}`,
       method: HTTP_METHOD.PUT,
       data,
       progress
     }
-    return this.request(config)
+    return Connection.request(config)
   }
 
   /**
@@ -101,21 +108,21 @@ class Connection {
    * @param {boolean} progress
    * @return {Promise<any>}
    */
-  private deleteItem (url: string, id: number, progress: boolean = true): Promise<any> {
+  public static deleteItem (url: string, id: number, progress: boolean = true): Promise<any> {
     const config:AxiosRequestConfig = {
       url: `${url}/${id}`,
       method: HTTP_METHOD.DELETE,
       progress
     }
-    return this.request(config)
+    return Connection.request(config)
   }
 
   /**
-   * Exécution de la requete
+   * Exécute la requete
    * @param {AxiosRequestConfig} config
    * @return {Promise<any>}
    */
-  private async request (config:AxiosRequestConfig): Promise<any> {
+  private static async request (config: AxiosRequestConfig): Promise<any> {
     return await Connection.connector.$request(config)
   }
 
@@ -123,7 +130,7 @@ class Connection {
    * Test si l'argument est bien de type DataPersister
    * @param args
    */
-  private isArgsIsDataPersisterArgs (args:DataProviderArgs|DataPersisterArgs): args is DataPersisterArgs {
+  private static isDataPersisterArgs (args:DataProviderArgs|DataPersisterArgs): args is DataPersisterArgs {
     return (args as DataPersisterArgs).data !== undefined
   }
 }

+ 21 - 13
services/connection/constructUrl.ts

@@ -12,20 +12,20 @@ class ConstructUrl {
   static ROOT = '/api/'
 
   /**
-   * Main méthode qui apperlera les méthode privées correspondantes (getDefaultUrl, getEnumUrl, getModelUrl)
+   * Main méthode qui appellera les méthode privées correspondantes (getDefaultUrl, getEnumUrl, getModelUrl)
    * @param {UrlArgs} args
    * @return {string}
    */
-  invoke (args:UrlArgs): string {
+  public static invoke (args:UrlArgs): string {
     switch (args.type) {
       case QUERY_TYPE.DEFAULT:
-        return this.getDefaultUrl(args.url)
+        return ConstructUrl.getDefaultUrl(args.url)
 
       case QUERY_TYPE.ENUM:
-        return this.getEnumUrl(args.enumType)
+        return ConstructUrl.getEnumUrl(args.enumType)
 
       case QUERY_TYPE.MODEL:
-        return this.getModelUrl(args.model, args.root_model, args.root_id)
+        return ConstructUrl.getModelUrl(args.model, args.rootModel, args.rootId)
 
       default:
         throw new Error('url, model or enum must be defined')
@@ -37,8 +37,10 @@ class ConstructUrl {
    * @param {string} url
    * @return {string}
    */
-  private getDefaultUrl (url?: string): string {
-    if (typeof url === 'undefined') { throw new TypeError('url must be defined') }
+  private static getDefaultUrl (url?: string): string {
+    if (typeof url === 'undefined') {
+      throw new TypeError('url must be defined')
+    }
     return String(ConstructUrl.ROOT + url).toString()
   }
 
@@ -47,8 +49,10 @@ class ConstructUrl {
    * @param {string} enumType
    * @return {string}
    */
-  private getEnumUrl (enumType?: string): string {
-    if (typeof enumType === 'undefined') { throw new TypeError('enumType must be defined') }
+  private static getEnumUrl (enumType?: string): string {
+    if (typeof enumType === 'undefined') {
+      throw new TypeError('enumType must be defined')
+    }
     return String(ConstructUrl.ROOT + 'enum/' + enumType).toString()
   }
 
@@ -61,15 +65,19 @@ class ConstructUrl {
    * @param {number} rootId roles à tester
    * @return {string}
    */
-  private getModelUrl (model?: typeof Model, rootModel?: typeof Model, rootId?: number): string {
-    if (typeof model === 'undefined') { throw new TypeError('model must be defined') }
+  private static getModelUrl (model?: typeof Model, rootModel?: typeof Model, rootId?: number): string {
+    if (typeof model === 'undefined') {
+      throw new TypeError('model must be defined')
+    }
 
     const entity = repositoryHelper.getEntity(model)
 
     if (typeof rootModel !== 'undefined') {
-      if (typeof rootId === 'undefined') { throw new TypeError('Root ID must be defined') }
+      if (typeof rootId === 'undefined') {
+        throw new TypeError('Root ID must be defined')
+      }
 
-      const rootUrl = this.getModelUrl(rootModel) as string
+      const rootUrl = ConstructUrl.getModelUrl(rootModel) as string
       return String(`${rootUrl}/${rootId}/${entity}`).toString()
     }
 

+ 34 - 34
services/dataDeleter/dataDeleter.ts

@@ -3,63 +3,63 @@ import { hooks } from '~/services/dataDeleter/hook/_import'
 import { DataDeleterArgs } from '~/types/interfaces'
 import Connection from '~/services/connection/connection'
 import ApiError from '~/services/utils/apiError'
-import { HTTP_METHOD } from '~/types/enums'
-import ConstructUrl from '~/services/connection/constructUrl'
 import { repositoryHelper } from '~/services/store/repository'
 
+/**
+ * Le DataProvider a pour rôle de supprimer des enregistrements via l'API Opentalent
+ */
 class DataDeleter {
   private ctx !: Context
   private arguments!: DataDeleterArgs
 
-  constructor () {
-    this.sort()
-  }
-
-  initCtx (ctx:Context) {
+  /**
+   * Initialise le contexte (la connection en particulier)
+   * @param ctx
+   */
+  public initCtx (ctx:Context) {
     Connection.initConnector(ctx.$axios)
     this.ctx = ctx
   }
 
-  async invoke (args:DataDeleterArgs): Promise<any> {
+  /**
+   * Exécute la requête
+   * @param args
+   */
+  public async invoke (args:DataDeleterArgs): Promise<any> {
     this.arguments = args
     try {
-      this.preHook()
-
-      const url = this.constructUrl()
-      const response = await this.connection(url)
+      await this.preHook()
 
-      if (this.arguments.model) { repositoryHelper.deleteItem(this.arguments.model, this.arguments.id) }
+      // const url = ConstructUrl.invoke(this.arguments)
+      // const response = await Connection.invoke(HTTP_METHOD.DELETE, url, this.arguments)
+      if (this.arguments.model) {
+        repositoryHelper.deleteItem(this.arguments.model, this.arguments.id)
+      }
     } catch (error) {
       throw new ApiError(error.response.status, error.response.data.detail)
     }
   }
 
+  /**
+   * Iterate over the available hooks and return
+   * the first one that support the given args
+   */
   async preHook () {
-    for (const hook of hooks) {
-      if (hook.support(this.arguments)) {
-        await new hook().invoke(this.arguments)
+    for (const Hook of DataDeleter.sortedHooks()) {
+      if (Hook.support(this.arguments)) {
+        await new Hook().invoke(this.arguments)
       }
     }
   }
 
-  constructUrl (): string {
-    const constructUrl = new ConstructUrl()
-    return constructUrl.invoke(this.arguments)
-  }
-
-  connection (url: string): Promise<any> {
-    const connection = new Connection()
-    return connection.invoke(HTTP_METHOD.DELETE, url, this.arguments)
-  }
-
-  sort () {
-    hooks.sort(function (a, b) {
-      if (a.priority > b.priority) {
-        return 1
-      }
-      if (a.priority < b.priority) {
-        return -1
-      }
+  /**
+   * Sort the available hooks by priority
+   * @private
+   */
+  private static sortedHooks (): Iterable<any> {
+    return hooks.sort(function (a, b) {
+      if (a.priority > b.priority) { return 1 }
+      if (a.priority < b.priority) { return -1 }
       return 0
     })
   }

+ 1 - 1
services/dataDeleter/hook/_import.ts

@@ -1,4 +1,4 @@
-import HookExample from '~/services/dataPersister/hook/hookExample';
+import HookExample from '~/services/hooks/hookExample';
 
 export const hooks = [
   HookExample

+ 0 - 11
services/dataDeleter/hook/baseHook.ts

@@ -1,11 +0,0 @@
-import { DataDeleterArgs } from '~/types/interfaces'
-
-class BaseHook {
-  static priority = 255
-
-  static support (args:DataDeleterArgs): boolean {
-    throw new Error('Need to be implement into static method')
-  }
-}
-
-export default BaseHook

+ 0 - 19
services/dataDeleter/hook/hookExample.ts

@@ -1,19 +0,0 @@
-import { DataDeleterArgs, HookDeleter } from '~/types/interfaces'
-import BaseHook from '~/services/dataDeleter/hook/baseHook'
-
-class HookExample extends BaseHook implements HookDeleter {
-  static priority = 10
-
-  constructor () {
-    super()
-  }
-
-  async invoke (args: DataDeleterArgs): Promise<any> {
-  }
-
-  static support (args:DataDeleterArgs): boolean {
-    return false
-  }
-}
-
-export default HookExample

+ 62 - 43
services/dataPersister/dataPersister.ts

@@ -3,52 +3,63 @@ import { hooks } from '~/services/dataPersister/hook/_import'
 import { AnyJson, DataPersisterArgs, DataProviderArgs } from '~/types/interfaces'
 import Connection from '~/services/connection/connection'
 import ConstructUrl from '~/services/connection/constructUrl'
-import { HTTP_METHOD, QUERY_TYPE } from '~/types/enums'
+import { DENORMALIZER_TYPE, HTTP_METHOD, QUERY_TYPE } from '~/types/enums'
 import Serializer from '~/services/serializer/serializer'
 import ApiError from '~/services/utils/apiError'
 import DataProvider from '~/services/dataProvider/dataProvider'
 
+/**
+ * Le DataProvider a pour rôle de mettre à jour les données via de l'API Opentalent
+ */
 class DataPersister {
   private ctx !: Context
-  private defaultArguments: DataPersisterArgs
+  private readonly defaultArguments: DataPersisterArgs
 
   constructor () {
-    this.sort()
     this.defaultArguments = {
       type: QUERY_TYPE.MODEL,
       progress: true
     }
   }
 
-  initCtx (ctx:Context) {
+  /**
+   * Initialise le contexte (la connection en particulier)
+   * @param ctx
+   */
+  public initCtx (ctx:Context) {
     Connection.initConnector(ctx.$axios)
     this.ctx = ctx
   }
 
-  getArguments (args: DataPersisterArgs):DataPersisterArgs {
-    return { ...this.defaultArguments, ...args }
-  }
-
-  async invoke (args:DataPersisterArgs): Promise<any> {
+  /**
+   * Exécute la requête et retourne la réponse désérialisée
+   * @param args
+   */
+  public async invoke (args:DataPersisterArgs): Promise<any> {
     try {
-      const dpArgs = this.getArguments(args)
+      // complete args with defaults
+      args = { ...this.defaultArguments, ...args }
 
-      this.startLoading(dpArgs)
+      this.startLoading(args)
 
-      this.preHook(dpArgs)
+      await this.preHook(args)
 
-      dpArgs.data = this.serialization(dpArgs)
+      args.data = Serializer.normalize(args)
 
-      const url = this.constructUrl(dpArgs)
+      const url = ConstructUrl.invoke(args)
 
-      const response = await this.connection(url, dpArgs)
+      const response = await this.sendRequest(url, args)
 
-      this.provideResponse(response, dpArgs)
+      await this.provideResponse(response, args)
     } catch (error) {
       throw new ApiError(error.response.status, error.response.data.detail)
     }
   }
 
+  /**
+   * Signale le début du chargement à nuxt (si progress est true)
+   * @param args
+   */
   startLoading (args: DataPersisterArgs) {
     if (args.progress) {
       const $nuxt = window.$nuxt
@@ -56,52 +67,60 @@ class DataPersister {
     }
   }
 
+  /**
+   * Iterate over the available hooks and return
+   * the first one that support the given args
+   * @param args
+   */
   async preHook (args: DataPersisterArgs) {
-    for (const hook of hooks) {
-      if (hook.support(args)) {
-        await new hook().invoke(args)
+    for (const Hook of DataPersister.sortedHooks()) {
+      if (Hook.support(args)) {
+        await new Hook().invoke(args)
       }
     }
   }
 
-  serialization (args: DataPersisterArgs) {
-    const serializer = new Serializer()
-    return serializer.normalize(args)
+  /**
+   * Send the request trough the Connection
+   * @param url
+   * @param args
+   */
+  sendRequest (url: string, args: DataPersisterArgs): Promise<any> {
+    return Connection.invoke(args.id ? HTTP_METHOD.PUT : HTTP_METHOD.POST, url, args)
   }
 
-  constructUrl (args: DataPersisterArgs): string {
-    const constructUrl = new ConstructUrl()
-    return constructUrl.invoke(args)
-  }
+  /**
+   * ?
+   * @param response
+   * @param args
+   */
+  private async provideResponse (response: AnyJson, args: DataPersisterArgs) {
 
-  connection (url: string, args: DataPersisterArgs): Promise<any> {
-    const connection = new Connection()
-    return connection.invoke(args.id ? HTTP_METHOD.PUT : HTTP_METHOD.POST, url, args)
-  }
+    const deserializedResponse = Serializer.denormalize(response, DENORMALIZER_TYPE.HYDRA)
 
-  async provideResponse (response: AnyJson, args: DataPersisterArgs) {
     const dataProvider = new DataProvider()
+    dataProvider.initCtx(this.ctx)
     const dataProviderArgs: DataProviderArgs = {
       type: args.type,
       url: args.url,
       enumType: args.enumType,
       model: args.model,
-      root_model: args.root_model,
+      root_model: args.rootModel,
       id: args.id,
-      root_id: args.root_id
+      root_id: args.rootId
     }
-    const deserializeResponse = dataProvider.deserialization(response)
-    return await dataProvider.provide(deserializeResponse, dataProviderArgs)
+
+    return await dataProvider.provide(deserializedResponse, dataProviderArgs)
   }
 
-  sort () {
-    hooks.sort(function (a, b) {
-      if (a.priority > b.priority) {
-        return 1
-      }
-      if (a.priority < b.priority) {
-        return -1
-      }
+  /**
+   * Sort the available hooks by priority
+   * @private
+   */
+  private static sortedHooks (): Iterable<any> {
+    return hooks.sort(function (a, b) {
+      if (a.priority > b.priority) { return 1 }
+      if (a.priority < b.priority) { return -1 }
       return 0
     })
   }

+ 1 - 1
services/dataPersister/hook/_import.ts

@@ -1,4 +1,4 @@
-import HookExample from '~/services/dataPersister/hook/hookExample'
+import HookExample from '~/services/hooks/hookExample'
 
 export const hooks = [
   HookExample

+ 0 - 11
services/dataPersister/hook/baseHook.ts

@@ -1,11 +0,0 @@
-import { DataPersisterArgs } from '~/types/interfaces'
-
-class BaseHook {
-  static priority = 255
-
-  static support (args:DataPersisterArgs): boolean {
-    throw new Error('Need to be implement into static method')
-  }
-}
-
-export default BaseHook

+ 0 - 19
services/dataPersister/hook/hookExample.ts

@@ -1,19 +0,0 @@
-import { DataPersisterArgs, HookPersister } from '~/types/interfaces'
-import BaseHook from '~/services/dataPersister/hook/baseHook'
-
-class HookExample extends BaseHook implements HookPersister {
-  static priority = 10
-
-  constructor () {
-    super()
-  }
-
-  async invoke (args: DataPersisterArgs): Promise<any> {
-  }
-
-  static support (args:DataPersisterArgs): boolean {
-    return false
-  }
-}
-
-export default HookExample

+ 43 - 31
services/dataProvider/dataProvider.ts

@@ -7,9 +7,12 @@ import Connection from '~/services/connection/connection'
 import Serializer from '~/services/serializer/serializer'
 import ApiError from '~/services/utils/apiError'
 
+/**
+ * Le DataProvider a pour rôle de fournir des données issues de l'API Opentalent
+ */
 class DataProvider {
   private ctx !: Context;
-  private defaultArguments!: DataProviderArgs;
+  private readonly defaultArguments!: DataProviderArgs;
 
   constructor () {
     this.defaultArguments = {
@@ -18,62 +21,71 @@ class DataProvider {
     }
   }
 
-  initCtx (ctx:Context) {
+  /**
+   * Initialise le contexte (la connection en particulier)
+   * @param ctx
+   */
+  public initCtx (ctx: Context) {
     Connection.initConnector(ctx.$axios)
     this.ctx = ctx
   }
 
-  getArguments (args: DataProviderArgs): DataProviderArgs {
-    return { ...this.defaultArguments, ...args }
-  }
-
-  async invoke (args:DataProviderArgs): Promise<any> {
+  /**
+   * Exécute la requête et retourne la réponse désérialisée
+   * @param args
+   */
+  public async invoke (args: DataProviderArgs): Promise<any> {
     try {
-      const dpArgs = this.getArguments(args)
+      // complete args with defaults
+      args = { ...this.defaultArguments, ...args }
 
-      this.startLoading(dpArgs)
+      DataProvider.startLoading(args)
 
-      const url = this.constructUrl(dpArgs)
+      const url = ConstructUrl.invoke(args)
 
-      const response = await this.connection(url, dpArgs)
+      const response = await DataProvider.sendRequest(url, args)
 
-      const deserializeResponse = await this.deserialization(response)
+      const deserializeResponse = await Serializer.denormalize(response, DENORMALIZER_TYPE.HYDRA)
 
-      return await this.provide(deserializeResponse, dpArgs)
+      return await this.provide(deserializeResponse, args)
     } catch (error) {
       throw new ApiError(500, error)
     }
   }
 
-  startLoading (args: DataProviderArgs) {
+  /**
+   * Signale le début du chargement à nuxt (si progress est true)
+   * @param args
+   */
+  private static startLoading (args: DataProviderArgs) {
     if (args.progress) {
       const $nuxt = window.$nuxt
       $nuxt.$loading.start()
     }
   }
 
-  constructUrl (args: DataProviderArgs): string {
-    const constructUrl = new ConstructUrl()
-    return constructUrl.invoke(args)
-  }
-
-  connection (url: string, args: DataProviderArgs): Promise<any> {
-    const connection = new Connection()
-    return connection.invoke(HTTP_METHOD.GET, url, args)
+  /**
+   * Send the request trough the Connection
+   * @param url
+   * @param args
+   */
+  public static sendRequest (url: string, args: DataProviderArgs): Promise<any> {
+    return Connection.invoke(HTTP_METHOD.GET, url, args)
   }
 
-  provide (data: AnyJson, args: DataProviderArgs): any {
-    for (const provider of providers) {
-      if (provider.support(args)) {
-        return new provider(this.ctx, args).invoke(data)
+  /**
+   * Iterate over the available providers and invoke
+   * the first one that support the given args
+   * @param data
+   * @param args
+   */
+  public provide (data: AnyJson, args: DataProviderArgs): any {
+    for (const Provider of providers) {
+      if (Provider.support(args)) {
+        return new Provider(this.ctx, args).invoke(data)
       }
     }
   }
-
-  deserialization (data: AnyJson): AnyJson {
-    const serializer = new Serializer()
-    return serializer.denormalize(data, DENORMALIZER_TYPE.HYDRA)
-  }
 }
 
 export default DataProvider

+ 20 - 13
services/dataProvider/provider/baseProvider.ts

@@ -9,29 +9,36 @@ class BaseProvider {
   constructor (ctx: Context, args: DataProviderArgs) {
     this.arguments = args
     this.ctx = ctx
-    this.sortHook()
   }
 
-  static support (args:DataProviderArgs): boolean {
+  /**
+   * Is the given argument a supported model
+   * @param _args
+   */
+  static support (_args: DataProviderArgs): boolean {
     throw new Error('Need to be implement into static method')
   }
 
+  /**
+   * Iterate over the available hooks and return
+   * the first one that support the given args
+   */
   async postHook () {
-    for (const hook of hooks) {
-      if (hook.support(this.arguments)) {
-        await new hook().invoke(this.arguments)
+    for (const Hook of BaseProvider.sortedHooks()) {
+      if (Hook.support(this.arguments)) {
+        await new Hook().invoke(this.arguments)
       }
     }
   }
 
-  sortHook () {
-    hooks.sort(function (a, b) {
-      if (a.priority > b.priority) {
-        return 1
-      }
-      if (a.priority < b.priority) {
-        return -1
-      }
+  /**
+   * Sort the available hooks by priority
+   * @private
+   */
+  public static sortedHooks (): Iterable<any> {
+    return hooks.sort(function (a, b) {
+      if (a.priority > b.priority) { return 1 }
+      if (a.priority < b.priority) { return -1 }
       return 0
     })
   }

+ 9 - 5
services/dataProvider/provider/defaultProvider.ts

@@ -1,17 +1,21 @@
-import { Context } from '@nuxt/types/app'
 import { AnyJson, DataProviderArgs, Provider } from '~/types/interfaces'
 import BaseProvider from '~/services/dataProvider/provider/baseProvider'
 import { QUERY_TYPE } from '~/types/enums'
 
 class DefaultProvider extends BaseProvider implements Provider {
-  constructor (ctx: Context, args: DataProviderArgs) {
-    super(ctx, args)
-  }
-
+  /**
+   * Exécute la requête et retourne la réponse désérialisée
+   * @param data
+   */
+  // eslint-disable-next-line require-await
   async invoke (data: AnyJson): Promise<any> {
     return data
   }
 
+  /**
+   * Is the given argument a supported model
+   * @param args
+   */
   static support (args:DataProviderArgs): boolean {
     return args.type === QUERY_TYPE.DEFAULT
   }

+ 18 - 7
services/dataProvider/provider/enumProvider.ts

@@ -1,16 +1,18 @@
 import * as _ from 'lodash'
-import { Context } from '@nuxt/types/app'
 import { AnyJson, DataProviderArgs, EnumChoice, EnumChoices, Provider } from '~/types/interfaces'
 import BaseProvider from '~/services/dataProvider/provider/baseProvider'
 import { QUERY_TYPE } from '~/types/enums'
 
 class EnumProvider extends BaseProvider implements Provider {
-  constructor (ctx: Context, args: DataProviderArgs) {
-    super(ctx, args)
-  }
 
+  /**
+   * Exécute la requête et retourne la réponse désérialisée
+   * @param data
+   */
+  // eslint-disable-next-line require-await
   async invoke (data: AnyJson): Promise<any> {
-    const enums:EnumChoices = []
+    const enums: EnumChoices = []
+
     _.each(data.items, (item, key) => {
       const entry:EnumChoice = {
         value: key,
@@ -18,10 +20,15 @@ class EnumProvider extends BaseProvider implements Provider {
       }
       enums.push(entry)
     })
-    return this.sortEnum(enums)
+    return EnumProvider.sortEnum(enums)
   }
 
-  private sortEnum (enums:EnumChoices) {
+  /**
+   * Sort the given enum by its elements labels
+   * @param enums
+   * @private
+   */
+  private static sortEnum (enums: EnumChoices) {
     return enums.sort((a, b) => {
       if (a.label > b.label) { return 1 }
       if (a.label < b.label) { return -1 }
@@ -29,6 +36,10 @@ class EnumProvider extends BaseProvider implements Provider {
     })
   }
 
+  /**
+   * Is the given argument a supported model
+   * @param args
+   */
   static support (args:DataProviderArgs): boolean {
     return args.type === QUERY_TYPE.ENUM
   }

+ 1 - 1
services/dataProvider/provider/hook/_import.ts

@@ -1,4 +1,4 @@
-import HookExample from '~/services/dataProvider/provider/hook/hookExample';
+import HookExample from '~/services/hooks/hookExample'
 
 export const hooks = [
   HookExample

+ 0 - 14
services/dataProvider/provider/hook/baseHook.ts

@@ -1,14 +0,0 @@
-import { DataProviderArgs } from '~/types/interfaces'
-
-class BaseHook {
-  static priority = 255
-
-  constructor () {
-  }
-
-  static support (args:DataProviderArgs): boolean {
-    throw new Error('Need to be implement into static method')
-  }
-}
-
-export default BaseHook

+ 0 - 19
services/dataProvider/provider/hook/hookExample.ts

@@ -1,19 +0,0 @@
-import { DataProviderArgs, HookProvider } from '~/types/interfaces'
-import BaseHook from '~/services/dataProvider/provider/hook/baseHook'
-
-class HookExample extends BaseHook implements HookProvider {
-  static priority = 10
-
-  constructor () {
-    super()
-  }
-
-  async invoke (args: DataProviderArgs): Promise<any> {
-  }
-
-  static support (args:DataProviderArgs): boolean {
-    return false
-  }
-}
-
-export default HookExample

+ 13 - 8
services/dataProvider/provider/modelProvider.ts

@@ -1,4 +1,3 @@
-import { Context } from '@nuxt/types/app'
 import * as _ from 'lodash'
 import { AnyJson, DataProviderArgs, Provider } from '~/types/interfaces'
 import BaseProvider from '~/services/dataProvider/provider/baseProvider'
@@ -6,20 +5,26 @@ import { QUERY_TYPE } from '~/types/enums'
 import { repositoryHelper } from '~/services/store/repository'
 
 class ModelProvider extends BaseProvider implements Provider {
-  constructor (ctx: Context, args: DataProviderArgs) {
-    super(ctx, args)
-  }
-
+  /**
+   * Exécute la requête et retourne la réponse désérialisée
+   * @param data
+   */
   async invoke (data: AnyJson): Promise<any> {
-    if (typeof this.arguments.model === 'undefined') { throw new TypeError('model must be defined') }
+    if (typeof this.arguments.model === 'undefined') {
+      throw new TypeError('model must be defined')
+    }
 
     data.originalState = _.cloneDeep(data)
-    await repositoryHelper.persist(this.arguments.model, data)
+    repositoryHelper.persist(this.arguments.model, data)
 
     await this.postHook()
   }
 
-  static support (args:DataProviderArgs): boolean {
+  /**
+   * Is the given argument a supported model
+   * @param args
+   */
+  static support (args: DataProviderArgs): boolean {
     return args.type === QUERY_TYPE.MODEL
   }
 }

+ 16 - 0
services/hooks/baseHook.ts

@@ -0,0 +1,16 @@
+import { DataProviderArgs } from '~/types/interfaces'
+
+class BaseHook {
+  static priority = 255
+
+  // eslint-disable-next-line require-await
+  async invoke (_args: DataProviderArgs): Promise<any> {
+    throw new Error('Not implemented')
+  }
+
+  static support (_args: DataProviderArgs): boolean {
+    throw new Error('Not implemented')
+  }
+}
+
+export default BaseHook

+ 14 - 0
services/hooks/hookExample.ts

@@ -0,0 +1,14 @@
+import { DataPersisterArgs, HookPersister } from '~/types/interfaces'
+import BaseHook from '~/services/hooks/baseHook'
+
+class HookExample extends BaseHook implements HookPersister {
+  static priority = 10
+
+  async invoke (_args: DataPersisterArgs): Promise<any> {}
+
+  static support (_args:DataPersisterArgs): boolean {
+    return false
+  }
+}
+
+export default HookExample

+ 17 - 12
services/profile/accessProfile.ts

@@ -8,41 +8,46 @@ import { AbilitiesType, accessState, AccessStore, AnyJson } from '~/types/interf
  */
 class AccessProfile {
   private accessProfile: accessState
-
-  private $ability:Ability = {} as Ability
+  private $ability: Ability = {} as Ability
 
   /**
    * @constructor
    * @param {AccessStore} store State Access du Store contenant les informations de l'utilisateur
    * @param {Ability} ability Plugin $ability
    */
-  constructor (store:AccessStore, ability:Ability) {
+  constructor (store: AccessStore, ability: Ability) {
     this.accessProfile = store.state.profile.access
     this.$ability = ability
   }
 
   /**
-   * Est ce que l'utilisateur possède le role.
+   * Est-ce que l'utilisateur possède le role.
    * @param {Array<string>} roles roles à tester
    * @return {boolean}
    */
-  hasRole (roles:Array<string>): boolean {
-    if (roles === null) { return true }
+  hasRole (roles: Array<string>): boolean {
+    if (roles === null) {
+      return true
+    }
 
     let hasRole = false
     roles.map((r) => {
-      if (this.accessProfile.roles.includes(r)) { hasRole = true }
+      if (this.accessProfile.roles.includes(r)) {
+        hasRole = true
+      }
     })
     return hasRole
   }
 
   /**
-   * Est-ce que l'utilisateur possède l'abilité
-   * @param {Array<AbilitiesType>} ability abilité à tester
+   * Est-ce que l'utilisateur possède l'habilité
+   * @param {Array<AbilitiesType>} ability habilité à tester
    * @return {boolean}
    */
-  hasAbility (ability:Array<AbilitiesType>): boolean {
-    if (ability === null) { return true }
+  hasAbility (ability: Array<AbilitiesType>): boolean {
+    if (ability === null) {
+      return true
+    }
 
     let hasAbility = false
     ability.map((ability) => {
@@ -55,7 +60,7 @@ class AccessProfile {
    * Factory
    * @return {AnyJson} retourne les fonction rendues publiques
    */
-  handler ():AnyJson {
+  handler (): AnyJson {
     return {
       hasRole: this.hasRole.bind(this),
       hasAbility: this.hasAbility.bind(this)

+ 14 - 14
services/profile/organizationProfile.ts

@@ -6,13 +6,13 @@ import { AnyJson, organizationState, OrganizationStore } from '~/types/interface
  * Classe répondant aux différentes questions que l'on peut se poser sur l'organization de l'access connecté
  */
 class OrganizationProfile {
-  private organizationProfile:organizationState
+  private organizationProfile: organizationState
 
   /**
    * @constructor
    * @param {OrganizationStore} store State organization du store contenant les informations de l'organisation
    */
-  constructor (store:OrganizationStore) {
+  constructor (store: OrganizationStore) {
     this.organizationProfile = store.state.profile.organization
   }
 
@@ -21,7 +21,7 @@ class OrganizationProfile {
    * @param {Array<string>} modules Modules à tester
    * @return {boolean}
    */
-  hasModule (modules:Array<string>):boolean {
+  hasModule (modules: Array<string>): boolean {
     let hasModule = false
     modules.map((module) => {
       if (this.organizationProfile.modules && this.organizationProfile.modules.includes(module)) { hasModule = true }
@@ -41,7 +41,7 @@ class OrganizationProfile {
    * L'organization fait-elle partie du réseau CMF ?
    * @return {boolean}
    */
-  isCmf ():boolean {
+  isCmf (): boolean {
     const networks = this.organizationProfile.networks.filter((network:string) => {
       return network == process.env.cmf_network
     })
@@ -52,7 +52,7 @@ class OrganizationProfile {
    * L'organization fait-elle partie du réseau FFEC ?
    * @return {boolean}
    */
-  isFfec ():boolean {
+  isFfec (): boolean {
     const networks = this.organizationProfile.networks.filter((network:string) => {
       return network == process.env.ffec_network
     })
@@ -63,7 +63,7 @@ class OrganizationProfile {
    * L'organization possède t'elle un produit school ou school premium
    * @return {boolean}
    */
-  isSchool ():boolean {
+  isSchool (): boolean {
     return this.isSchoolProduct() || this.isSchoolPremiumProduct()
   }
 
@@ -71,7 +71,7 @@ class OrganizationProfile {
    * L'organization possède t'elle un produit artiste ou artiste premium
    * @return {boolean}
    */
-  isArtist ():boolean {
+  isArtist (): boolean {
     return this.isArtistProduct() || this.isArtistPremiumProduct()
   }
 
@@ -79,7 +79,7 @@ class OrganizationProfile {
    * L'organization possède t'elle un produit school
    * @return {boolean}
    */
-  isSchoolProduct ():boolean {
+  isSchoolProduct (): boolean {
     return this.organizationProfile.product === process.env.school_product
   }
 
@@ -87,7 +87,7 @@ class OrganizationProfile {
    * L'organization possède t'elle un produit school premium
    * @return {boolean}
    */
-  isSchoolPremiumProduct ():boolean {
+  isSchoolPremiumProduct (): boolean {
     return this.organizationProfile.product === process.env.school_premium_product
   }
 
@@ -95,7 +95,7 @@ class OrganizationProfile {
    * L'organization possède t'elle un produit premium
    * @return {boolean}
    */
-  isArtistProduct ():boolean {
+  isArtistProduct (): boolean {
     return this.organizationProfile.product === process.env.artist_product
   }
 
@@ -103,7 +103,7 @@ class OrganizationProfile {
    * L'organization possède t'elle un produit artiste premium
    * @return {boolean}
    */
-  isArtistPremiumProduct ():boolean {
+  isArtistPremiumProduct (): boolean {
     return this.organizationProfile.product === process.env.artist_premium_product
   }
 
@@ -111,7 +111,7 @@ class OrganizationProfile {
    * L'organization possède t'elle un produit manager
    * @return {boolean}
    */
-  isManagerProduct ():boolean {
+  isManagerProduct (): boolean {
     return this.organizationProfile.product === process.env.manager_product
   }
 
@@ -119,7 +119,7 @@ class OrganizationProfile {
    * L'organization possède t'elledes enfants
    * @return {boolean|null}
    */
-  isOrganizationWithChildren ():any {
+  isOrganizationWithChildren (): any {
     return this.organizationProfile.hasChildren
   }
 
@@ -127,7 +127,7 @@ class OrganizationProfile {
    * Factory
    * @return {AnyJson} retourne les fonction rendues publiques
    */
-  handler ():AnyJson {
+  handler (): AnyJson {
     return {
       hasModule: this.hasModule.bind(this),
       isSchool: this.isSchool.bind(this),

+ 17 - 20
services/rights/abilitiesUtils.ts

@@ -10,7 +10,7 @@ import { DENORMALIZER_TYPE } from '~/types/enums'
 /**
  * @category Services/droits
  * @class AbilitiesUtils
- * Classe permettant de mener des opérations sur les abilités
+ * Classe permettant de mener des opérations sur les habilités
  */
 class AbilitiesUtils {
   private $store: AnyStore = {} as AnyStore
@@ -47,20 +47,18 @@ class AbilitiesUtils {
    * Set les abilities de l'utilisateur à chaque fois qu'on update son profile
    */
   setAbilities () {
-    // Nécessaire pour que l'update des abilité soit correct après la phase SSR
+    // Nécessaire pour que l'update des habilités soit correcte après la phase SSR
     this.$ability.update(this.$store.state.profile.access.abilities)
 
-    /**
-     * Au moment où l'on effectue un SetProfile via le store Organization, il faut aller récupérer
-     * les différentes abilitées que l'utilisateur peut effectuer. (Tout cela se passe en SSR)
-     */
+    // Au moment où l'on effectue un SetProfile via le store Organization, il faut aller récupérer
+    // les différentes habilitées que l'utilisateur peut effectuer. (Tout cela se passe en SSR)
     const unsubscribe = this.$store.subscribeAction({
-      after: (action, state) => {
+      after: (action, _state) => {
+        // On récupère les habilités
+        const abilities = this.getAbilities()
+
         switch (action.type) {
           case 'profile/organization/setProfile':
-            // On récupère les abilités
-            const abilities = this.getAbilities()
-
             // On les store puis on update le service ability pour le mettre à jour.
             this.$store.commit('profile/access/setAbilities', abilities)
             this.$ability.update(abilities)
@@ -73,10 +71,10 @@ class AbilitiesUtils {
   }
 
   /**
-   * Récupération de l'ensemble des abilities quelles soient par Roles ou par Config.
+   * Récupération de l'ensemble des abilities qu'elles soient par Roles ou par Config.
    * @return {Array<AbilitiesType>}
    */
-  getAbilities ():Array<AbilitiesType> {
+  getAbilities (): Array<AbilitiesType> {
     const abilitiesByRoles = this.getAbilitiesByRoles(this.$store.state.profile.access.roles)
     this.$ability.update(abilitiesByRoles)
     this.initFactory()
@@ -100,11 +98,10 @@ class AbilitiesUtils {
    * @param {string} configPath
    * @return {Array<AbilitiesType>}
    */
-  getAbilitiesByConfig (configPath:string): Array<AbilitiesType> {
+  getAbilitiesByConfig (configPath: string): Array<AbilitiesType> {
     let abilitiesByConfig: Array<AbilitiesType> = []
     try {
-      const serializer = new Serializer()
-      const doc = serializer.denormalize({ path: configPath }, DENORMALIZER_TYPE.YAML)
+      const doc = Serializer.denormalize({ path: configPath }, DENORMALIZER_TYPE.YAML)
       const abilitiesAvailable = doc.abilities
       const abilitiesFiltered = this.abilitiesAvailableFilter(abilitiesAvailable)
       abilitiesByConfig = this.transformAbilitiesConfigToAbility(abilitiesFiltered)
@@ -131,7 +128,7 @@ class AbilitiesUtils {
    * @param {AnyJson} abilitiesAvailable
    * @return {Array<AbilitiesType>}
    */
-  transformAbilitiesConfigToAbility (abilitiesAvailable:AnyJson):Array<AbilitiesType> {
+  transformAbilitiesConfigToAbility (abilitiesAvailable: AnyJson): Array<AbilitiesType> {
     const abilitiesByConfig: Array<AbilitiesType> = []
     _.each(abilitiesAvailable, (ability, subject) => {
       const myAbility: AbilitiesType = {
@@ -144,13 +141,13 @@ class AbilitiesUtils {
   }
 
   /**
-   * Parcours les fonctions par services et établit si oui ou non l'abilité est autorisée
-   * @param {AnyJson} functionByservices
+   * Parcourt les fonctions par services et établit si oui ou non l'habilité est autorisée
+   * @param {AnyJson} functionByServices
    * @return {boolean}
    */
-  canHaveTheAbility (functionByservices: AnyJson) {
+  canHaveTheAbility (functionByServices: AnyJson) {
     let hasAbility = true
-    _.each(functionByservices, (functions, service) => {
+    _.each(functionByServices, (functions, service) => {
       if (hasAbility) {
         const nbFunctions = functions.length
         let cmpt = 0

+ 12 - 12
services/rights/roleUtils.ts

@@ -1,7 +1,7 @@
 import * as _ from 'lodash'
 import { AbilitiesType, AnyJson } from '~/types/interfaces'
 
-const roles_by_function:Array<string> = [
+const rolesByFunction: Array<string> = [
   'ROLE_SUPER_ADMIN',
   'ROLE_ADMIN',
   'ROLE_ADMIN_CORE',
@@ -23,7 +23,7 @@ const roles_by_function:Array<string> = [
   'ROLE_OTHER_CORE'
 ]
 
-const roles_to_change:Array<string> = [
+const rolesToChange: Array<string> = [
   'ROLE_GENERAL_CONFIG',
   'ROLE_GENERAL_CONFIG_VIEW',
   'ROLE_TAGG_ADVANCED',
@@ -40,7 +40,7 @@ const roles_to_change:Array<string> = [
   'ROLE_ONLINEREGISTRATION_ADMINISTRATION_VIEW'
 ]
 
-const action_map: AnyJson = {
+const actionMap: AnyJson = {
   '': 'manage',
   _VIEW: 'read'
 }
@@ -48,17 +48,17 @@ const action_map: AnyJson = {
 /**
  * @category Services/droits
  * @class RoleUtils
- * Classe permettant de mener des opérations sur les roles
+ * Classe permettant de mener des opérations sur les rôles
  */
 class RoleUtils {
   /**
    * Test si une personne possède un profil suivant ses roles
-   * @param {string} profil_name
+   * @param {string} profileName
    * @param {Array<string>} roles
    * @return {boolean}
    */
-  isA (profil_name:string, roles:Array<string>): boolean {
-    return roles.includes('ROLE_' + profil_name + '_CORE')
+  isA (profileName: string, roles: Array<string>): boolean {
+    return roles.includes('ROLE_' + profileName + '_CORE')
   }
 
   /**
@@ -66,14 +66,14 @@ class RoleUtils {
    * @param {Array<string>} roles
    * @return {Array<string>}
    */
-  filterFunctionRoles (roles:Array<string>):Array<string> {
+  filterFunctionRoles (roles: Array<string>): Array<string> {
     return roles.filter((role) => {
-      return !roles_by_function.includes(role)
+      return !rolesByFunction.includes(role)
     })
   }
 
   /**
-   * Avant la migration complète, quelque role disposent d'underscore en trop, on corrige cela...
+   * Fix en attendant la migration complète, quelques roles disposent d'underscore en trop, on corrige cela...
    * @param {Array<string>} roles
    * @return {Array<string>}
    */
@@ -81,7 +81,7 @@ class RoleUtils {
     const regex = /(ROLE_)([A-Z]*_[A-Z]*)([A-Z_]*)*/i
     let match
     roles = roles.map((role) => {
-      if (roles_to_change.includes(role)) {
+      if (rolesToChange.includes(role)) {
         if ((match = regex.exec(role)) !== null) {
           const role = match[1]
           const subject = match[2].replace('_', '-')
@@ -110,7 +110,7 @@ class RoleUtils {
         const subject = match[2]
         const action = match[3]
         abilities.push({
-          action: action_map[action],
+          action: actionMap[action],
           subject: subject.toLowerCase()
         })
       }

+ 2 - 2
services/serializer/denormalizer/baseDenormalizer.ts

@@ -1,8 +1,8 @@
 import { DENORMALIZER_TYPE } from '~/types/enums'
 
 abstract class BaseDenormalizer {
-  static support (type: DENORMALIZER_TYPE): boolean {
-    throw new Error('Need to be implement into static method')
+  static support (_type: DENORMALIZER_TYPE): boolean {
+    throw new Error('Not implemented')
   }
 }
 

+ 11 - 11
services/serializer/denormalizer/hydra.ts

@@ -1,4 +1,4 @@
-import { AnyJson, Denormalizer } from '~/types/interfaces'
+import { AnyJson } from '~/types/interfaces'
 import BaseDenormalizer from '~/services/serializer/denormalizer/baseDenormalizer'
 import { DENORMALIZER_TYPE } from '~/types/enums'
 
@@ -7,22 +7,22 @@ import { DENORMALIZER_TYPE } from '~/types/enums'
  * @class HydraParser
  * Classe permettant d'assurer la dénormalization d'un objet Hydra en JSON
  */
-class Hydra extends BaseDenormalizer implements Denormalizer {
+class Hydra extends BaseDenormalizer {
   static support (type: DENORMALIZER_TYPE): boolean {
     return type === DENORMALIZER_TYPE.HYDRA
   }
 
   /**
-   * Parcours une réponse Hydra pour retourner son équivalent en Json
+   * Parcourt une réponse Hydra pour retourner son équivalent en Json
    * @param {AnyJson} hydraData
    * @return {AnyJson} réponse parsée
    */
-  public denormalize (hydraData: AnyJson): AnyJson {
+  public static denormalize (hydraData: AnyJson): AnyJson {
     if (hydraData['hydra:member']) {
       hydraData.totalCount = hydraData['hydra:totalItems']
-      return this.parseCollection(hydraData)
+      return Hydra.parseCollection(hydraData)
     } else {
-      return this.parseItem(hydraData)
+      return Hydra.parseItem(hydraData)
     }
   }
 
@@ -30,7 +30,7 @@ class Hydra extends BaseDenormalizer implements Denormalizer {
    * Méthode de parsing appelé si on est dans un GET
    * @param {AnyJson} hydraData
    */
-  private parseItem (hydraData: AnyJson): AnyJson {
+  private static parseItem (hydraData: AnyJson): AnyJson {
     if (hydraData['hydra:previous']) {
       const iriParts = hydraData['hydra:previous'].split('/')
       hydraData.previous = iriParts[iriParts.length - 1]
@@ -52,7 +52,7 @@ class Hydra extends BaseDenormalizer implements Denormalizer {
    * Méthode de parsing appelé si on est dans un GET Collection
    * @param {AnyJson} hydraData
    */
-  private parseCollection (hydraData: AnyJson): AnyJson {
+  private static parseCollection (hydraData: AnyJson): AnyJson {
     const collectionResponse = hydraData['hydra:member']
     collectionResponse.metadata = {}
     collectionResponse.order = {}
@@ -69,7 +69,7 @@ class Hydra extends BaseDenormalizer implements Denormalizer {
     // Populate href property for all elements of the collection
     for (const key in collectionResponse) {
       const value = collectionResponse[key]
-      this.populateAllData(value)
+      Hydra.populateAllData(value)
     }
 
     if (typeof (hydraData['hydra:search']) !== 'undefined') {
@@ -90,11 +90,11 @@ class Hydra extends BaseDenormalizer implements Denormalizer {
    * Hydrate l'objet JSON de façon récursive (afin de gérer les objet nested)
    * @param {AnyJson} data
    */
-  private populateAllData (data: AnyJson):void {
+  private static populateAllData (data: AnyJson):void {
     for (const key in data) {
       const value = data[key]
       if (value instanceof Object) {
-        this.populateAllData(value)
+        Hydra.populateAllData(value)
       }
     }
   }

+ 2 - 2
services/serializer/denormalizer/yaml.ts

@@ -9,7 +9,7 @@ const yaml = require('js-yaml')
  * @class YamlParser
  * Classe permettant d'assurer la dénormalization d'un fichier JSON en JSON
  */
-class Yaml extends BaseDenormalizer implements Denormalizer {
+class Yaml extends BaseDenormalizer {
   static support (type: DENORMALIZER_TYPE): boolean {
     return type === DENORMALIZER_TYPE.YAML
   }
@@ -19,7 +19,7 @@ class Yaml extends BaseDenormalizer implements Denormalizer {
    * @param {AnyJson} data
    * @return {AnyJson}
    */
-  denormalize (data: AnyJson): AnyJson {
+  public static denormalize (data: AnyJson): AnyJson {
     try {
       return yaml.load(yaml.dump(read(data.path)))
     } catch (e) {

+ 2 - 2
services/serializer/normalizer/baseNormalizer.ts

@@ -1,8 +1,8 @@
 import { QUERY_TYPE } from '~/types/enums'
 
 abstract class BaseNormalizer {
-  static support (type: QUERY_TYPE): boolean {
-    throw new Error('Need to be implement into static method')
+  static support (_type: QUERY_TYPE): boolean {
+    throw new Error('Not implemented')
   }
 }
 

+ 9 - 5
services/serializer/normalizer/model.ts

@@ -1,6 +1,6 @@
 import * as _ from 'lodash'
 import BaseNormalizer from '~/services/serializer/normalizer/baseNormalizer'
-import { DataPersisterArgs, Normalizer } from '~/types/interfaces'
+import { DataPersisterArgs } from '~/types/interfaces'
 import { QUERY_TYPE } from '~/types/enums'
 import { repositoryHelper } from '~/services/store/repository'
 
@@ -9,7 +9,7 @@ import { repositoryHelper } from '~/services/store/repository'
  * @class Model
  * Classe assurant la normalization d'un Model vers un fichier JSON
  */
-class Model extends BaseNormalizer implements Normalizer {
+class Model extends BaseNormalizer {
   static support (type: QUERY_TYPE): boolean {
     return type === QUERY_TYPE.MODEL
   }
@@ -19,12 +19,16 @@ class Model extends BaseNormalizer implements Normalizer {
    * @param {DataPersisterArgs} args
    * @return {any} réponse
    */
-  normalize (args:DataPersisterArgs): any {
-    if (!args.model) { throw new Error('model must be present') }
+  public static normalize (args: DataPersisterArgs): any {
+    if (!args.model) {
+      throw new Error('*args* has no model attribute')
+    }
 
     const item = repositoryHelper.findItemFromModel(args.model, args.id)
 
-    if (!item || typeof item === 'undefined') { throw new Error('Item not found') }
+    if (!item || typeof item === 'undefined') {
+      throw new Error('Item not found')
+    }
 
     const data = item.$toJson()
     return _.omit(data, 'originalState')

+ 8 - 8
services/serializer/serializer.ts

@@ -4,18 +4,18 @@ import { normalizers } from '~/services/serializer/normalizer/_import'
 import { DENORMALIZER_TYPE } from '~/types/enums'
 
 class Serializer {
-  public normalize (args:DataPersisterArgs) {
-    for (const normalizer of normalizers) {
-      if (normalizer.support(args.type)) {
-        return new normalizer().normalize(args)
+  public static normalize (args:DataPersisterArgs) {
+    for (const Normalizer of normalizers) {
+      if (Normalizer.support(args.type)) {
+        return new Normalizer().normalize(args)
       }
     }
   }
 
-  public denormalize (data: AnyJson, type: DENORMALIZER_TYPE): any {
-    for (const denormalizer of denormalizers) {
-      if (denormalizer.support(type)) {
-        return new denormalizer().denormalize(data)
+  public static denormalize (data: AnyJson, type: DENORMALIZER_TYPE): any {
+    for (const Denormalizer of denormalizers) {
+      if (Denormalizer.support(type)) {
+        return new Denormalizer().denormalize(data)
       }
     }
   }

+ 6 - 8
services/store/query.ts

@@ -1,4 +1,4 @@
-import { Query as VuexQuery, Model } from '@vuex-orm/core'
+import { Query as VuexQuery } from '@vuex-orm/core'
 import { Collection, Item } from '@vuex-orm/core/dist/src/data/Data'
 import { $objectProperties } from '~/services/utils/objectProperties'
 import { AnyJson } from '~/types/interfaces'
@@ -15,10 +15,9 @@ class Query {
    * @param {number} id
    * @return {Item} l'Item
    */
-  public getItem (query: VuexQuery, id:number): Item {
+  public getItem (query: VuexQuery, id: number): Item {
     const item = query.find(id)
     if (!item || typeof item === 'undefined') { throw new Error('item not found') }
-
     return item
   }
 
@@ -30,7 +29,6 @@ class Query {
   public getFirstItem (query: VuexQuery): Item {
     const item = query.first()
     if (!item || typeof item === 'undefined') { throw new Error('item not found') }
-
     return item
   }
 
@@ -39,22 +37,22 @@ class Query {
    * @param {VuexQuery} query
    * @return {Collection} Array d'Item
    */
-  public getCollection (query: VuexQuery):Collection {
+  public getCollection (query: VuexQuery): Collection {
     return query.get()
   }
 
   /**
-   * Récupération de l'Item souhaité puis transformation en JSON applatit
+   * Récupération de l'Item souhaité puis transformation en JSON aplati
    * @param {VuexQuery} query
    * @param {number} id
    * @return {AnyJson} réponse
    */
-  public getFlattenEntry (query: VuexQuery, id:number): AnyJson {
+  public getFlattenEntry (query: VuexQuery, id: number): AnyJson {
     return $objectProperties.cloneAndFlatten(this.getItem(query, id) as AnyJson)
   }
 
   /**
-   * Récupération la collection de la Query puis transformation en JSON applatit
+   * Récupération la collection de la Query puis transformation en JSON aplati
    * @param {VuexQuery} query
    * @return {Array<AnyJson>} réponse
    */

+ 3 - 3
services/store/repository.ts

@@ -47,7 +47,7 @@ class Repository {
    * @param {Model} model
    * @param {AnyJson} entry
    */
-  public persist (model: typeof Model, entry:AnyJson): void {
+  public persist (model: typeof Model, entry: AnyJson): void {
     if (_.isEmpty(entry)) { throw new Error('entry is empty') }
 
     this.getRepository(model).save(entry)
@@ -60,7 +60,7 @@ class Repository {
    * @param {any} value
    * @param {string} field
    */
-  public updateStoreFromField (model: typeof Model, entry:AnyJson, value:any, field:string): void {
+  public updateStoreFromField (model: typeof Model, entry: AnyJson, value: any, field: string): void {
     if (!_.has(entry, field)) { throw new Error('field not found') }
 
     entry[field] = value
@@ -73,7 +73,7 @@ class Repository {
    * @param {number} id
    * @return {Item} l'Item
    */
-  public findItemFromModel (model: typeof Model, id:number): Item {
+  public findItemFromModel (model: typeof Model, id: number): Item {
     const repository = this.getRepository(model)
     const item = repository.find(id)
     if (!item || typeof item === 'undefined') { throw new Error('Item not found') }

+ 3 - 3
services/utils/apiError.ts

@@ -1,12 +1,12 @@
 class ApiError extends Error {
-  private status !: number
+  private readonly status !: number
 
-  constructor (status:number, message:string) {
+  constructor (status: number, message: string) {
     super(message)
     this.status = status
   }
 
-  public getStatus () {
+  public getStatus (): number {
     return this.status
   }
 }

+ 17 - 8
services/utils/datesUtils.ts

@@ -1,25 +1,34 @@
 import moment from 'moment'
 
 export default class DatesUtils {
-  private $moment:typeof moment;
+  private $moment: typeof moment;
 
-  constructor (momentInstance:any) {
+  constructor (momentInstance: any) {
     this.$moment = momentInstance
   }
 
-  formattedDate (dates:any, format:string): string {
-    const d_format:Array<string> = []
+  /**
+   * Formate la ou les dates au format donné
+   * @param dates
+   * @param format
+   */
+  formattedDate (dates: any, format: string): string {
+    const dFormat: Array<string> = []
     if (Array.isArray(dates)) {
       for (const date of dates) {
-        d_format.push(this.$moment(date).format(format))
+        dFormat.push(this.$moment(date).format(format))
       }
     } else {
-      d_format.push(this.$moment(dates as string).format(format))
+      dFormat.push(this.$moment(dates as string).format(format))
     }
-    return d_format.join(' - ')
+    return dFormat.join(' - ')
   }
 
-  sortDate (dates:Array<string>): Array<string> {
+  /**
+   * Trie les dates par ordre chronologique
+   * @param dates
+   */
+  sortDate (dates: Array<string>): Array<string> {
     return dates.sort((a, b) => {
       if (a > b) { return 1 }
       if (a < b) { return -1 }

+ 40 - 32
services/utils/objectProperties.ts

@@ -1,10 +1,10 @@
+import { AnyJson } from '~/types/interfaces'
+
 /**
  * @category Services/utils
  * @class ObjectProperties
  * Classe aidant à manipuler des Objets
  */
-import { AnyJson } from '~/types/interfaces'
-
 class ObjectProperties {
   /**
    * Flatten un objet nested en un objet avec un seul niveau avec des noms de propriétés transformées comme cela 'foo.bar'
@@ -15,47 +15,56 @@ class ObjectProperties {
    * @param excludedProperties
    * @return {AnyJson}
    */
-  cloneAndFlatten (object:AnyJson, excludedProperties:Array<string> = []):AnyJson {
+  cloneAndFlatten (object: AnyJson, excludedProperties: Array<string> = []): AnyJson {
     if (typeof object !== 'object') {
       throw new TypeError('Expecting an object parameter')
     }
-    return Object.keys(object).reduce((values: AnyJson, name: string) => {
-      if (!object.hasOwnProperty(name)) { return values }
-      if (this.isObject(object[name])) {
-        if (!excludedProperties.includes(name)) {
-          const flatObject = this.cloneAndFlatten(object[name])
-          Object.keys(flatObject).forEach((flatObjectKey) => {
-            if (!flatObject.hasOwnProperty(flatObjectKey)) { return }
-            values[name + '.' + flatObjectKey] = flatObject[flatObjectKey]
-          })
+    return Object.keys(object).reduce(
+      (values: AnyJson, name: string) => {
+        if (!object.hasOwnProperty(name)) {
+          return values
+        }
+
+        if (this.isObject(object[name])) {
+          if (!excludedProperties.includes(name)) {
+            const flatObject = this.cloneAndFlatten(object[name])
+            Object.keys(flatObject).forEach((flatObjectKey) => {
+              if (!flatObject.hasOwnProperty(flatObjectKey)) { return }
+              values[name + '.' + flatObjectKey] = flatObject[flatObjectKey]
+            })
+          } else {
+            values[name] = this.clone(object[name])
+          }
         } else {
-          values[name] = this.clone(object[name])
+          values[name] = object[name]
         }
-      } else {
-        values[name] = object[name]
-      }
-      return values
-    }, {})
+        return values
+      }, {}
+    )
   };
 
   /**
-   * Trasnforme un objet flattened en un objet nested. L'objet passé en paramètre reste inchangé
+   * Transforme un objet flattened en un objet nested. L'objet passé en paramètre reste inchangé
    * @example cloneAndNest({ a: 1, 'b.c': 2, 'd.e': 3, 'd.f.g': 4, 'd.f.h': 5 } ) => { a: 1, b: { c: 2 }, d: { e: 3, f: { g: 4, h: 5 } } }
    * @param {AnyJson} object
    * @return {AnyJson}
    */
-  cloneAndNest (object:AnyJson):AnyJson {
+  cloneAndNest (object: AnyJson): AnyJson {
     if (typeof object !== 'object') {
       throw new TypeError('Expecting an object parameter')
     }
     return Object.keys(object).reduce((values, name) => {
-      if (!object.hasOwnProperty(name)) { return values }
+      if (!object.hasOwnProperty(name)) {
+        return values
+      }
       name.split('.').reduce((previous: AnyJson, current: string, index: number, list: Array<string>) => {
         if (previous != null) {
-          if (typeof previous[current] === 'undefined') { previous[current] = {} }
+          if (typeof previous[current] === 'undefined') {
+            previous[current] = {}
+          }
           if (index < (list.length - 1)) {
             return previous[current]
-          };
+          }
           previous[current] = object[name]
         }
       }, values)
@@ -64,20 +73,19 @@ class ObjectProperties {
   }
 
   /**
-   * Test si le paramètre est un objet
+   * Teste si le paramètre est un objet
    * @param {AnyJson} value
    * @return {boolean}
    */
-  isObject (value:any):boolean {
-    if (value === null) { return false }
-    if (typeof value !== 'object') { return false }
-    if (Array.isArray(value)) { return false }
-    if (Object.prototype.toString.call(value) === '[object Date]') { return false }
-    return true
+  isObject (value: any): boolean {
+    return value !== null &&
+      typeof value === 'object' &&
+      !Array.isArray(value) &&
+      Object.prototype.toString.call(value) !== '[object Date]'
   }
 
   /**
-   * Clone l'objet et ces propriétés.
+   * Clône l'objet et ses propriétés.
    * @param {Object} object
    * @return {Object}
    */
@@ -95,7 +103,7 @@ class ObjectProperties {
    * @example sortObjectByKey({b:1, d:2, c:3, a:4}) => {a:4, b:1, c:3, d:2}
    * @param toSort
    */
-  sortObjectByKey (toSort:any): any {
+  sortObjectByKey (toSort: any): any {
     if (typeof toSort !== 'object') {
       throw new TypeError('Expecting an object parameter')
     }

+ 17 - 23
tests/unit/services/connection/connection.spec.ts

@@ -3,75 +3,69 @@ import Connection from '~/services/connection/connection'
 import axios from '~/plugins/Data/axios'
 import { HTTP_METHOD, QUERY_TYPE } from '~/types/enums'
 
-let $connection:any
 const axiosMock = axios as jest.Mocked<NuxtAxiosInstance>
 
 beforeAll(() => {
-  $connection = new Connection()
   Connection.initConnector(axiosMock)
 })
 
 describe('invoke()', () => {
-  it('should throw an error if the method is unknown', () => {
-    expect(() => $connection.invoke('GETS', 'users', { type: QUERY_TYPE.MODEL })).toThrow()
-  })
-
   describe('getItem()', () => {
     it('should return item data', async () => {
       Connection.connector.$request = jest.fn().mockReturnValue({ data: 'data user 1' })
-      const response = await $connection.invoke(HTTP_METHOD.GET, 'users', { type: QUERY_TYPE.MODEL })
+      const response = await Connection.invoke(HTTP_METHOD.GET, 'users', { type: QUERY_TYPE.MODEL })
       expect(response).toStrictEqual({ data: 'data user 1' })
     })
 
     it('should call getItem', async () => {
-      $connection.getItem = jest.fn().mockReturnValue({})
-      await $connection.invoke(HTTP_METHOD.GET, 'users', { type: QUERY_TYPE.MODEL, id: 1 })
-      expect($connection.getItem).toHaveBeenCalled()
+      Connection.getItem = jest.fn().mockReturnValue({})
+      await Connection.invoke(HTTP_METHOD.GET, 'users', { type: QUERY_TYPE.MODEL, id: 1 })
+      expect(Connection.getItem).toHaveBeenCalled()
     })
   })
 
   describe('getCollection()', () => {
     it('should return collection data', async () => {
       Connection.connector.$request = jest.fn().mockReturnValue([{ data: 'data user 1' }, { data: 'data user 2' }])
-      const response = await $connection.invoke(HTTP_METHOD.GET, 'users', { type: QUERY_TYPE.MODEL })
+      const response = await Connection.invoke(HTTP_METHOD.GET, 'users', { type: QUERY_TYPE.MODEL })
       expect(response).toStrictEqual([{ data: 'data user 1' }, { data: 'data user 2' }])
     })
     it('should call getCollection and return collection data', async () => {
-      $connection.getCollection = jest.fn().mockReturnValue({})
-      await $connection.invoke(HTTP_METHOD.GET, 'users', { type: QUERY_TYPE.MODEL })
-      expect($connection.getCollection).toHaveBeenCalled()
+      Connection.getCollection = jest.fn().mockReturnValue({})
+      await Connection.invoke(HTTP_METHOD.GET, 'users', { type: QUERY_TYPE.MODEL })
+      expect(Connection.getCollection).toHaveBeenCalled()
     })
   })
 
   describe('put()', () => {
     it('should throw an error if data missing', async () => {
-      expect(() => $connection.invoke(HTTP_METHOD.PUT, 'users', { type: QUERY_TYPE.MODEL })).toThrow()
+      expect(() => Connection.invoke(HTTP_METHOD.PUT, 'users', { type: QUERY_TYPE.MODEL })).toThrow()
     })
 
     it('should return item data', async () => {
       Connection.connector.$request = jest.fn().mockReturnValue({ data: 'data user 1' })
-      const response = await $connection.invoke(HTTP_METHOD.PUT, 'users', { type: QUERY_TYPE.MODEL, id: 1, data: {} })
+      const response = await Connection.invoke(HTTP_METHOD.PUT, 'users', { type: QUERY_TYPE.MODEL, id: 1, data: {} })
       expect(response).toStrictEqual({ data: 'data user 1' })
     })
 
     it('should call put and return item data', async () => {
-      $connection.put = jest.fn().mockReturnValue({})
-      await $connection.invoke(HTTP_METHOD.PUT, 'users', { type: QUERY_TYPE.MODEL, id: 1, data: {} })
-      expect($connection.put).toHaveBeenCalled()
+      Connection.put = jest.fn().mockReturnValue({})
+      await Connection.invoke(HTTP_METHOD.PUT, 'users', { type: QUERY_TYPE.MODEL, id: 1, data: {} })
+      expect(Connection.put).toHaveBeenCalled()
     })
   })
 
   describe('deleteItem()', () => {
     it('should delete item', async () => {
       Connection.connector.$request = jest.fn().mockReturnValue({})
-      const response = await $connection.invoke(HTTP_METHOD.DELETE, 'users', { type: QUERY_TYPE.MODEL, id: 1 })
+      const response = await Connection.invoke(HTTP_METHOD.DELETE, 'users', { type: QUERY_TYPE.MODEL, id: 1 })
       expect(response).toStrictEqual({})
     })
 
     it('should call deleteItem', async () => {
-      $connection.deleteItem = jest.fn().mockReturnValue({})
-      await $connection.invoke(HTTP_METHOD.DELETE, 'users', { type: QUERY_TYPE.MODEL, id: 1 })
-      expect($connection.deleteItem).toHaveBeenCalled()
+      Connection.deleteItem = jest.fn().mockReturnValue({})
+      await Connection.invoke(HTTP_METHOD.DELETE, 'users', { type: QUERY_TYPE.MODEL, id: 1 })
+      expect(Connection.deleteItem).toHaveBeenCalled()
     })
   })
 })

+ 8 - 14
tests/unit/services/connection/constructUrl.spec.ts

@@ -4,22 +4,16 @@ import User from '~/tests/unit/fixture/models/User'
 import Organization from '~/tests/unit/fixture/models/Organization'
 import { repositoryHelper } from '~/services/store/repository'
 
-let $constructUrl:ConstructUrl
-
-beforeAll(async () => {
-  $constructUrl = new ConstructUrl()
-})
-
 describe('invoke()', () => {
   describe('getDefaultUrl()', () => {
     it('should throw an error if URL is missing', () => {
-      expect(() => $constructUrl.invoke({
+      expect(() => ConstructUrl.invoke({
         type: QUERY_TYPE.DEFAULT
       })).toThrow()
     })
 
     it('should return the URL concat with Root URL', () => {
-      expect($constructUrl.invoke({
+      expect(ConstructUrl.invoke({
         type: QUERY_TYPE.DEFAULT,
         url: 'users'
       })).toEqual('/api/users')
@@ -28,13 +22,13 @@ describe('invoke()', () => {
 
   describe('getEnumUrl()', () => {
     it('should throw an error if enumType is missing', () => {
-      expect(() => $constructUrl.invoke({
+      expect(() => ConstructUrl.invoke({
         type: QUERY_TYPE.ENUM
       })).toThrow()
     })
 
     it('should return the Enum URL concat with Root URL', () => {
-      expect($constructUrl.invoke({
+      expect(ConstructUrl.invoke({
         type: QUERY_TYPE.ENUM,
         enumType: 'billing_type'
       })).toEqual('/api/enum/billing_type')
@@ -43,7 +37,7 @@ describe('invoke()', () => {
 
   describe('getModelUrl()', () => {
     it('should throw an error if model is missing', () => {
-      expect(() => $constructUrl.invoke({
+      expect(() => ConstructUrl.invoke({
         type: QUERY_TYPE.MODEL
       })).toThrow()
     })
@@ -52,7 +46,7 @@ describe('invoke()', () => {
       const repositoryHelperMock = repositoryHelper as jest.Mocked<typeof repositoryHelper>
       repositoryHelperMock.getEntity = jest.fn().mockReturnValue('users')
 
-      expect($constructUrl.invoke({
+      expect(ConstructUrl.invoke({
         type: QUERY_TYPE.MODEL,
         model: User
       })).toEqual('/api/users')
@@ -62,7 +56,7 @@ describe('invoke()', () => {
       const repositoryHelperMock = repositoryHelper as jest.Mocked<typeof repositoryHelper>
       repositoryHelperMock.getEntity = jest.fn().mockReturnValue('users')
 
-      expect(() => $constructUrl.invoke({
+      expect(() => ConstructUrl.invoke({
         type: QUERY_TYPE.MODEL,
         model: User,
         root_model: Organization
@@ -75,7 +69,7 @@ describe('invoke()', () => {
         .mockReturnValueOnce('users')
         .mockReturnValueOnce('organizations')
 
-      expect($constructUrl.invoke({
+      expect(ConstructUrl.invoke({
         type: QUERY_TYPE.MODEL,
         model: User,
         root_model: Organization,

+ 0 - 14
tests/unit/services/datadeleter/hook/baseHook.spec.ts

@@ -1,14 +0,0 @@
-import { QUERY_TYPE } from '~/types/enums'
-import BaseHook from '~/services/dataDeleter/hook/baseHook'
-import { DataDeleterArgs } from '~/types/interfaces'
-
-class DummyHook extends BaseHook {}
-
-describe('support()', () => {
-  it('should trow an error if support doesnt defined in DummyHook', () => {
-    const args:DataDeleterArgs = {
-      type: QUERY_TYPE.DEFAULT
-    }
-    expect(() => DummyHook.support(args)).toThrow()
-  })
-})

+ 0 - 14
tests/unit/services/datapersister/hook/baseHook.spec.ts

@@ -1,14 +0,0 @@
-import { QUERY_TYPE } from '~/types/enums'
-import BaseHook from '~/services/dataPersister/hook/baseHook'
-import { DataPersisterArgs } from '~/types/interfaces'
-
-class DummyHook extends BaseHook {}
-
-describe('support()', () => {
-  it('should trow an error if support doesnt defined in DummyHook', () => {
-    const args:DataPersisterArgs = {
-      type: QUERY_TYPE.DEFAULT
-    }
-    expect(() => DummyHook.support(args)).toThrow()
-  })
-})

+ 0 - 14
tests/unit/services/dataprovider/hook/baseHook.spec.ts

@@ -1,14 +0,0 @@
-import { QUERY_TYPE } from '~/types/enums'
-import BaseHook from '~/services/dataProvider/provider/hook/baseHook'
-import { DataProviderArgs } from '~/types/interfaces'
-
-class DummyHook extends BaseHook {}
-
-describe('support()', () => {
-  it('should trow an error if support doesnt defined in DummyHook', () => {
-    const args:DataProviderArgs = {
-      type: QUERY_TYPE.DEFAULT
-    }
-    expect(() => DummyHook.support(args)).toThrow()
-  })
-})

+ 1 - 1
types/enums.ts

@@ -17,7 +17,7 @@ export const enum QUERY_TYPE {
 }
 
 export const enum ABILITIES {
-  DISPLAY = 'diplay',
+  DISPLAY = 'display',
   READ = 'read',
   MANAGE = 'manage'
 }

+ 13 - 13
types/interfaces.d.ts

@@ -138,47 +138,47 @@ interface UrlArgs {
   readonly url?:string,
   readonly enumType?:string,
   readonly model?: typeof Model,
-  readonly root_model?: typeof Model,
+  readonly rootModel?: typeof Model,
   readonly id?:any,
-  readonly root_id?:number
+  readonly rootId?:number
   readonly progress?:boolean
 }
 
 interface DataPersisterArgs extends UrlArgs{
-  data?:AnyJson,
-  readonly hook?:string
+  data?: AnyJson,
+  readonly hook?: string
 }
 
 interface DataDeleterArgs extends UrlArgs{
-  readonly hook?:string
+  readonly hook?: string
 }
 
 interface HookPersister{
-  invoke(args:DataPersisterArgs): Promise<any>,
+  invoke(args: DataPersisterArgs): Promise<any>,
 }
 
 interface HookDeleter{
-  invoke(args:DataDeleterArgs): Promise<any>,
+  invoke(args: DataDeleterArgs): Promise<any>,
 }
 
 interface DataProviderArgs extends UrlArgs{
-  readonly hook?:string
+  readonly hook?: string
 }
 
 interface HookProvider{
-  invoke(args:DataProviderArgs): Promise<any>,
+  invoke(args: DataProviderArgs): Promise<any>,
 }
 interface Provider{
   invoke(data: AnyJson): Promise<any>,
 }
 interface Denormalizer{
-  denormalize(data:any): any,
+  denormalize(data: any): any,
 }
 interface Normalizer{
-  normalize(args:DataPersisterArgs): any,
+  normalize(args: DataPersisterArgs): any,
 }
 
 interface DataProviders{
-  initCtx(ctx:Context): void,
-  invoke(args:DataProviderArgs): Promise<any>,
+  initCtx(ctx: Context): void,
+  invoke(args: DataProviderArgs): Promise<any>,
 }

+ 2 - 1
types/types.d.ts

@@ -1,2 +1,3 @@
-import { Query, Repository, Model } from '@vuex-orm/core'
+import { Query, Repository } from '@vuex-orm/core'
+
 export type RepositoryOrQuery<R extends Repository = Repository, Q extends Query = Query> = R | Q;