interfaces.d.ts 6.3 KB

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