interfaces.d.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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 AnyStore = Store<any>
  148. interface EnumChoice {
  149. value: string
  150. label: string
  151. }
  152. interface UrlArgs {
  153. readonly type: QUERY_TYPE
  154. readonly url?: string
  155. readonly baseUrl?: string
  156. readonly enumType?: string
  157. readonly model?: typeof Model
  158. readonly rootModel?: typeof Model
  159. readonly id?: any
  160. readonly idTemp?: any
  161. readonly rootId?: number
  162. readonly showProgress?: boolean
  163. readonly hook?: string
  164. readonly params?: AnyJson
  165. }
  166. interface ImageArgs {
  167. readonly id: number
  168. readonly height: number
  169. readonly width: number
  170. }
  171. interface FileArgs {
  172. readonly fileId: number
  173. }
  174. interface Filter {
  175. readonly key: string
  176. readonly value: string | boolean | number
  177. }
  178. interface ListArgs {
  179. readonly itemsPerPage?: number
  180. readonly page?: number
  181. readonly filters?: Array<Filter>
  182. }
  183. interface DataProviderArgs extends UrlArgs {
  184. imgArgs?: ImageArgs
  185. listArgs?: ListArgs
  186. fileArgs?: FileArgs
  187. }
  188. interface DataPersisterArgs extends UrlArgs {
  189. data?: AnyJson
  190. query?: Query
  191. file?: string
  192. }
  193. type DataDeleterArgs = UrlArgs
  194. type EnumChoices = Array<EnumChoice>
  195. interface DataManager {
  196. invoke(args: UrlArgs): Promise<any>
  197. }
  198. interface HookProvider {
  199. invoke(args: DataProviderArgs): Promise<any>
  200. }
  201. interface HookPersister {
  202. invoke(args: DataPersisterArgs): Promise<any>
  203. }
  204. interface HookDeleter {
  205. invoke(args: DataDeleterArgs): Promise<any>
  206. }
  207. interface Processor {
  208. process(data: AnyJson): Promise<any>
  209. }
  210. interface Normalizer {
  211. normalize(args: DataPersisterArgs): any
  212. }
  213. interface Denormalizer {
  214. denormalize(data: any): any
  215. }
  216. interface DolibarrContractLine {
  217. id: number
  218. contractId: number
  219. dateStart: Date
  220. dateEnd: Date
  221. serviceRef: string
  222. serviceLabel: string
  223. }
  224. interface DolibarrContract {
  225. ref: string
  226. socId: number
  227. lines: Array<DolibarrContractLine>
  228. }
  229. interface DolibarrBill {
  230. id: number
  231. ref: string
  232. socId: number
  233. date: Date
  234. taxExcludedAmount: number
  235. taxIncludedAmount: number
  236. paid: boolean
  237. }
  238. interface DolibarrAccount {
  239. organizationId: number
  240. socId: number
  241. clientNumber: string
  242. product:
  243. | 'PRODUCT_ARTIST'
  244. | 'PRODUCT_ARTIST_PREMIUM'
  245. | 'PRODUCT_SCHOOL'
  246. | 'PRODUCT_SCHOOL_PREMIUM'
  247. | 'PRODUCT_MANAGER'
  248. contract: DolibarrContract
  249. bills: Array<DolibarrBill>
  250. }
  251. interface MobytUserStatus {
  252. organizationId: number
  253. active: boolean
  254. amount: number
  255. money: number
  256. }
  257. interface MercureEntityUpdate {
  258. iri: string
  259. operation: 'create' | 'delete' | 'update'
  260. data: any
  261. }
  262. interface sseState {
  263. connected: boolean
  264. events: Array<MercureEntityUpdate>
  265. }