interfaces.d.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. import { Model } 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. }
  141. interface ImageArgs {
  142. readonly id: number,
  143. readonly height: number,
  144. readonly width: number
  145. }
  146. interface ListArgs {
  147. readonly itemsPerPage: number,
  148. readonly page: number
  149. }
  150. interface DataProviderArgs extends UrlArgs {
  151. imgArgs?: ImageArgs,
  152. listArgs?: ListArgs,
  153. }
  154. interface DataPersisterArgs extends UrlArgs {
  155. data?: AnyJson
  156. }
  157. interface DataDeleterArgs extends UrlArgs {}
  158. interface EnumChoices extends Array<EnumChoice> {}
  159. interface DataManager {
  160. initCtx(ctx: Context): void,
  161. invoke(args: UrlArgs): Promise<any>,
  162. }
  163. interface HookProvider {
  164. invoke(args: DataProviderArgs): Promise<any>,
  165. }
  166. interface HookPersister {
  167. invoke(args: DataPersisterArgs): Promise<any>,
  168. }
  169. interface HookDeleter {
  170. invoke(args: DataDeleterArgs): Promise<any>,
  171. }
  172. interface Processor {
  173. process(data: AnyJson): Promise<any>
  174. }
  175. interface Normalizer {
  176. normalize(args: DataPersisterArgs): any,
  177. }
  178. interface Denormalizer {
  179. denormalize(data: any): any,
  180. }
  181. interface DolibarrContractLine {
  182. id: number,
  183. contractId: number,
  184. dateStart: Date,
  185. dateEnd: Date,
  186. serviceRef: string,
  187. serviceLabel: string
  188. }
  189. interface DolibarrContract {
  190. ref: string,
  191. socId: number,
  192. lines: Array<DolibarrContractLine>
  193. }
  194. interface DolibarrBill {
  195. id: number,
  196. ref: string,
  197. socId: number,
  198. date: Date,
  199. taxExcludedAmount: number,
  200. taxIncludedAmount: number,
  201. paid: boolean
  202. }
  203. interface DolibarrAccount {
  204. organizationId: number,
  205. socId: number,
  206. clientNumber: string,
  207. product: 'PRODUCT_ARTIST' | 'PRODUCT_ARTIST_PREMIUM' | 'PRODUCT_SCHOOL' |
  208. 'PRODUCT_SCHOOL_PREMIUM' | 'PRODUCT_MANAGER',
  209. contract: DolibarrContract,
  210. bills: Array<DolibarrBill>
  211. }
  212. interface MobytUserStatus {
  213. organizationId: number,
  214. active: boolean,
  215. amount: number,
  216. money: number
  217. }
  218. interface ApiResponse{
  219. data: AnyJson,
  220. metadata: HydraMetadata
  221. }
  222. interface HydraMetadata {
  223. readonly totalItems?: number,
  224. firstPage?: number,
  225. lastPage?: number,
  226. nextPage?: number,
  227. previousPage?: number,
  228. type?: METADATA_TYPE
  229. }