interfaces.d.ts 6.5 KB

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