types.ts 4.2 KB

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