Olivier Massot 4 месяцев назад
Родитель
Сommit
8c4ac4f162

+ 1 - 1
components/Form/Freemium/Event.vue

@@ -224,7 +224,7 @@ const props = defineProps<{
 }>()
 
 const { em } = useEntityManager()
-const getAsserts = (key) => getAssertUtils(Event.getAsserts(), key)
+const getAsserts = (key: string) => getAssertUtils(Event.getAsserts(), key)
 
 /**
  * Si la date de début est mise à jour, on s'assure que la date de fin est

+ 1 - 1
components/Form/Parameter/AttendanceBookingReason.vue

@@ -21,6 +21,6 @@ defineProps<{
   entity: AttendanceBookingReason
 }>()
 
-const getAsserts = (key) =>
+const getAsserts = (key: string) =>
   getAssertUtils(AttendanceBookingReason.getAsserts(), key)
 </script>

+ 1 - 1
components/Form/Parameter/EducationTiming.vue

@@ -20,5 +20,5 @@ defineProps<{
   entity: EducationTiming
 }>()
 
-const getAsserts = (key) => getAssertUtils(EducationTiming.getAsserts(), key)
+const getAsserts = (key: string) => getAssertUtils(EducationTiming.getAsserts(), key)
 </script>

+ 1 - 1
components/Form/Parameter/ResidenceArea.vue

@@ -21,5 +21,5 @@ defineProps<{
   entity: ResidenceArea
 }>()
 
-const getAsserts = (key) => getAssertUtils(ResidenceArea.getAsserts(), key)
+const getAsserts = (key: string) => getAssertUtils(ResidenceArea.getAsserts(), key)
 </script>

+ 1 - 0
components/Layout/Parameters/EntityTable.vue

@@ -138,6 +138,7 @@ const items: ComputedRef<Array<ApiResource> | null> = computed(() => {
       for (const col of props.columnsDefinitions!) {
         newItem[col.property] = item[col.property]
       }
+      // @ts-expect-error intentional conversion of filtered object to ApiResource for table display
       return newItem as ApiResource
     })
   }

+ 2 - 0
composables/data/useRefreshProfile.ts

@@ -44,6 +44,7 @@ export const useRefreshProfile = () => {
     //  du repo de MyProfile ne fonctionne pas quand le plugin init.server.ts re-fetch le profil
     em.flush(MyProfile)
 
+    // @ts-expect-error MyProfile extends AccessProfile but type system doesn't recognize compatibility
     accessProfileStore.initiateProfile(profile)
     organizationProfileStore.initiateProfile(profile.organization)
   }
@@ -58,6 +59,7 @@ export const useRefreshProfile = () => {
     //  du repo de MyProfile ne fonctionne pas quand le plugin init.server.ts re-fetch le profil
     em.flush(MyProfile)
 
+    // @ts-expect-error MyProfile extends AccessProfile but type system doesn't recognize compatibility
     accessProfileStore.setProfile(profile)
     organizationProfileStore.setProfile(profile.organization)
   }

+ 1 - 1
pages/freemium/organization.vue

@@ -138,7 +138,7 @@ onUnmounted(() => {
   useRepo(Country).flush()
 })
 
-const getAsserts = (key) => getAssertUtils(Organization.getAsserts(), key)
+const getAsserts = (key: string) => getAssertUtils(Organization.getAsserts(), key)
 </script>
 
 <style scoped lang="scss">

+ 1 - 1
pages/parameters/attendances.vue

@@ -73,5 +73,5 @@ if (organizationProfile.parametersId === null) {
   throw new Error('Missing organization parameters id')
 }
 
-const getAsserts = (key) => getAssertUtils(Parameters.getAsserts(), key)
+const getAsserts = (key: string) => getAssertUtils(Parameters.getAsserts(), key)
 </script>

+ 1 - 1
pages/parameters/cycles/[id].vue

@@ -22,5 +22,5 @@ definePageMeta({
   name: 'cycle',
 })
 
-const getAsserts = (key) => getAssertUtils(Cycle.getAsserts(), key)
+const getAsserts = (key: string) => getAssertUtils(Cycle.getAsserts(), key)
 </script>

+ 2 - 2
services/asserts/getAssertUtils.ts

@@ -1,8 +1,8 @@
 import { AssertRuleRegistry } from './AssertRuleRegistry'
 
-export function getAssertUtils(asserts: Record<string, unknown>, key: string) {
+export function getAssertUtils(asserts: object, key: string) {
   if (!asserts || !(key in asserts)) return []
 
   const registry = new AssertRuleRegistry()
-  return registry.getValidators(asserts[key])
+  return registry.getValidators(asserts[key] as Record<string, unknown>)
 }

+ 1 - 2
services/data/entityManager.ts

@@ -239,9 +239,8 @@ class EntityManager {
     const response = await this.apiRequestService.get(url)
 
     // deserialize the response
-    // @ts-expect-error Response here is a Json Hydra response
     const apiCollection = HydraNormalizer.denormalize(
-      response,
+      response as unknown as AnyJson,
       model,
     ) as ApiCollection
 

+ 4 - 5
services/data/enumManager.ts

@@ -2,7 +2,8 @@ import type { VueI18n } from 'vue-i18n'
 import type ApiRequestService from './apiRequestService'
 import UrlUtils from '~/services/utils/urlUtils'
 import HydraNormalizer from '~/services/data/normalizer/hydraNormalizer'
-import type { Collection, Enum } from '~/types/data.d'
+import type { AnyJson, Collection, Enum } from '~/types/data.d'
+import type { EnumChoice } from '~/types/interfaces'
 
 class EnumManager {
   private apiRequestService: ApiRequestService
@@ -18,10 +19,8 @@ class EnumManager {
 
     const response = await this.apiRequestService.get(url)
 
-    // @ts-expect-error Response here is a Json Hydra response
-    const { data } = HydraNormalizer.denormalize(response) as {
-      data: Collection
-    }
+    // @ts-expect-error J'ignore pourquoi, mais response ici est bien de type AnyJson, et non Response...
+    const { data } = HydraNormalizer.denormalize(response) as { data: Collection<Record<string>> }
 
     const enum_: Enum = []
     for (const key in data.items) {

+ 1 - 0
services/data/normalizer/hydraNormalizer.ts

@@ -169,6 +169,7 @@ class HydraNormalizer {
         continue
       }
 
+      // @ts-expect-error entity property exists in iriEncodedFields configuration
       const targetEntity = iriEncodedFields[field].entity
 
       if (_.isArray(value)) {

+ 1 - 1
types/data.d.ts

@@ -48,7 +48,7 @@ interface Pagination {
 }
 
 interface Collection<T extends ApiResource> {
-  items: PiniaOrmCollection<T>
+  items: Array<T>
   pagination: Pagination
   totalItems: number | undefined
 }