types.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. relationQuality?: boolean
  47. metadataConfig?: string
  48. typeName?: string
  49. updateTime?: string
  50. }
  51. type IViewTemp = Omit<IViewBase, 'sourceName'>
  52. export interface IView extends IViewTemp {
  53. sql: string
  54. model: string
  55. variable: string
  56. config: string
  57. projectId: number
  58. source?: ISourceSimple
  59. sourceId: number
  60. roles: IViewRoleRaw[]
  61. }
  62. type IViewTemp2 = Omit<Omit<Omit<IView, 'model'>, 'variable'>, 'roles'>
  63. export interface IFormedView extends IViewTemp2 {
  64. model: IViewModel
  65. variable: IViewVariable[]
  66. roles: IViewRole[]
  67. }
  68. export interface ISqlValidation {
  69. code: number
  70. message: string
  71. }
  72. export interface IViewLoading {
  73. view: boolean
  74. table: boolean
  75. modal: boolean
  76. execute: boolean
  77. copy: boolean
  78. }
  79. export interface IExecuteSqlParams {
  80. sourceId: number
  81. sql: string
  82. limit: number
  83. variables: IViewVariableBase[]
  84. }
  85. export interface ISqlColumn {
  86. name: string
  87. type: SqlTypes
  88. }
  89. export interface IExecuteSqlResponse {
  90. columns: ISqlColumn[]
  91. totalCount: number
  92. resultList: Array<{ [key: string]: string | number }>
  93. }
  94. export interface IViewModelProps {
  95. name: string
  96. sqlType: SqlTypes
  97. visualType: ViewModelVisualTypes
  98. modelType: ViewModelTypes
  99. }
  100. export type IKeyOfViewModelProps = keyof Omit<IViewModelProps, 'name'>
  101. export interface IViewModel {
  102. [name: string]: Omit<IViewModelProps, 'name'>
  103. }
  104. interface IViewVariableChannel {
  105. bizId: number
  106. name: string
  107. tenantId: number
  108. }
  109. interface IViewVariableBase {
  110. name: string
  111. type: ViewVariableTypes
  112. valueType: ViewVariableValueTypes
  113. defaultValues: Array<string | number | boolean>
  114. channel?: IViewVariableChannel
  115. udf: boolean
  116. }
  117. export interface IViewVariable extends IViewVariableBase {
  118. key: string
  119. alias: string
  120. fromService: boolean
  121. }
  122. export interface IViewRoleRaw {
  123. roleId: number
  124. columnAuth: string
  125. rowAuth: string
  126. }
  127. export interface IViewRoleRowAuth {
  128. name: string
  129. values: Array<string | number | boolean>
  130. enable: boolean
  131. }
  132. export interface IViewRole {
  133. roleId: number
  134. /**
  135. * view columns name
  136. * @type {string[]}
  137. * @memberof IViewRole
  138. */
  139. columnAuth: string[]
  140. /**
  141. * query variable values
  142. * @type {(Array<string | number>)}
  143. * @memberof IViewRole
  144. */
  145. rowAuth: IViewRoleRowAuth[]
  146. }
  147. export interface IViewInfo {
  148. model: IViewModel
  149. variable: IViewVariable[]
  150. roles: IViewRole[]
  151. }
  152. export interface IFormedViews {
  153. [viewId: string]: IFormedView
  154. }
  155. export interface IShareFormedViews {
  156. [viewId: string]: Pick<IFormedView, 'name' | 'model' | 'variable'> & {
  157. dataToken: string
  158. }
  159. }
  160. export type IDacChannel = string
  161. export interface IDacTenant {
  162. id: number
  163. name: string
  164. }
  165. export interface IDacBiz {
  166. id: number
  167. name: string
  168. }
  169. export interface IViewQueryResponse {
  170. columns: Array<{ name: string; type: SqlTypes }>
  171. pageNo: number
  172. pageSize: number
  173. totalCount: number
  174. resultList: any[]
  175. }
  176. export interface IViewState {
  177. views: IViewBase[]
  178. formedViews: IFormedViews
  179. editingView: IView
  180. editingViewInfo: IViewInfo
  181. sources: ISourceBase[]
  182. schema: ISchema
  183. sqlValidation: ISqlValidation
  184. sqlDataSource: IExecuteSqlResponse
  185. sqlLimit: number
  186. loading: IViewLoading
  187. channels: IDacChannel[]
  188. tenants: IDacTenant[]
  189. bizs: IDacBiz[]
  190. cancelTokenSources: CancelTokenSource[]
  191. isLastExecuteWholeSql: boolean
  192. }