interfaces.d.ts 3.3 KB

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