interfaces.d.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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, 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. modules?: Array<string>,
  110. hasChildren?: boolean,
  111. showAdherentList?: boolean,
  112. networks: Array<string>,
  113. parents: Array<organizationState>,
  114. }
  115. interface OrganizationStore extends Store<{profile:{organization: organizationState}}> {}
  116. interface AnyJson extends Record<string, any> {}
  117. interface AnyStore extends Store<any> {}
  118. interface EnumChoice {
  119. value: string,
  120. label: string
  121. }
  122. interface UrlArgs {
  123. readonly type: QUERY_TYPE,
  124. readonly url?: string,
  125. readonly baseUrl?: string,
  126. readonly enumType?: string,
  127. readonly model?: typeof Model,
  128. readonly rootModel?: typeof Model,
  129. readonly id?: any,
  130. readonly rootId?: number
  131. readonly showProgress?: boolean
  132. readonly hook?: string
  133. }
  134. interface ImageArgs {
  135. readonly id: number,
  136. readonly height: number,
  137. readonly width: number
  138. }
  139. interface DataProviderArgs extends UrlArgs {
  140. imgArgs?: ImageArgs
  141. }
  142. interface DataPersisterArgs extends UrlArgs {
  143. data?: AnyJson
  144. }
  145. interface DataDeleterArgs extends UrlArgs {}
  146. interface EnumChoices extends Array<EnumChoice> {}
  147. interface DataManager {
  148. initCtx(ctx: Context): void,
  149. invoke(args: UrlArgs): Promise<any>,
  150. }
  151. interface HookProvider {
  152. invoke(args: DataProviderArgs): Promise<any>,
  153. }
  154. interface HookPersister {
  155. invoke(args: DataPersisterArgs): Promise<any>,
  156. }
  157. interface HookDeleter {
  158. invoke(args: DataDeleterArgs): Promise<any>,
  159. }
  160. interface Processor {
  161. process(data: AnyJson): Promise<any>
  162. }
  163. interface Normalizer {
  164. normalize(args: DataPersisterArgs): any,
  165. }
  166. interface Denormalizer {
  167. denormalize(data: any): any,
  168. }
  169. interface DolibarrContractLine {
  170. id: number,
  171. contractId: number,
  172. dateStart: Date,
  173. dateEnd: Date,
  174. serviceRef: string,
  175. serviceLabel: string
  176. }
  177. interface DolibarrContract {
  178. ref: string,
  179. socId: number,
  180. lines: Array<DolibarrContractLine>
  181. }
  182. interface DolibarrBill {
  183. id: number,
  184. ref: string,
  185. socId: number,
  186. date: Date,
  187. taxExcludedAmount: number,
  188. taxIncludedAmount: number,
  189. paid: boolean
  190. }
  191. interface DolibarrAccount {
  192. organizationId: number,
  193. socId: number,
  194. clientNumber: string,
  195. product: 'PRODUCT_ARTIST' | 'PRODUCT_ARTIST_PREMIUM' | 'PRODUCT_SCHOOL' |
  196. 'PRODUCT_SCHOOL_PREMIUM' | 'PRODUCT_MANAGER',
  197. contract: DolibarrContract,
  198. bills: Array<DolibarrBill>
  199. }
  200. interface MobytUserStatus {
  201. organizationId: number,
  202. active: boolean,
  203. amount: number,
  204. money: number
  205. }