interfaces.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import {Model} from "@vuex-orm/core";
  2. import {Ability} from "@casl/ability";
  3. import DataPersister from "~/services/dataPersister/dataPersister";
  4. import DataProvider from "~/services/dataProvider/dataProvider";
  5. import DataDeleter from "~/services/dataDeleter/dataDeleter";
  6. import {Store} from "vuex";
  7. import {ABILITIES, GENDER, QUERY_TYPE, TYPE_ALERT} from "~/types/enums";
  8. import {Context} from "@nuxt/types/app";
  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 accessState extends baseAccessState{
  64. bearer: string,
  65. switchId: number,
  66. activityYear: number,
  67. roles: Array<string>,
  68. abilities: Array<AbilitiesType>,
  69. isAdminAccess: boolean,
  70. isAdmin: boolean,
  71. isAdministratifManager: boolean,
  72. isPedagogicManager: boolean,
  73. isFinancialManager: boolean,
  74. isCaMember: boolean,
  75. isStudent: boolean,
  76. isTeacher: boolean,
  77. isMember: boolean,
  78. isOther: boolean,
  79. hasLateralMenu: boolean,
  80. hasConfigurationMenu: boolean,
  81. hasAccessesMenu: boolean,
  82. hasFamilyMenu: boolean,
  83. multiAccesses: Array<baseOrganizationState>,
  84. familyAccesses: Array<baseAccessState>,
  85. originalAccess: baseAccessState
  86. }
  87. interface AccessStore extends Store<{profile:{access:accessState}}> {}
  88. interface baseOrganizationState {
  89. id: number,
  90. name: string,
  91. website?: string,
  92. subDomain?: string
  93. }
  94. interface organizationState extends baseOrganizationState{
  95. id: number,
  96. name: string,
  97. product?: string,
  98. modules?: Array<string>,
  99. hasChildren?: boolean,
  100. networks: Array<string>,
  101. parents: Array<organizationState>,
  102. }
  103. interface OrganizationStore extends Store<{profile:{organization:organizationState}}> {}
  104. interface AnyJson extends Record<string, any> {}
  105. interface AnyStore extends Store<any> {}
  106. interface EnumChoice {
  107. value: string,
  108. label: string
  109. }
  110. interface EnumChoices extends Array<EnumChoice> {}
  111. interface UrlArgs {
  112. readonly type: QUERY_TYPE,
  113. readonly url?:string,
  114. readonly enumType?:string,
  115. readonly model?: typeof Model,
  116. readonly root_model?: typeof Model,
  117. readonly id?:any,
  118. readonly root_id?:number
  119. }
  120. interface DataPersisterArgs extends UrlArgs{
  121. data?:AnyJson,
  122. readonly hook?:string
  123. }
  124. interface DataDeleterArgs extends UrlArgs{
  125. readonly hook?:string
  126. }
  127. interface HookPersister{
  128. invoke(args:DataPersisterArgs): Promise<any>,
  129. }
  130. interface HookDeleter{
  131. invoke(args:DataDeleterArgs): Promise<any>,
  132. }
  133. interface DataProviderArgs extends UrlArgs{
  134. readonly hook?:string
  135. }
  136. interface HookProvider{
  137. invoke(args:DataProviderArgs): Promise<any>,
  138. }
  139. interface Provider{
  140. invoke(data: AnyJson): Promise<any>,
  141. }
  142. interface Denormalizer{
  143. denormalize(data:any): any,
  144. }
  145. interface Normalizer{
  146. normalize(args:DataPersisterArgs): any,
  147. }
  148. interface DataProviders{
  149. initCtx(ctx:Context): void,
  150. invoke(args:DataProviderArgs): Promise<any>,
  151. }