interfaces.d.ts 2.9 KB

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