interfaces.d.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import { Model } from '@vuex-orm/core'
  2. import { Ability } from '@casl/ability'
  3. import { Store } from 'vuex'
  4. import { Context } from '@nuxt/types/app'
  5. import DataPersister from '~/services/dataPersister/dataPersister'
  6. import DataProvider from '~/services/dataProvider/dataProvider'
  7. import DataDeleter from '~/services/dataDeleter/dataDeleter'
  8. import { ABILITIES, GENDER, QUERY_TYPE, TYPE_ALERT } from '~/types/enums'
  9. /**
  10. * Upgrade du @nuxt/types pour TypeScript
  11. */
  12. declare module '@nuxt/types' {
  13. interface Context {
  14. $ability: Ability,
  15. $dataPersister: DataPersister,
  16. $dataProvider: DataProvider,
  17. $dataDeleter: DataDeleter,
  18. }
  19. }
  20. interface ItemMenu {
  21. title: string,
  22. icon?: string,
  23. to?: string,
  24. children?: ItemsMenu,
  25. isExternalLink?: boolean,
  26. }
  27. interface ItemsMenu extends Array<ItemMenu> {}
  28. interface Menu{
  29. getMenu : () => ItemMenu | null,
  30. getHeaderMenu : () => ItemMenu | null,
  31. }
  32. interface AbilitiesType {
  33. action: ABILITIES,
  34. subject: string,
  35. /** an array of fields to which user has (or not) access */
  36. fields?: string[]
  37. /** an object of conditions which restricts the rule scope */
  38. conditions?: any
  39. /** indicates whether rule allows or forbids something */
  40. inverted?: boolean
  41. /** message which explains why rule is forbidden */
  42. reason?: string
  43. }
  44. interface formState {
  45. dirty: boolean,
  46. showConfirmToLeave: boolean,
  47. goAfterLeave: string
  48. }
  49. interface alert{
  50. type: TYPE_ALERT,
  51. message: string
  52. }
  53. interface pageState {
  54. alerts: Array<alert>,
  55. }
  56. interface baseAccessState {
  57. id: number,
  58. name: string,
  59. givenName: string,
  60. gender: GENDER,
  61. avatarId: number
  62. }
  63. interface Historical {
  64. future?: boolean,
  65. past?: boolean,
  66. present?: boolean,
  67. dateStart?: string,
  68. dateEnd?: string
  69. }
  70. interface accessState extends baseAccessState{
  71. bearer: string,
  72. switchId: number,
  73. activityYear: number,
  74. historical: Historical,
  75. roles: Array<string>,
  76. abilities: Array<AbilitiesType>,
  77. isAdminAccess: boolean,
  78. isAdmin: boolean,
  79. isAdministratifManager: boolean,
  80. isPedagogicManager: boolean,
  81. isFinancialManager: boolean,
  82. isCaMember: boolean,
  83. isStudent: boolean,
  84. isTeacher: boolean,
  85. isMember: boolean,
  86. isOther: boolean,
  87. hasLateralMenu: boolean,
  88. hasConfigurationMenu: boolean,
  89. hasAccessesMenu: boolean,
  90. hasFamilyMenu: boolean,
  91. multiAccesses: Array<baseOrganizationState>,
  92. familyAccesses: Array<baseAccessState>,
  93. originalAccess: baseAccessState
  94. }
  95. interface AccessStore extends Store<{profile:{access:accessState}}> {}
  96. interface baseOrganizationState {
  97. id: number,
  98. name: string,
  99. website?: string,
  100. subDomain?: string
  101. }
  102. interface organizationState extends baseOrganizationState{
  103. id: number,
  104. name: string,
  105. product?: string,
  106. modules?: Array<string>,
  107. hasChildren?: boolean,
  108. networks: Array<string>,
  109. parents: Array<organizationState>,
  110. }
  111. interface OrganizationStore extends Store<{profile:{organization:organizationState}}> {}
  112. interface AnyJson extends Record<string, any> {}
  113. interface AnyStore extends Store<any> {}
  114. interface EnumChoice {
  115. value: string,
  116. label: string
  117. }
  118. interface EnumChoices extends Array<EnumChoice> {}
  119. interface UrlArgs {
  120. readonly type: QUERY_TYPE,
  121. readonly url?:string,
  122. readonly enumType?:string,
  123. readonly model?: typeof Model,
  124. readonly root_model?: typeof Model,
  125. readonly id?:any,
  126. readonly root_id?:number
  127. readonly progress?:boolean
  128. }
  129. interface DataPersisterArgs extends UrlArgs{
  130. data?:AnyJson,
  131. readonly hook?:string
  132. }
  133. interface DataDeleterArgs extends UrlArgs{
  134. readonly hook?:string
  135. }
  136. interface HookPersister{
  137. invoke(args:DataPersisterArgs): Promise<any>,
  138. }
  139. interface HookDeleter{
  140. invoke(args:DataDeleterArgs): Promise<any>,
  141. }
  142. interface DataProviderArgs extends UrlArgs{
  143. readonly hook?:string
  144. }
  145. interface HookProvider{
  146. invoke(args:DataProviderArgs): Promise<any>,
  147. }
  148. interface Provider{
  149. invoke(data: AnyJson): Promise<any>,
  150. }
  151. interface Denormalizer{
  152. denormalize(data:any): any,
  153. }
  154. interface Normalizer{
  155. normalize(args:DataPersisterArgs): any,
  156. }
  157. interface DataProviders{
  158. initCtx(ctx:Context): void,
  159. invoke(args:DataProviderArgs): Promise<any>,
  160. }