interfaces.d.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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/data/dataPersister'
  6. import DataProvider from '~/services/data/dataProvider'
  7. import DataDeleter from '~/services/data/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. actions?: ItemsMenu,
  27. }
  28. interface ItemsMenu extends Array<ItemMenu> {}
  29. interface Menu {
  30. getMenu : () => ItemMenu | null,
  31. getHeaderMenu : () => ItemMenu | null,
  32. }
  33. interface AbilitiesType {
  34. action: ABILITIES,
  35. subject: string,
  36. /** an array of fields to which user has (or not) access */
  37. fields?: string[]
  38. /** an object of conditions which restricts the rule scope */
  39. conditions?: any
  40. /** indicates whether rule allows or forbids something */
  41. inverted?: boolean
  42. /** message which explains why rule is forbidden */
  43. reason?: string
  44. }
  45. interface formState {
  46. dirty: boolean,
  47. showConfirmToLeave: boolean,
  48. goAfterLeave: string
  49. }
  50. interface alert {
  51. type: TYPE_ALERT,
  52. message: string
  53. }
  54. interface pageState {
  55. alerts: Array<alert>,
  56. }
  57. interface baseAccessState {
  58. id: number,
  59. name: string,
  60. givenName: string,
  61. gender: GENDER,
  62. avatarId: number
  63. }
  64. interface Historical {
  65. future?: boolean,
  66. past?: boolean,
  67. present?: boolean,
  68. dateStart?: string,
  69. dateEnd?: string
  70. }
  71. interface accessState extends baseAccessState {
  72. bearer: string,
  73. switchId: number,
  74. activityYear: number,
  75. historical: Historical,
  76. roles: Array<string>,
  77. abilities: Array<AbilitiesType>,
  78. isAdminAccess: boolean,
  79. isAdmin: boolean,
  80. isAdministratifManager: boolean,
  81. isPedagogicManager: boolean,
  82. isFinancialManager: boolean,
  83. isCaMember: boolean,
  84. isStudent: boolean,
  85. isTeacher: boolean,
  86. isMember: boolean,
  87. isOther: boolean,
  88. isGuardian: boolean,
  89. isPayor: boolean,
  90. hasLateralMenu: boolean,
  91. hasConfigurationMenu: boolean,
  92. hasAccessesMenu: boolean,
  93. hasFamilyMenu: boolean,
  94. multiAccesses: Array<baseOrganizationState>,
  95. familyAccesses: Array<baseAccessState>,
  96. originalAccess: baseAccessState
  97. }
  98. interface AccessStore extends Store<{profile:{access: accessState}}> {}
  99. interface baseOrganizationState {
  100. id: number,
  101. name: string,
  102. website?: string,
  103. subDomain?: string
  104. }
  105. interface organizationState extends baseOrganizationState {
  106. id: number,
  107. name: string,
  108. product?: string,
  109. modules?: Array<string>,
  110. hasChildren?: boolean,
  111. showAdherentList?: boolean,
  112. networks: Array<string>,
  113. parents: Array<organizationState>,
  114. }
  115. interface OrganizationStore extends Store<{profile:{organization: organizationState}}> {}
  116. interface AnyJson extends Record<string, any> {}
  117. interface AnyStore extends Store<any> {}
  118. interface EnumChoice {
  119. value: string,
  120. label: string
  121. }
  122. interface EnumChoices extends Array<EnumChoice> {}
  123. interface DataManager {
  124. initCtx(ctx: Context): void,
  125. invoke(args: UrlArgs): Promise<any>,
  126. }
  127. interface UrlArgs {
  128. readonly type: QUERY_TYPE,
  129. readonly url?: string,
  130. readonly baseUrl?: string,
  131. readonly enumType?: string,
  132. readonly model?: typeof Model,
  133. readonly rootModel?: typeof Model,
  134. readonly id?: any,
  135. readonly rootId?: number
  136. readonly showProgress?: boolean
  137. readonly hook?: string
  138. }
  139. interface ImageArgs {
  140. readonly id: number,
  141. readonly height: number,
  142. readonly width: number
  143. }
  144. interface DataProviderArgs extends UrlArgs {
  145. imgArgs?: ImageArgs
  146. }
  147. interface DataPersisterArgs extends UrlArgs {
  148. data?: AnyJson
  149. }
  150. interface DataDeleterArgs extends UrlArgs {}
  151. interface HookProvider {
  152. invoke(args: DataProviderArgs): Promise<any>,
  153. }
  154. interface HookPersister {
  155. invoke(args: DataPersisterArgs): Promise<any>,
  156. }
  157. interface HookDeleter {
  158. invoke(args: DataDeleterArgs): Promise<any>,
  159. }
  160. interface Processor {
  161. process(data: AnyJson): Promise<any>
  162. }
  163. interface Normalizer {
  164. normalize(args: DataPersisterArgs): any,
  165. }
  166. interface Denormalizer {
  167. denormalize(data: any): any,
  168. }