interfaces.d.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 baseAccessState {
  58. id: number,
  59. name: string,
  60. givenName: string,
  61. gender: GENDER,
  62. avatarId: number
  63. }
  64. interface Historical {
  65. future?: boolean,
  66. past?: boolean,
  67. present?: boolean,
  68. dateStart?: string,
  69. dateEnd?: string
  70. }
  71. interface accessState extends baseAccessState {
  72. bearer: string,
  73. switchId: number,
  74. activityYear: number,
  75. historical: Historical,
  76. roles: Array<string>,
  77. abilities: Array<AbilitiesType>,
  78. isAdminAccess: boolean,
  79. isAdmin: boolean,
  80. isAdministratifManager: boolean,
  81. isPedagogicManager: boolean,
  82. isFinancialManager: boolean,
  83. isCaMember: boolean,
  84. isStudent: boolean,
  85. isTeacher: boolean,
  86. isMember: boolean,
  87. isOther: boolean,
  88. isGuardian: boolean,
  89. isPayor: boolean,
  90. hasLateralMenu: boolean,
  91. hasConfigurationMenu: boolean,
  92. hasAccessesMenu: boolean,
  93. hasFamilyMenu: boolean,
  94. multiAccesses: Array<baseOrganizationState>,
  95. familyAccesses: Array<baseAccessState>,
  96. originalAccess: baseAccessState
  97. }
  98. interface AccessStore extends Store<{profile:{access: accessState}}> {}
  99. interface baseOrganizationState {
  100. id: number,
  101. name: string,
  102. website?: string,
  103. subDomain?: string
  104. }
  105. interface organizationState extends baseOrganizationState {
  106. id: number,
  107. name: string,
  108. product?: string,
  109. currentActivityYear?: number,
  110. modules?: Array<string>,
  111. hasChildren?: boolean,
  112. showAdherentList?: boolean,
  113. networks: Array<string>,
  114. parents: Array<organizationState>,
  115. }
  116. interface OrganizationStore extends Store<{profile:{organization: organizationState}}> {}
  117. interface AnyJson extends Record<string, any> {}
  118. interface AnyStore extends Store<any> {}
  119. interface EnumChoice {
  120. value: string,
  121. label: string
  122. }
  123. interface UrlArgs {
  124. readonly type: QUERY_TYPE,
  125. readonly url?: string,
  126. readonly baseUrl?: string,
  127. readonly enumType?: string,
  128. readonly model?: typeof Model,
  129. readonly rootModel?: typeof Model,
  130. readonly id?: any,
  131. readonly idTemp?: any,
  132. readonly rootId?: number,
  133. readonly showProgress?: boolean,
  134. readonly hook?: string
  135. }
  136. interface ImageArgs {
  137. readonly id: number,
  138. readonly height: number,
  139. readonly width: number
  140. }
  141. interface ListArgs {
  142. readonly itemsPerPage: number,
  143. readonly page: number
  144. }
  145. interface DataProviderArgs extends UrlArgs {
  146. imgArgs?: ImageArgs,
  147. listArgs?: ListArgs,
  148. }
  149. interface DataPersisterArgs extends UrlArgs {
  150. data?: AnyJson
  151. }
  152. interface DataDeleterArgs extends UrlArgs {}
  153. interface EnumChoices extends Array<EnumChoice> {}
  154. interface DataManager {
  155. initCtx(ctx: Context): void,
  156. invoke(args: UrlArgs): Promise<any>,
  157. }
  158. interface HookProvider {
  159. invoke(args: DataProviderArgs): Promise<any>,
  160. }
  161. interface HookPersister {
  162. invoke(args: DataPersisterArgs): Promise<any>,
  163. }
  164. interface HookDeleter {
  165. invoke(args: DataDeleterArgs): Promise<any>,
  166. }
  167. interface Processor {
  168. process(data: AnyJson): Promise<any>
  169. }
  170. interface Normalizer {
  171. normalize(args: DataPersisterArgs): any,
  172. }
  173. interface Denormalizer {
  174. denormalize(data: any): any,
  175. }
  176. interface DolibarrContractLine {
  177. id: number,
  178. contractId: number,
  179. dateStart: Date,
  180. dateEnd: Date,
  181. serviceRef: string,
  182. serviceLabel: string
  183. }
  184. interface DolibarrContract {
  185. ref: string,
  186. socId: number,
  187. lines: Array<DolibarrContractLine>
  188. }
  189. interface DolibarrBill {
  190. id: number,
  191. ref: string,
  192. socId: number,
  193. date: Date,
  194. taxExcludedAmount: number,
  195. taxIncludedAmount: number,
  196. paid: boolean
  197. }
  198. interface DolibarrAccount {
  199. organizationId: number,
  200. socId: number,
  201. clientNumber: string,
  202. product: 'PRODUCT_ARTIST' | 'PRODUCT_ARTIST_PREMIUM' | 'PRODUCT_SCHOOL' |
  203. 'PRODUCT_SCHOOL_PREMIUM' | 'PRODUCT_MANAGER',
  204. contract: DolibarrContract,
  205. bills: Array<DolibarrBill>
  206. }
  207. interface MobytUserStatus {
  208. organizationId: number,
  209. active: boolean,
  210. amount: number,
  211. money: number
  212. }
  213. interface ApiResponse{
  214. data: AnyJson,
  215. metadata: HydraMetadata
  216. }
  217. interface HydraMetadata {
  218. readonly totalItems?: number,
  219. firstPage?: number,
  220. lastPage?: number,
  221. nextPage?: number,
  222. previousPage?: number,
  223. type?: METADATA_TYPE
  224. }