interfaces.d.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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,
  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. initCtx(ctx: Context): void,
  186. invoke(args: UrlArgs): Promise<any>,
  187. }
  188. interface HookProvider {
  189. invoke(args: DataProviderArgs): Promise<any>,
  190. }
  191. interface HookPersister {
  192. invoke(args: DataPersisterArgs): Promise<any>,
  193. }
  194. interface HookDeleter {
  195. invoke(args: DataDeleterArgs): Promise<any>,
  196. }
  197. interface Processor {
  198. process(data: AnyJson): Promise<any>
  199. }
  200. interface Normalizer {
  201. normalize(args: DataPersisterArgs): any,
  202. }
  203. interface Denormalizer {
  204. denormalize(data: any): any,
  205. }
  206. interface DolibarrContractLine {
  207. id: number,
  208. contractId: number,
  209. dateStart: Date,
  210. dateEnd: Date,
  211. serviceRef: string,
  212. serviceLabel: string
  213. }
  214. interface DolibarrContract {
  215. ref: string,
  216. socId: number,
  217. lines: Array<DolibarrContractLine>
  218. }
  219. interface DolibarrBill {
  220. id: number,
  221. ref: string,
  222. socId: number,
  223. date: Date,
  224. taxExcludedAmount: number,
  225. taxIncludedAmount: number,
  226. paid: boolean
  227. }
  228. interface DolibarrAccount {
  229. organizationId: number,
  230. socId: number,
  231. clientNumber: string,
  232. product: 'PRODUCT_ARTIST' | 'PRODUCT_ARTIST_PREMIUM' | 'PRODUCT_SCHOOL' |
  233. 'PRODUCT_SCHOOL_PREMIUM' | 'PRODUCT_MANAGER',
  234. contract: DolibarrContract,
  235. bills: Array<DolibarrBill>
  236. }
  237. interface MobytUserStatus {
  238. organizationId: number,
  239. active: boolean,
  240. amount: number,
  241. money: number
  242. }
  243. interface ApiResponse{
  244. data: AnyJson,
  245. metadata: HydraMetadata
  246. }
  247. interface HydraMetadata {
  248. readonly totalItems?: number,
  249. firstPage?: number,
  250. lastPage?: number,
  251. nextPage?: number,
  252. previousPage?: number,
  253. type?: METADATA_TYPE
  254. }
  255. interface MercureEntityUpdate {
  256. iri: string,
  257. operation: 'create' | 'delete' | 'update',
  258. data: any
  259. }
  260. interface sseState {
  261. connected: boolean,
  262. events: Array<MercureEntityUpdate>,
  263. }