interfaces.d.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. }
  123. interface organizationState extends baseOrganizationState {
  124. id: number,
  125. parametersId: number,
  126. name: string,
  127. product?: string,
  128. currentActivityYear?: number,
  129. modules?: Array<string>,
  130. hasChildren?: boolean,
  131. showAdherentList?: boolean,
  132. legalStatus?: string,
  133. networks: Array<string>,
  134. parents: Array<organizationState>,
  135. }
  136. interface OrganizationStore extends Store<{profile:{organization: organizationState}}> {}
  137. interface AnyJson extends Record<string, any> {}
  138. interface AnyStore extends Store<any> {}
  139. interface EnumChoice {
  140. value: string,
  141. label: string
  142. }
  143. interface UrlArgs {
  144. readonly type: QUERY_TYPE,
  145. readonly url?: string,
  146. readonly baseUrl?: string,
  147. readonly enumType?: string,
  148. readonly model?: typeof Model,
  149. readonly rootModel?: typeof Model,
  150. readonly id?: any,
  151. readonly idTemp?: any,
  152. readonly rootId?: number,
  153. readonly showProgress?: boolean,
  154. readonly hook?: string,
  155. readonly params?: AnyJson
  156. }
  157. interface ImageArgs {
  158. readonly id: number,
  159. readonly height: number,
  160. readonly width: number
  161. }
  162. interface FileArgs {
  163. readonly fileId: number
  164. }
  165. interface Filter{
  166. readonly key: string,
  167. readonly value: string|boolean|number
  168. }
  169. interface ListArgs {
  170. readonly itemsPerPage?: number,
  171. readonly page?: number
  172. readonly filters?: Array<Filter>
  173. }
  174. interface DataProviderArgs extends UrlArgs {
  175. imgArgs?: ImageArgs,
  176. listArgs?: ListArgs,
  177. fileArgs?: FileArgs,
  178. }
  179. interface DataPersisterArgs extends UrlArgs {
  180. data?: AnyJson,
  181. query?: Query,
  182. file?: string
  183. }
  184. interface DataDeleterArgs extends UrlArgs {}
  185. interface EnumChoices extends Array<EnumChoice> {}
  186. interface DataManager {
  187. initCtx(ctx: Context): void,
  188. invoke(args: UrlArgs): Promise<any>,
  189. }
  190. interface HookProvider {
  191. invoke(args: DataProviderArgs): Promise<any>,
  192. }
  193. interface HookPersister {
  194. invoke(args: DataPersisterArgs): Promise<any>,
  195. }
  196. interface HookDeleter {
  197. invoke(args: DataDeleterArgs): Promise<any>,
  198. }
  199. interface Processor {
  200. process(data: AnyJson): Promise<any>
  201. }
  202. interface Normalizer {
  203. normalize(args: DataPersisterArgs): any,
  204. }
  205. interface Denormalizer {
  206. denormalize(data: any): any,
  207. }
  208. interface DolibarrContractLine {
  209. id: number,
  210. contractId: number,
  211. dateStart: Date,
  212. dateEnd: Date,
  213. serviceRef: string,
  214. serviceLabel: string
  215. }
  216. interface DolibarrContract {
  217. ref: string,
  218. socId: number,
  219. lines: Array<DolibarrContractLine>
  220. }
  221. interface DolibarrBill {
  222. id: number,
  223. ref: string,
  224. socId: number,
  225. date: Date,
  226. taxExcludedAmount: number,
  227. taxIncludedAmount: number,
  228. paid: boolean
  229. }
  230. interface DolibarrAccount {
  231. organizationId: number,
  232. socId: number,
  233. clientNumber: string,
  234. product: 'PRODUCT_ARTIST' | 'PRODUCT_ARTIST_PREMIUM' | 'PRODUCT_SCHOOL' |
  235. 'PRODUCT_SCHOOL_PREMIUM' | 'PRODUCT_MANAGER',
  236. contract: DolibarrContract,
  237. bills: Array<DolibarrBill>
  238. }
  239. interface MobytUserStatus {
  240. organizationId: number,
  241. active: boolean,
  242. amount: number,
  243. money: number
  244. }
  245. interface ApiResponse{
  246. data: AnyJson,
  247. metadata: HydraMetadata
  248. }
  249. interface HydraMetadata {
  250. readonly totalItems?: number,
  251. firstPage?: number,
  252. lastPage?: number,
  253. nextPage?: number,
  254. previousPage?: number,
  255. type?: METADATA_TYPE
  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. }