interfaces.d.ts 6.1 KB

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