types.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import { SqlTypes } from 'app/globalConstants'
  21. import { ISourceSimple, ISourceBase, ISchema } from 'containers/Source/types'
  22. import {
  23. ViewModelTypes,
  24. ViewModelVisualTypes,
  25. ViewVariableTypes,
  26. ViewVariableValueTypes
  27. } from './constants'
  28. import { CancelTokenSource } from 'axios'
  29. export interface ICatalogue {
  30. description: string // 资源描述
  31. extConfig: string // 扩展信息
  32. id: number
  33. industry: string // 行业分类
  34. name: string // 资源名称
  35. originDept: string // 来源部门
  36. originSystem: string // 来源系统
  37. parentId: string
  38. projectId: number
  39. children?: ICatalogue[]
  40. }
  41. export interface IViewBase {
  42. id: number
  43. name: string
  44. description: string
  45. sourceName: string
  46. }
  47. type IViewTemp = Omit<IViewBase, 'sourceName'>
  48. export interface IView extends IViewTemp {
  49. sql: string
  50. model: string
  51. variable: string
  52. config: string
  53. projectId: number
  54. source?: ISourceSimple
  55. sourceId: number
  56. roles: IViewRoleRaw[]
  57. }
  58. type IViewTemp2 = Omit<Omit<Omit<IView, 'model'>, 'variable'>, 'roles'>
  59. export interface IFormedView extends IViewTemp2 {
  60. model: IViewModel
  61. variable: IViewVariable[]
  62. roles: IViewRole[]
  63. }
  64. export interface ISqlValidation {
  65. code: number
  66. message: string
  67. }
  68. export interface IViewLoading {
  69. view: boolean
  70. table: boolean
  71. modal: boolean
  72. execute: boolean
  73. copy: boolean
  74. }
  75. export interface IExecuteSqlParams {
  76. sourceId: number
  77. sql: string
  78. limit: number
  79. variables: IViewVariableBase[]
  80. }
  81. export interface ISqlColumn {
  82. name: string
  83. type: SqlTypes
  84. }
  85. export interface IExecuteSqlResponse {
  86. columns: ISqlColumn[]
  87. totalCount: number
  88. resultList: Array<{ [key: string]: string | number }>
  89. }
  90. export interface IViewModelProps {
  91. name: string
  92. sqlType: SqlTypes
  93. visualType: ViewModelVisualTypes
  94. modelType: ViewModelTypes
  95. }
  96. export type IKeyOfViewModelProps = keyof Omit<IViewModelProps, 'name'>
  97. export interface IViewModel {
  98. [name: string]: Omit<IViewModelProps, 'name'>
  99. }
  100. interface IViewVariableChannel {
  101. bizId: number
  102. name: string
  103. tenantId: number
  104. }
  105. interface IViewVariableBase {
  106. name: string
  107. type: ViewVariableTypes
  108. valueType: ViewVariableValueTypes
  109. defaultValues: Array<string | number | boolean>
  110. channel?: IViewVariableChannel
  111. udf: boolean
  112. }
  113. export interface IViewVariable extends IViewVariableBase {
  114. key: string
  115. alias: string
  116. fromService: boolean
  117. }
  118. export interface IViewRoleRaw {
  119. roleId: number
  120. columnAuth: string
  121. rowAuth: string
  122. }
  123. export interface IViewRoleRowAuth {
  124. name: string
  125. values: Array<string | number | boolean>
  126. enable: boolean
  127. }
  128. export interface IViewRole {
  129. roleId: number
  130. /**
  131. * view columns name
  132. * @type {string[]}
  133. * @memberof IViewRole
  134. */
  135. columnAuth: string[]
  136. /**
  137. * query variable values
  138. * @type {(Array<string | number>)}
  139. * @memberof IViewRole
  140. */
  141. rowAuth: IViewRoleRowAuth[]
  142. }
  143. export interface IViewInfo {
  144. model: IViewModel
  145. variable: IViewVariable[]
  146. roles: IViewRole[]
  147. }
  148. export interface IFormedViews {
  149. [viewId: string]: IFormedView
  150. }
  151. export interface IShareFormedViews {
  152. [viewId: string]: Pick<IFormedView, 'name' | 'model' | 'variable'> & {
  153. dataToken: string
  154. }
  155. }
  156. export type IDacChannel = string
  157. export interface IDacTenant {
  158. id: number
  159. name: string
  160. }
  161. export interface IDacBiz {
  162. id: number
  163. name: string
  164. }
  165. export interface IViewQueryResponse {
  166. columns: Array<{ name: string; type: SqlTypes }>
  167. pageNo: number
  168. pageSize: number
  169. totalCount: number
  170. resultList: any[]
  171. }
  172. export interface IViewState {
  173. views: IViewBase[]
  174. formedViews: IFormedViews
  175. editingView: IView
  176. editingViewInfo: IViewInfo
  177. sources: ISourceBase[]
  178. schema: ISchema
  179. sqlValidation: ISqlValidation
  180. sqlDataSource: IExecuteSqlResponse
  181. sqlLimit: number
  182. loading: IViewLoading
  183. channels: IDacChannel[]
  184. tenants: IDacTenant[]
  185. bizs: IDacBiz[]
  186. cancelTokenSources: CancelTokenSource[]
  187. isLastExecuteWholeSql: boolean
  188. }