interfaces.d.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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, METADATA_TYPE, 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. actions?: ItemsMenu,
  27. }
  28. interface ItemsMenu extends Array<ItemMenu> {}
  29. interface Menu {
  30. getMenu : () => ItemMenu | null,
  31. getHeaderMenu : () => ItemMenu | null,
  32. }
  33. interface AbilitiesType {
  34. action: ABILITIES,
  35. subject: string,
  36. /** an array of fields to which user has (or not) access */
  37. fields?: string[]
  38. /** an object of conditions which restricts the rule scope */
  39. conditions?: any
  40. /** indicates whether rule allows or forbids something */
  41. inverted?: boolean
  42. /** message which explains why rule is forbidden */
  43. reason?: string
  44. }
  45. interface formState {
  46. dirty: boolean,
  47. showConfirmToLeave: boolean,
  48. goAfterLeave: string
  49. }
  50. interface alert {
  51. type: TYPE_ALERT,
  52. message: string
  53. }
  54. interface pageState {
  55. alerts: Array<alert>,
  56. }
  57. interface baseAccessState {
  58. id: number,
  59. name: string,
  60. givenName: string,
  61. gender: GENDER,
  62. avatarId: number
  63. }
  64. interface Historical {
  65. future?: boolean,
  66. past?: boolean,
  67. present?: boolean,
  68. dateStart?: string,
  69. dateEnd?: string
  70. }
  71. interface accessState extends baseAccessState {
  72. bearer: string,
  73. switchId: number,
  74. activityYear: number,
  75. historical: Historical,
  76. roles: Array<string>,
  77. abilities: Array<AbilitiesType>,
  78. isAdminAccess: boolean,
  79. isAdmin: boolean,
  80. isAdministratifManager: boolean,
  81. isPedagogicManager: boolean,
  82. isFinancialManager: boolean,
  83. isCaMember: boolean,
  84. isStudent: boolean,
  85. isTeacher: boolean,
  86. isMember: boolean,
  87. isOther: boolean,
  88. isGuardian: boolean,
  89. isPayor: boolean,
  90. hasLateralMenu: boolean,
  91. hasConfigurationMenu: boolean,
  92. hasAccessesMenu: boolean,
  93. hasFamilyMenu: boolean,
  94. multiAccesses: Array<baseOrganizationState>,
  95. familyAccesses: Array<baseAccessState>,
  96. originalAccess: baseAccessState
  97. }
  98. interface AccessStore extends Store<{profile:{access: accessState}}> {}
  99. interface baseOrganizationState {
  100. id: number,
  101. name: string,
  102. website?: string,
  103. subDomain?: string
  104. }
  105. interface organizationState extends baseOrganizationState {
  106. id: number,
  107. name: string,
  108. product?: string,
  109. modules?: Array<string>,
  110. hasChildren?: boolean,
  111. showAdherentList?: boolean,
  112. networks: Array<string>,
  113. parents: Array<organizationState>,
  114. }
  115. interface OrganizationStore extends Store<{profile:{organization: organizationState}}> {}
  116. interface AnyJson extends Record<string, any> {}
  117. interface AnyStore extends Store<any> {}
  118. interface EnumChoice {
  119. value: string,
  120. label: string
  121. }
  122. interface UrlArgs {
  123. readonly type: QUERY_TYPE,
  124. readonly url?: string,
  125. readonly baseUrl?: string,
  126. readonly enumType?: string,
  127. readonly model?: typeof Model,
  128. readonly rootModel?: typeof Model,
  129. readonly id?: any,
  130. readonly idTemp?: any,
  131. readonly rootId?: number,
  132. readonly showProgress?: boolean,
  133. readonly hook?: string
  134. }
  135. interface ImageArgs {
  136. readonly id: number,
  137. readonly height: number,
  138. readonly width: number
  139. }
  140. interface ListArgs {
  141. readonly itemsPerPage: number,
  142. readonly page: number
  143. }
  144. interface DataProviderArgs extends UrlArgs {
  145. imgArgs?: ImageArgs,
  146. listArgs?: ListArgs,
  147. }
  148. interface DataPersisterArgs extends UrlArgs {
  149. data?: AnyJson
  150. }
  151. interface DataDeleterArgs extends UrlArgs {}
  152. interface EnumChoices extends Array<EnumChoice> {}
  153. interface DataManager {
  154. initCtx(ctx: Context): void,
  155. invoke(args: UrlArgs): Promise<any>,
  156. }
  157. interface HookProvider {
  158. invoke(args: DataProviderArgs): Promise<any>,
  159. }
  160. interface HookPersister {
  161. invoke(args: DataPersisterArgs): Promise<any>,
  162. }
  163. interface HookDeleter {
  164. invoke(args: DataDeleterArgs): Promise<any>,
  165. }
  166. interface Processor {
  167. process(data: AnyJson): Promise<any>
  168. }
  169. interface Normalizer {
  170. normalize(args: DataPersisterArgs): any,
  171. }
  172. interface Denormalizer {
  173. denormalize(data: any): any,
  174. }
  175. interface DolibarrContractLine {
  176. id: number,
  177. contractId: number,
  178. dateStart: Date,
  179. dateEnd: Date,
  180. serviceRef: string,
  181. serviceLabel: string
  182. }
  183. interface DolibarrContract {
  184. ref: string,
  185. socId: number,
  186. lines: Array<DolibarrContractLine>
  187. }
  188. interface DolibarrBill {
  189. id: number,
  190. ref: string,
  191. socId: number,
  192. date: Date,
  193. taxExcludedAmount: number,
  194. taxIncludedAmount: number,
  195. paid: boolean
  196. }
  197. interface DolibarrAccount {
  198. organizationId: number,
  199. socId: number,
  200. clientNumber: string,
  201. product: 'PRODUCT_ARTIST' | 'PRODUCT_ARTIST_PREMIUM' | 'PRODUCT_SCHOOL' |
  202. 'PRODUCT_SCHOOL_PREMIUM' | 'PRODUCT_MANAGER',
  203. contract: DolibarrContract,
  204. bills: Array<DolibarrBill>
  205. }
  206. interface MobytUserStatus {
  207. organizationId: number,
  208. active: boolean,
  209. amount: number,
  210. money: number
  211. }
  212. interface ApiResponse{
  213. data: AnyJson,
  214. metadata: HydraMetadata
  215. }
  216. interface HydraMetadata {
  217. readonly totalItems?: number,
  218. firstPage?: number,
  219. lastPage?: number,
  220. nextPage?: number,
  221. previousPage?: number,
  222. type?: METADATA_TYPE
  223. }