types.ts 4.2 KB

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