interfaces.d.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. }
  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. isGuardian: boolean,
  88. isPayor: boolean,
  89. hasLateralMenu: boolean,
  90. hasConfigurationMenu: boolean,
  91. hasAccessesMenu: boolean,
  92. hasFamilyMenu: boolean,
  93. multiAccesses: Array<baseOrganizationState>,
  94. familyAccesses: Array<baseAccessState>,
  95. originalAccess: baseAccessState
  96. }
  97. interface AccessStore extends Store<{profile:{access: accessState}}> {}
  98. interface baseOrganizationState {
  99. id: number,
  100. name: string,
  101. website?: string,
  102. subDomain?: string
  103. }
  104. interface organizationState extends baseOrganizationState {
  105. id: number,
  106. name: string,
  107. product?: string,
  108. modules?: Array<string>,
  109. hasChildren?: boolean,
  110. showAdherentList?: boolean,
  111. networks: Array<string>,
  112. parents: Array<organizationState>,
  113. }
  114. interface OrganizationStore extends Store<{profile:{organization: organizationState}}> {}
  115. interface AnyJson extends Record<string, any> {}
  116. interface AnyStore extends Store<any> {}
  117. interface EnumChoice {
  118. value: string,
  119. label: string
  120. }
  121. interface EnumChoices extends Array<EnumChoice> {}
  122. interface DataManager {
  123. initCtx(ctx: Context): void,
  124. invoke(args: UrlArgs): Promise<any>,
  125. }
  126. interface UrlArgs {
  127. readonly type: QUERY_TYPE,
  128. readonly url?: string,
  129. readonly enumType?: string,
  130. readonly model?: typeof Model,
  131. readonly rootModel?: typeof Model,
  132. readonly id?: any,
  133. readonly rootId?: number
  134. readonly showProgress?: boolean
  135. readonly hook?: string
  136. }
  137. interface DataProviderArgs extends UrlArgs {}
  138. interface DataPersisterArgs extends UrlArgs {
  139. data?: AnyJson
  140. }
  141. interface DataDeleterArgs extends UrlArgs {}
  142. interface HookProvider {
  143. invoke(args: DataProviderArgs): Promise<any>,
  144. }
  145. interface HookPersister {
  146. invoke(args: DataPersisterArgs): Promise<any>,
  147. }
  148. interface HookDeleter {
  149. invoke(args: DataDeleterArgs): Promise<any>,
  150. }
  151. interface Processor {
  152. process(data: AnyJson): Promise<any>
  153. }
  154. interface Normalizer {
  155. normalize(args: DataPersisterArgs): any,
  156. }
  157. interface Denormalizer {
  158. denormalize(data: any): any,
  159. }