interfaces.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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, 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 accessState {
  57. bearer: string,
  58. accessId: number,
  59. name: string,
  60. givenName: string,
  61. roles: Array<string>,
  62. abilities: Array<AbilitiesType>,
  63. isAdminAccess: boolean,
  64. isAdmin: boolean,
  65. isAdministratifManager: boolean,
  66. isPedagogicManager: boolean,
  67. isFinancialManager: boolean,
  68. isCaMember: boolean,
  69. isStudent: boolean,
  70. isTeacher: boolean,
  71. isMember: boolean,
  72. isOther: boolean,
  73. hasLateralMenu: boolean,
  74. hasConfigurationMenu: boolean,
  75. hasAccessesMenu: boolean,
  76. hasFamilyMenu: boolean
  77. }
  78. interface AccessStore extends Store<{profile:{access:accessState}}> {}
  79. interface organizationState {
  80. id: number,
  81. name: string,
  82. product?: string,
  83. modules?: Array<string>,
  84. hasChildren?: boolean,
  85. networks: Array<string>,
  86. website?: string,
  87. subDomain?: string,
  88. parents: Array<organizationState>,
  89. }
  90. interface OrganizationStore extends Store<{profile:{organization:organizationState}}> {}
  91. interface AnyJson extends Record<string, any> {}
  92. interface AnyStore extends Store<any> {}
  93. interface EnumChoice {
  94. value: string,
  95. label: string
  96. }
  97. interface EnumChoices extends Array<EnumChoice> {}
  98. interface UrlArgs {
  99. readonly type: QUERY_TYPE,
  100. readonly url?:string,
  101. readonly enumType?:string,
  102. readonly model?: typeof Model,
  103. readonly root_model?: typeof Model,
  104. readonly id?:any,
  105. readonly root_id?:number
  106. }
  107. interface DataPersisterArgs extends UrlArgs{
  108. data?:AnyJson,
  109. readonly hook?:string
  110. }
  111. interface DataDeleterArgs extends UrlArgs{
  112. readonly hook?:string
  113. }
  114. interface HookPersister{
  115. invoke(args:DataPersisterArgs): Promise<any>,
  116. }
  117. interface HookDeleter{
  118. invoke(args:DataDeleterArgs): Promise<any>,
  119. }
  120. interface DataProviderArgs extends UrlArgs{
  121. readonly hook?:string
  122. }
  123. interface HookProvider{
  124. invoke(args:DataProviderArgs): Promise<any>,
  125. }
  126. interface Provider{
  127. invoke(data: AnyJson): Promise<any>,
  128. }
  129. interface Denormalizer{
  130. denormalize(data:any): any,
  131. }
  132. interface Normalizer{
  133. normalize(args:DataPersisterArgs): any,
  134. }
  135. interface DataProviders{
  136. initCtx(ctx:Context): void,
  137. invoke(args:DataProviderArgs): Promise<any>,
  138. }