interfaces.d.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. import { Model, Query } from 'pinia-orm'
  2. import { Ability } from '@casl/ability'
  3. import { Store } from 'pinia'
  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|null,
  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|null
  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|null,
  80. name: string|null,
  81. givenName: string|null,
  82. gender: GENDER|null,
  83. avatarId: number|null
  84. }
  85. interface OrignalAccessState extends baseAccessState {
  86. isSuperAdminAccess: boolean,
  87. organization: baseOrganizationState
  88. }
  89. interface accessState extends baseAccessState {
  90. bearer: string|null,
  91. switchId: number|null
  92. activityYear: number|null
  93. historical: Historical|Array<String>
  94. roles: Array<string>
  95. abilities: Array<AbilitiesType>
  96. isAdminAccess: boolean|null
  97. isSuperAdminAccess: boolean|null
  98. isAdmin: boolean|null
  99. isAdministratifManager: boolean|null
  100. isPedagogicManager: boolean|null
  101. isFinancialManager: boolean|null
  102. isCaMember: boolean|null
  103. isStudent: boolean|null
  104. isTeacher: boolean|null
  105. isMember: boolean|null
  106. isOther: boolean|null
  107. isGuardian: boolean|null
  108. isPayor: boolean|null
  109. hasLateralMenu: boolean|null
  110. hasConfigurationMenu: boolean|null
  111. hasAccessesMenu: boolean|null
  112. hasFamilyMenu: boolean|null
  113. multiAccesses: Array<baseOrganizationState>
  114. familyAccesses: Array<baseAccessState>
  115. originalAccess: OrignalAccessState|null
  116. }
  117. interface baseOrganizationState {
  118. id: number|null,
  119. name: string|null,
  120. website?: string|null
  121. }
  122. interface organizationState extends baseOrganizationState {
  123. id: number|null,
  124. parametersId: number|null,
  125. name: string|null,
  126. product?: string|null,
  127. currentActivityYear?: number|null,
  128. modules?: Array<string>,
  129. hasChildren?: boolean|null,
  130. showAdherentList?: boolean|null,
  131. legalStatus?: string|null,
  132. networks: Array<string>,
  133. parents: Array<baseOrganizationState>,
  134. }
  135. interface AnyJson extends Record<string, any> {}
  136. interface AnyStore extends Store<any> {}
  137. interface EnumChoice {
  138. value: string,
  139. label: string
  140. }
  141. interface UrlArgs {
  142. readonly type: QUERY_TYPE,
  143. readonly url?: string,
  144. readonly baseUrl?: string,
  145. readonly enumType?: string,
  146. readonly model?: typeof Model,
  147. readonly rootModel?: typeof Model,
  148. readonly id?: any,
  149. readonly idTemp?: any,
  150. readonly rootId?: number,
  151. readonly showProgress?: boolean,
  152. readonly hook?: string,
  153. readonly params?: AnyJson
  154. }
  155. interface ImageArgs {
  156. readonly id: number,
  157. readonly height: number,
  158. readonly width: number
  159. }
  160. interface FileArgs {
  161. readonly fileId: 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. fileArgs?: FileArgs,
  176. }
  177. interface DataPersisterArgs extends UrlArgs {
  178. data?: AnyJson,
  179. query?: Query,
  180. file?: string
  181. }
  182. interface DataDeleterArgs extends UrlArgs {}
  183. interface EnumChoices extends Array<EnumChoice> {}
  184. interface DataManager {
  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. }
  254. interface MercureEntityUpdate {
  255. iri: string,
  256. operation: 'create' | 'delete' | 'update',
  257. data: any
  258. }
  259. interface sseState {
  260. connected: boolean,
  261. events: Array<MercureEntityUpdate>,
  262. }