interfaces.d.ts 6.0 KB

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