interfaces.d.ts 5.8 KB

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